Bell 32V release origin/Bell-Release Bell-32V
authorTom London <tbl@research.uucp>
Thu, 3 May 1979 04:26:55 +0000 (23:26 -0500)
committerTom London <tbl@research.uucp>
Thu, 3 May 1979 04:26:55 +0000 (23:26 -0500)
Snapshot of the completed development branch

Synthesized-from: 32v

1990 files changed:
bin/1 [deleted file]
bin/calendar [deleted file]
bin/diff3 [deleted file]
bin/false [deleted file]
bin/lint [deleted file]
bin/lookbib [deleted file]
bin/lorder [deleted file]
bin/man [deleted file]
bin/nohup [deleted file]
bin/pcc [deleted file]
bin/plot [deleted file]
bin/spell [deleted file]
bin/struct [deleted file]
bin/true [deleted file]
dev/makefile [deleted file]
etc/ddate [deleted file]
etc/group [deleted file]
etc/passwd [deleted file]
etc/rc [deleted file]
etc/ttys [deleted file]
etc/utmp [deleted file]
usr/adm/dummy [new file with mode: 0644]
usr/dict/papers/Ind.ic
usr/dict/papers/Rbstjissue [new file with mode: 0644]
usr/dict/words
usr/doc/REFS [new file with mode: 0644]
usr/doc/adb/dummy [new file with mode: 0644]
usr/doc/adb/tut [deleted file]
usr/doc/adb/tut1 [deleted file]
usr/doc/assembler [deleted file]
usr/doc/ctour/ios.r [new file with mode: 0644]
usr/doc/ctour/newstuff [new file with mode: 0644]
usr/doc/f77
usr/doc/index [deleted file]
usr/doc/learn/p0 [deleted file]
usr/doc/learn/p2 [deleted file]
usr/doc/learn/p3 [deleted file]
usr/doc/learn/p4 [deleted file]
usr/doc/learn/p5 [deleted file]
usr/doc/learn/p6 [deleted file]
usr/doc/learn/p7 [deleted file]
usr/doc/refer/pubuse
usr/doc/refer/refer
usr/doc/regen
usr/doc/run
usr/doc/scope [deleted file]
usr/doc/setup
usr/doc/summary/hel.mac [deleted file]
usr/doc/summary/hel0 [deleted file]
usr/doc/summary/hel1 [deleted file]
usr/doc/summary/hel2 [deleted file]
usr/doc/summary/hel3 [deleted file]
usr/doc/summary/hel4 [deleted file]
usr/doc/summary/hel5 [deleted file]
usr/doc/summary/hel6 [deleted file]
usr/doc/summary/vhel.mac [new file with mode: 0644]
usr/doc/summary/vhel0 [new file with mode: 0644]
usr/doc/summary/vhel1 [new file with mode: 0644]
usr/doc/summary/vhel2 [new file with mode: 0644]
usr/doc/summary/vhel3 [new file with mode: 0644]
usr/doc/summary/vhel4 [new file with mode: 0644]
usr/doc/summary/vhel5 [new file with mode: 0644]
usr/doc/summary/vhel6 [new file with mode: 0644]
usr/doc/tbl
usr/games/ching.d/log [new file with mode: 0644]
usr/games/lib/backrules [new file with mode: 0644]
usr/games/lib/fortunes
usr/games/quiz.k/africa [deleted file]
usr/games/quiz.k/america [deleted file]
usr/games/quiz.k/areas [deleted file]
usr/games/quiz.k/arith [deleted file]
usr/games/quiz.k/asia [deleted file]
usr/games/quiz.k/babies [deleted file]
usr/games/quiz.k/bard [deleted file]
usr/games/quiz.k/chinese [deleted file]
usr/games/quiz.k/collectives [deleted file]
usr/games/quiz.k/ed [deleted file]
usr/games/quiz.k/elements [deleted file]
usr/games/quiz.k/europe [deleted file]
usr/games/quiz.k/greek [deleted file]
usr/games/quiz.k/inca [deleted file]
usr/games/quiz.k/index [deleted file]
usr/games/quiz.k/latin [deleted file]
usr/games/quiz.k/locomotive [deleted file]
usr/games/quiz.k/midearth [deleted file]
usr/games/quiz.k/morse [deleted file]
usr/games/quiz.k/murders [deleted file]
usr/games/quiz.k/poetry [deleted file]
usr/games/quiz.k/posneg [deleted file]
usr/games/quiz.k/pres [deleted file]
usr/games/quiz.k/province [deleted file]
usr/games/quiz.k/seq-easy [deleted file]
usr/games/quiz.k/seq-hard [deleted file]
usr/games/quiz.k/sexes [deleted file]
usr/games/quiz.k/sov [deleted file]
usr/games/quiz.k/spell [deleted file]
usr/games/quiz.k/state [deleted file]
usr/games/quiz.k/trek [deleted file]
usr/games/quiz.k/ucc [deleted file]
usr/games/ttt.k [deleted file]
usr/games/words [deleted file]
usr/include/a.out.h
usr/include/core.h
usr/include/ctype.h
usr/include/dir.h [new file with mode: 0644]
usr/include/dk.h
usr/include/execargs.h
usr/include/ident.h
usr/include/math.h
usr/include/mp.h
usr/include/saio.h [new file with mode: 0644]
usr/include/setjmp.h
usr/include/sgtty.h
usr/include/signal.h
usr/include/stat.h [new file with mode: 0644]
usr/include/stdio.h
usr/include/sys.s
usr/include/sys/acct.h [new file with mode: 0644]
usr/include/sys/callo.h [new file with mode: 0644]
usr/include/sys/chan.h [new file with mode: 0644]
usr/include/sys/conf.h
usr/include/sys/dir.h [new file with mode: 0644]
usr/include/sys/fblk.h [new file with mode: 0644]
usr/include/sys/file.h [new file with mode: 0644]
usr/include/sys/filsys.h [new file with mode: 0644]
usr/include/sys/ino.h [new file with mode: 0644]
usr/include/sys/inode.h [new file with mode: 0644]
usr/include/sys/mount.h [new file with mode: 0644]
usr/include/sys/pack.h [new file with mode: 0644]
usr/include/sys/pcb.h [new file with mode: 0755]
usr/include/sys/pk.p [new file with mode: 0644]
usr/include/sys/prim.h [new file with mode: 0644]
usr/include/sys/psl.h [new file with mode: 0755]
usr/include/sys/reg.h [new file with mode: 0644]
usr/include/sys/seg.h [new file with mode: 0644]
usr/include/sys/stat.h [new file with mode: 0644]
usr/include/sys/timeb.h [new file with mode: 0644]
usr/include/sys/types.h [new file with mode: 0644]
usr/include/sys/user.h [new file with mode: 0644]
usr/include/whoami.h [deleted file]
usr/lib/cign [deleted file]
usr/lib/crontab
usr/lib/eign [deleted file]
usr/lib/learn/C/L0 [new file with mode: 0644]
usr/lib/learn/C/L0.1a [new file with mode: 0644]
usr/lib/learn/C/L1.1a [new file with mode: 0644]
usr/lib/learn/C/L1.1b [new file with mode: 0644]
usr/lib/learn/C/L1.1c [new file with mode: 0644]
usr/lib/learn/C/L1.1d [new file with mode: 0644]
usr/lib/learn/C/L1.1e [new file with mode: 0644]
usr/lib/learn/C/L1.1f [new file with mode: 0644]
usr/lib/learn/C/L10 [new file with mode: 0644]
usr/lib/learn/C/L11.1a [new file with mode: 0644]
usr/lib/learn/C/L11.2a [new file with mode: 0644]
usr/lib/learn/C/L12.1a [new file with mode: 0644]
usr/lib/learn/C/L12.1b [new file with mode: 0644]
usr/lib/learn/C/L13.1a [new file with mode: 0644]
usr/lib/learn/C/L14.1a [new file with mode: 0644]
usr/lib/learn/C/L14.2a [new file with mode: 0644]
usr/lib/learn/C/L14.2b [new file with mode: 0644]
usr/lib/learn/C/L15.1a [new file with mode: 0644]
usr/lib/learn/C/L15.1b [new file with mode: 0644]
usr/lib/learn/C/L16.2a [new file with mode: 0644]
usr/lib/learn/C/L16.2b [new file with mode: 0644]
usr/lib/learn/C/L16.2c [new file with mode: 0644]
usr/lib/learn/C/L17.1a [new file with mode: 0644]
usr/lib/learn/C/L17.1c [new file with mode: 0644]
usr/lib/learn/C/L18.1a [new file with mode: 0644]
usr/lib/learn/C/L19.1a [new file with mode: 0644]
usr/lib/learn/C/L2.1a [new file with mode: 0644]
usr/lib/learn/C/L2.1b [new file with mode: 0644]
usr/lib/learn/C/L2.1c [new file with mode: 0644]
usr/lib/learn/C/L2.1d [new file with mode: 0644]
usr/lib/learn/C/L2.1e [new file with mode: 0644]
usr/lib/learn/C/L20.1a [new file with mode: 0644]
usr/lib/learn/C/L3.1a [new file with mode: 0644]
usr/lib/learn/C/L3.1b [new file with mode: 0644]
usr/lib/learn/C/L30.1a [new file with mode: 0644]
usr/lib/learn/C/L31.1a [new file with mode: 0644]
usr/lib/learn/C/L32.1a [new file with mode: 0644]
usr/lib/learn/C/L33.1a [new file with mode: 0644]
usr/lib/learn/C/L35.1a [new file with mode: 0644]
usr/lib/learn/C/L37.1a [new file with mode: 0644]
usr/lib/learn/C/L4.1a [new file with mode: 0644]
usr/lib/learn/C/L40.1a [new file with mode: 0644]
usr/lib/learn/C/L41.1a [new file with mode: 0644]
usr/lib/learn/C/L42.1a [new file with mode: 0644]
usr/lib/learn/C/L43.1a [new file with mode: 0644]
usr/lib/learn/C/L43.1b [new file with mode: 0644]
usr/lib/learn/C/L5.1a [new file with mode: 0644]
usr/lib/learn/C/L5.1b [new file with mode: 0644]
usr/lib/learn/C/L5.1c [new file with mode: 0644]
usr/lib/learn/C/L5.1d [new file with mode: 0644]
usr/lib/learn/C/L5.1e [new file with mode: 0644]
usr/lib/learn/C/L5.1f [new file with mode: 0644]
usr/lib/learn/C/L5.1g [new file with mode: 0644]
usr/lib/learn/C/L5.2a [new file with mode: 0644]
usr/lib/learn/C/L5.2b [new file with mode: 0644]
usr/lib/learn/C/L5.2e [new file with mode: 0644]
usr/lib/learn/C/L5.3e [new file with mode: 0644]
usr/lib/learn/C/L50.1a [new file with mode: 0644]
usr/lib/learn/C/L9.1a [new file with mode: 0644]
usr/lib/learn/C/getline.c [new file with mode: 0644]
usr/lib/learn/C/getnum.c [new file with mode: 0644]
usr/lib/learn/Linfo
usr/lib/learn/Xinfo [deleted file]
usr/lib/learn/editor/L0 [new file with mode: 0644]
usr/lib/learn/editor/L1.1a [new file with mode: 0644]
usr/lib/learn/editor/L10.1a [new file with mode: 0644]
usr/lib/learn/editor/L10.1b [new file with mode: 0644]
usr/lib/learn/editor/L10.2a [new file with mode: 0644]
usr/lib/learn/editor/L10.2b [new file with mode: 0644]
usr/lib/learn/editor/L10.2c [new file with mode: 0644]
usr/lib/learn/editor/L10.3a [new file with mode: 0644]
usr/lib/learn/editor/L10.3b [new file with mode: 0644]
usr/lib/learn/editor/L10.3c [new file with mode: 0644]
usr/lib/learn/editor/L10.3d [new file with mode: 0644]
usr/lib/learn/editor/L10.3e [new file with mode: 0644]
usr/lib/learn/editor/L10.3f [new file with mode: 0644]
usr/lib/learn/editor/L11.1a [new file with mode: 0644]
usr/lib/learn/editor/L11.2a [new file with mode: 0644]
usr/lib/learn/editor/L11.2b [new file with mode: 0644]
usr/lib/learn/editor/L11.2c [new file with mode: 0644]
usr/lib/learn/editor/L12.1a [new file with mode: 0644]
usr/lib/learn/editor/L12.1b [new file with mode: 0644]
usr/lib/learn/editor/L12.2a [new file with mode: 0644]
usr/lib/learn/editor/L12.2b [new file with mode: 0644]
usr/lib/learn/editor/L12.2c [new file with mode: 0644]
usr/lib/learn/editor/L13.1a [new file with mode: 0644]
usr/lib/learn/editor/L13.2a [new file with mode: 0644]
usr/lib/learn/editor/L13.2b [new file with mode: 0644]
usr/lib/learn/editor/L14.1a [new file with mode: 0644]
usr/lib/learn/editor/L14.2a [new file with mode: 0644]
usr/lib/learn/editor/L14.2b [new file with mode: 0644]
usr/lib/learn/editor/L15.1a [new file with mode: 0644]
usr/lib/learn/editor/L15.1b [new file with mode: 0644]
usr/lib/learn/editor/L15.2a [new file with mode: 0644]
usr/lib/learn/editor/L15.2b [new file with mode: 0644]
usr/lib/learn/editor/L15.2c [new file with mode: 0644]
usr/lib/learn/editor/L15.2d [new file with mode: 0644]
usr/lib/learn/editor/L15.3b [new file with mode: 0644]
usr/lib/learn/editor/L15.3d [new file with mode: 0644]
usr/lib/learn/editor/L15.3e [new file with mode: 0644]
usr/lib/learn/editor/L15.3f [new file with mode: 0644]
usr/lib/learn/editor/L16.1a [new file with mode: 0644]
usr/lib/learn/editor/L16.1b [new file with mode: 0644]
usr/lib/learn/editor/L16.1c [new file with mode: 0644]
usr/lib/learn/editor/L16.2a [new file with mode: 0644]
usr/lib/learn/editor/L16.2c [new file with mode: 0644]
usr/lib/learn/editor/L17.2a [new file with mode: 0644]
usr/lib/learn/editor/L17.2b [new file with mode: 0644]
usr/lib/learn/editor/L17.2c [new file with mode: 0644]
usr/lib/learn/editor/L17.2d [new file with mode: 0644]
usr/lib/learn/editor/L18.1a [new file with mode: 0644]
usr/lib/learn/editor/L18.2a [new file with mode: 0644]
usr/lib/learn/editor/L18.2c [new file with mode: 0644]
usr/lib/learn/editor/L18.2d [new file with mode: 0644]
usr/lib/learn/editor/L18.2e [new file with mode: 0644]
usr/lib/learn/editor/L18.3a [new file with mode: 0644]
usr/lib/learn/editor/L18.3b [new file with mode: 0644]
usr/lib/learn/editor/L19.1a [new file with mode: 0644]
usr/lib/learn/editor/L19.1b [new file with mode: 0644]
usr/lib/learn/editor/L19.2a [new file with mode: 0644]
usr/lib/learn/editor/L19.2c [new file with mode: 0644]
usr/lib/learn/editor/L19.2d [new file with mode: 0644]
usr/lib/learn/editor/L19.2e [new file with mode: 0644]
usr/lib/learn/editor/L19.2f [new file with mode: 0644]
usr/lib/learn/editor/L19.3b [new file with mode: 0644]
usr/lib/learn/editor/L2.1a [new file with mode: 0644]
usr/lib/learn/editor/L2.2a [new file with mode: 0644]
usr/lib/learn/editor/L20.1a [new file with mode: 0644]
usr/lib/learn/editor/L20.2a [new file with mode: 0644]
usr/lib/learn/editor/L20.2b [new file with mode: 0644]
usr/lib/learn/editor/L20.2c [new file with mode: 0644]
usr/lib/learn/editor/L21.1a [new file with mode: 0644]
usr/lib/learn/editor/L21.1b [new file with mode: 0644]
usr/lib/learn/editor/L21.1c [new file with mode: 0644]
usr/lib/learn/editor/L21.1d [new file with mode: 0644]
usr/lib/learn/editor/L21.1e [new file with mode: 0644]
usr/lib/learn/editor/L3.1a [new file with mode: 0644]
usr/lib/learn/editor/L3.1b [new file with mode: 0644]
usr/lib/learn/editor/L30.1a [new file with mode: 0644]
usr/lib/learn/editor/L30.1b [new file with mode: 0644]
usr/lib/learn/editor/L30.2a [new file with mode: 0644]
usr/lib/learn/editor/L30.2b [new file with mode: 0644]
usr/lib/learn/editor/L30.2c [new file with mode: 0644]
usr/lib/learn/editor/L30.2d [new file with mode: 0644]
usr/lib/learn/editor/L30.2e [new file with mode: 0644]
usr/lib/learn/editor/L30.2f [new file with mode: 0644]
usr/lib/learn/editor/L30.2g [new file with mode: 0644]
usr/lib/learn/editor/L30.2h [new file with mode: 0644]
usr/lib/learn/editor/L31.1a [new file with mode: 0644]
usr/lib/learn/editor/L31.2b [new file with mode: 0644]
usr/lib/learn/editor/L31.2c [new file with mode: 0644]
usr/lib/learn/editor/L32.1a [new file with mode: 0644]
usr/lib/learn/editor/L32.1b [new file with mode: 0644]
usr/lib/learn/editor/L32.1c [new file with mode: 0644]
usr/lib/learn/editor/L32.2a [new file with mode: 0644]
usr/lib/learn/editor/L32.2b [new file with mode: 0644]
usr/lib/learn/editor/L32.2c [new file with mode: 0644]
usr/lib/learn/editor/L32.2d [new file with mode: 0644]
usr/lib/learn/editor/L32.2e [new file with mode: 0644]
usr/lib/learn/editor/L32.2f [new file with mode: 0644]
usr/lib/learn/editor/L32.2g [new file with mode: 0644]
usr/lib/learn/editor/L33.1a [new file with mode: 0644]
usr/lib/learn/editor/L33.1b [new file with mode: 0644]
usr/lib/learn/editor/L33.2a [new file with mode: 0644]
usr/lib/learn/editor/L33.2b [new file with mode: 0644]
usr/lib/learn/editor/L33.2c [new file with mode: 0644]
usr/lib/learn/editor/L34.1a [new file with mode: 0644]
usr/lib/learn/editor/L34.1b [new file with mode: 0644]
usr/lib/learn/editor/L34.2a [new file with mode: 0644]
usr/lib/learn/editor/L34.2b [new file with mode: 0644]
usr/lib/learn/editor/L34.2c [new file with mode: 0644]
usr/lib/learn/editor/L34.2d [new file with mode: 0644]
usr/lib/learn/editor/L34.2e [new file with mode: 0644]
usr/lib/learn/editor/L34.2f [new file with mode: 0644]
usr/lib/learn/editor/L35.1a [new file with mode: 0644]
usr/lib/learn/editor/L35.2a [new file with mode: 0644]
usr/lib/learn/editor/L35.2b [new file with mode: 0644]
usr/lib/learn/editor/L35.2c [new file with mode: 0644]
usr/lib/learn/editor/L35.2d [new file with mode: 0644]
usr/lib/learn/editor/L35.2e [new file with mode: 0644]
usr/lib/learn/editor/L36.1a [new file with mode: 0644]
usr/lib/learn/editor/L36.2a [new file with mode: 0644]
usr/lib/learn/editor/L36.2b [new file with mode: 0644]
usr/lib/learn/editor/L36.2c [new file with mode: 0644]
usr/lib/learn/editor/L36.2d [new file with mode: 0644]
usr/lib/learn/editor/L37.1a [new file with mode: 0644]
usr/lib/learn/editor/L37.2a [new file with mode: 0644]
usr/lib/learn/editor/L37.2b [new file with mode: 0644]
usr/lib/learn/editor/L37.2c [new file with mode: 0644]
usr/lib/learn/editor/L37.2d [new file with mode: 0644]
usr/lib/learn/editor/L37.2e [new file with mode: 0644]
usr/lib/learn/editor/L37.2f [new file with mode: 0644]
usr/lib/learn/editor/L38.1a [new file with mode: 0644]
usr/lib/learn/editor/L38.2a [new file with mode: 0644]
usr/lib/learn/editor/L38.2b [new file with mode: 0644]
usr/lib/learn/editor/L39.1a [new file with mode: 0644]
usr/lib/learn/editor/L4.1a [new file with mode: 0644]
usr/lib/learn/editor/L4.1b [new file with mode: 0644]
usr/lib/learn/editor/L4.2a [new file with mode: 0644]
usr/lib/learn/editor/L4.2b [new file with mode: 0644]
usr/lib/learn/editor/L40.1a [new file with mode: 0644]
usr/lib/learn/editor/L40.1b [new file with mode: 0644]
usr/lib/learn/editor/L40.2b [new file with mode: 0644]
usr/lib/learn/editor/L40.2c [new file with mode: 0644]
usr/lib/learn/editor/L40.2d [new file with mode: 0644]
usr/lib/learn/editor/L41.1a [new file with mode: 0644]
usr/lib/learn/editor/L41.1b [new file with mode: 0644]
usr/lib/learn/editor/L42.1a [new file with mode: 0644]
usr/lib/learn/editor/L42.2a [new file with mode: 0644]
usr/lib/learn/editor/L42.2b [new file with mode: 0644]
usr/lib/learn/editor/L42.2c [new file with mode: 0644]
usr/lib/learn/editor/L43.1a [new file with mode: 0644]
usr/lib/learn/editor/L43.2a [new file with mode: 0644]
usr/lib/learn/editor/L43.2b [new file with mode: 0644]
usr/lib/learn/editor/L43.2c [new file with mode: 0644]
usr/lib/learn/editor/L43.2d [new file with mode: 0644]
usr/lib/learn/editor/L44.1a [new file with mode: 0644]
usr/lib/learn/editor/L44.1b [new file with mode: 0644]
usr/lib/learn/editor/L44.1c [new file with mode: 0644]
usr/lib/learn/editor/L44.1d [new file with mode: 0644]
usr/lib/learn/editor/L44.1e [new file with mode: 0644]
usr/lib/learn/editor/L44.1f [new file with mode: 0644]
usr/lib/learn/editor/L44.1g [new file with mode: 0644]
usr/lib/learn/editor/L44.1h [new file with mode: 0644]
usr/lib/learn/editor/L44.1i [new file with mode: 0644]
usr/lib/learn/editor/L45.1a [new file with mode: 0644]
usr/lib/learn/editor/L45.1b [new file with mode: 0644]
usr/lib/learn/editor/L5.1a [new file with mode: 0644]
usr/lib/learn/editor/L50.1a [new file with mode: 0644]
usr/lib/learn/editor/L50.1b [new file with mode: 0644]
usr/lib/learn/editor/L50.1c [new file with mode: 0644]
usr/lib/learn/editor/L50.2c [new file with mode: 0644]
usr/lib/learn/editor/L50.2d [new file with mode: 0644]
usr/lib/learn/editor/L50.2e [new file with mode: 0644]
usr/lib/learn/editor/L50.2f [new file with mode: 0644]
usr/lib/learn/editor/L50.2g [new file with mode: 0644]
usr/lib/learn/editor/L51.1a [new file with mode: 0644]
usr/lib/learn/editor/L51.2a [new file with mode: 0644]
usr/lib/learn/editor/L51.2b [new file with mode: 0644]
usr/lib/learn/editor/L51.2c [new file with mode: 0644]
usr/lib/learn/editor/L52.1a [new file with mode: 0644]
usr/lib/learn/editor/L52.1b [new file with mode: 0644]
usr/lib/learn/editor/L52.2a [new file with mode: 0644]
usr/lib/learn/editor/L52.2b [new file with mode: 0644]
usr/lib/learn/editor/L52.2c [new file with mode: 0644]
usr/lib/learn/editor/L53.1a [new file with mode: 0644]
usr/lib/learn/editor/L53.2b [new file with mode: 0644]
usr/lib/learn/editor/L54.1a [new file with mode: 0644]
usr/lib/learn/editor/L54.1b [new file with mode: 0644]
usr/lib/learn/editor/L55.1a [new file with mode: 0644]
usr/lib/learn/editor/L56.1a [new file with mode: 0644]
usr/lib/learn/editor/L57.1a [new file with mode: 0644]
usr/lib/learn/editor/L6.1a [new file with mode: 0644]
usr/lib/learn/editor/L6.2a [new file with mode: 0644]
usr/lib/learn/editor/L6.2b [new file with mode: 0644]
usr/lib/learn/editor/L60.1a [new file with mode: 0644]
usr/lib/learn/editor/L60.1b [new file with mode: 0644]
usr/lib/learn/editor/L60.2a [new file with mode: 0644]
usr/lib/learn/editor/L60.2b [new file with mode: 0644]
usr/lib/learn/editor/L60.2c [new file with mode: 0644]
usr/lib/learn/editor/L60.2d [new file with mode: 0644]
usr/lib/learn/editor/L61.1a [new file with mode: 0644]
usr/lib/learn/editor/L62.1a [new file with mode: 0644]
usr/lib/learn/editor/L62.2a [new file with mode: 0644]
usr/lib/learn/editor/L62.2b [new file with mode: 0644]
usr/lib/learn/editor/L62.2c [new file with mode: 0644]
usr/lib/learn/editor/L63.1a [new file with mode: 0644]
usr/lib/learn/editor/L63.1b [new file with mode: 0644]
usr/lib/learn/editor/L63.1c [new file with mode: 0644]
usr/lib/learn/editor/L63.1d [new file with mode: 0644]
usr/lib/learn/editor/L63.1e [new file with mode: 0644]
usr/lib/learn/editor/L64.1a [new file with mode: 0644]
usr/lib/learn/editor/L64.1b [new file with mode: 0644]
usr/lib/learn/editor/L65.1a [new file with mode: 0644]
usr/lib/learn/editor/L66.1a [new file with mode: 0644]
usr/lib/learn/editor/L7.1a [new file with mode: 0644]
usr/lib/learn/editor/L7.1b [new file with mode: 0644]
usr/lib/learn/editor/L7.2c [new file with mode: 0644]
usr/lib/learn/editor/L70.1a [new file with mode: 0644]
usr/lib/learn/editor/L70.2a [new file with mode: 0644]
usr/lib/learn/editor/L70.2b [new file with mode: 0644]
usr/lib/learn/editor/L70.2c [new file with mode: 0644]
usr/lib/learn/editor/L70.2d [new file with mode: 0644]
usr/lib/learn/editor/L70.2e [new file with mode: 0644]
usr/lib/learn/editor/L70.2f [new file with mode: 0644]
usr/lib/learn/editor/L70.2g [new file with mode: 0644]
usr/lib/learn/editor/L71.1a [new file with mode: 0644]
usr/lib/learn/editor/L72.1a [new file with mode: 0644]
usr/lib/learn/editor/L72.2a [new file with mode: 0644]
usr/lib/learn/editor/L72.2b [new file with mode: 0644]
usr/lib/learn/editor/L72.2c [new file with mode: 0644]
usr/lib/learn/editor/L72.2d [new file with mode: 0644]
usr/lib/learn/editor/L73.1a [new file with mode: 0644]
usr/lib/learn/editor/L74.1a [new file with mode: 0644]
usr/lib/learn/editor/L8.1a [new file with mode: 0644]
usr/lib/learn/editor/L8.1b [new file with mode: 0644]
usr/lib/learn/editor/L8.2a [new file with mode: 0644]
usr/lib/learn/editor/L8.2b [new file with mode: 0644]
usr/lib/learn/editor/L8.2c [new file with mode: 0644]
usr/lib/learn/editor/L9.1a [new file with mode: 0644]
usr/lib/learn/editor/L9.2a [new file with mode: 0644]
usr/lib/learn/editor/L9.2b [new file with mode: 0644]
usr/lib/learn/editor/L9.2d [new file with mode: 0644]
usr/lib/learn/editor/L9.2e [new file with mode: 0644]
usr/lib/learn/editor/L9.3c [new file with mode: 0644]
usr/lib/learn/eqn/Init [new file with mode: 0755]
usr/lib/learn/eqn/L0 [new file with mode: 0644]
usr/lib/learn/eqn/L0.1a [new file with mode: 0644]
usr/lib/learn/eqn/L1.1a [new file with mode: 0644]
usr/lib/learn/eqn/L1.1b [new file with mode: 0644]
usr/lib/learn/eqn/L1.1c [new file with mode: 0644]
usr/lib/learn/eqn/L1.1d [new file with mode: 0644]
usr/lib/learn/eqn/L1.1e [new file with mode: 0644]
usr/lib/learn/eqn/L1.1f [new file with mode: 0644]
usr/lib/learn/eqn/L10.1a [new file with mode: 0644]
usr/lib/learn/eqn/L10.1b [new file with mode: 0644]
usr/lib/learn/eqn/L10.1c [new file with mode: 0644]
usr/lib/learn/eqn/L10.2c [new file with mode: 0644]
usr/lib/learn/eqn/L11.1a [new file with mode: 0644]
usr/lib/learn/eqn/L11.1b [new file with mode: 0644]
usr/lib/learn/eqn/L11.1c [new file with mode: 0644]
usr/lib/learn/eqn/L11.1d [new file with mode: 0644]
usr/lib/learn/eqn/L11.1e [new file with mode: 0644]
usr/lib/learn/eqn/L11.1f [new file with mode: 0644]
usr/lib/learn/eqn/L11.1g [new file with mode: 0644]
usr/lib/learn/eqn/L12.1a [new file with mode: 0644]
usr/lib/learn/eqn/L12.1b [new file with mode: 0644]
usr/lib/learn/eqn/L12.1c [new file with mode: 0644]
usr/lib/learn/eqn/L12.1d [new file with mode: 0644]
usr/lib/learn/eqn/L12.1e [new file with mode: 0644]
usr/lib/learn/eqn/L2.1a [new file with mode: 0644]
usr/lib/learn/eqn/L2.1b [new file with mode: 0644]
usr/lib/learn/eqn/L2.1c [new file with mode: 0644]
usr/lib/learn/eqn/L2.1d [new file with mode: 0644]
usr/lib/learn/eqn/L2.1e [new file with mode: 0644]
usr/lib/learn/eqn/L2.1f [new file with mode: 0644]
usr/lib/learn/eqn/L2.2a [new file with mode: 0644]
usr/lib/learn/eqn/L2.2b [new file with mode: 0644]
usr/lib/learn/eqn/L2.2e [new file with mode: 0644]
usr/lib/learn/eqn/L3.1a [new file with mode: 0644]
usr/lib/learn/eqn/L3.1b [new file with mode: 0644]
usr/lib/learn/eqn/L3.1c [new file with mode: 0644]
usr/lib/learn/eqn/L3.1d [new file with mode: 0644]
usr/lib/learn/eqn/L3.1e [new file with mode: 0644]
usr/lib/learn/eqn/L3.2a [new file with mode: 0644]
usr/lib/learn/eqn/L3.2c [new file with mode: 0644]
usr/lib/learn/eqn/L3.2d [new file with mode: 0644]
usr/lib/learn/eqn/L4.1a [new file with mode: 0644]
usr/lib/learn/eqn/L4.1b [new file with mode: 0644]
usr/lib/learn/eqn/L4.1c [new file with mode: 0644]
usr/lib/learn/eqn/L4.1d [new file with mode: 0644]
usr/lib/learn/eqn/L4.2a [new file with mode: 0644]
usr/lib/learn/eqn/L4.2c [new file with mode: 0644]
usr/lib/learn/eqn/L5.1a [new file with mode: 0644]
usr/lib/learn/eqn/L5.1b [new file with mode: 0644]
usr/lib/learn/eqn/L5.1c [new file with mode: 0644]
usr/lib/learn/eqn/L5.1d [new file with mode: 0644]
usr/lib/learn/eqn/L5.1e [new file with mode: 0644]
usr/lib/learn/eqn/L5.1f [new file with mode: 0644]
usr/lib/learn/eqn/L5.1g [new file with mode: 0644]
usr/lib/learn/eqn/L5.1h [new file with mode: 0644]
usr/lib/learn/eqn/L5.2b [new file with mode: 0644]
usr/lib/learn/eqn/L5.2d [new file with mode: 0644]
usr/lib/learn/eqn/L5.2g [new file with mode: 0644]
usr/lib/learn/eqn/L6.1a [new file with mode: 0644]
usr/lib/learn/eqn/L6.1b [new file with mode: 0644]
usr/lib/learn/eqn/L6.1c [new file with mode: 0644]
usr/lib/learn/eqn/L6.1d [new file with mode: 0644]
usr/lib/learn/eqn/L7.1a [new file with mode: 0644]
usr/lib/learn/eqn/L7.1b [new file with mode: 0644]
usr/lib/learn/eqn/L7.1c [new file with mode: 0644]
usr/lib/learn/eqn/L7.1d [new file with mode: 0644]
usr/lib/learn/eqn/L7.2b [new file with mode: 0644]
usr/lib/learn/eqn/L7.2c [new file with mode: 0644]
usr/lib/learn/eqn/L8.1a [new file with mode: 0644]
usr/lib/learn/eqn/L8.1b [new file with mode: 0644]
usr/lib/learn/eqn/L8.2b [new file with mode: 0644]
usr/lib/learn/eqn/L9.1a [new file with mode: 0644]
usr/lib/learn/eqn/L9.1b [new file with mode: 0644]
usr/lib/learn/eqn/L9.2a [new file with mode: 0644]
usr/lib/learn/eqn/L9.2b [new file with mode: 0644]
usr/lib/learn/eqn/L9.3b [new file with mode: 0644]
usr/lib/learn/eqn/tinyms [new file with mode: 0644]
usr/lib/learn/files/L0 [new file with mode: 0644]
usr/lib/learn/files/L0.1a [new file with mode: 0644]
usr/lib/learn/files/L0.1b [new file with mode: 0644]
usr/lib/learn/files/L0.1c [new file with mode: 0644]
usr/lib/learn/files/L0.1d [new file with mode: 0644]
usr/lib/learn/files/L1.1a [new file with mode: 0644]
usr/lib/learn/files/L1.2a [new file with mode: 0644]
usr/lib/learn/files/L1.2b [new file with mode: 0644]
usr/lib/learn/files/L10.1a [new file with mode: 0644]
usr/lib/learn/files/L10.2a [new file with mode: 0644]
usr/lib/learn/files/L10.2b [new file with mode: 0644]
usr/lib/learn/files/L10.3a [new file with mode: 0644]
usr/lib/learn/files/L10.3b [new file with mode: 0644]
usr/lib/learn/files/L10.3c [new file with mode: 0644]
usr/lib/learn/files/L10.3d [new file with mode: 0644]
usr/lib/learn/files/L11.1a [new file with mode: 0644]
usr/lib/learn/files/L11.2a [new file with mode: 0644]
usr/lib/learn/files/L11.2b [new file with mode: 0644]
usr/lib/learn/files/L11.3a [new file with mode: 0644]
usr/lib/learn/files/L11.3b [new file with mode: 0644]
usr/lib/learn/files/L11.3c [new file with mode: 0644]
usr/lib/learn/files/L12.1a [new file with mode: 0644]
usr/lib/learn/files/L12.2a [new file with mode: 0644]
usr/lib/learn/files/L12.2b [new file with mode: 0644]
usr/lib/learn/files/L12.2c [new file with mode: 0644]
usr/lib/learn/files/L12.3a [new file with mode: 0644]
usr/lib/learn/files/L12.3b [new file with mode: 0644]
usr/lib/learn/files/L12.3c [new file with mode: 0644]
usr/lib/learn/files/L13.1a [new file with mode: 0644]
usr/lib/learn/files/L13.1b [new file with mode: 0644]
usr/lib/learn/files/L13.1c [new file with mode: 0644]
usr/lib/learn/files/L13.1d [new file with mode: 0644]
usr/lib/learn/files/L13.1e [new file with mode: 0644]
usr/lib/learn/files/L13.1f [new file with mode: 0644]
usr/lib/learn/files/L13.1g [new file with mode: 0644]
usr/lib/learn/files/L2.1a [new file with mode: 0644]
usr/lib/learn/files/L2.2a [new file with mode: 0644]
usr/lib/learn/files/L2.2b [new file with mode: 0644]
usr/lib/learn/files/L3.1a [new file with mode: 0644]
usr/lib/learn/files/L3.2a [new file with mode: 0644]
usr/lib/learn/files/L3.2b [new file with mode: 0644]
usr/lib/learn/files/L3.3a [new file with mode: 0644]
usr/lib/learn/files/L3.3b [new file with mode: 0644]
usr/lib/learn/files/L4.1a [new file with mode: 0644]
usr/lib/learn/files/L4.2a [new file with mode: 0644]
usr/lib/learn/files/L4.2b [new file with mode: 0644]
usr/lib/learn/files/L4.3a [new file with mode: 0644]
usr/lib/learn/files/L4.3b [new file with mode: 0644]
usr/lib/learn/files/L4.3c [new file with mode: 0644]
usr/lib/learn/files/L5.1a [new file with mode: 0644]
usr/lib/learn/files/L5.1b [new file with mode: 0644]
usr/lib/learn/files/L5.1c [new file with mode: 0644]
usr/lib/learn/files/L5.1d [new file with mode: 0644]
usr/lib/learn/files/L5.1e [new file with mode: 0644]
usr/lib/learn/files/L6.1a [new file with mode: 0644]
usr/lib/learn/files/L6.1b [new file with mode: 0644]
usr/lib/learn/files/L6.1c [new file with mode: 0644]
usr/lib/learn/files/L6.1d [new file with mode: 0644]
usr/lib/learn/files/L6.1e [new file with mode: 0644]
usr/lib/learn/files/L6.2a [new file with mode: 0644]
usr/lib/learn/files/L6.2b [new file with mode: 0644]
usr/lib/learn/files/L7.1a [new file with mode: 0644]
usr/lib/learn/files/L7.2a [new file with mode: 0644]
usr/lib/learn/files/L7.2b [new file with mode: 0644]
usr/lib/learn/files/L7.3a [new file with mode: 0644]
usr/lib/learn/files/L7.3b [new file with mode: 0644]
usr/lib/learn/files/L7.3c [new file with mode: 0644]
usr/lib/learn/files/L8.1a [new file with mode: 0644]
usr/lib/learn/files/L8.2a [new file with mode: 0644]
usr/lib/learn/files/L8.2b [new file with mode: 0644]
usr/lib/learn/files/L8.2c [new file with mode: 0644]
usr/lib/learn/files/L9.1a [new file with mode: 0644]
usr/lib/learn/files/L9.2a [new file with mode: 0644]
usr/lib/learn/files/L9.2b [new file with mode: 0644]
usr/lib/learn/files/L9.2c [new file with mode: 0644]
usr/lib/learn/files/Lxxx [new file with mode: 0644]
usr/lib/learn/log/dummy [new file with mode: 0644]
usr/lib/learn/macros/L0 [new file with mode: 0644]
usr/lib/learn/macros/L1.1a [new file with mode: 0644]
usr/lib/learn/macros/L10.1a [new file with mode: 0644]
usr/lib/learn/macros/L11.1a [new file with mode: 0644]
usr/lib/learn/macros/L12.1a [new file with mode: 0644]
usr/lib/learn/macros/L13.1a [new file with mode: 0644]
usr/lib/learn/macros/L14.1a [new file with mode: 0644]
usr/lib/learn/macros/L15.1a [new file with mode: 0644]
usr/lib/learn/macros/L2.1a [new file with mode: 0644]
usr/lib/learn/macros/L3.1a [new file with mode: 0644]
usr/lib/learn/macros/L4.1a [new file with mode: 0644]
usr/lib/learn/macros/L5.1a [new file with mode: 0644]
usr/lib/learn/macros/L6.1a [new file with mode: 0644]
usr/lib/learn/macros/L7.1a [new file with mode: 0644]
usr/lib/learn/macros/L8.1a [new file with mode: 0644]
usr/lib/learn/macros/L9.1a [new file with mode: 0644]
usr/lib/learn/morefiles/L0 [new file with mode: 0644]
usr/lib/learn/morefiles/L0.1a [new file with mode: 0644]
usr/lib/learn/morefiles/L0.1b [new file with mode: 0644]
usr/lib/learn/morefiles/L0.1c [new file with mode: 0644]
usr/lib/learn/morefiles/L0.1d [new file with mode: 0644]
usr/lib/learn/morefiles/L0.1e [new file with mode: 0644]
usr/lib/learn/morefiles/L0.1f [new file with mode: 0644]
usr/lib/learn/morefiles/L0.1g [new file with mode: 0644]
usr/lib/learn/morefiles/L1.1a [new file with mode: 0644]
usr/lib/learn/morefiles/L1.1b [new file with mode: 0644]
usr/lib/learn/morefiles/L1.1c [new file with mode: 0644]
usr/lib/learn/morefiles/L1.1d [new file with mode: 0644]
usr/lib/learn/morefiles/L2.1a [new file with mode: 0644]
usr/lib/learn/morefiles/L2.1b [new file with mode: 0644]
usr/lib/learn/morefiles/L2.1c [new file with mode: 0644]
usr/lib/learn/morefiles/L2.1d [new file with mode: 0644]
usr/lib/learn/morefiles/L2.1e [new file with mode: 0644]
usr/lib/learn/morefiles/L2.1f [new file with mode: 0644]
usr/lib/learn/morefiles/L3.1a [new file with mode: 0644]
usr/lib/learn/morefiles/L3.1b [new file with mode: 0644]
usr/lib/learn/morefiles/L3.1c [new file with mode: 0644]
usr/lib/learn/morefiles/L3.1d [new file with mode: 0644]
usr/lib/learn/morefiles/L3.1e [new file with mode: 0644]
usr/lib/learn/morefiles/L3.1f [new file with mode: 0644]
usr/lib/learn/morefiles/L3.2a [new file with mode: 0644]
usr/lib/learn/morefiles/L4.1a [new file with mode: 0644]
usr/lib/learn/morefiles/L4.1b [new file with mode: 0644]
usr/lib/learn/morefiles/L4.1c [new file with mode: 0644]
usr/lib/learn/morefiles/L4.1d [new file with mode: 0644]
usr/lib/learn/morefiles/L4.1e [new file with mode: 0644]
usr/lib/learn/morefiles/L4.1f [new file with mode: 0644]
usr/lib/learn/morefiles/L4.1g [new file with mode: 0644]
usr/lib/learn/morefiles/L4.2a [new file with mode: 0644]
usr/lib/learn/morefiles/L5.1a [new file with mode: 0644]
usr/lib/learn/morefiles/L5.1b [new file with mode: 0644]
usr/lib/learn/morefiles/L5.1c [new file with mode: 0644]
usr/lib/learn/morefiles/L5.1d [new file with mode: 0644]
usr/lib/learn/morefiles/L5.1e [new file with mode: 0644]
usr/lib/learn/morefiles/L6.1a [new file with mode: 0644]
usr/lib/learn/morefiles/L6.1b [new file with mode: 0644]
usr/lib/learn/morefiles/L6.1c [new file with mode: 0644]
usr/lib/learn/morefiles/L6.1d [new file with mode: 0644]
usr/lib/learn/morefiles/L6.1e [new file with mode: 0644]
usr/lib/learn/morefiles/L6.2e [new file with mode: 0644]
usr/lib/learn/morefiles/L7.1a [new file with mode: 0644]
usr/lib/learn/play/dummy [new file with mode: 0644]
usr/lib/lex/ncform [deleted file]
usr/lib/lib.b [new file with mode: 0644]
usr/lib/llib-lc [deleted file]
usr/lib/llib-lm [deleted file]
usr/lib/llib-port [changed mode: 0644->0755]
usr/lib/tmac/tmac.an
usr/lib/tmac/tmac.s
usr/lib/tmac/tmac.srefs
usr/lib/uucp/L-devices [deleted file]
usr/lib/uucp/L-dialcodes [deleted file]
usr/lib/uucp/L.sys [deleted file]
usr/lib/uucp/USERFILE [deleted file]
usr/lib/yaccpar [deleted file]
usr/lib/z [new file with mode: 0644]
usr/man/break [new file with mode: 0644]
usr/man/cattoc [new file with mode: 0644]
usr/man/ignore [new file with mode: 0644]
usr/man/man0/copyr [new file with mode: 0644]
usr/man/man0/intro
usr/man/man0/permindex [deleted file]
usr/man/man0/ptx.in [new file with mode: 0644]
usr/man/man0/ptxmac [deleted file]
usr/man/man0/ptxx [new file with mode: 0644]
usr/man/man0/title
usr/man/man0/title] [new file with mode: 0644]
usr/man/man0/toc.in [new file with mode: 0644]
usr/man/man0/toc1 [new file with mode: 0644]
usr/man/man0/toc2 [new file with mode: 0644]
usr/man/man0/toc3 [new file with mode: 0644]
usr/man/man0/toc4 [new file with mode: 0644]
usr/man/man0/toc5 [new file with mode: 0644]
usr/man/man0/toc6 [new file with mode: 0644]
usr/man/man0/toc7 [new file with mode: 0644]
usr/man/man0/toc8 [new file with mode: 0644]
usr/man/man0/tocx1 [new file with mode: 0644]
usr/man/man0/tocx2 [new file with mode: 0644]
usr/man/man0/tocx3 [new file with mode: 0644]
usr/man/man0/tocx4 [new file with mode: 0644]
usr/man/man0/tocx5 [new file with mode: 0644]
usr/man/man0/tocx6 [new file with mode: 0644]
usr/man/man0/tocx7 [new file with mode: 0644]
usr/man/man0/tocx8 [new file with mode: 0644]
usr/man/man0/vaxpref [new file with mode: 0644]
usr/man/man1/adb.1
usr/man/man1/ar11.1 [new file with mode: 0644]
usr/man/man1/as.1
usr/man/man1/at.1
usr/man/man1/bas.1 [deleted file]
usr/man/man1/calendar.1
usr/man/man1/call.1c [new file with mode: 0644]
usr/man/man1/cat.1
usr/man/man1/cc.1
usr/man/man1/col.1
usr/man/man1/cron.1m [new file with mode: 0644]
usr/man/man1/dd.1
usr/man/man1/diff3.1
usr/man/man1/du.1
usr/man/man1/dump.1m
usr/man/man1/dumpdir.1m
usr/man/man1/echo.1
usr/man/man1/eqn.1
usr/man/man1/f77.1
usr/man/man1/factor.1 [deleted file]
usr/man/man1/false.1 [new file with mode: 0644]
usr/man/man1/grep.1
usr/man/man1/intro.1
usr/man/man1/iostat.1m
usr/man/man1/ld.1
usr/man/man1/learn.1 [new file with mode: 0644]
usr/man/man1/lint.1
usr/man/man1/login.1
usr/man/man1/lookall.1 [deleted file]
usr/man/man1/lookbib.1 [new file with mode: 0644]
usr/man/man1/lpr.1 [new file with mode: 0644]
usr/man/man1/mail.1
usr/man/man1/mkconf.1m [deleted file]
usr/man/man1/mkfs.1m
usr/man/man1/mount.1m
usr/man/man1/mv.1
usr/man/man1/nice.1
usr/man/man1/nohup.1 [new file with mode: 0644]
usr/man/man1/number.1 [new file with mode: 0644]
usr/man/man1/od.1
usr/man/man1/passwd.1
usr/man/man1/prep.1 [deleted file]
usr/man/man1/ps.1
usr/man/man1/pstat.1m
usr/man/man1/pubindex.1 [deleted file]
usr/man/man1/quot.1m
usr/man/man1/ranlib.1 [deleted file]
usr/man/man1/ratfor.1
usr/man/man1/rc.1 [new file with mode: 0644]
usr/man/man1/restor.1m
usr/man/man1/roff.1 [deleted file]
usr/man/man1/sa.1m
usr/man/man1/sdb.1 [new file with mode: 0644]
usr/man/man1/sed.1
usr/man/man1/sh.1
usr/man/man1/size.1
usr/man/man1/sleep.1
usr/man/man1/sort.1
usr/man/man1/struct.1
usr/man/man1/stty.1
usr/man/man1/tar.1
usr/man/man1/tc.1
usr/man/man1/test.1
usr/man/man1/time.1
usr/man/man1/troff.1
usr/man/man1/uudiff.1c [new file with mode: 0644]
usr/man/man1/uulog.1c [new file with mode: 0644]
usr/man/man2/access.2
usr/man/man2/acct.2
usr/man/man2/alarm.2
usr/man/man2/brk.2
usr/man/man2/chdir.2
usr/man/man2/chmod.2
usr/man/man2/chown.2
usr/man/man2/close.2
usr/man/man2/creat.2
usr/man/man2/dup.2
usr/man/man2/exec.2
usr/man/man2/exit.2
usr/man/man2/fork.2
usr/man/man2/getpid.2
usr/man/man2/getuid.2
usr/man/man2/indir.2
usr/man/man2/intro.2
usr/man/man2/ioctl.2
usr/man/man2/kill.2
usr/man/man2/link.2
usr/man/man2/lseek.2
usr/man/man2/mknod.2
usr/man/man2/mount.2
usr/man/man2/mpxcall.2 [deleted file]
usr/man/man2/nice.2
usr/man/man2/open.2
usr/man/man2/pause.2
usr/man/man2/phys.2 [deleted file]
usr/man/man2/pipe.2
usr/man/man2/pkon.2 [deleted file]
usr/man/man2/profil.2
usr/man/man2/ptrace.2
usr/man/man2/read.2
usr/man/man2/setuid.2
usr/man/man2/signal.2
usr/man/man2/stat.2
usr/man/man2/stime.2
usr/man/man2/stty.2 [new file with mode: 0644]
usr/man/man2/sync.2
usr/man/man2/time.2
usr/man/man2/times.2
usr/man/man2/umask.2
usr/man/man2/unlink.2
usr/man/man2/utime.2
usr/man/man2/wait.2
usr/man/man2/write.2
usr/man/man3/abort.3
usr/man/man3/abs.3
usr/man/man3/assert.3x
usr/man/man3/atof.3
usr/man/man3/ctime.3
usr/man/man3/ctype.3
usr/man/man3/end.3
usr/man/man3/frexp.3
usr/man/man3/gamma.3m [new file with mode: 0644]
usr/man/man3/getarg.3f [new file with mode: 0644]
usr/man/man3/getc.3s
usr/man/man3/getpwent.3
usr/man/man3/intro.3
usr/man/man3/l3tol.3
usr/man/man3/mp.3x [deleted file]
usr/man/man3/pkopen.3 [deleted file]
usr/man/man3/printf.3s
usr/man/man3/rand.3
usr/man/man3/string.3
usr/man/man3/system.3
usr/man/man4/dc.4 [new file with mode: 0644]
usr/man/man4/dh.4 [new file with mode: 0644]
usr/man/man4/dp.4 [new file with mode: 0644]
usr/man/man4/du.4 [deleted file]
usr/man/man4/dz.4 [new file with mode: 0644]
usr/man/man4/hp.4
usr/man/man4/ht.4
usr/man/man4/kl.4 [new file with mode: 0644]
usr/man/man4/kmem.4 [new file with mode: 0644]
usr/man/man4/lp.4 [new file with mode: 0644]
usr/man/man4/mem.4
usr/man/man4/pc.4 [new file with mode: 0644]
usr/man/man4/rp.4
usr/man/man4/tm.4
usr/man/man4/tty.4
usr/man/man5/a.out.5
usr/man/man5/core.5
usr/man/man5/dir.5
usr/man/man5/filsys.5
usr/man/man5/tp.5
usr/man/man5/wtmp.5 [new file with mode: 0644]
usr/man/man6/banner.6 [deleted file]
usr/man/man6/bcd.6
usr/man/man6/bj.6 [deleted file]
usr/man/man6/checkers.6 [deleted file]
usr/man/man6/chess.6 [deleted file]
usr/man/man6/cubic.6 [deleted file]
usr/man/man6/hangman.6 [new file with mode: 0644]
usr/man/man6/maze.6
usr/man/man6/moo.6 [deleted file]
usr/man/man6/reversi.6 [deleted file]
usr/man/man6/ttt.6 [deleted file]
usr/man/man6/words.6 [deleted file]
usr/man/man7/ascii.7
usr/man/man7/eqnchar.7
usr/man/man7/greek.7 [new file with mode: 0644]
usr/man/man7/hier.7
usr/man/man7/term.7
usr/man/man8/boot.8 [deleted file]
usr/man/man8/bproc.8 [new file with mode: 0644]
usr/man/man8/crash.8
usr/man/man8/fget.demon.8 [new file with mode: 0644]
usr/man/man8/getty.8
usr/man/man8/init.8
usr/man/man8/lpd.8
usr/man/man8/sticky.8 [new file with mode: 0644]
usr/man/man8/sysgen.8 [new file with mode: 0644]
usr/man/nohup.out [new file with mode: 0644]
usr/man/tabs [new file with mode: 0644]
usr/man/tocrc [new file with mode: 0755]
usr/mdec/hpuboot.s [deleted file]
usr/mdec/makefile [deleted file]
usr/mdec/rpuboot.s [deleted file]
usr/news/dummy [new file with mode: 0644]
usr/pub/ascii
usr/pub/kbd [new file with mode: 0644]
usr/pub/marg8 [new file with mode: 0644]
usr/pub/tabclr [new file with mode: 0644]
usr/pub/tabs [new file with mode: 0644]
usr/pub/ttt [new file with mode: 0644]
usr/spool/at/lasttimedone [deleted file]
usr/spool/at/past/dummy [new file with mode: 0644]
usr/spool/dpd/empty [deleted file]
usr/spool/lpd/dummy [new file with mode: 0644]
usr/spool/mail/dmr [deleted file]
usr/spool/mail/dummy [new file with mode: 0644]
usr/spool/mail/root [deleted file]
usr/spool/uucp/users/dummy [new file with mode: 0644]
usr/src/cmd/Admin/Mk [new file with mode: 0755]
usr/src/cmd/Admin/destinations [new file with mode: 0644]
usr/src/cmd/adb/:rofix [new file with mode: 0644]
usr/src/cmd/adb/Makefile [new file with mode: 0644]
usr/src/cmd/adb/access.c
usr/src/cmd/adb/command.c
usr/src/cmd/adb/defs.h
usr/src/cmd/adb/dummy.c [deleted file]
usr/src/cmd/adb/err [new file with mode: 0644]
usr/src/cmd/adb/expr.c
usr/src/cmd/adb/findfn.c [deleted file]
usr/src/cmd/adb/format.c
usr/src/cmd/adb/input.c
usr/src/cmd/adb/mac.h
usr/src/cmd/adb/machine.h
usr/src/cmd/adb/main.c
usr/src/cmd/adb/makefile [deleted file]
usr/src/cmd/adb/message.c
usr/src/cmd/adb/mode.h
usr/src/cmd/adb/opset.c
usr/src/cmd/adb/optab.c [new file with mode: 0644]
usr/src/cmd/adb/output.c
usr/src/cmd/adb/pcs.c
usr/src/cmd/adb/print.c
usr/src/cmd/adb/runpcs.c
usr/src/cmd/adb/setup.c
usr/src/cmd/adb/sym.c
usr/src/cmd/ar11.c [new file with mode: 0644]
usr/src/cmd/args.c [new file with mode: 0644]
usr/src/cmd/arithmetic.c [new file with mode: 0644]
usr/src/cmd/as/:rofix [new file with mode: 0755]
usr/src/cmd/as/:yyfix [new file with mode: 0755]
usr/src/cmd/as/Makefile [new file with mode: 0644]
usr/src/cmd/as/as.h [new file with mode: 0644]
usr/src/cmd/as/as0.y [new file with mode: 0644]
usr/src/cmd/as/as1.c [new file with mode: 0644]
usr/src/cmd/as/as11.s [deleted file]
usr/src/cmd/as/as12.s [deleted file]
usr/src/cmd/as/as13.s [deleted file]
usr/src/cmd/as/as14.s [deleted file]
usr/src/cmd/as/as15.s [deleted file]
usr/src/cmd/as/as16.s [deleted file]
usr/src/cmd/as/as17.s [deleted file]
usr/src/cmd/as/as18.s [deleted file]
usr/src/cmd/as/as19.s [deleted file]
usr/src/cmd/as/as2.c [new file with mode: 0644]
usr/src/cmd/as/as21.s [deleted file]
usr/src/cmd/as/as22.s [deleted file]
usr/src/cmd/as/as23.s [deleted file]
usr/src/cmd/as/as24.s [deleted file]
usr/src/cmd/as/as25.s [deleted file]
usr/src/cmd/as/as26.s [deleted file]
usr/src/cmd/as/as27.s [deleted file]
usr/src/cmd/as/as28.s [deleted file]
usr/src/cmd/as/as29.s [deleted file]
usr/src/cmd/as/as3.c [new file with mode: 0644]
usr/src/cmd/as/err [new file with mode: 0644]
usr/src/cmd/as/instrs [new file with mode: 0644]
usr/src/cmd/as/makefile [deleted file]
usr/src/cmd/atrun.c
usr/src/cmd/awk/Makefile [new file with mode: 0644]
usr/src/cmd/awk/awk.def
usr/src/cmd/awk/awk.h [new file with mode: 0644]
usr/src/cmd/awk/awk.lx.l
usr/src/cmd/awk/b.c
usr/src/cmd/awk/dump.c [new file with mode: 0644]
usr/src/cmd/awk/lib.c
usr/src/cmd/awk/makefile [deleted file]
usr/src/cmd/awk/proc.c
usr/src/cmd/awk/run.c
usr/src/cmd/awk/tran.c
usr/src/cmd/bas/bas.s [deleted file]
usr/src/cmd/bas/makefile [deleted file]
usr/src/cmd/bc.y
usr/src/cmd/bcd.c [new file with mode: 0644]
usr/src/cmd/c/c0.h [deleted file]
usr/src/cmd/c/c00.c [deleted file]
usr/src/cmd/c/c01.c [deleted file]
usr/src/cmd/c/c02.c [deleted file]
usr/src/cmd/c/c03.c [deleted file]
usr/src/cmd/c/c04.c [deleted file]
usr/src/cmd/c/c05.c [deleted file]
usr/src/cmd/c/c1.h [deleted file]
usr/src/cmd/c/c10.c [deleted file]
usr/src/cmd/c/c11.c [deleted file]
usr/src/cmd/c/c12.c [deleted file]
usr/src/cmd/c/c13.c [deleted file]
usr/src/cmd/c/c2.h [deleted file]
usr/src/cmd/c/c20.c [deleted file]
usr/src/cmd/c/c21.c [deleted file]
usr/src/cmd/c/cvopt.c [deleted file]
usr/src/cmd/c/makefile [deleted file]
usr/src/cmd/c/table.s [deleted file]
usr/src/cmd/c2/Makefile [new file with mode: 0644]
usr/src/cmd/c2/c2.h [new file with mode: 0644]
usr/src/cmd/c2/c20.c [new file with mode: 0644]
usr/src/cmd/c2/c21.c [new file with mode: 0644]
usr/src/cmd/c2/c22.c [new file with mode: 0644]
usr/src/cmd/calendar.c [deleted file]
usr/src/cmd/calendar/Makefile [new file with mode: 0644]
usr/src/cmd/calendar/calendar.c [new file with mode: 0644]
usr/src/cmd/calendar/calendar.sh [new file with mode: 0755]
usr/src/cmd/call.c [new file with mode: 0644]
usr/src/cmd/cb.c
usr/src/cmd/cc.c
usr/src/cmd/checkeq.c
usr/src/cmd/cmake [deleted file]
usr/src/cmd/col.c
usr/src/cmd/cpall.c [new file with mode: 0644]
usr/src/cmd/cpio.c [new file with mode: 0644]
usr/src/cmd/cpp/Makefile [new file with mode: 0644]
usr/src/cmd/cpp/README
usr/src/cmd/cpp/makefile [deleted file]
usr/src/cmd/cpp/yylex.c
usr/src/cmd/cron.c
usr/src/cmd/cvtbl.c [new file with mode: 0644]
usr/src/cmd/dc/Makefile [new file with mode: 0644]
usr/src/cmd/dc/dc.c
usr/src/cmd/dc/makefile [deleted file]
usr/src/cmd/dcheck.c
usr/src/cmd/dd.c
usr/src/cmd/deroff.c
usr/src/cmd/df.c
usr/src/cmd/diff3.c [deleted file]
usr/src/cmd/diff3/Makefile [new file with mode: 0644]
usr/src/cmd/diff3/diff3.c [new file with mode: 0644]
usr/src/cmd/diff3/diff3.sh [new file with mode: 0755]
usr/src/cmd/dpr.c [new file with mode: 0644]
usr/src/cmd/draw.c [new file with mode: 0644]
usr/src/cmd/dump.c
usr/src/cmd/dumpdir.c
usr/src/cmd/egrep.y
usr/src/cmd/eqn/Makefile [new file with mode: 0644]
usr/src/cmd/eqn/makefile [deleted file]
usr/src/cmd/f77/Makefile [new file with mode: 0644]
usr/src/cmd/f77/defs
usr/src/cmd/f77/dmrdefs [deleted file]
usr/src/cmd/f77/drivedefs
usr/src/cmd/f77/driver.c
usr/src/cmd/f77/exec.c
usr/src/cmd/f77/expr.c
usr/src/cmd/f77/gram.dcl
usr/src/cmd/f77/gram.exec
usr/src/cmd/f77/gram.head
usr/src/cmd/f77/init.c
usr/src/cmd/f77/letters [new file with mode: 0644]
usr/src/cmd/f77/lex.c
usr/src/cmd/f77/locdefs
usr/src/cmd/f77/main.c
usr/src/cmd/f77/makefile [deleted file]
usr/src/cmd/f77/malloc.c [deleted file]
usr/src/cmd/f77/nnnn [new file with mode: 0644]
usr/src/cmd/f77/pdp11.c [deleted file]
usr/src/cmd/f77/pdp11defs [deleted file]
usr/src/cmd/f77/pdp11x.c [deleted file]
usr/src/cmd/f77/proc.c
usr/src/cmd/f77/putdmr.c [deleted file]
usr/src/cmd/f77/putscj.c [deleted file]
usr/src/cmd/f77/putscjb.c [new file with mode: 0644]
usr/src/cmd/f77/vax.c [new file with mode: 0644]
usr/src/cmd/f77/vaxdefs [new file with mode: 0644]
usr/src/cmd/f77/vaxx.c [new file with mode: 0644]
usr/src/cmd/factor.s [deleted file]
usr/src/cmd/false.sh [new file with mode: 0755]
usr/src/cmd/fgrep.c
usr/src/cmd/file.c
usr/src/cmd/find.c
usr/src/cmd/getty.c
usr/src/cmd/graph.c [deleted file]
usr/src/cmd/graph/Makefile [new file with mode: 0644]
usr/src/cmd/graph/graph.c [new file with mode: 0644]
usr/src/cmd/grep.c
usr/src/cmd/group.c [new file with mode: 0644]
usr/src/cmd/in [deleted file]
usr/src/cmd/init.c
usr/src/cmd/install.sh [new file with mode: 0755]
usr/src/cmd/iostat.c
usr/src/cmd/ld.c
usr/src/cmd/learn/makefile
usr/src/cmd/learn/omakefile [new file with mode: 0644]
usr/src/cmd/learn/origmakefile [new file with mode: 0644]
usr/src/cmd/learn/temp [new file with mode: 0644]
usr/src/cmd/lex/Makefile [new file with mode: 0644]
usr/src/cmd/lex/err [new file with mode: 0644]
usr/src/cmd/lex/lmain.c
usr/src/cmd/lex/makefile [deleted file]
usr/src/cmd/lex/ncform [new file with mode: 0644]
usr/src/cmd/lex/once.c
usr/src/cmd/lex/parser.y
usr/src/cmd/lex/sub1.c
usr/src/cmd/lex/sub2.c
usr/src/cmd/lex/y.tab.c [new file with mode: 0644]
usr/src/cmd/line.c [new file with mode: 0644]
usr/src/cmd/lint/Makefile [new file with mode: 0644]
usr/src/cmd/lint/SHELL
usr/src/cmd/lint/llib-lc [new file with mode: 0644]
usr/src/cmd/lint/llib-port [new file with mode: 0644]
usr/src/cmd/lint/makefile [deleted file]
usr/src/cmd/login.c
usr/src/cmd/lookbib.sh [new file with mode: 0755]
usr/src/cmd/lorder.sh [new file with mode: 0755]
usr/src/cmd/lpd.c [new file with mode: 0644]
usr/src/cmd/lpr.c [new file with mode: 0644]
usr/src/cmd/lpr/chrtab.c [deleted file]
usr/src/cmd/lpr/daemon.c [deleted file]
usr/src/cmd/lpr/daemon0.c [deleted file]
usr/src/cmd/lpr/lpd.c [deleted file]
usr/src/cmd/lpr/lpr.c [deleted file]
usr/src/cmd/lpr/makefile [deleted file]
usr/src/cmd/lpr/spool.c [deleted file]
usr/src/cmd/ls.c
usr/src/cmd/m4/Makefile [new file with mode: 0644]
usr/src/cmd/m4/makefile [deleted file]
usr/src/cmd/mail.c
usr/src/cmd/make/Makefile [new file with mode: 0644]
usr/src/cmd/make/dosys.c
usr/src/cmd/make/files.c
usr/src/cmd/make/ident.c
usr/src/cmd/make/main.c
usr/src/cmd/make/makefile [deleted file]
usr/src/cmd/make/misc.c
usr/src/cmd/makeall [deleted file]
usr/src/cmd/man.sh [new file with mode: 0755]
usr/src/cmd/mip/allo.c
usr/src/cmd/mip/cgram.c [new file with mode: 0644]
usr/src/cmd/mip/cgram.y
usr/src/cmd/mip/g [deleted file]
usr/src/cmd/mip/makefile [deleted file]
usr/src/cmd/mip/manifest
usr/src/cmd/mip/match.c
usr/src/cmd/mip/mfile1
usr/src/cmd/mip/mfile2
usr/src/cmd/mip/pftn.c
usr/src/cmd/mip/reader.c
usr/src/cmd/mip/scan.c
usr/src/cmd/mip/xdefs.c
usr/src/cmd/mtm.c [new file with mode: 0644]
usr/src/cmd/mvall.c [new file with mode: 0644]
usr/src/cmd/neqn/Makefile [new file with mode: 0644]
usr/src/cmd/neqn/makefile [deleted file]
usr/src/cmd/neqn/sqrt.c
usr/src/cmd/news.sh [new file with mode: 0755]
usr/src/cmd/nm.c
usr/src/cmd/nohup.sh [new file with mode: 0755]
usr/src/cmd/number.c [new file with mode: 0644]
usr/src/cmd/opr.c [new file with mode: 0644]
usr/src/cmd/osh.c [deleted file]
usr/src/cmd/paste.c [new file with mode: 0644]
usr/src/cmd/pcat.c [new file with mode: 0644]
usr/src/cmd/pcc/:rofix [new file with mode: 0755]
usr/src/cmd/pcc/:yyfix [new file with mode: 0755]
usr/src/cmd/pcc/code.c
usr/src/cmd/pcc/err [new file with mode: 0644]
usr/src/cmd/pcc/fort.h [new file with mode: 0644]
usr/src/cmd/pcc/local.c
usr/src/cmd/pcc/local2.c
usr/src/cmd/pcc/mac2defs
usr/src/cmd/pcc/macdefs
usr/src/cmd/pcc/makefile
usr/src/cmd/pcc/order.c
usr/src/cmd/pcc/table.c
usr/src/cmd/pcs.c [new file with mode: 0644]
usr/src/cmd/pg.c [new file with mode: 0644]
usr/src/cmd/plot/Makefile [new file with mode: 0644]
usr/src/cmd/plot/makefile [deleted file]
usr/src/cmd/plot/plot.sh [new file with mode: 0755]
usr/src/cmd/plot/vplot.c
usr/src/cmd/pr.c
usr/src/cmd/prep.h [deleted file]
usr/src/cmd/prep/makefile [deleted file]
usr/src/cmd/prep/prep.h [deleted file]
usr/src/cmd/prep/prep0.c [deleted file]
usr/src/cmd/prep/prep1.c [deleted file]
usr/src/cmd/prep/prep2.c [deleted file]
usr/src/cmd/primes.s [deleted file]
usr/src/cmd/prof.c [deleted file]
usr/src/cmd/prof/Makefile [new file with mode: 0644]
usr/src/cmd/prof/prof.c [new file with mode: 0644]
usr/src/cmd/ps.c
usr/src/cmd/ps.slow.c [new file with mode: 0644]
usr/src/cmd/pstat.c
usr/src/cmd/ptx.c
usr/src/cmd/quiz.c [new file with mode: 0644]
usr/src/cmd/random.c
usr/src/cmd/ranlib.c [deleted file]
usr/src/cmd/ratfor/Makefile [new file with mode: 0644]
usr/src/cmd/ratfor/makefile [deleted file]
usr/src/cmd/ratfor/r1.c
usr/src/cmd/ratfor/rio.c
usr/src/cmd/rc.c [new file with mode: 0644]
usr/src/cmd/refer/Makefile [new file with mode: 0644]
usr/src/cmd/refer/deliv2.c
usr/src/cmd/refer/glue1.c
usr/src/cmd/refer/glue4.c
usr/src/cmd/refer/glue5.c
usr/src/cmd/refer/hunt1.c
usr/src/cmd/refer/hunt2.c
usr/src/cmd/refer/hunt3.c
usr/src/cmd/refer/hunt6.c
usr/src/cmd/refer/hunt7.c
usr/src/cmd/refer/hunt8.c
usr/src/cmd/refer/inv1.c
usr/src/cmd/refer/inv2.c
usr/src/cmd/refer/inv5.c
usr/src/cmd/refer/inv6.c
usr/src/cmd/refer/makefile [deleted file]
usr/src/cmd/refer/mkey1.c
usr/src/cmd/refer/mkey2.c
usr/src/cmd/refer/mkey3.c
usr/src/cmd/refer/refer..c
usr/src/cmd/refer/refer0.c
usr/src/cmd/refer/refer1.c
usr/src/cmd/refer/refer2.c
usr/src/cmd/refer/refer4.c
usr/src/cmd/refer/refer5.c
usr/src/cmd/refer/refer6.c
usr/src/cmd/refer/refer7.c
usr/src/cmd/refer/refer8.c
usr/src/cmd/refer/sample [new file with mode: 0644]
usr/src/cmd/restor.c
usr/src/cmd/rew.c [new file with mode: 0644]
usr/src/cmd/roff/makefile [deleted file]
usr/src/cmd/roff/roff1.s [deleted file]
usr/src/cmd/roff/roff2.s [deleted file]
usr/src/cmd/roff/roff3.s [deleted file]
usr/src/cmd/roff/roff4.s [deleted file]
usr/src/cmd/roff/roff5.s [deleted file]
usr/src/cmd/roff/roff7.s [deleted file]
usr/src/cmd/roff/roff8.s [deleted file]
usr/src/cmd/sa.c
usr/src/cmd/sdb/Makefile [new file with mode: 0644]
usr/src/cmd/sdb/a.out.h [new file with mode: 0644]
usr/src/cmd/sdb/access.c [new file with mode: 0644]
usr/src/cmd/sdb/bio.c [new file with mode: 0644]
usr/src/cmd/sdb/bio.h [new file with mode: 0644]
usr/src/cmd/sdb/cdefs.h [new file with mode: 0644]
usr/src/cmd/sdb/decode.c [new file with mode: 0644]
usr/src/cmd/sdb/defs.h [new file with mode: 0644]
usr/src/cmd/sdb/display.c [new file with mode: 0644]
usr/src/cmd/sdb/docomm.c [new file with mode: 0644]
usr/src/cmd/sdb/err [new file with mode: 0644]
usr/src/cmd/sdb/fio.c [new file with mode: 0644]
usr/src/cmd/sdb/head.h [new file with mode: 0644]
usr/src/cmd/sdb/install [new file with mode: 0755]
usr/src/cmd/sdb/mac.h [new file with mode: 0644]
usr/src/cmd/sdb/machine.h [new file with mode: 0644]
usr/src/cmd/sdb/main.c [new file with mode: 0644]
usr/src/cmd/sdb/make [new file with mode: 0644]
usr/src/cmd/sdb/message.c [new file with mode: 0644]
usr/src/cmd/sdb/mode.h [new file with mode: 0644]
usr/src/cmd/sdb/ntest [new file with mode: 0644]
usr/src/cmd/sdb/pcs.c [new file with mode: 0644]
usr/src/cmd/sdb/re.c [new file with mode: 0644]
usr/src/cmd/sdb/runpcs.c [new file with mode: 0644]
usr/src/cmd/sdb/setup.c [new file with mode: 0644]
usr/src/cmd/sdb/sub.c [new file with mode: 0644]
usr/src/cmd/sdb/symt.c [new file with mode: 0644]
usr/src/cmd/sdb/udef.c [new file with mode: 0644]
usr/src/cmd/sdb/xeq.c [new file with mode: 0644]
usr/src/cmd/sed/Makefile [new file with mode: 0644]
usr/src/cmd/sed/makefile [deleted file]
usr/src/cmd/sed/sed.h
usr/src/cmd/sed/sed0.c
usr/src/cmd/sed/sed1.c
usr/src/cmd/sh/Makefile [new file with mode: 0644]
usr/src/cmd/sh/main.c
usr/src/cmd/sh/makefile [deleted file]
usr/src/cmd/sh/timeout.h
usr/src/cmd/size.c
usr/src/cmd/sort.c
usr/src/cmd/spell/Makefile [new file with mode: 0644]
usr/src/cmd/spell/american
usr/src/cmd/spell/british
usr/src/cmd/spell/makefile [deleted file]
usr/src/cmd/spell/spell.c
usr/src/cmd/spell/spell.sh [new file with mode: 0755]
usr/src/cmd/spell/stop
usr/src/cmd/spline.c
usr/src/cmd/standalone/M.s [deleted file]
usr/src/cmd/standalone/SYS.c [deleted file]
usr/src/cmd/standalone/boot.c [deleted file]
usr/src/cmd/standalone/cat.c [deleted file]
usr/src/cmd/standalone/cc+ld-stand [deleted file]
usr/src/cmd/standalone/conf.c [deleted file]
usr/src/cmd/standalone/contents [deleted file]
usr/src/cmd/standalone/cpgroup [deleted file]
usr/src/cmd/standalone/hp.c [deleted file]
usr/src/cmd/standalone/ht.c [deleted file]
usr/src/cmd/standalone/makefile [deleted file]
usr/src/cmd/standalone/maketape.c [deleted file]
usr/src/cmd/standalone/mtboot.s [deleted file]
usr/src/cmd/standalone/prf.c [deleted file]
usr/src/cmd/standalone/rk.c [deleted file]
usr/src/cmd/standalone/rkcontents [deleted file]
usr/src/cmd/standalone/rktapedir [deleted file]
usr/src/cmd/standalone/rp.c [deleted file]
usr/src/cmd/standalone/saio.h [deleted file]
usr/src/cmd/standalone/srt0.s [deleted file]
usr/src/cmd/standalone/tapedir [deleted file]
usr/src/cmd/standalone/tm.c [deleted file]
usr/src/cmd/strip.c
usr/src/cmd/struct/0.graph.c
usr/src/cmd/struct/0.list.c
usr/src/cmd/struct/1.form.c
usr/src/cmd/struct/1.fort.c
usr/src/cmd/struct/1.node.c
usr/src/cmd/struct/1.recog.c
usr/src/cmd/struct/4.out.c
usr/src/cmd/struct/Makefile [new file with mode: 0644]
usr/src/cmd/struct/beauty.c [new file with mode: 0644]
usr/src/cmd/struct/beauty.y
usr/src/cmd/struct/err [new file with mode: 0644]
usr/src/cmd/struct/makefile [deleted file]
usr/src/cmd/struct/struct [new file with mode: 0755]
usr/src/cmd/struct/y.tab.h [new file with mode: 0644]
usr/src/cmd/su.c
usr/src/cmd/tabs.c
usr/src/cmd/tabs4.sh [new file with mode: 0755]
usr/src/cmd/tabs8.sh [new file with mode: 0755]
usr/src/cmd/tail.c
usr/src/cmd/tar.c [new file with mode: 0644]
usr/src/cmd/tar/makefile [deleted file]
usr/src/cmd/tar/tar.c [deleted file]
usr/src/cmd/tbl/Makefile [new file with mode: 0644]
usr/src/cmd/tbl/makefile [deleted file]
usr/src/cmd/tbl/t1.c
usr/src/cmd/tbl/t3.c
usr/src/cmd/tbl/t8.c
usr/src/cmd/tc.c
usr/src/cmd/tp/Makefile [new file with mode: 0644]
usr/src/cmd/tp/makefile [deleted file]
usr/src/cmd/tp/tp2.c
usr/src/cmd/troff/Makefile [new file with mode: 0644]
usr/src/cmd/troff/Makenroff [new file with mode: 0644]
usr/src/cmd/troff/Maketroff [new file with mode: 0644]
usr/src/cmd/troff/font/ftBC.n [new file with mode: 0644]
usr/src/cmd/troff/font/ftC.n [new file with mode: 0644]
usr/src/cmd/troff/font/ftCW.n [new file with mode: 0644]
usr/src/cmd/troff/font/ftGR.n [new file with mode: 0644]
usr/src/cmd/troff/font/ftR.n [new file with mode: 0644]
usr/src/cmd/troff/font/makefile [deleted file]
usr/src/cmd/troff/font/onefont [new file with mode: 0755]
usr/src/cmd/troff/makefile [deleted file]
usr/src/cmd/troff/n2.c
usr/src/cmd/troff/n3.c
usr/src/cmd/troff/nmake [deleted file]
usr/src/cmd/troff/tdef.h
usr/src/cmd/troff/term/Makefile [new file with mode: 0644]
usr/src/cmd/troff/term/code.300
usr/src/cmd/troff/term/makefile [deleted file]
usr/src/cmd/troff/term/tab300-12.c [deleted file]
usr/src/cmd/troff/term/tab300.c
usr/src/cmd/troff/term/tab300S.c [new file with mode: 0644]
usr/src/cmd/troff/term/tab300X.c [new file with mode: 0644]
usr/src/cmd/troff/term/tab300s-12.c [deleted file]
usr/src/cmd/troff/term/tab300s.c
usr/src/cmd/troff/term/tab37.c
usr/src/cmd/troff/term/tab450-12.c
usr/src/cmd/troff/term/tab450.c
usr/src/cmd/troff/term/tab450X.c [new file with mode: 0644]
usr/src/cmd/troff/term/tab832.c [deleted file]
usr/src/cmd/troff/term/taba1.c [deleted file]
usr/src/cmd/troff/term/tablp.c [deleted file]
usr/src/cmd/troff/term/tabtn300.c
usr/src/cmd/troff/textscript [deleted file]
usr/src/cmd/troff/tmake [deleted file]
usr/src/cmd/true.sh [new file with mode: 0755]
usr/src/cmd/tsort.c
usr/src/cmd/und.c [new file with mode: 0644]
usr/src/cmd/units.c
usr/src/cmd/uucp/anyread.c [new file with mode: 0644]
usr/src/cmd/uucp/chkpth.c
usr/src/cmd/uucp/conn.c
usr/src/cmd/uucp/getprm.c
usr/src/cmd/uucp/gnamef.c
usr/src/cmd/uucp/makefile
usr/src/cmd/uucp/pk0.c
usr/src/cmd/uucp/pk1.c
usr/src/cmd/uucp/systat.c
usr/src/cmd/uucp/uucp.h
usr/src/cmd/uucp/uux.c
usr/src/cmd/uudiff/Makefile [new file with mode: 0644]
usr/src/cmd/uudiff/lenrem.c [new file with mode: 0644]
usr/src/cmd/uudiff/locpart.c [new file with mode: 0644]
usr/src/cmd/uudiff/printable.c [new file with mode: 0644]
usr/src/cmd/uudiff/remdiff [new file with mode: 0755]
usr/src/cmd/uudiff/run1.c [new file with mode: 0644]
usr/src/cmd/uudiff/trim.c [new file with mode: 0644]
usr/src/cmd/vis.c [new file with mode: 0644]
usr/src/cmd/wall.c
usr/src/cmd/who.c
usr/src/cmd/write.c
usr/src/cmd/xsend/makefile
usr/src/cmd/yacc/Makefile [new file with mode: 0644]
usr/src/cmd/yacc/files
usr/src/cmd/yacc/makefile [deleted file]
usr/src/cmd/yacc/yaccdiffs [new file with mode: 0644]
usr/src/cmd/yacc/yaccnews [new file with mode: 0644]
usr/src/cmd/yacc/yaccpar [new file with mode: 0644]
usr/src/games/arithmetic.c [deleted file]
usr/src/games/backgammon.c [deleted file]
usr/src/games/chess/README [deleted file]
usr/src/games/chess/agen.c [deleted file]
usr/src/games/chess/att.s [deleted file]
usr/src/games/chess/bgen.s [deleted file]
usr/src/games/chess/bheur.c [deleted file]
usr/src/games/chess/bmove.s [deleted file]
usr/src/games/chess/book.c [deleted file]
usr/src/games/chess/bplay.c [deleted file]
usr/src/games/chess/ctrl.s [deleted file]
usr/src/games/chess/data.c [deleted file]
usr/src/games/chess/init.c [deleted file]
usr/src/games/chess/io.c [deleted file]
usr/src/games/chess/makefile [deleted file]
usr/src/games/chess/mater.c [deleted file]
usr/src/games/chess/old.h [deleted file]
usr/src/games/chess/pio.c [deleted file]
usr/src/games/chess/play.c [deleted file]
usr/src/games/chess/qsort.s [deleted file]
usr/src/games/chess/savres.c [deleted file]
usr/src/games/chess/setup.c [deleted file]
usr/src/games/chess/stat.c [deleted file]
usr/src/games/chess/stdin.c [deleted file]
usr/src/games/chess/wgen.s [deleted file]
usr/src/games/chess/wheur.c [deleted file]
usr/src/games/chess/wmove.s [deleted file]
usr/src/games/chess/wplay.c [deleted file]
usr/src/games/fish.c [deleted file]
usr/src/games/fortune.c
usr/src/games/hangman.c [deleted file]
usr/src/games/quiz.c [deleted file]
usr/src/games/wump.c [deleted file]
usr/src/libF77/compall [deleted file]
usr/src/libF77/d_erf.c [new file with mode: 0644]
usr/src/libF77/d_erfc.c [new file with mode: 0644]
usr/src/libF77/erf.c [new file with mode: 0644]
usr/src/libF77/mklib [deleted file]
usr/src/libF77/r_erf.c [new file with mode: 0644]
usr/src/libF77/r_erfc.c [new file with mode: 0644]
usr/src/libF77/sinh.c [new file with mode: 0644]
usr/src/libF77/tanh.c [new file with mode: 0644]
usr/src/libI77/fmt.c
usr/src/libI77/fmt.h
usr/src/libI77/fmtlib.c
usr/src/libI77/lread.c
usr/src/libI77/pwd.c [new file with mode: 0644]
usr/src/libI77/rdfmt.c
usr/src/libI77/rewind.c
usr/src/libI77/wrtfmt.c
usr/src/libI77/wsfe.c
usr/src/libc/Makefile [new file with mode: 0644]
usr/src/libc/compall [deleted file]
usr/src/libc/crt/aldiv.s [deleted file]
usr/src/libc/crt/almul.s [deleted file]
usr/src/libc/crt/alrem.s [deleted file]
usr/src/libc/crt/cerror.s
usr/src/libc/crt/csv.s [deleted file]
usr/src/libc/crt/ldiv.s [deleted file]
usr/src/libc/crt/lmul.s [deleted file]
usr/src/libc/crt/lrem.s [deleted file]
usr/src/libc/crt/mcount.s [changed mode: 0644->0755]
usr/src/libc/csu/crt0.s
usr/src/libc/csu/fcrt0.s [deleted file]
usr/src/libc/csu/fmcrt0.s [deleted file]
usr/src/libc/csu/mcrt0.s
usr/src/libc/gen/abort.s [deleted file]
usr/src/libc/gen/abs.c [deleted file]
usr/src/libc/gen/atof.c
usr/src/libc/gen/atofo.s [new file with mode: 0644]
usr/src/libc/gen/atoi.c [deleted file]
usr/src/libc/gen/atos.c [new file with mode: 0644]
usr/src/libc/gen/chrtab.c [new file with mode: 0644]
usr/src/libc/gen/crypt.c
usr/src/libc/gen/cuexit.s [deleted file]
usr/src/libc/gen/fakcu.s [deleted file]
usr/src/libc/gen/fakfp.s [deleted file]
usr/src/libc/gen/frexp.c [new file with mode: 0644]
usr/src/libc/gen/frexp11.s [deleted file]
usr/src/libc/gen/isatty.c [changed mode: 0644->0755]
usr/src/libc/gen/l3.c [deleted file]
usr/src/libc/gen/l3tol.c [new file with mode: 0644]
usr/src/libc/gen/ldexp.c [new file with mode: 0644]
usr/src/libc/gen/ldexp11.s [deleted file]
usr/src/libc/gen/ldfps.s [deleted file]
usr/src/libc/gen/ltol3.c [new file with mode: 0755]
usr/src/libc/gen/malloc.c [changed mode: 0644->0755]
usr/src/libc/gen/mktemp.c [changed mode: 0644->0755]
usr/src/libc/gen/modf.c [new file with mode: 0644]
usr/src/libc/gen/modf11.s [deleted file]
usr/src/libc/gen/mon.c [changed mode: 0644->0755]
usr/src/libc/gen/mpx.c [deleted file]
usr/src/libc/gen/nlist.c [changed mode: 0644->0755]
usr/src/libc/gen/perror.c [changed mode: 0644->0755]
usr/src/libc/gen/pkon.c [deleted file]
usr/src/libc/gen/qsort.c [changed mode: 0644->0755]
usr/src/libc/gen/rand.c
usr/src/libc/gen/rin.c [new file with mode: 0755]
usr/src/libc/gen/setjmp.s [deleted file]
usr/src/libc/gen/sleep.c [changed mode: 0644->0755]
usr/src/libc/gen/strcat.c [changed mode: 0644->0755]
usr/src/libc/gen/strcatn.c [new file with mode: 0644]
usr/src/libc/gen/strcmp.c [changed mode: 0644->0755]
usr/src/libc/gen/strcmpn.c [new file with mode: 0644]
usr/src/libc/gen/strcpyn.c [new file with mode: 0644]
usr/src/libc/gen/swab.c [changed mode: 0644->0755]
usr/src/libc/gen/ttyslot.c [changed mode: 0644->0755]
usr/src/libc/gen/ttytest.c [new file with mode: 0644]
usr/src/libc/mklib [deleted file]
usr/src/libc/stdio/Makefile [new file with mode: 0644]
usr/src/libc/stdio/data.c
usr/src/libc/stdio/doprnt.s
usr/src/libc/stdio/doscan.c
usr/src/libc/stdio/endopen.c [deleted file]
usr/src/libc/stdio/error.c [new file with mode: 0644]
usr/src/libc/stdio/fdopen.c
usr/src/libc/stdio/ffltpr.s [deleted file]
usr/src/libc/stdio/filbuf.c
usr/src/libc/stdio/findiop.c [deleted file]
usr/src/libc/stdio/flsbuf.c
usr/src/libc/stdio/fltpr.s [deleted file]
usr/src/libc/stdio/fopen.c
usr/src/libc/stdio/freopen.c
usr/src/libc/stdio/fseek.c
usr/src/libc/stdio/ftell.c
usr/src/libc/stdio/getw.c
usr/src/libc/stdio/intss.c [new file with mode: 0644]
usr/src/libc/stdio/ios.r [new file with mode: 0644]
usr/src/libc/stdio/portli.cc [new file with mode: 0644]
usr/src/libc/stdio/putw.c
usr/src/libc/stdio/rew.c
usr/src/libc/stdio/strout.c
usr/src/libc/stdio/stuff.c [new file with mode: 0644]
usr/src/libc/stdio/tmpnam.c [new file with mode: 0644]
usr/src/libc/sys/_exit.s [new file with mode: 0644]
usr/src/libc/sys/abort.s [new file with mode: 0644]
usr/src/libc/sys/abs.s [new file with mode: 0644]
usr/src/libc/sys/access.s
usr/src/libc/sys/acct.s [changed mode: 0644->0755]
usr/src/libc/sys/alarm.s
usr/src/libc/sys/alloca.s [new file with mode: 0644]
usr/src/libc/sys/cerror.s [new file with mode: 0644]
usr/src/libc/sys/chdir.s
usr/src/libc/sys/chmod.s
usr/src/libc/sys/chown.s
usr/src/libc/sys/chroot.s
usr/src/libc/sys/cleanup.s [new file with mode: 0644]
usr/src/libc/sys/close.s
usr/src/libc/sys/creat.s
usr/src/libc/sys/crt0.s [new file with mode: 0644]
usr/src/libc/sys/dup.s
usr/src/libc/sys/execl.s
usr/src/libc/sys/execle.s
usr/src/libc/sys/execv.s
usr/src/libc/sys/execve.s
usr/src/libc/sys/exit.s
usr/src/libc/sys/fork.s
usr/src/libc/sys/fstat.s
usr/src/libc/sys/getcsw.s [new file with mode: 0644]
usr/src/libc/sys/getgid.s
usr/src/libc/sys/getpid.s
usr/src/libc/sys/getuid.s
usr/src/libc/sys/ioctl.s
usr/src/libc/sys/itol.s [new file with mode: 0755]
usr/src/libc/sys/kill.s [changed mode: 0644->0755]
usr/src/libc/sys/link.s [changed mode: 0644->0755]
usr/src/libc/sys/lock.s [deleted file]
usr/src/libc/sys/locv.s [new file with mode: 0755]
usr/src/libc/sys/lseek.s [changed mode: 0644->0755]
usr/src/libc/sys/ltod.s [new file with mode: 0755]
usr/src/libc/sys/ltoi.s [new file with mode: 0755]
usr/src/libc/sys/makdir.s [new file with mode: 0755]
usr/src/libc/sys/mcount.s [new file with mode: 0755]
usr/src/libc/sys/mcrt0.s [new file with mode: 0644]
usr/src/libc/sys/mdate.s [new file with mode: 0755]
usr/src/libc/sys/mknod.s
usr/src/libc/sys/mount.s [changed mode: 0644->0755]
usr/src/libc/sys/mpxcall.s [deleted file]
usr/src/libc/sys/nargs.s [new file with mode: 0755]
usr/src/libc/sys/nexect.s [new file with mode: 0644]
usr/src/libc/sys/nice.s [changed mode: 0644->0755]
usr/src/libc/sys/open.s [changed mode: 0644->0755]
usr/src/libc/sys/pause.s [deleted file]
usr/src/libc/sys/phys.s [deleted file]
usr/src/libc/sys/pipe.s
usr/src/libc/sys/prof.s [new file with mode: 0755]
usr/src/libc/sys/profil.s [deleted file]
usr/src/libc/sys/ptrace.s [changed mode: 0644->0755]
usr/src/libc/sys/read.s
usr/src/libc/sys/reset.s [new file with mode: 0755]
usr/src/libc/sys/sbrk.s [changed mode: 0644->0755]
usr/src/libc/sys/setgid.s [changed mode: 0644->0755]
usr/src/libc/sys/setjmp.s [new file with mode: 0755]
usr/src/libc/sys/setuid.s [changed mode: 0644->0755]
usr/src/libc/sys/signal.s
usr/src/libc/sys/stat.s [changed mode: 0644->0755]
usr/src/libc/sys/stime.s [changed mode: 0644->0755]
usr/src/libc/sys/sync.s [changed mode: 0644->0755]
usr/src/libc/sys/syscall.s [new file with mode: 0644]
usr/src/libc/sys/time.s [changed mode: 0644->0755]
usr/src/libc/sys/times.s [changed mode: 0644->0755]
usr/src/libc/sys/umask.s
usr/src/libc/sys/umount.s [changed mode: 0644->0755]
usr/src/libc/sys/unlink.s
usr/src/libc/sys/utime.s
usr/src/libc/sys/wait.s [changed mode: 0644->0755]
usr/src/libc/sys/write.s [changed mode: 0644->0755]
usr/src/libc/v6/access.c [deleted file]
usr/src/libc/v6/chown.c [deleted file]
usr/src/libc/v6/execl.c [deleted file]
usr/src/libc/v6/ftime.c [deleted file]
usr/src/libc/v6/gtty.c [deleted file]
usr/src/libc/v6/lseek.c [deleted file]
usr/src/libc/v6/stat.c [deleted file]
usr/src/libc/v6/syscall.s [deleted file]
usr/src/libc/v6/time.s [deleted file]
usr/src/libdbm/Makefile [new file with mode: 0644]
usr/src/libdbm/compall [deleted file]
usr/src/libdbm/dbm.c
usr/src/libdbm/dbm.h
usr/src/libdbm/mklib [deleted file]
usr/src/libfpsim/compall [deleted file]
usr/src/libfpsim/fp1.s [deleted file]
usr/src/libfpsim/fp2.s [deleted file]
usr/src/libfpsim/fp3.s [deleted file]
usr/src/libfpsim/fpx.s [deleted file]
usr/src/libfpsim/mklib [deleted file]
usr/src/libg/Makefile [new file with mode: 0644]
usr/src/libg/dbxxx.s [new file with mode: 0644]
usr/src/libln/Makefile [new file with mode: 0644]
usr/src/libln/allprint.c [new file with mode: 0644]
usr/src/libln/main.c [new file with mode: 0644]
usr/src/libln/reject.c [new file with mode: 0644]
usr/src/libln/yyless.c [new file with mode: 0644]
usr/src/libln/yywrap.c [new file with mode: 0644]
usr/src/libm/Makefile [new file with mode: 0644]
usr/src/libm/asin.c
usr/src/libm/compall [deleted file]
usr/src/libm/erf.c [new file with mode: 0644]
usr/src/libm/mklib [deleted file]
usr/src/libnm/Makefile [new file with mode: 0644]
usr/src/libnm/acos.c [new file with mode: 0644]
usr/src/libnm/asin.s [new file with mode: 0644]
usr/src/libnm/atan.s [new file with mode: 0644]
usr/src/libnm/cbrt.s [new file with mode: 0644]
usr/src/libnm/exp.s [new file with mode: 0644]
usr/src/libnm/log.s [new file with mode: 0644]
usr/src/libnm/sin.s [new file with mode: 0644]
usr/src/libnm/sinh.s [new file with mode: 0644]
usr/src/libnm/sqrt.s [new file with mode: 0644]
usr/src/libnm/tan.s [new file with mode: 0644]
usr/src/libnm/tanh.s [new file with mode: 0644]
usr/src/libplot/Makefile [new file with mode: 0644]
usr/src/libplot/con.h [deleted file]
usr/src/libplot/makefile [deleted file]
usr/src/mdec/mboot.s [new file with mode: 0644]
usr/src/mdec/uboot.s [new file with mode: 0644]
usr/src/slowsys/h/acct.h [new file with mode: 0644]
usr/src/slowsys/h/buf.h [new file with mode: 0644]
usr/src/slowsys/h/callo.h [new file with mode: 0644]
usr/src/slowsys/h/chan.h [new file with mode: 0644]
usr/src/slowsys/h/clock.h [new file with mode: 0644]
usr/src/slowsys/h/clock.m [new file with mode: 0644]
usr/src/slowsys/h/conf.h [new file with mode: 0644]
usr/src/slowsys/h/cons.h [new file with mode: 0644]
usr/src/slowsys/h/cons.m [new file with mode: 0644]
usr/src/slowsys/h/dir.h [new file with mode: 0644]
usr/src/slowsys/h/fblk.h [new file with mode: 0644]
usr/src/slowsys/h/file.h [new file with mode: 0644]
usr/src/slowsys/h/filsys.h [new file with mode: 0644]
usr/src/slowsys/h/ino.h [new file with mode: 0644]
usr/src/slowsys/h/inode.h [new file with mode: 0644]
usr/src/slowsys/h/map.h [new file with mode: 0644]
usr/src/slowsys/h/mba.h [new file with mode: 0644]
usr/src/slowsys/h/mba.m [new file with mode: 0644]
usr/src/slowsys/h/mount.h [new file with mode: 0644]
usr/src/slowsys/h/mpx.h [new file with mode: 0644]
usr/src/slowsys/h/mtpr.h [new file with mode: 0644]
usr/src/slowsys/h/mtpr.m [new file with mode: 0644]
usr/src/slowsys/h/mx.h [new file with mode: 0644]
usr/src/slowsys/h/page.h [new file with mode: 0644]
usr/src/slowsys/h/page.m [new file with mode: 0644]
usr/src/slowsys/h/param.h [new file with mode: 0644]
usr/src/slowsys/h/pcb.h [new file with mode: 0644]
usr/src/slowsys/h/pcb.m [new file with mode: 0644]
usr/src/slowsys/h/proc.h [new file with mode: 0644]
usr/src/slowsys/h/psl.h [new file with mode: 0644]
usr/src/slowsys/h/psl.m [new file with mode: 0644]
usr/src/slowsys/h/reg.h [new file with mode: 0644]
usr/src/slowsys/h/seg.h [new file with mode: 0644]
usr/src/slowsys/h/stat.h [new file with mode: 0644]
usr/src/slowsys/h/systm.h [new file with mode: 0644]
usr/src/slowsys/h/text.h [new file with mode: 0644]
usr/src/slowsys/h/timeb.h [new file with mode: 0644]
usr/src/slowsys/h/trap.h [new file with mode: 0644]
usr/src/slowsys/h/trap.m [new file with mode: 0644]
usr/src/slowsys/h/tty.h [new file with mode: 0644]
usr/src/slowsys/h/uba.h [new file with mode: 0644]
usr/src/slowsys/h/uba.m [new file with mode: 0644]
usr/src/slowsys/h/user.h [new file with mode: 0644]
usr/src/slowsys/sys/acct.c [new file with mode: 0644]
usr/src/slowsys/sys/alloc.c [new file with mode: 0644]
usr/src/slowsys/sys/bio.c [new file with mode: 0644]
usr/src/slowsys/sys/clock.c [new file with mode: 0644]
usr/src/slowsys/sys/conf.c [new file with mode: 0644]
usr/src/slowsys/sys/cons.c [new file with mode: 0644]
usr/src/slowsys/sys/dkleave.c [new file with mode: 0644]
usr/src/slowsys/sys/dsort.c [new file with mode: 0644]
usr/src/slowsys/sys/dz.c [new file with mode: 0644]
usr/src/slowsys/sys/fio.c [new file with mode: 0644]
usr/src/slowsys/sys/hp.c [new file with mode: 0644]
usr/src/slowsys/sys/ht.c [new file with mode: 0644]
usr/src/slowsys/sys/iget.c [new file with mode: 0644]
usr/src/slowsys/sys/loadall [new file with mode: 0644]
usr/src/slowsys/sys/locore.s [new file with mode: 0644]
usr/src/slowsys/sys/machdep.c [new file with mode: 0644]
usr/src/slowsys/sys/main.c [new file with mode: 0644]
usr/src/slowsys/sys/makefile [new file with mode: 0644]
usr/src/slowsys/sys/malloc.c [new file with mode: 0644]
usr/src/slowsys/sys/mba.c [new file with mode: 0644]
usr/src/slowsys/sys/mem.c [new file with mode: 0644]
usr/src/slowsys/sys/mx1.c [new file with mode: 0644]
usr/src/slowsys/sys/mx2.c [new file with mode: 0644]
usr/src/slowsys/sys/nami.c [new file with mode: 0644]
usr/src/slowsys/sys/partab.c [new file with mode: 0644]
usr/src/slowsys/sys/pipe.c [new file with mode: 0644]
usr/src/slowsys/sys/prf.c [new file with mode: 0644]
usr/src/slowsys/sys/prim.c [new file with mode: 0644]
usr/src/slowsys/sys/rdwri.c [new file with mode: 0644]
usr/src/slowsys/sys/sig.c [new file with mode: 0644]
usr/src/slowsys/sys/slp.c [new file with mode: 0644]
usr/src/slowsys/sys/subr.c [new file with mode: 0644]
usr/src/slowsys/sys/sys.c [new file with mode: 0644]
usr/src/slowsys/sys/sys1.c [new file with mode: 0644]
usr/src/slowsys/sys/sys2.c [new file with mode: 0644]
usr/src/slowsys/sys/sys3.c [new file with mode: 0644]
usr/src/slowsys/sys/sys4.c [new file with mode: 0644]
usr/src/slowsys/sys/sysent.c [new file with mode: 0644]
usr/src/slowsys/sys/tdump.c [new file with mode: 0644]
usr/src/slowsys/sys/text.c [new file with mode: 0644]
usr/src/slowsys/sys/trap.c [new file with mode: 0644]
usr/src/slowsys/sys/tty.c [new file with mode: 0644]
usr/src/slowsys/sys/uba.c [new file with mode: 0644]
usr/src/slowsys/sys/univec.c [new file with mode: 0644]
usr/src/slowsys/sys/ureg.c [new file with mode: 0644]
usr/src/slowsys/sys/v45lnk.c [new file with mode: 0644]
usr/src/standalone/CON.h [new file with mode: 0644]
usr/src/standalone/EMES.h [new file with mode: 0644]
usr/src/standalone/FL.h [new file with mode: 0644]
usr/src/standalone/MBA.h [new file with mode: 0644]
usr/src/standalone/README [new file with mode: 0644]
usr/src/standalone/RP.h [new file with mode: 0644]
usr/src/standalone/TEboot.s [new file with mode: 0644]
usr/src/standalone/TM.h [new file with mode: 0644]
usr/src/standalone/d2dcpy.c [new file with mode: 0644]
usr/src/standalone/d2tcpy.c [new file with mode: 0644]
usr/src/standalone/dadmes.c [new file with mode: 0644]
usr/src/standalone/ddump.c [new file with mode: 0644]
usr/src/standalone/fboot.c [new file with mode: 0644]
usr/src/standalone/fdump.c [new file with mode: 0644]
usr/src/standalone/flpcpy.c [new file with mode: 0644]
usr/src/standalone/makefile [new file with mode: 0644]
usr/src/standalone/rel.h [new file with mode: 0644]
usr/src/standalone/rp6fmt.c [new file with mode: 0644]
usr/src/standalone/rpboot.s [new file with mode: 0644]
usr/src/standalone/rpread.c [new file with mode: 0644]
usr/src/standalone/stmes.c [new file with mode: 0644]
usr/src/standalone/tdcopy.c [new file with mode: 0644]
usr/src/standalone/tpboot.s [new file with mode: 0644]
usr/src/standalone/vrmhead.c [new file with mode: 0644]
usr/src/sys/dev/cat.c [new file with mode: 0644]
usr/src/sys/dev/dc.c [new file with mode: 0644]
usr/src/sys/dev/dh.c [new file with mode: 0644]
usr/src/sys/dev/dhdm.c [new file with mode: 0644]
usr/src/sys/dev/dhfdm.c [new file with mode: 0644]
usr/src/sys/dev/dn.c [new file with mode: 0644]
usr/src/sys/dev/du.c [new file with mode: 0644]
usr/src/sys/dev/kl.c [new file with mode: 0644]
usr/src/sys/dev/lp.c [new file with mode: 0644]
usr/src/sys/dev/vp.c [new file with mode: 0644]
usr/src/sys/dev/vs.c [new file with mode: 0644]
usr/src/sys/h/acct.h [new file with mode: 0644]
usr/src/sys/h/buf.h [new file with mode: 0644]
usr/src/sys/h/callo.h [new file with mode: 0755]
usr/src/sys/h/clock.h [new file with mode: 0755]
usr/src/sys/h/clock.m [new file with mode: 0755]
usr/src/sys/h/conf.h [new file with mode: 0644]
usr/src/sys/h/cons.h [new file with mode: 0755]
usr/src/sys/h/cons.m [new file with mode: 0644]
usr/src/sys/h/dir.h [new file with mode: 0755]
usr/src/sys/h/fblk.h [new file with mode: 0755]
usr/src/sys/h/file.h [new file with mode: 0644]
usr/src/sys/h/filsys.h [new file with mode: 0644]
usr/src/sys/h/ino.h [new file with mode: 0644]
usr/src/sys/h/inode.h [new file with mode: 0644]
usr/src/sys/h/map.h [new file with mode: 0644]
usr/src/sys/h/mba.h [new file with mode: 0644]
usr/src/sys/h/mba.m [new file with mode: 0644]
usr/src/sys/h/mem.h [new file with mode: 0644]
usr/src/sys/h/mount.h [new file with mode: 0755]
usr/src/sys/h/mtpr.h [new file with mode: 0755]
usr/src/sys/h/mtpr.m [new file with mode: 0755]
usr/src/sys/h/mx.h [new file with mode: 0644]
usr/src/sys/h/nuser.h [new file with mode: 0644]
usr/src/sys/h/page.h [new file with mode: 0755]
usr/src/sys/h/page.m [new file with mode: 0644]
usr/src/sys/h/param.h [new file with mode: 0644]
usr/src/sys/h/pcb.h [new file with mode: 0755]
usr/src/sys/h/pcb.m [new file with mode: 0755]
usr/src/sys/h/proc.h [new file with mode: 0644]
usr/src/sys/h/psl.h [new file with mode: 0755]
usr/src/sys/h/psl.m [new file with mode: 0644]
usr/src/sys/h/reg.h [new file with mode: 0755]
usr/src/sys/h/seg.h [new file with mode: 0755]
usr/src/sys/h/stat.h [new file with mode: 0644]
usr/src/sys/h/systm.h [new file with mode: 0644]
usr/src/sys/h/text.h [new file with mode: 0644]
usr/src/sys/h/timeb.h [new file with mode: 0644]
usr/src/sys/h/trap.h [new file with mode: 0755]
usr/src/sys/h/trap.m [new file with mode: 0644]
usr/src/sys/h/tty.h [new file with mode: 0644]
usr/src/sys/h/uba.h [new file with mode: 0644]
usr/src/sys/h/uba.m [new file with mode: 0644]
usr/src/sys/h/user.h [new file with mode: 0644]
usr/src/sys/sys/acct.c [new file with mode: 0644]
usr/src/sys/sys/alloc.c [new file with mode: 0644]
usr/src/sys/sys/bio.c [new file with mode: 0644]
usr/src/sys/sys/clock.c [new file with mode: 0644]
usr/src/sys/sys/conf.c [new file with mode: 0644]
usr/src/sys/sys/cons.c [new file with mode: 0644]
usr/src/sys/sys/dkleave.c [new file with mode: 0644]
usr/src/sys/sys/dsort.c [new file with mode: 0644]
usr/src/sys/sys/dz.c [new file with mode: 0644]
usr/src/sys/sys/fio.c [new file with mode: 0644]
usr/src/sys/sys/hp.c [new file with mode: 0644]
usr/src/sys/sys/ht.c [new file with mode: 0644]
usr/src/sys/sys/iget.c [new file with mode: 0644]
usr/src/sys/sys/loadall [new file with mode: 0755]
usr/src/sys/sys/locore.s [new file with mode: 0644]
usr/src/sys/sys/m.1 [new file with mode: 0644]
usr/src/sys/sys/m.2 [new file with mode: 0644]
usr/src/sys/sys/machdep.c [new file with mode: 0644]
usr/src/sys/sys/main.c [new file with mode: 0644]
usr/src/sys/sys/makefile [new file with mode: 0644]
usr/src/sys/sys/malloc.c [new file with mode: 0644]
usr/src/sys/sys/mba.c [new file with mode: 0644]
usr/src/sys/sys/mem.c [new file with mode: 0644]
usr/src/sys/sys/mx1.c [new file with mode: 0644]
usr/src/sys/sys/mx2.c [new file with mode: 0644]
usr/src/sys/sys/nami.c [new file with mode: 0644]
usr/src/sys/sys/partab.c [new file with mode: 0644]
usr/src/sys/sys/pipe.c [new file with mode: 0644]
usr/src/sys/sys/prf.c [new file with mode: 0644]
usr/src/sys/sys/prim.c [new file with mode: 0644]
usr/src/sys/sys/rdwri.c [new file with mode: 0644]
usr/src/sys/sys/sig.c [new file with mode: 0644]
usr/src/sys/sys/slp.c [new file with mode: 0644]
usr/src/sys/sys/subr.c [new file with mode: 0644]
usr/src/sys/sys/sys.c [new file with mode: 0644]
usr/src/sys/sys/sys1.c [new file with mode: 0644]
usr/src/sys/sys/sys2.c [new file with mode: 0644]
usr/src/sys/sys/sys3.c [new file with mode: 0644]
usr/src/sys/sys/sys4.c [new file with mode: 0644]
usr/src/sys/sys/sysent.c [new file with mode: 0644]
usr/src/sys/sys/tdump.c [new file with mode: 0644]
usr/src/sys/sys/text.c [new file with mode: 0644]
usr/src/sys/sys/trap.c [new file with mode: 0644]
usr/src/sys/sys/tty.c [new file with mode: 0644]
usr/src/sys/sys/uba.c [new file with mode: 0644]
usr/src/sys/sys/univec.c [new file with mode: 0644]
usr/src/sys/sys/v45lnk.c [new file with mode: 0644]
usr/sys/40/README [deleted file]
usr/sys/40/m40.s [deleted file]
usr/sys/40/param.h [deleted file]
usr/sys/conf/c.c [deleted file]
usr/sys/conf/hphtconf [deleted file]
usr/sys/conf/hptmconf [deleted file]
usr/sys/conf/l.s [deleted file]
usr/sys/conf/makefile [deleted file]
usr/sys/conf/mch.s [deleted file]
usr/sys/conf/mch0.s [deleted file]
usr/sys/conf/mkconf.c [deleted file]
usr/sys/conf/rkhtconf [deleted file]
usr/sys/conf/rktmconf [deleted file]
usr/sys/conf/rp1conf [deleted file]
usr/sys/conf/rphtconf [deleted file]
usr/sys/conf/rptmconf [deleted file]
usr/sys/conf/tconf [deleted file]
usr/sys/dev/bio.c [deleted file]
usr/sys/dev/cat.c [deleted file]
usr/sys/dev/dc.c [deleted file]
usr/sys/dev/dh.c [deleted file]
usr/sys/dev/dhdm.c [deleted file]
usr/sys/dev/dhfdm.c [deleted file]
usr/sys/dev/dkleave.c [deleted file]
usr/sys/dev/dn.c [deleted file]
usr/sys/dev/dsort.c [deleted file]
usr/sys/dev/du.c [deleted file]
usr/sys/dev/dz.c [deleted file]
usr/sys/dev/hp.c [deleted file]
usr/sys/dev/ht.c [deleted file]
usr/sys/dev/kl.c [deleted file]
usr/sys/dev/lp.c [deleted file]
usr/sys/dev/mem.c [deleted file]
usr/sys/dev/mklib [deleted file]
usr/sys/dev/mx1.c [deleted file]
usr/sys/dev/mx2.c [deleted file]
usr/sys/dev/partab.c [deleted file]
usr/sys/dev/pk0.c [deleted file]
usr/sys/dev/pk1.c [deleted file]
usr/sys/dev/pk2.c [deleted file]
usr/sys/dev/pk3.c [deleted file]
usr/sys/dev/rf.c [deleted file]
usr/sys/dev/rk.c [deleted file]
usr/sys/dev/rl.c [deleted file]
usr/sys/dev/rp.c [deleted file]
usr/sys/dev/sys.c [deleted file]
usr/sys/dev/tc.c [deleted file]
usr/sys/dev/tm.c [deleted file]
usr/sys/dev/tty.c [deleted file]
usr/sys/dev/vp.c [deleted file]
usr/sys/dev/vs.c [deleted file]
usr/sys/dummy [new file with mode: 0644]
usr/sys/h/acct.h [deleted file]
usr/sys/h/buf.h [deleted file]
usr/sys/h/callo.h [deleted file]
usr/sys/h/conf.h [deleted file]
usr/sys/h/dir.h [deleted file]
usr/sys/h/fblk.h [deleted file]
usr/sys/h/file.h [deleted file]
usr/sys/h/filsys.h [deleted file]
usr/sys/h/ino.h [deleted file]
usr/sys/h/inode.h [deleted file]
usr/sys/h/map.h [deleted file]
usr/sys/h/mount.h [deleted file]
usr/sys/h/mpx.h [deleted file]
usr/sys/h/mx.h [deleted file]
usr/sys/h/pack.h [deleted file]
usr/sys/h/param.h [deleted file]
usr/sys/h/pk.h [deleted file]
usr/sys/h/pk.p [deleted file]
usr/sys/h/prim.h [deleted file]
usr/sys/h/proc.h [deleted file]
usr/sys/h/pwd.h [deleted file]
usr/sys/h/reg.h [deleted file]
usr/sys/h/seg.h [deleted file]
usr/sys/h/smallparam.h [deleted file]
usr/sys/h/stat.h [deleted file]
usr/sys/h/systm.h [deleted file]
usr/sys/h/text.h [deleted file]
usr/sys/h/timeb.h [deleted file]
usr/sys/h/tty.h [deleted file]
usr/sys/h/types.h [deleted file]
usr/sys/h/user.h [deleted file]
usr/sys/sys/acct.c [deleted file]
usr/sys/sys/alloc.c [deleted file]
usr/sys/sys/clock.c [deleted file]
usr/sys/sys/fakemx.c [deleted file]
usr/sys/sys/fio.c [deleted file]
usr/sys/sys/iget.c [deleted file]
usr/sys/sys/machdep.c [deleted file]
usr/sys/sys/main.c [deleted file]
usr/sys/sys/malloc.c [deleted file]
usr/sys/sys/mklib [deleted file]
usr/sys/sys/nami.c [deleted file]
usr/sys/sys/pipe.c [deleted file]
usr/sys/sys/prf.c [deleted file]
usr/sys/sys/prim.c [deleted file]
usr/sys/sys/rdwri.c [deleted file]
usr/sys/sys/sig.c [deleted file]
usr/sys/sys/slp.c [deleted file]
usr/sys/sys/subr.c [deleted file]
usr/sys/sys/sys1.c [deleted file]
usr/sys/sys/sys2.c [deleted file]
usr/sys/sys/sys3.c [deleted file]
usr/sys/sys/sys4.c [deleted file]
usr/sys/sys/sysent.c [deleted file]
usr/sys/sys/text.c [deleted file]
usr/sys/sys/trap.c [deleted file]
usr/sys/sys/ureg.c [deleted file]
usr/t.toc [new file with mode: 0644]
usr/tmp/dummy [new file with mode: 0644]

diff --git a/bin/1 b/bin/1
deleted file mode 100755 (executable)
index ee9a6d4..0000000
--- a/bin/1
+++ /dev/null
@@ -1,17 +0,0 @@
-case $# in
-
-0)
-       if random -e 1.1
-       then
-       echo one bell system - it works
-       elif random -e 1.1
-       then
-       /usr/games/fortune
-       else 1;1;1;1;1;1;1;1;1;1
-       fi
-;;
-
-*)
-       echo one $* - it works
-
-esac
diff --git a/bin/calendar b/bin/calendar
deleted file mode 100755 (executable)
index d534f02..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-PATH=/bin:/usr/bin
-tmp=/tmp/cal$$
-trap "rm $tmp; exit" 0 1 2 13 15
-/usr/lib/calendar >$tmp
-case $1 in
--)
-       sed '
-               s/\([^:]*\):.*:\(.*\):[^:]*$/y=\2 z=\1/
-       ' /etc/passwd \
-       | while read x
-       do
-               eval $x
-               if test -r $y/calendar; then
-                       egrep -f $tmp $y/calendar 2>/dev/null  | mail $z
-               fi
-       done;;
-*)
-       egrep -f $tmp calendar
-esac
diff --git a/bin/diff3 b/bin/diff3
deleted file mode 100755 (executable)
index d56219f..0000000
--- a/bin/diff3
+++ /dev/null
@@ -1,17 +0,0 @@
-e=
-case $1 in
--*)
-       e=$1
-       shift;;
-esac
-if test $# = 3 -a -f $1 -a -f $2 -a -f $3
-then
-       :
-else
-       echo usage: diff3 file1 file2 file3 1>&2
-       exit
-fi
-trap "rm -f /tmp/d3[ab]$$" 0 1 2 13 15
-diff $1 $3 >/tmp/d3a$$
-diff $2 $3 >/tmp/d3b$$
-/usr/lib/diff3 $e /tmp/d3[ab]$$ $1 $2 $3
diff --git a/bin/false b/bin/false
deleted file mode 100755 (executable)
index 379a4c9..0000000
--- a/bin/false
+++ /dev/null
@@ -1 +0,0 @@
-exit 1
diff --git a/bin/lint b/bin/lint
deleted file mode 100755 (executable)
index 4b87497..0000000
--- a/bin/lint
+++ /dev/null
@@ -1,23 +0,0 @@
-L=/usr/lib/lint T=/usr/tmp/lint.$$ PATH=/bin:/usr/bin O="-C -Dlint" X= P=unix
-LL=/usr/lib
-trap "rm -f $T; exit" 1 2 15
-for A in $*
-do
-       case $A in
-       -*n*)   P= ;;
-       -*p*)   P=port ;;
-       esac
-       case $A in
-       -l*)    (/lib/cpp $O $LL/llib$A | ${L}1 -v$X-L$A >>$T)2>&1 ;;
-       -[IDOU]*)       O="$O $A" ;;
-       -X)     LL=/usr/scj/lint L=/usr/scj/lint/lpass ;;
-       -*)     X="$X$A" ;;
-       *)      (/lib/cpp $O $A | ${L}1 $X-L$A >>$T)2>&1
-       esac
-       done
-case $P in
-       unix)   (/lib/cpp $O $LL/llib-lc | ${L}1 -v$X-L-lc >>$T)2>&1 ;;
-       port)   (/lib/cpp $O $LL/llib-port | ${L}1 -v$X-L-lc >>$T)2>&1 ;;
-       esac
-sort -u $T | ${L}2 $X
-rm -f $T
diff --git a/bin/lookbib b/bin/lookbib
deleted file mode 100755 (executable)
index 1cc2d98..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-A=
-case $1 in
-       -p)     A="$1 $2"
-               shift; shift;;
-       -*)     A=$1
-               shift;;
-esac
-case $1 in
-       -p)     A="$A $1 $2"
-               shift; shift;;
-       -*)     A="$A $1"
-               shift;;
-esac
-if test $1x = x 
-then /usr/lib/refer/mkey -s
-else echo $* | /usr/lib/refer/mkey -s
-fi | /usr/lib/refer/hunt $A /usr/dict/papers/Ind
diff --git a/bin/lorder b/bin/lorder
deleted file mode 100755 (executable)
index 7fd6003..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-trap "rm -f $$sym?ef; exit" 0 1 2 13 15
-case $# in
-0)     echo usage: lorder file ...
-       exit ;;
-1)     case $1 in
-       *.o)    set $1 $1
-       esac
-esac
-nm -g $* | sed '
-       /^$/d
-       /:$/{
-               /\.o:/!d
-               s/://
-               h
-               s/.*/& &/
-               p
-               d
-       }
-       /[TD] /{
-               s/.* //
-               G
-               s/\n/ /
-               w '$$symdef'
-               d
-       }
-       s/.* //
-       G
-       s/\n/ /
-       w '$$symref'
-       d
-'
-sort $$symdef -o $$symdef
-sort $$symref -o $$symref
-join $$symref $$symdef | sed 's/[^ ]* *//'
diff --git a/bin/man b/bin/man
deleted file mode 100755 (executable)
index 28a4218..0000000
--- a/bin/man
+++ /dev/null
@@ -1,62 +0,0 @@
-cmd= sec= fil= opt= i= all=
-cmd=n sec=\?
-cd /usr/man
-for i
-do
-       case $i in
-
-       [1-8])
-               sec=$i ;;
-       -n)
-               cmd=n ;;
-       -t)
-               cmd=t ;;
-       -k)
-               cmd=k ;;
-       -e | -et | -te)
-               cmd=e ;;
-       -ek | -ke)
-               cmd=ek ;;
-       -ne | -en)
-               cmd=ne ;;
-
-       -w)
-               cmd=where ;;
-       -*)
-               opt="$opt $i" ;;
-
-       *)
-               fil=`echo man$sec/$i.*`
-               case $fil in
-               man7/eqnchar.7)
-                       all="$all /usr/pub/eqnchar $fil" ;;
-
-               *\*)
-                       echo $i not found 1>&2 ;;
-               *)
-                       all="$all $fil" ;;
-               esac
-       esac
-done
-case $all in
-       "")
-               exit ;;
-esac
-case $cmd in
-
-n)
-       nroff $opt -man $all ;;
-ne)
-       neqn $all | nroff $opt -man ;;
-t)
-       troff $opt -man $all ;;
-k)
-       troff -t $opt -man $all | tc ;;
-e)
-       eqn $all | troff $opt -man ;;
-ek)
-       eqn $all | troff -t $opt -man | tc ;;
-
-where)
-       echo $all ;;
-esac
diff --git a/bin/nohup b/bin/nohup
deleted file mode 100755 (executable)
index 6b590e9..0000000
--- a/bin/nohup
+++ /dev/null
@@ -1,7 +0,0 @@
-trap "" 1 15
-if test -t 2>&1  ; then
-       echo "Sending output to 'nohup.out'"
-       exec nice -5 $* >>nohup.out 2>&1
-else
-       exec nice -5 $* 2>&1
-fi
diff --git a/bin/pcc b/bin/pcc
deleted file mode 100755 (executable)
index cb4e405..0000000
--- a/bin/pcc
+++ /dev/null
@@ -1,71 +0,0 @@
-T=/tmp/$$ PATH=/bin:/usr/bin O= OTWO= S= N=yes OPT= ret=0 prof=
-L=/lib COPT=/lib/c2
-LC="$L/crt0.o" LIBS=" $L/libc.a" NAS=as LD=ld CCOMP=/usr/lib/ccom
-ECHO=echo
-trap "rm -f $T.*; exit 1" 1 2 3 15
-trap 'rm -f $T.*; exit $ret' 0
-for A
-do     case $A in
-       *.c)    B=`basename $A .c`
-               $ECHO "$B.c"
-               case "$S$OPT" in
-               -S)     if /lib/cpp $O $A $T.i &&
-                          $CCOMP $prof <$T.i $OTWO >$B.s; then
-                               : OK
-                       else
-                               ret=$?
-                       fi ;;
-               -Syes)  if /lib/cpp $O $A $T.i &&
-                          $CCOMP $prof <$T.i $OTWO >$T.s &&
-                          $COPT $T.s $B.s; then
-                               : OK
-                       else
-                               ret=$?
-                       fi ;;
-               yes)    if /lib/cpp $O $A $T.i &&
-                           $CCOMP $prof <$T.i $OTWO >$T.x &&
-                           $COPT $T.x  $T.s &&
-                           $NAS - -o $B.o $T.s ; then
-                               ll="$ll $B.o"
-                       else
-                               N=no ret=$?
-                       fi ;;
-               *)      if /lib/cpp $O $A $T.i &&
-                          $CCOMP $prof <$T.i $OTWO >$T.s &&
-                           $NAS - -o $B.o $T.s ; then
-                               ll="$ll $B.o"
-                       else
-                               N=no ret=$?
-                       fi ;;
-               esac ;;
-
-       -S)     N=no S=-S OTWO=-l ;;
-
-       -X)     CCOMP=/usr/scj/pcc/comp ;;
-
-       -O)     OPT=yes ;;
-
-       -[IDU]*)        O="$O $A" ;;
-
-       -c)     N=no ;;
-
-       -)      ECHO=: ;;
-
-       *.s)    B=`basename $A .s`
-               if echo "$B.s:" &&
-               $NAS - -o $B.o $A; then
-                       ll="$ll $B.o"
-               else
-                       N=no ret=$?
-               fi ;;
-
-       -p)     prof=-p  ;;
-
-       *)      ll="$ll $A"
-       esac
-done
-case $N in
-       no)     : ;;
-       *)      $LD $LC $ll $LIBS
-       ret=$?
-esac
diff --git a/bin/plot b/bin/plot
deleted file mode 100755 (executable)
index c7ee671..0000000
--- a/bin/plot
+++ /dev/null
@@ -1,14 +0,0 @@
-PATH=/bin:/usr/bin
-case $1 in
--T*)   t=$1
-       shift ;;
-*)     t=-T$TERM
-esac
-case $t in
--T450) exec t450 $*;;
--T300) exec t300 $*;;
--T300S|-T300s) exec t300s $*;;
--Tver) exec vplot $*;;
--Ttek|-T4014|-T)       exec tek $* ;;
-*)  echo plot: terminal type $t not known 1>&2; exit 1
-esac
diff --git a/bin/spell b/bin/spell
deleted file mode 100755 (executable)
index 8a8efeb..0000000
--- a/bin/spell
+++ /dev/null
@@ -1,28 +0,0 @@
-: B flags, D dictionary, F files, H history, S stop, V data for -v
-H=${H-/usr/dict/spellhist}
-T=/tmp/spell.$$
-V=/dev/null
-F= B=
-trap "rm -f $T*; exit" 0 1 2 13 15
-for A in $*
-do
-       case $A in
-       -v)     B="$B -v"
-               V=${T}a ;;
-       -a)     ;;
-       -b)     D=${D-/usr/dict/hlistb}
-               B="$B -b" ;;
-       *)      F="$F $A"
-       esac
-       done
-deroff -w $F |\
-  sort -u |\
-  /usr/lib/spell ${S-/usr/dict/hstop} $T |\
-  /usr/lib/spell ${D-/usr/dict/hlista} $V $B |\
-  sort -u +0f +0 - $T |\
-  tee -a $H
-who am i >>$H 2>/dev/null
-case $V in
-/dev/null)     exit
-esac
-sed '/^\./d' $V | sort -u +1f +0
diff --git a/bin/struct b/bin/struct
deleted file mode 100755 (executable)
index 69d2383..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-trap "rm -f /tmp/struct*$$" 0 1 2 3 13 15
-files=no
-for i
-do
-       case $i in
-       -*)     ;;
-       *)      files=yes
-       esac
-done
-
-case $files in
-yes)
-       /usr/lib/struct/structure $* >/tmp/struct$$
-       ;;
-no)
-       cat >/tmp/structin$$
-       /usr/lib/struct/structure /tmp/structin$$ $* >/tmp/struct$$
-esac &&
-       /usr/lib/struct/beautify</tmp/struct$$
diff --git a/bin/true b/bin/true
deleted file mode 100755 (executable)
index e69de29..0000000
diff --git a/dev/makefile b/dev/makefile
deleted file mode 100644 (file)
index bb7dd82..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-rp03:
-       /etc/mknod rp0 b 1 1
-       /etc/mknod swap b 1 2
-       /etc/mknod rp3 b 1 3
-       /etc/mknod rrp0 c 11 1
-       /etc/mknod rrp3 c 11 3
-       chmod go-w rp0 swap rp3 rrp0 rrp3
-
-rp04 rp05:
-       /etc/mknod rp0 b 6 0
-       /etc/mknod swap b 6 1
-       /etc/mknod rp3 b 6 6
-       /etc/mknod rrp0 c 14 0
-       /etc/mknod rrp3 c 14 6
-       chmod go-w rp0 swap rp3 rrp0 rrp3
-
-rp06:
-       /etc/mknod rp0 b 6 0
-       /etc/mknod swap b 6 1
-       /etc/mknod rp3 b 6 7
-       /etc/mknod rrp0 c 14 0
-       /etc/mknod rrp3 c 14 7
-       chmod go-w rp0 swap rp3 rrp0 rrp3
-
-tm:
-       /etc/mknod mt0 b 3 0
-       /etc/mknod rmt0 c 12 0
-       /etc/mknod nrmt0 c 12 128
-       chmod go+w mt0 rmt0 nrmt0
-
-ht:
-       /etc/mknod mt0 b 7 64
-       /etc/mknod mt1 b 7 0
-       /etc/mknod rmt0 c 15 64
-       /etc/mknod rmt1 c 15 0
-       /etc/mknod nrmt0 c 15 192
-       /etc/mknod nrmt1 c 15 128
-       chmod go+w mt0 mt1 rmt0 rmt1 nrmt0 nrmt1
diff --git a/etc/ddate b/etc/ddate
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/etc/group b/etc/group
deleted file mode 100644 (file)
index 26a29d7..0000000
--- a/etc/group
+++ /dev/null
@@ -1,4 +0,0 @@
-other::1:
-sys::2:bin,sys
-bin::3:sys,bin
-uucp::4:
diff --git a/etc/passwd b/etc/passwd
deleted file mode 100644 (file)
index a4acc83..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-root:VwL97VCAx1Qhs:0:1::/:
-daemon:x:1:1::/:
-sys::2:2::/usr/sys:
-bin::3:3::/bin:
-uucp::4:4::/usr/lib/uucp:/usr/lib/uucico
-dmr::7:3::/usr/dmr:
diff --git a/etc/rc b/etc/rc
deleted file mode 100644 (file)
index 8e59c75..0000000
--- a/etc/rc
+++ /dev/null
@@ -1,14 +0,0 @@
-PATH=/bin:/usr/bin
-echo "Restricted rights: Use, duplication, or disclosure
-is subject to restrictions stated in your contract with
-Western Electric Company, Inc." >/dev/console
-rm /etc/mtab
-cat /dev/null >/etc/utmp
-/etc/mount /dev/rp3 /usr
-rm -f /usr/spool/lpd/lock
-: /etc/accton /usr/adm/acct
-rm -f /usr/tmp/*
-rm -f /tmp/*
-/etc/update
-date >/dev/console
-/etc/cron
diff --git a/etc/ttys b/etc/ttys
deleted file mode 100644 (file)
index 49c2c80..0000000
--- a/etc/ttys
+++ /dev/null
@@ -1,33 +0,0 @@
-14console
-00tty00
-00tty01
-00tty02
-00tty03
-00tty04
-00tty05
-00tty06
-00tty07
-00tty08
-00tty09
-00tty10
-00tty11
-00tty12
-00tty13
-00tty14
-00tty15
-00tty16
-00tty17
-00tty18
-00tty19
-00tty20
-00tty21
-00tty22
-00tty23
-00tty24
-00tty25
-00tty26
-00tty27
-00tty28
-00tty29
-00tty30
-00tty31
diff --git a/etc/utmp b/etc/utmp
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/usr/adm/dummy b/usr/adm/dummy
new file mode 100644 (file)
index 0000000..e69de29
index 58f1927..3cf849a 100644 (file)
@@ -1,3 +1,25 @@
+Rbstjissue:0,129
+Rbstjissue:129,161
+Rbstjissue:290,139
+Rbstjissue:429,146
+Rbstjissue:575,241
+Rbstjissue:816,142
+Rbstjissue:958,193
+Rbstjissue:1151,191
+Rbstjissue:1342,170
+Rbstjissue:1512,151
+Rbstjissue:1663,179
+Rbstjissue:1842,175
+Rbstjissue:2017,178
+Rbstjissue:2195,162
+Rbstjissue:2357,180
+Rbstjissue:2537,218
+Rbstjissue:2755,218
+Rbstjissue:2973,140
+Rbstjissue:3113,176
+Rbstjissue:3289,155
+Rbstjissue:3444,215
+Rbstjissue:3659,175
 Rv7man:0,135
 Rv7man:135,279
 Rv7man:414,175
 Rv7man:0,135
 Rv7man:135,279
 Rv7man:414,175
diff --git a/usr/dict/papers/Rbstjissue b/usr/dict/papers/Rbstjissue
new file mode 100644 (file)
index 0000000..c4f2555
--- /dev/null
@@ -0,0 +1,224 @@
+%T U\s-2NIX\s0 Time-Sharing System: Preface
+%A T. H. Crowley
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 1897-1898
+%D 1978
+%K bstj unix
+
+%T U\s-2NIX\s0 Time-Sharing System: Foreword
+%A M. D. McIlroy
+%A E. N. Pinson
+%A B. A. Tague
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 1899-1904
+%D 1978
+%K unix bstj
+
+%T The U\s-2NIX\s0 Time-Sharing System
+%K unix bstj
+%A D. M. Ritchie
+%A K. Thompson
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 1905-1929
+%D 1978
+
+%T U\s-2NIX\s0 Time-Sharing System: U\s-2NIX\s0 Implementation
+%K unix bstj
+%A K. Thompson
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 1931-1946
+%D 1978
+
+%T U\s-2NIX\s0 Time-Sharing System: A Retrospective
+%K unix bstj
+%A D. M. Ritchie
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 1947-1969
+%D 1978
+%O Also in \f1Proc. Hawaii International Conference on Systems Science,\f1 Honolulu, Hawaii, Jan. 1977.
+
+%T U\s-2NIX\s0 Time-Sharing System: The U\s-2NIX\s0 Shell
+%A S. R. Bourne
+%K unix bstj
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 1971-1990
+%D 1978
+
+%T U\s-2NIX\s0 Time-Sharing System: The C Programming Language
+%A D. M. Ritchie
+%A S. C. Johnson
+%A M. E. Lesk
+%A B. W. Kernighan
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 1991-2019
+%D 1978
+%K bstj
+
+%T U\s-2NIX\s0 Time-Sharing System: Portability of C Programs and the U\s-2NIX\s0 System
+%K unix bstj
+%A S. C. Johnson
+%A D. M. Ritchie
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 2021-2048
+%D 1978
+
+%T U\s-2NIX\s0 Time-Sharing System: The M\s-2ERT\s0 Operating System
+%A H. Lycklama
+%A D. L. Bayer
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%K mert
+%P 2049-2086
+%D 1978
+%K bstj
+
+%T U\s-2NIX\s0 Time-Sharing System: U\s-2NIX\s0 on a Microprocessor
+%K unix bstj
+%A H. Lycklama
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 2087-2101
+%D 1978
+
+%T U\s-2NIX\s0 Time-Sharing System: A Minicomputer Satellite Processor System
+%A H. Lycklama
+%A C. Christensen
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 2103-2113
+%D 1978
+%K bstj unix
+
+%T U\s-2NIX\s0 Time-Sharing System: Document Preparation
+%K unix bstj
+%A B. W. Kernighan
+%A M. E. Lesk
+%A J. F. Ossanna
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 2115-2135
+%D 1978
+
+%T U\s-2NIX\s0 Time-Sharing System: Statistical Text Processing
+%K unix bstj
+%A L. E. McMahon
+%A L. L. Cherry
+%A R. Morris
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 2137-2154
+%D 1978
+
+%T U\s-2NIX\s0 Time-Sharing System: Language Development Tools
+%K unix bstj
+%A S. C. Johnson
+%A M. E. Lesk
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 2155-2175
+%D 1978
+
+%T U\s-2NIX\s0 Time-Sharing System: The Programmer's Workbench
+%A T. A. Dolotta
+%A R. C. Haight
+%A J. R. Mashey
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 2177-2200
+%D 1978
+%K unix bstj
+
+%T U\s-2NIX\s0 Time-Sharing System: The U\s-2NIX\s0 Operating System as
+a Base for Applications
+%K unix bstj
+%A G. W. R. Luderer
+%A J. F. Maranzano
+%A B. A. Tague
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 2201-2207
+%D 1978
+
+%T U\s-2NIX\s0 Time-Sharing System: Microcomputer Control of Apparatus, Machinery, and Experiments
+%K unix bstj
+%A B. C. Wonsiewicz
+%A A. R. Storm
+%A J. D. Sieber
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 2209-2232
+%D 1978
+
+%T U\s-2NIX\s0 Time-Sharing System: Circuit Design Aids
+%K unix bstj
+%A A. G. Fraser
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 2233-2249
+%D 1978
+
+%T U\s-2NIX\s0 Time-Sharing System: A Support Environment for M\s-2AC\s0-8 Systems
+%A H. D. Rovegno
+%K mac8 unix
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 2251-2263
+%K bstj
+%D 1978
+
+%T U\s-2NIX\s0 Time-Sharing System: No. 4 ESS Diagnostic Environment
+%K unix bstj
+%A S. P. Pekarich
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 2265-2274
+%D 1978
+
+%T U\s-2NIX\s0 Time-Sharing System: R\s-2BCS\s0/R\s-2CMAS\s0 \(em Converting to the M\s-2ERT\s0 Operating System
+%K unix bstj
+%A E. R. Nagelberg
+%A M. A. Pilla
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 2275-2287
+%D 1978
+
+%T U\s-2NIX\s0 Time-Sharing System: The Network Operations Center System
+%K unix bstj
+%A H. Cohen
+%A J. C. Kaufeld, Jr.
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 2289-2304
+%D 1978
+
index c2d5594..77bd7e7 100644 (file)
@@ -9,13 +9,9 @@
 8th
 9th
 a
 8th
 9th
 a
-A&M
 A&P
 a's
 A&P
 a's
-AAA
-AAAS
 Aaron
 Aaron
-AAU
 ABA
 Ababa
 aback
 ABA
 Ababa
 aback
@@ -24,7 +20,6 @@ abandon
 abase
 abash
 abate
 abase
 abash
 abate
-abater
 abbas
 abbe
 abbey
 abbas
 abbe
 abbey
@@ -47,6 +42,7 @@ aberrant
 aberrate
 abet
 abetted
 aberrate
 abet
 abetted
+abetting
 abeyance
 abeyant
 abhorred
 abeyance
 abeyant
 abhorred
@@ -225,12 +221,12 @@ acropolis
 across
 acrylate
 acrylic
 across
 acrylate
 acrylic
-ACS
 act
 Actaeon
 actinic
 actinide
 actinium
 act
 Actaeon
 actinic
 actinide
 actinium
+actinolite
 actinometer
 activate
 activation
 actinometer
 activate
 activation
@@ -291,8 +287,8 @@ adieu
 adipic
 Adirondack
 adjacent
 adipic
 Adirondack
 adjacent
+adject
 adjectival
 adjectival
-adjective
 adjoin
 adjoint
 adjourn
 adjoin
 adjoint
 adjourn
@@ -456,6 +452,7 @@ aggressor
 aggrieve
 aghast
 agile
 aggrieve
 aghast
 agile
+aging
 agitate
 agleam
 Agnes
 agitate
 agleam
 Agnes
@@ -626,8 +623,6 @@ alizarin
 alkali
 alkaline
 alkaloid
 alkali
 alkaline
 alkaloid
-alkane
-alkene
 all
 Allah
 allay
 all
 Allah
 allay
@@ -768,7 +763,6 @@ ambrose
 ambrosia
 ambrosial
 ambulant
 ambrosia
 ambrosial
 ambulant
-ambulate
 ambulatory
 ambuscade
 ambush
 ambulatory
 ambuscade
 ambush
@@ -919,7 +913,6 @@ angle
 Angles
 Anglican
 Anglicanism
 Angles
 Anglican
 Anglicanism
-anglicize
 angling
 Anglo
 Anglophobia
 angling
 Anglo
 Anglophobia
@@ -961,7 +954,6 @@ Annalen
 Annapolis
 Anne
 anneal
 Annapolis
 Anne
 anneal
-Annette
 annex
 Annie
 annihilate
 annex
 Annie
 annihilate
@@ -989,6 +981,7 @@ anonymity
 anonymous
 anorexia
 anorthic
 anonymous
 anorexia
 anorthic
+anorthite
 anorthosite
 another
 Anselm
 anorthosite
 another
 Anselm
@@ -1001,7 +994,6 @@ Antaeus
 antagonism
 antagonist
 antagonistic
 antagonism
 antagonist
 antagonistic
-antarctic
 Antarctica
 Antares
 ante
 Antarctica
 Antares
 ante
@@ -1029,6 +1021,7 @@ anticipatory
 Antietam
 antigen
 Antigone
 Antietam
 antigen
 Antigone
+antigorite
 antimony
 Antioch
 antipasto
 antimony
 Antioch
 antipasto
@@ -1050,7 +1043,6 @@ Antoinette
 Anton
 Antonio
 Antony
 Anton
 Antonio
 Antony
-antonym
 anus
 anvil
 anxiety
 anus
 anvil
 anxiety
@@ -1070,6 +1062,7 @@ apart
 apartheid
 apathetic
 apathy
 apartheid
 apathetic
 apathy
+apatite
 ape
 aperiodic
 aperture
 ape
 aperiodic
 aperture
@@ -1137,7 +1130,7 @@ apply
 appoint
 appointe
 appointee
 appoint
 appointe
 appointee
-apportion
+apport
 apposite
 apposition
 appraisal
 apposite
 apposition
 appraisal
@@ -1162,7 +1155,6 @@ apricot
 April
 apron
 apropos
 April
 apron
 apropos
-APS
 apse
 apt
 aptitude
 apse
 apt
 aptitude
@@ -1282,6 +1274,7 @@ armature
 armchair
 Armco
 Armenian
 armchair
 Armco
 Armenian
+armful
 armhole
 armillaria
 armistice
 armhole
 armillaria
 armistice
@@ -1332,6 +1325,7 @@ arteriole
 arteriolosclerosis
 arteriosclerosis
 artery
 arteriolosclerosis
 arteriosclerosis
 artery
+artful
 arthritis
 Arthur
 artichoke
 arthritis
 Arthur
 artichoke
@@ -1470,6 +1464,7 @@ astute
 Asuncion
 asunder
 asylum
 Asuncion
 asunder
 asylum
+asymmetric
 asymmetry
 asymptote
 asymptotic
 asymmetry
 asymptote
 asymptotic
@@ -1483,7 +1478,6 @@ atavistic
 Atchison
 ate
 Athabascan
 Atchison
 ate
 Athabascan
-atheism
 atheist
 Athena
 Athenian
 atheist
 Athena
 Athenian
@@ -1563,6 +1557,7 @@ Auerbach
 Aug
 Augean
 auger
 Aug
 Augean
 auger
+augite
 augment
 augmentation
 augur
 augment
 augmentation
 augur
@@ -1636,7 +1631,6 @@ averred
 averring
 averse
 aversion
 averring
 averse
 aversion
-aversive
 avert
 avertive
 Avery
 avert
 avertive
 Avery
@@ -1680,6 +1674,7 @@ axiology
 axiom
 axiomatic
 axis
 axiom
 axiomatic
 axis
+axisymmetric
 axle
 axon
 aye
 axle
 axon
 aye
@@ -1706,6 +1701,7 @@ Babylon
 Babylonian
 babysat
 babysit
 Babylonian
 babysat
 babysit
+babysitting
 baccarat
 Bacchus
 Bach
 baccarat
 Bacchus
 Bach
@@ -1717,7 +1713,6 @@ backboard
 backbone
 backdrop
 backfill
 backbone
 backdrop
 backfill
-backgammon
 background
 backhand
 backlash
 background
 backhand
 backlash
@@ -1782,6 +1777,7 @@ Baldwin
 baldy
 bale
 baleen
 baldy
 bale
 baleen
+baleful
 Balfour
 Bali
 Balinese
 Balfour
 Bali
 Balinese
@@ -1831,6 +1827,7 @@ bandwidth
 bandy
 bane
 baneberry
 bandy
 bane
 baneberry
+baneful
 bang
 bangkok
 Bangladesh
 bang
 bangkok
 Bangladesh
@@ -1844,6 +1841,7 @@ bank
 bankrupt
 bankruptcy
 Banks
 bankrupt
 bankruptcy
 Banks
+banning
 banquet
 banshee
 bantam
 banquet
 banshee
 bantam
@@ -1898,6 +1896,7 @@ Barnhard
 barnstorm
 barnyard
 barometer
 barnstorm
 barnyard
 barometer
+barometric
 baron
 baroness
 baronet
 baron
 baroness
 baronet
@@ -1915,6 +1914,7 @@ Barrett
 barrette
 barricade
 barrier
 barrette
 barricade
 barrier
+barring
 Barrington
 barrow
 Barry
 Barrington
 barrow
 Barry
@@ -1941,6 +1941,7 @@ basemen
 baseplate
 bash
 bashaw
 baseplate
 bash
 bashaw
+bashful
 basic
 basidiomycetes
 basil
 basic
 basidiomycetes
 basil
@@ -2043,6 +2044,7 @@ Beaujolais
 Beaumont
 Beauregard
 beauteous
 Beaumont
 Beauregard
 beauteous
+beautiful
 beautify
 beauty
 beaux
 beautify
 beauty
 beaux
@@ -2062,6 +2064,7 @@ become
 bed
 bedazzle
 bedbug
 bed
 bedazzle
 bedbug
+bedding
 bedfast
 Bedford
 bedim
 bedfast
 Bedford
 bedim
@@ -2100,6 +2103,7 @@ befell
 befit
 befitting
 befog
 befit
 befitting
 befog
+befogging
 before
 beforehand
 befoul
 before
 beforehand
 befoul
@@ -2162,6 +2166,7 @@ bellum
 bellwether
 belly
 bellyache
 bellwether
 belly
 bellyache
+bellyfull
 Belmont
 Beloit
 belong
 Belmont
 Beloit
 belong
@@ -2270,6 +2275,7 @@ beryl
 beryllium
 beseech
 beset
 beryllium
 beseech
 beset
+besetting
 beside
 besiege
 besmirch
 beside
 besiege
 besmirch
@@ -2284,6 +2290,7 @@ Bessie
 best
 bestial
 bestir
 best
 bestial
 bestir
+bestirring
 bestow
 bestowal
 bestseller
 bestow
 bestowal
 bestseller
@@ -2310,6 +2317,7 @@ betrothal
 Betsey
 Betsy
 Bette
 Betsey
 Betsy
 Bette
+betting
 bettor
 Betty
 between
 bettor
 Betty
 between
@@ -2348,6 +2356,7 @@ biconnected
 bicycle
 bid
 biddable
 bicycle
 bid
 biddable
+bidding
 biddy
 bide
 bidiagonal
 biddy
 bide
 bidiagonal
@@ -2397,6 +2406,7 @@ binaural
 bind
 bindery
 bindle
 bind
 bindery
 bindle
+bindweed
 bing
 binge
 Bingham
 bing
 binge
 Bingham
@@ -2406,12 +2416,28 @@ Bini
 binocular
 binomial
 binuclear
 binocular
 binomial
 binuclear
+biochemic
+biochemist
+biochemistry
+biograph
 biography
 biology
 biography
 biology
+biomass
+biomedical
+biometric
 Biometrika
 biometry
 Biometrika
 biometry
+biophysic
+biophysical
+biophysicist
 biopsy
 biopsy
+bioscience
+biosphere
+biostatistic
+biosynthesize
 biota
 biota
+biotic
+biotite
 bipartisan
 bipartite
 biplane
 bipartisan
 bipartite
 biplane
@@ -2462,6 +2488,7 @@ biz
 bizarre
 Bizet
 blab
 bizarre
 Bizet
 blab
+blabbing
 black
 blackball
 blackberry
 black
 blackball
 blackberry
@@ -2480,6 +2507,7 @@ Blackstone
 Blackwell
 bladder
 bladdernut
 Blackwell
 bladder
 bladdernut
+bladderwort
 blade
 Blaine
 Blair
 blade
 Blaine
 Blair
@@ -2491,7 +2519,6 @@ blanch
 Blanchard
 Blanche
 bland
 Blanchard
 Blanche
 bland
-blandish
 blank
 blanket
 blare
 blank
 blanket
 blare
@@ -2502,6 +2529,7 @@ blast
 blat
 blatant
 blather
 blat
 blatant
 blather
+blatting
 Blatz
 blaze
 blazon
 Blatz
 blaze
 blazon
@@ -2526,6 +2554,7 @@ blink
 Blinn
 blip
 bliss
 Blinn
 blip
 bliss
+blissful
 blister
 blithe
 blitz
 blister
 blithe
 blitz
@@ -2561,9 +2590,9 @@ bloop
 blossom
 blot
 blotch
 blossom
 blot
 blotch
+blotting
 blouse
 blow
 blouse
 blow
-blowback
 blowfish
 blown
 blowup
 blowfish
 blown
 blowup
@@ -2591,6 +2620,7 @@ Blumenthal
 blunder
 blunt
 blur
 blunder
 blunt
 blur
+blurring
 blurry
 blurt
 blush
 blurry
 blurt
 blush
@@ -2604,6 +2634,7 @@ boar
 board
 boardinghouse
 boast
 board
 boardinghouse
 boast
+boastful
 boat
 boathouse
 boatload
 boat
 boathouse
 boatload
@@ -2614,20 +2645,21 @@ boatyard
 bob
 Bobbie
 bobbin
 bob
 Bobbie
 bobbin
+bobbing
 bobble
 bobby
 bobcat
 bobolink
 Boca
 bock
 bobble
 bobby
 bobcat
 bobolink
 Boca
 bock
-bocklogged
 bode
 bodhisattva
 bodice
 bodied
 Bodleian
 body
 bode
 bodhisattva
 bodice
 bodied
 Bodleian
 body
-bodybuild
+bodybuilder
+bodybuilding
 bodyguard
 Boeing
 Boeotian
 bodyguard
 Boeing
 Boeotian
@@ -2723,11 +2755,11 @@ bootleg
 bootlegger
 bootlegging
 bootstrap
 bootlegger
 bootlegging
 bootstrap
-bootstrapped
 bootstrapping
 booty
 booze
 bop
 bootstrapping
 booty
 booze
 bop
+bopping
 borate
 borax
 Bordeaux
 borate
 borax
 Bordeaux
@@ -2778,7 +2810,6 @@ bouffant
 bough
 bought
 boulder
 bough
 bought
 boulder
-boule
 boulevard
 bounce
 bouncy
 boulevard
 bounce
 bouncy
@@ -2964,6 +2995,8 @@ Brighton
 brilliant
 Brillouin
 brim
 brilliant
 Brillouin
 brim
+brimful
+brimming
 brimstone
 Brindisi
 brindle
 brimstone
 Brindisi
 brindle
@@ -3082,6 +3115,7 @@ buck
 buckaroo
 buckboard
 bucket
 buckaroo
 buckboard
 bucket
+bucketfull
 buckeye
 buckhorn
 buckle
 buckeye
 buckhorn
 buckle
@@ -3098,6 +3132,7 @@ Budd
 Buddha
 Buddhism
 Buddhist
 Buddha
 Buddhism
 Buddhist
+budding
 buddy
 budge
 budget
 buddy
 budge
 budget
@@ -3149,6 +3184,7 @@ bulwark
 bum
 bumble
 bumblebee
 bum
 bumble
 bumblebee
+bumming
 bump
 bumptious
 bun
 bump
 bumptious
 bun
@@ -3201,7 +3237,6 @@ burn
 Burnett
 Burnham
 burnish
 Burnett
 Burnham
 burnish
-burnout
 Burnside
 burnt
 burp
 Burnside
 burnt
 burp
@@ -3255,6 +3290,7 @@ buttery
 buttock
 button
 buttonhole
 buttock
 button
 buttonhole
+buttonweed
 buttress
 Buttrick
 butyl
 buttress
 Buttrick
 butyl
@@ -3345,7 +3381,6 @@ calamity
 calamus
 calcareous
 calcify
 calamus
 calcareous
 calcify
-calcine
 calcite
 calcium
 calculable
 calcite
 calcium
 calculable
@@ -3389,6 +3424,8 @@ calm
 caloric
 calorie
 calorimeter
 caloric
 calorie
 calorimeter
+calorimetric
+calorimetry
 Calumet
 calumniate
 calumny
 Calumet
 calumniate
 calumny
@@ -3466,6 +3503,7 @@ cannabis
 cannel
 cannery
 cannibal
 cannel
 cannery
 cannibal
+canning
 cannister
 cannon
 cannonball
 cannister
 cannon
 cannonball
@@ -3476,7 +3514,6 @@ Canoga
 canon
 canonic
 canopy
 canon
 canonic
 canopy
-canst
 cant
 cantaloupe
 canteen
 cant
 cantaloupe
 canteen
@@ -3512,6 +3549,7 @@ capitol
 Capitoline
 capitulate
 capo
 Capitoline
 capitulate
 capo
+capping
 caprice
 capricious
 Capricorn
 caprice
 capricious
 Capricorn
@@ -3558,13 +3596,13 @@ cardamom
 cardboard
 cardiac
 cardinal
 cardboard
 cardiac
 cardinal
-cardioid
 cardiology
 cardiovascular
 care
 careen
 career
 carefree
 cardiology
 cardiovascular
 care
 careen
 career
 carefree
+careful
 caress
 caret
 caretaker
 caress
 caret
 caretaker
@@ -3702,7 +3740,6 @@ cater
 caterpillar
 catfish
 catharsis
 caterpillar
 catfish
 catharsis
-cathedra
 cathedral
 Catherine
 Catherwood
 cathedral
 Catherine
 Catherwood
@@ -3751,7 +3788,6 @@ caviar
 cavil
 cavilling
 Caviness
 cavil
 cavilling
 Caviness
-cavitate
 cavort
 caw
 cayenne
 cavort
 caw
 cayenne
@@ -3861,6 +3897,7 @@ chairwoman
 chairwomen
 chaise
 chalcedony
 chairwomen
 chaise
 chalcedony
+chalcocite
 chalice
 chalk
 chalkline
 chalice
 chalk
 chalkline
@@ -3906,9 +3943,9 @@ chapel
 chaperon
 chaperone
 chaplain
 chaperon
 chaperone
 chaplain
-chaplaincy
 Chaplin
 Chapman
 Chaplin
 Chapman
+chapping
 chapter
 char
 character
 chapter
 char
 character
@@ -3930,6 +3967,7 @@ Charlotte
 Charlottesville
 charm
 Charon
 Charlottesville
 charm
 Charon
+charring
 chart
 Charta
 Chartres
 chart
 Charta
 Chartres
@@ -3948,6 +3986,7 @@ chateaux
 Chatham
 Chattanooga
 chattel
 Chatham
 Chattanooga
 chattel
+chatting
 chatty
 Chaucer
 chauffeur
 chatty
 Chaucer
 chauffeur
@@ -3966,15 +4005,16 @@ checkout
 checkpoint
 checksum
 checksummed
 checkpoint
 checksum
 checksummed
+checksumming
 checkup
 cheek
 cheekbone
 cheeky
 cheer
 checkup
 cheek
 cheekbone
 cheeky
 cheer
+cheerful
 cheerleader
 cheery
 cheese
 cheerleader
 cheery
 cheese
-cheesecake
 cheesecloth
 cheesy
 cheetah
 cheesecloth
 cheesy
 cheetah
@@ -3986,7 +4026,6 @@ chemisorb
 chemisorption
 chemist
 chemistry
 chemisorption
 chemist
 chemistry
-chemotherapy
 Chen
 Cheney
 chenille
 Chen
 Cheney
 chenille
@@ -4020,6 +4059,7 @@ Chicano
 chick
 chickadee
 chicken
 chick
 chickadee
 chicken
+chickweed
 chicory
 chide
 chief
 chicory
 chide
 chief
@@ -4055,12 +4095,14 @@ chinchilla
 chine
 Chinese
 chink
 chine
 Chinese
 chink
+chinning
 Chinook
 chinquapin
 chip
 chipboard
 chipmunk
 Chippendale
 Chinook
 chinquapin
 chip
 chipboard
 chipmunk
 Chippendale
+chipping
 chiropractor
 chirp
 chisel
 chiropractor
 chirp
 chisel
@@ -4093,6 +4135,7 @@ choose
 choosy
 chop
 Chopin
 choosy
 chop
 Chopin
+chopping
 choppy
 choral
 chorale
 choppy
 choral
 chorale
@@ -4144,6 +4187,7 @@ chronography
 chronology
 chrysanthemum
 Chrysler
 chronology
 chrysanthemum
 Chrysler
+chrysolite
 chub
 chubby
 chuck
 chub
 chubby
 chuck
@@ -4153,13 +4197,15 @@ chuff
 chug
 chugging
 chum
 chug
 chugging
 chum
+chumming
 chummy
 chump
 Chungking
 chunk
 chunky
 church
 chummy
 chump
 Chungking
 chunk
 chunky
 church
-churchgo
+churchgoer
+churchgoing
 Churchill
 Churchillian
 churchman
 Churchill
 Churchillian
 churchman
@@ -4239,6 +4285,7 @@ civic
 civil
 civilian
 clad
 civil
 civilian
 clad
+cladding
 cladophora
 claim
 claimant
 cladophora
 claim
 claimant
@@ -4246,6 +4293,7 @@ Claire
 clairvoyant
 clam
 clamber
 clairvoyant
 clam
 clamber
+clamming
 clammy
 clamp
 clamshell
 clammy
 clamp
 clamshell
@@ -4257,6 +4305,7 @@ clannish
 clap
 clapboard
 Clapeyron
 clap
 clapboard
 Clapeyron
+clapping
 Clara
 Clare
 Claremont
 Clara
 Clare
 Claremont
@@ -4339,6 +4388,7 @@ Clinton
 Clio
 clip
 clipboard
 Clio
 clip
 clipboard
+clipping
 clique
 Clive
 cloak
 clique
 Clive
 cloak
@@ -4371,6 +4421,7 @@ clothesman
 clothesmen
 clothier
 Clotho
 clothesmen
 clothier
 Clotho
+clotting
 cloture
 cloud
 cloudburst
 cloture
 cloud
 cloudburst
@@ -4380,6 +4431,7 @@ clove
 clown
 cloy
 club
 clown
 cloy
 club
+clubbing
 clubhouse
 clubroom
 cluck
 clubhouse
 clubroom
 cluck
@@ -4564,6 +4616,7 @@ Colorado
 colorate
 coloratura
 colorimeter
 colorate
 coloratura
 colorimeter
+colorimetry
 colossal
 Colosseum
 colossi
 colossal
 Colosseum
 colossi
@@ -4686,7 +4739,6 @@ complain
 complainant
 complaint
 complaisant
 complainant
 complaint
 complaisant
-compleat
 complement
 complementarity
 complementary
 complement
 complementarity
 complementary
@@ -4703,6 +4755,7 @@ complimentary
 compline
 comply
 component
 compline
 comply
 component
+componentry
 comport
 compose
 composite
 comport
 compose
 composite
@@ -4792,6 +4845,7 @@ conduce
 conducive
 conduct
 conductance
 conducive
 conduct
 conductance
+conductive
 conductor
 conduit
 cone
 conductor
 conduit
 cone
@@ -4806,6 +4860,7 @@ confederate
 confer
 conferee
 conference
 confer
 conferee
 conference
+conferrable
 conferred
 conferring
 confess
 conferred
 conferring
 confess
@@ -4943,7 +4998,6 @@ Constantine
 Constantinople
 constellate
 consternate
 Constantinople
 constellate
 consternate
-constipate
 constituent
 constitute
 constitution
 constituent
 constitute
 constitution
@@ -5295,7 +5349,6 @@ courtier
 Courtney
 courtroom
 courtyard
 Courtney
 courtroom
 courtyard
-couscous
 cousin
 couturier
 covalent
 cousin
 couturier
 covalent
@@ -5305,6 +5358,7 @@ covary
 cove
 coven
 covenant
 cove
 coven
 covenant
+Coventry
 cover
 coverage
 coverall
 cover
 coverage
 coverall
@@ -5345,6 +5399,7 @@ cozy
 CPA
 crab
 crabapple
 CPA
 crab
 crabapple
+crabbing
 crack
 crackle
 crackpot
 crack
 crackle
 crackpot
@@ -5360,6 +5415,7 @@ craggy
 Craig
 cram
 Cramer
 Craig
 cram
 Cramer
+cramming
 cramp
 cranberry
 Crandall
 cramp
 cranberry
 Crandall
@@ -5441,6 +5497,7 @@ crewel
 crewman
 crewmen
 crib
 crewman
 crewmen
 crib
+cribbing
 cricket
 cried
 crime
 cricket
 cried
 crime
@@ -5479,6 +5536,7 @@ crony
 crook
 croon
 crop
 crook
 croon
 crop
+cropping
 Crosby
 cross
 crossarm
 Crosby
 cross
 crossarm
@@ -5486,7 +5544,6 @@ crossbar
 crossbill
 crosscut
 crosshatch
 crossbill
 crosscut
 crosshatch
-crosslink
 crossover
 crosspoint
 crossroad
 crossover
 crosspoint
 crossroad
@@ -5494,6 +5551,7 @@ crosstalk
 crosswalk
 crossway
 crosswise
 crosswalk
 crossway
 crosswise
+crosswort
 crotch
 crotchety
 crouch
 crotch
 crotchety
 crouch
@@ -5590,8 +5648,10 @@ Cunningham
 CUNY
 cup
 cupboard
 CUNY
 cup
 cupboard
+cupful
 Cupid
 cupidity
 Cupid
 cupidity
+cupping
 cupric
 cuprous
 cur
 cupric
 cuprous
 cur
@@ -5653,6 +5713,7 @@ cutoff
 cutout
 cutover
 cutthroat
 cutout
 cutover
 cutthroat
+cutting
 cuttlebone
 cuttlefish
 cutworm
 cuttlebone
 cuttlefish
 cutworm
@@ -5696,6 +5757,7 @@ d'etat
 d'oeuvre
 d's
 dab
 d'oeuvre
 d's
 dab
+dabbing
 dabble
 Dacca
 dachshund
 dabble
 Dacca
 dachshund
@@ -5736,6 +5798,7 @@ damage
 Damascus
 damask
 dame
 Damascus
 damask
 dame
+damming
 damn
 damnation
 Damon
 damn
 damnation
 Damon
@@ -5844,6 +5907,7 @@ deathbed
 deathward
 debacle
 debar
 deathward
 debacle
 debar
+debarring
 debase
 debate
 debater
 debase
 debate
 debater
@@ -5882,6 +5946,7 @@ Decca
 decease
 decedent
 deceit
 decease
 decedent
 deceit
+deceitful
 deceive
 decelerate
 December
 deceive
 decelerate
 December
@@ -5959,14 +6024,13 @@ default
 defeat
 defecate
 defect
 defeat
 defecate
 defect
-defector
 defend
 defendant
 defensible
 defensive
 defer
 defend
 defendant
 defensible
 defensive
 defer
-deferable
 deferent
 deferent
+deferrable
 deferred
 deferring
 defiant
 deferred
 deferring
 defiant
@@ -5992,6 +6056,7 @@ deft
 defunct
 defy
 degas
 defunct
 defy
 degas
+degassing
 degeneracy
 degenerate
 degradation
 degeneracy
 degenerate
 degradation
@@ -5999,6 +6064,7 @@ degrade
 degrease
 degree
 degum
 degrease
 degree
 degum
+degumming
 dehumidify
 dehydrate
 deify
 dehumidify
 dehydrate
 deify
@@ -6027,6 +6093,7 @@ delicatessen
 delicious
 delicti
 delight
 delicious
 delicti
 delight
+delightful
 Delilah
 delimit
 delimitation
 Delilah
 delimit
 delimitation
@@ -6096,8 +6163,6 @@ demurring
 demythologize
 den
 denature
 demythologize
 den
 denature
-dendrite
-dendritic
 Deneb
 Denebola
 deniable
 Deneb
 Denebola
 deniable
@@ -6115,6 +6180,8 @@ denouement
 denounce
 dense
 densitometer
 denounce
 dense
 densitometer
+densitometric
+densitometry
 dent
 dental
 dentistry
 dent
 dental
 dentistry
@@ -6260,7 +6327,6 @@ detestation
 detonable
 detonate
 detour
 detonable
 detonate
 detour
-detoxify
 detract
 detractor
 detriment
 detract
 detractor
 detriment
@@ -6324,6 +6390,7 @@ dialysis
 diamagnetic
 diamegnetism
 diameter
 diamagnetic
 diamegnetism
 diameter
+diametric
 diamond
 Diana
 Diane
 diamond
 Diana
 Diane
@@ -6413,6 +6480,7 @@ dihedral
 dilapidate
 dilatation
 dilate
 dilapidate
 dilatation
 dilate
+dilation
 dilatory
 dilemma
 dilettante
 dilatory
 dilemma
 dilettante
@@ -6430,6 +6498,7 @@ dimethyl
 diminish
 diminution
 diminutive
 diminish
 diminution
 diminutive
+dimming
 dimple
 din
 Dinah
 dimple
 din
 Dinah
@@ -6450,6 +6519,7 @@ Dionysus
 Diophantine
 diopter
 diorama
 Diophantine
 diopter
 diorama
+diorite
 dioxide
 dip
 diphthong
 dioxide
 dip
 diphthong
@@ -6458,6 +6528,7 @@ diplomacy
 diplomat
 diplomatic
 dipole
 diplomat
 diplomatic
 dipole
+dipping
 Dirac
 dire
 direct
 Dirac
 dire
 direct
@@ -6498,8 +6569,10 @@ discuss
 discussant
 discussion
 disdain
 discussant
 discussion
 disdain
+disdainful
 disembowel
 disgruntle
 disembowel
 disgruntle
+disgustful
 dish
 dishevel
 dishwasher
 dish
 dishevel
 dishwasher
@@ -6515,7 +6588,6 @@ disparate
 dispel
 dispelled
 dispelling
 dispel
 dispelled
 dispelling
-dispensable
 dispensary
 dispensate
 dispense
 dispensary
 dispensate
 dispense
@@ -6647,9 +6719,9 @@ Dolan
 dolce
 doldrum
 dole
 dolce
 doldrum
 dole
+doleful
 doll
 dollar
 doll
 dollar
-dollop
 dolly
 dolomite
 dolomitic
 dolly
 dolomite
 dolomitic
@@ -6685,6 +6757,7 @@ donkey
 Donna
 Donnelly
 Donner
 Donna
 Donnelly
 Donner
+donning
 donnybrook
 donor
 Donovan
 donnybrook
 donor
 Donovan
@@ -6725,6 +6798,7 @@ dossier
 Dostoevsky
 dot
 dote
 Dostoevsky
 dot
 dote
+dotting
 double
 Doubleday
 doubleheader
 double
 Doubleday
 doubleheader
@@ -6732,6 +6806,7 @@ doublet
 doubleton
 doubloon
 doubt
 doubleton
 doubloon
 doubt
+doubtful
 douce
 Doug
 dough
 douce
 Doug
 dough
@@ -6811,6 +6886,7 @@ drawbridge
 drawl
 drawn
 dread
 drawl
 drawn
 dread
+dreadful
 dreadnought
 dream
 dreamboat
 dreadnought
 dream
 dreamboat
@@ -6835,6 +6911,7 @@ drift
 drill
 drink
 drip
 drill
 drink
 drip
+dripping
 drippy
 Driscoll
 drive
 drippy
 Driscoll
 drive
@@ -6852,6 +6929,7 @@ drop
 drophead
 droplet
 dropout
 drophead
 droplet
 dropout
+dropping
 drosophila
 dross
 drought
 drosophila
 dross
 drought
@@ -6860,6 +6938,7 @@ drown
 drowse
 drowsy
 drub
 drowse
 drowsy
 drub
+drubbing
 drudge
 drudgery
 drug
 drudge
 drudgery
 drug
@@ -6869,6 +6948,7 @@ druid
 drum
 drumhead
 drumlin
 drum
 drumhead
 drumlin
+drumming
 Drummond
 drunk
 drunkard
 Drummond
 drunk
 drunkard
@@ -6905,7 +6985,6 @@ dug
 Dugan
 dugout
 duke
 Dugan
 dugout
 duke
-dukedom
 dulcet
 dull
 dully
 dulcet
 dull
 dully
@@ -6965,6 +7044,7 @@ dutchess
 Dutchman
 Dutchmen
 dutiable
 Dutchman
 Dutchmen
 dutiable
+dutiful
 Dutton
 duty
 dwarf
 Dutton
 duty
 dwarf
@@ -7009,11 +7089,13 @@ earn
 earnest
 earphone
 earring
 earnest
 earphone
 earring
+earsplitting
 earth
 earthen
 earthenware
 earthmen
 earth
 earthen
 earthenware
 earthmen
-earthmove
+earthmover
+earthmoving
 earthquake
 earthworm
 earthy
 earthquake
 earthworm
 earthy
@@ -7036,6 +7118,7 @@ eater
 Eaton
 eave
 eavesdrop
 Eaton
 eave
 eavesdrop
+eavesdropping
 ebb
 Eben
 ebony
 ebb
 Eben
 ebony
@@ -7054,6 +7137,7 @@ ecliptic
 eclogue
 Ecole
 ecology
 eclogue
 Ecole
 ecology
+econometric
 Econometrica
 economic
 economist
 Econometrica
 economic
 economist
@@ -7246,6 +7330,7 @@ ellipsis
 ellipsoid
 ellipsoidal
 ellipsometer
 ellipsoid
 ellipsoidal
 ellipsometer
+ellipsometry
 elliptic
 Ellis
 Ellison
 elliptic
 Ellis
 Ellison
@@ -7298,7 +7383,6 @@ embedding
 embellish
 ember
 embezzle
 embellish
 ember
 embezzle
-emblem
 emblematic
 embodiment
 embody
 emblematic
 embodiment
 embody
@@ -7368,20 +7452,38 @@ emulate
 emulsify
 emulsion
 en
 emulsify
 emulsion
 en
-enable
+enact
 enamel
 enamel
+encamp
 encapsulate
 encapsulate
+encase
 encephalitis
 encephalitis
+enchain
+enchant
 enchantress
 enchantress
+encipher
+encircle
 enclave
 enclave
+enclose
+enclosure
+encode
 encomia
 encomium
 encomia
 encomium
+encompass
+encore
+encounter
+encourage
 encroach
 encroach
+encrust
+encrypt
 encryption
 encumber
 encumbrance
 encryption
 encumber
 encumbrance
+encyclical
 encyclopedic
 end
 encyclopedic
 end
+endanger
+endear
 endgame
 Endicott
 endogamous
 endgame
 Endicott
 endogamous
@@ -7400,25 +7502,41 @@ energetic
 energy
 enervate
 enfant
 energy
 enervate
 enfant
+enfeeble
 Enfield
 Enfield
+enforce
 enforceable
 enforceable
+enforcible
+enfranchise
 Eng
 Eng
+engage
 Engel
 Engel
+engender
 engine
 engineer
 England
 engine
 engineer
 England
+Englander
 Engle
 Englewood
 English
 Englishman
 Englishmen
 Engle
 Englewood
 English
 Englishman
 Englishmen
+engrave
+engross
+engulf
 enhance
 Enid
 enigma
 enigmatic
 enhance
 Enid
 enigma
 enigmatic
+enjoin
 enjoinder
 enjoinder
+enjoy
+enlarge
 enlargeable
 enlargeable
+enlighten
+enlist
 enliven
 enliven
+enmesh
 enmity
 Enoch
 enormity
 enmity
 Enoch
 enormity
@@ -7427,37 +7545,69 @@ Enos
 enough
 enquire
 enquiry
 enough
 enquire
 enquiry
+enrage
+enrapture
+enrich
 Enrico
 Enrico
+enroll
 enrollee
 ensconce
 ensemble
 enrollee
 ensconce
 ensemble
+enshroud
+ensign
+enslave
+ensnare
+enstatite
+ensue
+ensure
+entail
+entangle
 entendre
 enter
 enterprise
 entertain
 enthalpy
 enthrall
 entendre
 enter
 enterprise
 entertain
 enthalpy
 enthrall
+enthrone
 enthusiasm
 enthusiast
 enthusiastic
 entice
 enthusiasm
 enthusiast
 enthusiastic
 entice
+entire
 entirety
 entirety
+entitle
 entity
 entity
+entomb
 entomology
 entourage
 entomology
 entourage
+entrain
+entrance
 entranceway
 entrant
 entranceway
 entrant
+entrap
+entrapping
+entreat
+entreaty
+entree
+entrench
 entrepreneur
 entrepreneurial
 entropy
 entrepreneur
 entrepreneurial
 entropy
+entrust
+entry
+entwine
 enumerable
 enumerate
 enunciable
 enunciate
 envelop
 envelope
 enumerable
 enumerate
 enunciable
 enunciate
 envelop
 envelope
+envenom
+enviable
 envious
 environ
 envious
 environ
+envisage
+envision
 envoy
 envy
 enzymatic
 envoy
 envy
 enzymatic
@@ -7496,7 +7646,6 @@ episcopal
 Episcopalian
 episcopate
 episode
 Episcopalian
 episcopate
 episode
-episodic
 epistemology
 epistle
 epistolatory
 epistemology
 epistle
 epistolatory
@@ -7508,7 +7657,6 @@ epithelium
 epithet
 epitome
 epoch
 epithet
 epitome
 epoch
-epochal
 epoxy
 epsilon
 Epsom
 epoxy
 epsilon
 Epsom
@@ -7710,6 +7858,7 @@ even
 evenhanded
 evensong
 event
 evenhanded
 evensong
 event
+eventful
 eventide
 eventual
 eventuate
 eventide
 eventual
 eventuate
@@ -7741,7 +7890,6 @@ evolve
 evzone
 ewe
 Ewing
 evzone
 ewe
 Ewing
-ex
 exacerbate
 exact
 exaggerate
 exacerbate
 exact
 exaggerate
@@ -7791,7 +7939,6 @@ excrete
 excretion
 excretory
 excruciate
 excretion
 excretory
 excruciate
-exculpate
 exculpatory
 excursion
 excursus
 exculpatory
 excursion
 excursus
@@ -7976,6 +8123,7 @@ eyeball
 eyebright
 eyebrow
 eyed
 eyebright
 eyebrow
 eyed
+eyeful
 eyeglass
 eyelash
 eyelet
 eyeglass
 eyelash
 eyelet
@@ -8020,7 +8168,6 @@ fag
 Fahey
 Fahrenheit
 fail
 Fahey
 Fahrenheit
 fail
-failsafe
 failsoft
 failure
 fain
 failsoft
 failure
 fain
@@ -8034,6 +8181,7 @@ Fairport
 fairway
 fairy
 faith
 fairway
 fairy
 faith
+faithful
 fake
 falcon
 falconry
 fake
 falcon
 falconry
@@ -8061,11 +8209,13 @@ famine
 famous
 fan
 fanatic
 famous
 fan
 fanatic
+fanciful
 fancy
 fanfare
 fanfold
 fang
 fangled
 fancy
 fanfare
 fanfold
 fang
 fangled
+fanning
 Fanny
 fanout
 fantasia
 Fanny
 fanout
 fantasia
@@ -8108,6 +8258,7 @@ fastidious
 fat
 fatal
 fate
 fat
 fatal
 fate
+fateful
 father
 fathom
 fatigue
 father
 fathom
 fatigue
@@ -8135,12 +8286,14 @@ FDA
 Fe
 fealty
 fear
 Fe
 fealty
 fear
+fearful
 fearsome
 feasible
 feast
 feat
 feather
 featherbed
 fearsome
 feasible
 feast
 feat
 feather
 featherbed
+featherbedding
 featherbrain
 feathertop
 featherweight
 featherbrain
 feathertop
 featherweight
@@ -8177,6 +8330,7 @@ fellow
 felon
 felonious
 felony
 felon
 felonious
 felony
+felsite
 felt
 female
 feminine
 felt
 female
 feminine
@@ -8241,6 +8395,7 @@ fiancee
 fiasco
 fiat
 fib
 fiasco
 fiat
 fib
+fibbing
 fiberboard
 Fiberglas
 Fibonacci
 fiberboard
 Fiberglas
 Fibonacci
@@ -8356,7 +8511,6 @@ firewall
 firewood
 firework
 firm
 firewood
 firework
 firm
-firmware
 first
 firsthand
 fiscal
 first
 firsthand
 fiscal
@@ -8379,6 +8533,8 @@ fisticuff
 fit
 Fitch
 Fitchburg
 fit
 Fitch
 Fitchburg
+fitful
+fitting
 Fitzgerald
 Fitzpatrick
 Fitzroy
 Fitzgerald
 Fitzpatrick
 Fitzroy
@@ -8417,6 +8573,7 @@ flange
 flank
 flannel
 flap
 flank
 flannel
 flap
+flapping
 flare
 flash
 flashback
 flare
 flash
 flashback
@@ -8441,6 +8598,7 @@ flaxen
 flaxseed
 flea
 fleabane
 flaxseed
 flea
 fleabane
+fleawort
 fleck
 fled
 fledge
 fleck
 fled
 fledge
@@ -8472,10 +8630,12 @@ flinty
 flip
 flipflop
 flippant
 flip
 flipflop
 flippant
+flipping
 flirt
 flirtation
 flirtatious
 flit
 flirt
 flirtation
 flirtatious
 flit
+flitting
 Flo
 float
 floc
 Flo
 float
 floc
@@ -8491,6 +8651,7 @@ floodlit
 floor
 floorboard
 flop
 floor
 floorboard
 flop
+flopping
 floppy
 flora
 floral
 floppy
 flora
 floral
@@ -8518,6 +8679,7 @@ flown
 Floyd
 flu
 flub
 Floyd
 flu
 flub
+flubbing
 fluctuate
 flue
 fluency
 fluctuate
 flue
 fluency
@@ -8554,6 +8716,7 @@ foam
 foamflower
 foamy
 fob
 foamflower
 foamy
 fob
+fobbing
 focal
 foci
 focus
 focal
 foci
 focus
@@ -8623,9 +8786,11 @@ forbearance
 Forbes
 forbid
 forbidden
 Forbes
 forbid
 forbidden
+forbidding
 forbore
 forborne
 force
 forbore
 forborne
 force
+forceful
 forcible
 ford
 Fordham
 forcible
 ford
 Fordham
@@ -8642,7 +8807,9 @@ forgave
 forge
 forgery
 forget
 forge
 forgery
 forget
+forgetful
 forgettable
 forgettable
+forgetting
 forgive
 forgiven
 forgot
 forgive
 forgiven
 forgot
@@ -8656,6 +8823,7 @@ formaldehyde
 formant
 format
 formate
 formant
 format
 formate
+formatting
 formic
 Formica
 formidable
 formic
 Formica
 formidable
@@ -8685,7 +8853,6 @@ fortitude
 fortnight
 Fortran
 fortress
 fortnight
 Fortran
 fortress
-fortuitous
 fortunate
 fortune
 forty
 fortunate
 fortune
 forty
@@ -8695,6 +8862,7 @@ Foss
 fossil
 fossiliferous
 foster
 fossil
 fossiliferous
 foster
+fosterite
 fought
 foul
 foulmouth
 fought
 foul
 foulmouth
@@ -8818,6 +8986,7 @@ freshwater
 Fresnel
 Fresno
 fret
 Fresnel
 Fresno
 fret
+fretting
 Freud
 Freudian
 Frey
 Freud
 Freudian
 Frey
@@ -8837,6 +9006,7 @@ frigate
 Frigga
 fright
 frighten
 Frigga
 fright
 frighten
+frightful
 frigid
 Frigidaire
 frill
 frigid
 Frigidaire
 frill
@@ -8873,6 +9043,7 @@ frozen
 Fruehauf
 frugal
 fruit
 Fruehauf
 frugal
 fruit
+fruitful
 fruition
 frustrate
 frustrater
 fruition
 frustrate
 frustrater
@@ -8931,6 +9102,7 @@ furnace
 furnish
 furniture
 furrier
 furnish
 furniture
 furrier
+furring
 furrow
 furry
 further
 furrow
 furry
 further
@@ -8957,6 +9129,7 @@ g
 g's
 gab
 gabardine
 g's
 gab
 gabardine
+gabbing
 gabble
 gabbro
 Gaberones
 gabble
 gabbro
 Gaberones
@@ -8965,6 +9138,7 @@ Gabon
 Gabriel
 Gabrielle
 gad
 Gabriel
 Gabrielle
 gad
+gadding
 gadfly
 gadget
 gadgetry
 gadfly
 gadget
 gadgetry
@@ -8984,6 +9158,7 @@ gaillardia
 gain
 Gaines
 Gainesville
 gain
 Gaines
 Gainesville
+gainful
 gait
 Gaithersburg
 gal
 gait
 Gaithersburg
 gal
@@ -8997,6 +9172,7 @@ Galbreath
 gale
 Galen
 galena
 gale
 Galen
 galena
+galenite
 Galilee
 gall
 Gallagher
 Galilee
 gall
 Gallagher
@@ -9087,6 +9263,7 @@ gaslight
 gasoline
 gasp
 Gaspee
 gasoline
 gasp
 Gaspee
+gassing
 gassy
 Gaston
 gastrointestinal
 gassy
 Gaston
 gastrointestinal
@@ -9127,7 +9304,6 @@ gazette
 GE
 gear
 gecko
 GE
 gear
 gecko
-gedanken
 gee
 geese
 Gegenschein
 gee
 geese
 Gegenschein
@@ -9144,7 +9320,6 @@ gem
 Gemini
 gemlike
 Gemma
 Gemini
 gemlike
 Gemma
-gemstone
 gender
 gene
 genealogy
 gender
 gene
 genealogy
@@ -9190,7 +9365,9 @@ geographer
 geography
 geology
 geometer
 geography
 geology
 geometer
+geometric
 geometrician
 geometrician
+geometry
 geophysical
 geophysics
 geopolitic
 geophysical
 geophysics
 geopolitic
@@ -9229,6 +9406,7 @@ gesticulate
 gesture
 get
 getaway
 gesture
 get
 getaway
+getting
 Getty
 Gettysburg
 geyser
 Getty
 Gettysburg
 geyser
@@ -9294,6 +9472,7 @@ gingko
 ginkgo
 ginmill
 Ginn
 ginkgo
 ginmill
 Ginn
+ginning
 Gino
 Ginsberg
 Ginsburg
 Gino
 Ginsberg
 Ginsburg
@@ -9336,6 +9515,7 @@ Glasgow
 glass
 glassine
 glassware
 glass
 glassine
 glassware
+glasswort
 glassy
 Glaswegian
 glaucoma
 glassy
 Glaswegian
 glaucoma
@@ -9345,6 +9525,7 @@ gleam
 glean
 Gleason
 glee
 glean
 Gleason
 glee
+gleeful
 glen
 Glenda
 Glendale
 glen
 Glenda
 Glendale
@@ -9393,6 +9574,7 @@ glum
 glut
 glutamic
 glutinous
 glut
 glutamic
 glutinous
+glutting
 glutton
 glyceride
 glycerin
 glutton
 glyceride
 glycerin
@@ -9465,7 +9647,6 @@ golly
 gondola
 gone
 gong
 gondola
 gone
 gong
-goniometer
 Gonzales
 Gonzalez
 goober
 Gonzales
 Gonzalez
 goober
@@ -9519,7 +9700,9 @@ governor
 gown
 GPO
 grab
 gown
 GPO
 grab
+grabbing
 grace
 grace
+graceful
 gracious
 grackle
 grad
 gracious
 grackle
 grad
@@ -9534,7 +9717,6 @@ graft
 graham
 grail
 grain
 graham
 grail
 grain
-grainy
 grammar
 grammarian
 grammatic
 grammar
 grammarian
 grammatic
@@ -9580,6 +9762,7 @@ grassland
 grassy
 grata
 grate
 grassy
 grata
 grate
+grateful
 grater
 gratify
 gratis
 grater
 gratify
 gratis
@@ -9666,9 +9849,11 @@ Grimm
 grin
 grind
 grindstone
 grin
 grind
 grindstone
+grinning
 grip
 gripe
 grippe
 grip
 gripe
 grippe
+gripping
 grisly
 grist
 gristmill
 grisly
 grist
 gristmill
@@ -9709,6 +9894,7 @@ grown
 grownup
 growth
 grub
 grownup
 growth
 grub
+grubbing
 grubby
 grudge
 gruesome
 grubby
 grudge
 gruesome
@@ -9752,7 +9938,6 @@ guildhall
 guile
 Guilford
 guillemot
 guile
 Guilford
 guillemot
-guillotine
 guilt
 guilty
 guinea
 guilt
 guilty
 guinea
@@ -9768,7 +9953,7 @@ gully
 gulp
 gum
 gumbo
 gulp
 gum
 gumbo
-gumdrop
+gumming
 gummy
 gumption
 gumshoe
 gummy
 gumption
 gumshoe
@@ -9782,6 +9967,7 @@ gunky
 gunman
 gunmen
 gunnery
 gunman
 gunmen
 gunnery
+gunning
 gunny
 gunplay
 gunpowder
 gunny
 gunplay
 gunpowder
@@ -9805,6 +9991,7 @@ gut
 Gutenberg
 Guthrie
 gutsy
 Gutenberg
 Guthrie
 gutsy
+gutting
 guttural
 guy
 Guyana
 guttural
 guy
 Guyana
@@ -9817,6 +10004,7 @@ gymnast
 gymnastic
 gymnosperm
 gyp
 gymnastic
 gymnosperm
 gyp
+gypping
 gypsite
 gypsum
 gypsy
 gypsite
 gypsum
 gypsy
@@ -9918,6 +10106,7 @@ Hamiltonian
 hamlet
 Hamlin
 hammerhead
 hamlet
 Hamlin
 hammerhead
+hamming
 hammock
 Hammond
 hamper
 hammock
 Hammond
 hamper
@@ -9932,11 +10121,13 @@ handbook
 handclasp
 handcuff
 Handel
 handclasp
 handcuff
 Handel
+handful
 handgun
 handhold
 handicap
 handicapped
 handicapper
 handgun
 handhold
 handicap
 handicapped
 handicapper
+handicapping
 handicraft
 handicraftsman
 handicraftsmen
 handicraft
 handicraftsman
 handicraftsmen
@@ -10017,6 +10208,7 @@ Harlan
 Harlem
 Harley
 harm
 Harlem
 Harley
 harm
+harmful
 Harmon
 harmonic
 harmonious
 Harmon
 harmonic
 harmonious
@@ -10059,6 +10251,7 @@ hatch
 hatchet
 hatchway
 hate
 hatchet
 hatchway
 hate
+hateful
 hater
 Hatfield
 hath
 hater
 Hatfield
 hath
@@ -10120,15 +10313,14 @@ headsman
 headsmen
 headstand
 headstone
 headsmen
 headstand
 headstone
-headstrong
 headwall
 headwater
 headway
 headwall
 headwater
 headway
-headwind
 heady
 heal
 Healey
 health
 heady
 heal
 Healey
 health
+healthful
 healthy
 Healy
 heap
 healthy
 Healy
 heap
@@ -10183,7 +10375,6 @@ heigh
 height
 heighten
 Heine
 height
 heighten
 Heine
-Heinrich
 Heinz
 heir
 heiress
 Heinz
 heir
 heiress
@@ -10192,7 +10383,6 @@ held
 Helen
 Helena
 Helene
 Helen
 Helena
 Helene
-Helga
 helical
 helicopter
 heliocentric
 helical
 helicopter
 heliocentric
@@ -10214,6 +10404,7 @@ helmsman
 helmsmen
 Helmut
 help
 helmsmen
 Helmut
 help
+helpful
 helpmate
 Helsinki
 Helvetica
 helpmate
 Helsinki
 Helvetica
@@ -10223,6 +10414,7 @@ Hemingway
 hemisphere
 hemispheric
 hemlock
 hemisphere
 hemispheric
 hemlock
+hemming
 hemoglobin
 hemolytic
 hemorrhage
 hemoglobin
 hemolytic
 hemorrhage
@@ -10242,6 +10434,7 @@ Hendricks
 Hendrickson
 henequen
 Henley
 Hendrickson
 henequen
 Henley
+Henning
 henpeck
 Henri
 Henrietta
 henpeck
 Henri
 Henrietta
@@ -10300,6 +10493,7 @@ heron
 herpes
 herpetology
 Herr
 herpes
 herpetology
 Herr
+herring
 herringbone
 Herschel
 herself
 herringbone
 Herschel
 herself
@@ -10345,7 +10539,6 @@ hey
 heyday
 hi
 Hiatt
 heyday
 hi
 Hiatt
-hiatus
 Hiawatha
 hibachi
 Hibbard
 Hiawatha
 hibachi
 Hibbard
@@ -10396,7 +10589,6 @@ Hillcrest
 Hillel
 hillman
 hillmen
 Hillel
 hillman
 hillmen
-hillock
 hillside
 hilltop
 hilly
 hillside
 hilltop
 hilly
@@ -10418,6 +10610,7 @@ Hinman
 hint
 hinterland
 hip
 hint
 hinterland
 hip
+hipping
 hippo
 hippodrome
 hippopotamus
 hippo
 hippodrome
 hippopotamus
@@ -10429,9 +10622,7 @@ hireling
 Hiroshi
 Hiroshima
 Hirsch
 Hiroshi
 Hiroshima
 Hirsch
-hirsute
 his
 his
-Hispanic
 hiss
 histochemic
 histochemistry
 hiss
 histochemic
 histochemistry
@@ -10449,6 +10640,7 @@ Hitchcock
 hither
 hitherto
 Hitler
 hither
 hitherto
 Hitler
+hitting
 hive
 ho
 hoagie
 hive
 ho
 hoagie
@@ -10521,15 +10713,16 @@ holystone
 homage
 home
 homebound
 homage
 home
 homebound
-homebuild
-homecome
+homebuilder
+homebuilding
+homecoming
 homeland
 homemade
 homemake
 homeomorph
 homeomorphic
 homeopath
 homeland
 homemade
 homemake
 homeomorph
 homeomorphic
 homeopath
-homeown
+homeowner
 Homeric
 homesick
 homestead
 Homeric
 homesick
 homestead
@@ -10567,11 +10760,9 @@ Honeywell
 hong
 honk
 Honolulu
 hong
 honk
 Honolulu
-honoraria
 honorarium
 honorary
 honoree
 honorarium
 honorary
 honoree
-honorific
 Honshu
 hooch
 hood
 Honshu
 hooch
 hood
@@ -10591,8 +10782,10 @@ Hoover
 hooves
 hop
 hope
 hooves
 hop
 hope
+hopeful
 Hopkins
 Hopkinsian
 Hopkins
 Hopkinsian
+hopping
 hopple
 hopscotch
 Horace
 hopple
 hopscotch
 Horace
@@ -10609,6 +10802,7 @@ Hornblower
 hornet
 hornmouth
 horntail
 hornet
 hornmouth
 horntail
+hornwort
 horny
 horology
 horoscope
 horny
 horology
 horoscope
@@ -10697,7 +10891,6 @@ hubbub
 hubby
 Huber
 Hubert
 hubby
 Huber
 Hubert
-hubris
 huck
 huckleberry
 huckster
 huck
 huckleberry
 huckster
@@ -10730,6 +10923,7 @@ humidistat
 humiliate
 humility
 Hummel
 humiliate
 humility
 Hummel
+humming
 hummingbird
 hummock
 humorous
 hummingbird
 hummock
 humorous
@@ -10877,6 +11071,7 @@ iceland
 Icelandic
 ichneumon
 icicle
 Icelandic
 ichneumon
 icicle
+icing
 icon
 iconoclasm
 iconoclast
 icon
 iconoclasm
 iconoclast
@@ -10975,7 +11170,6 @@ immersion
 immigrant
 immigrate
 imminent
 immigrant
 immigrate
 imminent
-immiscible
 immobile
 immobility
 immoderate
 immobile
 immobility
 immoderate
@@ -11053,7 +11247,6 @@ important
 importation
 importunate
 importune
 importation
 importunate
 importune
-imposable
 impose
 imposition
 impossible
 impose
 imposition
 impossible
@@ -11289,6 +11482,7 @@ indomitable
 Indonesia
 Indonesian
 indoor
 Indonesia
 Indonesian
 indoor
+indorse
 indubitable
 induce
 inducible
 indubitable
 induce
 inducible
@@ -11371,7 +11565,7 @@ infest
 infestation
 infidel
 infield
 infestation
 infidel
 infield
-infight
+infighting
 infiltrate
 infima
 infimum
 infiltrate
 infima
 infimum
@@ -11390,7 +11584,6 @@ inflammation
 inflammatory
 inflate
 inflater
 inflammatory
 inflate
 inflater
-inflationary
 inflect
 inflexible
 inflict
 inflect
 inflexible
 inflict
@@ -11480,6 +11673,7 @@ innards
 innate
 inner
 innermost
 innate
 inner
 innermost
+inning
 innocent
 innovate
 innuendo
 innocent
 innovate
 innuendo
@@ -11516,6 +11710,7 @@ inshore
 inside
 insidious
 insight
 inside
 insidious
 insight
+insightful
 insignia
 insignificant
 insincere
 insignia
 insignificant
 insincere
@@ -11606,6 +11801,8 @@ interest
 interfere
 interference
 interferometer
 interfere
 interference
 interferometer
+interferometric
+interferometry
 interim
 interior
 interject
 interim
 interior
 interject
@@ -11651,10 +11848,17 @@ intonate
 intone
 intoxicant
 intoxicate
 intone
 intoxicant
 intoxicate
+intracity
 intractable
 intractable
-intramolecular
+intradepartment
+intramural
+intramuscular
+intranasal
 intransigent
 intransitive
 intransigent
 intransitive
+intraoffice
+intrastate
+intravenous
 intrepid
 intricacy
 intricate
 intrepid
 intricacy
 intricate
@@ -11671,7 +11875,6 @@ introvert
 intrude
 intrusion
 intrusive
 intrude
 intrusion
 intrusive
-intuit
 intuitable
 intuition
 intuitive
 intuitable
 intuition
 intuitive
@@ -11869,6 +12072,7 @@ Izvestia
 j
 j's
 jab
 j
 j's
 jab
+jabbing
 Jablonsky
 jack
 jackanapes
 Jablonsky
 jack
 jackanapes
@@ -11889,6 +12093,7 @@ Jacob
 Jacobean
 Jacobi
 Jacobian
 Jacobean
 Jacobi
 Jacobian
+Jacobite
 Jacobs
 Jacobsen
 Jacobson
 Jacobs
 Jacobsen
 Jacobson
@@ -11909,6 +12114,7 @@ Jamaica
 jamboree
 James
 Jamestown
 jamboree
 James
 Jamestown
+jamming
 Jan
 Jane
 Janeiro
 Jan
 Jane
 Janeiro
@@ -11926,6 +12132,7 @@ Japan
 Japanese
 jar
 jargon
 Japanese
 jar
 jargon
+jarring
 Jarvin
 Jason
 jasper
 Jarvin
 Jason
 jasper
@@ -11981,6 +12188,7 @@ Jesuit
 Jesus
 jet
 jetliner
 Jesus
 jet
 jetliner
+jetting
 jettison
 Jew
 jewel
 jettison
 Jew
 jewel
@@ -12004,8 +12212,6 @@ jingle
 jinx
 jitter
 jitterbug
 jinx
 jitter
 jitterbug
-jitterbugger
-jitterbugging
 jittery
 jive
 Jo
 jittery
 jive
 Jo
@@ -12014,6 +12220,7 @@ Joanna
 Joanne
 Joaquin
 job
 Joanne
 Joaquin
 job
+jobbing
 jobholder
 jock
 jockey
 jobholder
 jock
 jockey
@@ -12066,6 +12273,7 @@ Josiah
 joss
 jostle
 jot
 joss
 jostle
 jot
+jotting
 joule
 jounce
 journal
 joule
 jounce
 journal
@@ -12082,6 +12290,7 @@ jowl
 jowly
 joy
 Joyce
 jowly
 joy
 Joyce
+joyful
 joyous
 joyride
 joystick
 joyous
 joyride
 joystick
@@ -12160,6 +12369,7 @@ Justinian
 jut
 jute
 Jutish
 jut
 jute
 Jutish
+jutting
 juvenile
 juxtapose
 juxtaposition
 juvenile
 juxtapose
 juxtaposition
@@ -12188,6 +12398,7 @@ Kankakee
 Kansas
 Kant
 kaolin
 Kansas
 Kant
 kaolin
+kaolinite
 Kaplan
 kapok
 kappa
 Kaplan
 kapok
 kappa
@@ -12242,6 +12453,7 @@ Kennedy
 kennel
 Kenneth
 Kenney
 kennel
 Kenneth
 Kenney
+kenning
 keno
 Kensington
 Kent
 keno
 Kensington
 Kent
@@ -12293,7 +12505,9 @@ kickoff
 kid
 Kidde
 kiddie
 kid
 Kidde
 kiddie
+kidding
 kidnap
 kidnap
+kidnapping
 kidney
 Kieffer
 Kiev
 kidney
 Kieffer
 Kiev
@@ -12304,7 +12518,17 @@ Kilgore
 kill
 killdeer
 killjoy
 kill
 killdeer
 killjoy
+kilobit
+kilobuck
+kilobyte
+kilogauss
+kilohertz
 kilohm
 kilohm
+kilojoule
+kiloton
+kilovolt
+kilowatt
+kiloword
 Kim
 Kimball
 Kimberly
 Kim
 Kimball
 Kimberly
@@ -12380,6 +12604,7 @@ knifelike
 knight
 Knightsbridge
 knit
 knight
 Knightsbridge
 knit
+knitting
 knives
 knob
 knobby
 knives
 knob
 knobby
@@ -12389,6 +12614,7 @@ knockout
 knoll
 knot
 Knott
 knoll
 knot
 Knott
+knotting
 knotty
 know
 knoweth
 knotty
 know
 knoweth
@@ -12467,6 +12693,7 @@ laboratory
 laborious
 labour
 Labrador
 laborious
 labour
 Labrador
+labradorite
 labyrinth
 lac
 lace
 labyrinth
 lac
 lace
@@ -12518,8 +12745,8 @@ lame
 lamellar
 lament
 lamentation
 lamellar
 lament
 lamentation
-laminar
 laminate
 laminate
+lamming
 lamp
 lampblack
 lamplight
 lamp
 lampblack
 lamplight
@@ -12563,6 +12790,7 @@ lapelled
 lapidary
 Laplace
 lappet
 lapidary
 Laplace
 lappet
+lapping
 lapse
 Laramie
 larceny
 lapse
 Laramie
 larceny
@@ -12644,8 +12872,11 @@ lavender
 lavish
 Lavoisier
 law
 lavish
 Lavoisier
 law
-lawbreak
-lawgive
+lawbreaker
+lawbreaking
+lawful
+lawgiver
+lawgiving
 lawmake
 lawman
 lawmen
 lawmake
 lawman
 lawmen
@@ -12791,6 +13022,7 @@ leonine
 leopard
 Leopold
 leper
 leopard
 Leopold
 leper
+lepidolite
 leprosy
 Leroy
 Lesbian
 leprosy
 Leroy
 Lesbian
@@ -12812,6 +13044,7 @@ Letitia
 letterhead
 letterman
 lettermen
 letterhead
 letterman
 lettermen
+letting
 lettuce
 leukemia
 levee
 lettuce
 leukemia
 levee
@@ -12865,6 +13098,7 @@ lichen
 lick
 licorice
 lid
 lick
 licorice
 lid
+lidding
 lie
 Liechtenstein
 lied
 lie
 Liechtenstein
 lied
@@ -12968,11 +13202,11 @@ Lipschitz
 Lipscomb
 lipstick
 Lipton
 Lipscomb
 lipstick
 Lipton
+liquefaction
 liquefy
 liqueur
 liquid
 liquidate
 liquefy
 liqueur
 liquid
 liquidate
-liquidus
 liquor
 Lisa
 Lisbon
 liquor
 Lisa
 Lisbon
@@ -13012,6 +13246,7 @@ liturgy
 live
 Livermore
 Liverpool
 live
 Livermore
 Liverpool
+liverwort
 livery
 livestock
 liveth
 livery
 livestock
 liveth
@@ -13061,6 +13296,7 @@ locomotion
 locomotive
 locomotor
 locomotory
 locomotive
 locomotor
 locomotory
+locoweed
 locus
 locust
 locutor
 locus
 locust
 locutor
@@ -13127,6 +13363,7 @@ loot
 lop
 lope
 Lopez
 lop
 lope
 Lopez
+lopping
 lopseed
 lopsided
 loquacious
 lopseed
 lopsided
 loquacious
@@ -13151,7 +13388,8 @@ Lottie
 lotus
 Lou
 loud
 lotus
 Lou
 loud
-loudspeak
+loudspeaker
+loudspeaking
 Louis
 Louisa
 Louise
 Louis
 Louisa
 Louise
@@ -13161,6 +13399,7 @@ lounge
 Lounsbury
 Lourdes
 louse
 Lounsbury
 Lourdes
 louse
+lousewort
 lousy
 louver
 Louvre
 lousy
 louver
 Louvre
@@ -13260,6 +13499,7 @@ Lusaka
 luscious
 lush
 lust
 luscious
 lush
 lust
+lustful
 lustrous
 lusty
 lutanist
 lustrous
 lusty
 lutanist
@@ -13330,17 +13570,16 @@ mackintosh
 MacMillan
 Macon
 macro
 MacMillan
 Macon
 macro
-macromolecular
 macromolecule
 macrophage
 macroscopic
 macromolecule
 macrophage
 macroscopic
-macrostructure
 mad
 Madagascar
 madam
 Madame
 madcap
 madden
 mad
 Madagascar
 madam
 Madame
 madcap
 madden
+madding
 Maddox
 made
 Madeira
 Maddox
 made
 Madeira
@@ -13519,7 +13758,9 @@ Mann
 manna
 mannequin
 mannerism
 manna
 mannequin
 mannerism
+manning
 manometer
 manometer
+manometric
 manor
 manpower
 Mans
 manor
 manpower
 Mans
@@ -13550,6 +13791,7 @@ Mao
 Maori
 map
 maple
 Maori
 map
 maple
+mapping
 mar
 marathon
 maraud
 mar
 marathon
 maraud
@@ -13591,7 +13833,6 @@ Marion
 marionette
 marital
 maritime
 marionette
 marital
 maritime
-marjoram
 Marjorie
 Marjory
 mark
 Marjorie
 Marjory
 mark
@@ -13622,6 +13863,7 @@ marriage
 marriageable
 married
 Marrietta
 marriageable
 married
 Marrietta
+marring
 Marriott
 marrow
 marrowbone
 Marriott
 marrow
 marrowbone
@@ -13636,7 +13878,6 @@ marshland
 marshmallow
 mart
 marten
 marshmallow
 mart
 marten
-martensite
 Martha
 martial
 Martian
 Martha
 martial
 Martian
@@ -13676,6 +13917,7 @@ Massey
 massif
 massive
 mast
 massif
 massive
 mast
+masterful
 mastermind
 masterpiece
 mastery
 mastermind
 masterpiece
 mastery
@@ -13719,6 +13961,7 @@ Matson
 matte
 Matthew
 Matthews
 matte
 Matthew
 Matthews
+matting
 mattock
 mattress
 Mattson
 mattock
 mattress
 Mattson
@@ -13836,6 +14079,7 @@ mealtime
 mealy
 mean
 meander
 mealy
 mean
 meander
+meaningful
 meant
 meantime
 meanwhile
 meant
 meantime
 meanwhile
@@ -13938,7 +14182,6 @@ Menelaus
 menfolk
 menhaden
 menial
 menfolk
 menhaden
 menial
-meniscus
 Menlo
 Mennonite
 menstruate
 Menlo
 Mennonite
 menstruate
@@ -13957,6 +14200,7 @@ mercenary
 mercer
 merchandise
 merchant
 mercer
 merchandise
 merchant
+merciful
 mercilessly
 Merck
 mercurial
 mercilessly
 Merck
 mercurial
@@ -14011,7 +14255,6 @@ metalliferous
 metallography
 metalloid
 metallurgic
 metallography
 metalloid
 metallurgic
-metallurgist
 metallurgy
 metalwork
 metamorphic
 metallurgy
 metalwork
 metamorphic
@@ -14030,7 +14273,6 @@ meteorology
 meter
 methacrylate
 methane
 meter
 methacrylate
 methane
-methanol
 method
 methodic
 Methodism
 method
 methodic
 Methodism
@@ -14074,7 +14316,6 @@ Micky
 micro
 microbial
 microcosm
 micro
 microbial
 microcosm
-microfiche
 micrography
 microjoule
 micron
 micrography
 microjoule
 micron
@@ -14111,7 +14352,6 @@ midweek
 Midwest
 Midwestern
 midwife
 Midwest
 Midwestern
 midwife
-midwinter
 midwives
 mien
 miff
 midwives
 mien
 miff
@@ -14154,13 +14394,21 @@ millennia
 millennium
 miller
 millet
 millennium
 miller
 millet
+milliammeter
+milliampere
 Millie
 Millie
+millihenry
+millijoule
 Millikan
 millinery
 million
 millionaire
 millionth
 millipede
 Millikan
 millinery
 million
 millionaire
 millionth
 millipede
+millisecond
+millivolt
+millivoltmeter
+milliwatt
 Mills
 millstone
 milord
 Mills
 millstone
 milord
@@ -14180,17 +14428,16 @@ mince
 mincemeat
 mind
 Mindanao
 mincemeat
 mind
 Mindanao
+mindful
 mine
 minefield
 mineral
 mineralogy
 Minerva
 mine
 minefield
 mineral
 mineralogy
 Minerva
-minestrone
 minesweeper
 mingle
 mini
 miniature
 minesweeper
 mingle
 mini
 miniature
-minibike
 minicomputer
 minim
 minima
 minicomputer
 minim
 minima
@@ -14238,7 +14485,6 @@ miscegenation
 miscellaneous
 miscellany
 mischievous
 miscellaneous
 miscellany
 mischievous
-miscible
 miscreant
 miser
 misery
 miscreant
 miser
 misery
@@ -14259,10 +14505,12 @@ Missouri
 Missy
 mist
 mistletoe
 Missy
 mist
 mistletoe
+mistress
 misty
 MIT
 Mitchell
 mite
 misty
 MIT
 Mitchell
 mite
+miterwort
 mitigate
 mitral
 mitre
 mitigate
 mitral
 mitre
@@ -14276,6 +14524,7 @@ mnemonic
 moan
 moat
 mob
 moan
 moat
 mob
+mobbing
 mobcap
 Mobil
 mobile
 mobcap
 Mobil
 mobile
@@ -14365,6 +14614,7 @@ monetarism
 monetary
 money
 moneymake
 monetary
 money
 moneymake
+moneywort
 Mongolia
 mongoose
 Monica
 Mongolia
 mongoose
 Monica
@@ -14434,6 +14684,7 @@ Moorish
 moose
 moot
 mop
 moose
 moot
 mop
+mopping
 moraine
 moral
 morale
 moraine
 moral
 morale
@@ -14519,10 +14770,12 @@ mountaineer
 mountainous
 mountainside
 mourn
 mountainous
 mountainside
 mourn
+mournful
 mouse
 moustache
 mousy
 mouth
 mouse
 moustache
 mousy
 mouth
+mouthful
 mouthpiece
 Mouton
 move
 mouthpiece
 Mouton
 move
@@ -14542,6 +14795,7 @@ mucosa
 mucus
 mud
 Mudd
 mucus
 mud
 Mudd
+mudding
 muddle
 muddlehead
 muddy
 muddle
 muddlehead
 muddy
@@ -14572,10 +14826,8 @@ mulligan
 mulligatawny
 mullion
 multi
 mulligatawny
 mullion
 multi
-multifarious
 multinomial
 multiple
 multinomial
 multiple
-multiplet
 multiplex
 multiplexor
 multipliable
 multiplex
 multiplexor
 multipliable
@@ -14614,6 +14866,7 @@ Murray
 murre
 Muscat
 muscle
 murre
 Muscat
 muscle
+Muscovite
 Muscovy
 muscular
 musculature
 Muscovy
 muscular
 musculature
@@ -14644,7 +14897,6 @@ mustang
 mustard
 mustn't
 musty
 mustard
 mustn't
 musty
-mutagen
 mutandis
 mutant
 mutate
 mutandis
 mutant
 mutate
 n's
 NAACP
 nab
 n's
 NAACP
 nab
+nabbing
 Nabisco
 Nabisco
-nabla
 Nadine
 nadir
 nag
 Nadine
 nadir
 nag
@@ -14725,11 +14977,11 @@ nanosecond
 Nantucket
 Naomi
 nap
 Nantucket
 Naomi
 nap
-nape
 napkin
 Naples
 Napoleon
 Napoleonic
 napkin
 Naples
 Napoleon
 Napoleonic
+napping
 Narbonne
 narcissist
 narcissus
 Narbonne
 narcissist
 narcissus
@@ -14791,7 +15043,6 @@ Ndjamena
 ne
 Neal
 Neanderthal
 ne
 Neal
 Neanderthal
-neap
 Neapolitan
 near
 nearby
 Neapolitan
 near
 nearby
@@ -14824,6 +15075,7 @@ nectary
 Ned
 nee
 need
 Ned
 nee
 need
+needful
 needham
 needle
 needlepoint
 needham
 needle
 needlepoint
@@ -14874,6 +15126,7 @@ net
 nether
 Netherlands
 netherworld
 nether
 Netherlands
 netherworld
+netting
 nettle
 nettlesome
 network
 nettle
 nettlesome
 network
@@ -15001,6 +15254,7 @@ ninth
 Niobe
 niobium
 nip
 Niobe
 niobium
 nip
+nipping
 nipple
 Nippon
 nirvana
 nipple
 Nippon
 nirvana
@@ -15034,6 +15288,7 @@ nocturnal
 nocturne
 nod
 nodal
 nocturne
 nod
 nodal
+nodding
 node
 nodular
 nodule
 node
 nodular
 nodule
@@ -15044,12 +15299,10 @@ noisy
 Nolan
 Noll
 nolo
 Nolan
 Noll
 nolo
-nomadic
 nomenclature
 nominal
 nominate
 nominee
 nomenclature
 nominal
 nominate
 nominee
-nomograph
 non
 nonce
 nonchalant
 non
 nonce
 nonchalant
@@ -15105,6 +15358,7 @@ Nostradamus
 Nostrand
 nostril
 not
 Nostrand
 nostril
 not
+notarize
 notary
 notate
 notch
 notary
 notate
 notch
@@ -15191,6 +15445,7 @@ nutrition
 nutritious
 nutritive
 nutshell
 nutritious
 nutritive
 nutshell
+nutting
 nuzzle
 NY
 NYC
 nuzzle
 NY
 NYC
@@ -15242,7 +15497,6 @@ objectify
 objectivity
 objector
 objet
 objectivity
 objector
 objet
-oblate
 obligate
 obligatory
 oblige
 obligate
 obligatory
 oblige
@@ -15269,7 +15523,6 @@ obsidian
 obsolescent
 obsolete
 obstacle
 obsolescent
 obsolete
 obstacle
-obstetric
 obstinacy
 obstinate
 obstruct
 obstinacy
 obstinate
 obstruct
@@ -15310,7 +15563,6 @@ octahedral
 octahedron
 octal
 octane
 octahedron
 octal
 octane
-octant
 octave
 Octavia
 octennial
 octave
 Octavia
 octennial
@@ -15353,6 +15605,7 @@ officialdom
 officiate
 officio
 officious
 officiate
 officio
 officious
+offing
 offload
 offsaddle
 offset
 offload
 offsaddle
 offset
@@ -15394,7 +15647,6 @@ oldy
 oleander
 olefin
 oleomargarine
 oleander
 olefin
 oleomargarine
-olfactory
 Olga
 oligarchic
 oligarchy
 Olga
 oligarchic
 oligarchy
@@ -15412,7 +15664,6 @@ Olympia
 Olympic
 Omaha
 Oman
 Olympic
 Omaha
 Oman
-ombudsman
 omega
 omelet
 omen
 omega
 omelet
 omen
@@ -15438,9 +15689,9 @@ onetime
 oneupmanship
 ongoing
 onion
 oneupmanship
 ongoing
 onion
-onlook
+onlooker
+onlooking
 only
 only
-onomatopoeic
 Onondaga
 onrush
 onrushing
 Onondaga
 onrush
 onrushing
@@ -15501,6 +15752,7 @@ optimum
 option
 optoacoustic
 optoisolate
 option
 optoacoustic
 optoisolate
+optometric
 optometrist
 optometry
 opulent
 optometrist
 optometry
 opulent
@@ -15687,6 +15939,7 @@ Pablo
 Pabst
 pace
 pacemake
 Pabst
 pace
 pacemake
+pacesetting
 pacific
 pacifism
 pacifist
 pacific
 pacifism
 pacifist
@@ -15697,6 +15950,7 @@ Packard
 packet
 pact
 pad
 packet
 pact
 pad
+padding
 paddle
 paddock
 paddy
 paddle
 paddock
 paddy
@@ -15713,6 +15967,7 @@ paid
 pail
 pain
 Paine
 pail
 pain
 Paine
+painful
 painstaking
 paint
 paintbrush
 painstaking
 paint
 paintbrush
@@ -15762,7 +16017,6 @@ panacea
 panama
 pancake
 Pancho
 panama
 pancake
 Pancho
-pancreatic
 panda
 Pandanus
 pandemic
 panda
 Pandanus
 pandemic
@@ -15777,6 +16031,7 @@ panicked
 panicky
 panicle
 panjandrum
 panicky
 panicle
 panjandrum
+panning
 panoply
 panorama
 panoramic
 panoply
 panorama
 panoramic
@@ -15822,6 +16077,7 @@ paradox
 paradoxic
 paraffin
 paragon
 paradoxic
 paraffin
 paragon
+paragonite
 paragraph
 Paraguay
 parakeet
 paragraph
 Paraguay
 parakeet
@@ -15833,6 +16089,7 @@ paralysis
 paramagnet
 paramagnetic
 parameter
 paramagnet
 paramagnetic
 parameter
+parametric
 paramilitary
 paramount
 Paramus
 paramilitary
 paramount
 Paramus
@@ -16001,6 +16258,7 @@ Patsy
 pattern
 Patterson
 Patti
 pattern
 Patterson
 Patti
+patting
 Patton
 patty
 paucity
 Patton
 patty
 paucity
@@ -16039,6 +16297,7 @@ pea
 Peabody
 peace
 peaceable
 Peabody
 peace
 peaceable
+peaceful
 peacemake
 peacetime
 peach
 peacemake
 peacetime
 peach
@@ -16135,6 +16394,7 @@ penmen
 Penn
 penna
 pennant
 Penn
 penna
 pennant
+penning
 Pennsylvania
 penny
 pennyroyal
 Pennsylvania
 penny
 pennyroyal
@@ -16161,6 +16421,7 @@ peppergrass
 peppermint
 pepperoni
 peppery
 peppermint
 pepperoni
 peppery
+pepping
 peppy
 Pepsi
 PepsiCo
 peppy
 Pepsi
 PepsiCo
@@ -16203,6 +16464,7 @@ Pergamon
 perhaps
 Periclean
 Pericles
 perhaps
 Periclean
 Pericles
+peridotite
 perihelion
 peril
 Perilla
 perihelion
 peril
 Perilla
@@ -16323,6 +16585,7 @@ petrol
 petroleum
 petrology
 petticoat
 petroleum
 petrology
 petticoat
+petting
 petty
 petulant
 petunia
 petty
 petulant
 petunia
@@ -16402,6 +16665,8 @@ photogenic
 photography
 photolysis
 photolytic
 photography
 photolysis
 photolytic
+photometric
+photometry
 photon
 phrase
 phrasemake
 photon
 phrase
 phrasemake
@@ -16484,6 +16749,7 @@ pigtail
 pike
 Pilate
 pile
 pike
 Pilate
 pile
+pilewort
 pilfer
 pilferage
 pilgrim
 pilfer
 pilferage
 pilgrim
@@ -16514,6 +16780,7 @@ pinkie
 pinkish
 pinnacle
 pinnate
 pinkish
 pinnacle
 pinnate
+pinning
 pinochle
 pinpoint
 pinscher
 pinochle
 pinpoint
 pinscher
@@ -16556,10 +16823,12 @@ pitfall
 pith
 pithy
 pitiable
 pith
 pithy
 pitiable
+pitiful
 pitilessly
 pitman
 Pitney
 Pitt
 pitilessly
 pitman
 Pitney
 Pitt
+pitting
 Pittsburgh
 Pittsfield
 Pittston
 Pittsburgh
 Pittsfield
 Pittston
@@ -16605,6 +16874,7 @@ planetesimal
 planetoid
 plank
 plankton
 planetoid
 plank
 plankton
+planning
 planoconcave
 planoconvex
 plant
 planoconcave
 planoconvex
 plant
@@ -16634,11 +16904,13 @@ Platonism
 Platonist
 platoon
 Platte
 Platonist
 platoon
 Platte
+platting
 plausible
 play
 playa
 playback
 playboy
 plausible
 play
 playa
 playback
 playboy
+playful
 playground
 playhouse
 playmate
 playground
 playhouse
 playmate
@@ -16662,6 +16934,7 @@ Pleistocene
 plenary
 plenipotentiary
 plenitude
 plenary
 plenipotentiary
 plenitude
+plentiful
 plenty
 plenum
 plethora
 plenty
 plenum
 plethora
@@ -16676,15 +16949,18 @@ plight
 Pliny
 Pliocene
 plod
 Pliny
 Pliocene
 plod
+plodding
 plop
 plop
+plopping
 plot
 plot
+plotting
 plover
 plover
+plow
 plowman
 plowshare
 pluck
 plucky
 plug
 plowman
 plowshare
 pluck
 plucky
 plug
-plugboard
 pluggable
 plugging
 plum
 pluggable
 plugging
 plum
@@ -16716,6 +16992,7 @@ Po
 poach
 pocket
 pocketbook
 poach
 pocket
 pocketbook
+pocketful
 Pocono
 pod
 podge
 Pocono
 pod
 podge
@@ -16744,6 +17021,7 @@ pol
 Poland
 polar
 polarimeter
 Poland
 polar
 polarimeter
+polarimetry
 Polaris
 polariscope
 polariton
 Polaris
 polariscope
 polariton
@@ -16822,6 +17100,7 @@ pond
 ponder
 ponderous
 pong
 ponder
 ponderous
 pong
+pont
 Pontiac
 pontiff
 pontific
 Pontiac
 pontiff
 pontific
@@ -16839,6 +17118,7 @@ pope
 popish
 poplar
 poplin
 popish
 poplar
 poplin
+popping
 poppy
 populace
 popular
 poppy
 populace
 popular
@@ -16879,7 +17159,6 @@ Portsmouth
 Portugal
 Portuguese
 portulaca
 Portugal
 Portuguese
 portulaca
-posable
 pose
 Poseidon
 poseur
 pose
 Poseidon
 poseur
@@ -16945,6 +17224,7 @@ potlatch
 Potomac
 potpourri
 pottery
 Potomac
 potpourri
 pottery
+potting
 Potts
 pouch
 Poughkeepsie
 Potts
 pouch
 Poughkeepsie
@@ -16961,7 +17241,7 @@ powderpuff
 powdery
 Powell
 power
 powdery
 Powell
 power
-powerhouse
+powerful
 Powers
 Poynting
 ppm
 Powers
 Poynting
 ppm
@@ -16986,6 +17266,7 @@ Pratt
 Pravda
 pray
 prayer
 Pravda
 pray
 prayer
+prayerful
 preach
 preachy
 preamble
 preach
 preachy
 preamble
@@ -17004,7 +17285,6 @@ precipice
 precipitable
 precipitate
 precipitous
 precipitable
 precipitate
 precipitous
-precis
 precise
 precision
 preclude
 precise
 precision
 preclude
@@ -17065,11 +17345,11 @@ preponderant
 preponderate
 preposition
 preposterous
 preponderate
 preposition
 preposterous
+prepping
 prerequisite
 prerogative
 presage
 Presbyterian
 prerequisite
 prerogative
 presage
 Presbyterian
-presbytery
 Prescott
 prescribe
 prescript
 Prescott
 prescribe
 prescript
@@ -17161,6 +17441,7 @@ privet
 privilege
 privy
 prize
 privilege
 privy
 prize
+prizewinning
 pro
 probabilist
 probate
 pro
 probabilist
 probate
@@ -17187,6 +17468,7 @@ proctor
 procure
 Procyon
 prod
 procure
 Procyon
 prod
+prodding
 prodigal
 prodigious
 prodigy
 prodigal
 prodigious
 prodigy
@@ -17238,7 +17520,6 @@ prologue
 prolong
 prolongate
 prolusion
 prolong
 prolongate
 prolusion
-prom
 promenade
 Promethean
 Prometheus
 promenade
 Promethean
 Prometheus
@@ -17287,6 +17568,7 @@ propos
 proposal
 propose
 proposition
 proposal
 propose
 proposition
+propping
 proprietary
 proprietor
 propriety
 proprietary
 proprietor
 propriety
@@ -17397,6 +17679,7 @@ psychoanalyst
 psychoanalytic
 psychobiology
 psychology
 psychoanalytic
 psychobiology
 psychology
+psychometric
 psychometry
 psychopath
 psychopathic
 psychometry
 psychopath
 psychopathic
@@ -17475,6 +17758,7 @@ punish
 punitive
 punk
 punky
 punitive
 punk
 punky
+punning
 punster
 punt
 puny
 punster
 punt
 puny
@@ -17504,6 +17788,7 @@ purloin
 purple
 purport
 purpose
 purple
 purport
 purpose
+purposeful
 purposive
 purr
 purse
 purposive
 purr
 purse
@@ -17546,9 +17831,11 @@ pyroelectric
 pyrolyse
 pyrolysis
 pyrometer
 pyrolyse
 pyrolysis
 pyrometer
+pyrometry
 pyrophosphate
 pyrotechnic
 pyroxene
 pyrophosphate
 pyrotechnic
 pyroxene
+pyroxenite
 Pythagoras
 Pythagorean
 python
 Pythagoras
 Pythagorean
 python
@@ -17609,14 +17896,11 @@ quartet
 quartic
 quartile
 quartz
 quartic
 quartile
 quartz
+quartzite
 quasar
 quash
 quasi
 quasar
 quash
 quasi
-quasicontinuous
-quasiorder
 quasiparticle
 quasiparticle
-quasiperiodic
-quasistationary
 quaternary
 quatrain
 quaver
 quaternary
 quatrain
 quaver
@@ -17643,11 +17927,11 @@ quicklime
 quicksand
 quicksilver
 quickstep
 quicksand
 quicksilver
 quickstep
-quid
 quiescent
 quiet
 quietus
 quill
 quiescent
 quiet
 quietus
 quill
+quillwort
 quilt
 quince
 quinine
 quilt
 quince
 quinine
@@ -17721,6 +18005,8 @@ radiochemistry
 radiography
 radiology
 radiometer
 radiography
 radiology
 radiometer
+radiometric
+radiometry
 radiophysics
 radiosonde
 radiosterilize
 radiophysics
 radiosonde
 radiosterilize
@@ -17770,6 +18056,7 @@ Ramada
 Raman
 ramble
 ramify
 Raman
 ramble
 ramify
+ramming
 Ramo
 ramp
 rampage
 Ramo
 ramp
 rampage
@@ -17806,6 +18093,7 @@ rape
 Raphael
 rapid
 rapier
 Raphael
 rapid
 rapier
+rapping
 rapport
 rapprochement
 rapt
 rapport
 rapprochement
 rapt
@@ -17813,6 +18101,7 @@ rapture
 rare
 rarefy
 Raritan
 rare
 rarefy
 Raritan
+rarity
 rasa
 rascal
 rash
 rasa
 rascal
 rash
@@ -17974,10 +18263,8 @@ reel
 Reese
 reeve
 Reeves
 Reese
 reeve
 Reeves
-refection
 refectory
 refer
 refectory
 refer
-referable
 referee
 refereeing
 referenda
 referee
 refereeing
 referenda
@@ -18026,8 +18313,8 @@ registration
 registry
 regress
 regression
 registry
 regress
 regression
-regressive
 regret
 regret
+regretful
 regrettable
 regretted
 regretting
 regrettable
 regretted
 regretting
@@ -18035,7 +18322,6 @@ regular
 regulate
 regulatory
 Regulus
 regulate
 regulatory
 Regulus
-regurgitate
 rehabilitate
 rehearsal
 rehearse
 rehabilitate
 rehearsal
 rehearse
@@ -18094,6 +18380,7 @@ remitting
 remnant
 remonstrate
 remorse
 remnant
 remonstrate
 remorse
+remorseful
 remote
 removal
 remunerate
 remote
 removal
 remunerate
@@ -18173,6 +18460,7 @@ rescue
 resemblant
 resemble
 resent
 resemblant
 resemble
 resent
+resentful
 reserpine
 reservation
 reserve
 reserpine
 reservation
 reserve
@@ -18202,7 +18490,9 @@ resonant
 resonate
 resorcinol
 resort
 resonate
 resorcinol
 resort
+resourceful
 respect
 respect
+respectful
 respiration
 respirator
 respiratory
 respiration
 respirator
 respiratory
@@ -18217,6 +18507,7 @@ responsive
 rest
 restaurant
 restaurateur
 rest
 restaurant
 restaurateur
+restful
 restitution
 restive
 restoration
 restitution
 restive
 restoration
@@ -18259,7 +18550,6 @@ retrieval
 retrieve
 retroactive
 retrofit
 retrieve
 retroactive
 retrofit
-retrofitted
 retrofitting
 retrograde
 retrogress
 retrofitting
 retrograde
 retrogress
@@ -18337,6 +18627,8 @@ Rhodes
 Rhodesia
 rhodium
 rhododendron
 Rhodesia
 rhodium
 rhododendron
+rhodolite
+rhodonite
 rhombi
 rhombic
 rhombus
 rhombi
 rhombic
 rhombus
@@ -18346,6 +18638,7 @@ rhythm
 rhythmic
 rib
 ribald
 rhythmic
 rib
 ribald
+ribbing
 ribbon
 riboflavin
 ribonucleic
 ribbon
 riboflavin
 ribonucleic
@@ -18368,6 +18661,7 @@ ricochet
 rid
 riddance
 ridden
 rid
 riddance
 ridden
+ridding
 riddle
 ride
 ridge
 riddle
 ride
 ridge
@@ -18387,6 +18681,7 @@ rigging
 Riggs
 right
 righteous
 Riggs
 right
 righteous
+rightful
 rightmost
 rightward
 rigid
 rightmost
 rightward
 rigid
@@ -18396,6 +18691,7 @@ rill
 rilly
 rim
 rime
 rilly
 rim
 rime
+rimming
 rimy
 Rinehart
 ring
 rimy
 Rinehart
 ring
@@ -18413,6 +18709,7 @@ ripe
 ripen
 Ripley
 ripoff
 ripen
 Ripley
 ripoff
+ripping
 ripple
 rise
 risen
 ripple
 rise
 risen
@@ -18450,6 +18747,7 @@ roast
 rob
 robbery
 robbin
 rob
 robbery
 robbin
+robbing
 Robbins
 robe
 Robert
 Robbins
 robe
 Robert
@@ -18517,6 +18815,7 @@ rook
 rookie
 rooky
 room
 rookie
 rooky
 room
+roomful
 roommate
 roomy
 Roosevelt
 roommate
 roomy
 Roosevelt
@@ -18553,6 +18852,7 @@ rotogravure
 rotor
 rototill
 rotten
 rotor
 rototill
 rotten
+rotting
 rotund
 rotunda
 rouge
 rotund
 rotunda
 rouge
@@ -18594,6 +18894,7 @@ RSVP
 Ruanda
 rub
 rubbery
 Ruanda
 rub
 rubbery
+rubbing
 rubbish
 rubble
 rubdown
 rubbish
 rubble
 rubdown
@@ -18614,6 +18915,7 @@ Rudolph
 Rudy
 Rudyard
 rue
 Rudy
 Rudyard
 rue
+rueful
 ruffian
 ruffle
 rufous
 ruffian
 ruffle
 rufous
@@ -18642,6 +18944,7 @@ rung
 Runge
 runic
 runneth
 Runge
 runic
 runneth
+running
 Runnymede
 runoff
 runt
 Runnymede
 runoff
 runt
@@ -18676,6 +18979,7 @@ ruthless
 rutile
 Rutland
 Rutledge
 rutile
 Rutland
 Rutledge
+rutting
 rutty
 Rwanda
 Ryan
 rutty
 Rwanda
 Ryan
@@ -18859,6 +19163,7 @@ sapient
 sapling
 saponify
 sapphire
 sapling
 saponify
 sapphire
+sapping
 sappy
 sapsucker
 Sara
 sappy
 sapsucker
 Sara
@@ -18956,6 +19261,7 @@ scandal
 scandalous
 Scandinavia
 scandium
 scandalous
 Scandinavia
 scandium
+scanning
 scant
 scanty
 scapegoat
 scant
 scanty
 scapegoat
@@ -18977,6 +19283,7 @@ scat
 scathe
 scatterbrain
 scattergun
 scathe
 scatterbrain
 scattergun
+scatting
 scaup
 scavenge
 scenario
 scaup
 scavenge
 scenario
@@ -18989,6 +19296,7 @@ Schaefer
 Schafer
 Schantz
 schedule
 Schafer
 Schantz
 schedule
+schelling
 schema
 schemata
 schematic
 schema
 schemata
 schematic
@@ -19066,6 +19374,7 @@ scoreboard
 scorecard
 scoria
 scorn
 scorecard
 scoria
 scorn
+scornful
 Scorpio
 scorpion
 Scot
 Scorpio
 scorpion
 Scot
@@ -19087,10 +19396,12 @@ scrabble
 scraggly
 scram
 scramble
 scraggly
 scram
 scramble
+scramming
 Scranton
 scrap
 scrapbook
 scrape
 Scranton
 scrap
 scrapbook
 scrape
+scrapping
 scratch
 scratchy
 scrawl
 scratch
 scratchy
 scrawl
@@ -19121,6 +19432,7 @@ scroll
 scrooge
 scrounge
 scrub
 scrooge
 scrounge
 scrub
+scrubbing
 scrumptious
 scruple
 scrupulosity
 scrumptious
 scruple
 scrupulosity
@@ -19129,6 +19441,7 @@ scrutable
 scrutiny
 scuba
 scud
 scrutiny
 scuba
 scud
+scudding
 scuff
 scuffle
 scull
 scuff
 scuffle
 scull
@@ -19160,7 +19473,6 @@ sealant
 seam
 seaman
 seamen
 seam
 seaman
 seamen
-seamstress
 seamy
 Sean
 seance
 seamy
 Sean
 seance
@@ -19201,7 +19513,6 @@ sect
 sectarian
 section
 sector
 sectarian
 section
 sector
-sectoral
 secular
 secure
 sedan
 secular
 secure
 sedan
@@ -19276,6 +19587,7 @@ seminar
 seminarian
 seminary
 Seminole
 seminarian
 seminary
 Seminole
+Semiramis
 Semite
 Semitic
 semper
 Semite
 Semitic
 semper
@@ -19336,7 +19648,6 @@ serape
 seraphim
 serenade
 serendipitous
 seraphim
 serenade
 serendipitous
-serendipity
 serene
 serge
 sergeant
 serene
 serge
 sergeant
@@ -19371,6 +19682,7 @@ setback
 Seth
 Seton
 setscrew
 Seth
 Seton
 setscrew
+setting
 settle
 setup
 seven
 settle
 setup
 seven
@@ -19439,6 +19751,7 @@ sham
 shamble
 shame
 shameface
 shamble
 shame
 shameface
+shameful
 shampoo
 shamrock
 shan't
 shampoo
 shamrock
 shan't
@@ -19481,6 +19794,7 @@ sheath
 sheathe
 sheave
 shed
 sheathe
 sheave
 shed
+shedding
 Shedir
 Sheehan
 sheen
 Shedir
 Sheehan
 sheen
@@ -19523,6 +19837,7 @@ shifty
 shill
 Shiloh
 shim
 shill
 Shiloh
 shim
+shimming
 shimmy
 shin
 shinbone
 shimmy
 shin
 shinbone
@@ -19533,11 +19848,13 @@ shiny
 ship
 shipboard
 shipbuild
 ship
 shipboard
 shipbuild
+shipbuilding
 shiplap
 Shipley
 shipman
 shipmate
 shipmen
 shiplap
 Shipley
 shipman
 shipmate
 shipmen
+shipping
 shipshape
 shipwreck
 shipyard
 shipshape
 shipwreck
 shipyard
@@ -19569,6 +19886,7 @@ shook
 shoot
 shop
 shopkeep
 shoot
 shop
 shopkeep
+shopping
 shopworn
 shore
 shoreline
 shopworn
 shore
 shoreline
@@ -19605,6 +19923,7 @@ showy
 shrank
 shrapnel
 shred
 shrank
 shrapnel
 shred
+shredding
 Shreveport
 shrew
 shrewd
 Shreveport
 shrew
 shrewd
@@ -19636,11 +19955,13 @@ shuffle
 shuffleboard
 Shulman
 shun
 shuffleboard
 Shulman
 shun
+shunning
 shunt
 shut
 shutdown
 shutoff
 shutout
 shunt
 shut
 shutdown
 shutoff
 shutout
+shutting
 shuttle
 shuttlecock
 shy
 shuttle
 shuttlecock
 shy
@@ -19662,6 +19983,7 @@ sick
 sicken
 sickish
 sickle
 sicken
 sickish
 sickle
+sicklewort
 sickroom
 side
 sidearm
 sickroom
 side
 sidearm
@@ -19674,9 +19996,11 @@ sidelong
 sideman
 sidemen
 sidereal
 sideman
 sidemen
 sidereal
+siderite
 sidesaddle
 sideshow
 sidestep
 sidesaddle
 sideshow
 sidestep
+sidestepping
 sidetrack
 sidewalk
 sidewall
 sidetrack
 sidewalk
 sidewall
@@ -19775,6 +20099,7 @@ Sinclair
 sine
 sinew
 sinewy
 sine
 sinew
 sinewy
+sinful
 sing
 singable
 Singapore
 sing
 singable
 Singapore
@@ -19790,6 +20115,7 @@ sinister
 sinistral
 sink
 sinkhole
 sinistral
 sink
 sinkhole
+sinning
 sinter
 sinuous
 sinus
 sinter
 sinuous
 sinus
@@ -19797,6 +20123,7 @@ sinusoid
 sinusoidal
 Sioux
 sip
 sinusoidal
 Sioux
 sip
+sipping
 sir
 sire
 siren
 sir
 sire
 siren
@@ -19810,6 +20137,7 @@ Sisyphean
 Sisyphus
 sit
 site
 Sisyphus
 sit
 site
+sitting
 situ
 situate
 situs
 situ
 situate
 situs
@@ -19838,19 +20166,24 @@ sketchy
 skew
 ski
 skid
 skew
 ski
 skid
+skidding
 skiddy
 skied
 skiff
 skill
 skillet
 skiddy
 skied
 skiff
 skill
 skillet
+skillful
 skim
 skim
+skimming
 skimp
 skimpy
 skin
 skindive
 skimp
 skimpy
 skin
 skindive
+skinning
 skinny
 skip
 skipjack
 skinny
 skip
 skipjack
+skipping
 Skippy
 skirmish
 skirt
 Skippy
 skirmish
 skirt
@@ -19881,16 +20214,19 @@ slag
 slain
 slake
 slam
 slain
 slake
 slam
+slamming
 slander
 slanderous
 slang
 slant
 slap
 slander
 slanderous
 slang
 slant
 slap
+slapping
 slapstick
 slash
 slat
 slate
 slater
 slapstick
 slash
 slat
 slate
 slater
+slatting
 slaughter
 slaughterhouse
 Slav
 slaughter
 slaughterhouse
 Slav
@@ -19900,6 +20236,7 @@ Slavic
 slavish
 slay
 sled
 slavish
 slay
 sled
+sledding
 sledge
 sledgehammer
 sleek
 sledge
 sledgehammer
 sleek
@@ -19928,8 +20265,10 @@ slingshot
 slip
 slippage
 slippery
 slip
 slippage
 slippery
+slipping
 slit
 slither
 slit
 slither
+slitting
 sliver
 slivery
 Sloan
 sliver
 slivery
 Sloan
@@ -19944,10 +20283,12 @@ slogging
 sloop
 slop
 slope
 sloop
 slop
 slope
+slopping
 sloppy
 slosh
 slot
 sloth
 sloppy
 slosh
 slot
 sloth
+slothful
 slouch
 slough
 sloven
 slouch
 slough
 sloven
@@ -19960,10 +20301,12 @@ sluggish
 sluice
 slum
 slumber
 sluice
 slum
 slumber
+slumming
 slump
 slung
 slur
 slurp
 slump
 slung
 slur
 slurp
+slurring
 slurry
 sly
 smack
 slurry
 sly
 smack
@@ -19975,7 +20318,7 @@ smallpox
 smalltime
 smart
 smash
 smalltime
 smart
 smash
-smatter
+smattering
 smear
 smell
 smelt
 smear
 smell
 smelt
@@ -20020,6 +20363,7 @@ snakeroot
 snap
 snapback
 snapdragon
 snap
 snapback
 snapdragon
+snapping
 snappish
 snappy
 snapshot
 snappish
 snappy
 snapshot
@@ -20063,6 +20407,7 @@ snowflake
 snowstorm
 snowy
 snub
 snowstorm
 snowy
 snub
+snubbing
 snuff
 snuffer
 snuffle
 snuff
 snuffer
 snuffle
@@ -20080,6 +20425,7 @@ soapsud
 soapy
 soar
 sob
 soapy
 soar
 sob
+sobbing
 sober
 sobriety
 sobriquet
 sober
 sobriety
 sobriquet
@@ -20091,6 +20437,7 @@ Societe
 society
 socioeconomic
 sociology
 society
 socioeconomic
 sociology
+sociometric
 sociometry
 sock
 socket
 sociometry
 sock
 socket
@@ -20100,6 +20447,7 @@ Socratic
 sod
 soda
 sodden
 sod
 soda
 sodden
+sodding
 sodium
 sofa
 soffit
 sodium
 sofa
 soffit
@@ -20134,7 +20482,6 @@ solicitude
 solid
 solidarity
 solidify
 solid
 solidarity
 solidify
-solidus
 soliloquy
 solipsism
 solitary
 soliloquy
 solipsism
 solitary
@@ -20180,6 +20527,7 @@ sonata
 song
 songbag
 songbook
 song
 songbag
 songbook
+songful
 sonic
 sonnet
 sonny
 sonic
 sonnet
 sonny
@@ -20204,6 +20552,7 @@ Sophoclean
 Sophocles
 sophomore
 sophomoric
 Sophocles
 sophomore
 sophomoric
+sopping
 soprano
 sora
 sorb
 soprano
 sora
 sorb
@@ -20217,6 +20566,7 @@ sorority
 sorption
 sorrel
 sorrow
 sorption
 sorrel
 sorrow
+sorrowful
 sorry
 sort
 sortie
 sorry
 sort
 sortie
@@ -20224,6 +20574,7 @@ sou
 souffle
 sought
 soul
 souffle
 sought
 soul
+soulful
 sound
 soundproof
 soup
 sound
 soundproof
 soup
@@ -20266,12 +20617,14 @@ spacious
 spade
 spaghetti
 Spain
 spade
 spaghetti
 Spain
+spalding
 span
 spandrel
 spangle
 Spaniard
 spaniel
 Spanish
 span
 spandrel
 spangle
 Spaniard
 spaniel
 Spanish
+spanning
 spar
 spare
 sparge
 spar
 spare
 sparge
@@ -20280,6 +20633,7 @@ sparkle
 Sparkman
 sparky
 sparling
 Sparkman
 sparky
 sparling
+sparring
 sparrow
 sparse
 Sparta
 sparrow
 sparse
 Sparta
@@ -20322,7 +20676,11 @@ spectrogram
 spectrograph
 spectrography
 spectrometer
 spectrograph
 spectrography
 spectrometer
+spectrometric
+spectrometry
 spectrophotometer
 spectrophotometer
+spectrophotometric
+spectrophotometry
 spectroscope
 spectroscopic
 spectroscopy
 spectroscope
 spectroscopic
 spectroscopy
@@ -20348,6 +20706,7 @@ spermatophyte
 Sperry
 spew
 sphagnum
 Sperry
 spew
 sphagnum
+sphalerite
 sphere
 spheric
 spheroid
 sphere
 spheric
 spheroid
@@ -20359,6 +20718,7 @@ spice
 spicebush
 spicy
 spider
 spicebush
 spicy
 spider
+spiderwort
 spidery
 Spiegel
 spigot
 spidery
 Spiegel
 spigot
@@ -20374,6 +20734,7 @@ spindle
 spine
 spinnaker
 spinneret
 spine
 spinnaker
 spinneret
+spinning
 spinodal
 spinoff
 spinster
 spinodal
 spinoff
 spinster
@@ -20385,7 +20746,9 @@ spiritual
 Spiro
 spit
 spite
 Spiro
 spit
 spite
+spiteful
 spitfire
 spitfire
+spitting
 spittle
 spitz
 splash
 spittle
 spitz
 splash
@@ -20394,6 +20757,7 @@ splat
 splay
 splayed
 spleen
 splay
 splayed
 spleen
+spleenwort
 splendid
 splenetic
 splice
 splendid
 splenetic
 splice
@@ -20401,6 +20765,7 @@ spline
 splint
 splintery
 split
 splint
 splintery
 split
+splitting
 splotch
 splotchy
 splurge
 splotch
 splotchy
 splurge
@@ -20412,7 +20777,6 @@ spoke
 spoken
 spokesman
 spokesmen
 spoken
 spokesman
 spokesmen
-spokesperson
 sponge
 spongy
 sponsor
 sponge
 spongy
 sponsor
@@ -20423,17 +20787,19 @@ spook
 spooky
 spool
 spoon
 spooky
 spool
 spoon
+spoonful
 sporadic
 spore
 sport
 sportsman
 sportsmen
 sportswear
 sporadic
 spore
 sport
 sportsman
 sportsmen
 sportswear
-sportswrite
+sportswriter
 sportswriting
 sporty
 spot
 spotlight
 sportswriting
 sporty
 spot
 spotlight
+spotting
 spotty
 spouse
 spout
 spotty
 spouse
 spout
@@ -20471,6 +20837,7 @@ spur
 spurge
 spurious
 spurn
 spurge
 spurious
 spurn
+spurring
 spurt
 sputnik
 sputter
 spurt
 sputnik
 sputter
@@ -20516,6 +20883,7 @@ SST
 St
 St.
 stab
 St
 St.
 stab
+stabbing
 stabile
 stable
 stableman
 stabile
 stable
 stableman
@@ -20595,6 +20963,7 @@ starlet
 starlight
 starling
 Starr
 starlight
 starling
 Starr
+starring
 start
 startle
 startup
 start
 startle
 startup
@@ -20661,6 +21030,7 @@ Steiner
 stella
 stellar
 stem
 stella
 stellar
 stem
+stemming
 stench
 stencil
 stenographer
 stench
 stencil
 stenographer
@@ -20675,6 +21045,7 @@ Stephens
 Stephenson
 stepmother
 steppe
 Stephenson
 stepmother
 steppe
+stepping
 steprelation
 stepson
 stepwise
 steprelation
 stepson
 stepwise
@@ -20734,6 +21105,7 @@ stipple
 stipulate
 stir
 Stirling
 stipulate
 stir
 Stirling
+stirring
 stirrup
 stitch
 stochastic
 stirrup
 stitch
 stochastic
@@ -20748,6 +21120,7 @@ Stockton
 stocky
 stodgy
 stoic
 stocky
 stodgy
 stoic
+stoichiometric
 stoichiometry
 stoke
 Stokes
 stoichiometry
 stoke
 Stokes
@@ -20761,6 +21134,7 @@ stonecrop
 Stonehenge
 stonewall
 stoneware
 Stonehenge
 stonewall
 stoneware
+stonewort
 stony
 stood
 stooge
 stony
 stood
 stooge
@@ -20772,6 +21146,7 @@ stopcock
 stopgap
 stopover
 stoppage
 stopgap
 stopover
 stoppage
+stopping
 stopwatch
 storage
 store
 stopwatch
 storage
 store
@@ -20807,6 +21182,7 @@ strange
 strangle
 strangulate
 strap
 strangle
 strangulate
 strap
+strapping
 strata
 stratagem
 strategic
 strata
 stratagem
 strategic
@@ -20834,6 +21210,7 @@ strengthen
 strenuous
 streptococcus
 stress
 strenuous
 streptococcus
 stress
+stressful
 stretch
 strewn
 striate
 stretch
 strewn
 striate
@@ -20842,7 +21219,6 @@ Strickland
 strict
 stricture
 stride
 strict
 stricture
 stride
-strident
 strife
 strike
 strikebreak
 strife
 strike
 strikebreak
@@ -20851,6 +21227,7 @@ stringent
 stringy
 strip
 stripe
 stringy
 strip
 stripe
+stripping
 striptease
 strive
 striven
 striptease
 strive
 striven
@@ -20867,23 +21244,28 @@ strongroom
 strontium
 strop
 strophe
 strontium
 strop
 strophe
+stropping
 strove
 struck
 structural
 structure
 struggle
 strum
 strove
 struck
 structural
 structure
 struggle
 strum
+strumming
 strung
 strut
 strung
 strut
+strutting
 strychnine
 Stuart
 stub
 strychnine
 Stuart
 stub
+stubbing
 stubble
 stubborn
 stubby
 stucco
 stuck
 stud
 stubble
 stubborn
 stubby
 stucco
 stuck
 stud
+studding
 Studebaker
 student
 studio
 Studebaker
 student
 studio
@@ -20899,6 +21281,7 @@ stumpy
 stun
 stung
 stunk
 stun
 stung
 stunk
+stunning
 stunt
 stupefy
 stupendous
 stunt
 stupefy
 stupendous
@@ -20923,6 +21306,7 @@ Styrofoam
 Styx
 suave
 sub
 Styx
 suave
 sub
+subbing
 subject
 subjectivity
 sublimate
 subject
 subjectivity
 sublimate
@@ -20962,6 +21346,7 @@ subversive
 subvert
 succeed
 success
 subvert
 succeed
 success
+successful
 succession
 successive
 successor
 succession
 successive
 successor
@@ -21026,6 +21411,7 @@ summary
 summate
 Summers
 summertime
 summate
 Summers
 summertime
+summing
 summit
 summitry
 summon
 summit
 summitry
 summon
@@ -21050,6 +21436,7 @@ sunk
 sunken
 sunlight
 sunlit
 sunken
 sunlight
 sunlit
+sunning
 sunny
 Sunnyvale
 sunrise
 sunny
 Sunnyvale
 sunrise
@@ -21060,6 +21447,7 @@ sunshiny
 sunspot
 suntan
 suntanned
 sunspot
 suntan
 suntanned
+suntanning
 SUNY
 sup
 super
 SUNY
 sup
 super
@@ -21082,6 +21470,7 @@ superstitious
 supervene
 supervisory
 supine
 supervene
 supervisory
 supine
+supping
 supplant
 supple
 supplementary
 supplant
 supple
 supplementary
@@ -21156,9 +21545,9 @@ suzerainty
 Suzuki
 svelte
 swab
 Suzuki
 svelte
 swab
+swabbing
 swabby
 swag
 swabby
 swag
-swage
 Swahili
 swain
 swallow
 Swahili
 swain
 swallow
@@ -21173,6 +21562,7 @@ swanky
 swanlike
 Swanson
 swap
 swanlike
 Swanson
 swap
+swapping
 swarm
 swart
 Swarthmore
 swarm
 swart
 Swarthmore
@@ -21183,6 +21573,7 @@ swat
 swatch
 swath
 swathe
 swatch
 swath
 swathe
+swatting
 sway
 Swaziland
 swear
 sway
 Swaziland
 swear
@@ -21198,7 +21589,6 @@ Sweeney
 sweep
 sweepstake
 sweet
 sweep
 sweepstake
 sweet
-sweeten
 sweetheart
 sweetish
 swell
 sweetheart
 sweetish
 swell
@@ -21211,6 +21601,7 @@ swift
 swig
 swigging
 swim
 swig
 swigging
 swim
+swimming
 swimsuit
 swindle
 swine
 swimsuit
 swindle
 swine
@@ -21248,6 +21639,7 @@ sycamore
 sycophant
 sycophantic
 Sydney
 sycophant
 sycophantic
 Sydney
+syenite
 Sykes
 syllabic
 syllabify
 Sykes
 syllabic
 syllabify
@@ -21259,8 +21651,10 @@ Sylvania
 Sylvester
 Sylvia
 symbiosis
 Sylvester
 Sylvia
 symbiosis
+symbiotic
 symbol
 symbolic
 symbol
 symbolic
+symmetric
 symmetry
 sympathetic
 sympathy
 symmetry
 sympathetic
 sympathy
@@ -21311,6 +21705,7 @@ systemwide
 t
 t's
 tab
 t
 t's
 tab
+tabbing
 tabernacle
 table
 tableau
 tabernacle
 table
 tableau
@@ -21318,6 +21713,7 @@ tableaux
 tablecloth
 tableland
 tablespoon
 tablecloth
 tableland
 tablespoon
+tablespoonful
 tablet
 tabloid
 taboo
 tablet
 tabloid
 taboo
@@ -21334,6 +21730,7 @@ tackle
 tacky
 Tacoma
 tact
 tacky
 Tacoma
 tact
+tactful
 tactic
 tactile
 tactual
 tactic
 tactile
 tactual
@@ -21349,7 +21746,6 @@ Tahoe
 tail
 tailgate
 tailor
 tail
 tailgate
 tailor
-tailwind
 taint
 Taipei
 Taiwan
 taint
 Taipei
 Taiwan
@@ -21357,7 +21753,6 @@ take
 taken
 takeoff
 takeover
 taken
 takeoff
 takeover
-taketh
 talc
 talcum
 tale
 talc
 talcum
 tale
@@ -21402,6 +21797,7 @@ tangy
 tanh
 tank
 tannin
 tanh
 tank
 tannin
+tanning
 tansy
 tantalum
 Tantalus
 tansy
 tantalum
 Tantalus
@@ -21422,6 +21818,7 @@ tapir
 tapis
 tappa
 tappet
 tapis
 tappa
 tappet
+tapping
 tar
 tara
 tarantara
 tar
 tara
 tarantara
@@ -21434,6 +21831,7 @@ tarnish
 tarpaper
 tarpaulin
 tarpon
 tarpaper
 tarpaulin
 tarpon
+tarring
 tarry
 Tarrytown
 tart
 tarry
 Tarrytown
 tart
@@ -21446,11 +21844,13 @@ Tasmania
 Tass
 tassel
 taste
 Tass
 tassel
 taste
+tasteful
 tasting
 tasty
 tat
 tate
 tater
 tasting
 tasty
 tat
 tate
 tater
+tatting
 tattle
 tattler
 tattletale
 tattle
 tattler
 tattletale
@@ -21471,7 +21871,6 @@ taxation
 taxi
 taxicab
 taxied
 taxi
 taxicab
 taxied
-taxiway
 taxonomy
 taxpayer
 taxpaying
 taxonomy
 taxpayer
 taxpaying
@@ -21491,9 +21890,11 @@ teamwork
 teapot
 tear
 teardrop
 teapot
 tear
 teardrop
+tearful
 tease
 teasel
 teaspoon
 tease
 teasel
 teaspoon
+teaspoonful
 teat
 tech
 technetium
 teat
 tech
 technetium
@@ -21504,6 +21905,7 @@ technology
 tectonic
 tecum
 ted
 tectonic
 tecum
 ted
+tedding
 Teddy
 tedious
 tedium
 Teddy
 tedious
 tedium
@@ -21532,6 +21934,8 @@ telegraph
 telegraphy
 telekinesis
 telemeter
 telegraphy
 telekinesis
 telemeter
+telemetric
+telemetry
 teleology
 teleost
 telepathic
 teleology
 teleost
 telepathic
@@ -21546,6 +21950,7 @@ teleprompter
 telescope
 telescopic
 teletype
 telescope
 telescopic
 teletype
+teletypesetting
 teletypewrite
 televise
 television
 teletypewrite
 televise
 television
@@ -21680,6 +22085,7 @@ thallium
 thallophyte
 than
 thank
 thallophyte
 than
 thank
+thankful
 thanksgiving
 that
 that'd
 thanksgiving
 that
 that'd
@@ -21738,8 +22144,23 @@ thermal
 thermionic
 thermistor
 thermo
 thermionic
 thermistor
 thermo
+thermocouple
+thermodynamic
+thermoelastic
+thermoelectric
 Thermofax
 Thermofax
+thermometer
+thermometric
+thermometry
+thermomigrate
+thermonuclear
+thermopile
+thermoplastic
+thermopower
+thermosetting
+thermostable
 thermostat
 thermostat
+thermostatic
 thesaurus
 these
 theses
 thesaurus
 these
 theses
@@ -21768,6 +22189,7 @@ thin
 thine
 thing
 think
 thine
 thing
 think
+thinning
 thinnish
 thiocyanate
 thiouracil
 thinnish
 thiocyanate
 thiouracil
@@ -21805,6 +22227,7 @@ those
 thou
 though
 thought
 thou
 though
 thought
+thoughtful
 thousand
 thousandth
 thrash
 thousand
 thousandth
 thrash
@@ -21827,6 +22250,7 @@ thrive
 throat
 throaty
 throb
 throat
 throaty
 throb
+throbbing
 throes
 thrombosis
 throne
 throes
 thrombosis
 throne
@@ -21839,11 +22263,13 @@ throw
 throwback
 thrown
 thrum
 throwback
 thrown
 thrum
+thrumming
 thrush
 thrust
 Thruway
 Thuban
 thud
 thrush
 thrust
 Thruway
 Thuban
 thud
+thudding
 thug
 thuggee
 Thule
 thug
 thuggee
 Thule
@@ -21852,7 +22278,6 @@ thumb
 thumbnail
 thump
 thunder
 thumbnail
 thump
 thunder
-thunderbird
 thunderclap
 thunderflower
 thunderous
 thunderclap
 thunderflower
 thunderous
@@ -21863,7 +22288,6 @@ thus
 thwack
 thwart
 thy
 thwack
 thwart
 thy
-thyme
 thyratron
 thyroglobulin
 thyroid
 thyratron
 thyroglobulin
 thyroid
@@ -21921,7 +22345,6 @@ timid
 Timon
 timothy
 tin
 Timon
 timothy
 tin
-Tina
 tincture
 tinder
 tine
 tincture
 tinder
 tine
@@ -21930,6 +22353,7 @@ tinge
 tingle
 tinker
 tinkle
 tingle
 tinker
 tinkle
+tinning
 tinsel
 tint
 tintype
 tinsel
 tint
 tintype
@@ -21938,6 +22362,7 @@ Tioga
 tip
 tipoff
 Tipperary
 tip
 tipoff
 Tipperary
+tipping
 tipple
 tippy
 tipsy
 tipple
 tippy
 tipsy
@@ -22047,6 +22472,7 @@ topnotch
 topocentric
 topography
 topology
 topocentric
 topography
 topology
+topping
 topple
 topsoil
 Topsy
 topple
 topsoil
 Topsy
@@ -22135,7 +22561,6 @@ tragedy
 tragic
 tragicomic
 trail
 tragic
 tragicomic
 trail
-trailblaze
 trailside
 train
 trainee
 trailside
 train
 trainee
@@ -22171,7 +22596,6 @@ transduction
 transect
 transept
 transfer
 transect
 transept
 transfer
-transferable
 transferee
 transference
 transferor
 transferee
 transference
 transferor
@@ -22181,6 +22605,7 @@ transferring
 transfix
 transform
 transformation
 transfix
 transform
 transformation
+transfusable
 transfuse
 transfusion
 transgress
 transfuse
 transfusion
 transgress
@@ -22221,6 +22646,7 @@ transposable
 transpose
 transposition
 transship
 transpose
 transposition
 transship
+transshipping
 transversal
 transverse
 transvestite
 transversal
 transverse
 transvestite
@@ -22228,6 +22654,7 @@ trap
 trapezium
 trapezoid
 trapezoidal
 trapezium
 trapezoid
 trapezoidal
+trapping
 trash
 trashy
 Trastevere
 trash
 trashy
 Trastevere
@@ -22262,6 +22689,7 @@ treelike
 treetop
 trefoil
 trek
 treetop
 trefoil
 trek
+trekking
 trellis
 tremble
 tremendous
 trellis
 tremble
 tremendous
@@ -22280,7 +22708,6 @@ tress
 trestle
 Trevelyan
 triable
 trestle
 Trevelyan
 triable
-triac
 triad
 trial
 triangle
 triad
 trial
 triangle
@@ -22315,6 +22742,7 @@ trifle
 trifluouride
 trig
 trigonal
 trifluouride
 trig
 trigonal
+trigonometric
 trigonometry
 trigram
 trill
 trigonometry
 trigram
 trill
@@ -22324,6 +22752,7 @@ trilogy
 trim
 trimer
 trimester
 trim
 trimer
 trimester
+trimming
 Trinidad
 trinitarian
 trinity
 Trinidad
 trinitarian
 trinity
@@ -22342,6 +22771,7 @@ triplex
 triplicate
 tripod
 tripoli
 triplicate
 tripod
 tripoli
+tripping
 triptych
 trisodium
 Tristan
 triptych
 trisodium
 Tristan
@@ -22376,6 +22806,7 @@ tropopause
 troposphere
 tropospheric
 trot
 troposphere
 tropospheric
 trot
+trotting
 trouble
 troubleshoot
 troublesome
 trouble
 troubleshoot
 troublesome
@@ -22407,8 +22838,10 @@ trunk
 truss
 trust
 trustee
 truss
 trust
 trustee
+trustful
 trustworthy
 truth
 trustworthy
 truth
+truthful
 TRW
 try
 trypsin
 TRW
 try
 trypsin
@@ -22447,6 +22880,7 @@ tun
 tuna
 tundra
 tune
 tuna
 tundra
 tune
+tuneful
 tung
 tungstate
 tungsten
 tung
 tungstate
 tungsten
@@ -22524,6 +22958,7 @@ twin
 twine
 twinge
 twinkle
 twine
 twinge
 twinkle
+twinning
 twirl
 twirly
 twist
 twirl
 twirly
 twist
@@ -22531,6 +22966,7 @@ twisty
 twit
 twitch
 twitchy
 twit
 twitch
 twitchy
+twitting
 two
 twofold
 Twombly
 two
 twofold
 Twombly
@@ -22540,7 +22976,6 @@ Tyburn
 tycoon
 tying
 Tyler
 tycoon
 tying
 Tyler
-Tyndall
 type
 typeface
 typescript
 type
 typeface
 typescript
@@ -22584,6 +23019,16 @@ ulterior
 ultimate
 ultimatum
 ultra
 ultimate
 ultimatum
 ultra
+ultracentrifuge
+ultraconservative
+ultrafast
+ultramarine
+ultramodern
+ultrashort
+ultrasonic
+ultrasound
+ultrastructure
+ultraviolet
 Ulysses
 umber
 umbilical
 Ulysses
 umber
 umbilical
@@ -22726,6 +23171,7 @@ USC
 USC&GS
 USDA
 use
 USC&GS
 USDA
 use
+useful
 USGS
 usher
 USIA
 USGS
 usher
 USIA
@@ -22777,7 +23223,6 @@ Vail
 vain
 vainglorious
 vale
 vain
 vainglorious
 vale
-valediction
 valedictorian
 valedictory
 valent
 valedictorian
 valedictory
 valent
@@ -22879,7 +23324,6 @@ Venice
 venison
 venom
 venomous
 venison
 venom
 venomous
-venous
 vent
 ventilate
 ventricle
 vent
 ventilate
 ventricle
@@ -22956,6 +23400,7 @@ veteran
 veterinarian
 veterinary
 veto
 veterinarian
 veterinary
 veto
+vetting
 vex
 vexation
 vexatious
 vex
 vexation
 vexatious
@@ -23123,6 +23568,7 @@ Volterra
 voltmeter
 voluble
 volume
 voltmeter
 voluble
 volume
+volumetric
 voluminous
 voluntary
 volunteer
 voluminous
 voluntary
 volunteer
@@ -23190,6 +23636,7 @@ waitress
 waive
 wake
 Wakefield
 waive
 wake
 Wakefield
+wakeful
 waken
 wakerobin
 wakeup
 waken
 wakerobin
 wakeup
@@ -23262,6 +23709,7 @@ warp
 warrant
 warranty
 warren
 warrant
 warranty
 warren
+warring
 warrior
 Warsaw
 wart
 warrior
 Warsaw
 wart
@@ -23286,12 +23734,14 @@ wast
 wastage
 waste
 wastebasket
 wastage
 waste
 wastebasket
+wasteful
 wasteland
 wastewater
 wastrel
 watch
 watchband
 watchdog
 wasteland
 wastewater
 wastrel
 watch
 watchband
 watchdog
+watchful
 watchmake
 watchman
 watchmen
 watchmake
 watchman
 watchmen
@@ -23360,13 +23810,16 @@ weather
 weatherbeaten
 weatherproof
 weatherstrip
 weatherbeaten
 weatherproof
 weatherstrip
+weatherstripping
 weave
 web
 Webb
 weave
 web
 Webb
+webbing
 weber
 Webster
 WECo
 wed
 weber
 Webster
 WECo
 wed
+wedding
 wedge
 wedlock
 Wednesday
 wedge
 wedlock
 Wednesday
@@ -23427,11 +23880,13 @@ Weston
 westward
 wet
 wetland
 westward
 wet
 wetland
+wetting
 Weyerhauser
 whack
 whale
 Whalen
 wham
 Weyerhauser
 whack
 whale
 Whalen
 wham
+whamming
 wharf
 Wharton
 wharves
 wharf
 Wharton
 wharves
@@ -23476,6 +23931,7 @@ wherever
 wherewith
 whet
 whether
 wherewith
 whet
 whether
+whetting
 which
 whichever
 whiff
 which
 whichever
 whiff
@@ -23491,6 +23947,7 @@ whip
 whiplash
 Whippany
 whippet
 whiplash
 Whippany
 whippet
+whipping
 Whipple
 whipsaw
 whir
 Whipple
 whipsaw
 whir
@@ -23498,6 +23955,7 @@ whirl
 whirligig
 whirlpool
 whirlwind
 whirligig
 whirlpool
 whirlwind
+whirring
 whisk
 whisper
 whistle
 whisk
 whisper
 whistle
@@ -23519,8 +23977,8 @@ Whitman
 Whitney
 Whittaker
 Whittier
 Whitney
 Whittaker
 Whittier
-whittle
 whiz
 whiz
+whizzing
 who
 who'd
 who'll
 who
 who'd
 who'll
@@ -23536,6 +23994,7 @@ whomsoever
 whoop
 whoosh
 whop
 whoop
 whoosh
 whop
+whopping
 whore
 whose
 whosoever
 whore
 whose
 whosoever
@@ -23563,7 +24022,6 @@ Wiggins
 wiggle
 wiggly
 wigmake
 wiggle
 wiggly
 wigmake
-wigwam
 Wilbur
 Wilcox
 wild
 Wilbur
 Wilcox
 wild
@@ -23584,6 +24042,7 @@ Wilkinson
 will
 Willa
 Willard
 will
 Willa
 Willard
+willful
 William
 Williams
 Williamsburg
 William
 Williams
 Williamsburg
@@ -23636,6 +24095,7 @@ wink
 winkle
 Winnetka
 Winnie
 winkle
 Winnetka
 Winnie
+winning
 Winnipeg
 Winnipesaukee
 winnow
 Winnipeg
 Winnipesaukee
 winnow
@@ -23662,9 +24122,11 @@ wisecrack
 wisenheimer
 wish
 wishbone
 wisenheimer
 wish
 wishbone
+wishful
 wishy
 wisp
 wispy
 wishy
 wisp
 wispy
+wistful
 wit
 witch
 witchcraft
 wit
 witch
 witchcraft
@@ -23685,12 +24147,14 @@ withstood
 withy
 witness
 Witt
 withy
 witness
 Witt
+witting
 witty
 wive
 wizard
 wobble
 woe
 woebegone
 witty
 wive
 wizard
 wobble
 woe
 woebegone
+woeful
 wok
 woke
 Wolcott
 wok
 woke
 Wolcott
@@ -23708,6 +24172,7 @@ women
 won
 won't
 wonder
 won
 won't
 wonder
+wonderful
 wonderland
 wondrous
 Wong
 wonderland
 wondrous
 Wong
@@ -23749,7 +24214,6 @@ wordy
 wore
 work
 workbench
 wore
 work
 workbench
-workbook
 workday
 workhorse
 workload
 workday
 workhorse
 workload
@@ -23772,6 +24236,7 @@ worry
 worse
 worsen
 worship
 worse
 worsen
 worship
+worshipful
 worst
 worth
 Worthington
 worst
 worth
 Worthington
@@ -23788,8 +24253,10 @@ wrack
 wraith
 wrangle
 wrap
 wraith
 wrangle
 wrap
+wrapping
 wrapup
 wrath
 wrapup
 wrath
+wrathful
 wreak
 wreath
 wreathe
 wreak
 wreath
 wreathe
@@ -23813,7 +24280,9 @@ writeup
 writhe
 written
 wrong
 writhe
 written
 wrong
-wrongdo
+wrongdoer
+wrongdoing
+wrongful
 Wronskian
 wrote
 wrought
 Wronskian
 wrote
 wrought
@@ -23930,6 +24399,7 @@ your
 yourself
 yourselves
 youth
 yourself
 yourselves
 youth
+youthful
 yow
 Ypsilanti
 ytterbium
 yow
 Ypsilanti
 ytterbium
@@ -23955,6 +24425,7 @@ Zambia
 Zan
 Zanzibar
 zap
 Zan
 Zanzibar
 zap
+zapping
 zeal
 Zealand
 zealot
 zeal
 Zealand
 zealot
@@ -23975,6 +24446,7 @@ Ziegler
 zig
 zigging
 zigzag
 zig
 zigging
 zigzag
+zigzagging
 zilch
 Zimmerman
 zinc
 zilch
 Zimmerman
 zinc
@@ -23982,6 +24454,7 @@ zing
 Zion
 Zionism
 zip
 Zion
 Zionism
 zip
+zipping
 zircon
 zirconium
 zloty
 zircon
 zirconium
 zloty
@@ -23997,5 +24470,4 @@ zoom
 Zoroaster
 Zoroastrian
 zounds
 Zoroaster
 Zoroastrian
 zounds
-zucchini
 Zurich
 Zurich
diff --git a/usr/doc/REFS b/usr/doc/REFS
new file mode 100644 (file)
index 0000000..e5da452
--- /dev/null
@@ -0,0 +1,405 @@
+%A L. P. Deutsch
+%A B. W. Lampson
+%T An online editor
+%J Comm. Assoc. Comp. Mach.
+%V 10
+%N 12
+%D December 1967
+%P 793-799, 803
+%K qed
+
+.[
+%r 17
+%K cstr
+%R Comp. Sci. Tech. Rep. No. 17
+%I Bell Laboratories
+%C Murray Hill, New Jersey
+%A B. W. Kernighan
+%A L. L. Cherry
+%T A System for Typesetting Mathematics
+%d May 1974, revised April 1977
+%J Comm. Assoc. Comp. Mach.
+%K acm cacm
+%V 18
+%P 151-157
+%D March 1975
+.]
+
+%T U\s-2NIX\s0 Time-Sharing System: Document Preparation
+%K unix bstj
+%A B. W. Kernighan
+%A M. E. Lesk
+%A J. F. Ossanna
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 2115-2135
+%D 1978
+
+%A T. A. Dolotta
+%A J. R. Mashey
+%T An Introduction to the Programmer's Workbench
+%J Proc. 2nd Int. Conf. on Software Engineering
+%D October 13-15, 1976
+%P 164-168
+
+%T U\s-2NIX\s0 Time-Sharing System: The Programmer's Workbench
+%A T. A. Dolotta
+%A R. C. Haight
+%A J. R. Mashey
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 2177-2200
+%D 1978
+%K unix bstj
+
+%T U\s-2NIX\s0 Time-Sharing System: U\s-2NIX\s0 on a Microprocessor
+%K unix bstj
+%A H. Lycklama
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 2087-2101
+%D 1978
+
+%T The C Programming Language
+%A B. W. Kernighan
+%A D. M. Ritchie
+%I Prentice-Hall
+%C Englewood Cliffs, New Jersey
+%D 1978
+
+%T Computer Recreations
+%A Aleph-null
+%J Software Practice and Experience
+%V 1
+%N 2
+%D April-June 1971
+%P 201-204
+
+%T U\s-2NIX\s0 Time-Sharing System: The U\s-2NIX\s0 Shell
+%A S. R. Bourne
+%K unix bstj
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 1971-1990
+%D 1978
+
+%A L. P. Deutsch
+%A B. W. Lampson
+%T \*sSDS\*n 930 time-sharing system preliminary reference manual
+%R Doc. 30.10.10, Project \*sGENIE\*n
+%C Univ. Cal. at Berkeley
+%D April 1965
+
+%A R. J. Feiertag
+%A E. I. Organick
+%T The Multics input-output system
+%J Proc. Third Symposium on Operating Systems Principles
+%D October 18-20, 1971
+%P 35-41
+
+%A D. G. Bobrow
+%A J. D. Burchfiel
+%A D. L. Murphy
+%A R. S. Tomlinson
+%T \*sTENEX\*n, a Paged Time Sharing System for the \*sPDP\*n-10
+%J Comm. Assoc. Comp. Mach.
+%V 15
+%N 3
+%D March 1972
+%K tenex
+%P 135-143
+
+%A R. E. Griswold
+%A D. R. Hanson
+%T An Overview of SL5
+%J SIGPLAN Notices
+%V 12
+%N 4
+%D April 1977
+%P 40-50
+
+%A E. W. Dijkstra
+%T Cooperating Sequential Processes
+%B Programming Languages
+%E F. Genuys
+%I Academic Press
+%C New York
+%D 1968
+%P 43-112
+
+%A J. A. Hawley
+%A W. B. Meyer
+%T M\s-2UNIX\s0, A Multiprocessing Version of U\s-2NIX\s0
+%K munix unix
+%R M.S. Thesis
+%I Naval Postgraduate School
+%C Monterey, Cal.
+%D 1975
+
+%T The U\s-2NIX\s0 Time-Sharing System
+%K unix bstj
+%A D. M. Ritchie
+%A K. Thompson
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 1905-1929
+%D 1978
+
+%A E. I. Organick
+%T The M\s-2ULTICS\s0 System
+%K multics
+%I M.I.T. Press
+%C Cambridge, Mass.
+%D 1972
+
+%T UNIX for Beginners
+%A B. W. Kernighan
+%D 1978
+
+%T U\s-2NIX\s0 Programmer's Man\&ual
+%A K. Thompson
+%A D. M. Ritchie
+%K unix
+%I Bell Laboratories
+%O Seventh Edition.
+%D 1978
+
+%A K. Thompson
+%T The U\s-2NIX\s0 Command Language
+%B Structured Programming\(emInfotech State of the Art Report
+%I Infotech International Ltd.
+%C Nicholson House, Maidenhead, Berkshire, England
+%D March 1975
+%P 375-384
+%K unix
+%X pwb
+Brief description of shell syntax and semantics, without much
+detail on implementation.
+Much on pipes and convenience of hooking programs together.
+Includes SERMONETTE:
+"Many familiar computing `concepts' are missing from UNIX.
+Files have no records. There are no access methods.
+There are no file types.  These concepts fill a much-needed gap.
+I sincerely hope that when future systems are designed by
+manufacturers the value of some of these ingrained notions is re-examined.
+Like the politician and his `common man', manufacturers have
+their `average user'.
+
+%A J. R. Mashey
+%T PWB/UNIX Shell Tutorial
+%D September 30, 1977
+
+%A D. F. Hartley (Ed.)
+%T The Cambridge Multiple Access System \- Users Reference Manual
+%I University Mathematical Laboratory
+%C Cambridge, England
+%D 1968
+
+%A P. A. Crisman (Ed.)
+%T The Compatible Time-Sharing System
+%I M.I.T. Press
+%K whole ctss book
+%C Cambridge, Mass.
+%D 1965
+
+%T LR Parsing
+%A A. V. Aho
+%A S. C. Johnson
+%J Comp. Surveys
+%V 6
+%N 2
+%P 99-124
+%D June 1974
+
+%T Deterministic Parsing of Ambiguous Grammars
+%A A. V. Aho
+%A S. C. Johnson
+%A J. D. Ullman
+%J Comm. Assoc. Comp. Mach.
+%K acm cacm
+%V 18
+%N 8
+%P 441-452
+%D August 1975
+
+%A A. V. Aho
+%A J. D. Ullman
+%T Principles of Compiler Design
+%I Addison-Wesley
+%C Reading, Mass.
+%D 1977
+
+.[
+%r 65
+%R Comp. Sci. Tech. Rep. No. 65
+%K CSTR
+%A S. C. Johnson
+%T Lint, a C Program Checker
+%D December 1977
+%O updated version TM 78-1273-3
+%D 1978
+.]
+
+%T A Portable Compiler: Theory and Practice
+%A S. C. Johnson
+%J Proc. 5th ACM Symp. on Principles of Programming Languages
+%P 97-104
+%D January 1978
+
+.[
+%r 39
+%K CSTR
+%R Comp. Sci. Tech. Rep. No. 39
+%I Bell Laboratories
+%C Murray Hill, New Jersey
+%A M. E. Lesk
+%T Lex \(em A Lexical Analyzer Generator
+%D October 1975
+.]
+
+.[
+%r 32
+%K CSTR
+%R Comp. Sci. Tech. Rep. No. 32
+%I Bell Laboratories
+%C Murray Hill, New Jersey
+%A S. C. Johnson
+%T Yacc \(em  Yet Another Compiler-Compiler
+%D July 1975
+.]
+
+%T U\s-2NIX\s0 Time-Sharing System: Portability of C Programs and the U\s-2NIX\s0 System
+%K unix bstj
+%A S. C. Johnson
+%A D. M. Ritchie
+%J Bell Sys. Tech. J.
+%V 57
+%N 6
+%P 2021-2048
+%D 1978
+
+%T Typing Documents on UNIX and GCOS:  The -ms Macros for Troff
+%A M. E. Lesk
+%D 1977
+
+%A K. Thompson
+%A D. M. Ritchie
+%T U\s-2NIX\s0 Programmer's Manual
+%K unix
+%I Bell Laboratories
+%O Sixth Edition
+%D May 1975
+
+%T The Network U\s-2NIX\s0 System
+%K unix
+%A G. L. Chesson
+%J Operating Systems Review
+%V 9
+%N 5
+%P 60-66
+%D 1975
+%O Also in \f2Proc. 5th Symp. on Operating Systems Principles.\f1
+
+%T Spider \(em An Experimental Data Communications System
+%Z ctr127
+%A A. G. Fraser
+%J Proc. IEEE Conf. on Communications
+%P 21F
+%O IEEE Cat. No. 74CH0859-9-CSCB.
+%D June 1974
+
+%T A Virtual Channel Network
+%A A. G. Fraser
+%J Datamation
+%P 51-56
+%D February 1975
+
+.[
+%r 41
+%K CSTR
+%R Comp. Sci. Tech. Rep. No. 41
+%I Bell Laboratories
+%C Murray Hill, New Jersey
+%A J. W. Hunt
+%A M. D. McIlroy
+%T An Algorithm for Differential File Comparison
+%D June 1976
+.]
+
+%A F. P. Brooks, Jr.
+%T The Mythical Man-Month
+%I Addison-Wesley
+%C Reading, Mass.
+%D 1975
+%X pwb
+Readable, classic reference on software engineering and
+problems of large projects, from someone with experience in them.
+Required reading for any software engineer, even if conclusions may not
+always be agreed with.
+%br
+"The second is the most dangerous system a man every designs." p.55.
+%br
+"Hence plan to throw one away; you will, anyhow." p.116.
+%br
+"Cosgrove has perceptively pointed out that the programmer delivers
+satisfaction of a user need rather than any tangible product.
+And both the actual need and the user's perception of that need
+will change as programs are built, tested, and used." p.117.
+%br
+"The total cost of maintaining a widely used program is typically 40 percent
+or more of the cost of developing it." p.121.
+%br
+"As shown above, amalgamating prose and program reduces the total
+number of characters to be stored." p.175.
+
+%T A Portable Compiler for the Language C
+%A A. Snyder
+%I Master's Thesis, M.I.T.
+%C Cambridge, Mass.
+%D 1974
+
+%T The C Language Calling Sequence
+%A M. E. Lesk
+%A S. C. Johnson
+%A D. M. Ritchie
+%D 1977
+
+%T Optimal Code Generation for Expression Trees
+%A A. V. Aho
+%A S. C. Johnson
+%D 1975
+%J J. Assoc. Comp. Mach.
+%K acm jacm
+%V 23
+%N 3
+%P 488-501
+%O Also in \f2Proc. ACM Symp. on Theory of Computing,\f1 pp. 207-217, 1975.
+
+%A R. Sethi
+%A J. D. Ullman
+%T The Generation of Optimal Code for Arithmetic Expressions
+%J J. Assoc. Comp. Mach.
+%K acm jacm
+%V 17
+%N 4
+%D October 1970
+%P 715-728
+%O Reprinted as pp. 229-247 in \fICompiler Techniques\fR, ed. B. W. Pollack, Auerbach, Princeton NJ (1972).
+%X pwb
+Optimal approach for straight-line, fixed
+number of regs.
+
+%T Code Generation for Machines with Multiregister
+Operations
+%A A. V. Aho
+%A S. C. Johnson
+%A J. D. Ullman
+%J Proc. 4th ACM Symp. on Principles of Programming Languages
+%P 21-28
+%D January 1977
+
diff --git a/usr/doc/adb/dummy b/usr/doc/adb/dummy
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/doc/adb/tut b/usr/doc/adb/tut
deleted file mode 100644 (file)
index 13d3ed2..0000000
+++ /dev/null
@@ -1,1292 +0,0 @@
-.de P1
-.sp .5
-.if \\n(.$>0 .ta \\$1 \\$2 \\$3 \\$4 \\$5 \\$6
-.if \\n(.$=0 .ta 1i 1.7i 2.5i
-.ft 3
-.nf
-..
-.de P2
-.sp .5
-.ft 1
-.fi
-..
-.RP
-.....TM "77-8234-11 77-1273-10" "49170-220 39199" "40952-1 39199-11"
-.ND May 5, 1977
-.TL
-A Tutorial Introduction to ADB
-.AU "MH2F-207" "3816"
-J. F. Maranzano
-.AU "MH2C-512" 7419
-S. R. Bourne
-.AI
-.MH
-.OK
-UNIX
-Debugging
-C Programming
-.AB
-.PP
-Debugging tools generally provide a wealth of information
-about the inner workings of programs.
-These tools have been available on
-.UX
-to allow users to
-examine ``core'' files 
-that result from aborted programs.
-A new debugging program, ADB, provides enhanced capabilities
-to examine "core" and other program files in a
-variety of formats, run programs with embedded breakpoints and patch files.
-.PP
-ADB is an indispensable but complex tool for debugging crashed systems and/or
-programs.
-This document provides an introduction to ADB with examples of its use.
-It explains the various formatting options, 
-techniques for debugging C programs, examples of printing
-file system information and patching.
-.AE
-.CS 12 15 27 13 0 5
-.NH
-Introduction
-.PP
-ADB is a new debugging program that is
-available on UNIX.
-It provides capabilities to look at
-``core'' files resulting from aborted programs, print output in a
-variety of formats, patch files, and run programs
-with embedded breakpoints.
-This document provides examples of
-the more useful features of ADB.
-The reader is expected to be
-familiar with the basic commands on
-.UX
-with the C
-language, and with References 1, 2 and 3.
-.NH
-A Quick Survey
-.NH 2
-Invocation
-.PP
-ADB is invoked as:
-.P1
-       adb objfile corefile
-.P2
-where
-.ul
-objfile
-is an executable UNIX file and 
-.ul
-corefile 
-is a core image file.
-Many times this will look like:
-.P1
-       adb a.out core
-.P2
-or more simply:
-.P1
-       adb
-.P2
-where the defaults are 
-.ul
-a.out
-and
-.ul
-core
-respectively.
-The filename minus (\-) means ignore this argument as in:
-.P1
-       adb \- core
-.P2
-.PP
-ADB has requests for examining locations in either file.
-The
-\fB?\fP
-request examines the contents of 
-.ul
-objfile,
-the
-\fB/\fP
-request examines the 
-.ul
-corefile.
-The general form of these requests is:
-.P1
-       address ? format
-.P2
-or
-.P1
-       address / format
-.P2
-.NH 2
-Current Address
-.PP
-ADB maintains a current address, called dot,
-similar in function to the current pointer in the UNIX editor.
-When an address is entered, the current address is set to that location,
-so that:
-.P1
-       0126?i
-.P2
-sets dot to octal 126 and prints the instruction
-at that address.
-The request:
-.P1
-       .,10/d
-.P2
-prints 10 decimal numbers starting at dot.
-Dot ends up referring to the address of the last item printed.
-When used with the \fB?\fP or \fB/\fP requests,
-the current address can be advanced by typing newline; it can be decremented
-by typing \fB^\fP.
-.PP
-Addresses are represented by
-expressions.
-Expressions are made up from decimal, octal, and hexadecimal integers,
-and symbols from the program under test.
-These may be combined with the operators +, \-, *, % (integer division), 
-& (bitwise and), | (bitwise inclusive or),  # (round up
-to the next multiple), and ~ (not).
-(All arithmetic within ADB is 32 bits.)
-When typing a symbolic address for a C program, 
-the user can type 
-.ul
-name
-or
-.ul
-_name;
-ADB will recognize both forms.
-.NH 2
-Formats
-.PP
-To print data, a user specifies a collection of letters and characters
-that describe the format of the printout.
-Formats are "remembered" in the sense that typing a request without one
-will cause the new printout to appear in the previous format.
-The following are the most commonly used format letters.
-.P1
-\fB    b       \fPone byte in octal
-\fB    c       \fPone byte as a character
-\fB    o       \fPone word in octal
-\fB    d       \fPone word in decimal
-\fB    f       \fPtwo words in floating point
-\fB    i       \fPPDP 11 instruction
-\fB    s       \fPa null terminated character string
-\fB    a       \fPthe value of dot
-\fB    u       \fPone word as unsigned integer
-\fB    n       \fPprint a newline
-\fB    r       \fPprint a blank space
-\fB    ^       \fPbackup dot
-.P2
-(Format letters are also available for "long" values,
-for example, `\fBD\fR' for long decimal, and `\fBF\fP' for double floating point.)
-For other formats see the ADB manual.
-.NH 2
-General Request Meanings
-.PP
-The general form of a request is:
-.P1
-       address,count command modifier
-.P2
-which sets `dot' to \fIaddress\fP
-and executes the command
-\fIcount\fR times.
-.PP
-The following table illustrates some general ADB command meanings:
-.P1
-       Command Meaning
-\fB        ?   \fPPrint contents from \fIa.out\fP file
-\fB        /   \fPPrint contents from \fIcore\fP file
-\fB        =   \fPPrint value of "dot"
-\fB        :   \fPBreakpoint control
-\fB        $   \fPMiscellaneous requests
-\fB        ;   \fPRequest separator
-\fB        !   \fPEscape to shell
-.P2
-.PP
-ADB catches signals, so a user cannot use a quit signal to exit from ADB.
-The request $q or $Q (or cntl-D) must be used
-to exit from ADB.
-.NH
-Debugging C Programs
-.NH 2
-Debugging A Core Image 
-.PP
-Consider the C program in Figure 1.
-The program is used to illustrate a common error made by
-C programmers.
-The object of the program is to change the
-lower case "t" to upper case in the string pointed to by
-.ul
-charp
-and then write the character string to the file indicated by
-argument 1.
-The bug shown is that the character "T"
-is stored in the pointer 
-.ul
-charp
-instead of the string pointed to by
-.ul
-charp.
-Executing the program produces a core file because of an out of bounds memory reference.
-.PP
-ADB is invoked by:
-.P1
-       adb a.out core
-.P2
-The first debugging request:
-.P1
-       $c
-.P2
-is used to give a C backtrace through the
-subroutines called.
-As shown in Figure 2
-only one function (\fImain\fR) was called and the
-arguments 
-.ul
-argc 
-and 
-.ul
-argv 
-have octal values 02 and
-0177762 respectively.
-Both of these values look
-reasonable; 02 = two arguments, 0177762 = address on stack
-of parameter vector.
-.br
-The next request:
-.P1
-       $C
-.P2
-is used to give a C backtrace plus an interpretation
-of all the local variables in each function and their
-values in octal.
-The value of the variable 
-.ul
-cc
-looks incorrect
-since
-.ul
-cc
-was declared as a character.
-.PP
-The next request:
-.P1
-       $r
-.P2
-prints out the registers including the program
-counter and an interpretation of the instruction at that
-location.
-.PP
-The request:
-.P1
-       $e
-.P2
-prints out the values of all external variables.
-.PP
-A map exists for each file
-handled by
-ADB.
-The map for the
-.ul
-a.out
-file is referenced by \fB?\fP whereas the map for 
-.ul
-core
-file is referenced by \fB/\fP.
-Furthermore, a good rule of thumb is to use \fB?\fP for
-instructions and \fB/\fP for data when looking at programs.
-To print out information about the maps type:
-.P1
-       $m
-.P2
-This produces a report of the contents of the maps.
-More about these maps later.
-.PP
-In our example, it is useful to see the
-contents of the string pointed to by
-.ul
-charp.
-This is done by:
-.P1
-       *charp/s
-.P2
-which says use 
-.ul
-charp
-as a pointer in the
-.ul
-core
-file
-and print the information as a character string.
-This printout clearly shows that the character buffer
-was incorrectly overwritten and helps identify the error.
-Printing the locations around 
-.ul
-charp
-shows that the buffer is unchanged
-but that the pointer is destroyed.
-Using ADB similarly, we could print information about the
-arguments to a function.
-The request:
-.P1
-       main.argc/d
-.P2
-prints the decimal 
-.ul
-core
-image value of the argument 
-.ul
-argc
-in the function 
-.ul
-main.
-.br
-The request:
-.P1
-       *main.argv,3/o
-.P2
-prints the octal values of the three consecutive
-cells pointed to by 
-.ul
-argv
-in the function 
-.ul
-main.
-Note that these values are the addresses of the arguments
-to main.
-Therefore: 
-.P1
-       0177770/s
-.P2
-prints the ASCII value of the first argument.
-Another way to print this value would have been
-.P1
-       *"/s
-.P2
-The " means ditto which remembers the last address
-typed, in this case \fImain.argc\fP ; the \fB*\fP instructs ADB to use the address field of the
-.ul
-core 
-file as a pointer.
-.PP
-The request:
-.P1
-       .=o
-.P2
-prints the current address (not its contents) in octal which has been set to the address of the first argument.
-The current address, dot, is used by ADB to
-"remember" its current location.
-It allows the user 
-to reference locations relative to the current
-address, for example:
-.P1
-       .\-10/d
-.P2
-.NH 2
-Multiple Functions
-.PP
-Consider the C program illustrated in
-Figure 3.
-This program calls functions 
-.ul
-f, g,
-and
-.ul
-h 
-until the stack is exhausted and a core image is produced.
-.PP
-Again you can enter the debugger via:
-.P1
-       adb
-.P2
-which assumes the names 
-.ul
-a.out
-and 
-.ul
-core
-for the executable
-file and core image file respectively.
-The request:
-.P1
-       $c
-.P2
-will fill a page of backtrace references to 
-.ul
-f, g,
-and
-.ul
-h.
-Figure 4 shows an abbreviated list (typing 
-.ul
-DEL
-will terminate the output and bring you back to ADB request level).
-.PP
-The request:
-.P1
-       ,5$C
-.P2
-prints the five most recent activations.
-.PP
-Notice that each function 
-(\fIf,g,h\fP) has a counter
-of the number of times it was called.
-.PP
-The request:
-.P1
-       fcnt/d
-.P2
-prints the decimal value of the counter for the function
-.ul
-f.
-Similarly 
-.ul
-gcnt
-and
-.ul
-hcnt
-could be printed.
-To print the value of an automatic variable,
-for example the decimal value of
-.ul 
-x
-in the last call of the function
-.ul
-h,
-type:
-.P1
-       h.x/d
-.P2
-It is currently not possible in the exported version to print stack frames other than the most recent activation of a function.
-Therefore, a user can print everything with 
-\fB$C\fR or the occurrence of a variable in the most recent call of a function.
-It is possible with the \fB$C\fR request, however, to print the stack frame
-starting at some address as \fBaddress$C.\fR
-.NH 2
-Setting Breakpoints
-.PP
-Consider the C program in Figure 5.
-This program, which changes tabs into blanks, is adapted from
-.ul
-Software Tools
-by Kernighan and Plauger, pp. 18-27.
-.PP
-We will run this program under the control of ADB (see Figure 6a) by:
-.P1
-       adb a.out \-
-.P2
-Breakpoints are set in the program as:
-.ul
-.P1
-       address:b  [request]
-.P2
-The requests:
-.P1
-       settab+4:b
-       fopen+4:b
-       getc+4:b
-       tabpos+4:b
-.P2
-set breakpoints at the start of these functions.
-C does not generate statement labels.
-Therefore it is currently not possible to plant breakpoints at locations
-other than function entry points without a knowledge of the code
-generated by the C compiler.
-The above addresses are entered as
-.ft B
-symbol+4
-.ft R
-so that they will appear in any
-C backtrace since the first instruction of each function is a call
-to the C save routine 
-(\fIcsv\fR).
-Note that some of the functions are from the C library.
-.PP
-To print the location of breakpoints one types:
-.P1
-       $b
-.P2
-The display indicates a
-.ul
-count
-field.
-A breakpoint is bypassed
-.ul
-count \-1
-times before causing a stop.
-The
-.ul
-command
-field indicates the ADB requests to be executed each time the breakpoint is encountered.
-In our example no
-.ul
-command
-fields are present.
-.PP
-By displaying the original instructions at the function
-.ul
-settab
-we see that 
-the breakpoint is set after the jsr to the C save routine.
-We can display the instructions using the ADB request:
-.P1
-       settab,5?ia
-.P2
-This request displays five instructions starting at
-.ul
-settab
-with the addresses of each location displayed.
-Another variation is:
-.P1
-       settab,5?i
-.P2
-which displays the instructions with only the starting address.
-.PP
-Notice that we accessed the addresses from the 
-.ul
-a.out 
-file with the \fB?\fP command.
-In general when asking for a printout of multiple items,
-ADB will advance the current address the number of
-bytes necessary to satisfy the request; in the above
-example five instructions were displayed and the current address was
-advanced 18 (decimal) bytes.
-.PP
-To run the program one simply types:
-.P1
-       :r
-.P2
-To delete a breakpoint, for instance the entry to the function
-.ul
-settab,
-one types:
-.P1
-       settab+4:d
-.P2
-To continue execution of the program from the breakpoint type:
-.P1
-       :c
-.PP
-Once the program has stopped (in this case at the breakpoint for
-.ul
-fopen),
-ADB requests can be used to display the contents of memory.
-For example:
-.P1
-       $C
-.P2
-to display a stack trace, or:
-.P1
-       tabs,3/8o
-.P2
-to print three lines of 8 locations each from the array called
-.ul
-tabs.
-By this time (at location
-.ul
-fopen)
-in the C program,
-.ul
-settab
-has been called and should have set a one in every eighth location of 
-.ul
-tabs.
-.NH 2
-Advanced Breakpoint Usage
-.PP
-We continue execution of the program with:
-.P1
-       :c
-.P2
-See Figure 6b.
-.ul
-Getc
-is called three times and  the contents of the variable 
-.ul
-c
-in the function
-.ul
-main
-are displayed
-each time.
-The single character on the left hand edge is the output from the C program.
-On the third occurrence of 
-.ul
-getc
-the program stops.
-We can look at the full buffer of characters by typing:
-.P1
-       ibuf+6/20c
-.P2
-When we continue the program with:
-.P1
-       :c
-.P2
-we hit our first breakpoint at
-.ul
-tabpos
-since there is a tab following the
-"This" word of the data.
-.PP
-Several breakpoints of
-.ul
-tabpos
-will occur until the program has changed the tab into equivalent blanks.
-Since we feel that
-.ul
-tabpos
-is working,
-we can remove the breakpoint at that location by:
-.P1
-       tabpos+4:d
-.P2
-If the program is continued with:
-.P1
-       :c
-.P2
-it resumes normal execution after ADB prints
-the message
-.P1
-       a.out:running
-.P2
-.PP
-The UNIX quit and interrupt signals
-act on ADB itself rather than on the program being debugged.
-If such a signal occurs then the program being debugged is stopped and control is returned to ADB.
-The signal is saved by ADB and is passed on to the test program if:
-.P1
-       :c
-.P2
-is typed.
-This can be useful when testing interrupt
-handling routines.
-The signal is not passed on to the test program if:
-.P1
-       :c  0
-.P2
-is typed.
-.PP
-Now let us reset the breakpoint at
-.ul
-settab
-and display the instructions located there when we reach the breakpoint.
-This is accomplished by:
-.P1
-       settab+4:b  settab,5?ia  \fR*
-.P2
-.FS
-* Owing to a bug in early versions of ADB (including the
-version distributed in Generic 3 UNIX) these statements
-must be written as:
-.br
-.in 1i
-\fBsettab+4:b  settab,5?ia;0\fR
-.ft B
-.br
-getc+4,3:b     main.c?C;0
-.br
-settab+4:b     settab,5?ia; ptab/o;0
-.br
-.ft R
-.in -1i
-Note that \fB;0\fR will set dot to zero and stop at the breakpoint.
-.FE
-It is also possible to execute the ADB requests for each occurrence of the breakpoint but
-only stop after the third occurrence by typing:
-.P1
-       getc+4,3:b  main.c?C  \fR*
-.P2
-This request will print the local variable 
-.ul
-c
-in the function 
-.ul
-main
-at each occurrence of the breakpoint.
-The semicolon is used to separate multiple ADB requests on a single line.
-.PP
-Warning:
-setting a breakpoint causes the value of dot to be changed;
-executing the program under ADB does not change dot.
-Therefore:
-.P1
-       settab+4:b  .,5?ia
-       fopen+4:b
-.P2
-will print the last thing dot was set to
-(in the example \fIfopen+4\fP)
-.ul
-not
-the current location (\fIsettab+4\fP)
-at which the program is executing.
-.PP
-A breakpoint can be overwritten without first deleting the old breakpoint.
-For example:
-.P1
-       settab+4:b  settab,5?ia; ptab/o  \fR*
-.P2
-could be entered after typing the above requests.
-.PP
-Now the display of breakpoints:
-.P1
-       $b
-.P2
-shows the above request for the
-.ul
-settab
-breakpoint.
-When the breakpoint at
-.ul
-settab
-is encountered the ADB requests are executed.
-Note that the location at
-.ul
-settab+4
-has been changed to plant the breakpoint;
-all the other locations match their original value.
-.PP
-Using the functions,
-.ul
-f, g
-and 
-.ul
-h
-shown in Figure 3,
-we can follow the execution of each function by planting non-stopping
-breakpoints.
-We call ADB with the executable program of Figure 3 as follows:
-.P1
-       adb ex3 \-
-.P2
-Suppose we enter the following breakpoints:
-.P1
-       h+4:b   hcnt/d;  h.hi/;  h.hr/
-       g+4:b   gcnt/d;  g.gi/;  g.gr/
-       f+4:b   fcnt/d;  f.fi/;  f.fr/
-       :r
-.P2
-Each request line indicates that the variables are printed in decimal
-(by the specification \fBd\fR).
-Since the format is not changed, the \fBd\fR can be left off all but
-the first request.
-.PP
-The output in Figure 7 illustrates two points.
-First, the ADB requests in the breakpoint line are not
-examined until the program under
-test is run.
-That means any errors in those ADB requests is not detected until run time.
-At the location of the error ADB stops running the program.
-.PP
-The second point is the way ADB handles register variables.
-ADB uses the symbol table to address variables.
-Register variables, like \fIf.fr\fR above, have pointers to uninitialized
-places on the stack.
-Therefore the message "symbol not found".
-.PP
-Another way of getting at the data in this example is to print
-the variables used in the call as:
-.P1
-       f+4:b   fcnt/d;  f.a/;  f.b/;  f.fi/
-       g+4:b   gcnt/d;  g.p/;  g.q/;  g.gi/
-       :c
-.P2
-The operator / was used instead of ?
-to read values from the \fIcore\fP file.
-The output for each function, as shown in Figure 7, has the same format.
-For the function \fIf\fP, for example, it shows the name and value of the
-.ul
-external
-variable
-.ul
-fcnt.
-It also shows the address on the stack and value of the
-variables
-.ul
-a, b
-and
-.ul
-fi.
-.PP
-Notice that the addresses on the stack will continue to decrease
-until no address space is left for program execution
-at which time (after many pages of output)
-the program under test aborts.
-A display with names would be produced by requests like the following:
-.P1
-       f+4:b   fcnt/d;  f.a/"a="d;  f.b/"b="d;  f.fi/"fi="d
-.P2
-In this format the quoted string is printed literally and the \fBd\fP
-produces a decimal display of the variables.
-The results are shown in Figure 7.
-.NH 2
-Other Breakpoint Facilities
-.LP
-.IP \(bu 4
-Arguments and change of standard input and output are passed to a program as:
-.P1
-       :r  arg1  arg2 ... <infile  >outfile
-.P2
-This request
-kills any existing program under test and
-starts the
-.ul
-a.out
-afresh.
-.IP \(bu
-The program being debugged can be single stepped
-by:
-.P1
-       :s
-.P2
-If necessary, this request will start up the program being
-debugged and stop after executing
-the first instruction.
-.IP \(bu
-ADB allows a program to be entered at a specific address
-by typing:
-.P1
-       address:r
-.P2
-.IP \(bu
-The count field can be used to skip the first \fIn\fR breakpoints as:
-.P1
-       ,n:r
-.P2
-The request:
-.P1
-       ,n:c
-.P2
-may also be used for skipping the first \fIn\fR breakpoints
-when continuing a program.
-.sp
-.IP \(bu
-A program can be continued at an address different from the breakpoint by:
-.P1
-       address:c
-.P2
-.IP \(bu
-The program being debugged runs as a separate process and can be killed by:
-.P1
-       :k
-.P2
-.LP
-.NH
-Maps
-.PP
-UNIX supports several executable file formats.  These are used to tell
-the loader how to load  the program file.  File type 407
-is the most common and is generated by a C compiler invocation such as
-\fBcc pgm.c\fP.
-A 410 file is produced by a C compiler command of the form \fBcc -n pgm.c\fP,
-whereas a 411 file is produced by \fBcc -i pgm.c\fP.
-ADB interprets these different file formats and
-provides access to the different segments through a set of maps (see Figure 8).
-To print the maps type:
-.P1
-       $m
-.P2
-.PP
-In 407 files, both text (instructions) and data are intermixed.
-This makes it impossible for ADB to differentiate data from
-instructions and some of the printed symbolic addresses look incorrect;
-for example, printing data addresses as offsets from routines.
-.PP
-In 410 files (shared text), the instructions are separated from data and
-\fB?*\fR accesses the data part of the \fIa.out\fP file.
-The \fB?* \fP request tells ADB to use the second part of the
-map in the
-.ul
-a.out
-file.
-Accessing data in the \fIcore\fP file shows
-the data after it was modified by the execution of the program.
-Notice also that the data segment may have grown during
-program execution.
-.PP
-In 411 files (separated I & D space), the
-instructions and data are also separated.
-However, in this
-case, since data is mapped through a separate set of segmentation
-registers, the base of the data segment is also relative to address zero.
-In this case since the addresses overlap it is necessary to use
-the \fB?*\fR operator to access the data space of the \fIa.out\fP file.
-In both 410 and 411 files the corresponding
-core file does not contain the program text.
-.PP
-Figure 9 shows the display of three maps
-for the same program linked as a 407, 410, 411 respectively.
-The b, e, and f fields are used by ADB to map
-addresses into file addresses.
-The "f1" field is the
-length of the header at the beginning of the file (020 bytes
-for an \fIa.out\fP file and 02000 bytes for a \fIcore\fP file).
-The "f2" field is the displacement from the beginning of the file to the data.
-For a 407 file with mixed text and data this is the
-same as the length of the header; for 410 and 411 files this
-is the length of the header plus the size of the text portion.
-.PP
-The "b" and "e" fields are the starting and ending locations
-for a segment.
-Given an address, A, the location in
-the file (either \fIa.out\fP or \fIcore\fP) is calculated as:
-.P1
-       b1\(<=A\(<=e1 =\h'-.5m'> file address = (A\-b1)+f1
-       b2\(<=A\(<=e2 =\h'-.5m'> file address = (A\-b2)+f2
-.P2
-A user can access locations by using the ADB defined variables.
-The \fB$v\fR request prints the variables initialized by ADB:
-.P1
-       b       base address of data segment
-       d       length of the data segment
-       s       length of the stack
-       t       length of the text
-       m       execution type (407,410,411)
-.P2
-.PP
-In Figure 9 those variables not present are zero.
-Use can be made of these variables by expressions such as:
-.P1
-       <b
-.P2
-in the address field.
-Similarly the value of the variable can be changed by an assignment request
-such as:
-.P1
-       02000>b
-.P2
-that sets \fBb\fP to octal 2000.
-These variables are useful to know if the file under examination
-is an executable or \fIcore\fP image file.
-.PP
-ADB reads the header of the \fIcore\fP image file to find the
-values for these variables.
-If the second file specified does not
-seem to be a \fIcore\fP file, or if it is missing then the header of
-the executable file is used instead.
-.NH
-Advanced Usage
-.PP
-It is possible with ADB to combine formatting requests
-to provide elaborate displays.
-Below are several examples.
-.NH 2
-Formatted dump
-.PP
-The line:
-.P1
-       <b,\-1/4o4^8Cn
-.P2
-prints 4 octal words followed by their ASCII interpretation
-from the data space of the core image file.
-Broken down, the various request pieces mean:
-.sp
-.in 1.7i
-.ta .7i
-.ti -.7i
-<b     The base address of the data segment.
-.sp
-.ti -.7i
-<b,\-1 Print from the base address to the end of file.
-A negative count is used here and elsewhere to loop indefinitely
-or until some error condition (like end of file) is detected.
-.sp
-.ti -1.7i
-The format \fB4o4^8Cn\fR is broken down as follows:
-.sp
-.ti -.7i
-4o     Print 4 octal locations.
-.sp
-.ti -.7i
-4^     Backup the current address 4 locations (to the original start of the field).
-.sp
-.ti -.7i
-8C     Print 8 consecutive characters using an escape convention;
-each character in the range 0 to 037 is printed as @ followed by the corresponding character in the range 0140 to 0177.
-An @ is printed as @@.
-.sp
-.ti -.7i
-n      Print a newline.
-.in -1.7i
-.fi
-.sp
-.PP
-The request:
-.P1
-       <b,<d/4o4^8Cn
-.P2
-could have been used instead to allow the printing to stop
-at the end of the data segment (<d provides the data segment size in bytes).
-.PP
-The formatting requests can be combined with ADB's ability
-to read in a script to produce a core image dump script.
-ADB is invoked as:
-.P1
-       adb a.out core < dump
-.P2
-to read in a script file,
-.ul
-dump,
-of requests.
-An example of such a script is:
-.P1
-       120$w
-       4095$s
-       $v
-       =3n
-       $m
-       =3n"C Stack Backtrace"
-       $C
-       =3n"C External Variables"
-       $e
-       =3n"Registers"
-       $r
-       0$s
-       =3n"Data Segment"
-       <b,\-1/8ona
-.P2
-.PP
-The request \fB120$w\fP sets the width of the output to
-120 characters
-(normally, the width is 80 characters).
-ADB attempts to print addresses as:
-.P1
-       symbol + offset
-.P2
-The request \fB4095$s\fP increases the maximum permissible offset
-to the nearest symbolic address from 255 (default) to 4095.
-The request \fB=\fP can be used to print literal strings.
-Thus,
-headings are provided in this
-.ul
-dump
-program
-with requests of the form:
-.P1
-       =3n"C Stack Backtrace"
-.P2
-that spaces three lines and prints the literal
-string.
-The request \fB$v\fP prints all non-zero ADB variables (see Figure 8).
-The request
-\fB0$s\fP
-sets the maximum offset for symbol matches to zero thus
-suppressing the printing of symbolic labels in favor
-of octal values.
-Note that this is only done for the printing of the data segment.
-The request:
-.P1
-       <b,\-1/8ona
-.P2
-prints a dump from the base of the data segment to the end of file
-with an octal address field and eight octal numbers per line.
-.PP
-Figure 11 shows the results of some formatting requests
-on the C program of Figure 10.
-.NH 2
-Directory Dump
-.PP
-As another illustration (Figure 12) consider a set of requests to dump
-the contents of a directory (which is made up
-of an integer \fIinumber\fP followed by a 14 character name):
-.P1
-       adb dir \-
-       =n8t"Inum"8t"Name"
-       0,\-1? u8t14cn
-.P2
-In this example, the \fBu\fP prints the \fIinumber\fP as an unsigned decimal integer,
-the \fB8t\fP means that ADB will space to the next
-multiple of 8 on the output line, and the \fB14c\fP prints the 14 character file name.
-.NH 2
-Ilist Dump
-.PP
-Similarly the contents of the \fIilist\fP of a file system, (e.g. /dev/src,
-on UNIX systems distributed by the UNIX Support Group;
-see UNIX Programmer's
-Manual Section V) could be dumped with the following set of 
-requests:
-.P1
-       adb /dev/src \-
-       02000>b
-       ?m <b
-       <b,\-1?"flags"8ton"links,uid,gid"8t3bn",size"8tbrdn"addr"8t8un"times"8t2Y2na
-.P2
-In this example the value of the base for the map was changed 
-to 02000 (by saying \fB?m<b\fR) since that is the start of an \fIilist\fP within a file system.
-An artifice (\fBbrd\fP above) was used to print the 24 bit size field
-as a byte, a space, and a decimal integer.
-The last access time and last modify time are printed with the
-\fB2Y\fR
-operator.
-Figure 12 shows portions of these requests as applied to a directory
-and file system.
-.NH 2
-Converting values
-.PP
-ADB may be used to convert values from one representation to
-another.
-For example:
-.P1
-       072 = odx
-.P2
-will print
-.P1
-       072     58      #3a
-.P2
-which is the octal, decimal and hexadecimal representations
-of 072 (octal).
-The format is remembered so that typing
-subsequent numbers will print them in the given formats.
-Character values may be converted similarly, for example:
-.P1
-       'a' = co
-.P2
-prints
-.P1
-       a       0141
-.P2
-It may also be used to evaluate expressions but be
-warned that all binary operators have
-the same precedence which is lower than that for unary operators.
-.NH
-Patching
-.PP
-Patching files with ADB is accomplished with the 
-.ul
-write,
-\fBw\fP or \fBW\fP, request (which is not like the \fIed\fP editor write command).
-This is often used in conjunction with the 
-.ul
-locate,
-\fBl\fP or \fBL\fP
-request.
-In general, the request syntax for \fBl\fP and \fBw\fP are similar as follows:
-.P1
-       ?l value
-.P2
-The request \fBl\fP is used to match on two bytes, \fBL\fP is used for
-four bytes.
-The request \fBw\fP is used to write two bytes, whereas
-\fBW\fP writes four bytes.
-The \fBvalue\fP field in either 
-.ul
-locate
-or
-.ul
-write
-requests
-is an expression.
-Therefore, decimal and octal numbers, or character strings are supported.
-.PP
-In order to modify a file, ADB must be called as:
-.P1
-       adb \-w file1 file2
-.P2
-When called with this option, 
-.ul
-file1
-and 
-.ul
-file2
-are created if necessary and opened for both reading and writing.
-.PP
-For example, consider the C program shown in Figure 10.
-We can change the word "This" to "The " in the executable file
-for this program, \fIex7\fP, by using the following requests:
-.P1
-       adb \-w ex7 \-
-       ?l 'Th'
-       ?W 'The '
-.P2
-The request \fB?l\fP starts at dot and stops at the first match of "Th"
-having set dot to the address of the location found.
-Note the use of \fB?\fP to write to the 
-.ul
-a.out
-file.
-The form \fB?*\fP would have been used for a 411 file.
-.PP
-More frequently the 
-request will be typed as:
-.P1
-       ?l 'Th'; ?s
-.P2
-and locates the first occurrence of "Th" and print the entire string.
-Execution of this ADB request will set dot to the address of the 
-"Th" characters.
-.PP
-As another example of the utility of the patching facility,
-consider a C program that has an internal logic flag.
-The flag could be set by the user through ADB and the program run.
-For example:
-.P1
-       adb a.out \-
-       :s arg1 arg2
-       flag/w 1
-       :c
-.P2
-The \fB:s\fR request is normally used to single step through a process
-or start a process in single step mode.
-In this case it starts
-.ul
-a.out
-as a subprocess
-with arguments \fBarg1\fP and \fBarg2\fP.
-If there is a subprocess running ADB writes to it rather than to the file
-so the \fBw\fP request causes \fIflag\fP to be changed in the memory of the subprocess.
-.NH
-Anomalies
-.PP
-Below is a list of some strange things that users
-should be aware of.
-.IP 1.
-Function calls and arguments are put on the stack by the C
-save routine.
-Putting breakpoints at the entry point to routines
-means that the function appears not to have been called
-when the
-breakpoint occurs.
-.IP 2.
-When printing addresses, ADB uses
-either text or data symbols from the \fIa.out\fP file.
-This sometimes causes unexpected symbol names to be printed 
-with data (e.g. \fIsavr5+022\fP).
-This does not happen if
-\fB?\fR is used for text (instructions)
-and \fB/\fP for data.
-.IP 3.
-ADB cannot handle C register variables
-in the most recently activated function.
-.LP
-.NH
-Acknowledgements
-.PP
-The authors are grateful for the thoughtful comments
-on how to organize this document
-from R. B. Brandt, E. N. Pinson and B. A. Tague.
-D. M. Ritchie made the system changes necessary to accommodate
-tracing within ADB. He also participated in discussions 
-during the writing of ADB.
-His earlier work with DB and CDB led to many of the 
-features found in ADB.
-.SG MH-8234-JFM/1273-SRB-unix
-.NH
-References
-.LP
-.IP 1.
-D. M. Ritchie and K. Thompson,
-``The UNIX Time-Sharing System,''
-CACM, July, 1974.
-.IP 2.
-B. W. Kernighan and D. M. Ritchie,
-.ul
-The C Programming Language,
-Prentice-Hall, 1978.
-.IP 3.
-K. Thompson and D. M. Ritchie,
-UNIX Programmer's Manual - 7th Edition,
-1978.
-.IP 4.
-B. W. Kernighan and P. J. Plauger,
-.ul
-Software Tools,
-Addison-Wesley, 1976.
diff --git a/usr/doc/adb/tut1 b/usr/doc/adb/tut1
deleted file mode 100644 (file)
index 8366473..0000000
+++ /dev/null
@@ -1,961 +0,0 @@
-.sp 100
-.nr PS 9
-.nr VS 11
-.      \" START OF Figures
-.de P1
-.nf
-.in +.5i
-.ta .5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i
-.sp
-.ps 9
-.vs 11p
-..
-.de P2
-.sp
-.fi
-.ps \\n(PS
-.vs \\n(VS
-.in -.5i
-..
-.SH
-Figure 1:  C program with pointer bug
-.LP
-.P1
-struct buf {
-       int fildes;
-       int nleft;
-       char *nextp;
-       char buff[512];
-       }bb;
-struct buf *obuf;
-
-char *charp "this is a sentence.";
-
-main(argc,argv)
-int argc;
-char **argv;
-{
-       char    cc;
-
-       if(argc < 2) {
-               printf("Input file missing\\n");
-               exit(8);
-       }
-
-       if((fcreat(argv[1],obuf)) < 0){
-               printf("%s : not found\\n", argv[1]);
-               exit(8);
-       }
-       charp = \'T\';
-printf("debug 1 %s\\n",charp);
-       while(cc=  *charp++)
-               putc(cc,obuf);
-       fflush(obuf);
-}
-.P2
-.sp 100
-.SH
-Figure 2:  ADB output for C program of Figure 1
-.LP
-.P1
-.ft B
-adb a.out core
-$c
-.ft R
-~main(02,0177762)
-.ft B
-$C
-.ft R
-~main(02,0177762)
-       argc:       02
-       argv:       0177762
-       cc:         02124
-.ft B
-$r
-.ft R
-ps     0170010
-pc     0204    ~main+0152
-sp     0177740
-r5     0177752
-r4     01
-r3     0
-r2     0
-r1     0
-r0     0124
-~main+0152:    mov     _obuf,(sp)
-.ft B
-$e
-.ft R
-savr5:     0
-_obuf:     0
-_charp:            0124
-_errno:            0
-_fout:     0
-.ft B
-$m
-.ft R
-text map    \`ex1\'
-b1 = 0              e1 = 02360           f1 = 020
-b2 = 0              e2 = 02360           f2 = 020
-data map    \`core1\'
-b1 = 0              e1 = 03500           f1 = 02000
-b2 = 0175400        e2 = 0200000                 f2 = 05500
-.ft B
-*charp/s
-.ft R
-0124:          TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\1dL\ 3x\7f  \ 3N\1dh\ 4@\1dx\7f&\10_
-~
-.ft B
-charp/s
-.ft R
-_charp:                T
-_charp+02:     this is a sentence.
-_charp+026:    Input file missing
-.ft B
-main.argc/d
-.ft R
-0177756:       2
-.ft B
-*main.argv/3o
-.ft R
-0177762:       0177770 0177776 0177777
-.ft B
-0177770/s
-.ft R
-0177770:       a.out
-.ft B
-*main.argv/3o
-.ft R
-0177762:       0177770 0177776 0177777
-.ft B
-*"/s
-.ft R
-0177770:       a.out
-.ft B
- .=o
-.ft R
-               0177770
-.ft B
- .\(mi10/d
-.ft R
-0177756:       2
-.ft B
-$q
-.P2
-.sp 100
-.SH
-Figure 3:  Multiple function C program for stack trace illustration
-.LP
-.P1
-int    fcnt,gcnt,hcnt;
-h(x,y)
-{
-       int hi; register int hr;
-       hi = x+1;
-       hr = x\(miy+1;
-       hcnt++ ;
-       hj:
-       f(hr,hi);
-}
-
-g(p,q)
-{
-       int gi; register int gr;
-       gi = q\(mip;
-       gr = q\(mip+1;
-       gcnt++ ;
-       gj:
-       h(gr,gi);
-}
-
-f(a,b)
-{
-       int fi; register int fr;
-       fi = a+2*b;
-       fr = a+b;
-       fcnt++ ;
-       fj:
-       g(fr,fi);
-}
-
-main()
-{
-       f(1,1);
-}
-.P2
-.sp 100
-.SH
-Figure 4:  ADB output for C program of Figure 3
-.LP
-.P1
-.ft B
-adb
-$c
-.ft R
-~h(04452,04451)
-~g(04453,011124)
-~f(02,04451)
-~h(04450,04447)
-~g(04451,011120)
-~f(02,04447)
-~h(04446,04445)
-~g(04447,011114)
-~f(02,04445)
-~h(04444,04443)
-.ft B
-HIT DEL KEY
-.ft R
-adb
-.ft B
-,5$C
-.ft R
-~h(04452,04451)
-       x:          04452
-       y:          04451
-       hi:         ?
-~g(04453,011124)
-       p:          04453
-       q:          011124
-       gi:         04451
-       gr:         ?
-~f(02,04451)
-       a:          02
-       b:          04451
-       fi:         011124
-       fr:         04453
-~h(04450,04447)
-       x:          04450
-       y:          04447
-       hi:         04451
-       hr:         02
-~g(04451,011120)
-       p:          04451
-       q:          011120
-       gi:         04447
-       gr:         04450
-.ft B
-fcnt/d
-.ft R
-_fcnt:         1173
-.ft B
-gcnt/d
-.ft R
-_gcnt:         1173
-.ft B
-hcnt/d
-.ft R
-_hcnt:         1172
-.ft B
-h.x/d
-.ft R
-022004:                2346
-.ft B
-$q
-.P2
-.sp 100
-.SH
-Figure 5:  C program to decode tabs
-.LP
-.P1
-#define MAXLINE        80
-#define YES            1
-#define NO             0
-#define TABSP          8
-.sp .5
-char   input[] "data";
-char   ibuf[518];
-int    tabs[MAXLINE];
-.sp .5
-main()
-{
-       int col, *ptab;
-       char c;
-.sp .5
-       ptab = tabs;
-       settab(ptab);   /*Set initial tab stops */
-       col = 1;
-       if(fopen(input,ibuf) < 0) {
-               printf("%s : not found\\n",input);
-               exit(8);
-       }
-       while((c = getc(ibuf)) != \(mi1) {
-               switch(c) {
-                       case \(fm\\t\(fm:       /* TAB */
-                               while(tabpos(col) != YES) {
-                                       putchar(\(fm \(fm);     /* put BLANK */
-                                       col++ ;
-                               }
-                               break;
-                       case \(fm\\n\(fm:       /*NEWLINE */
-                               putchar(\(fm\\n\(fm);
-                               col = 1;
-                               break;
-                       default:
-                               putchar(c);
-                               col++ ;
-               }
-       }
-}
-.sp .5
-/* Tabpos return YES if col is a tab stop */
-tabpos(col)
-int col;
-{
-       if(col > MAXLINE)
-               return(YES);
-       else
-               return(tabs[col]);
-}
-.sp .5
-/* Settab - Set initial tab stops */
-settab(tabp)
-int *tabp;
-{
-       int i;
-.sp .5
-       for(i = 0; i<= MAXLINE; i++) 
-               (i%TABSP) ? (tabs[i] = NO) : (tabs[i] = YES);
-}
-.P2
-.sp 100
-.SH
-Figure 6a:  ADB output for C program of Figure 5
-.LP
-.P1
-.ft B
-adb a.out \(mi
-settab+4:b
-fopen+4:b
-getc+4:b
-tabpos+4:b
-$b
-.ft R
-breakpoints
-count  bkpt            command
-1      ~tabpos+04
-1      _getc+04
-1      _fopen+04
-1      ~settab+04
-.ft B
-settab,5?ia
-.ft R
-~settab:               jsr     r5,csv
-~settab+04:    tst     \(mi(sp)
-~settab+06:    clr     0177770(r5)
-~settab+012:   cmp     $0120,0177770(r5)
-~settab+020:   blt     ~settab+076
-~settab+022:
-.ft B
-settab,5?i
-.ft R
-~settab:               jsr     r5,csv
-               tst     \(mi(sp)
-               clr     0177770(r5)
-               cmp     $0120,0177770(r5)
-               blt     ~settab+076
-.ft B
-:r
-.ft R
-a.out: running
-breakpoint     ~settab+04:     tst     \(mi(sp)
-.ft B
-settab+4:d
-:c
-.ft R
-a.out: running
-breakpoint     _fopen+04:      mov     04(r5),nulstr+012
-.ft B
-$C
-.ft R
-_fopen(02302,02472)
-~main(01,0177770)
-       col:        01
-       c:          0
-       ptab:       03500
-.ft B
-tabs,3/8o
-.ft R
-03500:         01      0       0       0       0       0       0       0
-               01      0       0       0       0       0       0       0
-               01      0       0       0       0       0       0       0
-.P2
-.sp 100
-.SH
-Figure 6b:  ADB output for C program of Figure 5
-.LP
-.P1
-.ft B
-:c
-.ft R
-a.out: running
-breakpoint     _getc+04:       mov     04(r5),r1
-.ft B
-ibuf+6/20c
-.ft R
-__cleanu+0202:         This    is      a test  of
-.ft B
-:c
-.ft R
-a.out: running
-breakpoint     ~tabpos+04:     cmp     $0120,04(r5)
-.ft B
-tabpos+4:d
-settab+4:b  settab,5?ia
-settab+4:b  settab,5?ia;  0
-getc+4,3:b  main.c?C;  0
-settab+4:b  settab,5?ia;  ptab/o;  0
-$b
-.ft R
-breakpoints
-count  bkpt            command
-1      ~tabpos+04
-3      _getc+04        main.c?C;0
-1      _fopen+04
-1      ~settab+04      settab,5?ia;ptab?o;0
-~settab:               jsr     r5,csv
-~settab+04:    bpt
-~settab+06:    clr     0177770(r5)
-~settab+012:   cmp     $0120,0177770(r5)
-~settab+020:   blt     ~settab+076
-~settab+022:
-0177766:       0177770
-0177744:       @\`
-T0177744:      T
-h0177744:      h
-i0177744:      i
-s0177744:      s
-.P2
-.sp 100
-.SH
-Figure 7:  ADB output for C program with breakpoints
-.LP
-.in +.5i
-.nf
-.ps 8
-.vs 9
-.ft B
-adb ex3 \(mi
-h+4:b hcnt/d; h.hi/; h.hr/
-g+4:b gcnt/d; g.gi/; g.gr/
-f+4:b fcnt/d; f.fi/; f.fr/
-:r
-.ft R
-ex3: running
-_fcnt:         0
-0177732:       214
-symbol not found
-.ft B
-f+4:b fcnt/d; f.a/; f.b/; f.fi/
-g+4:b gcnt/d; g.p/; g.q/; g.gi/
-h+4:b hcnt/d; h.x/; h.y/; h.hi/
-:c
-.ft R
-ex3: running
-_fcnt:         0
-0177746:       1
-0177750:       1
-0177732:       214
-_gcnt:         0
-0177726:       2
-0177730:       3
-0177712:       214
-_hcnt:         0
-0177706:       2
-0177710:       1
-0177672:       214
-_fcnt:         1
-0177666:       2
-0177670:       3
-0177652:       214
-_gcnt:         1
-0177646:       5
-0177650:       8
-0177632:       214
-.ft B
-HIT DEL
-f+4:b fcnt/d; f.a/"a = "d; f.b/"b = "d; f.fi/"fi = "d
-g+4:b gcnt/d; g.p/"p = "d; g.q/"q = "d; g.gi/"gi = "d
-h+4:b hcnt/d; h.x/"x = "d; h.y/"h = "d; h.hi/"hi = "d
-:r
-.ft R
-ex3: running
-_fcnt:         0
-0177746:       a = 1
-0177750:       b = 1
-0177732:       fi = 214
-_gcnt:         0
-0177726:       p = 2
-0177730:       q = 3
-0177712:       gi = 214
-_hcnt:         0
-0177706:       x = 2
-0177710:       y = 1
-0177672:       hi = 214
-_fcnt:         1
-0177666:       a = 2
-0177670:       b = 3
-0177652:       fi = 214
-.ft B
-HIT DEL
-$q
-.in -.5i
-.sp 100
-.SH
-Figure 8:  ADB address maps
-.LP
-.de l1
-.tc
-.ta 1.20i +1.6i +2.5i
-..
-.de l3
-.tc
-.ta 1.6i +2.80i +.2i +1.55i
-..
-.de l2
-.tc
-.ti 1.0i
-.ta +0.5i +3.0i +1.75i
-.tc _
-..
-.de l5
-.tc 
-.ti 1.0i
-.ta +0.75i +3.0i +1.5i
-.tc _
-..
-.de l6
-.tc
-.ti 1.0i
-.ta +.8i +2.85i +0.4i +1.1i
-..
-.de l8
-.tc
-.ti 1.0i
-.ta +0.5i +3.0i +1.75i
-.tc _
-..
-.de la
-.tc
-.ta 1.20i +1.25i +1.7i
-..
-.de lc
-.tc
-.ti 1.0i
-.ta +.85i +1.6i +.35i +1.1i
-..
-.de lb
-.tc
-.ti 1.0i
-.ta +0.75i +1.75i +1.5i
-.tc _
-..
-.ul
-407 files
-.sp
-.l1
-a.out  hdr     text+data
-.l2
-|      |       |
-.l3
-       0       D
-.sp
-.l1
-core   hdr     text+data       stack
-.l5
-|      |       ......| |
-.l6
-       0       D       S       E
-.sp 2
-.ul
-410 files (shared text)
-.sp
-.l1
-a.out  hdr      text   data
-.l2
-|      |       |       |
-.l3
-       0       T       B       D
-.sp
-.la
-core   hdr     data    stack
-.lb
-|      |       ......| |
-.lc
-       B       D       S       E
-.sp 2
-.ul
-411 files (separated I and D space)
-.sp
-.l1
-a.out  hdr     text    data
-.l2
-|      |       |       |
-.l3
-       0       T       0       D
-.sp
-.la
-core   hdr     data    stack
-.lb
-|      |       ......| |
-.lc
-       0       D       S       E
-.sp 2
-The following 
-.ul 
-adb
-variables are set.
-.nf
-.ta .75i 1.5i 3.5i 4.5i 5.5i
-.sp
-                       407     410     411
-.sp
-       b       base of data    0       B       0
-       d       length of data  D       D\(miB  D
-       s       length of stack S       S       S
-       t       length of text  0       T       T
-.sp 100
-.SH
-Figure 9:  ADB output for maps
-.LP
-.nf
-.in +.5i
-.ft B
-adb map407 core407
-$m
-.ft R
-text map    \`map407\'
-b1 = 0              e1 = 0256            f1 = 020
-b2 = 0              e2 = 0256            f2 = 020
-data map    \`core407\'
-b1 = 0              e1 = 0300            f1 = 02000
-b2 = 0175400        e2 = 0200000         f2 = 02300
-.ft B
-$v
-.ft R
-variables
-d = 0300
-m = 0407
-s = 02400
-.ft B
-$q
-.sp 2
-adb map410 core410
-$m
-.ft R
-text map    \`map410\'
-b1 = 0              e1 = 0200            f1 = 020
-b2 = 020000         e2 = 020116          f2 = 0220
-data map    \`core410\'
-b1 = 020000         e1 = 020200          f1 = 02000
-b2 = 0175400        e2 = 0200000         f2 = 02200
-.ft B
-$v
-.ft R
-variables
-b = 020000
-d = 0200
-m = 0410
-s = 02400
-t = 0200
-.ft B
-$q
-.sp 2
-adb map411 core411
-$m
-.ft R
-text map    \`map411\'
-b1 = 0              e1 = 0200            f1 = 020
-b2 = 0              e2 = 0116            f2 = 0220
-data map    \`core411\'
-b1 = 0              e1 = 0200            f1 = 02000
-b2 = 0175400        e2 = 0200000         f2 = 02200
-.ft B
-$v
-.ft R
-variables
-d = 0200
-m = 0411
-s = 02400
-t = 0200
-.ft B
-$q
-.in -.5i
-.sp 100
-.SH
-Figure 10:  Simple C program for illustrating formatting and patching
-.LP
-.P1
-char   str1[]  "This is a character string";
-int    one     1;
-int    number  456;
-long   lnum    1234;
-float  fpt     1.25;
-char   str2[]  "This is the second character string";
-main()
-{
-       one = 2;
-}
-.P2
-.sp 100
-.SH
-Figure 11:  ADB output illustrating fancy formats
-.LP
-.nf
-.ps 9
-.vs 11p
-.ft B
-adb map410 core410
-<b,\(mi1/8ona
-.ft R
-020000:                0       064124  071551  064440  020163  020141  064143  071141
-.sp .5
-_str1+016:     061541  062564  020162  072163  064562  063556  0       02
-.sp .5
-_number:
-_number:       0710    0       02322   040240  0       064124  071551  064440
-.sp .5
-_str2+06:      020163  064164  020145  062563  067543  062156  061440  060550
-.sp .5
-_str2+026:     060562  072143  071145  071440  071164  067151  0147    0
-.sp .5
-savr5+02:      0       0       0       0       0       0       0       0
-.sp .5
-.ft B
-<b,20/4o4^8Cn
-.ft R
-020000:                0       064124  071551  064440  @\`@\`This i
-               020163  020141  064143  071141  s a char
-               061541  062564  020162  072163  acter st
-               064562  063556  0       02      ring@\`@\`@b@\`
-.sp .5
-_number:       0710    0       02322   040240  H@a@\`@\`R@d @@
-               0       064124  071551  064440  @\`@\`This i
-               020163  064164  020145  062563  s the se
-               067543  062156  061440  060550  cond cha
-               060562  072143  071145  071440  racter s
-               071164  067151  0147    0       tring@\`@\`@\`
-               0       0       0       0       @\`@\`@\`@\`@\`@\`@\`@\`
-               0       0       0       0       @\`@\`@\`@\`@\`@\`@\`@\`
-data address not found
-.ft B
-<b,20/4o4^8t8cna
-.ft R
-020000:                0       064124  071551  064440          This i
-_str1+06:      020163  020141  064143  071141          s a char
-_str1+016:     061541  062564  020162  072163          acter st
-_str1+026:     064562  063556  0       02              ring\ 2
-_number:
-_number:       0710    0       02322   040240          HR
-_fpt+02:       0       064124  071551  064440          This i
-_str2+06:      020163  064164  020145  062563          s the se
-_str2+016:     067543  062156  061440  060550          cond cha
-_str2+026:     060562  072143  071145  071440          racter  s
-_str2+036:     071164  067151  0147    0               tring
-savr5+02:      0       0       0       0
-savr5+012:     0       0       0       0
-data address not found
-.ft B
-<b,10/2b8t^2cn
-.ft R
-020000:                0       0
-.sp .5
-_str1:         0124    0150            Th
-               0151    0163            is
-               040     0151             i
-               0163    040             s
-               0141    040             a
-               0143    0150            ch
-               0141    0162            ar
-               0141    0143            ac
-               0164    0145            te
-.ft B
-$Q
-.sp 100
-.SH
-Figure 12:  Directory and inode dumps
-.LP
-.nf
-.ft B
-adb dir \(mi
-=nt"Inode"t"Name"
-0,\(mi1?ut14cn
-.ft R
-
-               Inode   Name
-0:             652     .
-               82      ..
-               5971    cap.c
-               5323    cap
-               0       pp
-.sp 4
-.ft B
-adb /dev/src \(mi
-.ft B
-02000>b
-?m<b
-.ft R
-new map            \`/dev/src\'
-b1 = 02000          e1 = 0100000000      f1 = 0
-b2 = 0              e2 = 0               f2 = 0
-.ft B
-$v
-.ft R
-variables
-b = 02000
-.ft B
-<b,\(mi1?"flags"8ton"links,uid,gid"8t3bn"size"8tbrdn"addr"8t8un"times"8t2Y2na
-.ft R
-02000:         flags   073145
-               links,uid,gid   0163    0164    0141
-               size    0162    10356
-               addr    28770   8236    25956   27766   25455   8236    25956   25206
-               times   1976 Feb 5 08:34:56     1975 Dec 28 10:55:15
-
-02040:         flags   024555
-               links,uid,gid   012     0163    0164
-               size    0162    25461
-               addr    8308    30050   8294    25130   15216   26890   29806   10784
-               times   1976 Aug 17 12:16:51    1976 Aug 17 12:16:51
-
-02100:         flags   05173
-               links,uid,gid   011     0162    0145
-               size    0147    29545
-               addr    25972   8306    28265   8308    25642   15216   2314    25970
-               times   1977 Apr 2 08:58:01     1977 Feb 5 10:21:44
-.\"
-.\"    Start of Summary
-.sp 100
-.TL
-ADB Summary
-.LP
-.LP
-.if t .2C
-.nr VS 9
-.nr VS 11
-.SH
-Command Summary
-.LP
-.ta .7i
-a)   formatted printing
-.sp .5
-.IP "\fB? \fIformat\fR" .7i
-print from \fIa.out\fR file according to \fIformat\fR
-.IP "\fB/ \fIformat\fR" .7i
-print from \fIcore\fR file according to \fIformat\fR
-.IP "\fB= \fIformat\fR" .7i
-print the value of \fIdot\fR
-.sp .5
-.IP "\fB?w\fR expr" .7i
-write expression into \fIa.out\fR file
-.IP "\fB/w\fR expr" .7i
-write expression into \fIcore\fR file
-.sp .5
-.IP "\fB?l\fR expr" .7i
-locate expression in \fIa.out\fR file
-.LP
-.ta .7i
-b)   breakpoint and program control
-.LP
-.ta .7i
-.nf
-.ta .7i
-\fB:b\fR       set breakpoint at \fIdot\fR
-\fB:c\fR       continue running program
-\fB:d\fR       delete breakpoint
-\fB:k\fR       kill the program being debugged
-\fB:r\fR       run \fIa.out\fR file under ADB control
-\fB:s\fR       single step
-.LP
-.ta .7i
-c)   miscellaneous printing
-.LP
-.ta .7i
-.nf
-\fB$b\fR       print current breakpoints
-\fB$c\fR       C stack trace
-\fB$e\fR       external variables
-\fB$f\fR       floating registers
-\fB$m\fR       print ADB segment maps
-\fB$q\fR       exit from ADB
-\fB$r\fR       general registers
-\fB$s\fR       set offset for symbol match
-\fB$v\fR       print ADB variables
-\fB$w\fR       set output line width
-.LP
-.ta .7i
-d)   calling the shell
-.LP
-.ta .7i
-.nf
-\fB!\fR        call \fIshell\fP to read rest of line
-.LP
-.ta .7i
-e)   assignment to variables
-.LP
-.ta .7i
-.nf
-\fB>\fIname\fR assign dot to variable or register \fIname\fR
-.sp 100
-.SH
-Format Summary
-.LP
-.ta .7i
-.nf
-\fBa   \fRthe value of dot
-\fBb   \fRone byte in octal
-\fBc   \fRone byte as a character
-\fBd   \fRone word in decimal
-\fBf   \fRtwo words in floating point
-\fBi   \fRPDP 11 instruction
-\fBo   \fRone word in octal
-\fBn   \fRprint a newline
-\fBr   \fRprint a blank space
-\fBs   \fRa null terminated character string
-\fIn\fBt       \fRmove to next \fIn\fR space tab
-\fBu   \fRone word as unsigned integer
-\fBx   \fRhexadecimal
-\fBY   \fRdate
-\fB^   \fRbackup dot
-\fB"..."\fR    print string
-.LP
-.ta .7i
-.SH
-Expression Summary
-.LP
-.ta .7i
-a) expression components
-.LP
-.ta .1.1i
-.nf
-\fBdecimal integer     \fRe.g. 256
-\fBoctal integer       \fRe.g. 0277
-\fBhexadecimal \fRe.g. #ff
-\fBsymbols     \fRe.g. flag  _main  main.argc
-\fBvariables   \fRe.g. <b
-\fBregisters   \fRe.g. <pc <r0
-\fB(expression)        \fRexpression grouping
-.LP
-.ta .7i
-b) dyadic operators
-.LP
-.ta .7i
-.nf
-\fB+\fP        add
-\fB\(mi\fP     subtract
-\fB*\fP        multiply
-\fB%\fP        integer division
-\fB&\fP        bitwise and
-\fB|\fP        bitwise or
-\fB#\fP        round up to the next multiple
-.LP
-.ta .7i
-c) monadic operators
-.LP
-.ta .7i
-.nf
-\v'.25m'\s+2\fB~\fP\s0\v'-.25m'        not
-\fB*\fR        contents of location
-\fB\(mi\fR     integer negate
-.fi
diff --git a/usr/doc/assembler b/usr/doc/assembler
deleted file mode 100644 (file)
index d9840ee..0000000
+++ /dev/null
@@ -1,1009 +0,0 @@
-.\"tbl ... ^ [tn]roff -ms
-.hc %
-.TL
-Assembler Reference Manual
-.AU
-Dennis M. Ritchie
-.AI
-.MH
-.SH
-0.  Introduction
-.PP
-This document describes the usage and input syntax
-of the \s8UNIX PDP\s10-11 assembler \fIas\fP.
-The details
-of the \s8PDP\s10-11 are not described.
-.PP
-The input syntax of the \s8UNIX\s10 assembler is generally
-similar to that of the \s8DEC\s10 assembler \s8PAL\s10-11\s8R\s10, although
-its internal workings and output format
-are unrelated.
-It may be useful to read the publication \s8DEC\s10-11-\s8ASDB\s10-\s8D\s10,
-which describes \s8PAL\s10-11\s8R\s10, although naturally
-one must use care in assuming that its rules apply
-to \fIas\fP.
-.PP
-\fIAs\fP is a rather ordinary assembler without
-macro capabilities.
-It produces an output file that contains
-relocation information and a complete
-symbol table;
-thus the output is acceptable to the \s8UNIX\s10 link-editor
-\fIld\fP, which
-may be used to combine the outputs of several
-assembler runs and to obtain
-object programs from libraries.
-The output format has been designed
-so that if a program contains no unresolved
-ref%er%ences to external symbols, it is executable
-without further processing.
-.SH
-1.  Usage
-.PP
-\fIas\fP is used as follows:
-.DS
-as \fR[\fB \-u \fR] [ \fB\-o \fIoutput\fR ] \fIfile\s6\d1\u\s10 .\|.\|.
-.DE
-If the optional ``\-u'' argument is
-given, all undefined symbols
-in the current assembly will be made undefined-external.
-See the \fB.globl\fR directive below.
-.PP
-The other arguments name files
-which are concatenated and assembled.
-Thus programs may be written in several
-pieces and assembled together.
-.PP
-The output of the assembler is by default placed on
-the file \fIa.out\fR in the current directory;
-the ``\-o'' flag causes the output to be placed on the named file.
-If there were no unresolved
-external ref%er%ences, and no errors detected,
-the output file is marked executable; otherwise, if it is
-produced at all, it is made non-executable.
-.SH
-2.  Lexical conventions
-.PP
-Assembler tokens include identifiers (alternatively, ``symbols'' or ``names''),
-temporary symbols,
-constants, and operators.
-.SH
-2.1  Identifiers
-.PP
-An identifier consists of a sequence of alphanumeric characters (including
-period ``\|\fB.\fR\|'', underscore ``\(ul'',
-and tilde ``~''
-as alphanumeric)
-of which the first may not
-be numeric.
-Only the first eight characters are significant.
-When a name begins with a tilde, the tilde is discarded
-and that occurrence of the identifier generates
-a unique entry in the symbol table which can match
-no other occurrence of the identifier.
-This feature is used
-by the C compiler to place names of local variables
-in the output symbol table
-without having to worry
-about 
-making them unique.
-.SH
-2.2  Temporary symbols
-.PP
-A temporary symbol consists of a digit followed by ``f\|'' or
-``b''.
-Temporary symbols are discussed fully in \(sc5.1.
-.SH
-2.3  Constants
-.PP
-An octal constant consists of a sequence of digits; ``8'' and
-``9'' are taken to have octal value 10 and 11.
-The constant
-is truncated to 16 bits and interpreted in two's complement
-notation.
-.PP
-A decimal constant consists of a sequence of digits terminated
-by a decimal point ``\fB.\fR''.  The magnitude of the constant should be
-representable in 15 bits; i.e., be less than 32,768.
-.PP
-A single-character constant consists of a single quote ``\|\(fm\|''
-followed by an \s8ASCII\s10 character not a new-line.
-Certain dual-character escape sequences
-are acceptable in place of the \s8ASCII\s10 character to represent
-new-line and other non-graphics (see \fIString state%ments\fP, \(sc5.5).
-The constant's value has the code for the
-given character in the least significant
-byte of the word and is null-padded on the left.
-.PP
-A double-character constant consists of a double
-quote ``\|"\|'' followed by a pair of \s8ASCII\s10 characters
-not including new-line.
-Certain dual-character escape sequences are acceptable
-in place of either of the \s8ASCII\s10 characters
-to represent new-line and other non-graphics
-(see \fIString state%ments\fR, \(sc5.5).
-The constant's value has the code for the first
-given character in the least significant
-byte and that for the second character in
-the most significant byte.
-.SH
-2.4  Operators
-.PP
-There are several single- and double-character
-operators; see \(sc6.
-.SH
-2.5  Blanks
-.PP
-Blank and tab characters
-may be interspersed freely between tokens, but may
-not be used within tokens (except character constants).
-A blank or tab is required to separate adjacent
-identifiers or constants not otherwise separated.
-.SH
-2.6  Comments
-.PP
-The character ``\|/\|'' introduces a comment, which extends
-through the end of the line on which it appears.
-Comments are ignored by the assembler.
-.SH
-3.  Segments
-.PP
-Assembled code and data
-fall into three segments: the text segment, the data segment, and the bss segment.
-The text segment is the one in which the assembler begins,
-and it is the one into which instructions are typically placed.
-The \s8UNIX\s10 system will, if desired,
-enforce the purity of the text segment of programs by
-trapping write operations
-into it.
-Object programs produced by the assembler must be processed
-by the link-editor \fIld\fR
-(using its ``\-n'' flag)
-if the text segment is to be write-protected.
-A single copy of the text
-segment is shared among all processes
-executing such a program.
-.PP
-The data segment is available for placing
-data or instructions which
-will be modified during execution.
-Anything which may go in the text segment may be put
-into the data segment.
-In programs with write-protected, sharable text segments,
-data segment contains the initialized but variable
-parts of a program.
-If the text segment is not pure, the data segment begins
-immediately after the
-text segment;
-if the text segment is pure, the data segment begins at the lowest
-8K byte boundary after the text segment.
-.PP
-The bss segment may not contain any explicitly initialized code
-or data.
-The length of the bss segment (like that of text or data)
-is determined by the high-water mark of the location counter
-within it.
-The bss segment is actually an extension of
-the data segment and begins immediately after it.
-At the start of execution of a program, the bss segment
-is set to 0.
-Typically the bss segment is set up
-by state%ments exemplified by
-.DS
-lab\fB: .\fR = \fB.\fR+10
-.DE
-The advantage in using the bss segment
-for storage that starts off empty is that the initialization
-information need not be stored in the output file.
-See also \fILocation counter\fP and \fIAssignment state%ments\fP
-below.
-.SH
-4.  The location counter
-.PP
-One special symbol, ``\|\fB.\fP\|'', is the location counter.
-Its value at any time is the offset
-within the appropriate segment of the start of
-the state%ment in which it appears.
-The location counter may be assigned to,
-with the restriction that the
-current segment may not change;
-furthermore,
-the value of ``\|\fB.\fP\|'' may not decrease.
-If the effect of the assignment is to increase the value of ``\|\fB.\fP\|'',
-the required number of null bytes are generated
-(but see \fISegments\fP above).
-.SH
-5.  Statements
-.PP
-A source program is composed of a sequence of
-\fIstate%ments\fP.
-Statements are separated either by new-lines
-or by semicolons.
-There are five kinds of state%ments: null state%ments,
-expression state%ments, assignment state%ments,
-string state%ments,
-and keyword state%ments.
-.PP
-Any kind of state%ment may be preceded by
-one or more labels.
-.SH
-5.1  Labels
-.PP
-There are two kinds of label:
-name labels and numeric labels.
-A name label consists of a name followed
-by a colon (\|:\|).
-The effect of a name label is to assign the current
-value and type of the location counter ``\|\fB.\fP\|''
-to the name.
-An error is indicated in pass 1 if the
-name is already defined;
-an error is indicated in pass 2 if the ``\|\fB.\fP\|''
-value assigned changes the definition
-of the label.
-.PP
-A numeric label consists of a digit \fI0\fR to \fI9\fR followed by a colon (\|:\|).
-Such a label serves to define temporary
-symbols of the form ``\fIn\fR\|b'' and ``\fIn\fR\|f\|'', where \fIn\fR is
-the digit of the label.
-As in the case of name labels, a numeric label assigns
-the current value and type of ``\|\fB.\fP\|'' to the temporary
-symbol.
-However, several numeric labels with the same
-digit may be used within the same assembly.
-Ref%er%ences of the form ``\fIn\fR\|f\|'' refer to the first
-numeric label ``\fIn\|\fR:'' \fIf\fR\|orward from the ref%er%ence;
-``\fIn\|\fRb'' symbols refer to the first ``\fIn\|\fR\|:'' label
-\fIb\|\fRackward from the ref%er%ence.
-This sort of temporary label was introduced by Knuth
-[\fIThe Art of Computer Programming, Vol I: Fundamental Algorithms\|\fR].
-Such labels tend to conserve both the symbol table
-space of the assembler and the
-inventive powers of the programmer.
-.SH
-5.2  Null state%ments
-.PP
-A null state%ment is an empty state%ment (which may, however,
-have labels).
-A null state%ment is ignored by the assembler.
-Common examples of null state%ments are empty
-lines or lines containing only a label.
-.SH
-5.3  Expression state%ments
-.PP
-An expression state%ment consists of an arithmetic
-expression not beginning with
-a keyword.
-The assembler computes its (16-bit) value
-and places it in the output stream, together with the
-appropriate relocation bits.
-.SH
-5.4  Assignment state%ments
-.PP
-An assignment state%ment consists of an identifier, an equals sign (\|=\|),
-and an expression.
-The value and type of the expression are assigned to
-the identifier.
-It is not required that the type or value be
-the same in pass 2 as in pass 1, nor is it an
-error to redefine any symbol by assignment.
-.PP
-Any external attribute of the expression is lost across
-an assignment.
-This means that it is not possible to declare a global
-symbol by assigning to it, and that it is impossible
-to define a symbol to be offset from a non-locally
-defined global symbol.
-.PP
-As mentioned,
-it is permissible to assign to the
-location counter ``\|\fB.\fP\|''.
-It is required, however, that the type of
-the expression assigned be of the same type
-as ``\|\fB.\fP\|'',
-and it is forbidden to decrease the value
-of ``\fB\|.\|\fR''.
-In practice, the most common assignment to ``\|\fB.\fP\|'' has the form
-``.\|=\|.\|+\|\fIn\fR''
-for some number \fIn;\fR this has the effect of generating
-\fIn\fR null bytes.
-.SH
-5.5  String state%ments
-.PP
-A string state%ment generates a sequence of bytes containing \s8ASCII\s10 characters.
-A string state%ment consists of a left string quote ``<''
-followed by a sequence of \s8ASCII\s10 characters not including newline,
-followed by a right string quote ``>''.
-Any of the \s8ASCII\s10 characters may
-be replaced by a two-character escape sequence to represent
-certain non-graphic characters, as follows:
-.DS C
-.TS
-l l l.
-\en    \s8NL\s10       (012)
-\es    \s8SP\s10       (040)
-\et    \s8HT\s10       (011)
-\ee    \s8EOT\s10      (004)
-\e0    \s8NUL\s10      (000)
-\er    \s8CR\s10       (015)
-\ea    \s8ACK\s10      (006)
-\ep    \s8PFX\s10      (033)
-\e\e   \e
-\e>    >
-.TE
-.DE
-The last two are included so that the escape character
-and the right string quote may be represented.
-The same escape sequences
-may also be used within single- and double-character
-constants (see \(sc2.3 above).
-.SH
-5.6  Keyword state%ments
-.PP
-Keyword state%ments are numerically the most common type,
-since most machine instructions are of this
-sort.
-A keyword state%ment begins with one of the many predefined
-keywords of the assembler;
-the syntax of the remainder depends
-on the keyword.
-All the keywords are listed below with the syntax they require.
-.SH
-6.  Expressions
-.PP
-An expression is a sequence of symbols representing a value.
-Its constituents are identifiers, constants, temporary symbols,
-operators, and brackets.
-Each expression has a type.
-.PP
-All operators in expressions are fundamentally binary in
-nature; if an operand is missing on the left, a 0
-of absolute type is assumed.
-Arithmetic
-is two's complement and has 16 bits of precision.
-All operators have equal precedence, and expressions
-are evaluated
-strictly left to right except for the effect
-of brackets.
-.SH
-6.1  Expression operators
-.PP
-The operators are:
-.IP (blank) 8
-when there is no operand between
-operands, the effect is
-exactly the same as if a ``+'' had appeared.
-.pg
-.ti 0
-.IP + 8
-addition
-.IP \- 8
-subtraction
-.IP * 8
-multiplication
-.IP \e\(sl 8
-division (note that plain ``\|/\|'' starts a comment)
-.IP 8 & 8
-bitwise \fBand\fR
-.IP \(bv 8
-bitwise \fBor\fR
-.IP \e> 8
-logical right shift
-.IP \\e< 8
-logical left shift
-.hc
-.IP % 8
-modulo
-.IP ! 8
-.hc %
-\fIa\fR\|!\|\fIb\fR is \fIa \fBor \fR(\|\fBnot \fIb\fR\|);
-i.e., the \fBor\fR of the first operand and
-the one's complement of the second; most common use is
-as a unary.
-.IP ^ 8
-result has the value of first operand and the type of the second;
-most often used to define new machine instructions
-with syntax identical to existing instructions.
-.PP
-Expressions may be grouped by use of square brackets ``\|[\|\|]\|''.
-(Round parentheses are reserved for address modes.)
-.SH
-6.2  Types
-.PP
-The assembler deals with a number of types
-of expressions.  Most types
-are attached to keywords and used to select the
-routine which treats that keyword.  The types likely
-to be met explicitly are:
-.IP undefined 8
-.br
-Upon first encounter, each symbol is undefined.
-It may become undefined if it is assigned an undefined expression.
-It is an error to attempt to assemble an undefined
-expression in pass 2; in pass 1, it is not (except that
-certain keywords require operands which are not undefined).
-.IP "undefined external" 8
-.br
-A symbol which is declared \fB.globl\fR but not defined
-in the current assembly is an undefined
-external.
-If such a symbol is declared, the link editor \fIld\fR
-must be used to load the assembler's output with
-another routine that defines the undefined ref%er%ence.
-.IP absolute 8
-An absolute symbol is defined ultimately from a constant.
-Its value is unaffected by any possible future applications
-of the link-editor to the output file.
-.IP text 8
-The value of a text symbol is measured
-with respect to the beginning of the text segment of the program.
-If the assembler output is link-edited, its text
-symbols may change in value
-since the program need
-not be the first in the link editor's output.
-Most text symbols are defined by appearing as labels.
-At the start of an assembly, the value of ``\|\fB.\fP\|'' is text 0.
-.IP data 8
-The value of a data symbol is measured
-with respect to the origin of the data segment of a program.
-Like text symbols, the value of a data symbol may change
-during a subsequent link-editor run since previously
-loaded programs may have data segments.
-After the first \fB.data\fR state%ment, the value of ``\|\fB.\fP\|''
-is data 0.
-.IP bss 8
-The value of a bss symbol is measured from
-the beginning of the bss segment of a program.
-Like text and data symbols, the value of a bss symbol
-may change during a subsequent link-editor
-run, since previously loaded programs may have bss segments.
-After the first \fB.bss\fR state%ment, the value of ``\|\fB.\fP\|'' is bss 0.
-.IP "external absolute, text, data, or bss" 8
-.br
-symbols declared \fB.globl\fR
-but defined within an assembly as absolute, text, data, or bss
-symbols may be used exactly as if they were not
-declared \fB.globl\fR; however, their value and type are available
-to the link editor so that the program may be loaded with others
-that ref%er%ence these symbols.
-.IP register 8
-.br
-The symbols
-.DS
-\fBr0\fR  .\|.\|. \fBr5
-fr0\fR  .\|.\|. \fBfr5
-sp
-pc
-.DE
-are predefined
-as register symbols.
-Either they or symbols defined from them must
-be used to refer to the six general-purpose,
-six floating-point, and
-the 2 special-purpose machine registers.
-The behavior of the floating register names
-is identical to that of the corresponding
-general register names; the former
-are provided as a mnemonic aid.
-.IP "other types" 8
-.br
-Each keyword known to the assembler has a type which
-is used to select the routine which processes
-the associated keyword state%ment.
-The behavior of such symbols
-when not used as keywords is the same as if they were absolute.
-.SH
-6.3  Type propagation in expressions
-.PP
-When operands are combined by expression operators,
-the result has a type which depends on the types
-of the operands and on the operator.
-The rules involved are complex to state but
-were intended to be sensible and predictable.
-For purposes of expression evaluation the
-important types are
-.DS
-undefined
-absolute
-text
-data
-bss
-undefined external
-other
-.DE
-The combination rules are then:
-If one of the operands
-is undefined, the result is undefined.
-If both operands are absolute, the result is absolute.
-If an absolute is combined with one of the ``other types''
-mentioned above,
-or with a register expression, the result
-has the register or other type.
-As a consequence,
-one can refer to r3 as ``r0+3''.
-If two operands of ``other type'' are combined,
-the result has the
-numerically larger type
-An ``other type'' combined with an explicitly
-discussed type other than absolute
-acts like an absolute.
-.PP
-Further rules applying to particular operators
-are:
-.IP +
-If one operand is text-, data-, or bss-segment
-relocatable, or is an undefined external,
-the result has the postulated type and the other operand
-must be absolute.
-.IP \-
-If the first operand is a relocatable
-text-, data-, or bss-segment symbol, the second operand
-may be absolute (in which case the result has the
-type of the first operand);
-or the second operand may have the same type
-as the first (in which case the result is absolute).
-If the first operand is external undefined, the second must be
-absolute.
-All other combinations are illegal.
-.IP ^
-This operator follows no other rule than
-that the result has the value
-of the first operand and the type of the second.
-.PP
-.IP others
-.br
-It is illegal to apply these operators to any but absolute
-symbols.
-.SH
-7.  Pseudo-operations
-.PP
-The keywords listed below introduce
-state%ments that generate data in unusual forms or
-influence the later operations of the assembler.
-The metanotation
-.DS
-[ stuff ] .\|.\|.
-.DE
-means that 0 or more instances of the given stuff may appear.
-Also, boldface tokens are literals, italic words
-are substitutable.
-.SH
-7.1  \fB.byte  \fIexpression  \fR[  \fB, \fIexpression \fR]  .\|.\|.
-.PP
-The \fIexpression\fRs in the comma-separated
-list are truncated to 8 bits and assembled in successive
-bytes.
-The expressions must be absolute.
-This state%ment and the string state%ment above are the only ones
-that assemble data one byte at at time.
-.SH
-7.2  \fB.even\fR
-.PP
-If the location counter ``\|\fB.\fP\|'' is odd, it is advanced by one
-so the next state%ment will be assembled
-at a word boundary.
-.SH
-7.3  \fB.if  \fIexpression\fR
-.PP
-The \fIexpression\fR must be absolute and defined in pass 1.
-If its value is nonzero, the \fB.if\fR is ignored; if zero,
-the state%ments between the \fB.if\fR and the matching \fB.endif\fR
-(below) are ignored.
-\&\fB.if\fR may be nested.
-The effect of \fB.if\fR cannot extend beyond
-the end of the input file in which it appears.
-(The state%ments are not totally ignored, in
-the following
-sense: \fB.if\fRs and \fB.endif\fRs are scanned for, and
-moreover all names
-are entered in the symbol table.
-Thus names occurring only inside
-an \fB.if\fR
-will show up as undefined if the symbol
-table is listed.)
-.SH
-7.4  \fB.endif\fR
-.PP
-This state%ment marks the end of a conditionally-assembled section of code.
-See \fB.if\fR above.
-.SH
-7.5  \fB.globl  \fIname  \fR[  \fB,\fI  name  \fR]  .\|.\|.
-.PP
-This state%ment makes the \fInames\fR external.
-If they are otherwise defined (by assignment or
-appearance as a label)
-they act within the assembly exactly as if
-the \fB.globl\fR state%ment were not given; however,
-the link editor \fIld\fR may be used
-to combine this routine with other routines that refer
-these symbols.
-.PP
-Conversely, if the given symbols are not defined
-within the current assembly, the link editor
-can combine the output of this assembly
-with that of others which define the symbols.
-As discussed in \(sc1, it is possible to force
-the assembler to make all otherwise
-undefined symbols external.
-.SH
-7.6  \fB.text\fR
-.SH
-7.7  \fB.data\fR
-.SH
-7.8  \fB.bss\fR
-.PP
-These three pseudo-operations cause the
-assembler to begin assembling into the text, data, or
-bss segment respectively.
-Assembly starts in the text segment.
-It is forbidden to assemble any
-code or data into the bss segment, but symbols may
-be defined and ``\|\fB.\fP\|'' moved about by assignment.
-.SH
-7.9  \fB.comm\fI  name  \fB,  \fIexpression\fR
-.PP
-Provided the \fIname\fR is not defined elsewhere,
-this state%ment is equivalent to
-.DS
-\&.globl  name
-name = expression ^ name
-.DE
-That is, the type of \fIname\fR
-is ``undefined external'', and its value is \fIexpression\fR.
-In fact the \fIname\fR behaves
-in the current assembly just like an
-undefined external.
-However, the link-editor \fIld\fR has been special-cased
-so that all external symbols which are not
-otherwise defined, and which have a non-zero
-value, are defined to lie in the bss
-segment, and enough space is left after the
-symbol to hold \fIexpression\fR
-bytes.
-All symbols which become defined in this way
-are located before all the explicitly defined
-bss-segment locations.
-.SH
-8.   Machine instructions
-.PP
-Because of the rather complicated instruction and addressing
-structure of the \s8PDP\s10-11, the syntax of machine instruction
-state%ments is varied.
-Although the following sections give the syntax
-in detail, the machine handbooks should
-be consulted on the semantics.
-.SH
-8.1  Sources and Destinations
-.PP
-The syntax of general source and destination
-addresses is the same.
-Each must have one of the following forms,
-where \fIreg\fR is a register symbol, and \fIexpr\fR
-is any sort of expression:
-.DS C
-.TS
-c c c
-l l l.
-syntax words   mode
-_
-\fIreg\fR      0       00+\fIreg\fB
-(\|\fIreg\fB\|)\|+     \fR0    20+\fIreg\fB
-\fB\-\|(\|\fIreg\fB\|) \fR0    40+\fIreg\fR
-\fIexpr\|\fB(\|\fIreg\fB\|)    \fR1    60+\fIreg\fB
-(\|\fIreg\fB\|)        \fR0    10+\fIreg\fB
-*\|\fIreg\fB   \fR0    10+\fIreg\fB
-\fB*\|(\|\fIreg\fB\|)\|+       \fR0    30+\fIreg\fB
-\fB*\|\-\|(\|\fIreg\fB\|)      \fR0    50+\fIreg\fB
-*\|(\|\fIreg\fB\|)     \fR1    70+\fIreg\fB
-\fB*\|\fIexpr\fB\|(\|\fIreg\fB\|)      \fR1    70+\fIreg\fB
-\fIexpr        \fR1    67
-\fB$\|\fIexpr  \fR1    27
-\fB*\|\fIexpr  \fR1    77
-\fB*\|$\|\fIexpr       \fR1    37
-.TE
-.DE
-The \fIwords\fR column gives the number of address words generated;
-the \fImode\fR column gives the octal address-mode number.
-The syntax of the address forms is
-identical to that in \s8DEC\s10 assemblers, except that ``*'' has
-been substituted for ``@''
-and ``$'' for ``#''; the \s8UNIX\s10 typing conventions make ``@'' and ``#''
-rather inconvenient.
-.PP
-Notice that mode ``*reg'' is identical to ``(reg)'';
-that ``*(reg)'' generates an index word (namely, 0);
-and that addresses consisting of an unadorned expression
-are assembled as pc-relative ref%er%ences independent
-of the type of the expression.
-To force a non-relative ref%er%ence, the form ``*$expr'' can
-be used, but notice that further indirection is impossible.
-.SH
-8.3  Simple machine instructions
-.PP
-The following instructions
-are defined as absolute symbols:
-.KS
-.DS
-.ft B
-clc
-clv
-clz
-cln
-sec
-sev
-sez
-sen
-.DE
-.KE
-They therefore require
-no special syntax.
-The \s8PDP\s10-11 hardware allows more than one of the ``clear''
-class, or alternatively more than one of the ``set'' class
-to be \fBor\fR-ed together; this may be expressed as follows:
-.DS
-clc\|\|\|\(bv\|\|clv
-.DE
-.SH
-8.4  Branch
-.PP
-The following instructions take an expression as operand.
-The expression must lie in the same segment as the ref%er%ence,
-cannot be undefined-external,
-and its value cannot differ from the current location of ``\|\fB.\fP\|''
-by more than 254 bytes:
-.KS
-.DS
-.ft B
-.ta 1.5i 2.5i
-br     blos
-bne    bvc
-beq    bvs
-bge    bhis
-blt    bec     \fR(=\fB bcc\fR)\fB
-bgt    bcc
-ble    blo
-bpl    bcs
-bmi    bes     \fR(=\fB bcs\fR)\fB
-bhi
-.DE
-.KE
-\fBbes\fR (``branch on error set'')
-and \fBbec\fR (``branch on error clear'')
-are intended to test the error bit
-returned by system calls (which
-is the c-bit).
-.SH
-8.5   Extended branch instructions
-.PP
-The following symbols are followed by an expression
-representing an address
-in the same segment as ``\|\fB.\|\fP''.
-If the target address is close enough,
-a branch-type instruction is generated;
-if the address is too far away,
-a \fBjmp\fR will be used.
-.pg
-.KS
-.DS
-.ft B
-.ta 1.5i
-jbr    jlos
-jne    jvc
-jeq    jvs
-jge    jhis
-jlt    jec
-jgt    jcc
-jle    jlo
-jpl    jcs
-jmi    jes
-jhi
-.DE
-.KE
-\fBjbr\fR turns into a plain \fBjmp\fR
-if its target is too remote;
-the others (whose names are contructed
-by replacing the ``b'' in the branch instruction's
-name by ``j''\|)
-turn into the converse branch over a \fBjmp\fR
-to the target address.
-.SH
-8.6  Single operand instructions
-.PP
-The following
-symbols are names of single-operand
-machine instructions.
-The form
-of address expected is discussed in \(sc8.1 above.
-.KS
-.DS
-.ta 1.5i
-clr    sbcb
-clrb   ror
-com    rorb
-comb   rol
-inc    rolb
-incb   asr
-dec    asrb
-decb   asl
-neg    aslb
-negb   jmp
-adc    swab
-adcb   tst
-sbc    tstb
-.DE
-.KE
-.SH
-8.7  Double operand instructions
-.PP
-The following instructions take a general source
-and destination (\(sc8.1), separated by a comma, as operands.
-.KS
-.DS
-.ft B
-.ta 1.5i
-mov
-movb
-cmp
-cmpb
-bit
-bitb
-bic
-bicb
-bis
-bisb
-add
-sub
-.DE
-.KE
-.SH
-8.8  Miscellaneous instructions
-.PP
-The following instructions have
-more specialized syntax.
-Here \fIreg\fR is
-a register name, \fIsrc\fR and \fIdst\fR a general source
-or destination
-(\(sc8.1), and \fIexpr\fR is an expression:
-.KS
-.DS
-.ta .5i 2i
-\fBjsr\fI      reg,dst
-\fBrts\fI      reg
-\fBsys\fI      expr
-\fBash \fIsrc\|,\|reg  \fR(or, \fBals\fR)\fB
-\fBashc        \fIsrc\|,\|reg  \fR(or, \fBalsc\fR)\fB
-\fBmul \fIsrc\|,\|reg  \fR(or, \fBmpy\fR)\fB
-\fBdiv \fIsrc\|,\|reg  \fR(or, \fBdvd\fR)\fR
-\fBxor \fIreg\|,\|dst\fB
-\fBsxt \fIdst\fB
-\fBmark        \fIexpr\fB
-\fBsob \fIreg\|,\|expr\fB
-.DE
-.KE
-\fBsys\fR is another name for the \fBtrap\fR instruction.
-It is used to code system calls.
-Its operand is required to be expressible in 6 bits.
-The expression in \fBmark\fR must be expressible
-in six bits, and the expression in \fBsob\fR must
-be in the same segment as ``\fB\|.\|\fR'',
-must not be external-undefined, must be less than ``\|\fB.\fR\|'',
-and must be within 510 bytes of ``\|\fB.\fR\|''.
-.SH
-8.9  Floating-point unit instructions
-.PP
-The following floating-point operations are defined,
-with syntax as indicated:
-.KS
-.DS
-.ta .5i 2i
-\fBcfcc
-\fBsetf
-\fBsetd
-\fBseti
-\fBsetl
-\fBclrf        \fIfdst
-\fBnegf        \fIfdst
-\fBabsf        \fIfdst
-\fBtstf        \fIfsrc
-\fBmovf        \fIfsrc,\|freg  \fR(= ldf\fR\|)
-\fBmovf        \fIfreg,\|fdst  \fR(= stf\fR\|)
-\fBmovif       \fIsrc,\|freg   \fR(= ldcif\fR\|)
-\fBmovfi       \fIfreg,\|dst   \fR(= stcfi\fR\|)
-\fBmovof       \fIfsrc,\|freg  \fR(= ldcdf\fR\|)
-\fBmovfo       \fIfreg,\|fdst  \fR(= stcfd\fR\|)
-\fBmovie       \fIsrc,\|freg   \fR(= ldexp\fR)
-\fBmovei       \fIfreg,\|dst   \fR(= stexp\fR)
-\fBaddf        \fIfsrc,\|freg
-\fBsubf        \fIfsrc,\|freg
-\fBmulf        \fIfsrc,\|freg
-\fBdivf        \fIfsrc,\|freg
-\fBcmpf        \fIfsrc,\|freg
-\fBmodf        \fIfsrc,\|freg
-\fBldfps       \fIsrc
-\fBstfps       \fIdst
-\fBstst        \fIdst\fR
-.DE
-.KE
-\fIfsrc\fR, \fIfdst\fR, and \fIfreg\fR mean floating-point
-source, destination, and register respectively.
-Their syntax is identical to that for
-their non-floating counterparts, but
-note that only
-floating registers 0-3 can be a \fIfreg\fR.
-.PP
-The names of several of the operations
-have been changed to bring out an analogy with
-certain fixed-point instructions.
-The only strange case is \fBmovf\fR, which turns into
-either \fBstf\fR or \fBldf\fR
-depending respectively on whether its first operand is
-or is not a register.
-Warning:  \fBldf\fR sets the floating condition codes,
-\fBstf\fR does not.
-.SH
-9.  Other symbols
-.SH
-9.1  \fB.\|.\fR
-.PP
-The symbol ``\fB\|.\|.\|\fR''
-is the
-\fIrelocation counter\fR.
-Just before each assembled word is placed in the output stream,
-the current value of this symbol is added to the word
-if the word refers to a text, data or bss segment location.
-If the output word is a pc-relative address word
-that refers to an absolute location,
-the value of ``\fB\|.\|.\|\fR'' is subtracted.
-.PP
-Thus the value of ``\fB\|.\|.\|\fR'' can be taken to mean
-the starting memory location of the program.
-The initial value of ``\|\fB.\|.\fR\|'' is 0.
-.PP
-The value of ``\|\fB.\|.\fR\|'' may be changed by assignment.
-Such a course of action is sometimes
-necessary, but the consequences
-should be carefully thought out.
-It is particularly ticklish
-to change ``\|\fB.\|.\fR\|'' midway in an assembly
-or to do so in a program which will
-be treated by the loader, which has
-its own notions of ``\|\fB.\|.\fR\|''.
-.SH
-9.2  System calls
-.PP
-System call names are not predefined.
-They may be found in the file
-.I /usr/include/sys.s
-.SH
-10.  Diagnostics
-.PP
-When
-an input file cannot be read, its name
-followed by a question mark is typed and assembly
-ceases.
-When syntactic or semantic errors occur, a single-character diagnostic is typed out
-together with the line number and the file name in which it
-occurred.  Errors in pass 1 cause cancellation of pass 2.
-The possible errors are:
-.KS
-.DS
-.ta .3i
-)       parentheses error
-]       parentheses error
->       string not terminated properly
-*       indirection (\|*\|) used illegally
-\&\fB.\fR       illegal assignment to ``\|\fB.\fR\|''
-\s8A\s10        error in address
-\s8B\s10        branch address is odd or too remote
-\s8E\s10        error in expression
-\s8F\s10        error in local (``f\|'' or ``b'') type symbol
-\s8G\s10        garbage (unknown) character
-\s8I\s10        end of file inside an \fB.if\fR
-\s8M\s10        multiply defined symbol as label
-\s8O\s10        word quantity assembled at odd address
-\s8P\s10        phase error\(em ``\|\fB.\fP\|'' different in pass 1 and 2
-\s8R\s10        relocation error
-\s8U\s10        undefined symbol
-\s8X\s10        syntax error
-.DE
-.KE
diff --git a/usr/doc/ctour/ios.r b/usr/doc/ctour/ios.r
new file mode 100644 (file)
index 0000000..9b8a1e9
--- /dev/null
@@ -0,0 +1,417 @@
+.de sr
+.sp 1
+.ft I
+.ne 2
+\\$1
+.if t .sp .2
+.br
+.ft R
+..
+.de it
+\fI\\$1\fR
+..
+.TL
+A New Input-Output Package
+.AU
+D. M. Ritchie
+.PP
+A new package of IO routines is available under the Unix system.
+It was designed with the following goals in mind.
+.IP 1.
+It should be similar in spirit to the earlier Portable
+Library, and, to the extent possible, be compatible with it.
+At the same time a few dubious design choices
+in the Portable Library will be corrected.
+.IP 2.
+It must be as efficient as possible, both in time and in space,
+so that there will be no hesitation in using it
+no matter how critical the application.
+.IP 3.
+It must be simple to use, and also free of the magic
+numbers and mysterious calls the use
+of which mars the understandability and portability
+of many programs using older packages.
+.IP 4.
+The interface provided should be applicable on all machines,
+whether or not the programs which implement it are directly portable
+to other systems,
+or to machines other than the PDP11 running a version of Unix.
+.PP
+It is intended that this package replace the Portable Library.
+Although it is not directly compatible, as discussed below,
+it is sufficiently similar that
+a set of relatively small, inexpensive adaptor routines
+exist which make it appear identical to the current Portable Library
+except in some very obscure details.
+.PP
+The most crucial difference between this package and the Portable
+Library is that the current offering names streams in terms
+of pointers rather than by
+the integers known as `file descriptors.'
+Thus, for example, the routine which opens a named file
+returns a pointer to a certain structure rather than a number;
+the routine which reads an open file
+takes as an argument the pointer returned from the open call.
+.SH
+General Usage
+.RT
+Each program using the library must have the line
+.DS
+               #include <stdio.h>
+.DE
+which defines certain macros and variables.
+The library containing the routines is `/usr/lib/libS.a,'
+so the command to compile is
+.DS
+               cc  . . .  \-lS
+.DE
+All names in the include file intended only for internal use begin
+with an underscore `\_' to reduce the possibility
+of collision with a user name.
+The names intended to be visible outside the package are
+.IP stdin 10
+The name of the standard input file
+.IP stdout 10
+The name of the standard output file
+.IP stderr 10
+The name of the standard error file
+.IP EOF 10
+is actually \-1, and is the value returned by
+the read routines on end-of-file or error.
+.IP NULL 10
+is a notation for the null pointer, returned by
+pointer-valued functions
+to indicate an error
+.IP FILE 10
+expands to `struct \_iob' and is a useful
+shorthand when declaring pointers
+to streams.
+.IP BUFSIZ
+is a number (viz. 512)
+of the size suitable for an IO buffer supplied by the user.
+See
+.it setbuf,
+below.
+.IP "getc, getchar, putc, putchar, feof, ferror, fileno" 10
+
+.br
+are defined as macros.
+Their actions are described below;
+they are mentioned here
+to point out that it is not possible to
+redeclare them
+and that they are not actually functions;
+thus, for example, they may not have breakpoints set on them.
+.PP
+The routines in this package, like the current Portable
+Library,
+offer the convenience of automatic buffer allocation
+and output flushing where appropriate.
+Absent, however, is the facility
+of changing the default input and output streams
+by assigning to `cin' and `cout.'
+The names `stdin,' stdout,' and `stderr'
+are in effect constants and may not be assigned to.
+.SH
+Calls
+.RT
+The routines in the library are in nearly one-to-one
+correspondence with those in the Portable Library.
+In several cases the name has been changed.
+This is an attempt to reduce confusion.
+If the attempt is judged to fail the names may be made identical even
+though
+the arguments may be different.
+The order of this list generally follows the order
+used in the Portable Library document.
+.sr "FILE *fopen(filename, type)"
+.it Fopen
+opens the file and, if needed, allocates a buffer for it.
+.it Filename
+is a character string specifying the name.
+.it Type
+is a character string (not a single character).
+It may be `"r",' `"w",' or `"a"' to indicate
+intent to read, write, or append.
+The value returned is a file pointer.
+If it is null the attempt to open failed.
+.sr "int getc(ioptr)"
+returns the next character from the stream named by
+.it ioptr,
+which is a pointer to a file such as returned by
+.it fopen,
+or the name
+.it stdin.
+The integer EOF is returned on end-of-file or when
+an error occurs.
+The null character is a legal character.
+.sr "putc(c, ioptr)"
+.it Putc
+writes the character
+.it c
+on the output stream named by
+.it ioptr,
+which is a value returned from
+.it fopen
+or perhaps
+.it stdout
+or
+.it stderr.
+The character is returned as value,
+but EOF is returned on error.
+.sr fclose(ioptr)
+The file corresponding to
+.it ioptr
+is closed after any buffers are emptied.
+A buffer allocated by the IO system is freed.
+.it Fclose
+is automatic on normal termination of the program.
+.sr fflush(ioptr)
+Any buffered information on the (output) stream named by
+.it ioptr
+is written out.
+Output files are normally buffered
+if and only if they are not directed to the terminal,
+but
+.it stderr
+is unbuffered unless
+.it setbuf
+is used.
+.sr exit(errcode)
+.it Exit
+terminates the process and returns its argument as status
+to the parent.
+This is a special version of the routine
+which calls
+.it fflush
+for each output file.
+To terminate without flushing,
+use
+.it \_exit.
+.sr feof(ioptr)
+returns non-zero when end-of-file
+has occurred on the specified input stream.
+.sr ferror(ioptr)
+returns non-zero when an error has occurred while reading
+or writing the named stream.
+The error indication lasts until the file has been closed.
+.sr "getchar( )"
+is identical to `getc(stdin)'.
+.sr "putchar(c)"
+is identical to `putc(c, stdout)'.
+.sr "char *gets(s)"
+reads characters up to a new-line from the standard input.
+The new-line character is replaced by a null character.
+It is the user's responsibility to make sure that the character array
+.it s
+is large enough.
+.it Gets
+returns its argument, or null if end-of-file or error occurred.
+.sr "char *fgets(s, n, ioptr)"
+reads up to
+.it n
+characters from the stream
+.it ioptr
+into the character pointer
+.it s.
+The read terminates with a new-line character.
+The new-line character is placed in the buffer
+followed by a null pointer.
+The first argument,
+or a null pointer if error or end-of-file occurred,
+is returned.
+.sr puts(s)
+writes the null-terminated string (character array)
+.it s
+on the standard output.
+A new-line is appended.
+No value is returned.
+.sr "fputs(s, ioptr)"
+writes the null-terminated string (character array)
+on the stream
+.it s.
+No new-line is appended.
+No value is returned.
+.sr "ungetc(c, ioptr)"
+The argument character
+.it c
+is pushed back on the input stream named by
+.it ioptr.
+Only one character may be pushed back.
+.sr "printf(format, a1, . . .)"
+.sr "fprintf(ioptr, format, a1, . . .)"
+.sr "sprintf(s, format, a1, . . .)"
+.it Printf
+writes on the standard output.
+.it Fprintf
+writes on the named output stream.
+.it Sprintf
+puts characters in the character array (string)
+named by
+.it s.
+The specifications are as usual.
+.sr "scanf(format, a1, . . .)"
+.sr "fscanf(ioptr, format, a1, . . .)"
+.sr "sscanf(s, format, a1, . . .)"
+.it Scanf
+reads from the standard input.
+.it Fscanf
+reads from the named input stream.
+.it Sscanf
+reads from the character string
+supplied as
+.it s.
+The specifications are identical
+to those of the Portable Library.
+.sr "fread(ptr, sizeof(*ptr), nitems, ioptr)"
+writes
+.it nitems
+of data beginning at
+.it ptr
+on file
+.it ioptr.
+It behaves identically to the Portable Library's
+.it cread.
+No advance notification
+that binary IO is being done is required;
+when, for portability reasons,
+it becomes required, it will be done
+by adding an additional character to the mode-string on the
+fopen call.
+.sr "fwrite(ptr, sizeof(*ptr), nitems, ioptr)"
+Like
+.it fread,
+but in the other direction.
+.sr rewind(ioptr)
+rewinds the stream
+named by
+.it ioptr.
+It is not very useful except on input,
+since a rewound output file is still open only for output.
+.sr system(string)
+.sr atof(s)
+.sr tmpnam(s)
+.sr abort(code)
+.sr "intss( )"
+.sr "cfree(ptr)"
+.sr  "wdleng( )"
+are available with specifications identical to those
+described for the Portable Library.
+.sr "char *calloc(n, sizeof(object))"
+returns null when no space is available.
+The space is guaranteed to be 0.
+.sr ftoa
+is not implemented but there are plausible alternatives.
+.sr "nargs( )"
+is not implemented.
+.sr getw(ioptr)
+returns the next word from the input stream named by
+.it ioptr.
+EOF is returned on end-of-file or error,
+but since this a perfectly good
+integer
+.it feof
+and
+.it ferror
+should be used.
+.sr "putw(w, ioptr)"
+writes the integer
+.it w
+on the named output stream.
+.sr "setbuf(ioptr, buf)"
+.it Setbuf
+may be used after a stream has been opened
+but before IO has started.
+If
+.it buf
+is null,
+the stream will be unbuffered.
+Otherwise the buffer supplied will be used.
+It is a character array of sufficient size:
+.DS
+char   buf[BUFSIZ];
+.DE
+.sr "fileno(ioptr)"
+returns the integer file descriptor associated with the file.
+.PP
+Several additional routines are available.
+.sr "fseek(ioptr, offset, ptrname)"
+The location of the next byte in the stream
+named by
+.it ioptr
+is adjusted.
+.it Offset
+is a long integer.
+If
+.it ptrname
+is 0, the offset is measured from the beginning of the file;
+if
+.it ptrname
+is 1, the offset is measured from the current read or
+write pointer;
+if
+.it ptrname
+is 2, the offset is measured from the end of the file.
+The routine accounts properly for any buffering.
+.sr "long ftell(iop)"
+The byte offset, measured from the beginning of the file,
+associated with the named stream is returned.
+Any buffering is properly accounted for.
+.sr "getpw(uid, buf)"
+The password file is searched for the given integer user ID.
+If an appropriate line is found, it is copied into
+the character array
+.it buf,
+and 0 is returned.
+If no line is found corresponding to the user ID
+then 1 is returned.
+.sr "strcat(s1, s2)"
+.it S1
+and
+.it s2
+are character pointers.
+The end (null byte)
+of the
+.it s1
+string is found and
+.it s2
+is copied to
+.it s1
+starting there.
+The space pointed to by
+.it s1
+must be large enough.
+.sr "strcmp(s1, s2)"
+The character strings
+.it s1
+and
+.it s2
+are compared.
+The result is positive, zero, or negative according as
+.it s1
+is greater than, equal to, or less than
+.it s2
+in ASCII collating sequence.
+.sr "strcpy(s1, s2)
+The null-terminated character string
+.it s2
+is copied to the location pointed to by
+.it s1.
+.sr "strlen(s)"
+The number of bytes in s up to a null byte
+is returned.
+.it S
+is a character pointer.
+.sr "gcvt(num, ndig, buf)"
+.it Num
+is a floating or double quantity.
+.it Ndig
+significant digits are converted to ASCII and placed
+into the character array
+.it buf.
+The conversion is in Fortran
+.it e
+or
+.it f
+style, whichever yields the shorter string.
+Insignificant trailing zeros are eliminated.
diff --git a/usr/doc/ctour/newstuff b/usr/doc/ctour/newstuff
new file mode 100644 (file)
index 0000000..e0629ac
--- /dev/null
@@ -0,0 +1,443 @@
+.na
+.ce
+C Changes
+
+1.  Long integers
+
+The compiler implements 32-bit integers.
+The associated type keyword is `long'.
+The word can act rather like an adjective in that
+`long int' means a 32-bit integer and `long float'
+means the same as `double.'
+But plain `long' is a long integer.
+Essentially all operations on longs are implemented except that
+assignment-type operators do not have values, so
+l1+(l2=+l3) won't work.
+Neither will l1 = l2 = 0.
+
+Long constants are written with a terminating `l' or `L'.
+E.g. "123L" or "0177777777L" or "0X56789abcdL".
+The latter is a hex constant, which could also have been short;
+it is marked by starting with "0X".
+Every fixed decimal constant larger than 32767 is taken to
+be long, and so are octal or hex constants larger than
+0177777 (0Xffff, or 0xFFFF if you like).
+A warning is given in such a case since this is actually
+an incompatibility with the older compiler.
+Where the constant is just used as an initializer or
+assigned to something it doesn't matter.
+If it is passed to a subroutine
+then the routine will not get what it expected.
+
+When a short and a long integer are
+operands of an arithmetic operator,
+the short is converted to long (with sign extension).
+This is true also when a short is assigned to a long.
+When a long is assigned to a short integer it
+is truncated at the high order end with no notice
+of possible loss of significant digits.
+This is true as well when a long is added to a pointer
+(which includes its usage as a subscript).
+The conversion rules for expressions involving
+doubles and floats mixed with longs
+are the same as those for short integers,
+.ul
+mutatis mutandis.
+
+A point to note is that constant expressions involving
+longs are not evaluated at compile time,
+and may not be used where constants are expected.
+Thus
+
+       long x {5000L*5000L};
+
+is illegal;
+
+       long x {5000*5000};
+
+is legal but wrong because the high-order part is lost;
+but both
+
+       long x 25000000L;
+
+and
+
+       long x 25.e6;
+
+are correct
+and have the same meaning
+because the double constant is converted to long at compile time.
+
+2.  Unsigned integers
+
+A new fundamental data type with keyword `unsigned,' is
+available.  It may be used alone:
+
+        unsigned u;
+
+or as an adjective with `int'
+
+        unsigned int u;
+
+with the same meaning.  There are not yet (or possibly ever)
+unsigned longs or chars.  The meaning of an unsigned variable is
+that of an integer modulo 2^n, where n is 16 on the PDP-11.  All
+operators whose operands are unsigned produce results consistent
+with this interpretation except division and remainder where the
+divisor is larger than 32767; then the result is incorrect.  The
+dividend in an unsigned division may however have any value (i.e.
+up to 65535) with correct results.  Right shifts of unsigned
+quantities are guaranteed to be logical shifts.
+
+When an ordinary integer and an unsigned integer are combined
+then the ordinary integer is mapped into an integer mod 2^16 and
+the result is unsigned.  Thus, for example `u = -1' results in
+assigning 65535 to u.  This is mathematically reasonable, and
+also happens to involve no run-time overhead.
+
+When an unsigned integer is assigned to a plain integer, an
+(undiagnosed) overflow occurs when the unsigned integer exceeds
+2^15-1.
+
+It is intended that unsigned integers be used in contexts where
+previously character pointers were used (artificially and
+nonportably) to represent unsigned integers.
+
+3.  Block structure.
+
+A sequence of declarations may now appear at the beginning of any
+compound statement in {}.  The variables declared thereby are
+local to the compound statement.  Any declarations of the same
+name existing before the block was entered are pushed down for
+the duration of the block.  Just as in functions, as before, auto
+variables disappear and lose their values when the block is left;
+static variables retain their values.  Also according to the same
+rules as for the declarations previously allowed at the start of
+functions, if no storage class is mentioned in a declaration the
+default is automatic.
+
+Implementation of inner-block declarations is such that there is
+no run-time cost associated with using them.
+
+4.  Initialization (part 1)
+
+This compiler properly handles initialization of structures
+so the construction
+
+       struct { char name[8]; char type; float val; } x
+               { "abc", 'a', 123.4 };
+
+compiles correctly.
+In particular it is recognized that the string is supposed
+to fill an 8-character array, the `a' goes into a character,
+and that the 123.4 must be rounded and placed in a single-precision
+cell.
+Structures of arrays, arrays of structures, and the like all work;
+a more formal description of what is done follows.
+
+<initializer> ::= <element>
+
+<element> ::= <expression> | <element> , <element> |
+               { <element> } | { <element> , }
+
+An element is an expression or a comma-separated sequence of
+elements possibly enclosed in braces.
+In a brace-enclosed
+sequence, a comma is optional after the last element.
+This very
+ambiguous definition is parsed as described below.
+"Expression"
+must of course be a constant expression within the previous
+meaning of the Act.
+
+An initializer for a non-structured scalar is an element with
+exactly one expression in it.
+
+An "aggregate" is a structure or an array.
+If the initializer
+for an aggregate begins with a left brace, then the succeeding
+comma-separated sequence of elements initialize the members of
+the aggregate.
+It is erroneous for the number of members in the
+sequence to exceed the number of elements in the aggregate.
+If
+the sequence has too few members the aggregate is padded.
+
+If the initializer for an aggregate does not begin with a left
+brace, then the members of the aggregate are initialized with
+successive elements from the succeeding comma-separated sequence.
+If the sequence terminates before the aggregate is filled the
+aggregate is padded.
+
+The "top level" initializer is the object which initializes an
+external object itself, as opposed to one of its members.
+The
+top level initializer for an aggregate must begin with a left
+brace.
+
+If the top-level object being initialized is an array and if its
+size is omitted in the declaration, e.g. "int a[]", then the size
+is calculated from the number of elements which initialized it.
+
+Short of complete assimilation of this description, there are two
+simple approaches to the initialization of complicated objects.
+First, observe that it is always legal to initialize any object
+with a comma-separated sequence of expressions.
+The members of
+every structure and array are stored in a specified order, so the
+expressions which initialize these members may if desired be laid
+out in a row to successively, and recursively, initialize the
+members.
+
+Alternatively, the sequences of expressions which initialize
+arrays or structures may uniformly be enclosed in braces.
+
+5.  Initialization (part 2)
+
+Declarations, whether external, at the head of functions, or
+in inner blocks may have initializations whose syntax is the same
+as previous external declarations with initializations.  The only
+restrictions are that automatic structures and arrays may not be
+initialized (they can't be assigned either); nor, for the moment
+at least, may external variables when declared inside a function.
+
+The declarations and initializations should be thought of as
+occurring in lexical order so that forward references in
+initializations are unlikely to work.  E.g.,
+
+        { int a a;
+          int b c;
+          int c 5;
+          ...
+        }
+
+Here a is initialized by itself (and its value is thus
+undefined); b is initialized with the old value of c (which is
+either undefined or any c declared in an outer block).
+
+6.  Bit fields
+
+A declarator inside a structure may have the form
+
+       <declarator> : <constant>
+
+which specifies that the object declared is stored in a field
+the number of bits in which is specified by the constant.
+If several such things are stacked up next to each other
+then the compiler allocates the fields from right to left,
+going to the next word
+when the new field will not fit.
+The declarator may also have the form
+
+       : <constant>
+
+which allocates an unnamed field to simplify accurate
+modelling of things like hardware formats where there are unused
+fields.
+Finally,
+
+       : 0
+
+means to force the next field to start on a word boundary.
+
+The types of bit fields can be only "int" or "char".
+The only difference between the two
+is in the alignment and length restrictions:
+no int field can be longer than 16 bits, nor any char longer
+than 8 bits.
+If a char field will not fit into the current character,
+then it is moved up to the next character boundary.
+
+Both int and char fields
+are taken to be unsigned (non-negative)
+integers.
+
+Bit-field variables are not quite full-class citizens.
+Although most operators can be applied to them,
+including assignment operators,
+they do not have addresses (i.e. there are no bit pointers)
+so the unary & operator cannot be applied to them.
+For essentially this reason there are no arrays of bit field
+variables.
+
+There are three twoes in the implementation:
+addition (=+) applied to fields
+can result in an overflow into the next field;
+it is not possible to initialize bit fields.
+
+7.  Macro preprocessor
+
+The proprocessor handles `define' statements with formal arguments.
+The line
+
+       #define macro(a1,...,an) ...a1...an...
+
+is recognized by the presence of a left parenthesis
+following the defined name.
+When the form
+
+       macro(b1,...,bn)
+
+is recognized in normal C program text,
+it is replaced by the definition, with the corresponding
+.ul
+bi
+actual argument string substituted for the corresponding
+.ul
+ai
+formal arguments.
+Both actual and formal arguments are separated by
+commas not included in parentheses; the formal arguments
+have the syntax of names.
+
+Macro expansions are no longer surrounded by spaces.
+Lines in which a replacement has taken place are rescanned until
+no macros remain.
+
+The preprocessor has a rudimentary conditional facility.
+A line of the form
+
+       #ifdef name
+
+is ignored if
+`name' is defined to the preprocessor
+(i.e. was the subject of a `define' line).
+If name is not defined then all lines through
+a line of the form
+
+       #endif
+
+are ignored.
+A corresponding
+form is
+
+       #ifndef name
+       ...
+       #endif
+
+which ignores the intervening lines unless `name' is defined.
+The name `unix' is predefined and replaced by itself
+to aid writers of C programs which are expected to be transported
+to other machines with C compilers.
+
+In connection with this, there is a new option to the cc command:
+
+       cc -Dname
+
+which causes `name' to be defined to the preprocessor (and replaced by
+itself).
+This can be used together with conditional preprocessor
+statements to select variant versions of a program at compile time.
+
+The previous two facilities (macros with arguments, conditional
+compilation)
+were actually available in the 6th Edition system, but
+undocumented.
+New in this release of the cc command is the ability to
+nest `include' files.
+Preprocessor include lines may have the new form
+
+       #include <file>
+
+where the angle brackets replace double quotes.
+In this case, the file name is prepended with a standard prefix,
+namely `/usr/include'.
+In is intended that commonly-used include files be placed
+in this directory;
+the convention reduces the dependence on system-specific
+naming conventions.
+The standard prefix can be replaced by
+the cc command option `-I':
+
+       cc -Iotherdirectory
+
+8.  Registers
+
+A formal argument may be given the storage class `register.'
+When this occurs the save sequence copies it
+from the place
+the caller left it into a fast register;
+all usual restrictions on its use are the same
+as for ordinary register variables.
+
+Now any variable inside a function may be declared `register;'
+if the type is unsuitable, or if
+there are more than three register declarations,
+then the compiler makes it `auto' instead.
+The restriction that the & operator may not be applied
+to a register remains.
+
+9.  Mode declarations
+
+A declaration of the form
+
+       typedef\b\b\b\b\b\b\b_______ type-specifier declarator ;\b_
+
+makes the name given in the declarator into the equivalent
+of a keyword specifying the type which the name would have
+in an ordinary declaration.
+Thus
+
+       typedef int *iptr;
+
+makes `iptr' usable in declarations of pointers to integers;
+subsequently the declarations
+
+       iptr ip;
+.br
+       int *ip;
+
+would mean the same thing.
+Type names introduced in this way
+obey the same scope rules as ordinary variables.
+The facility is new, experimental, and probably buggy.
+
+10. Restrictions
+
+The compiler is somewhat stickier about
+some constructions that used to be accepted.
+
+One difference is that external declarations made inside
+functions are remembered to the end of the file,
+that is even past the end of the function.
+The most frequent problem that this causes is that
+implicit declaration of a function as an integer in one
+routine,
+and subsequent explicit declaration
+of it as another type,
+is not allowed.
+This turned out to affect
+several source programs
+distributed with the system.
+
+It is now required that all forward references to labels
+inside a function be the subject of a `goto.'
+This has turned out to affect mainly people who
+pass a label to the routine `setexit.'
+In fact a routine is supposed to be passed here,
+and why a label worked I do not know.
+
+In general this compiler makes it more difficult
+to use label variables.
+Think of this as a contribution to structured programming.
+
+The compiler now checks multiple declarations of the same name
+more carefully for consistency.
+It used to be possible to declare the same name to
+be a pointer to different structures;
+this is caught.
+So too are declarations of the same array as having different
+sizes.
+The exception is that array declarations with empty brackets
+may be used in conjunction with a declaration with a specified size.
+Thus
+
+       int a[];
+       int a[50];
+
+is acceptable (in either order).
+
+An external array all of whose definitions
+involve empty brackets is diagnosed as `undefined'
+by the loader;
+it used to be taken as having 1 element.
index 609a93f..6f8b7ec 100644 (file)
@@ -1678,6 +1678,9 @@ open(1, file=\(fmfort.junk\(fm)
 .DE
 .B open
 takes a variety of arguments with meanings described below.
 .DE
 .B open
 takes a variety of arguments with meanings described below.
+.EQ
+delim off
+.EN
 .RS
 .      \" macros here
 .de HP
 .RS
 .      \" macros here
 .de HP
diff --git a/usr/doc/index b/usr/doc/index
deleted file mode 100644 (file)
index b0a6de1..0000000
+++ /dev/null
@@ -1,331 +0,0 @@
-.nr n 0 +1
-.TL
-UNIX Programmer's Manual
-.br
-.sp .5
-Volume 2 \(em Supplementary Documents
-.AU
-.ft B
-.ps 11
-Seventh Edition
-.AI
-January 10, 1979
-.PP
-This volume contains documents which supplement
-the information contained in Volume 1 of 
-.ul
-The
-.ul
-.UX
-.ul
-Programmer's Manual.
-The documents here are grouped roughly into
-the areas of
-basics,
-editing,
-language tools,
-document preparation,
-and
-system maintenance.
-Further general information may be found in
-the Bell System Technical Journal
-special issue on
-.UX ,
-July-August, 1978.
-.PP
-Many of the documents cited within this volume as
-Bell Laboratories internal memoranda
-or Computing Science Technical Reports
-(CSTR) are also contained here.
-.PP
-These documents contain occasional localisms,
-typically references to other operating systems
-like
-GCOS
-and
-IBM.
-In all cases, such references may be safely ignored
-by
-UNIX
-users.
-.SH
-General Works
-.IP \n+n.
-7th Edition UNIX \(em Summary.
-.RS
-A concise summary of the facilities available on
-.UX .
-.RE
-.IP \n+n.
-The UNIX Time-Sharing System.
-D. M. Ritchie and K. Thompson.
-.RS
-The original
-.UX
-paper, reprinted from CACM.
-.RE
-.SH
-Getting Started
-.IP \n+n.
-UNIX for Beginners \(em Second Edition.
-B. W. Kernighan.
-.RS
-An introduction to the most basic use of the system.
-.RE
-.IP \n+n.
-A Tutorial Introduction to the UNIX Text Editor.
-B. W. Kernighan.
-.RS
-An easy way to get started with the editor.
-.RE
-.IP \n+n.
-Advanced Editing on UNIX.
-B. W. Kernighan.
-.RS
-The next step.
-.RE
-.IP \n+n.
-An Introduction to the UNIX Shell.
-S. R. Bourne.
-.RS
-An introduction to the capabilities of the command interpreter,
-the shell.
-.RE
-.IP \n+n.
-Learn \(em Computer Aided Instruction on UNIX.
-M. E. Lesk and B. W. Kernighan.
-.RS
-Describes a computer-aided instruction program that walks new users
-through the basics of
-files, 
-the editor,
-and
-document preparation software.
-.RE
-.SH
-Document Preparation
-.IP \n+n.
-Typing Documents on the UNIX System.
-M. E. Lesk.
-.RS
-Describes the basic use of the formatting tools.
-Also describes ``\-ms'', a standardized package of formatting requests
-that can be used to lay out most documents
-(including those in this volume).
-.RE
-.IP \n+n.
-A System for Typesetting Mathematics.
-B. W. Kernighan and L. L. Cherry.
-.RS
-Describes EQN. an easy-to-learn language for doing high-quality mathematical typesetting,
-.RE
-.IP \n+n.
-TBL \(em A Program to Format Tables.
-M. E. Lesk.
-.RS
-A program to permit easy specification of tabular material
-for typesetting.
-Again, easy to learn and use.
-.RE
-.IP \n+n.
-Some Applications of Inverted Indexes on the UNIX System.
-M. E. Lesk.
-.RS
-Describes, among other things, the program REFER
-which fills in bibliographic citations from a data base
-automatically.
-.RE
-.RE
-.IP \n+n.
-NROFF/TROFF User's Manual.
-J. F. Ossanna.
-.RS
-The basic formatting program.
-.RE
-.IP \n+n.
-A TROFF Tutorial.
-B. W. Kernighan.
-.RS
-An introduction to TROFF for those who
-really want to know such things.
-.RE
-.SH
-Programming
-.IP \n+n.
-The C Programming Language \(em Reference Manual.
-D. M. Ritchie.
-.RS
-Official statement of the syntax and semantics of C.
-Should be supplemented by
-.ul
-The C Programming Language,
-B. W. Kernighan and D. M. Ritchie,
-Prentice-Hall, 1978,
-which contains a tutorial introduction and many examples.
-.RE
-.IP \n+n.
-Lint, A C Program Checker.
-S. C. Johnson.
-.RS
-Checks C programs
-for syntax errors, type violations,
-portability problems,
-and a variety of probable errors.
-.RE
-.IP \n+n.
-Make \(em A Program for Maintaining Computer Programs.
-S. I. Feldman.
-.RS
-Indispensable tool for making sure that large programs
-are properly compiled with minimal effort.
-.RE
-.IP \n+n.
-UNIX Programming.
-B. W. Kernighan and D. M. Ritchie.
-.RS
-Describes the programming interface to the operating system
-and the standard I/O library.
-.RE
-.IP \n+n.
-A Tutorial Introduction to ADB.
-J. F. Maranzano and S. R. Bourne.
-.RS
-How to use the ADB debugger.
-.RE
-.SH
-Supporting Tools and Languages
-.IP \n+n.
-YACC: Yet Another Compiler-Compiler.
-S. C. Johnson.
-.RS
-Converts a BNF specification of a language
-and semantic actions written in C into a compiler for the language.
-.RE
-.IP \n+n.
-LEX \(em A Lexical Analyzer Generator.
-M. E. Lesk and E. Schmidt.
-.RS
-Creates a recognizer for a set of regular expressions;
-each regular expression can be followed by arbitrary C code
-which will be executed when the regular expression is found.
-.RE
-.IP \n+n.
-A Portable Fortran 77 Compiler.
-S. I. Feldman and P. J. Weinberger.
-.RS
-The first Fortran 77 compiler, and still one of the best.
-.RE
-.IP \n+n.
-Ratfor \(em A Preprocessor for a Rational Fortran.
-B. W. Kernighan.
-.RS
-Converts a Fortran with C-like control structures and cosmetics
-into real, ugly Fortran.
-.RE
-.IP \n+n.
-The M4 Macro Processor.
-B. W. Kernighan and D. M. Ritchie.
-.RS
-M4 is a macro processor useful as a front end for C, Ratfor,
-Cobol, and in its own right.
-.RE
-.IP \n+n.
-SED \(em A Non-interactive Text Editor.
-L. E. McMahon.
-.RS
-A variant of the editor for processing large
-inputs.
-.RE
-.IP \n+n.
-AWK \(em A Pattern Scanning and Processing Language.
-A. V. Aho, B. W. Kernighan and 
-.RS
-P. J. Weinberger.
-.br
-Makes it easy to specify many data transformation and selection operations.
-.RE
-.IP \n+n.
-DC \(em An Interactive Desk Calculator.
-R. H. Morris and L. L. Cherry.
-.RS
-A super HP calculator, if you don't need floating point.
-.RE
-.IP \n+n.
-BC \(em An Arbitrary Precision Desk-Calculator Language.
-L. L. Cherry and R. H. Morris.
-.RS
-A front end for DC
-that provides infix notation, control flow, and built-in functions.
-.RE
-.IP \n+n.
-UNIX Assembler Reference Manual.
-D. M. Ritchie.
-.RS
-The ultimate dead language.
-.RE
-.SH
-Implementation, Maintenance, and Miscellaneous
-.IP \n+n.
-Setting Up UNIX \(em Seventh Edition.
-C. B. Haley and D. M. Ritchie.
-.RS
-How to configure and get your system running.
-.RE
-.IP \n+n.
-Regenerating System Software.
-C. B. Haley and D. M. Ritchie.
-.RS
-What do do when you have to change things.
-.RE
-.IP \n+n.
-UNIX Implementation.
-K. Thompson.
-.RS
-How the system actually works inside.
-.RE
-.IP \n+n.
-The UNIX I/O System.
-D. M. Ritchie.
-.RS
-How the I/O system really works.
-.RE
-.IP \n+n.
-A Tour Through the UNIX C Compiler.
-D. M. Ritchie.
-.RS
-How the PDP-11 compiler works inside.
-.RE
-.IP \n+n.
-A Tour Through the Portable C Compiler.
-S. C. Johnson.
-.RS
-How the portable C compiler works inside.
-.RE
-.IP \n+n.
-A Dial-Up Network of UNIX Systems.
-D. A. Nowitz and M. E. Lesk.
-.RS
-Describes UUCP, a program for communicating files
-between UNIX systems.
-.RE
-.IP \n+n.
-UUCP Implementation Description.
-D. A. Nowitz.
-.RS
-How UUCP works, and how to administer it.
-.RE
-.IP \n+n.
-On the Security of UNIX.
-D. M. Ritchie.
-.RS
-Hints on how to break UNIX, and how to avoid doing so.
-.RE
-.IP \n+n.
-Password Security: A Case History.
-R. H. Morris and K. Thompson.
-.RS
-How the bad guys used to be able to
-break the password algorithm,
-and why they can't now,
-at least not so easily.
-.RE
diff --git a/usr/doc/learn/p0 b/usr/doc/learn/p0
deleted file mode 100644 (file)
index 9e7dc87..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-.RP
-.TM "79-1274-xx 79-1273-yy" 39199 39199-11
-....ND June 18, 1976
-....TM "76-1274-6 76-1273-5" 39199 39199-11
-.TL
-LEARN \(em Computer-Aided Instruction on UNIX
-.br
-(Second Edition)
-.AU "MH 2C-518" 6021
-Brian W. Kernighan
-.AU "MH 2C-569" 6377
-Michael E. Lesk
-.AI
-.MH
-.OK
-CAI
-.AB
-.PP
-This paper describes the
-second version of the
-.I
-learn
-.R
-program for interpreting CAI
-scripts on
-the
-.UX 
-operating system,
-and a set of scripts that provide a computerized introduction
-to the system.
-.PP
-Six current scripts cover basic commands and file
-handling, the editor, additional file handling commands, the
-.I
-eqn
-.R
-program for mathematical
-typing,
-the ``\-ms'' package of formatting macros,
-and an introduction to the C programming language.
-These scripts now include a total of
-about 530 lessons.
-.PP
-Many users from a wide variety of backgrounds have used
-.I learn
-to acquire basic UNIX skills.
-Most usage involves the first two scripts,
-an introduction to
-.UX
-files and commands, and
-the
-.UX
-editor.
-.PP
-The second version of
-.I learn
-is about four times faster than the previous one
-in CPU utilization,
-and much faster in perceived time
-because of better overlap of computing and printing.
-It also requires less file space than the first version.
-Many of the lessons have been revised;
-new material has been added to reflect changes
-and enhancements in 
-.UX
-itself.
-Script-writing is also easier
-because of revisions to the script language.
-.AE
-.CS 11 2 13 4 0 0
diff --git a/usr/doc/learn/p2 b/usr/doc/learn/p2
deleted file mode 100644 (file)
index 4888a8c..0000000
+++ /dev/null
@@ -1,254 +0,0 @@
-.NH
-Educational Assumptions and Design.
-.PP
-First, the way to teach people how to do something
-is to have them do it.  Scripts should
-not contain long pieces of explanation; they should
-instead frequently ask the student to do some task.
-So teaching is always by example: the typical
-script fragment shows a small example of some
-technique and then asks the
-user to either repeat that example or
-produce a variation on it.
-All are intended to be easy enough that most students will get most questions
-right, reinforcing the desired behavior.
-.PP
-Most lessons fall into one of three types.
-The simplest presents a lesson and asks for a yes or no
-answer to a question.
-The student is given a chance to experiment before replying.
-The script checks for the correct reply.
-Problems of this form are sparingly used.
-.PP
-The second type asks for a word or number as an answer.
-For example a lesson on files might say
-.IP
-.I
-How many files are there in the current directory?
-Type ``answer N'', where N is the number of files.
-.R
-.LP
-The student is expected to respond (perhaps after experimenting) with
-.LP
-.I
-       answer 17
-.R
-.LP
-or whatever.
-Surprisingly often, however, the idea of a substitutable argument
-(i.e., replacing
-.I
-N
-.R
-by
-17)
-is difficult for non-programmer students,
-so the first few such lessons need real care.
-.PP
-The third type of lesson is open-ended \(em
-a task is set for the student,
-appropriate parts of the input or output are monitored,
-and the student types 
-.ul
-ready
-when the task is done.
-Figure 1 shows a sample dialog that illustrates the last of these, using two
-lessons about the
-.I cat
-(concatenate, i.e., print) command taken
-from early in the script that teaches
-file handling.
-Most
-.I learn
-lessons are of this form.
-.KF
-.TS
-box, center;
-c.
-T{
-Figure 1:  Sample dialog from basic files script
-.sp
-(Student responses
-in italics; `$' is the prompt)
-.nf
-.sp
-A file can be printed on your terminal
-by using the "cat" command.  Just say
-"cat file" where "file" is the file name.
-For example, there is a file named
-"food" in this directory.  List it
-by saying "cat food"; then type "ready".
-$ \fIcat food\fR
-  this is the file
-  named food.
-$ \fIready\fR
-
-Good.  Lesson 3.3a (1)
-
-Of course, you can print any file with "cat".
-In particular, it is common to first use
-"ls" to find the name of a file and then "cat"
-to print it.  Note the difference between
-"ls", which tells you the name of the file,
-and "cat", which tells you the contents.
-One file in the current directory is named for
-a President.  Print the file, then type "ready".
-$ \fIcat President\fR
-cat: can't open President
-$ \fIready\fR
-
-Sorry, that's not right.  Do you want to try again? \fIyes\fR
-Try the problem again.
-$ \fIls\fR
-\&.ocopy
-X1
-roosevelt
-$ \fIcat roosevelt\fR
-  this file is named roosevelt
-  and contains three lines of
-  text.
-$ \fIready\fR
-
-Good.  Lesson 3.3b (0)
-
-The "cat" command can also print several files
-at once.  In fact, it is named "cat" as an abbreviation
-for "concatenate"....
-.fi
-T}
-.TE
-.sp
-.KE
-.PP
-After each correct response the computer congratulates
-the student and indicates the lesson number that
-has just been completed, permitting the student
-to restart the script after that lesson.
-If the answer is wrong, the student
-is offered a chance to repeat the lesson.
-The ``speed'' rating of the student (explained in
-section 5) is given after the lesson number when the lesson is completed successfully; it is
-printed only for the aid of script authors checking
-out possible errors in the lessons.
-.br
-.PP
-It is assumed that there is no foolproof way
-to determine if the student truly ``understands''
-what he or she is doing;
-accordingly,
-the current
-.I
-learn
-.R
-scripts
-only measure performance, not comprehension.
-If the student can perform a given task, that is deemed to be ``learning.''
-.[
-skinner teaching 1961
-.]
-.PP
-The main point of using the computer is that what the student
-does is checked for correctness immediately.
-Unlike many CAI scripts, however, these scripts provide
-few facilities for dealing with wrong answers.
-In practice, if most of the answers are not right the script is
-a failure; the universal solution to student error is to provide
-a new, easier script.
-Anticipating possible wrong answers is an endless job, and it is really
-easier as well as better to provide a simpler script.
-.PP
-Along with this goes the assumption that
-anything can be taught to anybody if it can
-be broken into sufficiently small pieces.  Anything
-not absorbed in a single chunk is just subdivided.
-.PP
-To avoid boring the faster students,
-however,
-an effort is made in the files and editor scripts to provide
-three tracks of different difficulty.
-The fastest sequence of lessons
-is aimed at roughly the bulk and speed of a typical tutorial
-manual and should be adequate for review and for
-well-prepared students.
-The next track is intended for most users and is roughly
-twice as long.  Typically, for example, the fast track
-might present an idea and ask for a variation on the
-example shown; the normal track will first
-ask the student to repeat the example that was shown
-before attempting a variation.
-The third and slowest track, which is often
-three or four times the length of the fast track,
-is intended to be adequate for anyone.
-(The lessons of Figure 1 are from the third track.)
-The multiple tracks also mean that a student repeating a course is unlikely
-to hit the same series of lessons; this makes it profitable for a shaky
-user to back up and try again, and many students have done so.
-.PP
-The tracks are not completely distinct, however.
-Depending on the number of correct answers the student has given for the
-last few lessons, the program may switch tracks.
-The driver is actually capable of following
-an arbitrary directed graph of lesson sequences, as discussed in section 5.
-Some more structured arrangement, however, is used in all current scripts
-to aid the script writer in organizing the material into lessons.
-It is sufficiently difficult
-to write lessons
-that the three-track theory
-is not followed very closely
-except in
-the files and editor scripts.
-Accordingly,
-in some cases, the fast track is produced merely by skipping
-lessons from the slower track.
-In others, there is essentially only one track.
-.PP
-The main reason for using the
-.I
-learn
-.R
-program rather than
-simply writing the same material as a workbook
-is not the selection of tracks, but
-actual hands-on experience.
-Learning by doing
-is much more effective
-than pencil and paper exercises.
-.PP
-.I Learn
-also provides a mechanical check on performance.
-The first version in fact would not let
-the student proceed unless it
-received correct answers to the questions
-it set and it would not tell a student the right answer.
-This somewhat Draconian approach has been moderated
-in version 2.
-Lessons are sometimes badly worded or even just plain wrong;
-in such cases,
-the student has no recourse.
-But if a student is simply unable to complete one lesson,
-that should not prevent access to the rest.
-Accordingly, the current version of
-.I learn
-allows the student to skip
-a lesson that he cannot pass;
-a ``no'' answer to the ``Do you want to try again?''
-question in Figure 1 will pass to the next lesson.
-It is still true that 
-.I learn
-will not tell the student the right answer.
-.PP
-Of course, there are valid objections to the
-assumptions above.
-In particular, some students may object to
-not understanding
-what they are doing;
-and the procedure of smashing everything into small pieces may provoke
-the retort ``you can't cross a ditch in two jumps.''
-Since writing CAI scripts is considerably
-more tedious than ordinary manuals, however, it is safe
-to assume that there will always be alternatives to the
-scripts as a way of learning.
-In fact, for a reference manual of 3 or 4 pages it would
-not be surprising to have a tutorial manual of 20 pages
-and a (multi-track) script of 100 pages.  Thus the reference manual
-will exist long before the scripts.
diff --git a/usr/doc/learn/p3 b/usr/doc/learn/p3
deleted file mode 100644 (file)
index 7ee9344..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-.NH
-Scripts.
-.PP
-As mentioned above, the present scripts try
-at most
-to follow a three-track theory.  Thus little
-of the potential complexity of the possible directed graph
-is employed, since
-care must be taken in lesson construction to see
-that every necessary fact is presented in
-every possible path through the units.  In addition,
-it is desirable that every unit have alternate successors
-to deal with student errors.
-.PP
-In most existing courses, the first few lessons
-are devoted to checking prerequisites.  For example,
-before the student is allowed to proceed through the editor
-script the script verifies that the student understands files
-and is able to type.
-It is felt that the sooner lack of student preparation
-is detected, the easier it will be on the student.
-Anyone proceeding through the scripts
-should be getting mostly correct answers; otherwise, the
-system will be unsatisfactory both because the wrong
-habits are being learned and because the
-scripts make little effort to deal with wrong answers.
-Unprepared students should not be encouraged
-to continue with scripts.
-.PP
-There are some preliminary items which the student must
-know before any scripts can be tried.  In particular,
-the student must know how to connect to
-a
-.UX
-system,
-set the terminal properly,
-log in,
-and execute simple commands (e.g.,
-.ul
-learn
-itself).
-In addition, the character erase and line kill conventions
-(# and @) should be known.
-It is hard to see how this much could be taught by
-computer-aided instruction, since a student who
-does not know these basic skills will not be able
-to run the learning program.
-A brief description on paper is provided (see Appendix A), although
-assistance will be needed for the first few
-minutes.  This assistance, however, need not be highly skilled.
-.PP
-The first script in the current set deals with files.  It assumes
-the basic knowledge above and teaches the student about
-the
-.I ls ,
-.I cat ,
-.I mv ,
-.I rm ,
-.I cp
-and
-.I diff
-commands.
-.tr ~
-It also deals with the abbreviation characters *, ?, and [\ ]
-in file names.
-It does not cover pipes or I/O redirection,
-nor does it present the many options
-on the
-.ul
-ls
-command.
-.PP
-This script contains 31 lessons
-in the fast track;
-two are
-intended as prerequisite checks,
-seven are review exercises.
-There are a total of 75 lessons in all three tracks,
-and the instructional passages typed at the student
-to begin each lesson total 4,476 words.  The average
-lesson thus begins with a 60-word message.
-In general, the fast track lessons have somewhat longer
-introductions, and the slow tracks somewhat shorter ones.
-The longest message is 144 words and the shortest 14.
-.PP
-The second script trains students in the use
-of the
-.UX
-context editor
-.I ed ,
-a sophisticated editor
-using regular expressions for searching.
-.[
-ritchie thompson unix  seventh edition 1978
-%O See section \f2ed\f1 (I).
-.]
-All editor
-features except encryption, mark names and `;' in addressing
-are covered.
-The fast track contains 2 prerequisite checks,
-93 lessons, and a review lesson.
-It is supplemented by 146 additional lessons in other tracks.
-.PP
-A comparison of sizes may be of interest.  The
-.ul
-ed
-description
-in the reference manual is 2,572 words long.  The
-.ul
-ed
-tutorial
-.[
-kernighan editor tutorial 1974
-.]
-is 6,138 words long.  
-The fast track through
-the
-.ul
-ed
-script is 7,407 words of explanatory messages, and the
-total
-.ul
-ed
-script, 242 lessons, 
-has 15,615 words.
-The average
-.ul
-ed
-lesson is thus also about 60 words; the largest
-is 171 words and the smallest 10.
-The
-original
-.ul
-ed
-script represents about three man-weeks of effort.
-.PP
-The advanced file handling script deals with
-.ul
-ls
-options,
-I/O diversion, pipes, and supporting programs like
-.I pr ,
-.I wc ,
-.I tail ,
-.I spell
-and
-.I grep .
-(The basic file handling script is a prerequisite.)
-It is not as refined as the first two scripts;
-this is reflected at least partly in the fact that
-it provides much less of a full three-track sequence
-than they do.
-On the other hand,
-since it is perceived as ``advanced,''
-it is hoped that the student will have somewhat
-more sophistication
-and be better able to cope with it at a reasonably
-high level of performance.
-.PP
-A fourth script covers the
-.ul
-eqn
-language for typing mathematics.
-This script must be run on a terminal capable of printing
-mathematics, for instance the DASI 300 and similar Diablo-based
-terminals, or the nearly extinct Model 37 teletype.
-Again, this script is relatively short of tracks:
-of 76 lessons, only 17 are in the second track and 2
-in the third track.
-Most of these provide additional practice for students
-who are having trouble in the first track.
-.PP
-The
-.I \-ms
-script for formatting macros
-is a short one-track only script.
-The macro package it describes is no longer the standard,
-so this script will undoubtedly be superseded
-in the future.
-Furthermore, the linear style of a single learn script is somewhat
-inappropriate for the macros, since the macro package is composed of many
-independent features, and few users need all of them.
-It would be better to have a selection of short lesson
-sequences dealing with the features independently.
-.PP
-The script on C is in a state of transition.
-It was originally designed to follow
-a tutorial on C,
-but that document has since become obsolete.
-The current script has been partially converted
-to follow the order of presentation in
-.ul
-The C Programming Language,
-.[
-ritchie kernighan programming 1978 prentice hall
-.]
-but this job is not complete.
-The C script was never intended to teach C;
-rather it is supposed to be a series of exercises
-for which the computer provides checking and
-(upon success) a suggested solution.
-.PP
-This combination of scripts covers much of the material which any
-.UX
-user
-will need to know
-to make effective use of the system.
-With enlargement of the advanced files
-course to include more on the command interpreter, there
-will be a relatively complete introduction to
-.UX
-available via
-.ul
-learn.
-Although we make no pretense that 
-.ul
-learn
-will replace other instructional materials,
-it should provide a useful supplement to existing tutorials and reference manuals.
diff --git a/usr/doc/learn/p4 b/usr/doc/learn/p4
deleted file mode 100644 (file)
index 5b4673b..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-.NH
-Experience with Students.
-.PP
-.I
-Learn
-.R
-has been installed on
-many different 
-.UX
-systems.
-Most of the usage is on the first two scripts, so these
-are more thoroughly debugged and polished.
-As a (random) sample of user experience,
-the
-.I learn
-program has been used at Bell Labs at Indian Hill
-for 10,500 lessons in a four month period.
-About 3600 of these are in the files script,
-4100 in the editor,
-and 1400 in advanced files.
-The passing rate is about 80%,
-that is, about 4 lessons are passed for every one
-failed.
-There have been 86 distinct users of the files script,
-and 58 of the editor.
-On our system at Murray Hill, there have been nearly 2000 lessons
-over two weeks that include
-Christmas and New Year.
-Users have ranged in age from six up.
-.PP
-It is difficult to characterize typical sessions with the
-scripts;
-many instances exist of someone doing one or two lessons
-and then logging out, as do instances of someone pausing
-in a script for twenty minutes or more.
-In the earlier version of
-.I learn ,
-the average session in the files course took 32 minutes and covered
-23 lessons.
-The distribution is quite
-broad and skewed, however; the longest session was
-130 minutes and there were five sessions shorter than
-five minutes.
-The average lesson took about 80 seconds.
-These numbers are roughly typical for non-programmers;
-a
-.UX
-expert can do the scripts at approximately 30 seconds
-per lesson, most of which is the system printing.
-.PP
-At present working through a section of the middle of the files
-script took about 1.4 seconds of processor time per lesson,
-and a system expert typing quickly took 15 seconds of real time per lesson.
-A novice would probably take at least a minute.
-Thus a UNIX system could support ten students working simultaneously
-with some spare capacity.
diff --git a/usr/doc/learn/p5 b/usr/doc/learn/p5
deleted file mode 100644 (file)
index addc79e..0000000
+++ /dev/null
@@ -1,585 +0,0 @@
-.NH
-The Script Interpreter.
-.PP
-The
-.I
-learn
-.R
-program itself merely interprets scripts.  It provides
-facilities for the script writer to capture student
-responses and their effects, and simplifies the job
-of passing control to and recovering control from the student.
-This section describes the operation and
-usage of the driver program,
-and indicates what is
-required to produce a new script.
-Readers only interested in
-the existing scripts may skip this section.
-.PP
-The file structure used by
-.I learn
-is shown in Figure 2.
-There is one parent directory (named \f2lib\f1\^) containing the script data.
-Within this directory are subdirectories, one for each
-subject in which a course is available,
-one for logging (named
-.I log ),
-and one in which user sub-directories
-are created (named
-.I play ).
-The subject directory contains master copies of all lessons,
-plus any supporting material for that subject.
-In a given subdirectory,
-each lesson is a single text file.
-Lessons are usually named systematically;
-the file that contains lesson
-.I n
-is called
-.I Ln .
-.br
-.KF
-.sp
-.TS
-center, box;
-c s s s
-l l l l.
-Figure 2:  Directory structure for \fIlearn\fR
-.sp
-.nf
-lib
-.if t .sp .5
-       play
-               student1
-                       files for student1...
-               student2
-                       files for student2...
-.if t .sp .5
-       files
-               L0.1a   lessons for files course
-               L0.1b
-               ...
-.if t .sp .5
-       editor
-               ...
-.if t .sp .5
-       (other courses)
-.if t .sp .5
-       log
-.TE
-.sp
-.KE
-.PP
-When
-.I
-learn
-.R
-is executed, it makes a private directory
-for the user to work in,
-within the
-.I
-learn
-.R
-portion of the file system.
-A fresh copy of all the files used in each lesson
-(mostly data for the student to operate upon) is made each
-time a student starts a lesson,
-so the script writer may assume that everything
-is reinitialized each time a lesson is entered.
-The student directory is deleted after each session; any permanent records
-must be kept elsewhere.
-.PP
-The script writer must provide certain basic items
-in each
-lesson:
-.IP (1)
-the text of the lesson;
-.IP (2)
-the set-up commands to be executed before the user gets control;
-.IP (3)
-the data, if any, which the user is supposed to edit, transform, or otherwise
-process;
-.IP (4)
-the evaluating commands to be executed after the user
-has finished the lesson, to decide whether the answer is right;
-and
-.IP (5)
-a list of possible successor lessons.
-.LP
-.I
-Learn
-.R
-tries to minimize the work
-of bookkeeping and installation, so
-that most of the effort involved in
-script production is in planning lessons,
-writing tutorial paragraphs,
-and coding tests of student performance.
-.PP
-The basic sequence of events is
-as follows.
-First,
-.I learn
-creates the working directory.
-Then, for each lesson,
-.I learn
-reads the script for the lesson and processes
-it a line at a time.
-The lines in the script are:
-(1) commands to the script interpreter
-to print something, to create a files,
-to test something, etc.;
-(2) text to be printed or put in a file;
-(3) other lines, which are sent to
-the shell to be executed.
-One line in each lesson turns control over
-to the user;
-the user can run any 
-.UX 
-commands.
-The user mode terminates when the user
-types 
-.I yes ,
-.I no ,
-.I ready ,
-or
-.I answer .
-At this point, the user's work is tested;
-if the lesson is passed,
-a new lesson is selected, and if not
-the old one is repeated.
-.PP
-Let us illustrate this with the script
-for the second lesson of Figure 1;
-this is shown in Figure 3.
-.KF
-.sp
-.TS
-center, box;
-c.
-T{
-Figure 3:  Sample Lesson
-.sp
-.nf
-#print
-Of course, you can print any file with "cat".
-In particular, it is common to first use
-"ls" to find the name of a file and then "cat"
-to print it.  Note the difference between
-"ls", which tells you the name of the files,
-and "cat", which tells you the contents.
-One file in the current directory is named for
-a President.  Print the file, then type "ready".
-#create roosevelt
-  this file is named roosevelt
-  and contains three lines of
-  text.
-#copyout
-#user
-#uncopyout
-tail \-3 .ocopy >X1
-#cmp X1 roosevelt
-#log
-#next
-3.2b 2
-.fi
-T}
-.TE
-.sp
-.KE
-.LP
-Lines which begin with
-# are commands to the
-.I  learn 
-script interpreter.
-For example,
-.LP
-.ul
-       #print
-.LP
-causes printing of any text that follows,
-up to the next line that begins with a sharp.
-.LP
-.ul
-       #print file
-.LP
-prints the contents of
-.I file ;
-it
-is the same as
-.ul
-cat file 
-but has
-less overhead.
-Both forms of
-.I #print
-have the added property that if a lesson is failed,
-the
-.ul
-#print
-will not be executed the second time through;
-this avoids annoying the student by repeating the preamble
-to a lesson.
-.LP
-.ul
-       #create filename
-.LP
-creates a file of the specified name,
-and copies any subsequent text up to a
-# to the file.
-This is used for creating and initializing working files
-and reference data for the lessons.
-.LP
-.ul
-       #user
-.LP
-gives control to the student;
-each line he or she types is passed to the shell
-for execution.
-The
-.I #user
-mode
-is terminated when the student types one of
-.I yes ,
-.I no ,
-.I ready 
-or
-.I answer .
-At that time, the driver
-resumes interpretation of the script.
-.LP
-.ul
-       #copyin
-.br
-.ul
-       #uncopyin
-.LP
-Anything the student types between these
-commands is copied onto a file
-called
-.ul
-\&.copy.
-This lets the script writer interrogate the student's
-responses upon regaining control.
-.LP
-.ul
-       #copyout
-.br
-.ul
-       #uncopyout
-.LP
-Between these commands, any material typed at the student
-by any program
-is copied to the file
-.ul
-\&.ocopy.
-This lets the script writer interrogate the
-effect of what the student typed, 
-which true believers in the performance theory of learning
-usually
-prefer to the student's actual input.
-.LP
-.ul
-       #pipe
-.br
-.ul
-       #unpipe
-.LP
-Normally the student input and the script commands
-are fed to the
-.UX
-command interpreter (the ``shell'') one line at a time. This won't do
-if, for example, a sequence of editor commands
-is provided,
-since the input to the editor must be handed to the editor,
-not to the shell.
-Accordingly, the material between 
-.ul
-#pipe
-and
-.ul
-#unpipe
-commands
-is fed
-continuously through a pipe so that such sequences
-work.
-If
-.ul
-copyout
-is also desired
-the
-.ul
-copyout
-brackets must include
-the
-.ul
-pipe
-brackets.
-.PP
-There are several commands for setting status
-after the student has attempted the lesson.
-.LP
-.ul
-       #cmp file1 file2
-.LP
-is an in-line implementation of
-.I cmp ,
-which compares two files for identity.
-.LP
-.ul
-       #match stuff
-.LP
-The last line of the student's input
-is compared to
-.I stuff ,
-and the success or fail status is set
-according to it.
-Extraneous things like the word
-.I answer
-are stripped before the comparison is made.
-There may be several 
-.I #match
-lines;
-this provides a convenient mechanism for handling multiple
-``right'' answers.
-Any text up to a
-# on subsequent lines after a successful
-.I #match
-is printed; 
-this is illustrated in Figure 4, another sample lesson.
-.br
-.KF
-.sp
-.TS
-center, box;
-c.
-T{
-Figure 4:  Another Sample Lesson
-.sp
-.nf
-#print
-What command will move the current line
-to the end of the file?  Type 
-"answer COMMAND", where COMMAND is the command.
-#copyin
-#user
-#uncopyin
-#match m$
-#match .m$
-"m$" is easier.
-#log
-#next
-63.1d 10
-T}
-.TE
-.sp
-.KE
-.LP
-.ul
-       #bad stuff
-.LP
-This is similar to
-.I #match ,
-except that it corresponds to specific failure answers;
-this can be used to produce hints for particular wrong answers
-that have been anticipated by the script writer.
-.LP
-.ul
-       #succeed
-.br
-.ul
-       #fail
-.LP
-print a message
-upon success or failure
-(as determined by some previous mechanism).
-.PP
-When the student types
-one of the ``commands''
-.I yes ,
-.I no ,
-.I ready ,
-or
-.I answer ,
-the driver terminates the
-.I #user
-command,
-and evaluation of the student's work can begin.
-This can be done either by
-the built-in commands above, such as
-.I #match
-and
-.I #cmp ,
-or by status returned by normal
-.UX 
-commands, typically
-.I grep
-and
-.I test .
-The last command
-should return status true
-(0) if the task was done successfully and
-false (non-zero) otherwise;
-this status return tells the driver
-whether or not the student
-has successfully passed the lesson.
-.PP
-Performance can be logged:
-.LP
-.ul
-       #log file
-.LP
-writes the date, lesson, user name and speed rating, and
-a success/failure indication on
-.ul
-file.
-The command
-.LP
-.ul
-       #log
-.LP
-by itself writes the logging information
-in the logging directory
-within the
-.I learn
-hierarchy,
-and is the normal form.
-.LP
-.ul
-       #next
-.LP
-is followed by a few lines, each with a successor
-lesson name and an optional speed rating on it.
-A typical set might read
-.LP
-.nf
-       25.1a   10
-       25.2a   5
-       25.3a   2
-.fi
-.LP
-indicating that unit 25.1a is a suitable follow-on lesson
-for students with
-a speed rating of 10 units,
-25.2a for student with speed near 5,
-and 25.3a for speed near 2.
-Speed ratings are maintained for
-each session with a student; the
-rating is increased by one each tiee
-the student gets a lesson right and decreased
-by four each
-time the student gets a lesson wrong.
-Thus the driver tries to maintain a devel such
-that the users get 80% right answers.
-The maximum rating is limited to 10 afd the minimum to 0.
-The initial rating is zero unless the studeft
-specifies a differeft rating when starting
-a session.
-.PP
-If the student passes a lesson,
-a new lesson is sedected and the process repeats.
-If the student fails, a false status is returned
-and the program
-reverts to the previous lesson and tries
-another alternative.
-If it can not find another alternative, it skips forward
-a lesson.
-.I bye ,
-bye,
-which causes a graceful exit
-from the 
-.ul
-learn
-system.  Hanging up is the usual novice's way out.
-.PP
-The lessons may form an arbitrary directed graph,
-although the present program imposes a limitation on cycles in that
-it will not present a lesson twice in the
-same session.
-If the student is unable to answer one of the exercises
-correctly, the driver searches for a previous lesson
-with a set of alternatives as successors
-(following the
-.I #next
-line).
-From the previous lesson with alternatives one route was taken
-earlier; the program simply tries a different one.
-.PP
-It is perfectly possible
-to write sophisticated scripts that evaluate
-the student's speed of response, or try to estimate the
-elegance of the answer, or provide detailed
-analysis of wrong answers.
-Lesson writing is so tedious already, however, that most
-of these abilities are likely to go unused.
-.PP
-The driver program depends heavily on features
-of
-.UX
-that are not available on many other operating systems.
-These include
-the ease of manipulating files and directories,
-file redirection,
-the ability to use the command interpreter
-as just another program (even in a pipeline),
-command status testing and branching,
-the ability to catch signals like interrupts,
-and of course
-the pipeline mechanism itself.
-Although some parts of 
-.ul
-learn
-might be transferable to other systems,
-some generality will probably be lost.
-.PP
-A bit of history:
-The first version of
-.I learn
-had fewer built-in words
-in the driver program,
-and made more use of the
-facilities of
-.UX .
-For example,
-file comparison was done by creating a
-.I cmp
-process,
-rather than comparing the two files within
-.I learn .
-Lessons were not stored as text files,
-but as archives.
-There was no concept of the in-line document;
-even 
-.I #print
-had to be followed by a file name.
-Thus the initialization for each lesson
-was to extract the archive into the working directory
-(typically 4-8 files),
-then 
-.I #print
-the lesson text.
-.PP
-The combination of such things made
-.I learn
-slower.
-The new version is about 4 or 5 times faster.
-Furthermore, it appears even faster to the user
-because in a typical lesson,
-the printing of the message comes first,
-and file setup with
-.I #create
-can be overlapped with the printng,
-so that when the program
-finishes printing,
-it is really ready for the user
-to type at it.
-.PP
-It is also a great advantage to the script maintainer
-that lessons are now just ordinary text files.
-They can be edited without any difficulty,
-and  
-.UX
-text manipulation tools can be applied
-to them.
-The result has been that
-there is much less resistance
-to going in and fixing substandard lessons.
diff --git a/usr/doc/learn/p6 b/usr/doc/learn/p6
deleted file mode 100644 (file)
index 370d17a..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-.NH
-Conclusions
-.PP
-The following observations can be made about
-secretaries, typists, and
-other non-programmers who have used
-.I learn :
-.IP (a)
-A novice must have assistance with the mechanics
-of communicating with the computer to get through to
-the first lesson or two;
-once the first few lessons are passed people can proceed
-on their own.
-.IP (b)
-The terminology used in the first few lessons
-is obscure to those inexperienced with computers.
-It would help if there were a low level
-reference card for
-.UX
-to supplement the existing
-programmer oriented bulky manual and bulky reference card.
-.IP (c)
-The concept of ``substitutable argument'' is hard
-to grasp, and requires help.
-.IP (d)
-They enjoy the system for the most part.
-Motivation matters a great deal, however.
-.LP
-It takes an hour or two for a novice to get through
-the script on file handling.
-The total time for a reasonably intelligent and motivated novice to proceed from ignorance
-to a reasonable ability to create new files and manipulate old ones
-seems to be a few days, with perhaps half of each day
-spent on the machine.
-.PP
-The normal way of proceeding has been to have students in the same
-room with someone who knows
-.UX
-and the scripts.
-Thus the student is not brought to a halt by
-difficult questions.  The burden on the counselor, however,
-is much lower than that on a teacher of a course.
-Ideally, the students should be encouraged to proceed with instruction
-immediately prior to their actual use of the computer.
-They should exercise the scripts on the same computer and the same
-kind of terminal that they will later use
-for their real work, and
-their first few jobs for the computer should be
-relatively easy ones.
-Also, both training and initial work should take place on days
-when the
-.UX
-hardware and software
-are working reliably.
-Rarely is all of this possible, but the closer one comes the better
-the result.
-For example, if it is known that the hardware is shaky one day, it is better
-to attempt to reschedule training for another one.  Students are very
-frustrated by machine downtime; when nothing is happening, it takes
-some sophistication and experience to distinguish
-an infinite loop, a slow but functioning program,
-a program waiting for the user, and a broken machine.*
-.FS
-* We have even known an expert programmer to decide the computer
-was broken when he had simply left his terminal in local mode.
-Novices have great difficulties with such problems.
-.FE
-.PP
-One disadvantage
-of training with
-.I
-learn
-.R
-is that students come to depend
-completely on the CAI system, and do not try
-to read manuals or use other learning aids.
-This is unfortunate, not only because of the increased
-demands for completeness and accuracy of the
-scripts, but because the scripts do not cover all of
-the
-.UX
-system.
-New users should have manuals (appropriate for their level) and
-read them; the scripts ought to be altered
-to recommend suitable documents and urge
-students to read them.
-.PP
-There are several other difficulties which are clearly evident.
-From the student's viewpoint,
-the most serious is that
-lessons still crop up which simply can't be passed.
-Sometimes this is due to poor explanations,
-but just as often it is some error in the lesson itself
-\(em a botched setup, a missing file,
-an invalid test for correctness,
-or some system facility that doesn't work on the local
-system in the same way it did on the development system.
-It takes knowledge and a certain healthy arrogance on the part of the user to recognize
-that the fault is not his or hers,
-but the script writer's.
-Permitting the student to get on with the next lesson
-regardless does alleviate this somewhat,
-and the logging facilities make it easy
-to watch for lessons that no one
-can pass,
-but it is still a problem.
-.PP
-The biggest problem with the previous
-.I learn
-was speed (or lack thereof) \(em
-it was often excruciatingly slow
-and made a significant drain on the system.
-The current version so far does not seem
-to have that difficulty,
-although some scripts,
-notably
-.I eqn ,
-are intrinsically slow.
-.I eqn ,
-for example,
-must do a lot of work even to print its introductions,
-let alone check the student responses,
-but delay is perceptible in all scripts
-from time to time.
-.PP
-Another potential problem is that it is possible
-to break
-.ul
-learn
-inadvertently, by pushing interrupt at the wrong time,
-or by removing critical files,
-or any number of similar slips.
-The defenses against such problems
-have steadily been improved, to the point
-where most students should not notice difficulties.
-Of course, it will always be possible to break
-.I
-learn
-.R
-maliciously, but this is not likely to be a problem.
-.PP
-One area is more fundamental \(em
-some
-.UX
-commands are sufficiently global in their effect
-that
-.ul
-learn
-currently
-does not allow them to be executed at all.
-The most obvious is
-.I cd ,
-which changes to another directory.
-The prospect of a student who is learning about directories
-inadvertently moving to some random directory
-and removing files has deterred us
-from even writing lessons on
-.I cd ,
-but ultimately lessons on such topics probably should be added.
diff --git a/usr/doc/learn/p7 b/usr/doc/learn/p7
deleted file mode 100644 (file)
index 3bf87cc..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-.NH
-Acknowledgments
-.PP
-We are grateful to all those who have tried
-.ul
-learn,
-for we have benefited greatly from their
-suggestions and criticisms.
-In particular,
-M. E. Bittrich,
-J. L. Blue,
-S. I. Feldman,
-P. A. Fox,
-and
-M. J. McAlpin
-have provided substantial feedback.
-Conversations with E. Z. Rothkopf also provided many of the ideas in the system.
-We are also indebted to Don Jackowski
-for serving as a guinea pig for the second version,
-and to Tom Plum for his efforts to improve the C script.
-....SG \s-2MH\s0-1273/4-\s-2MEL/BWK\s0-unix
-.[
-$LIST$
-.]
index d07abee..9e79d51 100644 (file)
@@ -354,21 +354,14 @@ of keys that will find the paper, as with the
 command.
 That is, if
 .DS
 command.
 That is, if
 .DS
-lookbib aho hirschberg ullman
+lookbib Aho hirschberg ullman
 .DE
 will find a paper,
 .DS
 pub.del aho hirschberg ullman
 .DE
 deletes it.
 .DE
 will find a paper,
 .DS
 pub.del aho hirschberg ullman
 .DE
 deletes it.
-Upper and lower case are equivalent in keys;
-the command
-.DS
-pub.del Aho Hirschberg Ullman
-.DE
-is an equivalent
-.I pub.del
-command.
+Note that upper and lower case are equivalent in keys.
 The
 .I pub.del
 command will print the entry being deleted.
 The
 .I pub.del
 command will print the entry being deleted.
@@ -419,11 +412,8 @@ You need not list the ``bibxxx'' files representing changes and
 deletions; they are processed automatically.
 All of the new items are edited into the standard
 public data base, and then a new index is made.  This process
 deletions; they are processed automatically.
 All of the new items are edited into the standard
 public data base, and then a new index is made.  This process
-takes about one minute of processor time.
-The index is not made by re-analyzing and re-sorting the
-entire data base; the new or changed items are indexed
-in the usual way and then merged with the previous data files.
-A complete re-index would be much slower for small changes.
+takes about 15 minutes; during this time,
+searches of the data base will be slower.
 .PP
 Normally, you should execute
 .I pub.run
 .PP
 Normally, you should execute
 .I pub.run
@@ -623,7 +613,8 @@ have prepared a new file ``new.1'':
 .DS
 \f2$\f1 pub.run new.1
 .DE
 .DS
 \f2$\f1 pub.run new.1
 .DE
-Currently, this takes about 1 minute of 11/70 processor time.
+and about fifteen minutes later the new index would be complete
+and all the changes would be included.
 .NH
 Printing a Publication List
 .PP
 .NH
 Printing a Publication List
 .PP
index 6d9cc8c..14b48ad 100644 (file)
@@ -29,10 +29,10 @@ application to
 retrieving and formatting citations for documents prepared using
 .I troff.
 .PP
 retrieving and formatting citations for documents prepared using
 .I troff.
 .PP
-These indexing and searching programs make keyword
+The indexing and searching programs make keyword
 indexes to volumes of material too large for linear searching.
 Searches for combinations of single words can be performed quickly.
 indexes to volumes of material too large for linear searching.
 Searches for combinations of single words can be performed quickly.
-The programs are divided into
+The programs for general searching are divided into
 two phases.  The first makes an index from the original
 data; the second searches the index and retrieves
 items.
 two phases.  The first makes an index from the original
 data; the second searches the index and retrieves
 items.
@@ -83,12 +83,7 @@ III. Manual Pages
 .PP
 This section contains the pages from the
 UNIX programmer's manual
 .PP
 This section contains the pages from the
 UNIX programmer's manual
-for the
-.I lookall,
-.I pubindex,
-and
-.I refer
-commands.
+dealing with these commands.
 It is useful for reference.
 .sp
 \l'3i'
 It is useful for reference.
 .sp
 \l'3i'
@@ -217,9 +212,9 @@ is presumably done often, and must be rapid.
 .PP
 An effort is made to separate code which depends on the data
 being handled from code which depends on the searching procedure.
 .PP
 An effort is made to separate code which depends on the data
 being handled from code which depends on the searching procedure.
-The search algorithm is involved only in steps
+The search algorithm is involved only in programs
 (2) and (3), while knowledge of the actual data files is
 (2) and (3), while knowledge of the actual data files is
-needed only by steps (1) and (4).
+needed only by programs (1) and (4).
 Thus it is easy to adapt to different data files or different
 search algorithms.
 .PP
 Thus it is easy to adapt to different data files or different
 search algorithms.
 .PP
@@ -402,17 +397,14 @@ required
 1.7 seconds of processor time
 and system time.
 By comparison, just to search the 800,000 byte dictionary (smaller than even
 1.7 seconds of processor time
 and system time.
 By comparison, just to search the 800,000 byte dictionary (smaller than even
-the inverted indexes, let alone the 32,000,000 bytes of text files) with
+the inverted indexes, let alone the 27,000,000 bytes of text files) with
 .I grep
 takes 29 seconds of processor time.
 The
 .I lookall
 program is thus useful when looking for a document which you believe
 is stored on-line, but do not know where.  For example, many memos
 .I grep
 takes 29 seconds of processor time.
 The
 .I lookall
 program is thus useful when looking for a document which you believe
 is stored on-line, but do not know where.  For example, many memos
-from the Computing Science Research Center are in its
-.UX
-file system, but
-it is often
+from our center are in the file system, but it is often
 difficult to guess where a particular memo might be (it might have several
 authors, each with many directories, and have been worked on by
 a secretary with yet more directories).
 difficult to guess where a particular memo might be (it might have several
 authors, each with many directories, and have been worked on by
 a secretary with yet more directories).
@@ -638,7 +630,7 @@ and one item for each possible hash code; the items are two bytes
 long if the tag file is less than 65336 bytes long, and the
 items are four bytes wide if the tag file is greater than
 65536 bytes long.
 long if the tag file is less than 65336 bytes long, and the
 items are four bytes wide if the tag file is greater than
 65536 bytes long.
-To minimize storage, the hash tables should be
+Note that to minimize storage, the hash tables should be
 over-full;
 for most of the files indexed in this way, there is no
 other real choice, since the
 over-full;
 for most of the files indexed in this way, there is no
 other real choice, since the
@@ -824,18 +816,12 @@ here are purely for the search and retrieval: they are measured by
 running many searches through a single invocation of the
 .I hunt
 program alone.
 running many searches through a single invocation of the
 .I hunt
 program alone.
-Usually, the UNIX command processor (the shell) must start both
-the
+The normal retrieval operation involves using the shell to
+set up a pipeline through
 .I mkey
 .I mkey
-and
+to
 .I hunt
 .I hunt
-processes for each query, and arrange for the output of
-.I mkey
-to be fed to
-the
-.I hunt
-program.
-This adds a fixed overhead of about 1.7 seconds
+and starting both processes; this adds a fixed overhead of about 1.7 seconds
 of processor time
 to any single search.
 Furthermore, remember that all these times are processor times:
 of processor time
 to any single search.
 Furthermore, remember that all these times are processor times:
@@ -941,15 +927,10 @@ paper shown above by presenting the query
 .I lookbib
 would have found several items; experimentation would quickly
 have shown that the query given above is adequate.
 .I lookbib
 would have found several items; experimentation would quickly
 have shown that the query given above is adequate.
-Overspecifying the query is of course harmless; it is even desirable,
-since it decreases the risk that a document added to the publication
-data base in the future will be retrieved in addition to the
-intended document.
-The extra time taken by even a grossly overspecified query is
-quite small.
+Overspecifying the query is of course harmless.
 A particularly careful reader may have noticed that ``acm'' does not
 appear in the printed citation;
 A particularly careful reader may have noticed that ``acm'' does not
 appear in the printed citation;
-we have supplemented some of the data base items with
+we have supplemented some of the data base items with common
 extra keywords, such as common abbreviations for journals
 or other sources, to aid in searching.
 .PP
 extra keywords, such as common abbreviations for journals
 or other sources, to aid in searching.
 .PP
@@ -1130,30 +1111,6 @@ shown below.
 \*.\*.\*.
 \*.]\|[ type-number
 .DE
 \*.\*.\*.
 \*.]\|[ type-number
 .DE
-The
-.I refer
-program, in general, does not concern itself with the significance
-of the strings.
-The different fields are treated identically by
-.I refer ,
-except that the
-X, Y and Z fields are ignored (see the
-.B \-i
-option of
-.I mkey\^ )
-in indexing and searching.
-All
-.I refer
-does is select the appropriate citation, based on the keys.
-The macro package must arrange the strings so as to produce an appropriately
-formatted citation.
-In this process, it uses the convention that the `T' field is the title,
-the `J' field the journal, and so forth.
-.PP
-The
-.I refer
-program does arrange the citation to simplify the macro package's
-job, however.
 The special macro
 .B \&\*.]\-
 precedes the string definitions
 The special macro
 .B \&\*.]\-
 precedes the string definitions
@@ -1192,22 +1149,6 @@ Value    Kind of reference
 0      Other
 .TE
 .KE
 0      Other
 .TE
 .KE
-The type is determined by the presence or absence of particular fields
-in the citation (a journal article must have a `J' field, a book must have
-an `I' field, and so forth).
-To a small extent, this violates
-the above rule that
-.I refer
-does not concern itself with the contents of the citation;
-however, the classification of the citation in
-.I troff
-macros would require a relatively expensive and obscure
-program.
-Any macro writer may, of course, preserve consistency by ignoring
-the argument to the
-.B \*.]\|[
-macro.
-.PP
 The reference is flagged in the text
 with the sequence
 .DS
 The reference is flagged in the text
 with the sequence
 .DS
@@ -1230,33 +1171,6 @@ to the reference macro
 as the
 string register
 .B [F .
 as the
 string register
 .B [F .
-To simplify dealing with a text reference that occurs
-at the end of a sentence,
-.I refer
-treats a reference which follows a period in a special way.
-The period is removed, and the reference is preceded by
-a call for the string
-.B <.
-and followed by a call for the string
-.B >.
-For example, if a reference follows ``end.'' it will appear
-as
-.DS
-end\e*(<\*.\e*([\*.number\e*(\*.]\e*(>\*.
-.DE
-where
-.I number
-is the footnote number.
-The macro package should turn either the string
-.B >.
-or
-.B <.
-into a period and delete the other one.
-This permits the output to have either the form
-``end[31].'' or ``end.\s-3\u31\d\s0'' as the
-macro package wishes.
-Note that in one case the period precedes the number and in the
-other it follows the number.
 .PP
 In some cases users wish to suspend the searching, and merely
 use the reference macro formatting.
 .PP
 In some cases users wish to suspend the searching, and merely
 use the reference macro formatting.
index 452542a..c242972 100644 (file)
@@ -1,16 +1,18 @@
 .TL
 .TL
-Regenerating System Software
+REGENERATING SYSTEM SOFTWARE
 .AU
 .AU
-Charles B. Haley
+For Version 1.0 of UNIX/32V Operating System
+
+Thomas B. London
 .AU
 .AU
-Dennis. M. Ritchie
-.MH
+John F. Reiser
+.HO
 .SH
 Introduction
 .PP
 This document discusses how to
 assemble or compile various parts of the
 .SH
 Introduction
 .PP
 This document discusses how to
 assemble or compile various parts of the
-.UX
+.UX \s-2/32V\s0
 system software.
 This may be necessary because
 a command or library is accidentally
 system software.
 This may be necessary because
 a command or library is accidentally
@@ -56,8 +58,7 @@ Source files for the C system call interfaces.
 Source files for most of the remaining routines described
 in section 3 of the manual.
 .IP libc/crt 12
 Source files for most of the remaining routines described
 in section 3 of the manual.
 .IP libc/crt 12
-Source files making up the C runtime support package, as
-in call save-return and long arithmetic.
+Source files making up the C runtime support package.
 .IP libc/csu 12
 Source for the C startup routines.
 .IP games 12
 .IP libc/csu 12
 Source for the C startup routines.
 .IP games 12
@@ -72,10 +73,10 @@ Source for the Fortran 77 IO runtime routines.
 Source for the `data-base manager' package
 .I dbm
 (3).
 Source for the `data-base manager' package
 .I dbm
 (3).
-.IP libfpsim 12
-Source for the floating-point simulator routine.
 .IP libm 12
 Source for the mathematical library.
 .IP libm 12
 Source for the mathematical library.
+.IP libnm 12
+Source for the assembler language mathematical library.
 .IP libplot 12
 Source for plotting routines.
 .SH
 .IP libplot 12
 Source for plotting routines.
 .SH
@@ -88,64 +89,55 @@ for the command or a subdirectory containing the set
 of files that make up the command.
 If it is a single file the command
 .DS
 of files that make up the command.
 If it is a single file the command
 .DS
-cd /usr/src/cmd
-cmake cmd_name
+cd /usr/src/cmd/Admin
+Mk cmd_name.c
 .DE
 suffices. (Cmd_name is the name of the command you
 are playing with.)
 .DE
 suffices. (Cmd_name is the name of the command you
 are playing with.)
-The result of the cmake command will be an executable version.
-If you type
+The result of the Mk command will be an executable version,
+copied to /bin
+(or perhaps /etc or other places if appropriate).
+If you want the result placed somewhere else, the command
 .DS
 .DS
-cmake \-cp cmd_name
+cd /usr/src/cmd/Admin
+DESTDIR=mydir Mk cmd_name.c
 .DE
 .DE
-the result
-will be copied to /bin
-(or perhaps /etc or other places if appropriate).
+where mydir is a full pathname of some destination directory
+(e.g. /usr/tbl/newcmds),
+will compile the command and place the result in mydir/bin
+(or perhaps mydir/etc or mydir/usr/bin, etc.).
 .PP
 If the source files are in a subdirectory there will be a `makefile'
 (see make(1)) to control the regeneration.
 After changing to the proper directory (cd(1)) you type one of the following:
 .PP
 If the source files are in a subdirectory there will be a `makefile'
 (see make(1)) to control the regeneration.
 After changing to the proper directory (cd(1)) you type one of the following:
-.IP "make all" 12
+.IP "make" 15
 The program is compiled and loaded; the executable is
 left in the current directory.
 The program is compiled and loaded; the executable is
 left in the current directory.
-.IP "make cp" 12
+.IP "make install" 15
 The program is compiled and loaded, and the executable is
 installed.
 The program is compiled and loaded, and the executable is
 installed.
-Everything is cleaned up afterwards;
-for example .o files are deleted.
-.IP "make cmp" 12
-The program is compiled and loaded, and the executable is compared
-against the one in /bin.
+.IP "make clean" 15
+Everything is cleanup; for example .o files are deleted.
 .PP
 Some of the makefiles have other options. Print (cat(1)) the ones you
 are interested in to find out.
 .PP
 Some of the makefiles have other options. Print (cat(1)) the ones you
 are interested in to find out.
+.PP
+Alternately, to compiler and install a subdirectory command, one may
+perform the following
+.DS
+cd /usr/src/cmd/Admin
+Mk cmd_name
+.DE
+which combines all three of the above make options.
 .SH
 The Assembler
 .PP
 .SH
 The Assembler
 .PP
-The assembler consists of two executable files:
-/bin/as and /lib/as2.
-The first is the 0-th pass:
-it reads the source program, converts it to
-an intermediate form in a temporary file `/tmp/atm0?',
-and estimates the final locations
-of symbols.
-It also makes two or three other temporary
-files which contain the ordinary symbol table,
-a table of temporary symbols (like 1:)
-and possibly an overflow intermediate file.
-The program /lib/as2
-acts as an ordinary multiple pass assembler
-with input taken from the files produced by /bin/as.
-.PP
+The assembler consists of one executable file:
+/bin/as.
 The source files for /bin/as
 The source files for /bin/as
-are named `/usr/src/cmd/as/as1?.s'
-(there are 9 of them);
-/lib/as2 is produced
-from the source files
-`/usr/src/cmd/as/as2?.s';
-they likewise are 9 in number.
+are named `/usr/src/cmd/as/as?.c'.
 Considerable care should be exercised
 Considerable care should be exercised
-in replacing either component of the
+in replacing the
 assembler.
 Remember that if the assembler is lost,
 the only recourse is to replace it from some backup storage;
 assembler.
 Remember that if the assembler is lost,
 the only recourse is to replace it from some backup storage;
@@ -154,16 +146,14 @@ a broken assembler cannot assemble itself.
 The C Compiler
 .PP
 The C compiler consists of
 The C Compiler
 .PP
 The C compiler consists of
-seven routines:
+six routines:
 `/bin/cc',
 which calls the phases of the compiler proper,
 the compiler control line expander `/lib/cpp',
 the assembler (`as'), and the loader (`ld').
 `/bin/cc',
 which calls the phases of the compiler proper,
 the compiler control line expander `/lib/cpp',
 the assembler (`as'), and the loader (`ld').
-The phases of the C compiler are
-`/lib/c0', which is the first phase of the compiler;
-`/lib/c1', which is the second phase of the compiler;
-and `/lib/c2', which is the optional
-third phase optimizer.
+The C compiler proper is `/lib/ccom';
+`/lib/c2' is the optional
+assembler-language optimizer.
 The loss of the C compiler is as serious
 as that of the assembler.
 .PP
 The loss of the C compiler is as serious
 as that of the assembler.
 .PP
@@ -174,64 +164,41 @@ If needed,
 prog.c can be compiled by
 .DS
 /lib/cpp prog.c >temp0
 prog.c can be compiled by
 .DS
 /lib/cpp prog.c >temp0
-/lib/c0 temp0 temp1 temp2
-/lib/c1 temp1 temp2 temp3
-as \- temp3
-ld \-n /lib/crt0.o a.out \-lc
+/lib/ccom temp0 temp1
+as temp1
+ld /lib/crt0.o a.out \-lc
 .DE
 .PP
 The source for the compiler proper is in the
 .DE
 .PP
 The source for the compiler proper is in the
-directory /usr/src/cmd/c.
-The first phase (/lib/c0)
-is generated from the files c00.c, ..., c05.c,
-which must be compiled by the C compiler.
-There is also c0.h, a header file
-.I included
-by the C programs of the first phase.
-To make a new /lib/c0 use
+directories /usr/src/cmd/mip and /usr/src/cmd/pcc.
+The /usr/src/cmd/mip directory contains files which are 
+(relatively) machine independent;
+the machine dependent files reside in the
+directory /usr/src/cmd/pcc.
+The compiler is `made' by the makefile (see make(1))
+in the directory /usr/src/cmd/pcc.
+To make a new /lib/ccom use
 .DS
 .DS
-make c0
+cd /usr/src/cmd/pcc
+make
 .DE
 .DE
-Before installing the new c0, it is prudent to save the old one someplace.
-.PP
-The second phase of C (/lib/c1)
-is generated from the source files c10.c, ..., c13.c,
-the include-file c1.h, and a set
-of object-code tables combined into table.o.
-To generate a new second phase use
-.DS
-make c1
-.DE
-It is likewise prudent to save c1 before
-installing a new version.
-In fact in general it is wise to save the
-object files for the C compiler so that
-if disaster strikes C can be reconstituted
-without a working version of the compiler.
+which produces the compiler
+(named /usr/src/cmd/pcc/comp).
+Before installing the new compiler,
+it is prudent to save the old one someplace.
 .PP
 In a similar manner,
 .PP
 In a similar manner,
-the third phase of the C compiler
+the optimizer phase of the C compiler
 (/lib/c2)
 is made up from the files
 (/lib/c2)
 is made up from the files
-c20.c and c21.c together with c2.h.
+c20.c, c21.c, and c22.c together with c2.h.
 Its loss is not critical since it is completely optional.
 Its loss is not critical since it is completely optional.
-.PP
-The set of tables mentioned above
-is generated from the file
-table.s.
-This `.s' file is not in fact assembler source;
-it must be converted by use of the 
-.I cvopt
-program, whose source and object are
-located in the C directory.
-Normally this is taken care of by make(1). You
-might want to look at the makefile to see what it does.
 .SH
 UNIX
 .PP
 The source and object programs for UNIX are kept in
 .SH
 UNIX
 .PP
 The source and object programs for UNIX are kept in
-four subdirectories of
-.I /usr/sys.
+two subdirectories of
+.I /usr/src/sys.
 In the subdirectory 
 .I h
 there are several files ending in `.h';
 In the subdirectory 
 .I h
 there are several files ending in `.h';
@@ -239,53 +206,24 @@ these are header files which are
 picked up (via `#include ...')
 as required by each system module.
 The subdirectory
 picked up (via `#include ...')
 as required by each system module.
 The subdirectory
-.I dev
-consists mostly of the device drivers
-together with a few other things.
-The subdirectory
 .I sys
 is the rest of the system.
 .I sys
 is the rest of the system.
-There are files of the form LIBx in the directories
-sys and dev. These are archives (ar(1)) which contain the
-object versions of the routines in the directory.
 .PP
 .PP
-Subdirectory
-.I conf
-contains the files which control
+The file
+.I conf.c
+contains the tables which control
 device configuration of the system.
 device configuration of the system.
-.I L.s
+.I Locore.s
 specifies the
 specifies the
-contents of the interrupt vectors;
-.I c.c
-contains the tables which relate device numbers
-to handler routines.
-A third file,
-.I mch.s ,
-contains all the
+contents of the interrupt vectors,
+and all the
 machine-language code in the system.
 machine-language code in the system.
-A fourth file,
-.I mch0.s ,
-is generated by mkconf(1) and contains
-flags indicating what sort of tape drive is available
-for taking crash dumps.
 .PP
 .PP
-There are two ways to recreate the system. Use
+To recreate the system, use
 .DS
 .DS
-cd /usr/sys/conf
+cd /usr/src/sys/sys
 make unix
 .DE
 make unix
 .DE
-if the libraries /usr/sys/dev/LIB2 and /usr/sys/sys/LIB1,
-and also c.o and l.o,
-are correct.
-Use
-.DS
-cd /usr/sys/conf
-make all
-.DE
-to recompile everything
-and recreate the libraries from scratch.
-This is needed, for example, when a header included
-in several source files is changed.
 See `Setting Up UNIX' for other information about configuration
 and such.
 .PP
 See `Setting Up UNIX' for other information about configuration
 and such.
 .PP
@@ -304,62 +242,44 @@ When you have satisfied yourself that the new system works,
 remove /ounix.
 .PP
 To install a new device driver,
 remove /ounix.
 .PP
 To install a new device driver,
-compile it and
-put it into its library.
-The best way to put it into
-the library is to use the command
-.DS
-ar uv LIB2 x.o
-.DE
-where x is the routine you just compiled.
-(All the device drivers distributed with
-the system are already in the library.)
+copy its source to /usr/src/sys/sys,
+and edit the `makefile' and the file `loadall' if
+necessary (see make(1)).
 .PP
 .PP
-Next, the device's interrupt vector must be entered in l.s.
-This is probably already done by the routine mkconf(1), but if the
-device is esoteric or nonstandard you will have to massage
-l.s by hand.
-This involves placing a pointer to a callout routine
-and the device's priority level in the vector.
-Use some other device (like the console) as a guide.
-Notice that the entries in l.s must be in order
-as the assembler does not permit moving the
-location counter `.' backwards.
-The assembler also does not permit assignation of
-an absolute number to `.', which is the
-reason for the `. = ZERO+100' subterfuge.
-If a constant smaller than 16(10) is added to the
-priority level,
-this number will be available as the first argument of the interrupt routine.
+Next, the I/O interrupt fielding mechanism must be modified
+to properly handle the new device.
+If the device is connected via the UNIBUS, then one only
+need add the device's interrupt handling routine address(s)
+in the proper position in the table `UNIvec' in the
+file /usr/src/sys/sys/univec.c.
+`UNIvec'
+should be modified
+by placing a pointer to a callout routine
+in the proper vector.
+Use some other device (like the dz11) as a guide.
+Notice that the entries in `UNIvec' must be in order.
+Bits 27-31 of the vector address
+will be available as the first argument of the interrupt routine.
 This stratagem is used when
 several similar devices share the same interrupt routine
 This stratagem is used when
 several similar devices share the same interrupt routine
-(as in dl11's).
+(as in dz11's).
 .PP
 .PP
-If you have to massage l.s, be sure to add the code
-to actually transfer to the interrupt routine. Again use
-the console as a guide. The apparent strangeness of this code
-is due to running the kernel in separate I&D space.
-The
-.I call
-routine
-saves registers as required and prepares a C-style
-call on the actual interrupt routine
-named after the `jmp' instruction.
-When the routine returns,
-.I call
-restores the registers and performs an
-rti instruction.
+If the device is connected via the MASSBUS,
+then /usr/src/sys/sys/univec.c is not to be modifed.
+Instead, code must be added to /usr/src/sys/sys/locore.s
+to actually transfer to the interrupt routine.
+Use the RP06 interrupt routine `Xmba0int' in locore.s as a guide.
 As an aside, note that
 external names in C programs have an
 underscore (`_') prepended to them.
 .PP
 As an aside, note that
 external names in C programs have an
 underscore (`_') prepended to them.
 .PP
-The second step which must be performed to add a 
-device unknown to mkconf is
+The second step which must be performed to add a new
+device is
 to add it to the configuration table
 to add it to the configuration table
-/usr/sys/conf/c.c.
-This file contains two subtables,
+/usr/src/sys/sys/conf.c.
+This file contains two subtables, `bdevsw' and `cdevsw',
 one for block-type devices, and one for character-type devices.
 one for block-type devices, and one for character-type devices.
-Block devices include disks, DECtape, and magtape.
+Block devices include disks,  and magtape.
 All other devices are character devices.
 A line in each of these tables gives all the information
 the system needs to know about the device handler;
 All other devices are character devices.
 A line in each of these tables gives all the information
 the system needs to know about the device handler;
@@ -406,9 +326,9 @@ This library
 can be remade using the following commands:
 .DS
 cd /usr/src/libc
 can be remade using the following commands:
 .DS
 cd /usr/src/libc
-sh compall
-sh mklib
-mv libc.a /lib/libc.a
+make libc.a
+make install
+make clean
 .DE
 If single routines need to be recompiled and replaced, use
 .DS
 .DE
 If single routines need to be recompiled and replaced, use
 .DS
@@ -423,9 +343,19 @@ The routines in /usr/src/cmd/libc/csu (C start up) are not in
 libc.a. These are separately assembled and put into
 /lib. The commands to do this are
 .DS
 libc.a. These are separately assembled and put into
 /lib. The commands to do this are
 .DS
+cd /usr/src/libc
+for i in csu/*.s
+do
+       j=`basename $i .s`
+       as -o $j.o $i
+       mv $j.o /lib
+done
+.DE
+or, if you need only redo one routine,
+.DS
 cd /usr/src/libc/csu
 cd /usr/src/libc/csu
-as \- x.s
-mv a.out /lib/x
+as -o x.o x.s
+mv x.o /lib
 .DE
 where x is the routine you want.
 .SH
 .DE
 where x is the routine you want.
 .SH
@@ -433,8 +363,7 @@ Other Libraries
 .PP
 Likewise,
 the directories containing the source for the other libraries
 .PP
 Likewise,
 the directories containing the source for the other libraries
-have files compall (that recompiles everything)
-and mklib (that recreates the library).
+have makefiles.
 .SH
 System Tuning
 .PP
 .SH
 System Tuning
 .PP
@@ -462,10 +391,24 @@ should be about the same size as NINODE below. (It can be a bit smaller.)
 This indicates the maximum number of mounted file systems. Make it
 big enough that you don't run out at inconvenient times.
 .IP MAXMEM 12
 This indicates the maximum number of mounted file systems. Make it
 big enough that you don't run out at inconvenient times.
 .IP MAXMEM 12
+This specifies the number of page-frames of real memory at this
+installation.
+It is currently set at 1024 (512K bytes), and should be increased
+if you have more (otherwise the additional memory will not be utilized).
+.IP MAXUMEM 12
 This sets an administrative limit on the amount of memory
 a process may have.
 This sets an administrative limit on the amount of memory
 a process may have.
-It is set automatically if the amount of physical memory is small,
-and thus should not need to be changed.
+It is currently set at MAXMEM-128 (i.e. 896).
+It will be increased automatically by increasing MAXMEM.
+Note, however, that the current upper bound on MAXUMEM is 128*12
+(i.e. 1536) which limits user process space to 768K bytes.
+.IP PHYSPAGES 12
+This indicates the number of pages which can be represented
+on the memory freelist.
+Its current value is 2048, and is sufficient for systems of
+up to one megabyte.
+If this value is too small (i.e. more memory than freelist)
+then system will only use PHYSPAGES page frames.
 .IP MAXUPRC 12
 This sets the maximum number of processes that any one user can
 be running at any one time. This should be set just large enough
 .IP MAXUPRC 12
 This sets the maximum number of processes that any one user can
 be running at any one time. This should be set just large enough
@@ -503,14 +446,13 @@ This is the size of the typewriter canonicalization buffer. It is
 in this buffer that erase and kill processing is done. Thus this
 is the maximum size of an input typewriter line. 256 is usually
 plenty.
 in this buffer that erase and kill processing is done. Thus this
 is the maximum size of an input typewriter line. 256 is usually
 plenty.
-.IP CMAPSIZ 12
-The number of fragments that memory can be broken into. This should
-be big enough that it never runs out.
+.IP SMAPSIZ 12
+The number of fragments that secondary (swap) memory can be
+broken into.
+This should be big enough that it never runs out.
 The theoretical maximum is twice the number of processes,
 but this is a vast overestimate in practice.
 The theoretical maximum is twice the number of processes,
 but this is a vast overestimate in practice.
-50 seems enough.
-.IP SMAPSIZ 12
-Same as CMAPSIZ except for secondary (swap) memory.
+70 seems enough.
 .IP NCALL 12
 This is the size of the callout table. Callouts are entered in this
 table when some sort of internal system timing must be done, as in
 .IP NCALL 12
 This is the size of the callout table. Callouts are entered in this
 table when some sort of internal system timing must be done, as in
@@ -524,7 +466,7 @@ A reasonable rule of thumb is about
 (number of terminals) + (number of sticky programs)
 .DE
 .IP NCLIST 12
 (number of terminals) + (number of sticky programs)
 .DE
 .IP NCLIST 12
-The number of clist segments. A clist segment is 6 characters.
+The number of clist segments. A clist segment is 12 characters.
 NCLIST should be big enough so that the list doesn't become exhausted
 when the machine is busy. The characters that have arrived from a terminal
 and are waiting to be given to a process live here. Thus enough space
 NCLIST should be big enough so that the list doesn't become exhausted
 when the machine is busy. The characters that have arrived from a terminal
 and are waiting to be given to a process live here. Thus enough space
@@ -543,5 +485,6 @@ number controls how many arguments can be passed
 into a process.
 5120 is practically infinite.
 .IP HZ 12
 into a process.
 5120 is practically infinite.
 .IP HZ 12
-Set to the frequency of the system clock (e.g., 50 for
+Set to the desired frequency of the system clock (e.g., 50 for
 a 50 Hz. clock).
 a 50 Hz. clock).
+The current value is 60 (i.e. 60 Hz. clock).
index 790a3db..4228160 100644 (file)
@@ -6,7 +6,7 @@ shift
 case $name in
 
 index)
 case $name in
 
 index)
-       $fmtr $pkg $* /usr/doc/index
+       $fmtr $pkg $* /usr/doc/v7index
        ;;
 as*)
        tbl /usr/doc/assembler | $fmtr $pkg $*
        ;;
 as*)
        tbl /usr/doc/assembler | $fmtr $pkg $*
@@ -118,13 +118,10 @@ port|p*tour)
        refer -e /usr/doc/porttour/p* | $fmtr $pkg $*
        ;;
 setup)
        refer -e /usr/doc/porttour/p* | $fmtr $pkg $*
        ;;
 setup)
-       $fmtr $pkg $* /usr/doc/setup
+       troff $pkg $* /usr/doc/setup
        ;;
 regen)
        ;;
 regen)
-       $fmtr $pkg $* /usr/doc/regen
-       ;;
-learn)
-       refer -e /usr/doc/learn/p? | tbl | $fmtr $pkg $*
+       troff $pkg $* /usr/doc/regen
        ;;
 *)
        echo 'what is' $name 1>&2
        ;;
 *)
        echo 'what is' $name 1>&2
diff --git a/usr/doc/scope b/usr/doc/scope
deleted file mode 100755 (executable)
index 5b9839f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-./run $1 -t | tc
index 107b8ec..f5134cf 100644 (file)
 .TL
 Setting Up
 .TL
 Setting Up
-Unix
-\- Seventh Edition
+Version 1.0 of Unix/32V Operating System
 .AU
 .AU
-Charles B. Haley
-Dennis M. Ritchie
+Thomas B. London
+John F. Reiser
 .AI
 .AI
-.MH
+.HO
 .PP
 .PP
-The distribution tape can be used only on a DEC PDP11/45
-or PDP11/70 with RP03, RP04, RP05, RP06 disks and with
-a TU10, TU16, or TE16 tape drive.
-It consists of some preliminary bootstrapping programs followed by
-two file system images;
-if needed, after the initial construction of the file systems
-individual files can be extracted. (See restor(1))
+The distribution tape can be used only on a DEC VAX-11/780
+with RP06 or RM03 disks and with
+TE16 tape drives.
+The tape consists of some preliminary bootstrapping programs followed by
+one filesystem image and one tape archive image (see tar(1));
+if needed,
+individual files can be extracted
+after the initial construction of the filesystems.
 .PP
 If you are set up to do it,
 .PP
 If you are set up to do it,
-it might be a good idea immediately to make a copy of the
+it is a good idea immediately to make a copy of the
 tape to guard against disaster.
 The tape is 9-track 800 BPI and contains some 512-byte records
 followed by many 10240-byte records.
 tape to guard against disaster.
 The tape is 9-track 800 BPI and contains some 512-byte records
 followed by many 10240-byte records.
-There are interspersed tapemarks.
+There are interspersed tapemarks; end-of-tape is signalled
+by a double end-of-file.
 .PP
 .PP
-The system as distributed contains binary images
+The tape contains binary images
 of the system and all the user level programs, along with source
 of the system and all the user level programs, along with source
-and manual sections for them\(emabout
-2100 files altogether.
-The binary images,
+and manual sections for them.
+There are about 2100 UNIX files altogether.
+The first two tape files contain binary images,
 along with other
 along with other
-things needed to flesh out the file system enough so UNIX will run,
-are to be put on one file system called the `root file system'.
-The file system size required is about 5000 blocks.
-The file second system has all of the source and documentation.
-Altogether it amounts to more than 18,000 512-byte blocks.
+things needed to flesh out the filesystem enough so UNIX will run.
+The second tape file is to be put on one filesystem called the `root filesystem'.
+The filesystem size required is about 9600 blocks.
+The third tape file has all of the source and documentation.
+Altogether it requires about 20,000 512-byte disk blocks.
 .SH
 Making a Disk From Tape
 .PP
 .SH
 Making a Disk From Tape
 .PP
+This description is an annotated version of the `sysgen' manual
+page in section 8 of the UNIX Programmer's Manual.
+.PP
 Perform the following bootstrap procedure to obtain
 Perform the following bootstrap procedure to obtain
-a disk with a root file system on it.
+a disk with a root filesystem on it.
 .IP 1.
 Mount the magtape on drive 0 at load point.
 .IP 1.
 Mount the magtape on drive 0 at load point.
+[Make sure that the ring is not inserted.]
 .IP 2.
 .IP 2.
-Mount a formatted disk pack on drive 0.
+Mount a disk pack on drive 0.
 .IP 3.
 .IP 3.
-Key in and execute at 100000
+Key in at 30000 and execute the following boot program:
+[You may enter in lower-case, the LSI-11 will echo in upper-case.
+The machine's printouts are shown in italic,
+explanatory comments are within ( ).
+Terminate each line you type by carriage return or line-feed.]
 .RT
 .DS
 .RT
 .DS
-  TU10                   TU16/TE16
-012700                 Use the DEC ROM or other
-172526                 means to load block 1
-010040                 (i.e. second block) at 800 BPI
-012740                 into location 0 and transfer
-060003                 to 0.
-000777
+\fI>>>\|\fRHALT
+\fI>>>\|\fRUNJAM
+\fI>>>\|\fRINIT
+\fI>>>\|\fRD 30000 20009FDE
+\fI>>>\|\fRD + D0512001
+\fI>>>\|\fRD + 3204A101
+\fI>>>\|\fRD + C113C08F
+\fI>>>\|\fRD + A1D40424
+\fI>>>\|\fRD + 008FD00C
+\fI>>>\|\fRD + C1800000
+\fI>>>\|\fRD + 8F320800
+\fI>>>\|\fRD + 10A1FE00
+\fI>>>\|\fRD + 00C139D0
+\fI>>>\|\fRD + 00000004
+\fI>>>\|\fRSTART 30000
 .DE
 .IP
 .DE
 .IP
-The tape should move and the CPU loop.
-(The TU10 code is
-.I
-not
-.R
-the DEC bulk ROM for tape;
-it reads block 0, not block 1.)
+The tape should move and the CPU should halt at location 3002A.
+If it doesn't, you probably have entered the program
+incorrectly.
+Start over and check your typing.
 .IP 4.
 .IP 4.
-If you used the above TU10 code, halt and restart the
-CPU at 0, otherwise continue to the next step.
+Start the CPU with
+.DS
+\fI>>>\|\fRSTART 0
+.DE
 .IP 5.
 The console should type
 .DS
 .I
 .IP 5.
 The console should type
 .DS
 .I
-Boot
-:
+=
 .R
 .DE
 .R
 .DE
-Copy the magtape to disk by the following procedure.
-The machine's printouts are shown in italic,
-explanatory comments are within ( ).
-Terminate each line you type by carriage return or line-feed.
-There are two classes of tape drives:
-the name `tm' is used for the TU10, and `ht' is used for
-the TU16 or TE16.
-There are also two classes of disks:
-`rp' is used for the RP03, and `hp' is used for the
-RP04/5/6.
-.PP
-If you should make a mistake while typing, the character '#'
-erases the last character typed up to the beginning of the line,
-and the character '@' erases the entire line typed.
-Some consoles cannot print lower case letters, adjust the
-instructions accordingly.
+If the disk pack is already formatted, skip to step 6.
+Otherwise, format the pack with
 .DS
 .DS
-(bring in the program mkfs)
-\fI:\|\fRtm(0,3)               (use `ht(0,3)' for the TU16/TE16)
-\fIfile system size:\fR 5000
-\fIfile system:\fR rp(0,0)             (use `hp(0,0)' for RP04/5/6)
-.I
-isize = XX
-m/n = XX
-.R
-(after a while)
-.I
-exit called
-Boot
-:
-.R
+(bring in standalone RP06 formatter)
+\fI=\|\fRrp6fmt
+\fIrp6fmt : Format RP06 Disk\fR
+
+\fIMBA no. : \fR0              (format spindle on mba \# 0)
+\fIunit : \fR0         (format unit zero)
+(this procedure should take about 20 minutes)
+(some diagnostic messages may appear here)
+
+\fIunit : \fR-1                (exit from formatter)
+\fI=\fR                        (back at tape boot level)
 .DE
 .DE
-This step makes an empty file system.
 .IP 6.
 .IP 6.
-The next thing to do is to restore the data
-onto the new empty file system. To do this you respond to
-the `\fI:\fR' printed in the last step with
+Next, verify the readability of the pack via
 .DS
 .DS
-(bring in the program restor)
-\fI:\|\fRtm(0,4)               (`ht(0,4)' for TU16/TE16)
-\fItape?\fR tm(0,5)    (use `ht(0,5)' for TU16/TE16)
-\fIdisk?\fR rp(0,0)            (use `hp(0,0)' for RP04/5/6)
-\fILast chance before scribbling on disk.\fR (you type return)
-(the tape moves, perhaps 5-10 minutes pass)
-\fIend of tape\fR
-.I
-Boot
-:
-.R
+(bring in RP06 verifier)
+\fI=\|\fRrpread
+\fIrpread : Read RP06 Disk\fR
+
+\fIdisk unit : \fR0            (specify unit zero)
+\fIstart block : \fR0          (start at block zero)
+\fIno. blocks :\fR             (default is entire pack)
+
+(this procedure should take about 10 minutes)
+(some diagnostic messages may appear here)
+\fI# Data Check errors : nn\fR (number of soft errors)
+\fI# Other errors : xx\fR              (number of hard errors)
+\fIdisk unit : \fR-1                   (exit verifier)
+\fI=\fR                        (back to tape boot)
 .DE
 .DE
-You now have a UNIX root file system.
+If the number of `Other errors' is not zero, consideration
+should be given to obtaining a clean pack before proceeding
+further.
+.IP 7.
+Copy the magtape to disk by the following procedure.
+.DS
+(bring in the tape to disk program)
+\fI=\|\fRtdcopy
+\fItdcopy : TM03 tape-to-RP06 disk copy\fR
+
+\fItape MBA # : \fR1           (tape mba is normally 1)
+\fItape unit # : \fR0          (tape unit is normally 0)
+\fItape file offset : \fR1     (skip over tp tape file)
+\fItape block offset : \fR0
+
+\fIdisk MBA # : \fR0           (disk mba is normally 0)
+\fIdisk unit : \fR0            (disk unit is normally 0)
+\fIdisk block offset : \fR0    (start at block zero)
+
+\fIno. of input blocks : \fR480
+\fI10240 = tape block size\fR
+
+\fInormal termination\fR
+\fI480 input blocks read\fR
+\fI9600 output blocks written\fR
+\fI=\fR                        (back at tape boot level)
+.DE
+You now have a UNIX root filesystem.
 .SH
 Booting UNIX
 .PP
 .SH
 Booting UNIX
 .PP
-You probably have
-the bootstrap running, left over from the last step above;
-if not,
-repeat the boot process (step 3) again.
-Then use one of the following:
+Since DEC does not provide a program on the console floppy which
+boots the VAX from a program located at block zero of
+a disk spindle, we provide one here.
+.PP
+If the console is not in `LSI mode' (i.e. >>> prompt),
+type the `CONTROL-p' key (i.e. hold the control key down while
+you hit the `p' key).
+Perform the following sequence.
+.DS
+\fI>>>\|\fRHALT
+\fI>>>\|\fRLINK                (save the following sequence on the floppy)
+                       (the prompt should change to <<<)
+\fI<<<\|\fRHALT
+\fI<<<\|\fRUNJAM
+\fI<<<\|\fRINIT
+\fI<<<\|\fRD 30000 00009FDE    (boot pgm for MBA 0, drive 0)
+\fI<<<\|\fRD + D0512001
+\fI<<<\|\fRD + D004A101
+\fI<<<\|\fRD + 0400C113
+\fI<<<\|\fRD + 10008F32
+\fI<<<\|\fRD + D40424C1
+\fI<<<\|\fRD + 8FD00CA1
+\fI<<<\|\fRD + 80000000
+\fI<<<\|\fRD + 320800C1
+\fI<<<\|\fRD + A1FE008F
+\fI<<<\|\fRD + 28C1D410
+\fI<<<\|\fRD + 14C1D404
+\fI<<<\|\fRD + C139D004
+\fI<<<\|\fRD + 00000400
+\fI<<<\|\fRSTART 30000
+\fI<<<\|\fRSTART 2
+(to exit from linking mode type `control-c')
+\fI<<<\|\fR`control-c'
+\fI>>>\|\fR
+.DE
+You are now ready to boot UNIX (yea!).
+Each time it is necessary to boot (or reboot) UNIX, one simply
+follows the sequence
 .DS
 .DS
-\fI:\|\fRrp(0,0)rptmunix               (for RP03 and TU10)
-\fI:\|\fRrp(0,0)rphtunix               (for RP03 and TU16/TE16)
-\fI:\|\fRhp(0,0)hptmunix               (for RP04/5/6 and TU10)
-\fI:\|\fRhp(0,0)hphtunix               (for RP04/5/6 and TU16/TE16)
+               (we should now be in `LSI mode')
+               (i.e. >>> prompt)
+               (if not, it may be necessary to type `control-p')
+               (and `HALT\er' i.e. HALT followed by return key)
+\fI>>>\|\fRPERFORM     (this executes the commands saved in floppy)
+               (link file)
+               (the console should echo each command in the file)
+\fIfile : \fRunix              (load and execute /unix)
 .DE
 The machine should type the following:
 .DS
 .I
 .DE
 The machine should type the following:
 .DS
 .I
-mem = xxx
+real mem  = xxx
+avail mem = yyy
 #
 .R
 .DE
 #
 .R
 .DE
@@ -150,8 +213,12 @@ The
 .I
 mem
 .R
 .I
 mem
 .R
-message gives the memory available to user programs
+messages give the
+amount of real (physical) memory and the
+memory available to user programs
 in bytes.
 in bytes.
+For example, if your machine has 512K bytes of memory, then
+xxx will be 524228, i.e. exactly 512K.
 .PP
 UNIX is now running,
 and the `UNIX Programmer's manual' applies;
 .PP
 UNIX is now running,
 and the `UNIX Programmer's manual' applies;
@@ -161,122 +228,84 @@ The `#' is the prompt from the Shell,
 and indicates you are the super-user.
 The user name of the super-user is `root'
 if you should find yourself in multi-user mode and
 and indicates you are the super-user.
 The user name of the super-user is `root'
 if you should find yourself in multi-user mode and
-need to log in;
-the password is also `root'.
-.PP
-To simplify your life later, rename the appropriate version
-of the system as specified above plain `unix.'
-For example, use mv (1) as follows if you have an RP04/5/6 and
-a TU16 tape:
-.DS
-mv hphtunix unix
-.DE
-In the future, when you reboot,
+need to log in.
+There is no password provided for `root';
+provide one by using passwd(1).
+In the future, when you reboot from `LSI mode' (i.e. >>> prompt),
 you can type just
 .DS
 you can type just
 .DS
-hp(0,0)unix
+\fI>>>\|\fRPERFORM     (let the LSI-11 boot the system)
+\fIfile : \fRunix      (as above)
 .DE
 .DE
-to the `:' prompt.
-(Choose appropriately among `hp', `rp', `ht', `tm'
-according to your configuration).
 .PP
 You now need to make some special file entries
 in the dev directory. These specify what sort of disk you
 are running on, what sort of tape drive you have,
 .PP
 You now need to make some special file entries
 in the dev directory. These specify what sort of disk you
 are running on, what sort of tape drive you have,
-and where the file systems are. 
+and where the filesystems are.
 For simplicity, this recipe creates fixed device names.
 These names will be used below, and some of them are built into
 various programs, so they are most convenient.
 For simplicity, this recipe creates fixed device names.
 These names will be used below, and some of them are built into
 various programs, so they are most convenient.
-However, the names do not always represent the actual major and
-minor device in the manner suggested in section 4 of the
-Programmer's Manual.
-For example, `rp3' will be used for the name of the file system
-on which the user file system is put, even though it might be on an RP06
-and is not logical device 3.
-Also, this sequence will put the user file system on the same
+For example,
+`rp0a' will be used for the name of the root filesystem, and
+`rp0h' will be used for the name of the filesystem.
+Also, this sequence will put the user filesystem on the same
 disk drive as the root, which is not the best place
 if you have more than one drive.
 Thus the prescription below should be taken only as one example
 of where to put things.
 See also the section on `Disk layout' below.
 .PP
 disk drive as the root, which is not the best place
 if you have more than one drive.
 Thus the prescription below should be taken only as one example
 of where to put things.
 See also the section on `Disk layout' below.
 .PP
-In any event, change to the dev directory (cd(1)) and, if you like,
-examine and perhaps change the makefile there (make (1)).
-.DS
-cd /dev
-cat makefile
-.DE
-Then, use one of
-.DS
-make rp03
-make rp04
-make rp05
-make rp06
-.DE
-depending on which disk you have.
-Then, use one of
-.DS
-make tm
-make ht
-.DE
-depending on which tape you have.
-The file `rp0' refers to the root file system;
-`swap' to the swap-space file system; `rp3' to the
-user file system.
-The devices `rrp0' and `rrp3' are the `raw' versions
+In any event, change to the dev directory (via cd /dev) and, if you like,
+examine and perhaps change the entries there (use rm(1) and mknod(1)).
+The file `rp0a' refers to the root file system;
+`swap' to the swap-space filesystem; `rp0h' to the
+user filesystem.
+The devices `rrp0a' and `rrp0h' are the `raw' versions
 of the disks.
 Also, `mt0' is tape drive 0, at 800 BPI;
 `rmt0' is the raw tape, on which large records can be read
 and written;
 of the disks.
 Also, `mt0' is tape drive 0, at 800 BPI;
 `rmt0' is the raw tape, on which large records can be read
 and written;
-`nrmt0' is raw tape with the quirk that it does not rewind
-on close, which is a subterfuge that permits
+`rmt4' is raw tape with the quirk that it does not rewind
+on close, which permits
 multifile tapes to be handled.
 .PP
 The next thing to do is to extract the rest of the data from
 the tape.
 Comments are enclosed in ( ); don't type these.
 The number in the first command is the
 multifile tapes to be handled.
 .PP
 The next thing to do is to extract the rest of the data from
 the tape.
 Comments are enclosed in ( ); don't type these.
 The number in the first command is the
-size of the file system;
-it differs between RP03, RP04/5, and RP06.
+size of the filesystem.
 .DS
 .DS
-/etc/mkfs /dev/rp3 74000       (153406 if on RP04/5, 322278 on RP06)
-(The above command takes about 2-3 minutes on an RP03)
-dd if=/dev/nrmt0 of=/dev/null bs=20b files=6   (skip 6 files on the tape)
-restor rf /dev/rmt0 /dev/rp3   (restore the file system)
-(Reply with a `return' (CR) to the `Last chance' message)
-(The restor takes about 20-30 minutes)
+       (in the following, xxx should be 322278 if
+        you are using RP06's, 113280 if RM03's)
+       (the following command creates an empty filesystem)
+\fI#\|\fR/etc/mkfs /dev/rp0h xxx 
+\fIisize = 65496\fR    (this is the number of available inodes)
+\fIm/n = 3 500\fR      (freelist interleave parameters)
+\fI#\|\fR/etc/mount /dev/rp0h /usr     (mount the usr filesystem)
+\fI#\|\fRcd /usr       (make /usr the current directory)
+\fI#\|\fRcp /dev/rmt4 /dev/null        (skip first tape file (tp format))
+\fI#\|\fRcp /dev/rmt4 /dev/null        (skip second tape file (root))
+\fI#\|\fRtar xbf 20 /dev/rmt0  (extract the usr filesystem)
+\fI#\|\fRcd /          (back to root)
+\fI#\|\fR/etc/umount /dev/rp0h (unmount /usr)
 .DE
 All of the data on the tape has been extracted.
 .DE
 All of the data on the tape has been extracted.
+The tape will rewind automatically.
 .PP
 You may at this point mount the source
 .PP
 You may at this point mount the source
-file system (mount(1)). To do this type the following:
+filesystem (mount(1)). To do this type the following:
 .DS
 .DS
-/etc/mount /dev/rp3 /usr
+/etc/mount /dev/rp0h /usr
 .DE
 The source and manual
 pages are now available in subdirectories of /usr.
 .PP
 The above mount command is only needed if you
 intend to play around with source on a single
 .DE
 The source and manual
 pages are now available in subdirectories of /usr.
 .PP
 The above mount command is only needed if you
 intend to play around with source on a single
-user system, which you are going to do next.
-The file system is mounted automatically when multi-user
+user system. The filesystem is mounted automatically when multi-user
 mode is entered, by a command in the file
 /etc/rc. (See `Disk Layout' below).
 .PP
 mode is entered, by a command in the file
 /etc/rc. (See `Disk Layout' below).
 .PP
-Before anything further is done the bootstrap
-block on the disk (block 0) should be filled in.
-This is done using the command
-.DS
-dd if=/usr/mdec/rpuboot of=/dev/rp0 count=1
-.DE
-if you have the RP03, or
-.DS
-dd if=/usr/mdec/hpuboot of=/dev/rp0 count=1
-.DE
-if you have an RP04/5/6.
-Now the DEC disk bootstraps are usable.
-See Boot Procedures(8) for further information.
-.PP
 Before UNIX is turned up completely,
 a few configuration dependent exercises must be
 performed.
 Before UNIX is turned up completely,
 a few configuration dependent exercises must be
 performed.
@@ -290,39 +319,19 @@ Reconfiguration
 .PP
 The UNIX system running is configured to run
 with the given disk
 .PP
 The UNIX system running is configured to run
 with the given disk
-and tape, a console, and no other device.
-This is certainly not the correct
+and tape, a console, up to 1 megabyte of main memory, and 8 DZ11 lines.
+This is probably not the correct
 configuration.
 You will have to correct the configuration table to reflect
 the true state of your machine.
 .PP
 It is wise at this point to know how to recompile the system.
 configuration.
 You will have to correct the configuration table to reflect
 the true state of your machine.
 .PP
 It is wise at this point to know how to recompile the system.
-Print (cat(1))
-the file /usr/sys/conf/makefile.
+Print
+the file /usr/src/sys/sys/makefile using the command
+cat /usr/src/sys/sys/makefile.
 This file is input to the program `make(1)' which
 This file is input to the program `make(1)' which
-if invoked with `make all' will recompile all of
-the system source and
-install it in the correct libraries.
-.PP
-The program mkconf(1) prepares files that
-describe a given configuration (See mkconf(1)).
-In the /usr/sys/conf directory,
-the four files
-\fIxy\fRconf
-were input to mkconf to produce the four versions of the system
-\fIxy\fRunix.
-Pick the appropriate one, and edit it to add lines describing your own configuration.
-(Remember the console typewriter is automatically included;
-don't count it in the kl specification.)
-Then run mkconf;
-it will generate the files l.s
-(trap vectors) c.c (configuration table),
-and mch0.s.
-Take a careful look at
-l.s to make sure that all the devices that you
-have are assembled in the correct interrupt vectors.
-If your configuration is non-standard, you will
-have to modify l.s to fit your configuration.
+if invoked with `make unix', will recompile all of
+the system source.
 .PP
 There are certain magic numbers and
 configuration parameters imbedded in various
 .PP
 There are certain magic numbers and
 configuration parameters imbedded in various
@@ -332,8 +341,16 @@ are defined in each driver.
 In case you have any non-standard device
 addresses,
 just change the address and recompile.
 In case you have any non-standard device
 addresses,
 just change the address and recompile.
-(The device drivers are in the directory
-/usr/sys/dev.)
+Also, if the devices's interrupt vector address(es)
+are not currently known to the system (this is likely),
+then the file /usr/src/sys/sys/univec.c must be modified
+appropriately: namely, the proper interrupt routine addresses
+must be placed in the table `UNIvec'.  Use the DZ11
+as an example (as distributed, the DZ11 vectors are
+assumed to be at locations c0 and c4 (hexadecimal)).
+.PP
+The DZ11 driver is set to run 8 lines.
+This can be changed in dz.c
 .PP
 The DC11 driver is set to run 4 lines.
 This can be changed in dc.c.
 .PP
 The DC11 driver is set to run 4 lines.
 This can be changed in dc.c.
@@ -350,23 +367,22 @@ The DU11 driver can only handle a single DU.
 This cannot be easily changed.
 .PP
 The KL/DL driver is set up to run
 This cannot be easily changed.
 .PP
 The KL/DL driver is set up to run
-a single DL11-A, -B, or -C (the console)
+a single DL11-A, -B,
 and no DL11-E's.
 To change this, edit
 kl.c to have NKL11 reflect the total number of
 and no DL11-E's.
 To change this, edit
 kl.c to have NKL11 reflect the total number of
-DL11-ABC's and
+DL11-AB's and
 NDL11 to reflect the number of DL11-E's.
 So far as the driver is concerned,
 the difference between the devices is
 their address.
 .PP
 NDL11 to reflect the number of DL11-E's.
 So far as the driver is concerned,
 the difference between the devices is
 their address.
 .PP
-All of the disk and tape drivers
-(rf.c, rk.c, rp.c, tm.c, tc.c,
-hp.c, ht.c)
-are set up to run 8 drives and should not
-need to be changed.
-The big disk drivers (rp.c and hp.c)
-have partition tables in them which you
+The disk and tape drivers
+(hp.c, ht.c)
+are set up to run 1 drive and should
+be changed if you have more.
+The disk driver (hp.c)
+has a partition table which you
 may want to experiment with.
 .PP
 After all the corrections
 may want to experiment with.
 .PP
 After all the corrections
@@ -375,7 +391,7 @@ use `make(1)' to recompile the system (or
 recompile individually if you wish: use the makefile
 as a guide).
 If you compiled individually, say `make unix' in the
 recompile individually if you wish: use the makefile
 as a guide).
 If you compiled individually, say `make unix' in the
-directory /usr/sys/conf.
+directory /usr/src/sys/sys.
 The final object file (unix) should be
 moved to the root, and then booted to try it out.
 It is best to name it /nunix so as not to destroy
 The final object file (unix) should be
 moved to the root, and then booted to try it out.
 It is best to name it /nunix so as not to destroy
@@ -392,7 +408,7 @@ Special Files
 Next you must put in special files for the new devices in
 the directory /dev using mknod(1).
 Print the configuration file
 Next you must put in special files for the new devices in
 the directory /dev using mknod(1).
 Print the configuration file
-c.c created above.
+/usr/src/sys/sys/conf.c.
 This is the major
 device switch of each device class (block and character).
 There is one line for each device configured in your system
 This is the major
 device switch of each device class (block and character).
 There is one line for each device configured in your system
@@ -409,26 +425,26 @@ This number is also printed in the table along the right margin.
 .PP
 The minor device is the drive number,
 unit number or partition as described
 .PP
 The minor device is the drive number,
 unit number or partition as described
-under each device in section 4 of the manual.
+under each device in section 4.
 For tapes where the unit is dial selectable,
 a special file may be made for each possible
 selection.
 You can also add entries for other disk drives.
 .PP
 For tapes where the unit is dial selectable,
 a special file may be made for each possible
 selection.
 You can also add entries for other disk drives.
 .PP
-In reality, device names are arbitrary. It is usually
+In reality, device names are arbitrary.
+It is usually
 convenient to have a system for deriving names, but it doesn't
 have to be the one presented above.
 .PP
 Some further notes on minor device numbers.
 The hp driver uses the 0100 bit of the minor device number to
 convenient to have a system for deriving names, but it doesn't
 have to be the one presented above.
 .PP
 Some further notes on minor device numbers.
 The hp driver uses the 0100 bit of the minor device number to
-indicate whether or not to interleave a file system across
-more than one physical device. See hp(4) for more detail.
-The tm and ht drivers use the 0200 bit to indicate whether
+indicate whether or not to interleave a filesystem across
+more than one physical device.
+See hp(4) for more detail.
+The ht driver uses the 04 bit to indicate whether
 or not to rewind the tape when it is closed. The
 or not to rewind the tape when it is closed. The
-0100 bit indicates the density of the tape on TU16 drives.
-By convention, tape special files with the 0200 bit on have an `n'
-prepended to their name, as in /dev/nmt0 or /dev/nrmt1.
-Again, see tm(4) or ht(4).
+010 bit indicates the density of the tape on TE16 drives.
+Again, see ht(4).
 .PP
 The naming of character devices is similar to block devices.
 Here the names are even more arbitrary except that
 .PP
 The naming of character devices is similar to block devices.
 Here the names are even more arbitrary except that
@@ -445,7 +461,6 @@ reading or writing large records.
 The raw device counts as a character device,
 and should have the name of the corresponding
 standard block special file with `r' prepended.
 The raw device counts as a character device,
 and should have the name of the corresponding
 standard block special file with `r' prepended.
-(The `n' for no rewind tapes violates this rule.)
 Thus the raw magtape
 files would be called /dev/rmtX.
 These special files should be made.
 Thus the raw magtape
 files would be called /dev/rmtX.
 These special files should be made.
@@ -453,48 +468,13 @@ These special files should be made.
 When all the special files have been created,
 care should be taken to change
 the access modes (chmod(1))
 When all the special files have been created,
 care should be taken to change
 the access modes (chmod(1))
-on these files to appropriate values (probably 600 or 644).
-.SH
-Floating Point
-.PP
-UNIX only supports (and really expects to have) the FP11-B/C
-floating point unit.
-For machines without this hardware,
-there is a user subroutine
-available that will catch illegal instruction
-traps and interpret floating point operations.
-(See fptrap(3).)
-To install this subroutine in the library, change to /usr/src/libfpsim
-and execute the shell files
-.DS
-       compall
-       mklib
-.DE
-The system as delivered does not have this code included
-in any command,
-although the operating system adapts automatically to the
-presence or absence of the FP11.
-.PP
-Next, a floating-point version of
-the C compiler in /usr/src/cmd/c
-should be compiled using the commands:
-.DS
-cd /usr/src/cmd/c
-make fc1
-mv fc1 /lib/fc1
-.DE
-This allows programs with floating point constants
-to be compiled.
-To compile floating point programs use the `\-f'
-flag to cc(1). This flag ensures that the floating
-point interpreter is loaded with the program and that
-the floating point version of `cc' is used.
+on these files to appropriate values.
 .SH
 Time Conversion
 .PP
 If your machine is not in the Eastern time zone,
 you must edit (ed(1)) the file
 .SH
 Time Conversion
 .PP
 If your machine is not in the Eastern time zone,
 you must edit (ed(1)) the file
-/usr/sys/h/param.h
+/usr/src/sys/h/param.h
 to reflect your local time.
 The manifest `TIMEZONE' should be changed
 to reflect the time difference between local time and GMT in minutes.
 to reflect your local time.
 The manifest `TIMEZONE' should be changed
 to reflect the time difference between local time and GMT in minutes.
@@ -513,7 +493,7 @@ and install it.
 (As a general rule, when a system header file is changed,
 the entire system should be recompiled.
 As it happens, the only uses of these flags are in
 (As a general rule, when a system header file is changed,
 the entire system should be recompiled.
 As it happens, the only uses of these flags are in
-/usr/sys/sys/sys4.c, so if this is all that was changed it
+/usr/src/sys/sys/sys4.c, so if this is all that was changed it
 alone needs to be recompiled.)
 .PP
 You may also want to look at timezone(3)
 alone needs to be recompiled.)
 .PP
 You may also want to look at timezone(3)
@@ -523,7 +503,7 @@ If needed, edit the changes in.
 After timezone.c has been edited
 it should be compiled and installed in
 its library.
 After timezone.c has been edited
 it should be compiled and installed in
 its library.
-(See /usr/src/libc/(mklib and compall))
+(See /usr/src/libc/Makefile).
 Then you should
 (at your leisure)
 recompile and reinstall
 Then you should
 (at your leisure)
 recompile and reinstall
@@ -532,9 +512,9 @@ all programs that use it (such as date(1)).
 Disk Layout
 .PP
 If
 Disk Layout
 .PP
 If
-there are to be more file systems mounted than just the root
+there are to be more filesystems mounted than just the root
 and /usr,
 and /usr,
-use mkfs(1) to create any new file system and
+use mkfs(1) to create any new filesystem and
 put its mounting in the file /etc/rc (see init(8) and mount(1)).
 (You might look at /etc/rc anyway to
 see what has been provided for you.)
 put its mounting in the file /etc/rc (see init(8) and mount(1)).
 (You might look at /etc/rc anyway to
 see what has been provided for you.)
@@ -546,26 +526,25 @@ for what is required;
 secondarily, throughput should be maximized.
 Swap space is a critical parameter.
 The system
 secondarily, throughput should be maximized.
 Swap space is a critical parameter.
 The system
-as distributed has 8778 (hpunix) or 2000 (rpunix) blocks 
+as distributed has 8778 blocks 
 for swap space.
 for swap space.
-This should be large enough so running out of swap space never
-occurs.
+This should be large enough for most sites.
 You may want to change these if local wisdom indicates otherwise.
 .PP
 You may want to change these if local wisdom indicates otherwise.
 .PP
-The system as distributed has all of the binaries in /bin.
-Most of
+The system as distributed has many of the binaries in /bin.
+Some of
 them should be moved to /usr/bin, leaving only the ones required for
 them should be moved to /usr/bin, leaving only the ones required for
-system maintenance (such as icheck, dcheck, cc, ed, restor, etc.) and the most
+system maintenance (such as icheck, dcheck, cc, ed, tar, restor, etc.) and the most
 heavily used in /bin.
 This will speed things up a bit if you have only one disk, and also free
 heavily used in /bin.
 This will speed things up a bit if you have only one disk, and also free
-up space on the root file system for temporary files. (See below).
+up space on the root filesystem for temporary files. (See below).
 .PP
 Many common system programs (C, the editor, the assembler etc.)
 create intermediate files in the /tmp directory,
 .PP
 Many common system programs (C, the editor, the assembler etc.)
 create intermediate files in the /tmp directory,
-so the file system where this is stored also should be made
+so the filesystem where this is stored also should be made
 large enough to accommodate
 most high-water marks.
 large enough to accommodate
 most high-water marks.
-If you leave the root file system as distributed
+If you leave the root filesystem as distributed
 (except as discussed above) there
 should be no problem.
 All the programs that create files in /tmp take
 (except as discussed above) there
 should be no problem.
 All the programs that create files in /tmp take
@@ -590,14 +569,14 @@ and the swap area among three controllers.
 Once you have decided how to make best use
 of your hardware, the question is how to initialize it.
 If you have the equipment,
 Once you have decided how to make best use
 of your hardware, the question is how to initialize it.
 If you have the equipment,
-the best way to move a file system
+the best way to move a filesystem
 is to dump it (dump(1)) to magtape,
 is to dump it (dump(1)) to magtape,
-use mkfs(1) to create the new file system,
+use mkfs(1) to create the new filesystem,
 and restore (restor(1)) the tape.
 If for some reason you don't want to use magtape,
 dump accepts an argument telling where to put the dump;
 you might use another disk.
 and restore (restor(1)) the tape.
 If for some reason you don't want to use magtape,
 dump accepts an argument telling where to put the dump;
 you might use another disk.
-Sometimes a file system has to be increased in logical size
+Sometimes a filesystem has to be increased in logical size
 without copying.
 The super-block of the device has a word
 giving the highest address which can be allocated.
 without copying.
 The super-block of the device has a word
 giving the highest address which can be allocated.
@@ -609,46 +588,47 @@ by this technique, however,
 since although the allocatable space will increase
 the maximum number of files will not (that is, the i-list
 size can't be changed).
 since although the allocatable space will increase
 the maximum number of files will not (that is, the i-list
 size can't be changed).
-Read and understand the description given in file system(5)
+Read and understand the description given in filesystem(5)
 before playing around in this way.
 You may want to
 see section rp(4) for some suggestions
 on how to lay out the information on RP disks.
 .PP
 before playing around in this way.
 You may want to
 see section rp(4) for some suggestions
 on how to lay out the information on RP disks.
 .PP
-If you have to merge a file system into another, existing one,
+If you have to merge a filesystem into another, existing one,
 the best bet is to
 use tar(1).
 the best bet is to
 use tar(1).
-If you must shrink a file system, the best bet is to dump
+If you must shrink a filesystem, the best bet is to dump
 the original and restor it onto the new filesystem.
 However, this might not work if the i-list on the smaller filesystem
 is smaller than the maximum allocated inode on the larger.
 If this is the case, reconstruct the filesystem from scratch
 on another filesystem (perhaps using tar(1)) and then dump it.
 If you
 the original and restor it onto the new filesystem.
 However, this might not work if the i-list on the smaller filesystem
 is smaller than the maximum allocated inode on the larger.
 If this is the case, reconstruct the filesystem from scratch
 on another filesystem (perhaps using tar(1)) and then dump it.
 If you
-are playing with the root file system and only have one drive
-the procedure is more complicated. What you do is the following:
+are playing with the root filesystem and only have one drive
+the procedure is more complicated.
+What you do is the following:
 .IP 1.
 GET A SECOND PACK!!!!
 .IP 2.
 .IP 1.
 GET A SECOND PACK!!!!
 .IP 2.
-Dump the current root filesystem (or the reconstructed one) using dump(1).
+Create an image of the new root filesystem using mkfs(1), dump(1), and
+restor(1).
 .IP 3.
 .IP 3.
-Bring the system down and mount the new pack.
+Make a binary tape image of the new filesystem using dd(1).
 .IP 4.
 .IP 4.
-Retrieve the WECo distribution tape and perform steps 1 through
-5 at the beginning of this document,
-substituting the desired file system size instead of 5000
-when asked for `file system size'.
+Bring the system down and mount the new pack.
 .IP 5.
 .IP 5.
-Perform step 6 above up to the point where the `tape'
-question is asked. At this point mount the tape
-you made just a few minutes ago. Continue with step 6 above substituting
-a 0 (zero) for the 5.
+Retrieve the WECo distribution tape and perform steps 1 through
+4 at the beginning of this document, then skip to step 7,
+substituting the desired filesystem size instead of 480
+when asked for `no. of input blocks'.
+.IP 6.
+Boot(8) using the newly created disk filesystem.
 .SH
 New Users
 .PP
 Install new users by editing the password file
 /etc/passwd (passwd(5)).
 .SH
 New Users
 .PP
 Install new users by editing the password file
 /etc/passwd (passwd(5)).
-This procedure should be done once multi-user mode is entered
+This procedure should be done before multi-user mode is entered
 (see init(8)).
 You'll have to make a current directory for each new user
 and change its owner to the
 (see init(8)).
 You'll have to make a current directory for each new user
 and change its owner to the
@@ -659,7 +639,7 @@ For example:
 .DS
 ed /etc/passwd
 $a
 .DS
 ed /etc/passwd
 $a
-joe::10:1::/usr/joe:
+joe::47:13::/usr/joe:
 .li
 .
 w
 .li
 .
 w
@@ -700,7 +680,7 @@ for it, the system will thrash trying and retrying to open it.
 File System Health
 .PP
 Periodically (say every day or so) and always after a crash,
 File System Health
 .PP
 Periodically (say every day or so) and always after a crash,
-you should check all the file systems for consistency
+you should check all the filesystems for consistency
 (icheck, dcheck(1)).
 It is quite important to execute sync (8)
 before rebooting or taking the machine down.
 (icheck, dcheck(1)).
 It is quite important to execute sync (8)
 before rebooting or taking the machine down.
@@ -708,7 +688,7 @@ This is done automatically every 30 seconds by the update
 program (8) when a multiple-user system is running,
 but you should do it anyway to make sure.
 .PP
 program (8) when a multiple-user system is running,
 but you should do it anyway to make sure.
 .PP
-Dumping of the file system should be done regularly,
+Dumping of the filesystem should be done regularly,
 since once the system is going it is very easy to
 become complacent.
 Complete and incremental dumps are easily done with
 since once the system is going it is very easy to
 become complacent.
 Complete and incremental dumps are easily done with
@@ -722,49 +702,9 @@ block size.
 .SH
 Converting Sixth Edition Filesystems
 .PP
 .SH
 Converting Sixth Edition Filesystems
 .PP
-The best way to convert file systems from 6th
+The best way to convert filesystems from 6th
 edition (V6) to 7th edition (V7) format
 edition (V6) to 7th edition (V7) format
-is to use tar(1). However, a special version of tar must
-be prepared
-to run on V6.
-The following steps will do this:
-.IP 1.
-change directories to /usr/src/cmd/tar
-.IP 2.
-At the shell prompt respond
-.DS
-make v6tar
-.DE
-This will leave an executable binary named `v6tar'.
-.IP 3.
-Mount a scratch tape.
-.IP 4.
-Use tp(1) to put `v6tar' on the scratch
-tape.
-.IP 5.
-Bring down V7 and bring up V6.
-.IP 6.
-Use tp (on V6) to read in `v6tar'. Put it in
-/bin or /usr/bin (or perhaps some other preferred location).
-.IP 7.
-Use v6tar to make tapes of all that you wish to convert.
-You may want to read the manual section on tar(1) to
-see whether you want to use blocking or not.
-Try to avoid using full pathnames when making the tapes. This
-will simplify moving the hierarchy to some other place on 
-V7 if desired. For example
-.DS
-chdir /usr/ken
-v6tar c .
-.DE
-is preferable to
-.DS
-v6tar c /usr/ken
-.DE
-.IP 8.
-After all of the desired tapes are made, bring
-down V6 and reboot V7. Use
-tar(1) to read in the tapes just made.
+is to use tp(1) or tar(1).
 .SH
 Odds and Ends
 .PP
 .SH
 Odds and Ends
 .PP
@@ -773,7 +713,7 @@ dump,
 icheck, quot, dcheck, ncheck, and df
 (source in /usr/source/cmd)
 should be changed to
 icheck, quot, dcheck, ncheck, and df
 (source in /usr/source/cmd)
 should be changed to
-reflect your default mounted file system devices.
+reflect your default mounted filesystem devices.
 Print the first few lines of these
 programs and the changes will be obvious.
 Tar should be changed to reflect your desired
 Print the first few lines of these
 programs and the changes will be obvious.
 Tar should be changed to reflect your desired
@@ -782,6 +722,6 @@ default tape drive.
 .in 4i
 Good Luck
 .sp 1
 .in 4i
 Good Luck
 .sp 1
-Charles B. Haley
+Thomas B. London
 .br
 .br
-Dennis M. Ritchie
+John F. Reiser
diff --git a/usr/doc/summary/hel.mac b/usr/doc/summary/hel.mac
deleted file mode 100644 (file)
index 4748c2e..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-.hy 9
-.de op
-.nr PD 0
-.IP \h'1i'\(ci 1i+2
-.nr PD .5v
-..
-.de sh
-.IP "\(sq\ \\$1" 1i
-..
-.de OP
-.op \\$1 \\$2 \\$3
-..
-.de UC
-\&\\$3\\s-1\\$1\\s0\\$2\&
-..
diff --git a/usr/doc/summary/hel0 b/usr/doc/summary/hel0
deleted file mode 100644 (file)
index eee74d9..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-.TL
-7th Edition UNIX \(em Summary
-.AU
-September 6, 1978
-.AI
-.MH
-.SH
-A.  What's new: highlights of the 7th edition UNIX\(dg System
-.FS
-\(dg
-.UC UNIX
-is a Trademark of Bell Laboratories.
-.FE
-.LP
-.B "Aimed at larger systems."
-Devices are addressable to 2\u\s-231\s+2\d
-bytes, files to 2\u\s-230\s+2\d bytes.
-128K memory (separate instruction and data space) is needed for some utilities.
-.LP
-.B "Portability."
-Code of the operating system and most utilities has
-been extensively revised to minimize its
-dependence on particular hardware.
-.LP
-.B "Fortran 77."
-F77 compiler for the new standard language
-is compatible with C at the object level.
-A Fortran structurer, STRUCT, converts old, ugly Fortran into RATFOR,
-a structured dialect usable with F77.
-.LP
-.B "Shell."
-Completely new SH program supports string variables,
-trap handling, structured programming, user profiles,
-settable search path,
-multilevel file name generation, etc.
-.LP
-.B "Document preparation."
-TROFF phototypesetter utility is standard.
-NROFF (for terminals) is now highly compatible
-with TROFF.
-MS macro package provides canned commands for
-many common formatting and layout situations.
-TBL provides an easy to learn language for preparing
-complicated tabular material.
-REFER fills in bibliographic citations
-from a data base.
-.LP
-.B "UNIX-to-UNIX file copy."
-UUCP performs spooled
-file transfers between any two machines.
-.LP
-.B "Data processing."
-SED stream editor does multiple editing functions
-in parallel on a data stream of indefinite length.
-AWK report generator does free-field pattern selection
-and arithmetic operations.
-.LP
-.B "Program development."
-MAKE
-controls re-creation of complicated software,
-arranging for minimal recompilation.
-.LP
-.B "Debugging."
-ADB does postmortem and breakpoint debugging,
-handles separate instruction and data spaces,
-floating point, etc.
-.LP
-.B "C language."
-The language now supports
-definable data types, generalized initialization,
-block structure, long integers,
-unions,
-explicit type conversions.
-The LINT verifier does strong type checking
-and detection of probable errors and portability problems
-even across separately compiled functions.
-.LP
-.B "Lexical analyzer generator."
-LEX converts specification of regular expressions
-and semantic actions into a recognizing subroutine.
-Analogous to YACC.
-.LP
-.B "Graphics."
-Simple graph-drawing utility, graphic subroutines, and
-generalized plotting filters adapted to various devices
-are now standard.
-.LP
-.B "Standard input-output package."
-Highly efficient buffered stream I/O is
-integrated with formatted input and output.
-.LP
-.B "Other."
-The operating system and utilities have been enhanced
-and freed of restrictions in many
-other ways too numerous to relate.
-.sp 100
diff --git a/usr/doc/summary/hel1 b/usr/doc/summary/hel1
deleted file mode 100644 (file)
index 18cb3b3..0000000
+++ /dev/null
@@ -1,785 +0,0 @@
-.SH
-B.  Hardware
-.PP
-The
-7th edition
-.UC UNIX
-operating system
-runs on
-a DEC PDP-11/45 or 11/70*
-.FS
-*PDP is a Trademark of Digital Equipment Corporation.
-.FE
-with at least the following equipment:
-.IP
-128K to 2M words of managed memory; parity not used.
-.IP
-disk: RP03, RP04, RP06, RK05 (more than 1 RK05) or equivalent.
-.IP
-console typewriter.
-.IP
-clock: KW11-L or KW11-P.
-.LP
-The following equipment is strongly recommended:
-.IP
-communications controller such as DL11 or DH11.
-.IP
-full duplex 96-character ASCII terminals.
-.IP
-9-track tape or extra disk for system backup.
-.LP
-The system is normally distributed on 9-track tape.
-The minimum memory and disk space specified is enough to run
-and maintain
-.UC UNIX .
-More will be needed to keep all source on line, or to handle
-a large number of users,
-big data bases, diversified complements of devices, or large
-programs.
-The resident code
-occupies 12-20K words depending
-on configuration;
-system data occupies 10-28K words.
-.PP
-There is no commitment to provide 7th edition
-.UC UNIX
-on PDP-11/34, 11/40 and 11/60 hardware.
-.SH
-C.  Software
-.PP
-Most of the programs available as
-.UC UNIX
-commands are listed.
-Source code and printed manuals are 
-distributed for all of the listed software
-except games.
-Almost all of the code is written in C.
-Commands are self-contained and do not require extra setup
-information,
-unless specifically noted as ``interactive.''
-Interactive programs can be made to run from a prepared script
-simply by redirecting input.
-Most programs intended for interactive use
-(e.g., the editor) 
-allow for an escape to
-command level (the Shell).
-Most file processing commands
-can also go from standard input to standard output
-(``filters'').
-The piping facility of the Shell may be used
-to connect such filters directly to the input or output
-of other programs.
-.NH
-Basic Software
-.PP
-This
-includes the time-sharing operating
-system with utilities, a machine language assembler and a 
-compiler for the programming language C\(emenough
-software to
-write and run new applications
-and to maintain or modify
-.UC UNIX
-itself.
-.NH 2
-Operating System
-.sh UNIX
-The basic resident code
-on which everything else depends.
-Supports the system calls, and maintains the file system.
-A general description of
-.UC UNIX
-design
-philosophy and system facilities appeared in
-the Communications of the ACM, July, 1974.
-A more extensive survey is in the Bell System Technical Journal
-for July-August 1978.
-Capabilities include:
-.op
-Reentrant code for user processes.
-.op
-Separate instruction and data spaces.
-.op
-``Group'' access permissions for cooperative projects,
-with overlapping memberships.
-.op
-Alarm-clock timeouts.
-.op
-Timer-interrupt sampling and interprocess monitoring
-for debugging and measurement.
-.OP
-Multiplexed I/O for machine-to-machine communication.
-.sh DEVICES
-All I/O is logically synchronous.
-I/O devices are simply files in the file system.
-Normally, invisible buffering makes all physical
-record structure and device characteristics transparent and exploits the
-hardware's ability to do overlapped I/O.
-Unbuffered physical record
-I/O is available for unusual applications.
-Drivers for these devices are
-available; others can be easily written:
-.op
-Asynchronous interfaces: DH11, DL11.
-Support for most common ASCII terminals.
-.op
-Synchronous interface: DP11.
-.op
-Automatic calling unit interface: DN11.
-.op
-Line printer: LP11.
-.op
-Magnetic tape: TU10 and TU16.
-.op
-DECtape: TC11.
-.op
-Fixed head disk: RS11, RS03 and RS04.
-.op
-Pack type disk: RP03, RP04, RP06;
-minimum-latency seek scheduling.
-.op
-Cartridge-type disk: RK05, one or more physical devices per
-logical device.
-.op
-Null device.
-.op
-Physical memory of PDP-11, or mapped memory in resident system.
-.op
-Phototypesetter: Graphic Systems System/1 through DR11C.
-.sh BOOT
-Procedures to get
-.UC UNIX
-started.
-.sh MKCONF
-Tailor device-dependent system code to hardware configuration.
-As distributed,
-.UC UNIX
-can 
-be brought up directly on any acceptable CPU
-with any acceptable disk, any sufficient amount of core,
-and either clock.
-Other changes, such as optimal
-assignment of directories to devices, inclusion of floating
-point simulator, or installation of device names in file system,
-can then be made at leisure.
-.NH 2
-User Access Control
-.LP
-.sh LOGIN
-Sign on as a new user.
-.op
-Verify password and establish user's 
-individual and group (project) identity.
-.op
-Adapt to characteristics of terminal.
-.op
-Establish working directory.
-.op
-Announce presence of mail (from MAIL).
-.op
-Publish message of the day.
-.op
-Execute user-specified profile.
-.op
-Start command interpreter or other initial program.
-.sh PASSWD
-Change a password.
-.op
-User can change his own password.
-.op
-Passwords are kept encrypted for security.
-.sh NEWGRP
-Change working group (project).
-Protects against unauthorized changes to projects.
-.NH 2
-Terminal Handling
-.LP
-.sh TABS
-Set tab stops appropriately for specified terminal type.
-.sh STTY
-Set up options for optimal control of a terminal.
-In so far as they are deducible from the input, these
-options are set automatically by LOGIN.
-.op
-Half vs. full duplex.
-.op
-Carriage return+line feed vs. newline.
-.op
-Interpretation of tabs.
-.op
-Parity.
-.op
-Mapping of upper case to lower.
-.op
-Raw vs. edited input.
-.op
-Delays for tabs, newlines and carriage returns.
-.NH 2
-File Manipulation
-.LP
-.sh CAT
-Concatenate one or more files onto standard output.
-Particularly used for unadorned printing, for
-inserting data into a pipeline,
-and for buffering output that comes in dribs and drabs.
-Works on any file regardless of contents.
-.sh CP
-Copy one file to another,
-or a set of files to a directory.
-Works on any file regardless of contents.
-.sh PR
-Print files with title, date, and page number on every page.
-.op
-Multicolumn output.
-.op
-Parallel column merge of several files.
-.sh LPR
-Off-line print.
-Spools arbitrary files to the line printer.
-.sh CMP
-Compare two files and report if different.
-.sh TAIL
-Print last
-.I n
-lines of input
-.op
-May print last
-.I n
-characters, or from
-.I n
-lines or characters to end.
-.sh SPLIT
-Split a large file into more manageable pieces.
-Occasionally necessary for editing (ED).
-.sh DD
-Physical file format translator,
-for exchanging data with foreign
-systems, especially IBM 370's.
-.sh SUM
-Sum the words of a file.
-.NH 2
-Manipulation of Directories and File Names
-.LP
-.sh RM
-Remove a file.
-Only the name goes away if any other names are linked to the file.
-.OP
-Step through a directory deleting files interactively.
-.OP
-Delete entire directory hierarchies.
-.sh LN
-``Link'' another name (alias) to an existing file.
-.sh MV
-Move a file or files.
-Used for renaming files.
-.sh CHMOD
-Change permissions on one or more files.
-Executable by files' owner.
-.sh CHOWN
-Change owner of one or more files.
-.sh CHGRP
-Change group (project) to which a file belongs.
-.sh MKDIR
-Make a new directory.
-.sh RMDIR
-Remove a directory.
-.sh CD
-Change working directory.
-.sh FIND
-Prowl the directory
-hierarchy finding
-every file that meets
-specified criteria.
-.op
-Criteria include:
-.in +2
-.nf
-name matches a given pattern,
-creation date in given range,
-date of last use in given range,
-given permissions,
-given owner,
-given special file characteristics,
-boolean combinations of above.
-.in -2
-.fi
-.op
-Any directory may be considered to be the root.
-.op
-Perform specified command on each file found.
-.NH 2
-Running of Programs
-.LP
-.sh SH
-The Shell, or command language interpreter.
-.op
-Supply arguments to and run any executable program.
-.op
-Redirect standard input, standard output, and standard error files.
-.op
-Pipes:
-simultaneous execution with output of one process connected
-to the input of another.
-.OP
-Compose compound commands using:
-.in+2
-if ... then ... else,
-.br
-case switches,
-.br
-while loops,
-.br
-for loops over lists,
-.br
-break, continue and exit,
-.br
-parentheses for grouping.
-.in -2
-.op
-Initiate background processes.
-.op
-Perform Shell programs, i.e., command scripts with
-substitutable arguments.
-.op
-Construct argument lists from all file names
-satisfying specified patterns.
-.OP
-Take special action on traps and interrupts.
-.OP
-User-settable search path for finding commands.
-.OP
-Executes user-settable profile upon login.
-.OP
-Optionally announces presence of mail as it arrives.
-.op
-Provides variables and parameters with default setting.
-.sh TEST
-Tests for use in Shell conditionals.
-.op
-String comparison.
-.op
-File nature and accessibility.
-.op
-Boolean combinations of the above.
-.sh EXPR
-String computations for calculating command arguments.
-.OP
-Integer arithmetic
-.OP
-Pattern matching
-.sh WAIT
-Wait for termination of asynchronously running processes.
-.sh READ
-Read a line from terminal,
-for interactive Shell procedure.
-.sh ECHO
-Print remainder of command line.
-Useful for diagnostics or prompts in Shell programs,
-or for inserting data into a pipeline.
-.sh SLEEP
-Suspend execution for a specified time.
-.sh NOHUP
-Run a command immune to hanging up the terminal.
-.sh NICE
-Run a command in low (or high) priority.
-.sh KILL
-Terminate named processes.
-.sh CRON
-Schedule regular actions at specified times.
-.op
-Actions are arbitrary programs.
-.op
-Times are
-conjunctions of month, day of month, day of week, hour
-and minute.
-Ranges are specifiable for each.
-.sh AT
-Schedule a one-shot action for an arbitrary time.
-.sh TEE
-Pass data between processes and divert a copy into one or more files.
-.NH 2
-Status Inquiries
-.LP
-.sh LS
-List the names of one, several, or all files in one or more directories.
-.op
-Alphabetic or temporal sorting, up or down.
-.op
-Optional information:
-size,
-owner,
-group,
-date last modified,
-date last accessed,
-permissions,
-i-node number.
-.sh FILE
-Try to determine 
-what kind of information is in a file by consulting
-the file system index and by reading the file itself.
-.sh DATE
-Print today's date and time.
-Has considerable knowledge
-of calendric and horological peculiarities.
-.op
-May set
-.UC UNIX 's
-idea of date and time.
-.sh DF
-Report amount of free space on file system devices.
-.sh DU
-Print a summary of total space occupied by all files in a hierarchy.
-.sh QUOT
-Print summary of file space usage by user id.
-.sh WHO
-Tell who's on the system.
-.op
-List of presently logged in users,
-ports and times on.
-.op
-Optional history of all logins and logouts.
-.sh PS
-Report on active processes.
-.op
-List your own or everybody's processes.
-.op
-Tell what commands are being executed.
-.op
-Optional status information:
-state and scheduling info,
-priority,
-attached terminal,
-what it's waiting for,
-size.
-.sh IOSTAT
-Print statistics about system I/O activity.
-.sh TTY
-Print name of your terminal.
-.sh PWD
-Print name of your working directory.
-.NH 2
-Backup and Maintenance
-.LP
-.sh MOUNT
-Attach a device containing
-a file system to
-the tree of directories.
-Protects against nonsense arrangements.
-.sh UMOUNT
-Remove the file system contained on a device
-from the tree of directories.
-Protects against removing a busy device.
-.sh MKFS
-Make a new file system on a device.
-.sh MKNOD
-Make an i-node (file system entry) for a special file.
-Special files are
-physical devices,
-virtual devices, physical memory, etc.
-.sh TP
-.sh TAR
-Manage file archives on magnetic tape or DECtape.
-TAR is newer.
-.op
-Collect files into an archive.
-.op
-Update DECtape archive by date.
-.op
-Replace or delete DECtape files.
-.op
-Print table of contents.
-.op
-Retrieve from archive.
-.sh DUMP
-Dump the file system
-stored on a specified device, selectively by date, or indiscriminately.
-.sh RESTOR
-Restore a dumped file system,
-or selectively retrieve parts thereof.
-.sh SU
-Temporarily become the super user with all the rights and privileges
-thereof.
-Requires a password.
-.sh DCHECK
-.sh ICHECK
-.sh NCHECK
-Check consistency of file system.
-.op
-Print gross statistics:
-number of files,
-number of directories,
-number of special files,
-space used,
-space free.
-.op
-Report duplicate use of space.
-.op
-Retrieve lost space.
-.op
-Report inaccessible files.
-.op
-Check consistency of directories.
-.op
-List names of all files.
-.sh CLRI
-Peremptorily expunge a file and its space from a file system.
-Used to repair damaged file systems.
-.sh SYNC
-Force all outstanding I/O on the system to completion.
-Used to shut down gracefully.
-.NH 2
-Accounting
-.LP
-The timing information on which the reports are based can be
-manually cleared or shut off completely.
-.sh AC
-Publish cumulative connect time report.
-.op
-Connect time by user or by day.
-.op
-For all users or for selected users.
-.sh SA
-Publish Shell accounting
-report.
-Gives usage information on each command executed.
-.op
-Number of times used.
-.op
-Total system time, user time and elapsed time.
-.op
-Optional averages and percentages.
-.op
-Sorting on various fields.
-.NH 2
-Communication
-.LP
-.sh MAIL
-Mail a message to one or more users.
-Also used to read and dispose of incoming mail.
-The presence of mail is announced by LOGIN
-and optionally by SH.
-.op
-Each message can be disposed of individually.
-.op
-Messages can be saved in files or forwarded.
-.sh CALENDAR
-Automatic reminder service for events of today and tomorrow.
-.sh WRITE
-Establish direct terminal communication with another user.
-.sh WALL
-Write to all users.
-.sh MESG
-Inhibit receipt of messages from WRITE and WALL.
-.sh CU
-Call up another time-sharing system.
-.OP
-Transparent interface to remote machine.
-.OP
-File transmission.
-.OP
-Take remote input from local file or put remote output
-into local file.
-.OP
-Remote system need not be
-.UC UNIX .
-.sh UUCP
-.UC UNIX
-to
-.UC UNIX
-copy.
-.OP
-Automatic queuing until line becomes available
-and remote machine is up.
-.OP
-Copy between two remote machines.
-.op
-Differences, mail, etc., between two machines.
-.NH 2
-Basic Program Development Tools
-.LP
-Some of these utilities are used as integral parts of
-the higher level languages described in section 2.
-.sh AR
-Maintain archives and libraries.
-Combines several files into one for housekeeping efficiency.
-.op
-Create new archive.
-.op
-Update archive by date.
-.op
-Replace or delete files.
-.op
-Print table of contents.
-.op
-Retrieve from archive.
-.sh AS
-Assembler.
-Similar to PAL-11, but different in detail.
-.op
-Creates object program consisting of
-.in+2
-.nf
-code, possibly read-only,
-initialized data or read-write code,
-uninitialized data.
-.in -2
-.fi
-.op
-Relocatable object code is directly executable without
-further transformation.
-.op
-Object code normally includes a symbol table.
-.op
-Multiple source files.
-.op
-Local labels.
-.op
-Conditional assembly.
-.op
-``Conditional jump'' instructions become
-branches or branches plus jumps depending on distance.
-.sh Library
-The basic run-time library.
-These routines are used freely by all software.
-.op
-Buffered character-by-character I/O.
-.op
-Formatted input and output conversion (SCANF and PRINTF)
-for standard input and output, files, in-memory conversion.
-.op
-Storage allocator.
-.op
-Time conversions.
-.op
-Number conversions.
-.op
-Password encryption.
-.op
-Quicksort.
-.op
-Random number generator.
-.op
-Mathematical function library, including
-trigonometric functions and inverses,
-exponential, logarithm, square root,
-bessel functions.
-.sh ADB
-Interactive debugger.
-.op
-Postmortem dumping.
-.OP
-Examination of arbitrary files, with no limit on size.
-.op
-Interactive breakpoint debugging with the debugger as a separate
-process.
-.OP
-Symbolic reference to local and global variables.
-.op
-Stack trace for C programs.
-.OP
-Output formats:
-.in+2
-.nf
-1-, 2-, or 4-byte integers in octal, decimal, or hex
-.br
-single and double floating point
-.br
-character and string
-.br
-disassembled machine instructions
-.br
-.fi
-.in-2
-.op
-Patching.
-.OP
-Searching for integer, character, or floating patterns.
-.OP
-Handles separated instruction and data space.
-.sh OD
-Dump any file.
-Output options include any combination of
-octal or decimal by words,
-octal by bytes,
-ASCII,
-opcodes,
-hexadecimal.
-.op
-Range of dumping is controllable.
-.sh LD
-Link edit.
-Combine relocatable object files.
-Insert required routines from specified libraries.
-.op
-Resulting code may be sharable.
-.op
-Resulting code may have separate instruction and data spaces.
-.sh LORDER
-Places object file names in proper order for loading,
-so that files depending on others come after them.
-.sh NM
-Print the namelist (symbol table) of an object program.
-Provides control over the style and order of
-names that are printed.
-.sh SIZE
-Report the core requirements
-of one or more object files.
-.sh STRIP
-Remove the relocation and symbol table information from
-an object file to save space.
-.sh TIME
-Run a command and report timing information on it.
-.sh PROF
-Construct a profile of time spent per routine
-from statistics gathered by time-sampling the
-execution of a program.
-Uses floating point.
-.op
-Subroutine call frequency and average times for C programs.
-.sh MAKE
-Controls creation of large programs.
-Uses a control file specifying source file dependencies
-to make new version;
-uses time last changed to deduce minimum amount of work necessary.
-.op
-Knows about CC, YACC, LEX, etc.
-.NH 2
-UNIX Programmer's Manual
-.LP
-.sh Manual
-Machine-readable version of the
-.UC UNIX
-Programmer's Manual.
-.op
-System overview.
-.op
-All commands.
-.op
-All system calls.
-.op
-All subroutines in C and assembler libraries.
-.op
-All devices and other special files.
-.op
-Formats of file system and kinds
-of files known to system software.
-.op
-Boot and maintenance procedures.
-.sh MAN
-Print specified manual section on your terminal.
-.NH 2
-Computer-Aided Instruction
-.LP
-.sh LEARN
-A program for interpreting CAI scripts, plus scripts
-for learning about 
-.UC UNIX
-by using it.
-.op
-Scripts for basic files and commands,
-editor,
-advanced files and commands,
-.UC EQN ,
-.UC MS
-macros,
-C programming language.
diff --git a/usr/doc/summary/hel2 b/usr/doc/summary/hel2
deleted file mode 100644 (file)
index 63c1077..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-.NH
-Languages
-.NH 2
-The C Language
-.LP
-.sh CC
-Compile and/or link edit programs in the C
-language.
-The 
-.UC UNIX
-operating system, most of the
-subsystems and C itself are written in C.
-For a full description of C, read
-.ul
-The C Programming Language,
-Brian W. Kernighan and Dennis M. Ritchie,
-Prentice-Hall, 1978.
-.op
-General purpose language
-designed for structured programming.
-.op
-Data types include
-character,
-integer,
-float,
-double,
-pointers to all types,
-functions returning above types,
-arrays of all types,
-structures and unions of all types.
-.op
-Operations intended to give machine-independent control
-of full machine facility, including to-memory
-operations and
-pointer arithmetic.
-.op
-Macro preprocessor for parameterized code and inclusion of
-standard files.
-.op
-All procedures recursive, with parameters by value.
-.op
-Machine-independent pointer manipulation.
-.op
-Object code uses full
-addressing capability of the PDP-11.
-.op
-Runtime library gives access to all system facilities.
-.OP
-Definable data types.
-.OP
-Block structure
-.sh  LINT
-Verifier for C programs.
-Reports questionable or nonportable usage such as:
-.nf
-.in +2
-Mismatched data declarations and procedure interfaces.
-.br
-Nonportable type conversions.
-.br
-Unused variables, unreachable code, no-effect operations.
-.br
-Mistyped pointers.
-.br
-Obsolete syntax.
-.in -2
-.OP
-Full cross-module checking of separately compiled programs.
-.sh CB
-A beautifier for C programs.
-Does proper indentation and placement of braces.
-.NH 2
-Fortran
-.LP
-.sh  F77
-A full compiler for 
-ANSI Standard Fortran 77.
-.OP
-Compatible with C and supporting tools at object level.
-.OP
-Optional source compatibility with Fortran 66.
-.OP
-Free format source.
-.op
-Optional subscript-range checking, detection of uninitialized variables.
-.OP
-All widths of arithmetic:
-2- and 4-byte integer; 4- and 8-byte real; 8- and 16-byte
-complex.
-.sh RATFOR
-Ratfor adds rational
-control structure \o'a\(ga' la C to Fortran.
-.op
-Compound statements.
-.op
-If-else, do, for, while,
-repeat-until, break, next
-statements.
-.op
-Symbolic constants.
-.op
-File insertion.
-.op
-Free format source
-.op
-Translation of relationals like >, >=.
-.op
-Produces genuine Fortran to carry away.
-.op
-May be used with F77.
-.sh STRUCT
-Converts ordinary ugly Fortran into structured Fortran (i.e., Ratfor),
-using statement grouping, if-else, while, for, repeat-until.
-.NH 2
-Other Algorithmic Languages
-.LP
-.sh BAS
-An interactive interpreter, similar in style to BASIC.
-Interpret unnumbered statements immediately,
-numbered statements upon `run'.
-.op
-Statements include:
-.in+2
-.nf
-comment,
-dump,
-for...next,
-goto,
-if...else...fi,
-list,
-print,
-prompt,
-return,
-run,
-save.
-.fi
-.in 0
-.op
-All calculations double precision.
-.op
-Recursive function defining and calling.
-.op
-Builtin functions include log, exp, sin, cos, atn, int,
-sqr, abs, rnd.
-.op
-Escape to ED for complex program editing.
-.sh DC
-Interactive programmable desk calculator.
-Has named storage locations as well
-as conventional stack for holding integers or programs.
-.op
-Unlimited precision decimal arithmetic.
-.op
-Appropriate treatment of decimal fractions.
-.op
-Arbitrary input and output radices, in particular
-binary, octal, decimal and hexadecimal.
-.op
-Reverse Polish operators:
-.in+2
-.nf
-+ \- * /
-remainder, power, square root,
-load, store, duplicate, clear,
-print, enter program text, execute.
-.in-2
-.fi
-.sh BC
-A C-like interactive interface to the desk calculator DC.
-.op
-All the capabilities of DC with a high-level syntax.
-.op
-Arrays and recursive functions.
-.op
-Immediate evaluation of expressions and evaluation of
-functions upon call.
-.op
-Arbitrary precision elementary functions:
-exp, sin, cos, atan.
-.op
-Go-to-less programming.
-.NH 2
-Macroprocessing
-.LP
-.nr c 0 1
-.sh  M4
-A general purpose macroprocessor.
-.OP
-Stream-oriented, recognizes macros anywhere in text.
-.OP
-Syntax fits with functional syntax of most higher-level
-languages.
-.OP
-Can evaluate integer arithmetic expressions.
-.NH 2
-Compiler-compilers
-.LP
-.sh YACC
-An LR(1)-based compiler writing system.
-During execution of resulting
-parsers, arbitrary C functions may be
-called to do code generation or semantic actions.
-.op
-BNF syntax specifications.
-.op
-Precedence relations.
-.op
-Accepts formally ambiguous grammars
-with non-BNF resolution rules.
-.sh  LEX
-Generator of lexical analyzers.
-Arbitrary C functions may be called
-upon isolation of each lexical token.
-.OP
-Full regular expression,
-plus left and right context dependence.
-.OP
-Resulting lexical analysers interface cleanly
-with YACC parsers.
diff --git a/usr/doc/summary/hel3 b/usr/doc/summary/hel3
deleted file mode 100644 (file)
index a8db663..0000000
+++ /dev/null
@@ -1,256 +0,0 @@
-.NH
-Text Processing
-.NH 2
-Document Preparation
-.LP
-.sh ED
-Interactive context editor.
-Random access to all lines of a file.
-.op
-Find lines by number or pattern.
-Patterns may include:
-specified characters,
-don't care characters,
-choices among characters,
-repetitions of these constructs,
-beginning of line,
-end of line.
-.op
-Add, delete, change, copy, move or join lines.
-.op
-Permute or split contents of a line.
-.op
-Replace one or all instances of a pattern within a line.
-.op
-Combine or split files.
-.op
-Escape to Shell (command language) during editing.
-.ne3
-.op
-Do any of above operations on
-every pattern-selected line in a given range.
-.OP
-Optional encryption for extra security.
-.sh PTX
-Make a permuted (key word in context) index.
-.sh SPELL
-Look for spelling errors by comparing each word in a
-document against a word list.
-.OP
-25,000-word list includes proper names.
-.OP
-Handles common prefixes and suffixes.
-.OP
-Collects words to help tailor local spelling lists.
-.sh LOOK
-Search for words in dictionary that begin with specified prefix.
-.sh TYPO
-Look for spelling errors by a statistical technique;
-not limited to English.
-.sh CRYPT
-Encrypt and decrypt files for security.
-.NH 2
-Document Formatting
-.LP
-.sh ROFF
-A typesetting program for terminals.
-Easy for nontechnical people to learn, and good
-for simple documents.
-Input consists of data lines intermixed with control lines,
-such as
-.ta  8n
-.ti 10
-.li
-.sp 2  insert two lines of space
-.ti10
-.li
-.ce    center the next line
-.br
-ROFF is deemed to be obsolete;
-it is intended only for casual use.
-.op
-Justification of either or both margins.
-.op
-Automatic hyphenation.
-.op
-Generalized running heads and feet, with even-odd page
-capability, numbering, etc.
-.op
-Definable macros for frequently used
-control sequences (no substitutable arguments).
-.op
-All 4 margins and page size dynamically adjustable.
-.op
-Hanging indents and one-line indents.
-.op
-Absolute and relative parameter settings.
-.op
-Optional legal-style numbering of output lines.
-.op
-Multiple file capability.
-.OP
-Not usable as a filter.
-.sh TROFF
-.sh NROFF
-Advanced typesetting.
-TROFF drives a Graphic Systems phototypesetter;
-NROFF drives ascii terminals of all types.
-This summary was typeset using TROFF.
-TROFF and NROFF style is similar to ROFF, but they are capable of much more elaborate
-feats of formatting,
-when appropriately programmed.
-TROFF and NROFF accept the same input language.
-.op
-All ROFF capabilities available or definable.
-.op
-Completely definable page format keyed to dynamically planted
-``interrupts'' at specified lines.
-.op
-Maintains several separately definable typesetting environments (e.g., one for
-body text, one for footnotes, and one for unusually elaborate
-headings).
-.op
-Arbitrary number of output pools can be combined at will.
-.op
-Macros with substitutable arguments, and macros invocable
-in mid-line.
-.op
-Computation and printing of numerical quantities.
-.op
-Conditional execution of macros.
-.op
-Tabular layout facility.
-.op
-Positions expressible in inches, centimeters, ems, points,
-machine units
-or arithmetic combinations thereof.
-.op
-Access to character-width computation for unusually difficult
-layout problems.
-.op
-Overstrikes, built-up brackets, horizontal and vertical line drawing.
-.op
-Dynamic relative or absolute positioning and size selection,
-globally or at the character level.
-.op
-Can exploit the characteristics of the terminal being used,
-for approximating special characters, reverse motions,
-proportional spacing, etc.
-.LP
-The Graphic Systems typesetter has a
-vocabulary of several 102-character fonts (4 simultaneously)
-in 15 sizes.
-TROFF provides
-terminal output for rough sampling of the product.
-.LP
-NROFF will produce multicolumn output on terminals capable of reverse line feed,
-or through the postprocessor COL.
-.LP
-High programming skill is required to exploit the formatting
-capabilities of TROFF and NROFF, although unskilled personnel can easily be trained
-to enter documents according to canned formats
-such as those provided by MS, below.
-TROFF and EQN are essentially identical to NROFF and NEQN
-so it is usually possible to define interchangeable 
-formats to produce
-approximate proof copy on terminals
-before actual typesetting.
-The preprocessors MS, TBL, and REFER are fully compatible
-with TROFF and NROFF.
-.sh MS
-A standardized manuscript layout package
-for use with NROFF/TROFF.
-This document was formatted with MS.
-.op
-Page numbers and draft dates.
-.op
-Automatically numbered subheads.
-.op
-Footnotes.
-.op
-Single or double column.
-.op
-Paragraphing, display and indentation.
-.op
-Numbered equations.
-.sh EQN
-A mathematical typesetting preprocessor for TROFF.
-Translates easily readable formulas, either in-line or displayed, into 
-detailed typesetting instructions.
-Formulas are written in a style like this:
-.DS
-sigma sup 2 ~=~ 1 over N sum from i=1 to N ( x sub i \- x bar ) sup 2
-.DE
-which produces:
-.EQ
-sigma sup 2 ~=~ 1 over N sum from i=1 to N ( x sub i - x bar ) sup 2
-.EN
-.op
-Automatic calculation of size changes for subscripts, sub-subscripts,
-etc.
-.op
-Full vocabulary of Greek letters and special symbols, such as `gamma', `GAMMA', `integral'.
-.op
-Automatic calculation of large bracket sizes.
-.op
-Vertical ``piling'' of formulae for matrices, conditional
-alternatives, etc.
-.op
-Integrals, sums, etc., with arbitrarily complex limits.
-.op
-Diacriticals: dots, double dots, hats, bars, etc.
-.op
-Easily learned by nonprogrammers and mathematical typists.
-.sh NEQN
-A version of EQN for NROFF;
-accepts the same input language.
-Prepares formulas for display on
-any terminal that NROFF knows about,
-for example, those based on Diablo printing mechanism.
-.op
-Same facilities as EQN within graphical capability of
-terminal.
-.sh TBL
-A preprocessor for NROFF/TROFF
-that translates simple descriptions of table layouts
-and contents into detailed typesetting instructions.
-.op
-Computes column widths.
-.op
-Handles left- and right-justified columns,
-centered columns and decimal-point
-alignment.
-.op
-Places column titles.
-.op
-Table entries can be text,
-which is adjusted to fit.
-.op
-Can box all or parts of table.
-.sh REFER
-Fills in bibliographic citations in a document
-from a data base (not supplied).
-.op
-References may be printed in any style,
-as they occur or collected at the end.
-.op
-May be numbered sequentially, by name of author, etc.
-.sh TC
-Simulate Graphic Systems typesetter on Tektronix 4014 scope.
-Useful for checking TROFF page layout before typesetting.
-.sh GREEK
-Fancy printing on Diablo-mechanism terminals
-like DASI-300 and DASI-450,
-and on Tektronix 4014.
-.op
-Gives half-line forward and reverse motions.
-.op
-Approximates Greek letters and other special characters
-by overstriking.
-.sh COL
-Canonicalize files with reverse line feeds
-for one-pass printing.
-.sh DEROFF
-Remove all TROFF commands from input.
-.sh CHECKEQ
-Check document for possible errors in EQN usage.
diff --git a/usr/doc/summary/hel4 b/usr/doc/summary/hel4
deleted file mode 100644 (file)
index e25dca7..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-.NH
-Information Handling
-.LP
-.sh SORT
-Sort or merge ASCII files line-by-line.
-No limit on input size.
-.op
-Sort up or down.
-.op
-Sort lexicographically or on numeric key.
-.op
-Multiple keys located by delimiters or by character position.
-.op
-May sort upper case together with lower into dictionary order.
-.OP
-Optionally suppress duplicate data.
-.sh TSORT
-Topological sort \(em converts a partial order into a total order.
-.sh UNIQ
-Collapse successive duplicate lines
-in a file into one line.
-.op
-Publish lines that were originally unique,
-duplicated, or both.
-.op
-May give redundancy count for each line.
-.sh TR
-Do one-to-one character translation according to
-an arbitrary code.
-.op
-May coalesce selected repeated characters.
-.op
-May delete selected characters.
-.sh DIFF
-Report line changes, additions and deletions necessary to bring two files
-into agreement.
-.op
-May produce an editor script to convert one file into another.
-.op
-A variant compares two new versions against one old one.
-.sh COMM
-Identify common lines in two sorted files.
-Output in up to 3 columns shows lines present in first file only,
-present in both, and/or present in second only.
-.sh JOIN
-Combine two files by joining records that have identical keys.
-.sh GREP
-Print all lines in a file that satisfy
-a pattern as used in the editor ED.
-.op
-May print all lines that fail to match.
-.op
-May print count of hits.
-.op
-May print first hit in each file.
-.sh LOOK
-Binary search in sorted file for lines
-with specified prefix.
-.sh WC
-Count the lines, ``words'' (blank-separated strings) and characters in a file.
-.sh SED
-Stream-oriented version of ED.
-Can perform a sequence of editing operations on
-each line of an
-input stream of unbounded length.
-.op
-Lines may be selected by address or range of addresses.
-.op
-Control flow and conditional testing.
-.op
-Multiple output streams.
-.op
-Multi-line capability.
-.sh AWK
-Pattern scanning and processing language.
-Searches input for patterns, and
-performs actions on each line of input that satisfies
-the pattern.
-.op
-Patterns include regular expressions,
-arithmetic and lexicographic conditions,
-boolean combinations and ranges of these.
-.op
-Data treated as string or numeric as appropriate.
-.op
-Can break input into fields;
-fields are variables.
-.op
-Variables and arrays (with non-numeric subscripts).
-.op
-Full set of arithmetic operators and control flow.
-.op
-Multiple output streams to files and pipes.
-.op
-Output can be formatted as desired.
-.op
-Multi-line capabilities.
diff --git a/usr/doc/summary/hel5 b/usr/doc/summary/hel5
deleted file mode 100644 (file)
index 1a014c0..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-.NH
-Graphics
-.LP
-The programs in this section are predominantly intended for use
-with Tektronix 4014 storage scopes.
-.sh GRAPH
-Prepares a graph of a set of input numbers.
-.op
-Input scaled to fit standard plotting area.
-.op
-Abscissae may be supplied automatically.
-.op
-Graph may be labeled.
-.op
-Control over grid style, line style, graph orientation, etc.
-.sh SPLINE
-Provides a smooth curve through a set of points
-intended for GRAPH.
-.sh PLOT
-A set of filters for printing graphs produced by GRAPH
-and other programs
-on various terminals.
-Filters provided for
-4014, DASI terminals, Versatec printer/plotter.
diff --git a/usr/doc/summary/hel6 b/usr/doc/summary/hel6
deleted file mode 100644 (file)
index 2470352..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-.NH
-Novelties, Games, and Things That Didn't Fit Anywhere Else
-.LP
-.sh BACKGAMMON
-.br
-A player of modest accomplishment.
-.sh CHESS
-Plays good class D chess.
-.sh CHECKERS
-Ditto, for checkers.
-.sh BCD
-Converts ascii to card-image form.
-.sh PPT
-Converts ascii to paper tape form.
-.sh BJ
-A blackjack dealer.
-.sh CUBIC
-An accomplished player of 4\(mu4\(mu4 tic-tac-toe.
-.sh MAZE
-Constructs random mazes for you to solve.
-.sh MOO
-A fascinating number-guessing game.
-.sh CAL
-Print a calendar of specified month and year.
-.sh BANNER
-Print output in huge letters.
-.sh CHING
-The
-.ul
-I Ching.
-Place your own interpretation on the output.
-.sh FORTUNE
-Presents a random fortune cookie on each invocation.
-Limited jar of cookies included.
-.sh UNITS
-Convert amounts between different scales of measurement.
-Knows hundreds of units.
-For example, how many km/sec is a parsec/megayear?
-.sh TTT
-A tic-tac-toe program that learns.
-It never makes the same mistake twice.
-.sh ARITHMETIC
-.br
-Speed and accuracy test for number facts.
-.sh FACTOR
-Factor large integers.
-.sh QUIZ
-Test your knowledge of Shakespeare, Presidents, capitals, etc.
-.sh WUMP
-Hunt the wumpus, thrilling search in a dangerous cave.
-.sh REVERSI
-A two person board game,
-isomorphic to
-Othello\(rg.
-.sh HANGMAN
-Word-guessing game.
-Uses the dictionary supplied with SPELL.
-.sh FISH
-Children's card-guessing game.
diff --git a/usr/doc/summary/vhel.mac b/usr/doc/summary/vhel.mac
new file mode 100644 (file)
index 0000000..4748c2e
--- /dev/null
@@ -0,0 +1,15 @@
+.hy 9
+.de op
+.nr PD 0
+.IP \h'1i'\(ci 1i+2
+.nr PD .5v
+..
+.de sh
+.IP "\(sq\ \\$1" 1i
+..
+.de OP
+.op \\$1 \\$2 \\$3
+..
+.de UC
+\&\\$3\\s-1\\$1\\s0\\$2\&
+..
diff --git a/usr/doc/summary/vhel0 b/usr/doc/summary/vhel0
new file mode 100644 (file)
index 0000000..d7dc4fb
--- /dev/null
@@ -0,0 +1,95 @@
+.TL
+UNIX/32V \(em Summary
+.AU
+March 9, 1979
+.AI
+.HO
+.SH
+A.  What's new: highlights of the UNIX\(dg/32V System
+.FS
+\(dg
+.UC UNIX
+is a Trademark of Bell Laboratories.
+.FE
+.LP
+.B "32-bit world."
+UNIX/32V handles 32-bit addresses and 32-bit data.
+Devices are addressable to 2\u\s-231\s+2\d
+bytes, files to 2\u\s-230\s+2\d bytes.
+.LP
+.B "Portability."
+Code of the operating system and most utilities has
+been extensively revised to minimize its
+dependence on particular hardware.
+UNIX/32V is highly compatible with UNIX version 7.
+.LP
+.B "Fortran 77."
+F77 compiler for the new standard language
+is compatible with C at the object level.
+A Fortran structurer, STRUCT, converts old, ugly Fortran into RATFOR,
+a structured dialect usable with F77.
+.LP
+.B "Shell."
+Completely new SH program supports string variables,
+trap handling, structured programming, user profiles,
+settable search path,
+multilevel file name generation, etc.
+.LP
+.B "Document preparation."
+TROFF phototypesetter utility is standard.
+NROFF (for terminals) is now highly compatible
+with TROFF.
+MS macro package provides canned commands for
+many common formatting and layout situations.
+TBL provides an easy to learn language for preparing
+complicated tabular material.
+REFER fills in bibliographic citations
+from a data base.
+.LP
+.B "UNIX-to-UNIX file copy."
+UUCP performs spooled
+file transfers between any two machines.
+.LP
+.B "Data processing."
+SED stream editor does multiple editing functions
+in parallel on a data stream of indefinite length.
+AWK report generator does free-field pattern selection
+and arithmetic operations.
+.LP
+.B "Program development."
+MAKE
+controls re-creation of complicated software,
+arranging for minimal recompilation.
+.LP
+.B "Debugging."
+ADB does postmortem and breakpoint debugging.
+.LP
+.B "C language."
+The language now supports
+definable data types, generalized initialization,
+block structure, long integers,
+unions,
+explicit type conversions.
+The LINT verifier does strong type checking
+and detection of probable errors and portability problems
+even across separately compiled functions.
+.LP
+.B "Lexical analyzer generator."
+LEX converts specification of regular expressions
+and semantic actions into a recognizing subroutine.
+Analogous to YACC.
+.LP
+.B "Graphics."
+Simple graph-drawing utility, graphic subroutines, and
+generalized plotting filters adapted to various devices
+are now standard.
+.LP
+.B "Standard input-output package."
+Highly efficient buffered stream I/O is
+integrated with formatted input and output.
+.LP
+.B "Other."
+The operating system and utilities have been enhanced
+and freed of restrictions in many
+other ways too numerous to relate.
+.sp 100
diff --git a/usr/doc/summary/vhel1 b/usr/doc/summary/vhel1
new file mode 100644 (file)
index 0000000..208ca61
--- /dev/null
@@ -0,0 +1,755 @@
+.SH
+B.  Hardware
+.PP
+The
+.UC "UNIX/32V"
+operating system
+runs on
+a DEC VAX-11/780*
+.FS
+*VAX is a Trademark of Digital Equipment Corporation.
+.FE
+with at least the following equipment:
+.IP
+memory: 256K bytes or more.
+.IP
+disk: RP06, RM03, or equivalent.
+.IP
+tape: any 9-track MASSBUS-compatible tape drive.
+.LP
+The following equipment is strongly recommended:
+.IP
+communications controller such as DZ11 or DL11.
+.IP
+full duplex 96-character ASCII terminals.
+.IP
+extra disk for system backup.
+.LP
+The system is normally distributed on 9-track tape.
+The minimum memory and disk space specified is enough to run
+and maintain
+.UC "UNIX/32V,"
+and to keep all source on line.
+More memory will be needed
+to handle
+a large number of users,
+big data bases, diversified complements of devices, or large
+programs.
+The resident code
+occupies 40-55K bytes depending
+on configuration;
+system data also occupies 30-55K bytes.
+.SH
+C.  Software
+.PP
+Most of the programs available as
+.UC "UNIX/32V"
+commands are listed.
+Source code and printed manuals are 
+distributed for all of the listed software
+except games.
+Almost all of the code is written in C.
+Commands are self-contained and do not require extra setup
+information,
+unless specifically noted as ``interactive.''
+Interactive programs can be made to run from a prepared script
+simply by redirecting input.
+Most programs intended for interactive use
+(e.g., the editor) 
+allow for an escape to
+command level (the Shell).
+Most file processing commands
+can also go from standard input to standard output
+(``filters'').
+The piping facility of the Shell may be used
+to connect such filters directly to the input or output
+of other programs.
+.NH
+Basic Software
+.PP
+This
+includes the time-sharing operating
+system with utilities, and a 
+compiler for the programming language C\(emenough
+software to
+write and run new applications
+and to maintain or modify
+.UC "UNIX/32V"
+itself.
+.NH 2
+Operating System
+.sh UNIX
+The basic resident code
+on which everything else depends.
+Supports the system calls, and maintains the file system.
+A general description of
+.UC UNIX
+design
+philosophy and system facilities appeared in
+the Communications of the ACM, July, 1974.
+A more extensive survey is in the Bell System Technical Journal
+for July-August 1978.
+Capabilities include:
+.op
+Reentrant code for user processes.
+.op
+``Group'' access permissions for cooperative projects,
+with overlapping memberships.
+.op
+Alarm-clock timeouts.
+.op
+Timer-interrupt sampling and interprocess monitoring
+for debugging and measurement.
+.OP
+Multiplexed I/O for machine-to-machine communication.
+.sh DEVICES
+All I/O is logically synchronous.
+I/O devices are simply files in the file system.
+Normally, invisible buffering makes all physical
+record structure and device characteristics transparent and exploits the
+hardware's ability to do overlapped I/O.
+Unbuffered physical record
+I/O is available for unusual applications.
+Drivers for these devices are
+available:
+.op
+Asynchronous interfaces: DZ11, DL11.
+Support for most common ASCII terminals.
+.op
+Automatic calling unit interface: DN11.
+.op
+Printer/plotter: Versatek.
+.op
+Magnetic tape: TE16.
+.op
+Pack type disk: RP06, RM03;
+minimum-latency seek scheduling.
+.op
+Physical memory of VAX-11, or mapped memory in resident system.
+.op
+Null device.
+.op
+Recipies are supplied to aid the construction of drivers for:
+.nf
+.in +2
+Asynchronous interface: DH11.
+Synchronous interface: DU11.
+DECtape: TC11.
+Fixed head disk: RS11, RS03 and RS04.
+Cartridge-type disk: RK05.
+Phototypesetter: Graphic Systems System/1 through DR11C.
+.in -2
+.fi
+.sh BOOT
+Procedures to get
+.UC "UNIX/32V"
+started.
+.NH 2
+User Access Control
+.LP
+.sh LOGIN
+Sign on as a new user.
+.op
+Verify password and establish user's 
+individual and group (project) identity.
+.op
+Adapt to characteristics of terminal.
+.op
+Establish working directory.
+.op
+Announce presence of mail (from MAIL).
+.op
+Publish message of the day.
+.op
+Execute user-specified profile.
+.op
+Start command interpreter or other initial program.
+.sh PASSWD
+Change a password.
+.op
+User can change his own password.
+.op
+Passwords are kept encrypted for security.
+.sh NEWGRP
+Change working group (project).
+Protects against unauthorized changes to projects.
+.NH 2
+Terminal Handling
+.LP
+.sh TABS
+Set tab stops appropriately for specified terminal type.
+.sh STTY
+Set up options for optimal control of a terminal.
+In so far as they are deducible from the input, these
+options are set automatically by LOGIN.
+.op
+Half vs. full duplex.
+.op
+Carriage return+line feed vs. newline.
+.op
+Interpretation of tabs.
+.op
+Parity.
+.op
+Mapping of upper case to lower.
+.op
+Raw vs. edited input.
+.op
+Delays for tabs, newlines and carriage returns.
+.NH 2
+File Manipulation
+.LP
+.sh CAT
+Concatenate one or more files onto standard output.
+Particularly used for unadorned printing, for
+inserting data into a pipeline,
+and for buffering output that comes in dribs and drabs.
+Works on any file regardless of contents.
+.sh CP
+Copy one file to another,
+or a set of files to a directory.
+Works on any file regardless of contents.
+.sh PR
+Print files with title, date, and page number on every page.
+.op
+Multicolumn output.
+.op
+Parallel column merge of several files.
+.sh LPR
+Off-line print.
+Spools arbitrary files to the line printer.
+.sh CMP
+Compare two files and report if different.
+.sh TAIL
+Print last
+.I n
+lines of input
+.op
+May print last
+.I n
+characters, or from
+.I n
+lines or characters to end.
+.sh SPLIT
+Split a large file into more manageable pieces.
+Occasionally necessary for editing (ED).
+.sh DD
+Physical file format translator,
+for exchanging data with foreign
+systems, especially IBM 370's.
+.sh SUM
+Sum the words of a file.
+.NH 2
+Manipulation of Directories and File Names
+.LP
+.sh RM
+Remove a file.
+Only the name goes away if any other names are linked to the file.
+.OP
+Step through a directory deleting files interactively.
+.OP
+Delete entire directory hierarchies.
+.sh LN
+``Link'' another name (alias) to an existing file.
+.sh MV
+Move a file or files.
+Used for renaming files.
+.sh CHMOD
+Change permissions on one or more files.
+Executable by files' owner.
+.sh CHOWN
+Change owner of one or more files.
+.sh CHGRP
+Change group (project) to which a file belongs.
+.sh MKDIR
+Make a new directory.
+.sh RMDIR
+Remove a directory.
+.sh CD
+Change working directory.
+.sh FIND
+Prowl the directory
+hierarchy finding
+every file that meets
+specified criteria.
+.op
+Criteria include:
+.in +2
+.nf
+name matches a given pattern,
+creation date in given range,
+date of last use in given range,
+given permissions,
+given owner,
+given special file characteristics,
+boolean combinations of above.
+.in -2
+.fi
+.op
+Any directory may be considered to be the root.
+.op
+Perform specified command on each file found.
+.NH 2
+Running of Programs
+.LP
+.sh SH
+The Shell, or command language interpreter.
+.op
+Supply arguments to and run any executable program.
+.op
+Redirect standard input, standard output, and standard error files.
+.op
+Pipes:
+simultaneous execution with output of one process connected
+to the input of another.
+.OP
+Compose compound commands using:
+.in+2
+if ... then ... else,
+.br
+case switches,
+.br
+while loops,
+.br
+for loops over lists,
+.br
+break, continue and exit,
+.br
+parentheses for grouping.
+.in -2
+.op
+Initiate background processes.
+.op
+Perform Shell programs, i.e., command scripts with
+substitutable arguments.
+.op
+Construct argument lists from all file names
+satisfying specified patterns.
+.OP
+Take special action on traps and interrupts.
+.OP
+User-settable search path for finding commands.
+.OP
+Executes user-settable profile upon login.
+.OP
+Optionally announces presence of mail as it arrives.
+.op
+Provides variables and parameters with default setting.
+.sh TEST
+Tests for use in Shell conditionals.
+.op
+String comparison.
+.op
+File nature and accessibility.
+.op
+Boolean combinations of the above.
+.sh EXPR
+String computations for calculating command arguments.
+.OP
+Integer arithmetic
+.OP
+Pattern matching
+.sh WAIT
+Wait for termination of asynchronously running processes.
+.sh READ
+Read a line from terminal,
+for interactive Shell procedure.
+.sh ECHO
+Print remainder of command line.
+Useful for diagnostics or prompts in Shell programs,
+or for inserting data into a pipeline.
+.sh SLEEP
+Suspend execution for a specified time.
+.sh NOHUP
+Run a command immune to hanging up the terminal.
+.sh NICE
+Run a command in low (or high) priority.
+.sh KILL
+Terminate named processes.
+.sh CRON
+Schedule regular actions at specified times.
+.op
+Actions are arbitrary programs.
+.op
+Times are
+conjunctions of month, day of month, day of week, hour
+and minute.
+Ranges are specifiable for each.
+.sh AT
+Schedule a one-shot action for an arbitrary time.
+.sh TEE
+Pass data between processes and divert a copy into one or more files.
+.NH 2
+Status Inquiries
+.LP
+.sh LS
+List the names of one, several, or all files in one or more directories.
+.op
+Alphabetic or temporal sorting, up or down.
+.op
+Optional information:
+size,
+owner,
+group,
+date last modified,
+date last accessed,
+permissions,
+i-node number.
+.sh FILE
+Try to determine 
+what kind of information is in a file by consulting
+the file system index and by reading the file itself.
+.sh DATE
+Print today's date and time.
+Has considerable knowledge
+of calendric and horological peculiarities.
+.op
+May set
+.UC "UNIX/32V" 's
+idea of date and time.
+.sh DF
+Report amount of free space on file system devices.
+.sh DU
+Print a summary of total space occupied by all files in a hierarchy.
+.sh QUOT
+Print summary of file space usage by user id.
+.sh WHO
+Tell who's on the system.
+.op
+List of presently logged in users,
+ports and times on.
+.op
+Optional history of all logins and logouts.
+.sh PS
+Report on active processes.
+.op
+List your own or everybody's processes.
+.op
+Tell what commands are being executed.
+.op
+Optional status information:
+state and scheduling info,
+priority,
+attached terminal,
+what it's waiting for,
+size.
+.sh IOSTAT
+Print statistics about system I/O activity.
+.sh TTY
+Print name of your terminal.
+.sh PWD
+Print name of your working directory.
+.NH 2
+Backup and Maintenance
+.LP
+.sh MOUNT
+Attach a device containing
+a file system to
+the tree of directories.
+Protects against nonsense arrangements.
+.sh UMOUNT
+Remove the file system contained on a device
+from the tree of directories.
+Protects against removing a busy device.
+.sh MKFS
+Make a new file system on a device.
+.sh MKNOD
+Make an i-node (file system entry) for a special file.
+Special files are
+physical devices,
+virtual devices, physical memory, etc.
+.sh TP
+.sh TAR
+Manage file archives on magnetic tape or DECtape.
+TAR is newer.
+.op
+Collect files into an archive.
+.op
+Update DECtape archive by date.
+.op
+Replace or delete DECtape files.
+.op
+Print table of contents.
+.op
+Retrieve from archive.
+.sh DUMP
+Dump the file system
+stored on a specified device, selectively by date, or indiscriminately.
+.sh RESTOR
+Restore a dumped file system,
+or selectively retrieve parts thereof.
+.sh SU
+Temporarily become the super user with all the rights and privileges
+thereof.
+Requires a password.
+.sh DCHECK
+.sh ICHECK
+.sh NCHECK
+Check consistency of file system.
+.op
+Print gross statistics:
+number of files,
+number of directories,
+number of special files,
+space used,
+space free.
+.op
+Report duplicate use of space.
+.op
+Retrieve lost space.
+.op
+Report inaccessible files.
+.op
+Check consistency of directories.
+.op
+List names of all files.
+.sh CLRI
+Peremptorily expunge a file and its space from a file system.
+Used to repair damaged file systems.
+.sh SYNC
+Force all outstanding I/O on the system to completion.
+Used to shut down gracefully.
+.NH 2
+Accounting
+.LP
+The timing information on which the reports are based can be
+manually cleared or shut off completely.
+.sh AC
+Publish cumulative connect time report.
+.op
+Connect time by user or by day.
+.op
+For all users or for selected users.
+.sh SA
+Publish Shell accounting
+report.
+Gives usage information on each command executed.
+.op
+Number of times used.
+.op
+Total system time, user time and elapsed time.
+.op
+Optional averages and percentages.
+.op
+Sorting on various fields.
+.NH 2
+Communication
+.LP
+.sh MAIL
+Mail a message to one or more users.
+Also used to read and dispose of incoming mail.
+The presence of mail is announced by LOGIN
+and optionally by SH.
+.op
+Each message can be disposed of individually.
+.op
+Messages can be saved in files or forwarded.
+.sh CALENDAR
+Automatic reminder service for events of today and tomorrow.
+.sh WRITE
+Establish direct terminal communication with another user.
+.sh WALL
+Write to all users.
+.sh MESG
+Inhibit receipt of messages from WRITE and WALL.
+.sh CU
+Call up another time-sharing system.
+.OP
+Transparent interface to remote machine.
+.OP
+File transmission.
+.OP
+Take remote input from local file or put remote output
+into local file.
+.OP
+Remote system need not be
+.UC "UNIX/32V" .
+.sh UUCP
+.UC UNIX
+to
+.UC UNIX
+copy.
+.OP
+Automatic queuing until line becomes available
+and remote machine is up.
+.OP
+Copy between two remote machines.
+.op
+Differences, mail, etc., between two machines.
+.NH 2
+Basic Program Development Tools
+.LP
+Some of these utilities are used as integral parts of
+the higher level languages described in section 2.
+.sh AR
+Maintain archives and libraries.
+Combines several files into one for housekeeping efficiency.
+.op
+Create new archive.
+.op
+Update archive by date.
+.op
+Replace or delete files.
+.op
+Print table of contents.
+.op
+Retrieve from archive.
+.sh AS
+Assembler.
+.op
+Creates object program consisting of
+.in+2
+.nf
+code, normally read-only and sharable,
+initialized data or read-write code,
+uninitialized data.
+.in -2
+.fi
+.op
+Relocatable object code is directly executable without
+further transformation.
+.op
+Object code normally includes a symbol table.
+.op
+``Conditional jump'' instructions become
+branches or branches plus jumps depending on distance.
+.sh Library
+The basic run-time library.
+These routines are used freely by all software.
+.op
+Buffered character-by-character I/O.
+.op
+Formatted input and output conversion (SCANF and PRINTF)
+for standard input and output, files, in-memory conversion.
+.op
+Storage allocator.
+.op
+Time conversions.
+.op
+Number conversions.
+.op
+Password encryption.
+.op
+Quicksort.
+.op
+Random number generator.
+.op
+Mathematical function library, including
+trigonometric functions and inverses,
+exponential, logarithm, square root,
+bessel functions.
+.sh ADB
+Interactive debugger.
+.op
+Postmortem dumping.
+.OP
+Examination of arbitrary files, with no limit on size.
+.op
+Interactive breakpoint debugging with the debugger as a separate
+process.
+.OP
+Symbolic reference to local and global variables.
+.op
+Stack trace for C programs.
+.OP
+Output formats:
+.in+2
+.nf
+1-, 2-, or 4-byte integers in octal, decimal, or hex
+.br
+single and double floating point
+.br
+character and string
+.br
+disassembled machine instructions
+.br
+.fi
+.in-2
+.op
+Patching.
+.OP
+Searching for integer, character, or floating patterns.
+.sh OD
+Dump any file.
+Output options include any combination of
+octal or decimal or hex by words,
+octal by bytes,
+ASCII,
+opcodes,
+hexadecimal.
+.op
+Range of dumping is controllable.
+.sh LD
+Link edit.
+Combine relocatable object files.
+Insert required routines from specified libraries.
+.op
+Resulting code is sharable by default.
+.sh LORDER
+Places object file names in proper order for loading,
+so that files depending on others come after them.
+.sh NM
+Print the namelist (symbol table) of an object program.
+Provides control over the style and order of
+names that are printed.
+.sh SIZE
+Report the memory requirements
+of one or more object files.
+.sh STRIP
+Remove the relocation and symbol table information from
+an object file to save space.
+.sh TIME
+Run a command and report timing information on it.
+.sh PROF
+Construct a profile of time spent per routine
+from statistics gathered by time-sampling the
+execution of a program.
+.op
+Subroutine call frequency and average times for C programs.
+.sh MAKE
+Controls creation of large programs.
+Uses a control file specifying source file dependencies
+to make new version;
+uses time last changed to deduce minimum amount of work necessary.
+.op
+Knows about CC, YACC, LEX, etc.
+.NH 2
+UNIX/32V Programmer's Manual
+.LP
+.sh Manual
+Machine-readable version of the
+.UC "UNIX/32V"
+Programmer's Manual.
+.op
+System overview.
+.op
+All commands.
+.op
+All system calls.
+.op
+All subroutines in C and assembler libraries.
+.op
+All devices and other special files.
+.op
+Formats of file system and kinds
+of files known to system software.
+.op
+Boot and maintenance procedures.
+.sh MAN
+Print specified manual section on your terminal.
+.NH 2
+Computer-Aided Instruction
+.LP
+.sh LEARN
+A program for interpreting CAI scripts, plus scripts
+for learning about 
+.UC "UNIX/32V"
+by using it.
+.op
+Scripts for basic files and commands,
+editor,
+advanced files and commands,
+.UC EQN ,
+.UC MS
+macros,
+C programming language.
diff --git a/usr/doc/summary/vhel2 b/usr/doc/summary/vhel2
new file mode 100644 (file)
index 0000000..de80512
--- /dev/null
@@ -0,0 +1,188 @@
+.NH
+Languages
+.NH 2
+The C Language
+.LP
+.sh CC
+Compile and/or link edit programs in the C
+language.
+The 
+.UC "UNIX/32V"
+operating system, most of the
+subsystems and C itself are written in C.
+For a full description of C, read
+.ul
+The C Programming Language,
+Brian W. Kernighan and Dennis M. Ritchie,
+Prentice-Hall, 1978.
+.op
+General purpose language
+designed for structured programming.
+.op
+Data types include
+character,
+integer,
+float,
+double,
+pointers to all types,
+functions returning above types,
+arrays of all types,
+structures and unions of all types.
+.op
+Operations intended to give machine-independent control
+of full machine facility, including to-memory
+operations and
+pointer arithmetic.
+.op
+Macro preprocessor for parameterized code and inclusion of
+standard files.
+.op
+All procedures recursive, with parameters by value.
+.op
+Machine-independent pointer manipulation.
+.op
+Object code uses full
+addressing capability of the VAX-11.
+.op
+Runtime library gives access to all system facilities.
+.OP
+Definable data types.
+.OP
+Block structure
+.sh  LINT
+Verifier for C programs.
+Reports questionable or nonportable usage such as:
+.nf
+.in +2
+Mismatched data declarations and procedure interfaces.
+.br
+Nonportable type conversions.
+.br
+Unused variables, unreachable code, no-effect operations.
+.br
+Mistyped pointers.
+.br
+Obsolete syntax.
+.in -2
+.OP
+Full cross-module checking of separately compiled programs.
+.sh CB
+A beautifier for C programs.
+Does proper indentation and placement of braces.
+.NH 2
+Fortran
+.LP
+.sh  F77
+A full compiler for 
+ANSI Standard Fortran 77.
+.OP
+Compatible with C and supporting tools at object level.
+.OP
+Optional source compatibility with Fortran 66.
+.OP
+Free format source.
+.op
+Optional subscript-range checking, detection of uninitialized variables.
+.OP
+All widths of arithmetic:
+2- and 4-byte integer; 4- and 8-byte real; 8- and 16-byte
+complex.
+.sh RATFOR
+Ratfor adds rational
+control structure \o'a\(ga' la C to Fortran.
+.op
+Compound statements.
+.op
+If-else, do, for, while,
+repeat-until, break, next
+statements.
+.op
+Symbolic constants.
+.op
+File insertion.
+.op
+Free format source
+.op
+Translation of relationals like >, >=.
+.op
+Produces genuine Fortran to carry away.
+.op
+May be used with F77.
+.sh STRUCT
+Converts ordinary ugly Fortran into structured Fortran (i.e., Ratfor),
+using statement grouping, if-else, while, for, repeat-until.
+.NH 2
+Other Algorithmic Languages
+.sh DC
+Interactive programmable desk calculator.
+Has named storage locations as well
+as conventional stack for holding integers or programs.
+.op
+Unlimited precision decimal arithmetic.
+.op
+Appropriate treatment of decimal fractions.
+.op
+Arbitrary input and output radices, in particular
+binary, octal, decimal and hexadecimal.
+.op
+Reverse Polish operators:
+.in+2
+.nf
++ \- * /
+remainder, power, square root,
+load, store, duplicate, clear,
+print, enter program text, execute.
+.in-2
+.fi
+.sh BC
+A C-like interactive interface to the desk calculator DC.
+.op
+All the capabilities of DC with a high-level syntax.
+.op
+Arrays and recursive functions.
+.op
+Immediate evaluation of expressions and evaluation of
+functions upon call.
+.op
+Arbitrary precision elementary functions:
+exp, sin, cos, atan.
+.op
+Go-to-less programming.
+.NH 2
+Macroprocessing
+.LP
+.nr c 0 1
+.sh  M4
+A general purpose macroprocessor.
+.OP
+Stream-oriented, recognizes macros anywhere in text.
+.OP
+Syntax fits with functional syntax of most higher-level
+languages.
+.OP
+Can evaluate integer arithmetic expressions.
+.NH 2
+Compiler-compilers
+.LP
+.sh YACC
+An LR(1)-based compiler writing system.
+During execution of resulting
+parsers, arbitrary C functions may be
+called to do code generation or semantic actions.
+.op
+BNF syntax specifications.
+.op
+Precedence relations.
+.op
+Accepts formally ambiguous grammars
+with non-BNF resolution rules.
+.sh  LEX
+Generator of lexical analyzers.
+Arbitrary C functions may be called
+upon isolation of each lexical token.
+.OP
+Full regular expression,
+plus left and right context dependence.
+.OP
+Resulting lexical analysers interface cleanly
+with YACC parsers.
diff --git a/usr/doc/summary/vhel3 b/usr/doc/summary/vhel3
new file mode 100644 (file)
index 0000000..1f8138b
--- /dev/null
@@ -0,0 +1,204 @@
+.NH
+Text Processing
+.NH 2
+Document Preparation
+.LP
+.sh ED
+Interactive context editor.
+Random access to all lines of a file.
+.op
+Find lines by number or pattern.
+Patterns may include:
+specified characters,
+don't care characters,
+choices among characters,
+repetitions of these constructs,
+beginning of line,
+end of line.
+.op
+Add, delete, change, copy, move or join lines.
+.op
+Permute or split contents of a line.
+.op
+Replace one or all instances of a pattern within a line.
+.op
+Combine or split files.
+.op
+Escape to Shell (command language) during editing.
+.ne3
+.op
+Do any of above operations on
+every pattern-selected line in a given range.
+.OP
+Optional encryption for extra security.
+.sh PTX
+Make a permuted (key word in context) index.
+.sh SPELL
+Look for spelling errors by comparing each word in a
+document against a word list.
+.OP
+25,000-word list includes proper names.
+.OP
+Handles common prefixes and suffixes.
+.OP
+Collects words to help tailor local spelling lists.
+.sh LOOK
+Search for words in dictionary that begin with specified prefix.
+.sh CRYPT
+Encrypt and decrypt files for security.
+.NH 2
+Document Formatting
+.LP
+.sh TROFF
+.sh NROFF
+Advanced typesetting.
+TROFF drives a Graphic Systems phototypesetter;
+NROFF drives ascii terminals of all types.
+This summary was typeset using TROFF.
+TROFF and NROFF are capable of elaborate
+feats of formatting,
+when appropriately programmed.
+TROFF and NROFF accept the same input language.
+.op
+Completely definable page format keyed to dynamically planted
+``interrupts'' at specified lines.
+.op
+Maintains several separately definable typesetting environments (e.g., one for
+body text, one for footnotes, and one for unusually elaborate
+headings).
+.op
+Arbitrary number of output pools can be combined at will.
+.op
+Macros with substitutable arguments, and macros invocable
+in mid-line.
+.op
+Computation and printing of numerical quantities.
+.op
+Conditional execution of macros.
+.op
+Tabular layout facility.
+.op
+Positions expressible in inches, centimeters, ems, points,
+machine units
+or arithmetic combinations thereof.
+.op
+Access to character-width computation for unusually difficult
+layout problems.
+.op
+Overstrikes, built-up brackets, horizontal and vertical line drawing.
+.op
+Dynamic relative or absolute positioning and size selection,
+globally or at the character level.
+.op
+Can exploit the characteristics of the terminal being used,
+for approximating special characters, reverse motions,
+proportional spacing, etc.
+.LP
+The Graphic Systems typesetter has a
+vocabulary of several 102-character fonts (4 simultaneously)
+in 15 sizes.
+TROFF provides
+terminal output for rough sampling of the product.
+.LP
+NROFF will produce multicolumn output on terminals capable of reverse line feed,
+or through the postprocessor COL.
+.LP
+High programming skill is required to exploit the formatting
+capabilities of TROFF and NROFF, although unskilled personnel can easily be trained
+to enter documents according to canned formats
+such as those provided by MS, below.
+TROFF and EQN are essentially identical to NROFF and NEQN
+so it is usually possible to define interchangeable 
+formats to produce
+approximate proof copy on terminals
+before actual typesetting.
+The preprocessors MS, TBL, and REFER are fully compatible
+with TROFF and NROFF.
+.sh MS
+A standardized manuscript layout package
+for use with NROFF/TROFF.
+This document was formatted with MS.
+.op
+Page numbers and draft dates.
+.op
+Automatically numbered subheads.
+.op
+Footnotes.
+.op
+Single or double column.
+.op
+Paragraphing, display and indentation.
+.op
+Numbered equations.
+.sh EQN
+A mathematical typesetting preprocessor for TROFF.
+Translates easily readable formulas, either in-line or displayed, into 
+detailed typesetting instructions.
+Formulas are written in a style like this:
+.DS
+sigma sup 2 ~=~ 1 over N sum from i=1 to N ( x sub i \- x bar ) sup 2
+.DE
+which produces:
+.EQ
+sigma sup 2 ~=~ 1 over N sum from i=1 to N ( x sub i - x bar ) sup 2
+.EN
+.op
+Automatic calculation of size changes for subscripts, sub-subscripts,
+etc.
+.op
+Full vocabulary of Greek letters and special symbols, such as `gamma', `GAMMA', `integral'.
+.op
+Automatic calculation of large bracket sizes.
+.op
+Vertical ``piling'' of formulae for matrices, conditional
+alternatives, etc.
+.op
+Integrals, sums, etc., with arbitrarily complex limits.
+.op
+Diacriticals: dots, double dots, hats, bars, etc.
+.op
+Easily learned by nonprogrammers and mathematical typists.
+.sh NEQN
+A version of EQN for NROFF;
+accepts the same input language.
+Prepares formulas for display on
+any terminal that NROFF knows about,
+for example, those based on Diablo printing mechanism.
+.op
+Same facilities as EQN within graphical capability of
+terminal.
+.sh TBL
+A preprocessor for NROFF/TROFF
+that translates simple descriptions of table layouts
+and contents into detailed typesetting instructions.
+.op
+Computes column widths.
+.op
+Handles left- and right-justified columns,
+centered columns and decimal-point
+alignment.
+.op
+Places column titles.
+.op
+Table entries can be text,
+which is adjusted to fit.
+.op
+Can box all or parts of table.
+.sh REFER
+Fills in bibliographic citations in a document
+from a data base (not supplied).
+.op
+References may be printed in any style,
+as they occur or collected at the end.
+.op
+May be numbered sequentially, by name of author, etc.
+.sh TC
+Simulate Graphic Systems typesetter on Tektronix 4014 scope.
+Useful for checking TROFF page layout before typesetting.
+.sh COL
+Canonicalize files with reverse line feeds
+for one-pass printing.
+.sh DEROFF
+Remove all TROFF commands from input.
+.sh CHECKEQ
+Check document for possible errors in EQN usage.
diff --git a/usr/doc/summary/vhel4 b/usr/doc/summary/vhel4
new file mode 100644 (file)
index 0000000..e25dca7
--- /dev/null
@@ -0,0 +1,97 @@
+.NH
+Information Handling
+.LP
+.sh SORT
+Sort or merge ASCII files line-by-line.
+No limit on input size.
+.op
+Sort up or down.
+.op
+Sort lexicographically or on numeric key.
+.op
+Multiple keys located by delimiters or by character position.
+.op
+May sort upper case together with lower into dictionary order.
+.OP
+Optionally suppress duplicate data.
+.sh TSORT
+Topological sort \(em converts a partial order into a total order.
+.sh UNIQ
+Collapse successive duplicate lines
+in a file into one line.
+.op
+Publish lines that were originally unique,
+duplicated, or both.
+.op
+May give redundancy count for each line.
+.sh TR
+Do one-to-one character translation according to
+an arbitrary code.
+.op
+May coalesce selected repeated characters.
+.op
+May delete selected characters.
+.sh DIFF
+Report line changes, additions and deletions necessary to bring two files
+into agreement.
+.op
+May produce an editor script to convert one file into another.
+.op
+A variant compares two new versions against one old one.
+.sh COMM
+Identify common lines in two sorted files.
+Output in up to 3 columns shows lines present in first file only,
+present in both, and/or present in second only.
+.sh JOIN
+Combine two files by joining records that have identical keys.
+.sh GREP
+Print all lines in a file that satisfy
+a pattern as used in the editor ED.
+.op
+May print all lines that fail to match.
+.op
+May print count of hits.
+.op
+May print first hit in each file.
+.sh LOOK
+Binary search in sorted file for lines
+with specified prefix.
+.sh WC
+Count the lines, ``words'' (blank-separated strings) and characters in a file.
+.sh SED
+Stream-oriented version of ED.
+Can perform a sequence of editing operations on
+each line of an
+input stream of unbounded length.
+.op
+Lines may be selected by address or range of addresses.
+.op
+Control flow and conditional testing.
+.op
+Multiple output streams.
+.op
+Multi-line capability.
+.sh AWK
+Pattern scanning and processing language.
+Searches input for patterns, and
+performs actions on each line of input that satisfies
+the pattern.
+.op
+Patterns include regular expressions,
+arithmetic and lexicographic conditions,
+boolean combinations and ranges of these.
+.op
+Data treated as string or numeric as appropriate.
+.op
+Can break input into fields;
+fields are variables.
+.op
+Variables and arrays (with non-numeric subscripts).
+.op
+Full set of arithmetic operators and control flow.
+.op
+Multiple output streams to files and pipes.
+.op
+Output can be formatted as desired.
+.op
+Multi-line capabilities.
diff --git a/usr/doc/summary/vhel5 b/usr/doc/summary/vhel5
new file mode 100644 (file)
index 0000000..1a014c0
--- /dev/null
@@ -0,0 +1,24 @@
+.NH
+Graphics
+.LP
+The programs in this section are predominantly intended for use
+with Tektronix 4014 storage scopes.
+.sh GRAPH
+Prepares a graph of a set of input numbers.
+.op
+Input scaled to fit standard plotting area.
+.op
+Abscissae may be supplied automatically.
+.op
+Graph may be labeled.
+.op
+Control over grid style, line style, graph orientation, etc.
+.sh SPLINE
+Provides a smooth curve through a set of points
+intended for GRAPH.
+.sh PLOT
+A set of filters for printing graphs produced by GRAPH
+and other programs
+on various terminals.
+Filters provided for
+4014, DASI terminals, Versatec printer/plotter.
diff --git a/usr/doc/summary/vhel6 b/usr/doc/summary/vhel6
new file mode 100644 (file)
index 0000000..b3c14ed
--- /dev/null
@@ -0,0 +1,34 @@
+.NH
+Novelties, Games, and Things That Didn't Fit Anywhere Else
+.LP
+.sh BACKGAMMON
+.br
+A player of modest accomplishment.
+.sh BCD
+Converts ascii to card-image form.
+.sh CAL
+Print a calendar of specified month and year.
+.sh CHING
+The
+.ul
+I Ching.
+Place your own interpretation on the output.
+.sh FORTUNE
+Presents a random fortune cookie on each invocation.
+Limited jar of cookies included.
+.sh UNITS
+Convert amounts between different scales of measurement.
+Knows hundreds of units.
+For example, how many km/sec is a parsec/megayear?
+.sh ARITHMETIC
+.br
+Speed and accuracy test for number facts.
+.sh QUIZ
+Test your knowledge of Shakespeare, Presidents, capitals, etc.
+.sh WUMP
+Hunt the wumpus, thrilling search in a dangerous cave.
+.sh HANGMAN
+Word-guessing game.
+Uses a dictionary supplied with SPELL.
+.sh FISH
+Children's card-guessing game.
index 3dce488..173734a 100644 (file)
@@ -631,18 +631,6 @@ containing only the string $fat "\e\(ul"$
 is taken to be a single line as wide as the contents of
 the column.  It is not extended to meet
 adjoining lines.
 is taken to be a single line as wide as the contents of
 the column.  It is not extended to meet
 adjoining lines.
-.IP "\fI##Repeated characters\fR#"
-\(em An input table
-.I entry
-containing only a string of the form $fat "\e"$\f3R\f2x\f1
-where
-.I x
-is any character is replaced by repetitions of the character
-.I x
-as wide as the data in the column.
-The sequence of
-.I x 's
-is not extended to meet adjoining columns.
 .IP "\fI##Vertically spanned items\fR#"
 \(em An input table entry containing only the
 character string
 .IP "\fI##Vertically spanned items\fR#"
 \(em An input table entry containing only the
 character string
@@ -1809,8 +1797,8 @@ of testing and assisted with the design of the program.
 He has also written many of the more intelligible sentences
 in this document and helped edit all of it.
 All phototypesetting programs on \s-2UNIX\s0 are dependent on the work
 He has also written many of the more intelligible sentences
 in this document and helped edit all of it.
 All phototypesetting programs on \s-2UNIX\s0 are dependent on the work
-of the late J. F. Ossanna, whose assistance with this program in particular
-had been most helpful.
+of J. F. Ossanna, whose assistance with this program in particular
+has been most helpful.
 This program is patterned on a table formatter originally
 written by J. F. Gimpel.
 The assistance of
 This program is patterned on a table formatter originally
 written by J. F. Gimpel.
 The assistance of
@@ -1840,20 +1828,20 @@ M. E. Lesk,
 .I
 Typing Documents on U\s-2NIX\s0,
 .R
 .I
 Typing Documents on U\s-2NIX\s0,
 .R
-UNIX Programmer's Manual, Volume 2.
+Bell Laboratories internal memorandum.
 .IP [5]
 M. E. Lesk and B. W. Kernighan,
 .I
 Computer Typesetting of Technical Journals on U\s-2NIX\s0,
 .R
 .IP [5]
 M. E. Lesk and B. W. Kernighan,
 .I
 Computer Typesetting of Technical Journals on U\s-2NIX\s0,
 .R
-\f2Proc. AFIPS NCC\f1, vol. 46, pp. 879-888 (1977).
+Computing Science Technical Report No. 44,
+Bell Laboratories, July 1976.
 .IP [6]
 J. R. Mashey and D. W. Smith,
 .IP [6]
 J. R. Mashey and D. W. Smith,
-``Documentation Tools and Techniques,''
 .I
 .I
-Proc. 2nd Int. Conf. on Software Engineering,
+\s-2PWB/MM\s0 \(em Programmer's Workbench Memorandum Macros,
 .R
 .R
-pp. 177-181 (October, 1976).
+Bell Laboratories memorandum.
 .sp 3
 .SH
 .ce
 .sp 3
 .SH
 .ce
@@ -1898,5 +1886,4 @@ w W       Minimum width value     2
 \&=    Double horizontal line  2,3
 \&$fat "_"$    Horizontal line 2,3
 \&$fat "\e_"$  Short horizontal line   3
 \&=    Double horizontal line  2,3
 \&$fat "_"$    Horizontal line 2,3
 \&$fat "\e_"$  Short horizontal line   3
-\&$fat "\e"$\f3R\f2x   Repeat character        3
 .TE
 .TE
diff --git a/usr/games/ching.d/log b/usr/games/ching.d/log
new file mode 100644 (file)
index 0000000..a050328
--- /dev/null
@@ -0,0 +1,153 @@
+877867 Sat Jul  9 12:21:37 1977
+976877 Sat Jul  9 12:24:49 1977
+877667 Sat Jul  9 13:22:23 1977
+887998 Sat Jul  9 13:36:22 1977
+767866 Sat Jul  9 13:38:07 1977
+778878 Sat Jul  9 13:43:32 1977
+877799 Sat Jul  9 13:44:40 1977
+988676 Sat Jul  9 13:55:59 1977
+877886 Sat Jul  9 14:02:37 1977
+688777 Sat Jul  9 14:09:52 1977
+987987 Sat Jul  9 15:26:59 1977
+877778 Sun Jul 10 18:25:05 1977
+777978 Mon Jul 11 08:28:53 1977
+887998 Mon Jul 11 09:21:53 1977
+978877 Mon Jul 11 10:19:58 1977
+986776 Mon Jul 11 10:21:44 1977
+677876 Mon Jul 11 10:24:36 1977
+877877 Tue Jul 12 21:38:43 1977
+876688 Tue Jul 12 21:40:41 1977
+777888 Thu Jul 14 05:53:00 1977
+667869 Thu Jul 14 05:53:57 1977
+877767 Thu Jul 14 09:06:18 1977
+886779 Thu Jul 14 09:08:02 1977
+877686 Thu Jul 14 09:15:00 1977
+877666 Thu Jul 14 09:16:11 1977
+677977 Thu Jul 14 09:17:36 1977
+778877 Thu Jul 14 09:21:30 1977
+778787 Thu Jul 14 21:02:26 1977
+768776 Thu Jul 14 21:05:39 1977
+679897 Thu Jul 14 21:07:13 1977
+877667 Thu Jul 14 21:38:28 1977
+889868 Thu Jul 14 21:51:34 1977
+966877 Fri Jul 15 17:49:14 1977
+766778 Sun Jul 17 01:51:08 1977
+879677 Sun Jul 17 02:44:48 1977
+777989 Sun Jul 17 03:44:25 1977
+678778 Sun Jul 17 03:51:04 1977
+877979 Sun Jul 17 16:48:15 1977
+777776 Sun Jul 17 16:49:31 1977
+877778 Fri Jul 22 05:03:29 1977
+678677 Fri Jul 22 05:05:06 1977
+878668 Fri Jul 22 17:10:06 1977
+778878 Sat Jul 23 12:00:31 1977
+768877 Sat Jul 23 12:01:24 1977
+686868 Tue Jul 26 16:45:51 1977
+678676 Wed Jul 27 00:51:28 1977
+688976 Sat Jul 30 00:21:38 1977
+987778 Sat Jul 30 04:50:41 1977
+877997 Sun Jul 31 16:12:10 1977
+668667 Sun Jul 31 16:12:54 1977
+989777 Tue Aug  2 14:59:44 1977
+786888 Wed Aug  3 19:23:44 1977
+878679 Wed Aug  3 19:24:55 1977
+896788 Wed Aug  3 19:26:06 1977
+897987 Fri Aug  5 16:27:31 1977
+988679 Fri Aug  5 16:27:59 1977
+688787 Mon Aug  8 14:51:24 1977
+676786 Mon Aug  8 22:43:11 1977
+798978 Mon Aug  8 22:45:38 1977
+987878 Tue Aug  9 05:38:40 1977
+787778 Tue Aug  9 07:44:52 1977
+798878 Tue Aug  9 07:46:54 1977
+687878 Tue Aug  9 18:49:42 1977
+787877 Tue Aug  9 18:51:07 1977
+779788 Tue Aug  9 19:15:29 1977
+878787 Tue Aug  9 19:23:49 1977
+688888 Wed Aug 10 16:44:06 1977
+889888 Fri Aug 19 03:02:15 1977
+778787 Fri Aug 19 03:16:43 1977
+787768 Fri Aug 19 03:17:49 1977
+677866 Fri Aug 19 22:18:24 1977
+787889 Sat Aug 20 20:43:55 1977
+787776 Sun Aug 21 14:55:46 1977
+778687 Sun Aug 21 17:18:46 1977
+787878 Mon Aug 22 17:57:46 1977
+678796 Wed Aug 24 02:16:53 1977
+776767 Wed Aug 24 02:17:16 1977
+967977 Wed Aug 24 02:18:42 1977
+678897 Wed Aug 24 02:20:43 1977
+786887 Wed Aug 31 16:08:21 1977
+789778 Wed Aug 31 17:28:17 1977
+678677 Thu Sep  1 21:38:26 1977
+876997 Sat Sep  3 23:32:21 1977
+767878 Thu Sep 15 16:05:35 1977
+986776 Thu Sep 15 16:08:16 1977
+888877 Thu Sep 15 16:09:50 1977
+687877 Thu Sep 15 16:10:33 1977
+878677 Thu Sep 15 16:11:59 1977
+786768 Thu Sep 15 16:14:04 1977
+886976 Fri Sep 16 22:14:18 1977
+676778 Fri Sep 16 22:18:47 1977
+687787 Fri Sep 16 22:21:25 1977
+887768 Fri Sep 16 23:47:16 1977
+778886 Fri Sep 16 23:49:52 1977
+788777 Fri Sep 16 23:51:26 1977
+779888 Fri Sep 16 23:52:31 1977
+786787 Fri Sep 16 23:54:27 1977
+768688 Thu Sep 22 01:26:48 1977
+777788 Sat Sep 24 18:21:58 1977
+789778 Sat Sep 24 18:41:28 1977
+686877 Wed Sep 28 21:14:56 1977
+788877 Fri Sep 30 17:05:30 1977
+878779 Mon Oct  3 23:14:33 1977
+688798 Sun Oct  9 16:22:27 1977
+678776 Sun Oct  9 16:26:07 1977
+878677 Tue Oct 11 14:23:38 1977
+787786 Sun Oct 30 01:10:58 1977
+766797 Sun Oct 30 01:12:15 1977
+878777 Sun Oct 30 01:13:13 1977
+877788 Sun Oct 30 01:14:26 1977
+878787 Sun Oct 30 20:14:12 1977
+897868 Tue Nov  1 22:42:56 1977
+676866 Tue Nov 29 17:33:27 1977
+687997 Wed Nov 30 15:30:22 1977
+978999 Fri Dec 16 20:47:49 1977
+998868 Thu Dec 22 16:49:53 1977
+677688 Wed Jan  4 16:58:48 1978
+887878 Sat Jan 28 17:09:45 1978
+677768 Sun Feb  5 11:43:35 1978
+787788 Fri Feb 17 23:13:17 1978
+877888 Sun Mar 12 19:01:52 1978
+866677 Thu Mar 30 16:49:56 1978
+777776 Mon Apr  3 19:35:57 1978
+877866 Mon Apr  3 19:38:45 1978
+877887 Fri May 12 15:11:23 1978
+988687 Sun Jun  4 12:32:56 1978
+776667 Fri Aug 18 18:09:06 1978
+769677 Fri Aug 18 18:10:29 1978
+877888 Sat Aug 19 01:21:46 1978
+698986 Sat Aug 19 01:35:36 1978
+788967 Mon Sep  4 16:37:20 1978
+798988 Tue Sep  5 17:48:04 1978
+896878 Tue Sep  5 17:52:26 1978
+867867 Tue Sep  5 17:52:45 1978
+877687 Tue Sep  5 17:54:50 1978
+678876 Tue Sep  5 17:55:58 1978
+788678 Tue Sep  5 17:57:16 1978
+667788 Thu Sep 14 15:42:54 1978
+767769 Thu Sep 14 15:43:42 1978
+787898 Fri Sep 15 09:52:06 1978
+677777 Sat Sep 16 13:16:24 1978
+879769 Sat Sep 23 14:30:55 1978
+886988 Thu Sep 28 19:08:03 1978
+889978 Sun Oct  1 19:43:09 1978
+788877 Sun Oct  1 19:43:32 1978
+888878 Thu Oct 26 08:53:28 1978
+677688 Fri Nov  3 17:40:18 1978
+867778 Wed Nov 22 21:09:05 1978
+878997 Wed Nov 22 21:10:12 1978
+767677 Thu Nov 23 16:34:36 1978
+778787 Thu Nov 23 16:36:48 1978
+877798 Thu Nov 23 16:37:18 1978
+977788 Thu Nov 23 19:49:00 1978
diff --git a/usr/games/lib/backrules b/usr/games/lib/backrules
new file mode 100644 (file)
index 0000000..31ef40e
--- /dev/null
@@ -0,0 +1,30 @@
+To play backgammon, you must type the numbers
+of the points from which pieces are to be
+moved. For example, if the roll was '2  6',
+typing '12 15' will move a piece from point
+12 two spaces to point 14 and a piece from
+point 15 six spaces to point 21. If the moves
+must be made in the opposite order, you must
+prepend the first number with a minus ('-').
+Thus, typing '-12 15' will move a piece from
+point 12 six spaces and a piece from point 15
+two spaces. If you want to move a single piece
+several times the sequence of points from
+which it is to be moved must be typed. For 
+example, if the roll is '3  5', typing
+'14  17' will move a piece from point 14 to
+point 17 and then to point 22. If a double
+is rolled, you should enter four numbers.
+
+Brown pieces that have been removed from the
+board after being hit by white are on point 0
+and must be brought in before any other moves
+can be made. White pieces that are hit are 
+removed to point 25.
+
+Illegal or excessive moves are detected, however
+if you choose to skip part or all of your turn
+you may do so. Type a '?' when you are asked
+for your move and a list of available actions 
+will be printed. Good luck!!!
+
index d3930a6..02da3d0 100644 (file)
@@ -29,10 +29,10 @@ Stop searching forever. Happiness is unattainable.
 A man who fishes for marlin in ponds will put his money in Etruscan bonds.
 A good memory does not equal pale ink.
 How sharper than a hound's tooth it is to have a thankless serpent.
 A man who fishes for marlin in ponds will put his money in Etruscan bonds.
 A good memory does not equal pale ink.
 How sharper than a hound's tooth it is to have a thankless serpent.
-You dialed 5483
+You dialed 2290
 It's later than you think.
 Mistakes are oft the stepping stones to failure.
 It's later than you think.
 Mistakes are oft the stepping stones to failure.
-It's not reality that's important, but how you perceive things.
+It's not reality that's important, but how you percieve things.
 Promptness is its own reward, if one lives by the clock instead of the sword.
 Like winter snow on summer lawn, time past is time gone.
 Far duller than a serpent's tooth it is to spend a quiet youth.
 Promptness is its own reward, if one lives by the clock instead of the sword.
 Like winter snow on summer lawn, time past is time gone.
 Far duller than a serpent's tooth it is to spend a quiet youth.
@@ -77,7 +77,6 @@ Man who falls in vat of molten optical glass makes spectacle of self.
 Go directly to jail.  Do not pass Go, do not collect $200.
 For a good time, call 8367-3100.
 Those who can, do; those who can't, simulate.
 Go directly to jail.  Do not pass Go, do not collect $200.
 For a good time, call 8367-3100.
 Those who can, do; those who can't, simulate.
-Those who can, do; those who can't, write.  Those who can't write work for the Bell Labs Record.
 God does not play dice.
 This fortune is inoperative.  Please try another.
 Laugh, and the world ignores you.  Crying doesn't help either.
 God does not play dice.
 This fortune is inoperative.  Please try another.
 Laugh, and the world ignores you.  Crying doesn't help either.
@@ -94,10 +93,10 @@ The early worm gets the bird.
 He who hesitates is sometimes saved.
 Time is nature's way of making sure that everything doesn't happen at once.
 The future isn't what it used to be. (It never was.)
 He who hesitates is sometimes saved.
 Time is nature's way of making sure that everything doesn't happen at once.
 The future isn't what it used to be. (It never was.)
-Can't open /usr/lib/fortunes.
+Can't open /usr/games/lib/fortunes.
 If God had wanted you to go around nude, He would have given you bigger hands.
 It is better to have loved and lost than just to have lost.
 If God had wanted you to go around nude, He would have given you bigger hands.
 It is better to have loved and lost than just to have lost.
-A journey of a thousand miles begins with a cash advance from Sam.
+A journey of a thousand miles begins with a cash advance from Charlie.
 Disk crunch - please clean up.
 Center meeting at 4pm in 2C-543
 I will never lie to you.
 Disk crunch - please clean up.
 Center meeting at 4pm in 2C-543
 I will never lie to you.
@@ -123,7 +122,8 @@ One Bell System - it sometimes works.
 * UNIX is a Trademark of Bell Laboratories.
 chess tonight
 External Security:
 * UNIX is a Trademark of Bell Laboratories.
 chess tonight
 External Security:
-Peters hungry, time to eat lunch.
+Tom's hungry, time to eat lunch.
+Phone call for chucky-pooh.
 MOUNT TAPE U1439 ON B3, NO RING
 A foolish consistency is the hobgoblin of little minds.
 IOT trap -- core dumped
 MOUNT TAPE U1439 ON B3, NO RING
 A foolish consistency is the hobgoblin of little minds.
 IOT trap -- core dumped
@@ -135,7 +135,3 @@ System going down at 1:45 this afternoon for disk crashing.
 Quantity is no substitute for quality, but its the only one we've got.
 Those who can do, those who can't, write.
 The more things change, the more they'll never be the same again.
 Quantity is no substitute for quality, but its the only one we've got.
 Those who can do, those who can't, write.
 The more things change, the more they'll never be the same again.
-New crypt. See /usr/news/crypt.
-You might have mail.
-You can't go home again, unless you set $HOME
-You are in a maze of twisty little passages, all alike.
diff --git a/usr/games/quiz.k/africa b/usr/games/quiz.k/africa
deleted file mode 100644 (file)
index 0f8722e..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-Algeria:Alg[iers|er]
-Botswana:Gaberones
-Burundi:Bujumbura
-Cameroun:Yaound['\be|e\b'|e]
-Central Africa{n Rep{ublic}}:Bangui
-Chad:Ndjamena
-Congo:Brazzaville
-Dahomey:Porto Novo
-Ethiopia:Addis Ababa
-Gabon:Libreville
-Ghana:Accra
-Guinea-Bissau:Bissau
-Guinea:Conakry
-Ivory Coast:Abidjan
-Kenya:Nairobi
-Lesotho:Maseru
-Liberia:Monrovia
-Libya:Tripoli|Al Bayda{'}
-Malagasy{ Rep{ublic}}|Madagascar:Tananarive
-Malawi:Zomba
-Mali:Bamako
-Mauritania:Nouakchott
-Morocco:Rabat
-Mo[z|,\bc|c\b,|c]ambique:Louren[,\bc|c\b,|c]o Marques
-Namibia:Windhoek
-Niger:Niamey
-Nigeria:Lagos
-Rhodesia:Salisbury
-Rwanda:Kigali
-Senegal:Dakar
-Sierra Leone:Freetown
-Somali{ Rep{ublic}}:Mogadis[cio|hu]
-Sudan:Khartoum
-Swaziland:Mbabane
-Tanzania:Dar es Salaam
-Togo:Lom['\be|e\b'|e]
-Tunisia:Tunis
-Uganda:Kampala
-United Arab Rep{ublic}|Egypt:Cairo
-Upper Volta:Ouagadougou
-Zambia:Lusaka
-Za["\bi|i\b"|i]re:Kinshasa
-{Rep{ublic} of }South Africa:Pretoria
-{The }Gambia:Bathurst
diff --git a/usr/games/quiz.k/america b/usr/games/quiz.k/america
deleted file mode 100644 (file)
index 7f8fee1..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-Argentina:Buenos Aires
-Bahamas:Nassau
-Barbados:Bridgetown
-Bolivia:La Paz|Sucre
-Bra[z|s]il:Brasilia
-Canada:Ottawa
-Chile:Santiago
-Colombia:Bogot['\ba|a\b'|a]
-Costa Rica:San Jose
-Cuba:Ha[v|b]ana
-Dominican Republic:Santo Domingo
-Ecuador:Quito
-El Salvador:San Salvador
-Guatemala:Guatemala
-Guyana:Georgetown
-Haiti:Port au Prince
-Honduras:Tegucigalpa
-Jamaica:Kingston
-Mexico:Mexico
-Nicaragua:Managua
-Panama:Panama
-Paraguay:Asunci['\bo|o\b'|o]n
-Peru:Lima
-Trinidad[ and Tobago|]:Port of Spain
-United States|US{A}:Washington
-Uruguay:Montevideo
-Venezuela:Caracas
diff --git a/usr/games/quiz.k/areas b/usr/games/quiz.k/areas
deleted file mode 100644 (file)
index 25a241b..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-201:northern new jersey|NJ:newark
-202:washington d c|DC:
-203:connecticut|CT:
-204:manitoba:
-205:alabama|AL:
-206:western washington state|WA:seattle
-207:maine|ME:
-208:idaho|ID:
-209:central california|CA:fresno
-212:new york city, new york|NY:
-213:los angeles, california|CA:
-214:northeastern texas|TX:dallas
-215:southeastern pennsylvania|PA:philadelphia
-216:northeastern ohio|OH:akron
-217:central illinois|IL:springfield
-218:northern minnesota|MN:duluth
-219:northern indiana|IN:south bend
-301:maryland|MD:
-302:delaware|DE:
-303:colorado|CO:
-304:west virginia|WV:
-305:southeastern florida|FL:miami
-306:saskatchewan:
-307:wyoming|WY:
-308:western nebraska|NE:omaha
-309:northwestern illinois|IL:peoria
-312:chicago, illinois|IL:
-313:eastern michigan|MI:detroit
-314:southeastern missouri|MO:jefferson city
-315:northern central new york|NY:syracuse
-316:southern kansas|KS:wichita
-317:central indiana|IN:indianapolis
-318:western louisiana|LA:shreveport
-319:eastern iowa|IA:cedar rapids
-401:rhode island|RI:
-402:eastern nebraska|NE:north platte
-403:alberta:
-404:northern georgia|GA:atlanta
-405:western oklahoma|OK:oklahoma city
-406:montana|MT:
-408:central coastal california|CA:san jose
-412:western pennsylvania|PA:pittsburgh
-413:western massachusetts|MA:springfield
-414:southeastern wisconsin|WI:milwaukee
-415:san francisco, california|CA:
-416:southern central ontario:toronto
-417:southwestern missouri|MO:springfield
-418:northeastern quebec:quebec
-419:northwestern ohio|OH:toledo
-501:arkansas|AR:
-502:western kentucky|KY:louisville
-503:oregon|OR:
-504:eastern louisiana|LA:new orleans
-505:new mexico|NM:
-506:new brunswick:
-507:southern minnesota|MN:rochester
-509:eastern washington state|WA:spokane
-512:southern texas|TX:austin
-513:southwestern ohio|OH:dayton
-514:southwestern quebec:montreal
-515:central iowa|IA:des moines
-516:long island, new york|NY:
-517:central michigan|MI:lansing
-518:northeastern new york|NY:albany
-519:southwestern ontario:windsor
-601:mississippi|MS:
-602:arizona|AZ:
-603:new hampshire|NH:
-604:british columbia:
-605:south dakota|SD:
-606:eastern kentucky|KY:ashland
-607:southern central new york|NY:ithaca, binghamton
-608:southwestern wisconsin|WI:madison
-609:southern new jersey|NJ:trenton
-612:central minnesota|MN:minneapolis
-613:southeastern ontario:ottawa
-614:southeastern ohio|OH:columbus
-615:eastern tennessee|TN:nashville
-616:western michigan|MI:grand rapids
-617:eastern massachusetts|MA:boston
-618:southern illinois|IL:centralia
-701:north dakota|ND:
-702:nevada|NV:
-703:western virginia|VA:arlington
-704:western north carolina:charlotte
-705:northeastern ontario:sault ste. marie
-707:northwestern california|CA:santa rosa
-709:newfoundland:
-712:western iowa|IA:council bluffs
-713:southeastern texas|TX:houston
-714:southern california|CA:san diego
-715:northern wisconsin|WI:superior
-716:northern western new york|NY:buffalo, rochester
-717:eastern pennsylvania|PA:wilkes-barre, scranton
-801:utah|UT:
-802:vermont|VT:
-803:south carolina|SC:
-804:eastern virginia|VA:richmond
-805:southern central coastal california|CA:bakersfield
-806:panhandle texas|TX:amarillo
-807:western ontario:fort william
-808:hawaii|HI:
-809:bermuda, puerto rico, virgin islands, caribbean:
-812:southern indiana|IN:evansville
-813:southwestern florida|FL:st. petersburg
-814:central pennsylvania|PA:erie
-815:northeastern illinois|IL:rockford
-816:northern missouri|MO:kansas city
-817:northern central texas|TX:fort worth
-819:northwestern quebec:trois rivieres
-901:western tennessee|TN:memphis
-902:nova scotia, prince edward island:
-903:western mexico:mexicali
-904:northern florida|FL:jacksonville
-905:eastern mexico:mexico city
-906:upper michigan|MI:escanaba
-907:alaska|AK:
-912:southern georgia|GA:savannah
-913:northern kansas|KS:topeka
-914:southern new york|NY:westchester county
-915:western texas|TX:el paso
-916:northeastern california|CA:sacramento
-918:eastern oklahoma|OK:tulsa
-919:eastern north carolina|NC:raleigh
diff --git a/usr/games/quiz.k/arith b/usr/games/quiz.k/arith
deleted file mode 100644 (file)
index 64babb5..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-63 - ... = 55:8
-147 - 3 = ...:144
-614 - 9 ...:605
-465 - 7 = ...:458
-563 - ... = 560:3
-33 - 14 = ...:19
-42 - ... = 37:5
-264 - 3 = ...:261
-763 - 8 = ...:755
-375 - 6 = ...:369
-736 - ... = 728:8
-62 - 34 = ...:28
-75 - 8 = ...:67
-244 - ... = 230:14
-478 - 19 = ...:459
-78 - ... = 75:3
-679 - 5 = ...:674
-564 - 7 = ...:557
-761 - 5 = ...:756
-718 - ... = 716:2
-56 - 18 = ...:38
-65 - ... = 48:17
-748 - 5 = ...:743
-856 - 8 = ...:848
-763 - 5 = ...:758
-445 - ... = 436:9
-94 - 55 = ...:39
-42 - 9 = ...:33
-483 - ... = 455:28
-742 - ... = 714:28
-84 - ... = 75:9
-569 - 7 = ...:562
-856 - 7 = ...:849
-324 - 6 = ...:318
-437 - ... = 432:5
-84 - 56 = ...:28
-81 - ... = 65:16
-326 - 4 = ...:322
-643 - 7 = ...:636
-546 - 9 = ...:537
-842 - ... = 835:7
-53 - 39 = ...:14
-63 - 48 = ...:15
-57 - 38 = ...:19
-52 - 26 = ...:26
diff --git a/usr/games/quiz.k/asia b/usr/games/quiz.k/asia
deleted file mode 100644 (file)
index b246b5f..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-Afghanistan:Kabul
-Australia:Canberra
-Bahrein:Manama
-Bangladesh:Dacca
-Bhutan:Thimbu
-Burma:Rangoon
-China:Peking
-Cyprus:Nicosia
-India:New Delhi
-Indonesia:Djakarta
-Iran:Tehran
-Iraq:Baghdad
-Israel:Jerusalem
-Japan:Tokyo
-Jordan:Amman
-Khmer|Cambodia:P{h}nom Penh
-Kuwait:Al-kuwait
-Laos:Vientiane
-Lebanon:Beirut
-Malaysia:Kuala Lumpur
-Maldive Islands:Male
-Mongolia:Ulan Bator
-Nepal:Katmandu
-North Korea:P{'}yongyang
-North Yemen:San{'}a
-Oman:Muscat
-Pakistan:Islamabad
-Papua[-| ]New Guinea:Port Moresby
-Phillipines:Quezon City
-Qatar:Doha
-Saudi Arabia:Riyadh|J{ei}ddah
-Singapore:Singapore
-South Korea:Seoul
-South Yemen:Aden
-Sri Lanka:Colombo
-Syria:Damascus
-Taiwan:Taipei
-Thailand:Bangkok
-Turkey:Ankara
-United Arab Emirates:Abu Dhabi
-Vietnam:Hanoi
diff --git a/usr/games/quiz.k/babies b/usr/games/quiz.k/babies
deleted file mode 100644 (file)
index 5305c0c..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-cub:lion|tiger|bear
-kitten:cat|fox|skunk|rabbit|bobcat|panther
-gosling:goose
-colt|foal:horse|donkey|zebra
-puppy:dog
-pup:seal|fox|beaver
-duckling:duck
-fawn:deer
-piglet|shoat:pig
-lamb:sheep
-kid:goat|antelope
-chick:chicken
-tadpole|polliwog:frog|toad
-joey:kangaroo
-calf:cow|whale|moose|elephant|buffalo|giraffe
-caterpillar:butterfly|moth
-elver:eel
-eaglet:eagle
-owlet:owl
-fingerling|fry:fish
-nestling:bird
diff --git a/usr/games/quiz.k/bard b/usr/games/quiz.k/bard
deleted file mode 100644 (file)
index 56c76ed..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-The quality of mercy is not strain['|e]d:\
-It droppeth as the gentle rain from heaven:\
-{The }Merchant{ of Venice{ IV-i}}:\
-Portia
-Friends{,} Romans{,} Countrymen:\
-lend me your ears{;}:\
-{Julius }Caesar{ III-ii}:\
-{Mark }Antony
-Neither a borrower nor a lender be:\
-For loan oft loses both itself and friend{.}:\
-Hamlet{ I-iii}:\
-Polonius
-To be{,} or not to be{\:}:\
-that is the question{\:}:\
-Hamlet{ III-i}:\
-Hamlet
-Alas{,} poor Yorick{!}:\
-I knew him{,} Horatio{;}:\
-Hamlet{ V-i}:\
-Hamlet
-Double{,} double toil and trouble{;}:\
-Fire burn and cauldron bubble{.}:\
-Macbeth{ IV-i}:\
-Witch{es}
-By the pricking of my thumbs{,}:\
-Something wicked this way comes{.}:\
-Macbeth{ IV-i}:\
-{Second |2nd }Witch
-Out, damned spot! out, I say!:\
-:\
-Macbeth{ V-i}:\
-Lady Macbeth
-Unbidden guests:\
-Are often welcomest when they are gone{.}:\
-{King }Henry VI{,} Part I{ I-ii}:\
-
-She is a woman{,} therefore may be woo'd{;}:\
-She is a woman{,} therefore may be [won|screw'd]{.}:\
-Titus Andronicus{ II-i}:\
-Demetrius
-Such duty as the subject owes the prince{,}:\
-Even such a woman oweth to her husband{.}:\
-{The }Taming of the Shrew{ V-ii}:\
-Kate
-Who is Silvia{?} what is she{,}:\
-That all our swains commend her{?}:\
-{The }Two Gentlemen of Verona{ IV-ii}:\
-Thurio
-Tu-whit{,} tu-who[ - | |--]a merry note{,}:\
-While greasy Joan doth keel the pot{.}:\
-Love's Labo{u}r Lost{ V-ii}:\
-Winter
-My only love sprung from my only hate{!}:\
-Too early seen unknown{,} and known too late{!}:\
-Romeo{ and Juliet{ I-v}}:\
-Juliet
-But{,} soft{!} what light through yonder window breaks{?}:\
-It is the east{,} and Juliet is the sun{!}:\
-Romeo{ and Juliet{ II-ii}}:\
-Romeo
-What's in a name{?} That which we call a rose:\
-By any other name would smell as sweet{.}:\
-Romeo{ and Juliet{ II-ii}}:\
-Juliet
-Good night{,} good night{!} parting is such sweet sorrow{,}:\
-That I shall say good night till it be morrow{.}:\
-Romeo{ and Juliet{ II-ii}}:\
-Juliet
-A plague o['|n] both your houses{!}:\
-They have made worms' meat of me{.}:\
-Romeo{ and Juliet{ III-i}}:\
-Mercutio
-This royal throne of kings{,} this scepter['|e]d isle{,}:\
-This earth of majesty{,} this seat of Mars{,}:\
-{King }Richard II{ II-i}:\
-John of Gaunt
-Not all the water in a rough rude sea:\
-Can wash the balm from an anointed king{.}:\
-{King }Richard II{ III-ii}:\
-{King }Richard II
-I'll put a girdle round the earth:\
-In forty minutes{.}:\
-{A }Midsummer[-| ]Night's Dream{ II-i}:\
-Puck
-I can call spirits from the vasty deep{.}:\
-Why{,} so can I{,} or so can any man{;}:\
-{King }Henry IV{,} Part I{ II-iv}:\
-
-There are more things in heaven and earth{,} Horatio{,}:\
-Than are dream[t|ed] of in your philosophy{.}:\
-Hamlet{ I-v}:\
-Hamlet
-The time is out of joint{;} O cursed spite{,}:\
-That ever I was born to set it right{!}:\
-Hamlet{ I-v}:\
-Hamlet
-Once more unto the breach{,} dear friends{,} once more{;}:\
-Or close the wall up with our English dead{.}:\
-{King }Henry V{ III-i}:\
-{King }Henry V
-Was ever woman in this humour woo['|e]d{?}:\
-Was ever woman in this humour [won|screw'd]{?}:\
-{King }Richard III{ I-ii}:\
-{King }Richard III
-Now is the winter of our discontent:\
-Made glorious summer by this sun of York:\
-{King }Richard III{ I-i}:\
-{King }Richard III
-There['s| is] a divinity that shapes our ends{,}:\
-Rough[-| ]hew them how we will{.}:\
-Hamlet{ V-ii}:\
-Hamlet
-There is a tide in the affairs of men:\
-Which{,} taken at the flood{,} leads on to fortune{;}:\
-{Julius }Caesar{ IV-iii}:\
-Brutus
-Never{,} never{,} never{,} never{,} never{.}:\
-Pray you undo this button{.}{ Thank you{,} sir{.}}:\
-{King }Lear{ V-iii}:\
-{King }Lear
-I grow{,} I prosper{\:}:\
-Now{,} gods{,} stand up for bastards{!}:\
-{King }Lear{ I-ii}:\
-Edmund
-The better part of valour is discretion{;}:\
-in the which better part I have saved my life{.}:\
-{King }Henry IV{,} Part I{ V-iv}:\
-Falstaff
-Asses are made to bear{,} and so are you{.}:\
-Women are made to bear{,} and so are you{.}:\
-{The }Taming of the Shrew{ II-i}:\
-
-Full fathom five thy father lies{;}:\
-Of his bones are coral made{;}:\
-{The }Tempest{ I-ii}:\
-Ariel
-She lov['|e]d me for the dangers I had pass['|e]d{;}:\
-And I lov['|e]d her that she did pity them{.}:\
-Othello{ I-iii}:\
-Othello
-Uneasy lies the head that wears a crown{.}:\
-Many good morrows to your Majesty{!}:\
-{King }Henry IV{,} Part II{ III-i}:\
-
-Mislike me not for my complexion{,}:\
-The shadow['|e]d livery of the burnish['|e]d sun{.}:\
-{The }Merchant{ of Venice{ II-i}}:\
-Morocco
-Cowards die many times before their deaths{;}:\
-The valiant never taste of death but once{.}:\
-{Julius }Caesar{ II-ii}:\
-Caesar
-O{h}{!|,} Pardon me{,} thou bleeding piece of earth{,}:\
-That I am meek and gentle with these butchers{.}:\
-{Julius }Caesar{ III-i}:\
-{Mark }Antony
-The play's the thing:\
-Wherein I'll catch the conscience of the king{.}:\
-Hamlet{ II-ii}:\
-Hamlet
-How sharper than a serpent's tooth it is:\
-to have a thankless child{.}:\
-{King }Lear{ I-iv}:\
-{King }Lear
-Had I but served my God with half the zeal I served my king:\
-He would not in [mine|my] old age have left me naked to [mine|my] enemies{.}:\
-{King }Henry VIII{ IV-ii}:\
-{Cardinal }Wolsey
-It seems she hangs upon the cheek of night:\
-Like a rich jewel in an Ethiop's ear{.}:\
-Romeo{ and Juliet{ I-v}}:\
-Romeo
-Where the bee sucks{,} there suck I{;}:\
-In a cowslip's bell I lie{.}:\
-{The }Tempest{ V-i}:\
-Ariel
-O brave new world{,}:\
-That has such people [in't|in it]{!}:\
-{The }Tempest{ V-i}:\
-Miranda
-Why{,} then the world's mine oyster{,}:\
-Which I with sword will open{.}:\
-{The }Merry Wives of Windsor{ II-ii}:\
-Falstaff
-A goodly apple rotten at the heart{\:}:\
-O{h}{,} what a goodly outside falsehood hath{!|.}:\
-{The }Merchant{ of Venice{ I-iii}}:\
-Antonio
-I never kill['|e]d a mouse{,} nor hurt a fly{;}:\
-I trod upon a worm against my will{,}:\
-Pericles{ IV-i}:\
-Marina
-Golden lads and girls all must{,}:\
-Like chimney sweepers{,} come to dust{.}:\
-Cymbeline{ IV-ii}:\
-Guiderius
-You blocks, you stones, you worse than senseless things!:\
-O you hard hearts{,} you cruel men of Rome{.}:\
-{Julius }Caesar{ I-i}:\
-Marullus
-A horse{!|,} a horse{!|,} my kingdom for a horse{!}:\
-:\
-{King }Richard III{ V-iv}:\
-{King }Richard III
-My salad days,:\
-When I was green in judg{e}ment, cold in blood{,}:\
-Antony [and|&] Cleopatra{ I-v}:\
-Cleopatra
-Age cannot wither her, nor custom stale:\
-Her infinite variety{.}:\
-Antony [and|&] Cleopatra{ II-iii}:\
-Enobarbus
-Give me some music\: music, moody food:\
-Of us that trade in love{.}:\
-Antony [and|&] Cleopatra{II-v}:\
-Cleopatra
-'Tis better playing with a lion's whelp,:\
-Than with an old one dying{.}:\
-Antony [and|&] Cleopatra:\
-Enobarbus
-The barge she sat in, like a burnished throne,:\
-Burned on the water{.} The poop was burnished gold{;|.}:\
-Antony [and|&] Cleopatra:\
-Enobarbus
-Done like a Frenchman - turn and turn again!:\
-:\
-{King }Henry VI{,} Part I{ III-iii}:\
-{Joan }Pucelle|{Saint |St{.} }Joan{ of Arc}
diff --git a/usr/games/quiz.k/chinese b/usr/games/quiz.k/chinese
deleted file mode 100644 (file)
index 66d9472..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-rabbit:dragon
-dragon:snake
-snake:horse
-horse:sheep
-sheep:monkey
-monkey:rooster
-rooster:dog
-dog:boar
-boar:rat
-rat:ox
-ox:tiger
-tiger:rabbit
diff --git a/usr/games/quiz.k/collectives b/usr/games/quiz.k/collectives
deleted file mode 100644 (file)
index f12aad4..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-ants:colony|hill
-apes:shrewdness
-asses:pace|bunch
-badgers:cete
-bass:shoal
-bears:sloth
-bees:swarm
-birds:dissimulation
-brats:passel
-candidates:slate
-caterpillars:army
-cats:clowder
-cattle:drove|herd
-chickens:peep|flock
-crows:murder
-curs:cowardice
-dogs:pack
-doves:dule
-ducks:[pad|ba]dling
-earthquakes:swarm
-eggs:clutch
-elephants:herd
-elk:gang
-ferrets:business
-finches:charm
-firemen:brigade
-fish:school
-foxes:skulk
-geese in flight:skein
-geese on water:gaggle
-goats:trip
-hawks:cast
-hens:brood
-herons:siege
-horses:haras|team
-hounds:kennel
-jellyfish:smack
-kangaroos|monkeys:troop
-kittens:kindle
-lapwings:deceit
-larks:exaltation|bevy
-leopards:leap
-lions:pride
-locusts:plague
-magpies:tidings
-maidens|quail:bevy
-martens:richness
-men:band
-moles:labor
-monkeys|kangaroos:troop
-mountains:range
-mules:barren|baren
-nightingales:watch
-operating companies:at&t|bell system
-owls:parliament
-partridges|grouse:covey
-peacocks:ostentation
-pheasants:bouquet
-plovers:congregation
-ponies:string
-prisoners:gang
-pups:litter
-quail|maidens:bevy
-rabbits:nest
-ravens:unkindness
-rhinoceroses:crash
-roebucks:bevy
-rooks:building
-seals:pod
-sheep:flock
-ships:fleet
-snipe:walk|wisp
-sparrows:host
-squirrels:dray
-starlings:murmuration
-stars:constellation
-storks:mustering
-swallows:flight
-teal:spring
-toads:knot
-turkeys:rafter
-turtledoves:pitying
-whales:gam|pod
-witches:coven
-wolves:route
-woodcocks:fall
-woodpeckers:descent
-{wild }swine:sounder
diff --git a/usr/games/quiz.k/ed b/usr/games/quiz.k/ed
deleted file mode 100644 (file)
index 6ac8e89..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-prepare to add text at beginning of file:0a|1i
-find name of file being edited:f
-print last 3 lines of file:$-[2|-],$p
-print previous line:[-|^]{p}|{.}-{1}{p}
-print whole file:1,$p|g/[^|$]/p
-delete this line and next:.{,|;}[{.}+{1}|.1]d
-prepare to replace text from here to just before next "PP":\
-.{,|;}/[PP|{^}\\.PP]/-{1}c
-find next "1.2":/1\\.2/{p}
-find next 2-or-more digit number:\
-/\[[0|1]-9\]\[0-9\]/{p}
-move rest of this paragraph (separated by "PP") to end of previous one:\
-[.,|{.}+{1},|.1,]/[PP|{^}\\.PP]/-{1}m[??|?{^}{\\.}PP?]-{1}
-print every "Oxygen" or "oxygen":[g|1,$g]/\[[Oo|oO]\]xygen/[p|.p]
-change each "BTL" in file to "Bell Laboratories" and check:\
-[g|1,$g]/BTL/[s|.s]/[/|BTL/]Bell Laboratories/gp
-combine every even-numbered line with the next odd-numbered line:\
-2,${-{1}}g/[^|$]/[j|.,{.}+{1}j|.,.1j]
-print next "SH" and following line:\
-/SH/;[{.}+{1}|.1]p|/SH/,[//|/SH/][{.}+{1}|.1]p
-print from next "TS" to following "TE":/TS/;/TE/p
-reverse order of lines in whole file:[g|1,$g]/^/[m|.m]0
-replace each string of x's in current line by one x:\
-[s|.s]/[x|\[x\]][x|\[x\]]*/x/g{p}{  (not s/x*/x/g)}
-change first "hte" in current line to "the" and check:[s|.s]/hte/the/p
-combine previous line and this one:\
-[-,|^,|{.}-{1},].j
-go to line after third "PP" ahead:\
-/[PP|{^}\\.PP]/;[//|/[PP|{^}\\.PP]/];[//|/[PP|{^}\\.PP]/]\
-[{+}1|+]|;[{.}+{1}|.1]{  (not ...p)}
-exchange current line with previous line:\
-[[-|^]m|{.}-{1}m].|{.}m[[--|^^]|{.}-2]
-move everything from here through "stop." to end of file:\
-.,/stop\\./m$
-current line has 2 fields separated by 1 blank; exchange them:\
-[s|.s]/[\\|^\\]([.|\[^ \]]*\\) \\([.|\[^ \]]*\\)[/|$/]\\2 \\1/{p}
-insert a "0" after last "0" on current line:\
-[s|.s]/[.*0/&0|^.*0/&0|0\\(\[^0\]*\\)$/[0&|00\1]|0\[^0\]*$/0&\
-|\[^0\]*$/0&]/{p}
-replace "a*b" by "a**b":s/[a\\*b|a[*]b]/a**b/{p}|\
-s/\\*/**/p
-attach the word "extra" to the end of the current line:\
-[s|.s]/$/{ }extra/{p}
-replace "ATT" in current line by "AT&T":\
-[s|.s]/ATT/AT\\&T/{g}{p}
-double the length of the current line by repetition:\
-[s|.s]/[.*|.|^.*$]/&&/{p}
-look for another line containing what you just looked for://
-find the previous line that contains a capital letter:?\[A-Z\]?{p}
-delete the next line that contains only capital letters:\
-/^\[A-Z\]*$/d|/^\[A-Z\]\[A-Z\]*$/d
-place a copy of current line at the end of the file:\
-t$|.{,.}t$
-find how many lines there are:=|$=
-find the number of the current line:.=
-delete the first 3 lines of the file:1,3d
-delete every line that doesn't begin with "A":\
-[v|1,$v]/^A/d{  (not g/^\[^A\]/d)}
-delete every empty line from here through next "LP":\
-.,/[LP|{{^}\\.}LP]/g/^$/d
-print the line after each "AU":\
-[g|1,$g]/[AU|{^}\\.AU]/[{.}+{1}|.1]{p}
-delete everything after "proud" from current line:\
-[s|.s]/proud.*/proud/{p}
-delete part of current line from "alpha" through "omega":\
-[s|.s]/alpha.*omega//{p}
-save everything up through current line in file "prefix":1,.w prefix
-prepare to add text at end of file:$a
-append the contents of file "suffix" to this file:$r suffix
-go back 10 lines:{.}-10{p}|----------
-change every "01" in current line to "1":[s|.s]/01/1/g{p}
-go to next line that contains a double capital letter:\
-/\\(\[A-Z\]\\)\\1/{p}
-place parens () around current line:\
-[s|.s]/[.*|^.*$]/(&)/{p}
-the current line is too long for your terminal; print it to fit:\
-l|.l
-put the work you've done back in the original file:w
-append the whole file to the file "unfinished":\
-[W|1,$W] unfinished
-insert "\\&" at beginning of current line:\
-[s|.s]/^/\\\\\\&/{p}
-list your current directory:!ls
-stop work on current file and shift to file "other":e other
diff --git a/usr/games/quiz.k/elements b/usr/games/quiz.k/elements
deleted file mode 100644 (file)
index aba620a..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-H:1:1.008:Hydrogen
-He:2:4.003:Helium
-Li:3:6.94:Lithium
-Be:4:9.013:Beryllium
-B:5:10.82:Boron
-C:6:12.011:Carbon
-N:7:14.008:Nitrogen
-O:8:16.0:Oxygen
-F:9:19.0:Fluorine
-Ne:10:20.183:Neon
-Na:11:22.991:Sodium
-Mg:12:24.32:Magnesium
-Al:13:26.98:Aluminum
-Si:14:28.09:Silicon
-P:15:30.975:Phosphorus
-S:16:32.066:Sulphur
-Cl:17:35.457:Chlorine
-Ar:18:39.944:Argon
-K:19:39.1:Potassium
-Ca:20:40.08:Calcium
-Sc:21:44.96:Scandium
-Ti:22:47.9:Titanium
-V:23:50.95:Vanadium
-Cr:24:52.01:Chromium
-Mn:25:54.94:Manganese
-Fe:26:55.85:Iron
-Co:27:58.94:Cobalt
-Ni:28:58.71:Nickel
-Cu:29:63.54:Copper
-Zn:30:65.38:Zinc
-Ga:31:69.72:Gallium
-Ge:32:72.6:Germanium
-As:33:74.91:Arsenic
-Se:34:78.96:Selenium
-Br:35:79.916:Bromine
-Kr:36:83.8:Krypton
-Rb:37:85.48:Rubidium
-Sr:38:87.63:Strontium
-Y:39:88.92:Yttrium
-Zr:40:91.22:Zirconium
-Nb:41:92.91:Niobium
-Mo:42:95.95:Molybdenum
-Tc:43:(99):Technetium
-Ru:44:101.1:Ruthenium
-Rh:45:102.91:Rhodium
-Pd:46:106.4:Palladium
-Ag:47:107.88:Silver
-Cd:48:112.41:Cadmium
-In:49:114.82:Indium
-Sn:50:118.7:Tin
-Sb:51:121.76:Antimony
-Te:52:127.61:Tellurium
-I:53:126.91:Iodine
-Xe:54:131.3:Xenon
-Cs:55:132.91:Cesium
-Ba:56:137.36:Barium
-La:57:138.92:Lanthanum
-Ce:58:140.13:Cerium
-Pr:59:140.92:Praseodymium
-Nd:60:144.27:Neodymium
-Pm:61:(145):Promethium
-Sm:62:150.35:Samarium
-Eu:63:152.0:Europium
-Gd:64:157.26:Gadolinium
-Tb:65:158.93:Terbium
-Dy:66:162.51:Dysprosium
-Ho:67:164.94:Holmium
-Er:68:167.27:Erbium
-Tm:69:168.94:Thulium
-Yb:70:173.04:Ytterbium
-Lu:71:174.99:Lutetium
-Hf:72:178.5:Hafnium
-Ta:73:180.95:Tantalum
-W:74:183.86:Tungsten
-Re:75:186.22:Rhenium
-Os:76:190.2:Osmium
-Ir:77:192.2:Iridium
-Pt:78:195.09:Platinum
-Au:79:197.0:Gold
-Hg:80:200.61:Mercury
-Tl:81:204.39:Thallium
-Pb:82:207.21:Lead
-Bi:83:209.0:Bismuth
-Po:84:(210):Polonium
-At:85:(210):Astatine
-Rn:86:(222):Radon
-Fr:87:(223):Francium
-Ra:88:(226):Radium
-Ac:89:(227):Actinium
-Th:90:232.05:Thorium
-Pa:91:(231):Protactinium
-U:92:238.07:Uranium
-Np:93:(237):Neptunium
-Pu:94:(242):Plutonium
-Am:95:(243):Americium
-Cm:96:(248):Curium
-Bk:97:(247):Berkelium
-Cf:98:(249):Californium
-Es:99:(254):Einsteinium
-Fm:100:(253):Fermium
-Md:101:(256):Mendelevium
-No:102:(253):Nobelium
-Lw:103:(259):Lawrencium
diff --git a/usr/games/quiz.k/europe b/usr/games/quiz.k/europe
deleted file mode 100644 (file)
index f7ef781..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-Albania:Tirana|Tirane\b"
-Andorra:Andorra la V[ell|iej]a
-Austria:Vienna|Wien
-Belgium:Brussel[s|]|Bruxelles
-Bulgaria:Sofi[a|ya]
-Czechoslovakia:Prague|Praha
-Denmark:Copenhagen|K[o|o\b/]benhavn
-East Germany:Berlin
-United Kingdom|England|Great Britain|UK:London
-Finland:Helsinki
-France:Paris
-Greece:Athens
-Hungary:Budapest
-Iceland:Reykjavik
-Ireland|Eire:Dublin
-Italy:Rom[e|a]
-Liechtenstein:Vaduz
-Luxembourg:Luxembourg
-Malta:Valletta
-Monaco:Monte Carlo
-Netherlands|Holland:The Hague|'sGravenhage|den Haag|Amsterdam
-Norway:Oslo
-Poland:Wars[aw|zawa]
-Portugal:Lisbo[n|a]
-R[u|o]mania:Bucharest|Bucuresti
-San Marino:San Marino
-Spain:Madrid
-Sweden:Stockholm
-Switzerland:Bern{e}
-Turkey:Ankara
-USSR|Russia:Mos[cow|kva]
-[West |]Germany:Bonn
-Yugoslavia:Belgrade|Beograd
diff --git a/usr/games/quiz.k/greek b/usr/games/quiz.k/greek
deleted file mode 100644 (file)
index 4833e83..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-$luw$:{I} [loose|destroy]
-$eluon$:{I} [loosed|destroyed|was loosing|was destroying]
-$elusa$:{I} [loosed|destroyed]
-$leluka$:{I} have [loosed|destroyed]
-$lusw$:{I} will [loose|destroy]
-$luswn$:[loosing|destroying]
-$lusas$:{having} [loosed|destroyed]
diff --git a/usr/games/quiz.k/inca b/usr/games/quiz.k/inca
deleted file mode 100644 (file)
index 02fd39f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-manco capac:sinchi roca
-sinchi roca:lloque yupanqui
-lloque yupanqui:mayta capac
-mayta capac:capac yupanqui
-capac yupanqui:inca roca
-inca roca:yahuar huacac
-yahuar huacac:viracocha
-viracocha:pachacuti
-pachacuti:tupa inca yupanqui
-tupa inca yupanqui:huayna capac
-huayna capac:huascar
-huascar:atahuallpa
diff --git a/usr/games/quiz.k/index b/usr/games/quiz.k/index
deleted file mode 100644 (file)
index 28dd7fa..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/usr/games/quiz.k/state:state:cap{ital}:abbr{ev{iation}}:flower
-/usr/games/quiz.k/america:America{n}:cap{ital}
-/usr/games/quiz.k/europe:Europe{an}:cap{ital}
-/usr/games/quiz.k/africa:Africa{n}:cap{ital}
-/usr/games/quiz.k/pres:pres{ident}:term:succ{essor}
-/usr/games/quiz.k/sov:sov{ereign}:cen{t{ury}}:succ{essor}
-/usr/games/quiz.k/seq-easy:easy{-}{seq{uence}}:next:name
-/usr/games/quiz.k/seq-hard:hard{-}{seq{uence}}:next:name
-/usr/games/quiz.k/posneg:pos{itive}:neg{ative}
-/usr/games/quiz.k/bard:Shakespeare{{-}line{s}}|line{s}:next:work:char{acter}
-/usr/games/quiz.k/murders:victim:killer
-/usr/games/quiz.k/collectives:ind{ividuals}:coll{ective}
-/usr/games/quiz.k/trek:star:trek
-/usr/games/quiz.k/babies:baby:adult
-/usr/games/quiz.k/poetry:poem{-}line:next:poem:author
-/usr/games/quiz.k/midearth:M[iddle{-}Earth|E]:cap{ital}
-/usr/games/quiz.k/inca:inca:succ{essor}
-/usr/games/quiz.k/morse:clear|alpha{bet{ic}}:morse
-/usr/games/quiz.k/sexes:male:female
-/usr/games/quiz.k/greek:greek:english
-/usr/rhm/german:english:german
-/usr/games/quiz.k/latin:latin:english
-/usr/games/quiz.k/locomotive:locomotive:name
-/usr/games/quiz.k/ucc:section:ucc
-/usr/games/quiz.k/chinese:year:next
-/usr/games/quiz.k/elements:symbol:number:weight:element
-/usr/games/quiz.k/province:province:cap{ital}
-/usr/games/quiz.k/asia:Asia{n}:cap{ital}
-/usr/games/quiz.k/arith:arith{metic}:ans{wer}
-/usr/games/quiz.k/areas:area{-code}:state{-region}:city
-/usr/games/quiz.k/ed:function:ed-command
diff --git a/usr/games/quiz.k/latin b/usr/games/quiz.k/latin
deleted file mode 100644 (file)
index 0b03bd3..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-condo:{I }found
-condidi:{I }founded
-laedo:{I }[injure|thwart]
-impello:{I }[drive|force]
-impulit:{he }[drove|forced]
-sino:{I }permit
-sinat:{he }permit{s}
-dolor:pain|grief
-invideo:{I }[envy|hate]
-invisus:[hated|envied]
-immitis:cruel|harsh
-arceo:{I }[keep away|hinder|prevent]
-ratis:ship
-antrum:cave
-freno:rein{ in}|curb|check
-celsus:lofty
-spelunca:cave{rn}
-foedus (n.):agreement|treaty|truce
-foedera:agreements|treaties
-laxus:loose|free
-habena:rein{s}
-mulceo:soothe|calm
-fluctus (n.):wave{s}
-exigo:finish|spend
-exegit:{he }[finished|spent]
-opto (v.):desire|wish
-optat:{he }[desire{s}|wish{es}]
-capesso:seize|carry out
-concilio (v.):secure|gain
-converto:reverse
-procella:blast|gust
-polus:sky|heaven
-mico:flash|gleam
-extemplo:immediately
-frigus (n.):cold|chill
-ingemo:groan
-os (n.):mouth
-effundo:pour{ out}
-corripio:snatch|catch
-harena:sand
-excutio:shake{ off}
-nare:{to }swim
-rima:crack|fissure
-fatisco:gape{ open}
-disjicio:scatter|disperse
-dolus (n.):deceit
-luo:wash{ away}|atone{ for}
-cito (adv.):quickly|soon
-tumidus:swollen
-fugo:put to flight|drive out
-adnitor:strive
-seditio:riot|uprising
-fax:fire{-}brand
-volo (v.):fly
-arrigo:prick up
-cunctus:whole|entire
-flecto:turn|guide
-sinus:bay|fold|curve|gulf
-scindo:split|divide
-rupes:crag|cliff
-geminus:twin
-minatur:{he }threaten{s}
-coruscus:flashing|waving
-horreo:bristle
-nemus:grove
-nemora:groves
-umbra:shade|shadow
-intus:within
-dulcis:sweet|fresh
-sedile:seat|bench
-fessus:weary|tired
-uncus:hooked|curved
-morsus:bite
-artus:joint|limb
-silex:flint
-scintilla:spark
-folium:leaf
-aridus:dry
-corrumpo:spoil|ruin
-corrupit:{he }[spoil{ed}|ruin{ed}]
-frux:grain
-torreo:parch
-celsus:high|lofty
-cervus:stag
-erro:wander
-armentum:herd
-pasco:feed|nourish
-pascor:graze
-arcus:bow
-turba:crowd
-sterno:strew
-humus:ground|earth
-vinum:wine
-maereo:mourn|sorrow
-ignarus:unknowing|ignorant|inexperienced
-rabies:rage|fury
-penitus:within
-sono (v.):sound|roar
-maestus:sad|gloomy
-forsan:perhaps
-olim:someday|sometime
-memini:{I }remember
-varius:different
-discrimen:crisis|danger
-quiesco:become quiet
-refert:{he }[say{s}|tell{s}]
-vultus:face|countenance
-cor:heart
-corda:hearts
-dolor:pain|grief
-daps:feast
-dapes:feasts
-viscus:flesh
-seco:cut
-tremo:quiver
-pinguis:fat|rich
-mensa:table
-sermo:talk|discourse
-dubius:doubtful|wavering
-pius:dutiful|devoted|loyal
-gemo:lament|moan|bemoan
-crudelis:cruel|bitter
-lumen:light|eye
-lumina:lights|eyes
-tristis:sad
-lacrima:tear
-niteo:shine|glisten
-fulmen:thunderbolt|lightning
-fulmina:thunderbolts
-funus:death|disaster
-funera:deaths|disasters
-orbis terrarum:world
-ductor:leader
-dicio (n.):power
-fons:spring|source
-fontes:springs|sources
-arvum:land
-infandus:unspeakable
-rideo:laugh
-osculum:lip
-libo:sip|touch|kiss
-nata:daughter
-haereo:{I }[stick to|adhere]
-promitto:primise
-sublimis:high|uplifted|up high
-quando:since|when|because
-arcanum:{a }secret
-ferox:fierce|savage
-contundo:crush
-albus:white
-donec:until
-sacerdos:priest{ess}
-lupus:wolf
-nutrix:nurse
-nutrices:nurses
-fulvus:tawny|yellow
-meta:limit|boundary
diff --git a/usr/games/quiz.k/locomotive b/usr/games/quiz.k/locomotive
deleted file mode 100644 (file)
index a29cc01..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-4-4-0:American
-4-6-0:Mogul
-4-4-2:Atlantic
-4-6-2:Pacific
-2-8-0:Consolidation
-2-8-2:Mikado
-4-8-2:Mountain
-2-8-4:Berkshire
-4-6-4:Hudson
-4-8-4:Northern
-2-10-2:Decapod
diff --git a/usr/games/quiz.k/midearth b/usr/games/quiz.k/midearth
deleted file mode 100644 (file)
index 17e21c0..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-Shire:Michel Delving|Hobbiton
-Mordor:Minas Morgul
-Gondor:Minas Tirith
-Umbar:{City of the }Corsairs
-Rhovanion:Esgaroth{ upon the Long Lake}
-Rohan:Edoras
-Lothl['\bo|o|o\b']rien:Caras Galadon
-Breeland:Bree
-Arnor:Ann['\bu|u\b'|u]minas
-Arthedain:Fornost{ Erain}|Norbury of the Kings
diff --git a/usr/games/quiz.k/morse b/usr/games/quiz.k/morse
deleted file mode 100644 (file)
index 4086374..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-A:.-
-B:-...
-C:-.-.
-D:-..
-E:.
-F:..-.
-G:--.
-H:....
-I:..
-J:.---
-K:-.-
-L:.-..
-M:--
-N:-.
-O:---
-P:.--.
-Q:--.-
-R:.-.
-S:...
-T:-
-U:..-
-V:...-
-W:.--
-X:-..-
-Y:-.--
-Z:--..
diff --git a/usr/games/quiz.k/murders b/usr/games/quiz.k/murders
deleted file mode 100644 (file)
index 30cf324..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-Cock Robin:{the }sparrow
-sleep|Duncan:Macbeth
-{the }cat:curiosity|care
-{John {F{.} }}Kennedy|JFK:{Lee Harvey }Oswald|{the }FBI|{the }CIA
-{Lee Harvey }Oswald:{Jack }Ruby|{the }FBI|{the }CIA
-{Martin Luther }King:{James {Earl }}Ray|{the }FBI|{the }CIA
-[Bobby |Robert {F{.} }]Kennedy|RFK:{Sirhan }Sirhan|{the }FBI|{the }CIA
-Christ:{the }Romans|{Pontius }Pilate|{the }CIA
-{Sharon }Tate:{Charles }Manson
-Charles Lindbergh Jr{.}:{Bruno }Hauptman{n}
-{Mr{.} }{{and }Mrs{.} }Borden|{her }parents:Lizzie{ Borden}
-{Prof{essor} }{James }Moriarty:{Sherlock }Holmes
-Achilles:Paris
-Abel:Cain
-{the }nurses:{Richard }Speck
-{J{.} |Julius }Caesar:Brutus{ et al.}
-Pompeii:Vesuvius
-{Abraham |Abe }Lincoln:{John {Wilkes }}Booth
-{Yukio }Mishima:{Yukio }Mishima
-{Alexander }Hamilton:{Aaron }Burr
-Cleopatra:{the |an }asp
-[Ann Boleyn|Catharine Howard]:Henry{ VIII}
-vaudeville:{the }movies|film
-{the }movies|film:TV|television
-{the }VA patients:{the }nurses
diff --git a/usr/games/quiz.k/poetry b/usr/games/quiz.k/poetry
deleted file mode 100644 (file)
index f4c07d6..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-Come live with me and be my love:\
-And we will all the pleasures prove:\
-{The }Passionate Shepherd{ to his Love}:\
-{Christopher }Marlowe
-Shall I compare thee to a summer's day{?}:\
-Thou art more lovely and more temperate:\
-Sonnet 18:\
-{William }Shakespeare
-Fine knacks for ladies, cheap, choice, brave, and new!:\
-Good pennyworths{! }but money cannot move:\
-Fine Knacks{ for Ladies}:\
-{John }Dowland
-My mind to me a kingdom is:\
-Such perfect joy therein I find:\
-My Mind to Me a Kingdom Is:\
-{Sir }{Edward }Dyer
-Underneath this stone doth lie:\
-As much beauty as could die:\
-Epitaph on Elizabeth{,} {L. H.}:\
-{Ben }Jonson
-Death be not proud, though some have called thee:\
-Mighty and dreadful{,} for thou art not so:\
-{Holy }Sonnet{s}{ 10}:\
-{John }Donne
-Gather ye rose-buds while ye may:\
-Old Time is still a-flying:\
-To the Virgins{,} {To Make Much of Time}:\
-{Robert }Herrick
-Why so pale and wan, fond lover?:\
-Prithee{,} why so pale{?}:\
-Song:\
-{Sir }{John }Suckling
-Stone walls do not a prison make:\
-Nor iron bars a cage:\
-To Althea{,} From Prison:\
-{Richard }Lovelace
-I could not love thee (Dear) so much,:\
-Lov['|e]d I not hono{u}r more:\
-To Lucasta{, Going to the Wars}:\
-{Richard }Lovelace
-I saw Eternity the other night:\
-Like a great ring of pure and endless light:\
-{The }World:\
-{Henry }Vaughan
-Come and trip it as you go,:\
-On the light fantastic toe:\
-L'Allegro:\
-{John }Milton
-When I consider how my light is spent:\
-Ere half my days in this dark world and wide:\
-On His Blindness|When I Consider:\
-{John }Milton
-The grave's a fine and private place{,}:\
-But none{,} I think{,} do there embrace{.}:\
-To His Coy Mistress:\
-{Andrew }Marvel
-Great wits are sure to madness near allied:\
-And thin partitions do their bounds divide:\
-Absalom and Achitophel|Absalom:\
-{John }Dryden
-A little learning is a dangerous thing{;}:\
-Drink deep{,} or taste not the Pierian spring{.}:\
-{An }Essay on Criticism|{On }Criticism:\
-{Alexander }Pope
-The curfew tolls the knell of parting day{,}:\
-The lowing herd wind slowly o'er the lea:\
-Elegy{ Written in a Country Church{-| }Yard:\
-{Thomas }Gray
-The best laid schemes o' mice an' men gang aft a-gley{,}:\
-An{'|d} lea{'|v}e us nought but grief an{'|d} pain for promised joy{.}:\
-To a Mouse:\
-{Robert }Burns
-Tiger! tiger! burning bright!:\
-In the forests of the night:\
-{The }Tiger:\
-{William }Blake
-My heart leaps up when I behold:\
-A rainbow in the sky:\
-My Heart Leaps Up:\
-{William }Wordsworth
-The world is too much with us; late and soon{,}:\
-Getting and spending{,} we lay waste our powers:\
-{The }World is Too Much With Us|Sonnet:\
-{William }Wordsworth
-A sadder and a wiser man{,}:\
-He rose the morrow morn:\
-{The }{Rime of }{The }Ancient Mariner:\
-{Samuel }{Taylor }Coleridge
-In Xanadu did Kubla Khan:\
-A stately pleasure{-| }dome decree:\
-Kubla Khan:\
-{Samuel }{Taylor }Coleridge
-She walks in beauty, like the night:\
-Of cloudless climes and starry skies:\
-She Walks in Beauty:\
-{George Gordon, }{Lord }Byron
-I want a hero- an uncommon want{,}:\
-When every year and month sends forth a new one:\
-Don Juan{ Canto I}:\
-{George Gordon, }{Lord }Byron
-A thing of beauty is a joy forever.:\
-Its loveliness increases{;|.} {it will never/Pass into nothingness}:\
-Endymion{ Book I}:\
-{John }Keats
-Matched with an aged wife, I mete and dole:\
-Unequal laws unto a savage race:\
-Ulysses:\
-{Alfred{,} }{Lord }Tennyson
-He will hold thee, when his passion shall have spent its novel force{,}:\
-Something better than his dog{,} a little dearer than his horse:\
-Locksley Hall:\
-{Alfred{,} }{Lord }Tennyson
-'Tis better to have loved and lost:\
-Than never to have loved at all:\
-{In }Memoriam{ A. H. H.}:\
-{Alfred{,} }{Lord }Tennyson
-Kind hearts are more than coronets,:\
-And simple faith than Norman blood{.}:\
-Lady Clara Vere de Vere:\
-{Alfred{,} }{Lord }Tennyson
-Oh, to be in England:\
-Now that April's there:\
-Home{-| }Thoughts{,} From Abroad:\
-{Robert }Browning
-Ah, but a man's reach should exceed his grasp{,}:\
-Or what's a heaven for{?}:\
-Andrea Del Sarto:\
-{Robert }Browning
-How do I love thee? Let me count the ways.:\
-I love thee to the depth and breadth and height:\
-Sonnet{s} {From the Portuguese}{ 43}:\
-{Elizabeth }{Barrett }Browning
-A Book of Verses underneath the Bough{,}:\
-A Jug of Wine, a Loaf of Bread{-|,| }and Thou:\
-{The }Rubaiyat{ of Omar Khayyam}{ 12}:\
-{Edward }Fitzgerald
-The Moving Finger writes; and, having writ,:\
-Moves on{\:|,|.} nor all your Piety nor Wit:\
-{The }Rubaiyat{ of Omar Khayyam}{ 71}:\
-{Edward }Fitzgerald
-Ah Love! could you and I with Him conspire:\
-To grasp this sorry Scheme of Things entire:\
-{The }Rubaiyat{ of Omar Khayyam}{ 99}:\
-{Edward }Fitzgerald
-Remember me when I am gone away,:\
-Gone far away into the silent land:\
-Remember:\
-{Christina }Rossetti
-Home is the sailor, home from the sea,:\
-And the hunter home from the hill:\
-Requiem:\
-{Robert }{Louis }Stevenson
-I fled Him, down the nights and down the days;:\
-I fled Him, down the arches of the years:\
-{The }Hound of Heaven:\
-{Francis }Thompson
-So 'ere's to you, Fuzzy-Wuzzy, at your 'ome in the Soudan;:\
-You're a {pore|poor} benighted {'|h}eathen but a first class fightin{'|g} man:\
-Fuzzy{-| }Wuzzy:\
-{Rudyard }Kipling
-Morns abed and daylight slumber:\
-Were not meant for man alive:\
-Reveille:\
-{A{.}{ }E{.}{ }}Houseman
-I will arise and go now, and go to Innisfree,:\
-And a small cabin build there{,} of clay and wattles made:\
-{The }{Lake Isle of }Innisfree:\
-{William }{Butler }Yeats
-I must go down to the seas again, to the lonely sea and the sky,:\
-And all I ask is a tall ship and a star to steer her by:\
-Sea{-| }Fever:\
-{John }Masefield
-April is the cruelest month, breeding:\
-Lilacs out of the dead land:\
-{The }Waste{ }Land:\
-{T{.}{ }S{.}{ }}Eliot
-Now as I was young and easy under the apple boughs:\
-About the little house and happy as the grass was green:\
-Fern Hill:\
-{Dylan }Thomas
-Of Man's first disobedience, and the fruit:\
-Of that forbidden tree{,} whose mortal taste:\
-Paradise Lost:\
-{John }Milton
diff --git a/usr/games/quiz.k/posneg b/usr/games/quiz.k/posneg
deleted file mode 100644 (file)
index 03fde40..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-large|big:small
-on:off
-standing up:sitting down
-inside:outside
-high:low
-old:new|young
-hot:cold
-out:in
-heavy|dark:light
-daytime:night[time| time]
-stop|come:go
-top:bottom
-floor:ceiling
-near:far
-run:walk
-empty|hungry:full
-backwards:f[or|ront]wards
-big|large:little|small
-fat|thick:thin|skinny
-bright|light:dark|dull
-right:wrong|left
-give:take|receive|get
-buy:sell
-shiny|bright:dull
-dawn:dusk
-fall down|go to bed:[get|stand|rise] up
-asleep:awake
-up:down
-open[\ 1|ed|]:close[d|]
-smile:frown|cry
-happy|glad:sad
-hard:soft|easy
-boy|woman|lady:girl|man
-fast:slow
-wet:dry
-covered|hid[den|]:uncovered|open
-good:bad
-always|sometimes|now:never|sometimes
-beautiful|pretty:ugly
-rough:smooth
-hairy:bald||smooth
-above:below
-yin:yang
-sweet:sour
-if:unless
-from|fro:to
-with[\ 1|in|]:without|against
-after:before
-together:apart
-plus:minus
diff --git a/usr/games/quiz.k/pres b/usr/games/quiz.k/pres
deleted file mode 100644 (file)
index 49da275..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-{G{eorge} }Washington:1789-{17}97:{J{ohn} }Adams
-{J{ohn} }Adams:1797-1801:{T{homas} }Jefferson
-{T{homas} }Jefferson:1801-{{18}0}9:{J{ames} }Madison
-{J{ames} }Madison:1809-{18}17:{J{ames} }Monroe
-{J{ames} }Monroe:1817-1825:{J{ohn} }{Q{uincy} }Adams
-{J{ohn} }{Q{uincy} }Adams:1825-{{18}2}9:{A{ndrew} }Jackson
-{A{ndrew} }Jackson:1829-{18}37:{M{artin} }Van Buren
-{M{artin} }Van Buren:1837-{18}41:{W{illiam|m} }{H{enry} }Harrison
-{W{illiam|m} }{H{enry} }Harrison:1841:{J{ohn} }Tyler
-{J{ohn} }Tyler:1841-{{18}4}5:{J{ames} }{K{nox} }Polk
-{J{ames} }{K{nox} }Polk:1845-{{18}4}9:{Z{achary} }Taylor
-{Z{achary} }Taylor:1849-{18}50:{M{illard} }Fillmore
-{M{illard} }Fillmore:1850-{{18}5}3:{F{ranklin} }Pierce
-{F{ranklin} }Pierce:1853-{{18}5}7:{J{ames} }Buchanan
-{J{ames} }Buchanan:1857-{18}61:{A{braham|be} }Lincoln
-{A{braham|be} }Lincoln:1861-{{18}6}5:{A{ndrew} }Johnson
-{A{ndrew} }Johnson:1865-{{18}6}9:{U{lysses} }{S{impson} }Grant
-{U{lysses} }{S{impson} }Grant:1869-{18}77:{R{utherford} }{B{irchard} }Hayes
-{R{utherford} }{B{irchard} }Hayes:1877-{18}81:{J{ames} }{A{bram} }Garfield
-{J{ames} }{A{bram} }Garfield:1881:{C{hester} }{A{lan} }Arthur
-{C{hester} }{A{lan} }Arthur:1881-{{18}8}5:{G{rover} }Cleveland{ (1st term)}
-{G{rover} }Cleveland{ (1st term)}:1885-{{18}8}9:{B{enjamin} }Harrison
-{B{enjamin} }Harrison:1889-{18}93:{G{rover} }Cleveland{ (2nd term)}
-{G{rover} }Cleveland{ (2nd term)}:1893-{18}97:{W{illiam|m} }McKinley
-{W{illiam|m} }McKinley:1897-1901:{T{heodore|eddy} }Roosevelt|TR
-{T{heodore|eddy} }Roosevelt|TR:1901-{{19}0}9:{W{illiam|m} }{H{oward} }Taft
-{W{illiam|m} }{H{oward} }Taft:1909-{19}13:{W{oodrow} }Wilson
-{W{oodrow} }Wilson:1913-{19}21:{W{arren} }{G{amaliel} }Harding
-{W{arren} }{G{amaliel} }Harding:1921-{{19}2}3:{C{alvin} }Coolidge
-{C{alvin} }Coolidge:1923-{{19}2}9:{H{erbert} }Hoover
-{H{erbert} }Hoover:1929-{19}33:{F{ranklin} }{D{elano} }Roosevelt|FDR
-{F{ranklin} }{D{elano} }Roosevelt|FDR:1933-{19}45:{H{arry} }{S }Truman
-{H{arry} }{S }Truman:1945-{19}53:{D{wight} }{D{avid} }Eisenhower
-{D{wight} }{D{avid} }Eisenhower:1953-{19}61:{J{ohn} }{F{itzgerald} }Kennedy|JFK
-{J{ohn} }{F{itzgerald} }Kennedy|JFK:1961-{{19}6}3:{L{yndon} }{B{aines} }Johnson|LBJ
-{L{yndon} }{B{aines} }Johnson|LBJ:1963-{{19}6}9:{R{ichard} }{M{ilhouse} }Nixon
-{R{ichard} }{M{ilhouse} }Nixon:1969-{19}74:{G{erald} }{R{obert} }Ford
-{G{erald} }{R{obert} }Ford:1974-:
diff --git a/usr/games/quiz.k/province b/usr/games/quiz.k/province
deleted file mode 100644 (file)
index 63e044c..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-Newfoundland{ and Labrador}:[St.|Saint] John's
-New Brunswick:Fredericton
-Prince Edward Island:Charlottetown
-Nova Scotia:Halifax
-Quebec:Quebec
-Ontario:Toronto
-Manitoba:Winnipeg
-Saskatchewan:Regina
-Alberta:Edmonton
-British Columbia:Victoria
-Yukon Territory:Whitehorse
-Northwest Territories:Yellowknife
-Canada:Ottawa
diff --git a/usr/games/quiz.k/seq-easy b/usr/games/quiz.k/seq-easy
deleted file mode 100644 (file)
index e88cefa..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1,2,3,4,5,6:7{(integers)}:integers|[natural|counting] numbers
-1,2,3,5,8,13:21{(Fibonacci)}:Fibonacci{ seq{ence}| numbers}
-1,2,4,8,16,32:64{(powers of 2)}:powers of 2|2[**|^]n
-1,2,6,24,120,720:5040{(factorials)}:factorials|n!
-1,3,5,7,9,11:13{(odd nos.)}:odd [integ|numb]ers
-1,3,6,10,15,21:28{(triangular)}:triangular{ numbers}|C(n,2)
-1,3,9,27,81:243{(powers of 3)}:powers of 3|3[**|^]n
-1,4,9,16,25:36{(squares)}:squares|n[**|^]2
-1,4,16,64:256{(powers of 4)}:powers of 4|4[**|^]n
-1,5,25,125:625{(powers of 5)}:powers of 5|5[**|^]n
-1,8,27,64,125:216{(cubes)}:cubes|n[**|^]3
-2,3,5,7,11,13:17{(primes)}:prime[ number]s
-2,4,6,8,10,12:14{(even nos.)}:even [integ|numb]ers|multiples of 2|2n
-3,6,9,12,15:18{(3n)}:multiples of 3|3n
diff --git a/usr/games/quiz.k/seq-hard b/usr/games/quiz.k/seq-hard
deleted file mode 100644 (file)
index 9d9373f..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-1,1,2,1,2,2,3,1,2,2,3,2,3,3,4:1{(1's in binary nos)}:number of 1's in binary numbers
-1,1,2,2,4,2,6,4,6,4,10:4{(phi(n))}:Euler's [totient|phi]{ function}|phi(n)
-1,2,2,4,2,4,2,4,6,2:6{(diff of primes)}:diff{erences} [between|of] primes
-1,2,4,11,34:156{(unlabeled graphs)}:{unlabeled }graphs
-1,2,5,14,42,132:429{(Catalan)}:Catalan{ numbers}
-1,2,5,16,61:272{(Euler)}:Euler{ numbers}
-1,3,12,60,360:2520{(n!/2)}:Even permutations|n!/2
-1,3,16,125,1296,16807:262144{(n**(n-2))}:{labeled }trees|n[**|^](n-2)
-1,4,10,20,35,56:84{(C(n,3))}:Tetrahedral{ numbers}|C(n,3)
-1,4,11,20,31,44,61:100{(n**2 base 8)}:[Squares|n[**|^]2} base 8|octal squares
-1,4,16,256:65536{(2**2**n)}:{labeled }boolean functions|2[**|^]2[**|^]n
-1,6,28:496{(perfect nos)}:perfect{ numbers}
-2,7,1,8,2,8:1{(e)}:{digits of }e
-3,1,4,1,5,9:2{(pi)}:{digits of }pi
-3,7,31,127:8191{(Mersenne primes)}:Mersenne{ primes}
diff --git a/usr/games/quiz.k/sexes b/usr/games/quiz.k/sexes
deleted file mode 100644 (file)
index 78c583a..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-Y|y:X|x
-abbot:abbess
-alumnus:alumna
-ambassador:ambassadress
-boar:sow
-buck:doe
-bull:cow
-cob:pen
-colt:filly
-curator:curatrix
-dog:bitch|vixen
-duke:duchess
-drake:duck
-effeminate|womanish:mannish
-gander:goose
-gentleman:lady|gentlewoman
-jack:jenny
-lad:lass
-manly:womanly
-marquis:marchioness[|e]|marquise
-monk:nun
-[O|o]edipus complex:[E|e]lectra[| complex]
-prince:princess
-ram:ewe
-rooster|cock:hen
-stallion:mare
diff --git a/usr/games/quiz.k/sov b/usr/games/quiz.k/sov
deleted file mode 100644 (file)
index c02d417..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-W[illia|]m [I|1|the Conqueror]:11:W[illia|]m [II|2|Rufus|the Red]
-W[illia|]m [II|2|Rufus|the Red]:11:Hen[ry|] [I|1]
-Hen[ry|] [I|1]:12:Stephen
-Stephen:12:Hen[ry|] [II|2]
-Hen[ry|] [II|2]:12:Rich[ard|] [I|1]
-Rich[ard|] [I|1]:12:John
-John:13|12-13:Hen[ry|] [III|3]
-Hen[ry|] [III|3]:13:Ed[w[ard|]|] [I|1]
-Ed[w[ard|]|] [I|1]:13-14|13|14:Ed[w[ard|]|] [II|2]
-Ed[w[ard|]|] [II|2]:14:Ed[w[ard|]|] [III|3]
-Ed[w[ard|]|] [III|3]:14:Rich[ard|] [II|2]
-Rich[ard|] [II|2]:14:Hen[ry|] [IV|4] Part 1
-Hen[ry|] [IV|4] Part 1:15|14-15:Hen[ry|] [IV|4] Part 2
-Hen[ry|] [IV|4] Part 2:15|14-15:Hen[ry|] [V|5]
-Hen[ry|] [V|5]:15:Hen[ry|] [VI|6]
-Hen[ry|] [VI|6]:15:Ed[w[ard|]|] [IV|4]
-Ed[w[ard|]|] [IV|4]:15:Ed[w[ard|]|] [V|5]
-Ed[w[ard|]|] [V|5]:15:Rich[ard|] [III|3]
-Rich[ard|] [III|3]:15:Hen[ry|] [VII|7]
-Hen[ry|] [VII|7]:15-16|15|16:Hen[ry|] [VIII|8]
-Hen[ry|] [VIII|8]:16:Ed[w[ard|]|] [VI|6]
-Ed[w[ard|]|] [VI|6]:16:Mary
-Mary:16:Eliz[abeth|][ [I|1]|]
-Elizabeth[ [I|1]|]:16-17|16:Ja[me|]s [I|1]
-Ja[me|]s [I|1]:17:Cha[rle|]s [I|1]
-Cha[rle|]s [I|1]:17:[Oliver |]Cromwell
-[Oliver |]Cromwell:17:Rich[ard|] Cromwell
-Rich[ard|] Cromwell:17:Ch[arle|]s [II|2]
-Cha[rle|]s [II|2]:17:Ja[me|]s [II|2]
-Ja[me|]s [II|2]:17:W[illia|]m and Mary
-W[illia|]m and Mary:17-18|17:Anne
-Anne:18:Geo[rge|] [I|1]
-Geo[rge|] [I|1]:18:Geo[rge|] [II|2]
-Geo[rge|] [II|2]:18:Geo[rge|] [III|3]
-Geo[rge|] [III|3]:18-19|18|19:Geo[rge|] [IV|4]
-Geo[rge|] [IV|4]:19:W[illia|]m [IV|4]
-W[illia|]m [IV|4]:19:Victoria
-Victoria:19:Ed[w[ard|]|] [VII|7]
-Ed[w[ard|]|] [VII|7]:19-20|19|20:Geo[rge|] [V|5]
-Geo[rge|] [V|5]:20:Ed[w[ard|]|] [VIII|8]
-Ed[w[ard|]|] [VIII|8]:20:Geo[rge|] [VI|6]
-Geo[rge|] [VI|6]:20:Eliz[abeth|] [II|2]
diff --git a/usr/games/quiz.k/spell b/usr/games/quiz.k/spell
deleted file mode 100644 (file)
index 75ce1e8..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-The son went behind a cloud.:sun
-Did you see the monky at the zoo?:monkey
diff --git a/usr/games/quiz.k/state b/usr/games/quiz.k/state
deleted file mode 100644 (file)
index 247228d..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-Alabama|Ala|AL:Montgomery:AL:camellia
-Alaska|AK:Juneau:AK:forget{-| }me{-| }not
-Arizona|Ariz|AZ:Phoenix:AZ:{saguaro }cactus{ blossom}
-Arkansas|Ark|AR:Little Rock:AR:apple{ blossom}
-Cal{if{ornia}}|CA:Sacramento:CA:{golden }poppy
-Col{o{rado}}|CO:Denver:CO:{Rocky Mountain }columbine
-Conn{ecticut}|CT:Hartford:CT:{mountain }laurel
-Del{aware}|DE:Dover:DE:peach{ blossom}
-Fl{orid}a|FL:Tallahassee:FL:orange{ blossom}
-Georgia|Ga:Atlanta:GA:{Cherokee }rose
-Hawaii|HI:Honolulu:HI:hibiscus
-Idaho|Ida|ID:Boise:ID:syringa
-Ill{inois}|IL:Springfield:IL:violet
-Ind{iana}|IN:Indianapolis:IN:peony
-Iowa|Ia:Des Moines:IA:{wild }rose
-Kans{as}|Kan|KS:Topeka:KS:sun{ }flower
-Kentucky|Ky:Frankfort:KY:goldenrod
-Louisiana|La:Baton Rouge:LA:magnolia
-Maine|Me:Augusta:ME:{white }pine{ }cone{ and}{ tassel}
-Maryland|Md:Annapolis:MD:blackeyed susan
-Mass{achusetts}|MA:Boston:MA:{trailing }arbutus
-Mich{igan}|MI:Lansing:MI:apple{ blossom}
-Minn{esota}|MN:Saint Paul|St Paul:MN:{showy }lady{-|'s | }slipper
-Miss{issippi}|MS:Jackson:MS:magnolia
-Missouri|Mo:Jefferson City:MO:hawthorn
-Mont{ana}|MT:Helena:MT:bitterroot
-Nebraska|Neb|NE|NB:Lincoln:NE|NB:goldenrod
-Nevada|Nev|NV:Carson City:NV:sagebrush
-New Hampshire|NH:Concord:NH:{purple }lilac
-New Jersey|NJ:Trenton:NJ:violet
-New Mexico|NM:Santa Fe:NM:yucca
-New York|NY:Albany:NY:rose
-N{orth} Carolina|NC:Raleigh:NC:{flowering }dogwood
-N{orth} Dakota|ND:Bismarck:ND:{wild }{prairie }rose
-Ohio|OH|O:Columbus:OH:{scarlet }carnation
-Oklahoma|Okla|OK:Oklahoma City:OK:mistletoe
-Oregon|Ore|OR:Salem:OR:{Oregon }grape
-Pennsylvania|Pa:Harrisburg:PA:{mountain }laurel
-Rhode Island|RI:Providence:RI:violet
-S{outh} Carolina|SC:Columbia:SC:{yellow }jasmine
-S{outh} Dakota|SD:Pierre:SD:{American }pasque{{f| f}lower}
-Tenn{essee}|TN:Nashville:TN:iris
-Texas|Tex|TX:Austin:TX:blue{-| }bonnet
-Utah|UT:Salt Lake City:UT:{sego }lily
-Vermont|Vt:Montpelier:VT:{red }clover
-Virginia|Va:Richmond:VA:{flowering }dogwood
-Wash{ington}|WA:Olympia:WA:{western }rhododendron
-W{est} Virginia|W{ }Va|WV:Charleston:WV:rhododendron
-Wisconsin|Wis|WI:Madison:WI:violet
-Wyo{ming}|WY:Cheyenne:WY:Indian paint brush
diff --git a/usr/games/quiz.k/trek b/usr/games/quiz.k/trek
deleted file mode 100644 (file)
index f800fe9..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-captain's name:{James |Jim }{T. }Kirk|{james |jim}{t. }kirk
-first officers name:Spock|spock|Mr. Spock|mr. spock
-name of ship:{the }{u.s.s. }enterprise|Enterprise
-name of the "good guys":{the }Federation|federation|{the }federation
-name of the "bad guys":{the }klingons|{the }romulans
-nickname of chief engineer:scotty|Scotty
-nickname of chief medical officer:bones|Bones
-machine use for transportation to surface of nearby planet:transporter|shuttlecraft
-main engines of ship:warp engines|warp
-number of crew:400|four hundred
-hand-held weapon:phaser
-type of torpedoes used on the ship:photon torpedoes|photon
-name of electronic protective device on ship:shields|shield
-name of device that makes a ship invisible:cloaking device|cloak|cloaking
-type of voice that the on-board computer has:female|feminine|woman's
-where first officer comes from:vulcan|Vulcan
-rare, but very powerful enemies:romulans|Romulans
-reaction that main engines operate on:matter-antimatter{ reaction}|matter/antimatter{ reaction}
-slow engines used in emergencies:impulse engines|impulse
diff --git a/usr/games/quiz.k/ucc b/usr/games/quiz.k/ucc
deleted file mode 100644 (file)
index d852b95..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-1-103:supplementary general principles of law applicable
-1-106:remedies to be liberally administered
-1-201:general definitions
-1-203:obligation of good faith
-1-205:course of dealing and usage of trade
-1-206:statue of frauds for kinds of personal property not otherwise covered
-2-103:definitions-sales
-2-201:statute of frauds
-2-208:course of performance or practical consideration
-2-302:unconscionable contract or clause
-2-310:open time for payment or running of credit
-2-319:FOB and FAS terms
-2-320:CIF and C&F terms
-2-323:form of bill of lading required in overseas shipment
-2-401:passing of title; reservation for security
-2-402:rights of seller's creditors against sold goods
-2-403:powr to transfer; good faith purchase of goods; entrusting
-2-501:insurable interest in goods; manner of identification of goods
-2-502:buyer's right to goods on seller's insolvency
-2-503:manner of seller's tender of delivery
-2-506:rights of financing agency
-2-507:effect of seller's tender; delivery on condition
-2-508:cure by seller of improper tender or delivery; replacement
-2-509:risk of loss in the absence ogf breach
-2-510:effect of breach on risk of loss
-2-513:buyer's right to inspection of goods
-2-601:buyer's rights on improper delivery
-2-602:manner and effect of rightful rejection
-2-603:merchant buyer's duties as to rightfully rejected goods
-2-605:waiver of buyer's objections by failure to particularize
-2-606:what constitutes acceptance of goods
-2-607:effect of acceptance; notice of breach
-2-608:revocation of acceptance in whole or in part
-2-609:right to adequate assurance of performance
-2-610:anticipatory repudiation
-2-611:retraction of anticipatory repudiation
-2-612:installment contract; breach
-2-702:seller's remedies on discovery o buyer's insolvency
-2-703:seller's remedies in general
-2-705:seller's stoppage of delivery in transit or otherwise
-2-706:seller's resale including contract for resale
-2-708:seller's damages for non-acceptance or repudiation
-2-709:action for the price
-2-711:buyer's remedies in general; buyer's security interest in rejected goods
-2-712:cover; buyer's procurement of substitute goods
-2-713:buyer's damages for on-delivery or repudiation
-2-714:buyer's damages for breach in regard to accepted goods
-2-715:buyer's incidental and consequential damages
-2-716:buyer's right to specific performance or replevin
-3-102:definitions-commercial paper
-3-104:form of negotiable instruments; draft; check; certificate of deposit; note
-3-110:payable to order
-3-111:payable to bearer
-3-201:transfer: right to indorsement
-3-202:negotiation
-3-204:special indorsement; blank indorsement
-3-301:rights of a holder
-3-302:holder in due course
-3-305:rights of a holder in due course
-3-306:rights of one not holder in due course
-3-401:signature
-3-404:unauthorized signature
-3-405:impostors; signature in name of payee
-3-406:negligence contributing to alteration or unauthorized signature
-3-407:alteration
-3-410:definition and operation of acceptance
-3-411:certification of a check
-3-413:contract of maker, drawer and acceptor
-3-414:contract of indorser; order of liability
-3-417:warranties on presentment and transfer
-3-418:finality of payment or acceptance
-3-419:conversion of instrument; innocent representative
-3-501:when presentment, notice of dishonor, and protest necessary or permissible
-3-502:unexcused delay; discharge
-3-503:time or presentment
-3-507:dishonor; holder's right of recourse; term allowing representment
-3-508:notice of dishonor
-3-511:waived or excused presentment, protest or notice of dishonor or delay therein
-3-601:discharge of parties
-3-802:effect of instrument on obligation for which it is given
-3-804:lost,destroyed or stolen instruments
-4-104:definitions-bank deposits and collections
-4-105:banks-depositary, intermediary, collecting, payor, presenting, remitting
-4-207:warranties of customer and collecting bank on transfer or presentment of items
-4-208:security interest of collecting bank in items, accompanying documents and proceeds
-4-209:when bank gives value for purposes of holder in due course
-4-211:media of remittance; provision and final settlement in remittance cases
-4-213:final payment of item by payor bank
-4-401:when bank may charge customer's account
-4-406:customer's duty to discover and report unauthorized signature or alteration
-4-402:bank liability to customer for wrongful dishonor
-4-407:payor bank's right to subrogation on improper payment
-5-111:warranties on transfer and presentment (letters of credit)
-5-114:issuer's duty and privilege to honor; right to reimbursement
-5-115:remedy for improper dishonor or anticipatory repudiaion (letters of credit)
-7-104:negotiable and non-negotiable warehouse receipt, bill of lading, other title
-7-204:duty of care; contractual limitation of warehouseperson's liability
-7-301:liability for non-receipt or misdescription
-7-403:obligation of warehouseperson or carrier to deliver; excuse
-7-404:no liability for good faith delivery pursuant to receipt or bill
-7-501:form of negotiation and requirements of due negotiation
-7-502:rights acquired by due negotiation
-7-503:document of title to goods defeated in certain cases
-7-504:rights acquired in absence of due negotiation; effect of diversion
-7-507:warranties on negotiation or transfer of receipt or bill
-7-508:warranties of collecting bank as to documents
-9-105:definitions-secured transactions
-9-107:definitions "purchase money security interest"
-9-109:classification of goods; consumer goods; equipment; farm products; inventory
-9-113:security interests arising under article on sales
-9-203:attachment and enforceability of security interest; proceeds; formal requisites
-9-206:agreement not to asserr defenses against assignee; modification of sales warranties
-9-301:persons who take priority over unperfected security interests
-9-302:when filing is required to perfect security interest
-9-303:when security interest is perfected
-9-304:perfection of security interest in instruments, documents
-9-305:when possession by secured party perfects security interest without filing
-9-306:proceeds; secured party's rights on disposition of collateral
-9-307:protection of buyers of goods
-9-310:periority of certain liens arising by opration of law (mechanic's liens)
-9-311:alienability of debtor's rights; judicial process
-9-312:priorities among conflicting security interests in the same collateral
-9-405:assignment of security interest
-9-501:default; procedure when security agreement  covers real and personal property
-9-503:secured party's right to take possession after default
-9-504:secured party's right to dispose of collateral after default
-9-505:compulsory disposition of collateral; acceptance of collateral as discharge of obligation
diff --git a/usr/games/ttt.k b/usr/games/ttt.k
deleted file mode 100644 (file)
index e63ad08..0000000
+++ /dev/null
@@ -1 +0,0 @@
-áH2.H?ÏHb=\8a<x<r<VH\1dCØ6Æ6b+À6L,q@\7f?\96-êHÅBt+%/\bI\e0?GYE\80@30\ 6I!0Z+\ 4#}B3HÉH;@¨>°+GG+H/Cz@\9fB\9b?4HÇHV@Â<       F÷EÍ;p<ñE$H÷GßG:GÝGTE²D|DdD\89.D@\17C\15C«EA@]?[?\9d<8C·D¬>\81DQGkEö<ÉDAHöHc?jHrBwB>C-B\9cEØ;ãAn6\v?\e6&6fENELEbDi?aE\11F\87?\81?ñG¸>0<W?\99<;.\85B\88A\95AÎG3?èE£EmEM=\88IÜ><0\ 4<[Ev/\190)H>@Õ?@Ië>\8e?à+ã>âEÒHQ?ÐHK?ÎB
\ No newline at end of file
diff --git a/usr/games/words b/usr/games/words
deleted file mode 100755 (executable)
index f16e46c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-egrep '^[-'$1']*$' /usr/dict/words ^ sed -n "`/usr/games/words1 $1`"
index 75e2ba9..538c822 100644 (file)
@@ -1,33 +1,56 @@
+/*
+ * Format of an a.out header
+ */
 struct exec {  /* a.out header */
 struct exec {  /* a.out header */
-       int             a_magic;        /* magic number */
-       unsigned        a_text;         /* size of text segment */
-       unsigned        a_data;         /* size of initialized data */
-       unsigned        a_bss;          /* size of unitialized data */
-       unsigned        a_syms;         /* size of symbol table */
-       unsigned        a_entry;        /* entry point */
-       unsigned        a_unused;       /* not used */
-       unsigned        a_flag;         /* relocation info stripped */
+       int             a_magic;        /* magic number */
+       unsigned        a_text;         /* size of text segment */
+       unsigned        a_data;         /* size of initialized data */
+       unsigned        a_bss;          /* size of uninitialized data */
+       unsigned        a_syms;         /* size of symbol table */
+       unsigned        a_entry;        /* entry point */
+       unsigned        a_trsize;       /* size of text relocation */
+       unsigned        a_drsize;       /* size of data relocation */
 };
 
 };
 
-#define        A_MAGIC1        0407            /* normal */
-#define        A_MAGIC2        0410            /* read-only text */
-#define        A_MAGIC3        0411            /* separated I&D */
-#define        A_MAGIC4        0405            /* overlay */
+#define        A_MAGIC1        0407            /* normal */
+#define        A_MAGIC2        0410            /* read-only text */
+#define        A_MAGIC3        0411            /* separated I&D */
+#define        A_MAGIC4        0405            /* overlay */
 
 
-struct nlist { /* symbol table entry */
-       char            n_name[8];      /* symbol name */
-       int             n_type;         /* type flag */
-       unsigned        n_value;        /* value */
+struct nlist { /* symbol table entry */
+       char    n_name[8];      /* symbol name */
+       char    n_type;         /* type flag */
+       char    n_other;
+       short   n_desc;
+       unsigned n_value;       /* value */
 };
 
 };
 
-               /* values for type flag */
-#define        N_UNDF  0       /* undefined */
-#define        N_ABS   01      /* absolute */
-#define        N_TEXT  02      /* text symbol */
-#define        N_DATA  03      /* data symbol */
-#define        N_BSS   04      /* bss symbol */
+       /* values for type flag */
+#define        N_UNDF  0               /* undefined */
+#define        N_ABS   02              /* absolute */
+#define        N_TEXT  04              /* text */
+#define        N_DATA  06              /* data */
+#define        N_BSS   08
 #define        N_TYPE  037
 #define        N_TYPE  037
-#define        N_REG   024     /* register name */
-#define        N_FN    037     /* file name symbol */
-#define        N_EXT   040     /* external bit, or'ed in */
-#define        FORMAT  "%06o"  /* to print a value */
+#define        N_FN    037             /* file name symbol */
+
+#define        N_GSYM  0040            /* global sym: name,,type,0 */
+#define        N_FUN   0044            /* function: name,,linenumber,address */
+#define        N_STSYM 0046            /* static symbol: name,,type,address */
+#define        N_RSYM  0100            /* register sym: name,,register,offset */
+#define        N_SLINE 0104            /* src line: ,,linenumber,address */
+#define        N_SSYM  0140            /* structure elt: name,,type,struct_offset */
+#define        N_SO    0144            /* source file name: name,,,address */
+#define        N_LSYM  0200            /* local sym: name,,type,offset */
+#define        N_SOL   0204            /* #line source filename: name,,,address */
+#define        N_PSYM  0240            /* parameter: name,,type,offset */
+#define        N_LBRAC 0300            /* left bracket: ,,nesting level,address */
+#define        N_RBRAC 0340            /* right bracket: ,,nesting level,address */
+#define        N_LENG  0376            /* second stab entry with length information */
+
+#define        N_EXT   01              /* external bit, or'ed in */
+
+#define        FORMAT  "%08x"
+
+#define        STABTYPES       0340
index 69155c7..ed3ef1c 100644 (file)
@@ -1,4 +1,4 @@
 /* machine dependent stuff for core files */
 /* machine dependent stuff for core files */
-#define TXTRNDSIZ 8192L
-#define stacktop(siz) (0x10000L)
-#define stackbas(siz) (0x10000L-siz)
+#define TXTRNDSIZ 512L
+#define stacktop(siz) (0x80000000L)
+#define stackbas(siz) (0x80000000L-siz)
index 9e81727..d314c05 100644 (file)
@@ -4,9 +4,9 @@
 #define        _S      010
 #define _P     020
 #define _C     040
 #define        _S      010
 #define _P     020
 #define _C     040
-#define        _X      0100
+#define _X     0100
 
 
-extern char    _ctype_[];      /* in /usr/src/libc/gen/ctype_.h */
+extern char    _ctype_[];
 
 #define        isalpha(c)      ((_ctype_+1)[c]&(_U|_L))
 #define        isupper(c)      ((_ctype_+1)[c]&_U)
 
 #define        isalpha(c)      ((_ctype_+1)[c]&(_U|_L))
 #define        isupper(c)      ((_ctype_+1)[c]&_U)
diff --git a/usr/include/dir.h b/usr/include/dir.h
new file mode 100644 (file)
index 0000000..f714208
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef        DIRSIZ
+#define        DIRSIZ  14
+#endif
+struct dir
+{
+       ino_t   d_ino;
+       char    d_name[DIRSIZ];
+};
index 9cbe4ff..d12c906 100644 (file)
@@ -6,6 +6,10 @@
 #define        R_CNTL  0264
 #define        W_CNTL  0170
 
 #define        R_CNTL  0264
 #define        W_CNTL  0170
 
+/*
+ * dk command channel mode
+ */
+#define        DKCMD   04000
 
 /*
  * library routine declarations
 
 /*
  * library routine declarations
@@ -14,38 +18,3 @@ extern long cmread();
 extern long ocmread();
 
 
 extern long ocmread();
 
 
-/*
- * call setup struct
- */
-
-struct dialout {
-       char    srv;
-       char    area;
-       char    sw;
-       char    mch;
-       char    chan;
-       char    other;
-       short   check;
-};
-
-struct indial {
-       char    i_lchan;
-       char    i_rhost;
-       char    i_rchan;
-       char    i_srv;
-       char    i_area;
-       char    i_sw;
-       char    i_mch;
-       char    i_chan;
-       char    i_other;
-       short   i_check;
-};
-#define        D_SH    1
-#define        D_FS    2
-#define        D_LSTNR 3
-
-
-struct ring {
-       char    r_lchan;
-       char    r_srv;
-};
index 17511bf..6c21e0a 100644 (file)
@@ -1 +1 @@
-char **execargs = (char**)(-2);
+char **execargs = (char**)(0x7ffffffc);
index 05cf4aa..a3c24a8 100644 (file)
@@ -1 +1 @@
-char myname[] = "research 11/70";
+char myname[] = "research VAX-11/780";
index 7c96b33..1bd661c 100644 (file)
@@ -7,4 +7,3 @@ extern double gamma();
 extern double j0(), j1(), jn(), y0(), y1(), yn();
 
 #define HUGE   1.701411733192644270e38
 extern double j0(), j1(), jn(), y0(), y1(), yn();
 
 #define HUGE   1.701411733192644270e38
-#define LOGHUGE 39
index e1703e9..5fa2116 100644 (file)
@@ -11,10 +11,17 @@ MINT
 #define shfree(u) { if(dbg) fprintf(stderr, "free %o\n", u); free((char *)u);}
 extern int dbg;
 #endif
 #define shfree(u) { if(dbg) fprintf(stderr, "free %o\n", u); free((char *)u);}
 extern int dbg;
 #endif
+#ifndef vax
 struct half
 {      short high;
        short low;
 };
 struct half
 {      short high;
        short low;
 };
+#else
+struct half
+{      short low;
+       short high;
+};
+#endif
 extern MINT *itom();
 extern short *xalloc();
 
 extern MINT *itom();
 extern short *xalloc();
 
diff --git a/usr/include/saio.h b/usr/include/saio.h
new file mode 100644 (file)
index 0000000..fc074fc
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * header file for standalone package
+ */
+
+/*
+ * io block: includes an
+ * inode, cells for the use of seek, etc,
+ * and a buffer.
+ */
+struct iob {
+       char    i_flgs;
+       struct inode i_ino;
+       int i_unit;
+       daddr_t i_boff;
+       daddr_t i_cyloff;
+       off_t   i_offset;
+       daddr_t i_bn;
+       char    *i_ma;
+       int     i_cc;
+       char    i_buf[512];
+};
+
+#define F_READ 01
+#define F_WRITE        02
+#define F_ALLOC        04
+#define F_FILE 010
+
+
+
+
+/*
+ * dev switch
+ */
+struct devsw {
+       char    *dv_name;
+       int     (*dv_strategy)();
+       int     (*dv_open)();
+       int     (*dv_close)();
+};
+
+struct devsw devsw[];
+
+/*
+ * request codes. Must be the same a F_XXX above
+ */
+#define        READ    1
+#define        WRITE   2
+
+
+#define        NBUFS   4
+
+
+char   b[NBUFS][512];
+daddr_t        blknos[NBUFS];
+
+
+
+#define NFILES 4
+struct iob iob[NFILES];
+
+/*
+ * Set to which 32Kw segment the code is physically running in.
+ * Must be set by the users main (or there abouts).
+ */
+int    segflag;
index ed7896d..e1cb175 100644 (file)
@@ -1 +1 @@
-typedef int jmp_buf[3];
+typedef int jmp_buf[10];
index be6b89f..fa5c331 100644 (file)
@@ -10,18 +10,6 @@ struct sgttyb {
        int     sg_flags;               /* mode flags */
 };
 
        int     sg_flags;               /* mode flags */
 };
 
-/*
- * List of special characters
- */
-struct tchars {
-       char    t_intrc;        /* interrupt */
-       char    t_quitc;        /* quit */
-       char    t_startc;       /* start output */
-       char    t_stopc;        /* stop output */
-       char    t_eofc;         /* end-of-file */
-       char    t_brkc;         /* input delimiter (like nl) */
-};
-
 /*
  * Modes
  */
 /*
  * Modes
  */
@@ -94,22 +82,9 @@ struct tchars {
 #define        TIOCSETN        (('t'<<8)|10)
 #define        TIOCEXCL        (('t'<<8)|13)
 #define        TIOCNXCL        (('t'<<8)|14)
 #define        TIOCSETN        (('t'<<8)|10)
 #define        TIOCEXCL        (('t'<<8)|13)
 #define        TIOCNXCL        (('t'<<8)|14)
-#define        TIOHMODE        (('t'<<8)|15)
 #define        TIOCTSTP        (('t'<<8)|16)
 #define        TIOCTSTP        (('t'<<8)|16)
-#define        TIOCSETC        (('t'<<8)|17)
-#define        TIOCGETC        (('t'<<8)|18)
-#define        DIOCLSTN        (('d'<<8)|1)
-#define        DIOCNTRL        (('d'<<8)|2)
-#define        DIOCMPX         (('d'<<8)|3)
-#define        DIOCNMPX        (('d'<<8)|4)
-#define        DIOCSCALL       (('d'<<8)|5)
-#define        DIOCRCALL       (('d'<<8)|6)
-#define        DIOCPGRP        (('d'<<8)|7)
 #define        DIOCGETP        (('d'<<8)|8)
 #define        DIOCSETP        (('d'<<8)|9)
 #define        DIOCGETP        (('d'<<8)|8)
 #define        DIOCSETP        (('d'<<8)|9)
-#define        DIOCLOSE        (('d'<<8)|10)
-#define        DIOCTIME        (('d'<<8)|11)
-#define        DIOCRESET       (('d'<<8)|12)
 #define        FIOCLEX         (('f'<<8)|1)
 #define        FIONCLEX        (('f'<<8)|2)
 #define        MXLSTN          (('x'<<8)|1)
 #define        FIOCLEX         (('f'<<8)|1)
 #define        FIONCLEX        (('f'<<8)|2)
 #define        MXLSTN          (('x'<<8)|1)
index 86b47d5..06f82a9 100644 (file)
@@ -1,4 +1,4 @@
-#define NSIG 17
+#define NSIG   17
 
 #define        SIGHUP  1       /* hangup */
 #define        SIGINT  2       /* interrupt */
 
 #define        SIGHUP  1       /* hangup */
 #define        SIGINT  2       /* interrupt */
diff --git a/usr/include/stat.h b/usr/include/stat.h
new file mode 100644 (file)
index 0000000..1468bde
--- /dev/null
@@ -0,0 +1,28 @@
+struct stat
+{
+       dev_t   st_dev;
+       ino_t   st_ino;
+       unsigned short  st_mode;
+       short   st_nlink;
+       short   st_uid;
+       short   st_gid;
+       dev_t   st_rdev;
+       off_t   st_size;
+       time_t  st_atime;
+       time_t  st_mtime;
+       time_t  st_ctime;
+};
+
+#define        S_IFMT  0170000         /* type of file */
+#define                S_IFDIR 0040000 /* directory */
+#define                S_IFCHR 0020000 /* character special */
+#define                S_IFBLK 0060000 /* block special */
+#define                S_IFREG 0100000 /* regular */
+#define                S_IFMPC 0030000 /* multiplexed char special */
+#define                S_IFMPB 0070000 /* multiplexed block special */
+#define        S_ISUID 0004000         /* set user id on execution */
+#define        S_ISGID 0002000         /* set group id on execution */
+#define        S_ISVTX 0001000         /* save swapped text even after use */
+#define        S_IREAD 0000400         /* read permission, owner */
+#define        S_IWRITE        0000200         /* write permission, owner */
+#define        S_IEXEC 0000100         /* execute/search permission, owner */
index 1764add..c62e694 100644 (file)
@@ -2,8 +2,8 @@
 #define        _NFILE  20
 # ifndef FILE
 extern struct  _iobuf {
 #define        _NFILE  20
 # ifndef FILE
 extern struct  _iobuf {
-       char    *_ptr;
        int     _cnt;
        int     _cnt;
+       char    *_ptr;
        char    *_base;
        char    _flag;
        char    _file;
        char    *_base;
        char    _flag;
        char    _file;
@@ -17,8 +17,6 @@ extern        struct  _iobuf {
 #define        _IOEOF  020
 #define        _IOERR  040
 #define        _IOSTRG 0100
 #define        _IOEOF  020
 #define        _IOERR  040
 #define        _IOSTRG 0100
-#define        _IORW   0200
-
 #define        NULL    0
 #define        FILE    struct _iobuf
 #define        EOF     (-1)
 #define        NULL    0
 #define        FILE    struct _iobuf
 #define        EOF     (-1)
@@ -35,7 +33,7 @@ extern        struct  _iobuf {
 #define        fileno(p)       p->_file
 
 FILE   *fopen();
 #define        fileno(p)       p->_file
 
 FILE   *fopen();
-FILE   *freopen();
 FILE   *fdopen();
 FILE   *fdopen();
+FILE   *freopen();
 long   ftell();
 char   *fgets();
 long   ftell();
 char   *fgets();
index 0986e3c..0502914 100644 (file)
@@ -1,57 +1,59 @@
-indir  = 0.
-exit   = 1.
-fork   = 2.
-read   = 3.
-write  = 4.
-open   = 5.
-close  = 6.
-wait   = 7.
-creat  = 8.
-link   = 9.
-unlink = 10.
-exec   = 11.
-chdir  = 12.
-time   = 13.
-mknod  = 14.
-chmod  = 15.
-chown  = 16.
-break  = 17.
-stat   = 18.
-lseek  = 19.
-getpid = 20.
-mount  = 21.
-umount = 22.
-setuid = 23.
-getuid = 24.
-stime  = 25.
-ptrace = 26.
-alarm  = 27.
-fstat  = 28.
-pause  = 29.
-utime  = 30.
-smdate = 30.
-stty   = 31.
-gtty   = 32.
-access = 33.
-nice   = 34.
-sleep  = 35.
-sync   = 36.
-kill   = 37.
-csw    = 38.
-setpgrp        = 39.
-dup    = 41.
-pipe   = 42.
-times  = 43.
-profil = 44.
-setgid = 46.
-getgid = 47.
-signal = 48.
-acct   = 51.
-phys   = 52.
-lock   = 53.
-ioctl  = 54.
-reboot = 55.
-mpx    = 56.
-setinf = 59.
-umask  = 60.
-getinf = 60.
+       .set    exit,1
+       .set    fork,2
+       .set    read,3
+       .set    write,4
+       .set    open,5
+       .set    close,6
+       .set    wait,7
+       .set    creat,8
+       .set    link,9
+       .set    unlink,10
+       .set    exec,11
+       .set    chdir,12
+       .set    time,13
+       .set    mknod,14
+       .set    chmod,15
+       .set    chown,16
+       .set    break,17
+       .set    stat,18
+       .set    lseek,19
+       .set    getpid,20
+       .set    mount,21
+       .set    umount,22
+       .set    setuid,23
+       .set    getuid,24
+       .set    stime,25
+       .set    ptrace,26
+       .set    alarm,27
+       .set    fstat,28
+       .set    pause,29
+       .set    utime,30
+       .set    smdate,30
+       .set    stty,31
+       .set    gtty,32
+       .set    access,33
+       .set    nice,34
+       .set    sleep,35
+       .set    sync,36
+       .set    kill,37
+       .set    switch,38
+       .set    setpgrp,39
+       .set    dup,41
+       .set    pipe,42
+       .set    times,43
+       .set    prof,44
+       .set    setgid,46
+       .set    getgid,47
+       .set    signal,48
+#      USG 49
+#      USG 50
+       .set    acct,51
+       .set    setphys,52
+       .set    syslock,53
+       .set    ioctl,54
+       .set    reboot,55
+       .set    mpx,56
+#      USG 57
+#      USG 58
+       .set    setinf,59
+       .set    umask,60
diff --git a/usr/include/sys/acct.h b/usr/include/sys/acct.h
new file mode 100644 (file)
index 0000000..9d99861
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Accounting structures
+ */
+
+typedef        unsigned short comp_t;  /* "floating pt": 3 bits base 8 exp, 13 bits fraction */
+struct acct
+{
+       char    ac_comm[10];            /* Accounting command name */
+       comp_t  ac_utime;               /* Accounting user time */
+       comp_t  ac_stime;               /* Accounting system time */
+       comp_t  ac_etime;               /* Accounting elapsed time */
+       time_t  ac_btime;               /* Beginning time */
+       short   ac_uid;                 /* Accounting user ID */
+       short   ac_gid;                 /* Accounting group ID */
+       short   ac_mem;                 /* average memory usage */
+       comp_t  ac_io;                  /* number of disk IO blocks */
+       dev_t   ac_tty;                 /* control typewriter */
+       char    ac_flag;                /* Accounting flag */
+};
+
+
+#define        AFORK   01              /* has executed fork, but no exec */
+#define        ASU     02              /* used super-user privileges */
diff --git a/usr/include/sys/callo.h b/usr/include/sys/callo.h
new file mode 100644 (file)
index 0000000..f66e5bb
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * The callout structure is for
+ * a routine arranging
+ * to be called by the clock interrupt
+ * (clock.c) with a specified argument,
+ * in a specified amount of time.
+ * Used, for example, to time tab
+ * delays on typewriters.
+ */
+
+struct callo
+{
+       int     c_time;         /* incremental time */
+       caddr_t c_arg;          /* argument to routine */
+       int     (*c_func)();    /* routine */
+};
+struct callo   callout[NCALL];
diff --git a/usr/include/sys/chan.h b/usr/include/sys/chan.h
new file mode 100644 (file)
index 0000000..93212ca
--- /dev/null
@@ -0,0 +1,112 @@
+#define NGROUPS                10
+#define        NCHANS          20
+
+#define        DCHAN           1
+#define        CCHAN           0
+
+struct chan {
+       short   c_flags;
+       char    c_index;
+       char    c_msg;
+       struct  group *c_group;
+       struct  tty     *c_ttyp;
+       struct  file    *c_fy;
+       int     c_pgrp;
+       union {
+               struct  clist   datq;
+       } cx;
+       union {
+               struct  clist   datq;
+               struct  chan    *c_chan;
+       } cy;
+       struct  clist   c_ctlx;
+       struct  clist   c_ctly;
+};
+
+
+struct group {
+       short   g_state;
+       char    g_mindex;
+       short   g_index;
+       short   g_count;
+       struct  inode   *g_inode;
+       struct  group   *g_master;
+       struct  clist   g_cntl;
+       struct  clist   g_datq;
+};
+
+/*
+ * flags
+ */
+#define        INUSE   01
+#define COPEN  02
+#define        XGRP    04
+#define        YGRP    010
+#define        WCLOSE  020
+#define        TTYO    040
+#define        SUBGRP  0100
+#define        BLOCK   0200
+#define        BLOCK1  0400
+#define        SIGBLK  01000
+#define        BLKMSG  01000
+#define        ENAMSG  02000
+#define        WFLUSH  04000
+#define        RZERO   010000
+
+
+/*
+ * mpxchan command codes
+ */
+#define        GROUP   5
+#define        GROUPN  6
+#define        CHAN    1
+#define JOIN   2
+#define EXTR   3
+#define        ATTACH  4
+#define        CONNECT 7
+#define        DETACH  8
+#define        DISCON  9
+#define DEBUG  10
+#define        NPGRP   11
+#define        CSIG    12
+#define PACK   13
+
+#define NDEBUGS        30
+/*
+ * control channel message codes
+ */
+#define        WATTCH  1
+#define M_WATCH 1
+#define        SCLOSE  2
+#define M_CLOSE 2
+#define        M_ATTACH 3
+#define        M_BLK   4
+#define        M_UBLK  5
+#define        DO_BLK  6
+#define        DO_UBLK 7
+#define        M_XINT  8
+#define        M_RINT  9
+#define        M_ACK   10
+#define        M_NAK\e  11
+
+
+/*
+ * debug codes other than mpxchan cmds
+ */
+#define MCCLOSE 29
+#define MCOPEN 28
+#define        ALL     27
+#define SCON   26
+#define        MSREAD  25
+#define        SDATA   24
+#define        MCREAD  23
+#define MCWRITE        22
+
+/* HDRSIZE == NLEVELS + sizeof (short) */
+#define        HDRSIZE         4
+#define NLEVELS                2
+union u_index {
+       short val;
+       char    bytes[NLEVELS];
+};
+typedef union u_index index_t;
index 8957651..25a0ed9 100644 (file)
@@ -23,9 +23,8 @@ extern struct cdevsw
        int     (*d_open)();
        int     (*d_close)();
        int     (*d_read)();
        int     (*d_open)();
        int     (*d_close)();
        int     (*d_read)();
-       char    *(*d_write)();
+       int     (*d_write)();
        int     (*d_ioctl)();
        int     (*d_ioctl)();
-       int     (*d_stop)();
        struct tty *d_ttys;
 } cdevsw[];
 
        struct tty *d_ttys;
 } cdevsw[];
 
@@ -40,8 +39,5 @@ extern struct linesw
        int     (*l_write)();
        int     (*l_ioctl)();
        int     (*l_rint)();
        int     (*l_write)();
        int     (*l_ioctl)();
        int     (*l_rint)();
-       int     (*l_rend)();
-       int     (*l_meta)();
        int     (*l_start)();
        int     (*l_start)();
-       int     (*l_modem)();
 } linesw[];
 } linesw[];
diff --git a/usr/include/sys/dir.h b/usr/include/sys/dir.h
new file mode 100644 (file)
index 0000000..737a3a6
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef        DIRSIZ
+#define        DIRSIZ  14
+#endif
+struct direct
+{
+       ino_t   d_ino;
+       char    d_name[DIRSIZ];
+};
diff --git a/usr/include/sys/fblk.h b/usr/include/sys/fblk.h
new file mode 100644 (file)
index 0000000..9a1ba29
--- /dev/null
@@ -0,0 +1,5 @@
+struct fblk
+{
+       int     df_nfree;
+       daddr_t df_free[NICFREE];
+};
diff --git a/usr/include/sys/file.h b/usr/include/sys/file.h
new file mode 100644 (file)
index 0000000..99b3124
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * One file structure is allocated
+ * for each open/creat/pipe call.
+ * Main use is to hold the read/write
+ * pointer associated with each open
+ * file.
+ */
+struct file
+{
+       char    f_flag;
+       char    f_count;        /* reference count */
+       struct inode *f_inode;  /* pointer to inode structure */
+       union {
+               off_t   f_offset;       /* read/write character pointer */
+               struct chan *f_chan;    /* mpx channel pointer */
+       } f_un;
+};
+
+extern struct file file[];     /* The file table itself */
+
+/* flags */
+#define        FREAD   01
+#define        FWRITE  02
+#define        FPIPE   04
+#define FMPX   010
+#define        FMPY    020
+#define        FMP     030
diff --git a/usr/include/sys/filsys.h b/usr/include/sys/filsys.h
new file mode 100644 (file)
index 0000000..19ebcee
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Structure of the super-block
+ */
+struct filsys {
+       unsigned short s_isize; /* size in blocks of i-list */
+       daddr_t s_fsize;        /* size in blocks of entire volume */
+       short   s_nfree;        /* number of addresses in s_free */
+       daddr_t s_free[NICFREE];/* free block list */
+       short   s_ninode;       /* number of i-nodes in s_inode */
+       ino_t   s_inode[NICINOD];/* free i-node list */
+       char    s_flock;        /* lock during free list manipulation */
+       char    s_ilock;        /* lock during i-list manipulation */
+       char    s_fmod;         /* super block modified flag */
+       char    s_ronly;        /* mounted read-only flag */
+       time_t  s_time;         /* last super block update */
+       /* remainder not maintained by this version of the system */
+       daddr_t s_tfree;        /* total free blocks*/
+       ino_t   s_tinode;       /* total free inodes */
+       short   s_m;            /* interleave factor */
+       short   s_n;            /* " " */
+       char    s_fname[6];     /* file system name */
+       char    s_fpack[6];     /* file system pack name */
+};
diff --git a/usr/include/sys/ino.h b/usr/include/sys/ino.h
new file mode 100644 (file)
index 0000000..084fd98
--- /dev/null
@@ -0,0 +1,19 @@
+       /* Inode structure as it appears on a disk block. */
+struct dinode
+{
+       unsigned short di_mode; /* mode and type of file */
+       short   di_nlink;       /* number of links to file */
+       short   di_uid;         /* owner's user id */
+       short   di_gid;         /* owner's group id */
+       off_t   di_size;        /* number of bytes in file */
+       char    di_addr[40];    /* disk block addresses */
+       time_t  di_atime;       /* time last accessed */
+       time_t  di_mtime;       /* time last modified */
+       time_t  di_ctime;       /* time created */
+};
+#define        INOPB   8               /* 8 inodes per block */
+/*
+ * the 40 address bytes:
+ *     39 used; 13 addresses
+ *     of 3 bytes each.
+ */
diff --git a/usr/include/sys/inode.h b/usr/include/sys/inode.h
new file mode 100644 (file)
index 0000000..de774e4
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * The I node is the focus of all
+ * file activity in unix. There is a unique
+ * inode allocated for each active file,
+ * each current directory, each mounted-on
+ * file, text file, and the root. An inode is 'named'
+ * by its dev/inumber pair. (iget/iget.c)
+ * Data, from mode on, is read in
+ * from permanent inode on volume.
+ */
+
+#define        NADDR   13
+
+#define        NINDEX          15
+struct group {
+       short   g_state;
+       char    g_index;
+       char    g_rot;
+       struct  group   *g_group;
+       struct  inode   *g_inode;
+       struct  file    *g_file;
+       short   g_rotmask;
+       short   g_datq;
+       struct  chan *g_chans[NINDEX];
+};
+struct inode
+{
+       char    i_flag;
+       char    i_count;        /* reference count */
+       dev_t   i_dev;          /* device where inode resides */
+       ino_t   i_number;       /* i number, 1-to-1 with device address */
+       unsigned short  i_mode;
+       short   i_nlink;        /* directory entries */
+       short   i_uid;          /* owner */
+       short   i_gid;          /* group of owner */
+       off_t   i_size;         /* size of file */
+       union {
+               struct {
+                       daddr_t i_addr[NADDR];  /* if normal file/directory */
+                       daddr_t i_lastr;        /* last logical block read (for read-ahead) */
+               };
+               struct  {
+                       daddr_t i_rdev;                 /* i_addr[0] */
+                       struct  group   i_group;        /*  multiplexor group file */
+               };
+       } i_un;
+};
+
+
+extern struct inode inode[];   /* The inode table itself */
+
+/* flags */
+#define        ILOCK   01              /* inode is locked */
+#define        IUPD    02              /* file has been modified */
+#define        IACC    04              /* inode access time to be updated */
+#define        IMOUNT  010             /* inode is mounted on */
+#define        IWANT   020             /* some process waiting on lock */
+#define        ITEXT   040             /* inode is pure text prototype */
+#define        ICHG    0100            /* inode has been changed */
+
+/* modes */
+#define        IFMT    0170000         /* type of file */
+#define                IFDIR   0040000 /* directory */
+#define                IFCHR   0020000 /* character special */
+#define                IFBLK   0060000 /* block special */
+#define                IFREG   0100000 /* regular */
+#define                IFMPC   0030000 /* multiplexed char special */
+#define                IFMPB   0070000 /* multiplexed block special */
+#define        ISUID   04000           /* set user id on execution */
+#define        ISGID   02000           /* set group id on execution */
+#define ISVTX  01000           /* save swapped text even after use */
+#define        IREAD   0400            /* read, write, execute permissions */
+#define        IWRITE  0200
+#define        IEXEC   0100
diff --git a/usr/include/sys/mount.h b/usr/include/sys/mount.h
new file mode 100644 (file)
index 0000000..dfdbc90
--- /dev/null
@@ -0,0 +1,11 @@
+/*
+ * Mount structure.
+ * One allocated on every mount.
+ * Used to find the super block.
+ */
+struct mount
+{
+       dev_t   m_dev;          /* device mounted */
+       struct buf *m_bufp;     /* pointer to superblock */
+       struct inode *m_inodp;  /* pointer to mounted on inode */
+} mount[NMOUNT];
diff --git a/usr/include/sys/pack.h b/usr/include/sys/pack.h
new file mode 100644 (file)
index 0000000..0635333
--- /dev/null
@@ -0,0 +1,115 @@
+struct pack {
+       short   p_state;        /* line state */
+       short   p_bits;         /* mask for getepack */
+       short   p_psize;        /* packet size */
+       short   p_icount;       /* input byte count */
+       char    p_ostate;       /* output state */
+       char    p_istate;       /* input state */
+       char    p_msgs;         /* # cntl msgs sent */
+       char    p_window;       /* window size */
+       char    p_iseq;         /* input SEQ byte */
+       char    p_oseq;         /* output SEQ byte */
+       char    p_msg;          /* control msg */
+       char    p_msg2;         /* extra msg bits */
+       char    p_ps,p_pr;      /* last packet sent, recv'd */
+       char    p_rps,p_rpr;    /* remote (received) ps and pr */
+       char    p_nxtps;        /* next output seq number */
+       char    p_nxtpr;        /* expected input seq number */
+       char    p_prcopy;       /* oldest received packet in kernel */
+       char    p_pscopy;       /* newest output packet */
+       char    *p_input;       /* points into input buffer */
+       char    p_iobuf[6];     /* cntl packet buffer */
+       char    *p_ob[8];       /* output buffers */
+       char    *p_ib[8];       /* input buffers */
+       char    p_bstate[8];    /* output buffer status */
+       char    p_cstate[8];    /* input buffer status */
+       short   p_checks[8];
+       short   p_rcheck;
+       struct tty *p_ttyp;
+       int     p_timer;
+       int     xcount,rcount;
+};
+#define        NPSTRUCT        (1+(sizeof(struct pack))/64)
+#define        NPERBUF         (8/NPSTRUCT)
+#define        CHECK   0125252
+
+int    npbits;
+
+/*
+ * driver state
+ */
+#define        DEAD    0
+#define        INITa   1
+#define        INITb   2
+#define        ISINIT  3
+#define        LIVE    4
+#define        RESYNC  010
+#define        DOWN    020
+#define        RREJ    040
+#define        RXMIT   0100
+#define PDEBUG 0200
+#define        DRAINO  0400
+#define        WAITO   01000
+
+/*
+ * input side states
+ */
+#define        P_IDLE  1
+#define        P_SCAN  2
+#define        P_SEQ1  3
+#define        P_PACK  4
+#define        P_CHK1  5
+#define        P_CHK2  6
+#define        P_SEQ2  7
+#define        P_FLUSH 8
+
+#define        SYN     026
+
+/*
+ * output side states
+ */
+#define        T_IDLE  0
+#define        T_READY 1
+#define        T_HDR   2
+#define        T_PACK  3
+#define        T_TAIL  4
+
+/*
+ * io buffer states
+ */
+#define        B_FREE  0
+#define        B_READY 1
+#define        B_SENT  2
+#define        B_PACK  4
+#define        B_COPY  010
+#define        B_XMIT  020
+
+/*
+ * frame control messages
+ */
+#define        RR      1
+#define        RWR     2
+#define        REJ     3
+#define        CLOSE   4
+#define        RESET   6
+#define        INIT    7
+#define        UA      8
+
+
+
+
+#define        PKOPRI  31
+#define        PKIPRI  30
+
+#define        NPLINES 8
+
+/*
+ * packet ioctl buf
+ */
+struct piocb {
+       unsigned t;
+       short   psize;
+       short   mode;
+       short   state;
+       char    window;
+};
diff --git a/usr/include/sys/pcb.h b/usr/include/sys/pcb.h
new file mode 100755 (executable)
index 0000000..a28f6a6
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+   VAX process control block
+ */
+
+struct pcb {
+       int
+       pcb_ksp,        /* kernal stack pointer */
+       pcb_esp,        /* exec stack pointer */
+       pcb_ssp,        /* supervisor stack pointer */
+       pcb_usp,        /* user stack pointer */
+       pcb_r0, 
+       pcb_r1, 
+       pcb_r2, 
+       pcb_r3, 
+       pcb_r4, 
+       pcb_r5, 
+       pcb_r6, 
+       pcb_r7, 
+       pcb_r8, 
+       pcb_r9, 
+       pcb_r10, 
+       pcb_r11, 
+       pcb_r12, 
+       pcb_r13, 
+       pcb_pc,         /* program counter */
+       pcb_psl,        /* program status longword */
+       pcb_p0br,       /* seg 0 base register */
+       pcb_p0lr,       /* seg 0 length register and astlevel */
+       pcb_p1br,       /* seg 1 base register */
+       pcb_p1lr,       /* seg 1 length register and pme */
+
+/*
+   Software pcb (extension)
+ */
+
+       pcb_szpt;       /* number of pages of user page table */
+
+};
diff --git a/usr/include/sys/pk.p b/usr/include/sys/pk.p
new file mode 100644 (file)
index 0000000..4e3076d
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * kernel level
+ */
+#ifdef KERNEL
+
+#define PADDR          ((struct pack *)tp->t_linep)
+#define TURNOFF                pkturnoff(tp)
+#define UCOUNT         u.u_count
+#define S              tp
+#define P              pk->p_ttyp
+#define SDEF           struct tty *tp
+#define FS             , tp
+
+#define SIGNAL         signal(pk->p_ttyp->t_pgrp, SIGPIPE)
+#define TERROR         pk->p_istate == R_ERROR
+#define SETERROR       u.u_error = EIO
+#define OBUSY          tp->t_state&BUSY
+#define GETEPACK       getepack(pk->p_bits)
+char * getepack();
+#define FREEPACK(a,b)  freepack(a, b)
+
+
+#define q1     tp->t_rawq
+#define q2     tp->t_canq
+#define q3     tp->t_outq
+
+#define LOCK           s = spl6()
+#define UNLOCK         splx(s)
+#define DSYSTEM                struct tty *p_ttyp
+#define ISYSTEM                tp = pk->p_ttyp
+#define        SLEEP(a, b)     sleep((caddr_t)a, b)
+#define        SLEEPNO         (tp->t_chan!=NULL)
+#define WAKEUP(a)      wakeup((caddr_t)a)
+#define IOMOVE(p, c, f) iomove(p, c, f)
+#define PKGETPKT(p)
+#define DTOM(a)                dtom(a)
+#include "../h/param.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/pk.h"
+#include "../h/tty.h"
+#include "../h/buf.h"
+#include "../h/proc.h"
+
+#endif
+/*
+ * user level
+ */
+#ifdef USER
+#define SLEEP(a, b) 
+#define SIGNAL
+#define WAKEUP(a)
+#define DSYSTEM                int p_ifn, p_ofn
+#define ISYSTEM
+#define GETEPACK       malloc(pk->p_xsize)
+#define FREEPACK(a, b) free(a)
+#define OBUSY          0
+#define PKGETPKT(p)    pkgetpack(p);
+#define DTOM(a)                1;
+#define S              ipk, ibuf, icount
+#define SDEF           int icount; char *ibuf; struct pack *ipk
+#define UCOUNT         icount
+#define IOMOVE(p, c, f)        pkmove(p, ibuf, c, f) ; ibuf += c; UCOUNT -= c
+#define PADDR          ipk
+#define TURNOFF
+#define LOCK
+#define UNLOCK
+#define SETERROR
+#define GENERROR(p, s)
+#define        PACKSIZE        64
+#define        WINDOWS         3
+#define        PKDEBUG(l, f, s) { extern Debug; if (Debug >= l) fprintf(stderr, f, s);}
+#define        PKASSERT(e, f, v) if (!(e)) {\
+fprintf(stderr, "AERROR - (%s) ", "e");\
+fprintf(stderr, f, v);\
+pkfail();};
+#endif
diff --git a/usr/include/sys/prim.h b/usr/include/sys/prim.h
new file mode 100644 (file)
index 0000000..a710c9f
--- /dev/null
@@ -0,0 +1,9 @@
+#define        NOSLEEP 0400
+#define        FORCE   01000
+#define        NORM    02000
+#define        KEEP    04000
+#define        CLR     010000
+
+int    bwaiting,wcount;
+
+char *getepack();
diff --git a/usr/include/sys/psl.h b/usr/include/sys/psl.h
new file mode 100755 (executable)
index 0000000..3f0e26b
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+       VAX program status longword
+ */
+
+#define PSL_C 0x1              /* carry bit */
+#define PSL_V 0x2              /* overflow bit */
+#define PSL_Z 0x4              /* zero bit */
+#define PSL_N 0x8              /* negative bit */
+#define PSL_T 0x10             /* trace enable bit */
+#define PSL_IV 0x20            /* integer overflow enable bit */
+#define PSL_FU 0x40            /* floating point underflow enable bit */
+#define PSL_DV 0x80            /* decimal overflow enable bit */
+#define PSL_IPL 0x1f0000       /* interrupt priority level */
+#define PSL_PRVMOD 0xc00000    /* previous mode */
+#define PSL_CURMOD 0x3000000   /* current mode */
+#define PSL_IS 0x4000000       /* interrupt stack */
+#define PSL_FPD 0x8000000      /* first part done */
+#define PSL_TP 0x40000000      /* trace pending */
+#define PSL_CM 0x80000000      /* compatibility mode */
+
diff --git a/usr/include/sys/reg.h b/usr/include/sys/reg.h
new file mode 100644 (file)
index 0000000..f967548
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Location of the users' stored
+ * registers relative to R0.
+ * Usage is u.u_ar0[XX].
+ */
+#define        R0      0
+#define        R1      1
+#define        R2      2
+#define        R3      3
+#define        R4      4
+#define        R5      5
+#define        R6      6
+#define        R7      7
+#define        R8      8
+#define        R9      9
+#define        R10     10
+#define        R11     11
+#define        R12     12
+#define        R13     13
+
+#define AP     12
+#define        FP      13
+#define        SP      14
+#define        PS      18
+#define        PC      17
diff --git a/usr/include/sys/seg.h b/usr/include/sys/seg.h
new file mode 100644 (file)
index 0000000..ab0437d
--- /dev/null
@@ -0,0 +1,6 @@
+/*
+ * Mapper addresses and bits
+ */
+
+#define        RO      PG_URKR         /* access abilities */
+#define        RW      PG_UW
diff --git a/usr/include/sys/stat.h b/usr/include/sys/stat.h
new file mode 100644 (file)
index 0000000..1468bde
--- /dev/null
@@ -0,0 +1,28 @@
+struct stat
+{
+       dev_t   st_dev;
+       ino_t   st_ino;
+       unsigned short  st_mode;
+       short   st_nlink;
+       short   st_uid;
+       short   st_gid;
+       dev_t   st_rdev;
+       off_t   st_size;
+       time_t  st_atime;
+       time_t  st_mtime;
+       time_t  st_ctime;
+};
+
+#define        S_IFMT  0170000         /* type of file */
+#define                S_IFDIR 0040000 /* directory */
+#define                S_IFCHR 0020000 /* character special */
+#define                S_IFBLK 0060000 /* block special */
+#define                S_IFREG 0100000 /* regular */
+#define                S_IFMPC 0030000 /* multiplexed char special */
+#define                S_IFMPB 0070000 /* multiplexed block special */
+#define        S_ISUID 0004000         /* set user id on execution */
+#define        S_ISGID 0002000         /* set group id on execution */
+#define        S_ISVTX 0001000         /* save swapped text even after use */
+#define        S_IREAD 0000400         /* read permission, owner */
+#define        S_IWRITE        0000200         /* write permission, owner */
+#define        S_IEXEC 0000100         /* execute/search permission, owner */
diff --git a/usr/include/sys/timeb.h b/usr/include/sys/timeb.h
new file mode 100644 (file)
index 0000000..23c850c
--- /dev/null
@@ -0,0 +1,9 @@
+/*
+ * Structure returned by ftime system call
+ */
+struct timeb {
+       time_t  time;
+       unsigned short millitm;
+       short   timezone;
+       short   dstflag;
+};
diff --git a/usr/include/sys/types.h b/usr/include/sys/types.h
new file mode 100644 (file)
index 0000000..4e59725
--- /dev/null
@@ -0,0 +1,16 @@
+typedef        struct { int r[1]; } *  physadr;
+typedef        long            daddr_t;
+typedef char *         caddr_t;
+typedef        unsigned short  ino_t;
+typedef        long            time_t;
+typedef        int             label_t[10];
+typedef        short           dev_t;
+typedef        long            off_t;
+/* major part of a device */
+#define        major(x)        (int)(((unsigned)x>>8)&0377)
+
+/* minor part of a device */
+#define        minor(x)        (int)(x&0377)
+
+/* make a device number */
+#define        makedev(x,y)    (dev_t)(((x)<<8) | (y))
diff --git a/usr/include/sys/user.h b/usr/include/sys/user.h
new file mode 100644 (file)
index 0000000..57edc6b
--- /dev/null
@@ -0,0 +1,129 @@
+#include <sys/pcb.h>
+/*
+ * The user structure.
+ * One allocated per process.
+ * Contains all per process data
+ * that doesn't need to be referenced
+ * while the process is swapped.
+ * The user block is USIZE*512 bytes
+ * long; resides at virtual kernel
+ * loc 80020000; contains the system
+ * stack per user; is cross referenced
+ * with the proc structure for the
+ * same process.
+ */
+#define        EXCLOSE 01
+struct user
+{
+       struct pcb u_pcb;               /* pcb, save area when exchanging stacks */
+       int u_ptable[(MAXUMEM+127)/128];        /* click nums of user page table */
+       label_t u_rsav;
+       char    u_segflg;               /* IO flag: 0:user D; 1:system; 2:user I */
+       char    u_error;                /* return error code */
+       short   u_uid;                  /* effective user id */
+       short   u_gid;                  /* effective group id */
+       short   u_ruid;                 /* real user id */
+       short   u_rgid;                 /* real group id */
+       struct proc *u_procp;           /* pointer to proc structure */
+       int     *u_ap;                  /* pointer to arglist */
+       union {                         /* syscall return values */
+               struct  {
+                       int     r_val1;
+                       int     r_val2;
+               };
+               off_t   r_off;
+               time_t  r_time;
+       } u_r;
+       caddr_t u_base;                 /* base address for IO */
+       unsigned int u_count;           /* bytes remaining for IO */
+       off_t   u_offset;               /* offset in file for IO */
+       struct inode *u_cdir;           /* pointer to inode of current directory */
+       struct inode *u_rdir;           /* root directory of current process */
+       char    u_dbuf[DIRSIZ];         /* current pathname component */
+       caddr_t u_dirp;                 /* pathname pointer */
+       struct direct u_dent;           /* current directory entry */
+       struct inode *u_pdir;           /* inode of parent directory of dirp */
+       struct file *u_ofile[NOFILE];   /* pointers to file structures of open files */
+       char    u_pofile[NOFILE];       /* per-process flags of open files */
+       int     u_arg[5];               /* arguments to current system call */
+       unsigned u_tsize;               /* text size (clicks) */
+       unsigned u_dsize;               /* data size (clicks) */
+       unsigned u_ssize;               /* stack size (clicks) */
+       label_t u_qsav;                 /* label variable for quits and interrupts */
+       label_t u_ssav;                 /* label variable for swapping */
+       int     u_signal[NSIG];         /* disposition of signals */
+       time_t  u_utime;                /* this process user time */
+       time_t  u_stime;                /* this process system time */
+       time_t  u_cutime;               /* sum of childs' utimes */
+       time_t  u_cstime;               /* sum of childs' stimes */
+       int     *u_ar0;                 /* address of users saved R0 */
+       struct {                        /* profile arguments */
+               short   *pr_base;       /* buffer base */
+               unsigned pr_size;       /* buffer size */
+               unsigned pr_off;        /* pc offset */
+               unsigned pr_scale;      /* pc scaling */
+       } u_prof;
+       char    u_intflg;               /* catch intr from sys */
+       char    u_sep;                  /* flag for I and D separation */
+       struct tty *u_ttyp;             /* controlling tty pointer */
+       dev_t   u_ttyd;                 /* controlling tty dev */
+       struct {                        /* header of executable file */
+               int     ux_mag;         /* magic number */
+               unsigned ux_tsize;      /* text size */
+               unsigned ux_dsize;      /* data size */
+               unsigned ux_bsize;      /* bss size */
+               unsigned ux_ssize;      /* symbol table size */
+               unsigned ux_entloc;     /* entry location */
+               unsigned ux_unused;
+               unsigned ux_relflg;
+       } u_exdata;
+       char    u_comm[DIRSIZ];
+       time_t  u_start;
+       char    u_acflag;
+       short   u_fpflag;               /* unused now, will be later */
+       short   u_cmask;                /* mask for file creation */
+       int     u_stack[1];
+                                       /* kernel stack per user
+                                        * extends from u + USIZE*64
+                                        * backward not to reah here
+                                        */
+};
+
+/* u_error codes */
+#define        EPERM   1
+#define        ENOENT  2
+#define        ESRCH   3
+#define        EINTR   4
+#define        EIO     5
+#define        ENXIO   6
+#define        E2BIG   7
+#define        ENOEXEC 8
+#define        EBADF   9
+#define        ECHILD  10
+#define        EAGAIN  11
+#define        ENOMEM  12
+#define        EACCES  13
+#define        EFAULT  14
+#define        ENOTBLK 15
+#define        EBUSY   16
+#define        EEXIST  17
+#define        EXDEV   18
+#define        ENODEV  19
+#define        ENOTDIR 20
+#define        EISDIR  21
+#define        EINVAL  22
+#define        ENFILE  23
+#define        EMFILE  24
+#define        ENOTTY  25
+#define        ETXTBSY 26
+#define        EFBIG   27
+#define        ENOSPC  28
+#define        ESPIPE  29
+#define        EROFS   30
+#define        EMLINK  31
+#define        EPIPE   32
+#define EDOM   33
+#define        ERANGE  34
diff --git a/usr/include/whoami.h b/usr/include/whoami.h
deleted file mode 100644 (file)
index e357f61..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#define        sysname "where I am"
diff --git a/usr/lib/cign b/usr/lib/cign
deleted file mode 100644 (file)
index b866a05..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-auto   4
-break  5
-case   5
-char   4
-continue       5
-default        5
-do     5
-double 4
-else   5
-extern 2
-float  4
-for    5
-goto   5
-if     5
-int    4
-long   4
-register       4
-return 5
-static 4
-struct 3
-switch 5
-while  5
index 1332037..dc4ef61 100644 (file)
@@ -1,3 +1,2 @@
-0,10,20,30,40,50 * *   *       *       /etc/dmesg - >>/usr/adm/messages
-0,5,10,15,20,25,30,35,40,45,50,55      *       *       *       *       /usr/lib/atrun
-20     1       *       *       *       /usr/bin/calendar -
+20 1 * * * /usr/bin/calendar -
+0,5,10,15,20,25,30,35,40,45,50,55 * * * *      /usr/lib/atrun
diff --git a/usr/lib/eign b/usr/lib/eign
deleted file mode 100644 (file)
index 1b1aecb..0000000
+++ /dev/null
@@ -1,400 +0,0 @@
-a
-about
-above
-across
-act
-action
-after
-again
-against
-ago
-air
-all
-almost
-along
-already
-also
-although
-always
-american
-among
-an
-and
-another
-any
-anything
-are
-area
-areas
-around
-as
-asked
-at
-available
-away
-back
-be
-became
-because
-become
-been
-before
-began
-behind
-being
-best
-better
-between
-big
-board
-body
-both
-boy
-brought
-business
-but
-by
-called
-came
-can
-cannot
-car
-case
-certain
-change
-children
-church
-city
-close
-college
-come
-community
-company
-could
-country
-course
-court
-day
-days
-death
-development
-did
-didn't
-different
-do
-does
-don't
-done
-door
-down
-during
-each
-early
-economic
-either
-end
-enough
-even
-ever
-every
-example
-experience
-eyes
-face
-fact
-family
-far
-federal
-feet
-felt
-few
-field
-find
-first
-five
-for
-force
-form
-found
-four
-free
-from
-gave
-general
-get
-give
-given
-go
-god
-going
-good
-got
-government
-great
-group
-had
-half
-hand
-hands
-has
-have
-having
-he
-head
-heard
-held
-help
-her
-here
-high
-him
-himself
-his
-history
-home
-house
-how
-however
-human
-i
-i'm
-if
-important
-in
-individual
-information
-interest
-into
-is
-it
-it's
-its
-itself
-job
-john
-just
-keep
-kind
-knew
-know
-known
-large
-last
-later
-law
-least
-left
-less
-let
-life
-light
-like
-line
-little
-local
-long
-look
-looked
-love
-made
-major
-make
-making
-man
-many
-matter
-may
-me
-means
-members
-men
-might
-mind
-miss
-moment
-money
-more
-most
-mr
-mrs
-much
-must
-my
-name
-national
-need
-never
-new
-next
-night
-no
-not
-nothing
-now
-number
-of
-off
-office
-often
-old
-on
-once
-one
-only
-open
-or
-order
-other
-others
-our
-out
-over
-own
-part
-past
-people
-per
-perhaps
-period
-place
-point
-political
-position
-possible
-power
-present
-president
-probably
-problem
-problems
-program
-public
-put
-question
-quite
-rather
-real
-really
-reason
-result
-right
-room
-said
-same
-saw
-say
-school
-second
-see
-seemed
-seems
-seen
-sense
-service
-set
-several
-shall
-she
-should
-show
-side
-since
-small
-so
-social
-society
-some
-something
-south
-special
-state
-states
-still
-street
-study
-such
-sure
-system
-take
-taken
-tell
-than
-that
-the
-their
-them
-themselves
-then
-there
-these
-they
-thing
-things
-think
-this
-those
-though
-thought
-three
-through
-thus
-time
-times
-to
-today
-together
-told
-too
-took
-toward
-true
-turn
-turned
-two
-under
-united
-until
-up
-upon
-us
-use
-used
-very
-want
-war
-was
-water
-way
-we
-week
-well
-went
-were
-west
-what
-when
-where
-whether
-which
-while
-white
-who
-whole
-whose
-why
-will
-with
-within
-without
-word
-words
-work
-world
-would
-year
-years
-yet
-york
-you
-young
-your
diff --git a/usr/lib/learn/C/L0 b/usr/lib/learn/C/L0
new file mode 100644 (file)
index 0000000..bab7601
--- /dev/null
@@ -0,0 +1,2 @@
+#next
+0.1a 10
diff --git a/usr/lib/learn/C/L0.1a b/usr/lib/learn/C/L0.1a
new file mode 100644 (file)
index 0000000..6082ae5
--- /dev/null
@@ -0,0 +1,19 @@
+#print
+This script is loosely based on the material in
+"The C Programming Language", by Brian Kernighan
+and Dennis Ritchie (Prentice-Hall, 1978).
+You may find it helpful to have that at hand.
+Some of the lessons will indicate
+the section that they are based on.
+
+Do you have a copy at hand?  Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match yes
+Fine.
+#fail
+It might help, but it's not critical.
+#log
+#next
+1.1a 10
diff --git a/usr/lib/learn/C/L1.1a b/usr/lib/learn/C/L1.1a
new file mode 100644 (file)
index 0000000..a84b86b
--- /dev/null
@@ -0,0 +1,23 @@
+#print
+(Section 1.1)
+The way you compile a C program is to say
+  cc name.c 
+where name.c is the name of the file the program
+is on.  Here is a short C program that prints
+out a line containing "hello".  Type it in and
+compile it.  Call it anything you want but
+don't rename the output.
+When done, type "ready".
+
+main()
+{
+       printf("hello\n");
+}
+#once #create Ref
+hello
+#user
+a.out >x
+#cmp x Ref
+#log
+#next
+1.1b 10
diff --git a/usr/lib/learn/C/L1.1b b/usr/lib/learn/C/L1.1b
new file mode 100644 (file)
index 0000000..9379873
--- /dev/null
@@ -0,0 +1,31 @@
+#print
+(Section 1.1)
+Now write a C program that prints two lines,
+the first of which says "hello" and the second
+"goodbye".  Don't forget those \n delimiters.
+Compile and test it.  When satisfied,
+type "ready".
+#once #create Ref
+hello
+goodbye
+#user
+a.out >test
+#cmp test Ref
+#succeed
+Here is one possible solution to compare against yours.
+
+main()
+{
+       printf("hello\n");
+       printf("goodbye\n");
+}
+
+You could also combine the two messages into one
+call to printf, like
+
+       printf("hello\ngoodbye\n");
+
+but this is harder to read at a glance.
+#log
+#next
+1.1c 10
diff --git a/usr/lib/learn/C/L1.1c b/usr/lib/learn/C/L1.1c
new file mode 100644 (file)
index 0000000..0ec06a3
--- /dev/null
@@ -0,0 +1,18 @@
+#print
+(Section 1.1)
+The program in Ref.c has an error in it.
+Find it, fix it, and run it.
+Then type ready.
+#once #create Ref.c
+main()
+{
+       printf("hello\");
+}
+#once #create Ref
+hello
+#user
+a.out >x
+#cmp x Ref
+#log
+#next
+1.1d 10
diff --git a/usr/lib/learn/C/L1.1d b/usr/lib/learn/C/L1.1d
new file mode 100644 (file)
index 0000000..1ee6693
--- /dev/null
@@ -0,0 +1,33 @@
+#print
+(Section 1.1)
+Write a program which prints these four lines,
+exactly as shown:
+A tab is \t
+A backspace is \b
+A quote is \"
+A backslash is \\
+
+Compile it, test it, then type ready.
+#once #create Ref
+A tab is \t
+A backspace is \b
+A quote is \"
+A backslash is \\
+#user
+a.out >x
+#cmp x Ref
+#succeed
+One solution:
+
+main()
+{
+       printf("A tab is \\t\n");
+       printf("A backspace is \\b\n");
+       printf("A quote is \\\"\n");
+       printf("A backslash is \\\\\n");
+}
+#fail
+Watch out for those backslashes.
+#log
+#next
+1.1e 10
diff --git a/usr/lib/learn/C/L1.1e b/usr/lib/learn/C/L1.1e
new file mode 100644 (file)
index 0000000..4a06790
--- /dev/null
@@ -0,0 +1,14 @@
+#print
+What will be printed by the following printf statement?
+
+       printf("\"#@\"");
+
+Type "answer XXX", where XXX is the set of characters
+that will be printed.
+#copyin
+#user
+#uncopyin
+#match "#@"
+#log
+#next
+1.1f 10
diff --git a/usr/lib/learn/C/L1.1f b/usr/lib/learn/C/L1.1f
new file mode 100644 (file)
index 0000000..b73e575
--- /dev/null
@@ -0,0 +1,19 @@
+#print
+(Section 1.2)
+Write a program to print
+the value of the character 'X' in
+octal.  Compile it and run it.
+Then type ready.
+#user
+a.out >test
+grep 130 test >/dev/null
+#succeed
+A possible solution:
+
+main()
+{
+       printf("%o\n", 'X');
+}
+#log
+#next
+2.1a 10
diff --git a/usr/lib/learn/C/L10 b/usr/lib/learn/C/L10
new file mode 100644 (file)
index 0000000..7599c4b
--- /dev/null
@@ -0,0 +1,15 @@
+#print
+The lessons from this point on are from the old C script.
+They have not been cleaned up as much as they could, so some
+are not very illuminating, and the code they illustrate
+is not always the best. You're welcome to try them nonetheless,
+but be warned.
+If you want to proceed, type yes;
+otherwise, type bye.
+#copyin
+#user
+#uncopyin
+#match yes
+#next 
+11.1a 10
+11.2a 5
diff --git a/usr/lib/learn/C/L11.1a b/usr/lib/learn/C/L11.1a
new file mode 100644 (file)
index 0000000..3351b46
--- /dev/null
@@ -0,0 +1,35 @@
+#print
+With your 'cc' command you can give the name of
+an object file to be loaded with your program.
+For example
+   cc x.c y.o
+will load the previously compiled program 'y' along with
+the program 'x' to be compiled now.
+
+The file "getnum.o" contains a subroutine "getnum" which
+reads an integer and returns its value.
+Write a program which reads a number and decides
+whether or not it is a multiple of 23.  If so print
+"yes" and otherwise print "no".
+Compile and test; then type "ready".
+#once #create Ref1
+23000
+#once #create Ref2
+23001
+#once cp %s/getnum.o .
+#user
+a.out <Ref1 >z1
+a.out <Ref2 >z2
+grep yes z1 >/dev/null && grep no z1 >/dev/null
+#succeed
+/*     One way: */
+
+main() {
+       if (getnum()%23 == 0)
+               printf("yes\n");
+       else
+               printf("no\n");
+}
+#log
+#next
+12.1a 10
diff --git a/usr/lib/learn/C/L11.2a b/usr/lib/learn/C/L11.2a
new file mode 100644 (file)
index 0000000..154493d
--- /dev/null
@@ -0,0 +1,29 @@
+#print
+With your 'cc' command you can give the name of
+an object file to be loaded with your program.
+For example
+   cc x.c y.o
+will load the previously compiled program 'y' along with
+the program 'x' to be compiled now.
+There is a file in this directory named "getnum.o"
+that contains a subroutine "getnum" that will read digits
+from the standard input, convert them to binary, and
+return an integer value.
+
+Write a program which reads an integer and prints
+it back in octal.  Compile and test as usual.
+#once #create Ref
+254
+#once cp %s/getnum.o .
+#user
+a.out <Ref >test
+grep 376 test >/dev/null
+#succeed
+/*     One way: */
+
+main() {
+       printf("%o\n", getnum());
+}
+#log
+#next
+11.1a 10
diff --git a/usr/lib/learn/C/L12.1a b/usr/lib/learn/C/L12.1a
new file mode 100644 (file)
index 0000000..f85a718
--- /dev/null
@@ -0,0 +1,34 @@
+#print
+Write a program which reads two numbers and
+prints the larger one in decimal. Use the same
+"getnum" subroutine.  Compile, test and type
+"ready" as usual.
+#once #create Ref1
+14039 89
+#once #create Ref2
+20022 23001
+#once cp %s/getnum.o .
+#user
+a.out <Ref1 >x1
+a.out <Ref2 >x2
+grep 14039 x1 >/dev/null && grep 23001 x2 >/dev/null
+#succeed
+/*     One way: */
+
+main() {
+       int n1, n2;
+
+       n1 = getnum();
+       n2 = getnum();
+       printf("%d\n", n1 > n2 ? n1 : n2);
+}
+
+You could also use something like
+
+       if (n1 > n2)
+               printf("%d\n", n1);
+       else
+               printf("%d\n", n2);
+#log
+#next
+12.1b 10
diff --git a/usr/lib/learn/C/L12.1b b/usr/lib/learn/C/L12.1b
new file mode 100644 (file)
index 0000000..733cb4f
--- /dev/null
@@ -0,0 +1,59 @@
+#print
+The function getnum actually returns -1 when it
+encounters end of file. (The source is in getnum.c
+if you're interested.)
+Write, compile and run a program that
+reads numbers one per line with getnum
+and, for each, prints:
+
+small  if the number is >0 and <=100
+big    if the number is >100 and <=1000
+huge   if the number is >1000.
+
+Type "ready" when you're done.
+#once cp %s/getnum.o .
+#once cp %s/getnum.c .
+#once #create Ref
+1001
+1000
+999
+101
+100
+1
+#once #create Ref1
+huge
+big
+big
+big
+small
+small
+#user
+a.out <Ref >test
+#cmp Ref1 test
+#succeed
+One way:
+
+main() {
+       int n;
+
+       while ((n = getnum()) >= 0)
+               if (n > 0 && n <= 100)
+                       printf("small\n");
+               else if (n > 100 && n <= 1000)
+                       printf("big\n");
+               else if (n > 1000)
+                       printf("huge\n");
+}
+
+       Notice that in principle n could be negative,
+       so we need the last case to say
+               else if (n > 1000)
+       instead of just falling into it with a bare
+               else
+
+       Also it's a good idea to indent the else-if's
+       exactly the way they are here; otherwise
+       you'll lose track of what's going on.
+#log
+#next
+13.1a 10
diff --git a/usr/lib/learn/C/L13.1a b/usr/lib/learn/C/L13.1a
new file mode 100644 (file)
index 0000000..49f1ab1
--- /dev/null
@@ -0,0 +1,40 @@
+#print
+Write a program which reads
+its input and counts the number of
+characters and the number of spaces
+(where a space is either a blank or
+a tab or a newline).  Print both numbers.
+Compile, test, and type "ready".
+#once #create Ref
+hoboken harrison newark roseville avenue grove street
+east orange brick church orange highland avenue
+mountain station south orange maplewood millburn short hills
+summit chatham madison convent station morristown
+new providence murray hill berkeley heights
+gillette stirling millington lyons basking ridge
+bernardsville far hills peapack gladstone
+#user
+a.out <Ref >x1
+a.out <Ref >x2
+grep 348 x1 >/dev/null && grep 45 x2 >/dev/null
+#success
+One way:
+
\b#include <stdio.h>
+
+main() {
+       int nchar, nspace;
+       char c;
+
+       nchar = nspace = 0;
+       while ((c = getchar()) != EOF) {
+               nchar++;
+               if (c == ' ' || c == '\t' || c == '\n')
+                       nspace++;
+       }
+       printf("spaces = %d, chars = %d\n", nspace, nchar);
+}
+#log
+#next
+14.1a 10
+14.2a 5
diff --git a/usr/lib/learn/C/L14.1a b/usr/lib/learn/C/L14.1a
new file mode 100644 (file)
index 0000000..c859863
--- /dev/null
@@ -0,0 +1,37 @@
+#print
+Using the familar "getnum.o" routine
+write a program that reads numbers one per line and determines
+for each if it is prime. Print "prime"
+for a prime number and "composite" for a non-prime number.
+Compile, test, and type "ready".
+#once #create Ref
+10039
+17947
+#once #create Ref1
+prime
+composite
+#once cp %s/getnum.o .
+#user
+a.out <Ref >x1
+#cmp x1 Ref1
+#success
+/* A slow but sure prime-tester */
+main()
+{
+       int p, i, comp;
+
+       while ((p = getnum()) >= 0) {
+               comp = 0;
+               for (i = 2; i*i <= p; i++)
+                       if (p%i == 0) {
+                               comp = 1;
+                               break;
+                       }
+               if (comp)
+                       printf("composite\n");
+               else
+                       printf("prime\n");
+       }
+}
+#log
+15.1a 10
diff --git a/usr/lib/learn/C/L14.2a b/usr/lib/learn/C/L14.2a
new file mode 100644 (file)
index 0000000..01cc54f
--- /dev/null
@@ -0,0 +1,26 @@
+#print
+Using the "getnum" routine on "getnum.o", write a program
+that reads a list of positive numbers and prints their sum.  Stop reading
+numbers when "getnum" returns a negative or zero value.
+Compile and test your program; then type "ready".
+#once #create Ref
+5 43 293 400 75 832 903 33
+#once cp %s/getnum.o .
+#user
+a.out <Ref >xxx
+grep 2584 xxx >/dev/null
+#succeed
+/* Read numbers and count */
+main()
+{
+       int s, n;
+
+       s = 0;
+       while ((n=getnum()) > 0)
+               s += n;
+       printf("Sum is %d\n", s);
+}
+#log
+#next
+14.2b 5
+15.1a 10
diff --git a/usr/lib/learn/C/L14.2b b/usr/lib/learn/C/L14.2b
new file mode 100644 (file)
index 0000000..6663304
--- /dev/null
@@ -0,0 +1,41 @@
+#print
+Write a program which counts the number of five letter
+words in its input (define a word as anything between
+blanks, tabs or newlines).  Compile and run it, then type "ready".
+Note that all that is wanted is the total number of
+five letter words - nothing was said about distinct
+words.  Just count the number of times exactly five
+characters appear between spaces.
+#once #create Ref
+This is a passage of text which contains
+exactly twelve words of five letters.
+Words may appear at the start or at the final
+part of a line.  Other words show up in
+the middle.  Avoid counting seven or eight letters
+but every five must be noted.
+#user
+a.out <Ref >xxx
+grep 12 xxx >/dev/null
+#succeed
+/*     one way to count five letter words */
\b#include <stdio.h>
+
+main()
+{
+       int since, wdnum, c;
+
+       since = 0;
+       while ((c=getchar()) != EOF) {
+               if (c == ' ' || c == '\t' || c == '\n') {
+                       if (since == 5)
+                               wdnum++;
+                       since = 0;
+               }
+               else
+                       since++;
+       }
+       printf("%d\n", wdnum);
+}
+#log
+#next
+15.1a 10
diff --git a/usr/lib/learn/C/L15.1a b/usr/lib/learn/C/L15.1a
new file mode 100644 (file)
index 0000000..38eed40
--- /dev/null
@@ -0,0 +1,33 @@
+#print
+Write a program that reads in lines one at a time,
+and prints them out if their length (including
+the newline) is odd.
+You can use the function getline if you like; the object
+file is in getline.o.
+Compile and run it, then type "ready".
+#once #create Ref1
+this line contains an odd number of letters
+this line, however, contains an even number of letters
+#once #create Ref2
+this line contains an odd number of letters
+#once cp %s/getline.o .
+#user
+a.out <Ref1 >x1
+#cmp x1 Ref2
+#succeed
+It's certainly easiest with getline:
+
\b#include <stdio.h>
+
+main()
+{
+       char line[500];
+       int n;
+
+       while ((n = getline(line, 500)) > 0)
+               if (n % 2 == 1)
+                       printf("%s", line);
+}
+#log
+#next
+15.1b 10
diff --git a/usr/lib/learn/C/L15.1b b/usr/lib/learn/C/L15.1b
new file mode 100644 (file)
index 0000000..d0032a8
--- /dev/null
@@ -0,0 +1,40 @@
+#print
+Write a program that reads in lines, and prints each out
+in reverse order (except that the newline should be
+at the end).
+Thus the line
+cat food
+should come out as
+doof tac
+Compile it and run it, then type "ready".
+#once #create Ref1
+This is odd.
+This is even.
+
+#once #create Ref2
+.ddo si sihT
+.neve si sihT
+
+#once cp %s/getline.o .
+#user
+a.out <Ref1 >x1
+#cmp x1 Ref2
+#succeed
+/*     one way to do this */
\b#include <stdio.h>
+
+main()
+{
+       char line[500];
+       int n;
+
+       while ((n = getline(line, 500)) > 0) {
+               for (n -= 2; n >= 0; n--)
+                       putchar(line[n]);
+               putchar('\n');
+       }
+}
+#log
+#next
+17.1a 10
+16.2a 5
diff --git a/usr/lib/learn/C/L16.2a b/usr/lib/learn/C/L16.2a
new file mode 100644 (file)
index 0000000..b9a2013
--- /dev/null
@@ -0,0 +1,53 @@
+#print
+Write a program which reads a file with lines of up
+to 200 characters and shortens them to 60 characters
+by throwing away any characters past the first 60.
+Compile and test it; then type "ready".
+#once #create Ref
+hoboken harrison newark roseville avenue grove street
+east orange brick church orange highland avenue east orange 
+mountain station south orange maplewood millburn short hills
+summit chatham madison convent station morristown summit cha
+new providence murray hill berkeley heights
+
+gillette stirling millingon lyons basking ridgexxxxxxxxxxxxx
+bernardsville far hills peapack gladstone
+#once #create badin
+hoboken harrison newark roseville avenue grove street
+east orange brick church orange highland avenue east orange brick church orange highland avenue east orange brick church orange highland avenue
+mountain station south orange maplewood millburn short hills
+summit chatham madison convent station morristown summit chatham madison convent station morristown summit chatham madison convent station morristown
+new providence murray hill berkeley heights
+
+gillette stirling millingon lyons basking ridgexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+bernardsville far hills peapack gladstone
+#user
+a.out <badin >xxx
+#cmp Ref xxx
+#succeed
+/*     one way to do this */
\b#include <stdio.h>
+
+main()
+{
+       char line[61];
+       int c, k;
+
+       k = 0;
+       while ((c = getchar()) != EOF) {
+               if (c == '\n') {
+                       line[k] = 0;
+                       printf("%s\n", line);
+                       k = 0;
+               }
+               else if (k < 60)
+                       line[k++] = c;
+       }
+}
+
+Note that this version works regardless of
+how long the lines are.  If you use getline,
+is the same thing true??
+#log
+#next
+16.2b 10
diff --git a/usr/lib/learn/C/L16.2b b/usr/lib/learn/C/L16.2b
new file mode 100644 (file)
index 0000000..3d4bf96
--- /dev/null
@@ -0,0 +1,40 @@
+#print
+Write a program which copies all lines containng
+the letter 'p' from its input to its output.
+Compile and test it; then type "ready".
+#once #create Ref
+mountain station south orange maplewood millburn short hills
+new providence murray hill berkeley heights
+bernardsville far hills peapack gladstone
+#once #create badin
+hoboken harrison newark roseville avenue grove street
+east orange brick church orange highland avenue
+mountain station south orange maplewood millburn short hills
+summit chatham madison convent station morristown
+new providence murray hill berkeley heights
+gillette stirling millington lyons basking ridge
+bernardsville far hills peapack gladstone
+#once cp %s/getline.o .
+#user
+a.out <badin >xxx
+#cmp Ref xxx
+#succeed
+/*     a way to find lines with 'p' */
\b#include <stdio.h>
+
+main()
+{
+       char line[500];
+       int k;
+
+       while (getline(line, 500) > 0)
+               for (k = 0; line[k] != '\0'; k++)
+                       if (line[k] == 'p') {
+                               printf("%s", line);
+                               break;
+                       }
+}
+#log
+#next
+16.2c 5
+17.1a 10
diff --git a/usr/lib/learn/C/L16.2c b/usr/lib/learn/C/L16.2c
new file mode 100644 (file)
index 0000000..d51310d
--- /dev/null
@@ -0,0 +1,67 @@
+#print
+Write a program to read its input and find the
+word in it with the most vowels (instances of a,e,i,o, or u).
+Print out that word. Compile and test your
+program, then type ready.
+#once #create Ref
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+  We hold these truths to be self evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#user
+a.out <Ref >xxx
+grep inalienable xxx >/dev/null
+#succeed
+/*     a way to find a word with lots of vowels */
\b#include <stdio.h>
+
+main()
+{
+       char bigword[100], thisword[100];
+       int nvow, maxvow, c, k;
+
+       maxvow = k = 0;
+       while ((c = getchar()) != EOF) {
+               if (c == '\n' || c == ' ') {
+                       if (nvow > maxvow) {
+                               copy(thisword, bigword, k);
+                               maxvow = nvow;
+                       }
+                       nvow = k = 0;
+               } else {
+                       thisword[k++] = c;
+                       switch (c) {
+                       case 'a': case 'e': case 'i': case 'o': case 'u':
+                               nvow++;
+                       }
+               }
+       }
+       printf("the word %s had %d vowels\n", bigword, maxvow);
+}
+
+copy(a, b, n)
+char a[], b[];
+{
+       int i;
+
+       for(i = 0; i < n; i++)
+               b[i] = a[i];
+       b[i] = 0;
+}
+#log
+#next
+17.1a 10
diff --git a/usr/lib/learn/C/L17.1a b/usr/lib/learn/C/L17.1a
new file mode 100644 (file)
index 0000000..16af750
--- /dev/null
@@ -0,0 +1,72 @@
+#print
+Write in a program which reads its input and writes it
+out line numbered, with a three-digit line number (starting at one)
+followed by a single space and then by the original line.
+Note: the printf format specification %3d will print a three
+digit number.
+You might try the function fgets (part of the standard library).
+       fgets(buf, size, stdin)
+reads from the terminal ("stdin") up to size characters
+into buf.  It returns NULL on end of file.
+
+Compile and test your program; then type "ready".
+#once #create Ref
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+  We hold these truths to be self evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#once #create reffed
+  1 When in the course of human events, it becomes
+  2 necessary for one people to dissolve the political bands which have
+  3 connected them with another, and to assume among the 
+  4 powers of the earth the separate and equal station to which
+  5 the laws of Nature and of Nature's God entitle them, a decent
+  6 respect to the opinions of mankind requires that they should
+  7 declare the causes which impel them to the separation.
+  8   We hold these truths to be self evident, that all men
+  9 are created equal, that they are endowed by their creator
+ 10 with certain unalienable rights, that among these are life, liberty,
+ 11 and the pursuit of happiness.  That to secure these rights,
+ 12 governments are instituted among men, deriving their just
+ 13 powers from the consent of the governed.  That whenever
+ 14 any form of government becomes destructive of these ends,
+ 15 it is the right of the people to alter or to abolish it, and
+ 16 to institute new government, laying its foundation on such
+ 17 principles and organizing its powers in such form, as to them
+ 18 shall seem most likely to effect their safety and happiness.
+#user
+a.out <Ref >xxx
+#cmp xxx reffed
+#succeed
+
+FROM HERE ON, EXAMPLES HAVEN'T BEEN CLEANED AT ALL
+
\b#include <stdio.h>
+
+main()
+{
+       char s[200];
+       int k;
+
+       k = 0;
+       while (fgets(s, 200, stdin) != NULL)
+               printf("%3d %s", ++k, s);
+}
+#log
+#next
+18.1a 10
+17.1c 5
diff --git a/usr/lib/learn/C/L17.1c b/usr/lib/learn/C/L17.1c
new file mode 100644 (file)
index 0000000..c7eb76c
--- /dev/null
@@ -0,0 +1,50 @@
+#print
+Print the 20 Fibonacci numbers beginning with 2
+(the sequence is 2,3,5,8,... where each number
+is the sum of the immediately preceding pair of numbers.
+Start with the pair 1,1).
+Print each number on a separate line as a five digit
+number (remember %3d in printf? %5d does five digits).
+Compile and test your program; then type "ready".
+#once #create Ref
+    2
+    3
+    5
+    8
+   13
+   21
+   34
+   55
+   89
+  144
+  233
+  377
+  610
+  987
+ 1597
+ 2584
+ 4181
+ 6765
+10946
+17711
+#user
+a.out >xxx
+#cmp xxx Ref
+#succeed
+/*      one way */
+main()
+{
+       int f1, f2, t, count;
+
+       f1 = 1;
+       f2 = 1;
+       for (count = 0; count < 20; count++) {
+               t = f1+f2;
+               f1 = f2;
+               f2 = t;
+               printf("%5d\n", t);
+       }
+}
+#log
+#next
+18.1a 10
diff --git a/usr/lib/learn/C/L18.1a b/usr/lib/learn/C/L18.1a
new file mode 100644 (file)
index 0000000..fc330b3
--- /dev/null
@@ -0,0 +1,49 @@
+#print
+There is nothing to force you to write a main program
+on each file; just as I supplied "getnum" on a separate file,
+you can put different routines on different files.  Write
+a function "length(s)" which if given a character array argument
+"s" returns the length of that string.
+Put this on a file names "length.c", and leave
+the object file in "length.o".
+Write the main program for
+testing this somewhere else.  Type "ready" when you have compiled
+and tested your program and are happy with it.
+#once #create Ref
+This file contains several lines of quite different lengths.
+
+You should get
+all of them exactly
+r
+right.
+#once #create answer
+60
+0
+14
+19
+1
+6
+#once #create tzaqc.c
+main() {
+       char s[200];
+       while (gets(s))
+               printf("%d\n", length(s));
+}
+#user
+cc tzaqc.c length.c -lS
+a.out <Ref >value
+#cmp value answer
+#succeed
+/*      one way */
+length(s)
+char *s;
+{
+       int k;
+
+       for (k=0; s[k]; k++)
+               ;
+       return(k);
+}
+#log
+#next
+19.1a 10
diff --git a/usr/lib/learn/C/L19.1a b/usr/lib/learn/C/L19.1a
new file mode 100644 (file)
index 0000000..21e46af
--- /dev/null
@@ -0,0 +1,29 @@
+#print
+Write a subroutine which counts the number of times it has
+been called and returns that count each time.  Name it
+"count()".  Write it on a file named "count.c".  Compile
+and test it; type "ready" when happy.
+#once #create Ref
+23080
+#once #create tzaqc.c
+main() {
+       int i;
+       for (i = 0; i < 23079; i++)
+               count();
+       printf("%d\n", count());
+}
+#user
+cc tzaqc.c count.o
+a.out  >value
+#cmp value Ref
+#succeed
+/*  one way */
+count()
+{
+       static int n = 0;
+       return(++n);
+}
+#log
+#next
+30.1a 10
+20.1a 5
diff --git a/usr/lib/learn/C/L2.1a b/usr/lib/learn/C/L2.1a
new file mode 100644 (file)
index 0000000..43e3baf
--- /dev/null
@@ -0,0 +1,55 @@
+#print
+(Section 1.2)
+The file Ref.c contains a copy of
+a program to convert Fahrenheit to
+Celsius. Modify it to print this
+heading at the top:
+Fahrenheit-Celsius Conversion
+  F:     C:
+Type ready when you're satisfied.
+#once #create Ref
+Fahrenheit-Celsius Conversion
+  F:     C:
+   0  -17.8
+  20   -6.7
+  40    4.4
+  60   15.6
+  80   26.7
+ 100   37.8
+ 120   48.9
+ 140   60.0
+ 160   71.1
+ 180   82.2
+ 200   93.3
+ 220  104.4
+ 240  115.6
+ 260  126.7
+ 280  137.8
+ 300  148.9
+#once #create Ref.c
+/* print Fahrenheit-Celsius table 
+       for f = 0, 20, ..., 300 */
+main()
+{
+       int lower, upper, step;
+       float fahr, celsius;
+
+       lower = 0;      /* lower limit of temperature table */
+       upper = 300;    /* upper limit */
+       step = 20;      /* step size */
+
+       fahr = lower;
+       while (fahr <= upper) {
+               celsius = (5.0/9.0) * (fahr-32.0);
+               printf("%4.0f %6.1f\n", fahr, celsius);
+               fahr = fahr + step;
+       }
+}
+#user
+a.out >x
+#cmp Ref x
+#fail
+Make sure you get the spacing right.
+#log
+#next
+2.1b 10
diff --git a/usr/lib/learn/C/L2.1b b/usr/lib/learn/C/L2.1b
new file mode 100644 (file)
index 0000000..efc9a0e
--- /dev/null
@@ -0,0 +1,21 @@
+#print
+(Section 1.2)
+Write a C program that prints a number which is
+the sum of three numbers: 23, 197, and the product
+of 23 and 197.  Again, compile and test
+it.  Please do the computation with the program -
+if you do it by hand, I'll give you credit for the
+work, but it's just stupid.
+#user
+a.out >test
+grep 4751 test >/dev/null
+#succeed
+/* Here is one possible solution */
+
+main()
+{
+       printf("%d\n", 23 + 197 + 23*197);
+}
+#log
+#next
+2.1c 10
diff --git a/usr/lib/learn/C/L2.1c b/usr/lib/learn/C/L2.1c
new file mode 100644 (file)
index 0000000..4158208
--- /dev/null
@@ -0,0 +1,16 @@
+#print
+(Section 1.2)
+What value is printed by this printf statement?
+
+       printf("%.3f", 3.141592654);
+
+Type "answer XXX", where XXX is the value.
+#copyin
+#user
+#uncopyin
+#match 3.142
+#fail
+Remember about rounding?
+#log
+#next
+2.1d 10
diff --git a/usr/lib/learn/C/L2.1d b/usr/lib/learn/C/L2.1d
new file mode 100644 (file)
index 0000000..94f328e
--- /dev/null
@@ -0,0 +1,15 @@
+#print
+What value is printed by this printf statement?
+
+       printf("%%3.1f", 3.141592654);
+
+Type "answer XXX", where XXX is the value.
+#copyin
+#user
+#uncopyin
+#match %3.1f
+#fail
+Look again - it's %%
+#log
+#next
+2.1e 10
diff --git a/usr/lib/learn/C/L2.1e b/usr/lib/learn/C/L2.1e
new file mode 100644 (file)
index 0000000..86df632
--- /dev/null
@@ -0,0 +1,19 @@
+#print
+Is there any difference between
+
+   printf("%s", s);
+
+and
+
+   printf(s);
+
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match yes
+#fail
+Consider the string "50% of the answers are wrong."
+#log
+#next
+3.1a 10
diff --git a/usr/lib/learn/C/L20.1a b/usr/lib/learn/C/L20.1a
new file mode 100644 (file)
index 0000000..b1036c6
--- /dev/null
@@ -0,0 +1,106 @@
+#print
+Write a program to read a list of positive numbers
+and sort them into ascending order.  Print
+the sorted list of numbers one per line
+as five digit numbers (%5d in printf).
+Stop reading numbers when getnum returns zero.
+Compile and test your program; then type "ready".
+#once #create Ref
+    1
+    3
+    4
+    9
+   11
+   12
+   13
+   14
+   15
+   16
+   17
+   20
+   34
+   71
+  200
+  225
+  250
+  275
+  300
+ 4095
+ 7111
+16384
+#once cp %s/getnum.o .
+#once #create input
+4 20 3 200 16384 4095 71 11 12 13 14
+15 16 17 34 9 7111 300 275 250 225 1
+#user
+a.out  <input >xxx
+#cmp xxx Ref
+#succeed
+main()
+{
+       getlist();
+       sortlist();
+       printlist();
+}
+
+int n;
+int list[1000];
+
+getlist()
+{
+       while (list[n]=getnum())
+               n++;
+}
+
+sortlist()
+{
+       shellsort(list,n);
+}
+
+/* this is a shell sort, stripped down to process a list
+   of integers only.  Although you probably don't know
+   how to write this offhand, you should know where to find
+   it - it is only marginally more code than a bubble sort
+   and much faster (n**1.5 vs. n**2) in time. */
+shellsort(array, nitem)
+int *array;
+shellsort(v, n)  /* sort v[0]...v[n-1] into increasing order */
+int v[], n;
+{
+    int gap, i, j, temp;
+
+    for (gap = n/2; gap > 0; gap /= 2)
+        for (i = gap; i < n; i++)
+            for (j=i-gap; j>=0 && v[j]>v[j+gap]; j-=gap) {
+                temp = v[j];
+                v[j] = v[j+gap];
+                v[j+gap] = temp;
+            }
+}
+
+printlist()
+{
+       int i;
+       for(i=0; i<n; i++)
+               printf("%5d\n",list[i]);
+}
+/* this is a crummy bubble sort which
+   would work perfectly well for this
+   problem but can not be recommended
+   for large jobs. 
+sortlist()
+{
+       int i, j, k;
+
+       for(i=0; i<n; i++)
+               for(j=n-1; j>0; j--)
+                       if (list[j-1] > list[j]) {
+                               k = list[j];
+                               list[j] = list[j-1];
+                               list[j-1] = k;
+                       }
+}
+ ****/
+#log
+#next
+30.1a 10
diff --git a/usr/lib/learn/C/L3.1a b/usr/lib/learn/C/L3.1a
new file mode 100644 (file)
index 0000000..9efe184
--- /dev/null
@@ -0,0 +1,56 @@
+#print
+(Section 1.3)
+The file Ref.c contains a copy of
+a program to convert Fahrenheit to
+Celsius that prints from 0 to 300
+degrees in steps of 20.
+Modify it to print from 300 down to 0
+in steps of 50. Type ready when you're done.
+#once #create Ref
+ 300  148.9
+ 250  121.1
+ 200   93.3
+ 150   65.6
+ 100   37.8
+  50   10.0
+   0  -17.8
+#once #create Ref.c
+/* print Fahrenheit-Celsius table 
+       for f = 0, 20, ..., 300 */
+main()
+{
+       int lower, upper, step;
+       float fahr, celsius;
+
+       lower = 0;      /* lower limit of temperature table */
+       upper = 300;    /* upper limit */
+       step = 20;      /* step size */
+
+       fahr = lower;
+       while (fahr <= upper) {
+               celsius = (5.0/9.0) * (fahr-32.0);
+               printf("%4.0f %6.1f\n", fahr, celsius);
+               fahr = fahr + step;
+       }
+}
+#user
+a.out >x
+#cmp Ref x
+#succeed
+Here's our solution:
+
+main() /* Fahrenheit-Celsius 300 ... 0 by 50 */
+{
+       int lower, upper, step;
+       float fahr;
+
+       lower = 0;      /* lower limit of temperature table */
+       upper = 300;    /* upper limit */
+       step = 50;      /* step size */
+
+       for (fahr = upper; fahr >= lower; fahr = fahr - step)
+               printf("%4.0f %6.1f\n", fahr, (5.0/9.0) * (fahr-32.0));
+}
+#log
+#next
+3.1b 10
diff --git a/usr/lib/learn/C/L3.1b b/usr/lib/learn/C/L3.1b
new file mode 100644 (file)
index 0000000..3382330
--- /dev/null
@@ -0,0 +1,14 @@
+#print
+What is the value of i after this
+___\b\b\bfor statement executes?
+Type "answer N", where N is the value of i.
+
+  for (i = 0; i < 10; i = i + 3)
+       ;
+#copyin
+#user
+#uncopyin
+#match 12
+#log
+#next
+4.1a 10
diff --git a/usr/lib/learn/C/L30.1a b/usr/lib/learn/C/L30.1a
new file mode 100644 (file)
index 0000000..c9aeda9
--- /dev/null
@@ -0,0 +1,44 @@
+#print
+Write a subroutine named "index(s,c)" which expects two
+arguments: the first is a pointer to characters 's' which
+points to a null-terminated string, and the second
+is a character 'c' which is to be searched for in the
+string 's'.  If the character 'c' does not
+appear in the string return 0; otherwise return a pointer
+to the position of 'c' in the string. Name the program "index.c";
+as usual, compile and test it and then type "ready".
+#once #create Ref
+0
+19
+0
+25
+0
+#once #create tzaqc.c
+char *alpha "abcdefghijklmnopqrstuvwxyz";
+main()
+{
+       extern char *index();
+       printf("%d\n", index(alpha, '+'));
+       printf("%d\n",index(alpha, 't')-alpha));
+       printf("%d\n",index(alpha, 'a')-alpha));
+       printf("%d\n",index(alpha, 'z')-alpha));
+       printf("%d\n",index("", 'z'));
+}
+#user
+cc tzaqc.c index.o
+a.out  >value
+#cmp value Ref
+#succeed
+Try this:
+
+char *index (s, c)
+char *s;
+{
+       for( ; *s; s++)
+               if (*s == c)
+                       return(s);
+       return(0);
+}
+#log
+#next
+31.1a 10
diff --git a/usr/lib/learn/C/L31.1a b/usr/lib/learn/C/L31.1a
new file mode 100644 (file)
index 0000000..ba8ab71
--- /dev/null
@@ -0,0 +1,48 @@
+#print
+Write a function named "rev(s)" which reverses
+the string "s" in place. Name the file that contains
+the function "rev.c".
+When you're satisfied, type "ready".
+#once #create Ref
+cbax0987654321
+#once #create tzaqc.c
+main(){
+       char *s1, *s2, *s3, *s4;
+       s1 = "abc";
+       s2 = "x";
+       s3 = "";
+       s4 = "1234567890";
+       rev(s1);
+       rev(s2);
+       rev(s3);
+       rev(s4);
+       printf(s1);
+       printf(s2);
+       printf(s3);
+       printf(s4);
+       printf("\n");
+}
+#user
+cc tzaqc.c rev.o
+a.out >value
+#cmp value Ref
+#succeed
+One way:
+
+rev (s)
+char *s;
+{
+       char *p;
+       int t;
+       
+       for (p=s; *p; p++)
+               ;
+       for (p--; p > s; p--, s++) {
+               t = *p;
+               *p = *s;
+               *s = t;
+       }
+}
+#log
+#next
+32.1a 10
diff --git a/usr/lib/learn/C/L32.1a b/usr/lib/learn/C/L32.1a
new file mode 100644 (file)
index 0000000..b84d881
--- /dev/null
@@ -0,0 +1,46 @@
+#print
+Write a program
+   pair(a,b)
+which accepts as arguments two pointers to integers
+and swaps the integers if necessary so that the
+first argument points to the larger one; that is
+       int x,y;
+       x = 9;
+       y = 15;
+       pair( &x, &y);
+results in x being 15 and y 9.  Leave the program
+on file "pair.c"; compile, test it, and type "ready".
+#once #create tzaqc.c
+main()
+{
+int x,y;
+y=200;
+x = 0;
+pair(&y, &x);
+if (x!=0 || y !=200) return(1);
+pair(&x,&y);
+if (x!=200 || y !=0) return(1);
+x = 30;
+y = 23097;
+pair(&x,&y);
+if (x!= 23097 || y!= 30) return(1);
+return(0);
+}
+#user
+cc tzaqc.c pair.o
+a.out 
+#succeed
+pair(a, b)
+int *a, *b;
+{
+       int t;
+
+       if (*a <= *b) {
+               t = *a;
+               *a = *b;
+               *b = t;
+       }
+}
+#log
+#next
+33.1a 10
diff --git a/usr/lib/learn/C/L33.1a b/usr/lib/learn/C/L33.1a
new file mode 100644 (file)
index 0000000..6c2f5ee
--- /dev/null
@@ -0,0 +1,23 @@
+#print
+Write a program which counts the number of arguments
+it has which begin with the letter 'b'.  Print the
+result in decimal.  Compile and test it as usual.
+Then type "ready".
+#user
+a.out abc bcd efg rpq b bbvd  >xxx
+grep 3 xxx >/dev/null
+#succeed
+/*  a possible solution */
+main(argc, argv)
+char *argv[];
+{
+       int i, k;
+
+       for(i=k=0; i<argc; i++)
+               if (argv[i][0] == 'b')
+                       k++;
+       printf("%d\n", k);
+}
+#log
+#next
+35.1a 10
diff --git a/usr/lib/learn/C/L35.1a b/usr/lib/learn/C/L35.1a
new file mode 100644 (file)
index 0000000..c6f7c0d
--- /dev/null
@@ -0,0 +1,35 @@
+#print
+Write a program which prints the number of vowels
+(instances of 'a', 'e', 'i', 'o', and 'u')
+in the input.
+#once #create Ref
+hoboken harrison newark roseville avenue grove street
+east orange brick church orange highland avenue
+mountain station south orange maplewood millburn short hills
+summit chatham madison convent station morristown
+new providence murray hill berkeley heights
+gillette stirling millington lyons basking ridge
+bernardsville far hills peapack gladstone
+#user
+a.out <Ref >xxx
+grep 109 xxx >/dev/null
+#succeed
+/*  a possible solution */
\b#include <stdio.h>
+
+main()
+{
+       int k, c;
+
+       k = 0;
+       while ((c = getchar()) != EOF)
+               switch (c) {
+               case 'a': case 'e':case 'i': case 'o': case 'u':
+                       k++;
+                       break;
+               }
+       printf("%d\n", k);
+}
+#log
+#next
+37.1a 10
diff --git a/usr/lib/learn/C/L37.1a b/usr/lib/learn/C/L37.1a
new file mode 100644 (file)
index 0000000..6390c8c
--- /dev/null
@@ -0,0 +1,48 @@
+#print
+Let's try a recursive function.  Write a subroutine
+    power(x,n)
+which computes x to the power n by the following
+algorithm:
+ 1. if n is zero return 1.
+ 2. if n is odd return x*power(x,n-1).
+ 3. if n is even return the square of
+    power(x,n/2).
+You may assume than x and n are integers, n>=0.
+If n is negative return 0 for an answer.
+Put your routine on a file "power.c".  Compile
+it and test it; then type "ready".
+#once #create tzaqc.c
+main()
+{
+if (power(-1,-1) != 0) return(1);
+if (power(-3,2) != 9) return(1);
+if (power(2,12) != 4096) return(1);
+if (power(3,5) !=  243) return(1);
+if (power(-5, 5) != -3125) return(1);
+if (power(7,3) != 343) return(1);
+if (power(7,4) != 2401) return(1);
+if (power(3,7) != 2187) return(1);
+if (power(2,10) != 1024) return(1);
+return(0);
+}
+#user
+cc tzaqc.c power.o
+a.out
+#succeed
+/*  a possible solution */
+power(x, n)
+{
+       int k;
+
+       if (n < 0)
+               return(0);
+       if (n == 0)
+               return(1);
+       if (n%2 == 1)
+               return(x * power(x, n-1));
+       k = power(x, n/2);
+       return(k*k);
+}
+#log
+#next
+40.1a 10
diff --git a/usr/lib/learn/C/L4.1a b/usr/lib/learn/C/L4.1a
new file mode 100644 (file)
index 0000000..e24f874
--- /dev/null
@@ -0,0 +1,10 @@
+#print
+Does the # of a "#define" statement absolutely
+have to go in column 1?  Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+5.1a 10
diff --git a/usr/lib/learn/C/L40.1a b/usr/lib/learn/C/L40.1a
new file mode 100644 (file)
index 0000000..a5d6700
--- /dev/null
@@ -0,0 +1,56 @@
+#print
+Write a subroutine
+       errmess(n)
+which looks at its argument and prints
+one of the following messages:
+  n     message (follow it by a newline)
+  1       ?
+  2       syntax error
+  3       bad syntax error
+  4       fatal error
+  5       I give up.
+anything else  eh?
+Leave the routine on errmess.c, compiled and tested
+as usual.  Then type "ready".
+#once #create Ref
+eh?
+eh?
+I give up.
+fatal error
+bad syntax error
+syntax error
+?
+#once #create tzaqc.c
+main()
+{
+       errmess (23069);
+       errmess (-2000);
+       errmess (5);
+       errmess (4);
+       errmess (3);
+       errmess (2);
+       errmess (1);
+}
+#user
+cc tzaqc.c errmess.o
+a.out >xxx
+#cmp Ref xxx
+#succeed
+/*  a possible solution */
+char *message[] = {
+       "eh?",
+       "?",
+       "syntax error",
+       "bad syntax error",
+       "fatal error",
+       "I give up.",
+       };
+errmess(n)
+{
+       if (n < 0 || n > 5)
+               n = 0;
+       printf("%s\n", message[n]);
+}
+#log
+#next
+41.1a 10
diff --git a/usr/lib/learn/C/L41.1a b/usr/lib/learn/C/L41.1a
new file mode 100644 (file)
index 0000000..9300390
--- /dev/null
@@ -0,0 +1,62 @@
+#print
+The problem is to produce a function
+       bitct(x)
+which examines the bits in x, returning a count of
+the number of 1-bits.  There are various ways of doing
+this job: here are two.
+(1) a sane way.  Shift the word x right 16 times (you are
+on UNIX) and check the rightmost bit each time, counting
+the number of times it is '1'.
+(2) a machine-independent (sort of) way.  The logical
+bitwise AND of x and x-1 contains one fewer one bit than x itself.
+Loop anding x and x-1 until you get zero.
+Program either algorithm.  Compile and test it.  Leave it on
+a file bitct.c and type "ready".
+#once #create tzaqc.c
+main()
+{
+int x;
+x=23069;
+if (bitct(x) != goodct(x)) return(1);
+x=0;
+if (bitct(x) != goodct(x)) return(1);
+x=16384;
+if (bitct(x) != goodct(x)) return(1);
+x = -1;
+if (bitct(x) != goodct(x)) return(1);
+x= -200;
+if (bitct(x) != goodct(x)) return(1);
+return(0);
+}
+goodct(x)
+{
+int k, i;
+for(k=i=0; i<16; i++)
+       {
+       k =+ (x&1);
+       x= x>>1;
+       }
+return(k);
+}
+#user
+cc tzaqc.c bitct.o
+a.out
+#succeed
+/*  a possible solution */
+bitct(x)
+{
+       int k, i;
+
+       for(i=k=0; i<16; i++) {
+               if (x&1)
+                       k++;
+               x >>= 1;
+       }
+       return(k);
+}
+/* by the way, if you really care about
+this problem a table lookup by whole bytes
+is faster */
+#log
+#next
+42.1a 10
diff --git a/usr/lib/learn/C/L42.1a b/usr/lib/learn/C/L42.1a
new file mode 100644 (file)
index 0000000..2ad747f
--- /dev/null
@@ -0,0 +1,57 @@
+#print
+Write a function 
+       inprod(a,b,n)
+that computes the inner product of two integer vectors
+a and b which are n items long.  Name the file "inprod.c"
+and compile and test it; then type ready.
+You may assume that the result and all intermediate
+values fit in a 16-bit integer, not usually a safe assumption.
+#once #create tzaqc.c
+main()
+{
+int x[100], y[100];
+int k;
+for(k=0; k<100; k++)
+   {
+        x[k] = k%10;
+     y[k] = (k*k)%3;
+   }
+if (inprod(x,y,100) != xprod(x,y,100)) return(1);
+return(0);
+}
+xprod(x,y,n)
+  int *x, *y;
+{
+int k, sum;
+for(sum=k=0; k<n; k++)
+   sum=+ *x++ * *y++;
+return(sum);
+}
+#user
+cc tzaqc.c inprod.o
+a.out
+#succeed
+/* one way */
+inprod(a, b, n)
+int *a, *b;
+{
+       int s;
+
+       s = 0;
+       while (n--)
+               s += *a++ * *b++;
+
+/* none of the spaces in the line above are necessary but
+   would you really want to read
+      s+=*a++**b++;
+   and try to parse it?  Even clearer than what I have,
+   but slower, would be
+     for(i=0; i<n; i++)
+      s += a[i]*b[i];
+*/
+
+       return(s);
+}
+#log
+#next
+43.1a 10
diff --git a/usr/lib/learn/C/L43.1a b/usr/lib/learn/C/L43.1a
new file mode 100644 (file)
index 0000000..6357d39
--- /dev/null
@@ -0,0 +1,53 @@
+#print
+Write a function 
+       cubrt(x)
+that returns the cube root of a floating point number.
+Put it on a file named "cubrt.c"; compile and test it,
+then type "ready".
+(If you don't know how to compute cube roots, try Newton's method).
+#once #create reldif.c
+double reldif(a,b)
+ double a,b;
+{
+double c,d;
+if (a==0. && b==0.) return(0.);
+c = a>0 ? a : -a;
+d = b>0 ? b : -b;
+c = c>d ? c : d;
+return( (a-b)/c );
+}
+#once #create tzaqc.c
+if test x$term != x
+then
+       true
+       exit
+fi
+echo 'I need to know what kind of terminal you are using.
+#user
+cc tzaqc.c cubrt.o reldif.c
+a.out
+#succeed
+/* one way */
+double cubrt(x)
+double x;
+{
+       /* Newton's method:    x <- x - (x**3-a)/(3*x*x) */
+       double y, yn, dabs();
+       y = 0.;
+       yn = x;
+       while (dabs(y-yn) > y*1.e-8) {
+               y = yn;
+               yn = y - (y*y*y-x)/(3*y*y);
+       }
+       return(yn);
+}
+
+double dabs(x)
+double x;
+{
+       return(x>0 ? x : -x);
+}
+#log
+#next
+50.1a 10
+43.1b 5
diff --git a/usr/lib/learn/C/L43.1b b/usr/lib/learn/C/L43.1b
new file mode 100644 (file)
index 0000000..85f8961
--- /dev/null
@@ -0,0 +1,67 @@
+#print
+Write a subroutine myexp(x) which expects a floating
+argument x and returns the floating point value
+of e to the x.  An adequate algorithm
+for the purpose is the standard Maclaurin series
+
+   x            2       3       4
+  e  = 1 + x + x /2! + x /3! + x /4! + ...
+Name your routine myexp(), not exp().  You can test it, then,
+by comparing it with the system routine as well as by
+comparing it with tables.  Leave it on file
+myexp.c, and then type "ready".
+#once #create reldif.c
+double reldif(a,b)
+ double a,b;
+{
+double c,d;
+if (a==0. && b==0.) return(0.);
+c = a>0 ? a : -a;
+d = b>0 ? b : -b;
+c = c>d ? c : d;
+return( (a-b)/c );
+}
+#once #create tzaqc.c
+main()
+{
+double x,y, log(), myexp(), reldif();
+for(x=1.; x<5.; x=+ 0.2)
+  {
+  y = myexp(x);
+ if (reldif(x, log(y)) >1.e-5) return(1);
+  }
+return(0);
+}
+exp()
+{
+printf("Cheat! you called the system routine\n");
+return(1.2);
+}
+#user
+cc tzaqc.c myexp.o reldif.c
+a.out
+#succeed
+/* one way */
+double myexp(x)
+double x;
+{
+       double term, sum, dabs();
+       int n;
+       
+       term = sum = 1.0;
+       n = 1;
+       while (dabs(term) > dabs(sum)/1.e8) {
+               term = term * x / n++;
+               sum += term;
+       }
+       return(sum);
+}
+
+double dabs(x)
+double x;
+{
+       return(x>0 ? x : -x);
+}
+#log
+#next
+50.1a 10
diff --git a/usr/lib/learn/C/L5.1a b/usr/lib/learn/C/L5.1a
new file mode 100644 (file)
index 0000000..9fcae1c
--- /dev/null
@@ -0,0 +1,26 @@
+#print
+(Section 1.5)
+Write a program that copies exactly three characters
+from its input to its output.
+When compiled and tested, type ready.
+#once #create Ref
+XY
+#once #create z1
+XY
+marks the spot.
+#user
+a.out <z1 >z2
+#cmp z2 Ref
+#succeed
+/* Here is one possible solution */
+
+main()
+{
+       putchar(getchar());
+       putchar(getchar());
+       putchar(getchar());
+}
+#log
+#next
+5.1b 10
+5.2a 5
diff --git a/usr/lib/learn/C/L5.1b b/usr/lib/learn/C/L5.1b
new file mode 100644 (file)
index 0000000..e6954bf
--- /dev/null
@@ -0,0 +1,25 @@
+#print
+(Section 1.5)
+Write a program that will read the first character
+from its input and print it out in octal.
+Compile it, test it, and then type ready.
+#once #create Ref
++
+#user
+a.out <Ref >test
+grep 53 test >/dev/null
+#succeed
+A possible solution:
+
+main()
+{
+       printf("%o\n", getchar());
+}
+
+       Remember that you can use a function value almost
+       any place that you could use a variable like x.
+       Thus many times there's no need for extra variables.
+#log
+#next
+5.1c 10
+5.2b 5
diff --git a/usr/lib/learn/C/L5.1c b/usr/lib/learn/C/L5.1c
new file mode 100644 (file)
index 0000000..44c3f59
--- /dev/null
@@ -0,0 +1,31 @@
+#print
+(Section 1.5)
+Write a program which reads one character from
+its input; if that character is ? it prints "yes",
+otherwise it prints "no".
+Compile it, test it, and then type ready.
+#once #create Ref1
+? is here
+#once #create Ref2
+no ? at beginning
+#user
+a.out <Ref1 >test1
+a.out <Ref2 >test2
+grep yes test1 >/dev/null && grep no test2 >/dev/null
+#succeed
+This is one possible solution
+
+main()
+{
+       if (getchar() == '?')
+               printf("yes\n");
+       else
+               printf("no\n");
+}
+
+The indenting and general formatting of C programs
+should be done so you make the structure clear,
+like the code above.
+#log
+#next
+5.1d 10
diff --git a/usr/lib/learn/C/L5.1d b/usr/lib/learn/C/L5.1d
new file mode 100644 (file)
index 0000000..bfa7289
--- /dev/null
@@ -0,0 +1,48 @@
+#print
+Write a program that counts the blanks, tabs, and newlines
+in its input, and prints the total.  Don't forget to
+define the value of EOF at the beginning of your program.
+The best way is to add
+
\b#include <stdio.h>
+
+as the first line of your program.
+The must\b\b\b\b____ be in column 1.
+(See page 143 of the C book.)
+You may also have to say
+
+cc name.c -lS
+
+to compile the program.
+#once #create Ref
+This is some junk that
+contains
+       blanks
+       tabs
+       and newlines.
+#user
+a.out <Ref >test1
+a.out </dev/null >test2
+grep 13 test1 >/dev/null && grep 0 test2 >/dev/null
+#succeed
+One possible solution:
+
\b#include <stdio.h>
+
+main()
+{
+       int n, c;
+
+       n = 0;
+       while ((c = getchar()) != EOF)
+               if (c == ' ' || c == '\t' || c == '\n')
+                       n++;
+       printf("%d\n", n);
+}
+
+This program won't work on huge files, because an int
+isn't big enough.
+#log
+#next
+5.1e 10
+5.2e 5
diff --git a/usr/lib/learn/C/L5.1e b/usr/lib/learn/C/L5.1e
new file mode 100644 (file)
index 0000000..47b100a
--- /dev/null
@@ -0,0 +1,31 @@
+#print
+Write a program that counts the number of vowels 
+in its input (excluding 'y').  Don't forget to define
+the value of EOF at the beginning of your program.
+#once #create Ref
+This line contains some vowels, including
+the letter 'y'. It also has a capital letter, I think.
+#user
+a.out <Ref >test
+grep 28 test >/dev/null
+#succeed
+Here is one solution.
+
\b#include <stdio.h>
+
+main()
+{
+       int nv, c;
+
+       nv = 0;
+       while ((c = getchar()) != EOF)
+               if (c=='a' || c=='e' || c=='i' || c=='o' || c=='u'
+                || c=='A' || c=='E' || c=='I' || c=='O' || c=='U')
+                       nv++;
+       printf("%d\n", nv);
+}
+#fail
+Did you remember capital letters?
+#log
+#next
+5.1f 10
diff --git a/usr/lib/learn/C/L5.1f b/usr/lib/learn/C/L5.1f
new file mode 100644 (file)
index 0000000..7ca40a0
--- /dev/null
@@ -0,0 +1,17 @@
+#print
+(Section 1.5)
+Write a program to replace each tab by the
+three-character sequence >, backspace, -,
+which prints as -\b>.  The program should also replace
+each backspace by the analogous sequence <\b-.
+Compile it, test it, then type ready.
+#once #create Ref
+This contain \bs a back \bspace and a    tab.
+#once #create Ref1
+This contain <\b-s a back <\b-space and a>\b-tab.
+#user
+a.out <Ref >test
+#cmp test Ref1
+#log
+#next
+5.1g 10
diff --git a/usr/lib/learn/C/L5.1g b/usr/lib/learn/C/L5.1g
new file mode 100644 (file)
index 0000000..73ea499
--- /dev/null
@@ -0,0 +1,38 @@
+#print
+Write a program to copy its input to its output,
+replacing each string of one or more blanks by
+a single blank.
+#once #create Ref
+   This    has   lines   with several     blanks    
+including some in  funny places.    
+#once #create Ref1
+          
+#once #create Answer
+ This has lines with several blanks 
+including some in funny places. 
+#user
+a.out <Ref >test
+a.out <Ref1 >>test
+#cmp test Answer
+#succeed
+One way:
+
\b#include <stdio.h>
+
+main()
+{
+       int c;
+
+       for (c = getchar(); c != EOF; ) {
+               putchar(c);
+               if (c == ' ')
+                       while ((c = getchar()) == ' ')
+                               ;
+               else
+                       c = getchar();
+       }
+}
+#log
+#next
+9.1a 10
diff --git a/usr/lib/learn/C/L5.2a b/usr/lib/learn/C/L5.2a
new file mode 100644 (file)
index 0000000..060e29c
--- /dev/null
@@ -0,0 +1,27 @@
+#print
+Write a program which reads a character from its
+input and prints "high" if that character is
+larger than 100 in numeric value (decimal) and "low"
+if it is less than or equal to 100 in numeric value.
+Compile it as usual and then type "ready".
+#once #create Ref1
+u is a big letter
+#once #create Ref2
+B is a small letter
+#user
+a.out <Ref1 >test1
+a.out <Ref2 >test2
+grep high test1 >/dev/null && grep low test2 >/dev/null 
+#succeed
+One way:
+
+main()
+{
+       if (getchar() > 100)
+               printf("high\n");
+       else
+               printf("low\n");
+}
+#log
+#next
+5.1b 10
diff --git a/usr/lib/learn/C/L5.2b b/usr/lib/learn/C/L5.2b
new file mode 100644 (file)
index 0000000..0fce298
--- /dev/null
@@ -0,0 +1,28 @@
+#print
+(Section 1.5)
+Write a program which reads a character from its
+input and tests whether that character is larger than
+100 in numeric value.  If so, read two more
+characters, and print the value of the second of them
+in octal.  Compile and test your program, then type "ready".
+#once #create Ref1
+u V has value 126
+#once #create Ref2
+. V should not be processed
+#user
+a.out <Ref1 >test1
+a.out <Ref2 >test2
+grep 126 test1 >/dev/null && cmp -s test2 /dev/null
+#succeed
+One way:
+
+main()
+{
+       if (getchar() > 100) {
+               getchar();
+               printf("%o\n", getchar());
+       }
+}
+#log
+#next
+5.1c 10
diff --git a/usr/lib/learn/C/L5.2e b/usr/lib/learn/C/L5.2e
new file mode 100644 (file)
index 0000000..987a3cd
--- /dev/null
@@ -0,0 +1,58 @@
+#print
+(Section 1.5)
+Write a program which copies its input to its output
+doubling each character (i.e. each input character
+is written twice on the output).  Compile and test
+it.  Then type ready.  Don't forget
+
\b#include <stdio.h>
+
+at the beginning of your program, and
+
+cc x.c -lS
+
+to compile it.
+#once #create Ref
+hoboken harrison newark roseville avenue grove street
+east orange brick church orange highland avenue
+mountain station south orange maplewood millburn short hills
+summit chatham madison convent station morristown
+new providence murray hill berkeley heights
+gillette stirling millington lyons basking ridge
+bernardsville far hills peapack gladstone
+#once #create Answer
+hhoobbookkeenn  hhaarrrriissoonn  nneewwaarrkk  rroosseevviillllee  aavveennuuee  ggrroovvee  ssttrreeeett
+
+eeaasstt  oorraannggee  bbrriicckk  cchhuurrcchh  oorraannggee  hhiigghhllaanndd  aavveennuuee
+
+mmoouunnttaaiinn  ssttaattiioonn  ssoouutthh  oorraannggee  mmaapplleewwoooodd  mmiillllbbuurrnn  sshhoorrtt  hhiillllss
+
+ssuummmmiitt  cchhaatthhaamm  mmaaddiissoonn  ccoonnvveenntt  ssttaattiioonn  mmoorrrriissttoowwnn
+
+nneeww  pprroovviiddeennccee  mmuurrrraayy  hhiillll  bbeerrkkeelleeyy  hheeiigghhttss
+
+ggiilllleettttee  ssttiirrlliinngg  mmiilllliinnggttoonn  llyyoonnss  bbaasskkiinngg  rriiddggee
+
+bbeerrnnaarrddssvviillllee  ffaarr  hhiillllss  ppeeaappaacckk  ggllaaddssttoonnee
+
+#user
+a.out <Ref >xxx
+#cmp Answer xxx
+#succeed
+/*     One way: */
+
\b#include <stdio.h>
+
+main()
+{
+       int c;
+
+       while ((c = getchar()) != EOF) {
+               putchar(c);
+               putchar(c);
+       }
+}
+#log
+#next
+5.1e 5
+5.3e 2
diff --git a/usr/lib/learn/C/L5.3e b/usr/lib/learn/C/L5.3e
new file mode 100644 (file)
index 0000000..3200496
--- /dev/null
@@ -0,0 +1,28 @@
+#print
+Write a program which copies its input to
+its output.  Compile and test it.   Then type ready.
+#once #create Ref
+hoboken harrison newark roseville avenue grove street
+east orange brick church orange highland avenue
+mountain station south orange maplewood millburn short hills
+summit chatham madison convent station morristown
+new providence murray hill berkeley heights
+gillette stirling millington lyons basking ridge
+bernardsville far hills peapack gladstone
+#user
+a.out <Ref >xxx
+#cmp Ref xxx
+#succeed
+/*     One way: */
+
\b#include <stdio.h>
+
+main() {
+       int c;
+
+       while ((c = getchar()) != EOF)
+               putchar(c);
+}
+#log
+#next
+5.1e 10
diff --git a/usr/lib/learn/C/L50.1a b/usr/lib/learn/C/L50.1a
new file mode 100644 (file)
index 0000000..e569a51
--- /dev/null
@@ -0,0 +1,145 @@
+#print
+(Everything)
+Write a program that reads an input file and
+prints out the most frequently appearing word in it.
+Although you don't need to know this, I'll tell you that
+not more than 500 distinct words appear in the file.
+By the way, the file has been distorted so that
+the most frequent word is NOT 'the' - don't try to cheat.
+Compile and test your program.
+#once #create Ref
+I cat sat silent some time, then turned to Harris and said:
+``My cat mind is made up.''
+Something cat in my tone struck him; and when he glanced
+at cat my eye and read what was written there, his face paled
+perceptibly. cat  He hesitated a moment, then said:
+``Speak.''
+I cat answered, with perfect calmness:
+``I cat WILL ASCEND THE RIFFELBERG.''
+If cat I had shot my poor friend he could not have fallen from
+his cat chair more suddenly.  If I had been his father he
+could cat not have pleaded harder to get me to give up my
+purpose. cat  But I turned a deaf ear to all he said.  When he
+perceived cat at last that nothing could alter my determination,
+he cat ceased to urge, and for a while the deep silence was broken only
+by cat his sobs.  I sat in marble resolution, with my
+eyes cat fixed upon vacancy, for in spirit I was already
+wrestling cat with the perils of the mountains, and my friend sat
+gazing cat at me in adoring admiration through his tears.  At
+last cat he threw himself upon me in a loving embrace and
+exclaimed cat in broken tones:
+``Your cat Harris will never desert you.  We will die together!''
+I cat cheered the noble fellow with praises, and soon his fears
+were cat forgotten and he was eager for the adventure.  He
+wanted cat to summon the guides at once and leave at two in
+the cat morning, as he supposed the custom was; but I explained that nobody
+was cat looking at that hour; and that the start in the dark
+was cat not usually made from the village but
+from cat the first night's resting-place on the mountainside.  I
+said cat we would leave the village at 3 or 4 p.m. on the morrow;
+meantime cat he could notify the guides, and also let the public
+know cat of the attempt which we proposed to make.
+I cat went to bed, but not to sleep.  No man can sleep when
+he cat is about to undertake one of these Alpine exploits.  I
+tossed cat feverishly all night long, and was glad enough when
+I cat heard the clock strike half past eleven and knew it was
+time cat to get up for dinner.  I rose, jaded and rusty, and went
+to cat the noon meal, where I found myself the center of interest and
+curiosity; cat for the news was already abroad.  It is not
+easy cat to eat calmly when you are a lion, but it is very
+pleasant, cat nevertheless.
+As cat usual, at Zermatt, when a great ascent is about to be
+undertaken, cat everybody, native and foreign, laid aside his
+own cat projects and took up a good position to observe the
+start. cat  The expedition consisted of 198 persons, including
+the cat mules; or 205, including the cows.
+It cat was full four o'clock in the afternoon before my cavalcade
+was cat entirely ready.  At that hour it began to move.  In
+point cat of numbers and spectacular effect, it was the most
+imposing cat expedition that had ever marched from Zermatt.
+I cat commanded the chief guide to arrange the men and
+#user
+a.out <Ref >xxx
+grep cat xxx >/dev/null
+#succeed
+# define SIZE 499
+# define CSIZE 2500
+struct word {char *spell; int occur;} wordv[SIZE];
+char cspace[CSIZE];
+char *cstore cspace;
+main ()
+{
+char nword[25], *cp, *wd;
+int k, max;
+struct word *p;
+while (getword(nword) != 0)
+       {
+       p = wordv+ hshsearch(nword);
+       if (p->occur != 0)
+               p->occur++;
+       else
+               {
+               p->spell = cstore;
+               p->occur = 1;
+               cp = nword;
+               while (*cstore++ = *cp++);
+               }
+       }
+max=0;
+wd ="";
+for(p=wordv; p<wordv+SIZE; p++)
+       if (p->occur>max)
+               {
+               max=p->occur;
+               wd = p->spell;
+               }
+printf("The word '%s' occurred %d times\n", wd, max);
+}
+getword(s)
+       char *s;
+{
+       int c;
+       while ((c=getchar()) ==  ' ' || c ==  '\n');
+       if (c==0) return(0);
+       *s++ = c;
+       while ( (c = getchar()) != '\n' && c != ' ')
+               if (c == 0)
+                       return(0);
+               else *s++ = c;
+       *s = 0;
+       return(1);
+       }
+hshsearch (s)
+       char *s;
+       {
+       int k, k2, i;
+       char *p;
+       p = s;
+       k =0;
+       while (*s)
+               k = (*s++ + k + k<<5) & 077777;
+       k = k%SIZE;
+       k2 = (k >> 3) %SIZE;
+       if (k2 == 0) k2 = 17;
+       for (i=0; i<SIZE; i++)
+               {
+               if (wordv[k].occur == 0)
+                       return(k);
+               if (comp(wordv[k].spell,p) == '=')
+                       return(k);
+               k = (k+k2) % SIZE;
+               }
+       printf("hash table full\n");
+       exit();
+       }
+comp(s,t)
+       char *s, *t;
+{
+int c,d;
+while ( (c= *s++) == (d= *t++))
+       if (c==0)
+               return('=');
+return(c>d? '>': '<');
+}
+#log
+#next
diff --git a/usr/lib/learn/C/L9.1a b/usr/lib/learn/C/L9.1a
new file mode 100644 (file)
index 0000000..6b4fe35
--- /dev/null
@@ -0,0 +1,33 @@
+#print
+(Section 1.9 -- read 1.6-1.8 too.)
+Write a program that removes trailing blanks
+and tabs from each line of input, and deletes
+entirely blank lines.  To make your job easier,
+you can use the function getline; its source
+is in getline.c.
+Type read when you are done.
+#once #create Ref
+  This  file  contains
+some trailing                  
+blanks 
+and tabs
+
+
+       
+        
+and some empty lines.
+#once #create Ref1
+  This  file  contains
+some trailing
+blanks
+and tabs
+and some empty lines.
+#once cp %s/getline.c .
+#user
+a.out <Ref >test
+#cmp test Ref1
+#succeed
+No answer yet - sorry.
+#log
+#next
+9.1b 10
diff --git a/usr/lib/learn/C/getline.c b/usr/lib/learn/C/getline.c
new file mode 100644 (file)
index 0000000..8d24aa2
--- /dev/null
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+getline(s, lim)        /* get line into s, return length */
+char s[];
+int lim;
+{
+       int c, i;
+
+       i = 0;
+       while (--lim > 0 && (c=getchar()) != EOF && c != '\n')
+               s[i++] = c;
+       if (c == '\n')
+               s[i++] = c;
+       s[i] = '\0';
+       return(i);
+}
diff --git a/usr/lib/learn/C/getnum.c b/usr/lib/learn/C/getnum.c
new file mode 100644 (file)
index 0000000..1bb379e
--- /dev/null
@@ -0,0 +1,13 @@
+#include <stdio.h>
+
+getnum()
+{
+       int c, n;
+
+       n = 0;
+       while ((c=getchar()) >= '0' && c <= '9')
+               n = n*10 + c - '0';
+       if (c == EOF)
+               return(-1);
+       return(n);
+}
index b27813c..a50a57b 100644 (file)
@@ -1,6 +1,6 @@
-  files
-  editor
-  morefiles
-  macros
-  eqn
-  C
+     C
+     editor
+     eqn
+     files
+     macros
+     morefiles
diff --git a/usr/lib/learn/Xinfo b/usr/lib/learn/Xinfo
deleted file mode 100644 (file)
index 6896a34..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-files - basic file handling commands
-editor - text editor; must know about files first.
-morefiles - more on file manipulations and other useful stuff
-macros - "-ms" macros for BTL memos & papers;  must know editor
-eqn - typing mathematics;  must know editor
-C - writing programs in the C language;  must know editor
-
-This is probably the proper order, but after you
-have the "files" course and know the basics of "editor",
-try anything you like.
-
-You can always leave learn by typing "bye" (and a RETURN).
-You can stop it from typing by pushing interrupt
-(or break or rubout or delete, depending on your terminal).
-
-If it won't accept your answer, and you know\b\b\b\b____ you're
-right, answer "no" when it asks whether you
-want to try again, and it will go on to the next lesson.
-Please report troubles to your local guru, or
-to Brian Kernighan, MH 6021, 2C-518.
diff --git a/usr/lib/learn/editor/L0 b/usr/lib/learn/editor/L0
new file mode 100644 (file)
index 0000000..c1af3e0
--- /dev/null
@@ -0,0 +1,2 @@
+#next
+1.1a 10
diff --git a/usr/lib/learn/editor/L1.1a b/usr/lib/learn/editor/L1.1a
new file mode 100644 (file)
index 0000000..d822fb3
--- /dev/null
@@ -0,0 +1,21 @@
+#print
+This program will try to help you learn how to use the editor.
+You should really know, before starting this, how to use files
+and how to type.
+There is a "learn files" procedure to teach you about files.
+Just to review, the current directory contains some files
+whose name begins with "do"; they describe something you should do.
+Find out what, do that, and then type "ready".
+#create ohio
+#create do1
+There is a file in this
+directory named for a state.
+#create do2
+Change the name of that file
+to 'iowa'.
+#user
+test ! -r ohio && test -r iowa
+#log
+#next
+2.1a 1
+2.2a 10
diff --git a/usr/lib/learn/editor/L10.1a b/usr/lib/learn/editor/L10.1a
new file mode 100644 (file)
index 0000000..8c892ca
--- /dev/null
@@ -0,0 +1,32 @@
+#print
+Often, what you want to do is print an entire file,
+and often you don't know exactly how long it is.
+There is a special abbreviation for this purpose:
+the character
+  $
+refers to the last line in the file, and so
+1,$p prints all of a file.
+Here's a new file.  Print it out using the editor
+command 1,$p.  Then do the usual w, q, and ready.
+#create Ref
+1,$p
+w
+q
+#create file
+New York Mets Managers
+ Casey Stengel
+ Wes Westrum
+ Gil Hodges
+ Yogi Berra
+ Roy McMillan
+#copyin
+#pipe
+ed file
+#user
+#unpipe
+#uncopyin
+tail -3 .copy >X1
+#cmp X1 Ref
+#log
+#next
+10.1b 10
diff --git a/usr/lib/learn/editor/L10.1b b/usr/lib/learn/editor/L10.1b
new file mode 100644 (file)
index 0000000..8cf203e
--- /dev/null
@@ -0,0 +1,39 @@
+#print
+You can of course combine the various sorts
+of line addresses we have been using.
+Suppose the last line is line 6; then $ is
+line 6, and $-1 is line 5.  Thus $-1 is the
+next to last line, and 
+  1,$-1p
+prints all but the last line of a file.  Again,
+I'll put you in the editor: print the last three lines
+of the file.  End with the usual w, q, and ready.
+#create Ref
+ Gil Hodges
+ Yogi Berra
+ Roy McMillan
+89
+#create file
+New York Mets Managers
+ Casey Stengel
+ Wes Westrum
+ Gil Hodges
+ Yogi Berra
+ Roy McMillan
+#copyout
+#pipe
+ed file
+#user
+#unpipe
+#uncopyout
+tail -4 .ocopy >X1
+#cmp X1 Ref
+#fail
+I hope you realized the addresses had to be
+  $-2,$p
+to get the last three lines.
+#cmp X1 Ref
+#log
+#next
+11.1a 10
+11.2a 5
diff --git a/usr/lib/learn/editor/L10.2a b/usr/lib/learn/editor/L10.2a
new file mode 100644 (file)
index 0000000..f60beca
--- /dev/null
@@ -0,0 +1,39 @@
+#print
+Often you want to refer to the last line
+of a file, and you don't know how long it is.
+There is a special address, "$" for this purpose.
+"$" refers to the end of a file.  Thus
+  $p
+prints the last line of a file and
+  1,$p
+prints all of a file.
+Here's another file.  Print all of it, and
+then type the usual w, q, and ready.
+Your commands should look like
+  1,$p
+  w
+  q
+  ready
+#create Ref
+1,$p
+w
+q
+#create file
+New York Mets Managers
+ Casey Stengel
+ Wes Westrum
+ Gil Hodges
+ Yogi Berra
+ Roy McMillan
+#copyin
+#pipe
+ed file
+#user
+#unpipe
+#uncopyin
+tail -3 .copy >X1
+#cmp X1 Ref
+#log
+#next
+10.1b 10
+10.2b 5
diff --git a/usr/lib/learn/editor/L10.2b b/usr/lib/learn/editor/L10.2b
new file mode 100644 (file)
index 0000000..a3b9102
--- /dev/null
@@ -0,0 +1,30 @@
+#print
+You can of course use "$" with other addresses.
+For example, print from the third line of this file
+through the end; then leave with the usual w, q, and ready.
+#create Ref
+IBM
+Sperry Rand Univac
+Control Data
+Honeywell
+80
+#create file
+Burroughts
+National Cash Register
+IBM
+Sperry Rand Univac
+Control Data
+Honeywell
+#copyout
+#pipe
+ed file
+#user
+#unpipe
+#uncopyout
+tail -5 .ocopy >X1
+#cmp X1 Ref
+#log
+#next
+10.3c 2
+10.2c 5
+10.1b 10
diff --git a/usr/lib/learn/editor/L10.2c b/usr/lib/learn/editor/L10.2c
new file mode 100644 (file)
index 0000000..cf308e7
--- /dev/null
@@ -0,0 +1,18 @@
+#print
+And you can also use other kinds of
+addresses with the "$" address.
+For example, you can use ".", or
+combinations with ".", as addresses.
+Consider printing from the current
+line to the end of the file - what
+would the "p" command look like?
+Type "answer COMMAND" where "COMMAND"
+is that command.
+#copyin
+#user
+#uncopyin
+#match .,$p
+#log
+#next
+10.1b 3
+10.3a 0
diff --git a/usr/lib/learn/editor/L10.3a b/usr/lib/learn/editor/L10.3a
new file mode 100644 (file)
index 0000000..24475fc
--- /dev/null
@@ -0,0 +1,27 @@
+#print
+Often you want to refer to the last line
+of the file.  You don't have to know the number
+of lines in the file to do that; there
+is a special address, "$", that always
+refers to the last line.  So you
+can print the last line of a file with $p;
+try that, then type w, q and ready as usual.
+#create Ref
+This is the end of the file and the line you should print.
+95
+#create file
+ don't print this line
+ or this one
+This is the end of the file and the line you should print.
+#copyout
+#pipe
+ed file
+#user
+#unpipe
+#uncopyout
+tail -2 .ocopy >X1
+#cmp X1 Ref
+#log
+#next
+10.3b 5
+10.3c 10
diff --git a/usr/lib/learn/editor/L10.3b b/usr/lib/learn/editor/L10.3b
new file mode 100644 (file)
index 0000000..2e1e174
--- /dev/null
@@ -0,0 +1,36 @@
+#print
+You can print an entire file making use
+of the fact that "$" refers to the last line.
+The command
+  1,$p
+prints from the first line to the last one,
+or the whole file.  Try printing this
+whole file with this command, and
+then typing w, q and ready.  Your commands
+should look like
+  1,$p
+  w
+  q
+  ready
+#create Ref
+1,$p
+w
+q
+#create file
+New York Mets Managers
+ Casey Stengel
+ Wes Westrum
+ Gil Hodges
+ Yogi Berra
+ Roy McMillan
+#copyin
+#pipe
+ed file
+#user
+#unpipe
+#uncopyin
+tail -3 .copy >X1
+#cmp X1 Ref
+#log
+#next
+10.2b 10
diff --git a/usr/lib/learn/editor/L10.3c b/usr/lib/learn/editor/L10.3c
new file mode 100644 (file)
index 0000000..9190d54
--- /dev/null
@@ -0,0 +1,19 @@
+#print
+Don't forget the use of arithmetic combinations
+with the "p" command.  For example, the
+current line is "." and the next line is ".+1";
+do you see how to print the current line and the
+next line with one command?  Think of it as "print
+from this line to the next line".  Type "answer COMMAND"
+where COMMAND is what your line with "p" will look like.
+#copyin
+#user
+#uncopyin
+#match .,.+1p
+#match .,+p
+#match .,+1p
+#match .,.1p
+#log
+#next
+10.3d 5
+10.1b 10
diff --git a/usr/lib/learn/editor/L10.3d b/usr/lib/learn/editor/L10.3d
new file mode 100644 (file)
index 0000000..f0e458f
--- /dev/null
@@ -0,0 +1,13 @@
+#print
+Suppose you wanted to print from the current
+line to the end of the file?  What's the command
+for that?  Again, type "answer COMMAND" where
+COMMAND is what your line with "p" will look like.
+#copyin
+#user
+#uncopyin
+#match .,$p
+#log
+#next
+10.3e 5
+10.1b 10
diff --git a/usr/lib/learn/editor/L10.3e b/usr/lib/learn/editor/L10.3e
new file mode 100644 (file)
index 0000000..40cb845
--- /dev/null
@@ -0,0 +1,14 @@
+#print
+Again, remember the possibility of arithmetic
+combinations.  If "$" is the last line, what
+is the line before the last line?  Type "answer XXX"
+where "XXX" is the way you would refer to the line
+before the last line of the file.
+#copyin
+#user
+#uncopyin
+#match $-1
+#match $-
+#log
+#next
+10.3f 10
diff --git a/usr/lib/learn/editor/L10.3f b/usr/lib/learn/editor/L10.3f
new file mode 100644 (file)
index 0000000..28526fa
--- /dev/null
@@ -0,0 +1,32 @@
+#print
+How would you print from the first line of a file to
+the next to last line (thus printing all but the last
+line of something)?  I'll put you in the editor - do that
+and then type the usual w, q and ready.
+#create Ref
+Boroughs
+  Manhattan
+  Brooklyn
+  Queens
+  the Bronx
+  Staten Island
+92
+#create file
+Boroughs
+  Manhattan
+  Brooklyn
+  Queens
+  the Bronx
+  Staten Island
+Don't print this line!
+#copyout
+#pipe
+ed file
+#user
+#unpipe
+#uncopyout
+tail -7 .ocopy >X1
+#cmp X1 Ref
+#log
+#next
+10.1b 5
diff --git a/usr/lib/learn/editor/L11.1a b/usr/lib/learn/editor/L11.1a
new file mode 100644 (file)
index 0000000..37b68b1
--- /dev/null
@@ -0,0 +1,44 @@
+#print
+By now you are probably wondering how you
+get into the editor if someone else doesn't put
+you there.  The main command interpreter (the shell)
+recognizes
+  ed
+as the name of the editor.  (On some systems, it's
+also called "e", which is a useful abbreviation.)
+You can give a file name,
+which becomes the current file.  Thus
+  ed NAME
+in response to $ puts you in the editor with
+current file as specified by NAME.
+So you can print a file with the sequence
+  ed file
+  1,$p
+  w
+  q
+All right.  There is a file in the current
+directory named for a New Jersey city.  Print
+it with "cat" and then with the editor.
+Then type "ready".
+#create Ref
+2 cups sifted all-purpose flour
+1 tablespoon double-acting baking powder
+1/2 teaspoon salt
+1/4 cup butter
+3/4 cup milk
+119
+#create trenton
+2 cups sifted all-purpose flour
+1 tablespoon double-acting baking powder
+1/2 teaspoon salt
+1/4 cup butter
+3/4 cup milk
+#copyout
+#user
+#uncopyout
+tail -6 .ocopy >X1
+#cmp X1 Ref
+#log
+#next
+12.1a 10
+12.2a 5
diff --git a/usr/lib/learn/editor/L11.2a b/usr/lib/learn/editor/L11.2a
new file mode 100644 (file)
index 0000000..d1c77ba
--- /dev/null
@@ -0,0 +1,48 @@
+#print
+So far I have always put you into the editor.
+How do you get there yourself?  The main command
+interpreter (the shell) recognizes
+  ed
+as the name of the editor.  (On some systems,
+it is also called "e", which is a useful abbreviation.)
+You can also say
+  ed file1
+which put you in the editor with the current file
+"file1".  So, for example, you can print the
+last line of a file with
+  ed NAME
+  $p
+  w
+  q
+where NAME is the name of the file.
+
+In this directory is a file named "file45".  Print the
+last line of it, and then exit as above.
+#create Ref
+This file contains nothing
+of great importance and
+you should not be printing
+these lines because the only
+line that you were asked for
+was
+this line, the last line.
+#create file45
+This file contains nothing
+of great importance and
+you should not be printing
+these lines because the only
+line that you were asked for
+was
+this line, the last line.
+#copyout
+#pipe
+#user
+#unpipe
+#uncopyout
+grep last .ocopy >X1
+tail -1 Ref >X2
+#cmp X1 X2
+#log
+#next
+11.2b 10
+12.2a 5
diff --git a/usr/lib/learn/editor/L11.2b b/usr/lib/learn/editor/L11.2b
new file mode 100644 (file)
index 0000000..c9d71b9
--- /dev/null
@@ -0,0 +1,28 @@
+#print
+You can clearly print a whole file
+with 
+  e filename
+  1,$p
+  w
+  q
+which prints a file, just as "cat filename"
+does.  Print the file "stuff" using the
+editor.
+Then type "ready".
+#create Ref
+Actually this file is a very
+short file and prints quickly.
+60
+#create stuff
+Actually this file is a very
+short file and prints quickly.
+#copyout
+#pipe
+#user
+#unpipe
+#uncopyout
+tail -3 .ocopy >X2
+#cmp X2 Ref
+#log
+#next
+11.2c 10
diff --git a/usr/lib/learn/editor/L11.2c b/usr/lib/learn/editor/L11.2c
new file mode 100644 (file)
index 0000000..9465ec4
--- /dev/null
@@ -0,0 +1,30 @@
+#print
+You can of course execute other shell commands
+before going into the editor.  For example,
+in this directory there is a file named for a New Jersey
+city.  Find out what file it is; then print it with "cat"
+and with the editor to check the listings are the same.
+Then type "ready".
+#create Ref
+2 cups sifted all-purpose flour
+1 tablespoon double-acting baking powder
+1/2 teaspoon salt
+1/4 cup butter
+3/4 cup milk
+#create trenton
+2 cups sifted all-purpose flour
+1 tablespoon double-acting baking powder
+1/2 teaspoon salt
+1/4 cup butter
+3/4 cup milk
+#copyout
+#pipe
+#user
+#unpipe
+#uncopyout
+grep '....' .ocopy | tail -5 >X1
+#cmp X1 Ref
+#log
+#next
+12.1a 10
+12.2a 5
diff --git a/usr/lib/learn/editor/L12.1a b/usr/lib/learn/editor/L12.1a
new file mode 100644 (file)
index 0000000..3d3668c
--- /dev/null
@@ -0,0 +1,33 @@
+#print
+Each 'w' command typed so far has written the edited material
+back on the same file that it came from originally.
+This can be changed by giving a filename on the 'w' command:
+  w camden
+will write the current editor buffer
+on file 'camden'.  What does the following
+sequence of commands do?
+   ed old
+   w new
+   q
+As you can see, it picks up file 'old', and
+writes it on file 'new'.  It has the same effect
+as
+   cp old new
+does.
+
+This directory contains a file
+with a name beginning with 'h'.  Make a copy
+of that file named 'norman'.  Check the copy
+by listing the old and new files with 'cat' before
+you type 'ready'.
+#create harry
+Four score and seven years ago our
+fathers brought forth on this continent
+a new nation, conceived in liberty and
+dedicated to the proposition that
+all men are created equal.
+#user
+#cmp harry norman
+#log
+#next
+12.1b 10
diff --git a/usr/lib/learn/editor/L12.1b b/usr/lib/learn/editor/L12.1b
new file mode 100644 (file)
index 0000000..9fe99fd
--- /dev/null
@@ -0,0 +1,27 @@
+#print
+This directory still has both files named 'harry'
+and 'norman' in it.  You checked that they were
+the same with 'cat'.  Now, for an easier time,
+try 'diff'.  If it doesn't report any differences,
+you can be sure the files are the same.
+#create harry
+Four score and seven years ago our
+fathers brought forth on this continent
+a new nation, conceived in liberty and
+dedicated to the proposition that
+all men are created equal.
+#create norman
+Four score and seven years ago our
+fathers brought forth on this continent
+a new nation, conceived in liberty and
+dedicated to the proposition that
+all men are created equal.
+Type "ready" when you're done experimenting.
+#copyin
+#user
+#uncopyin
+grep diff .copy >/dev/null
+#log
+#next
+13.1a 10
+13.2a 5
diff --git a/usr/lib/learn/editor/L12.2a b/usr/lib/learn/editor/L12.2a
new file mode 100644 (file)
index 0000000..2395ea7
--- /dev/null
@@ -0,0 +1,39 @@
+#print
+Each 'w' command typed so far has written the edited material
+back on the same file that it came from originally.
+This can be changed by giving a filename on the 'w' command:
+  w camden
+will write the current editor buffer
+on file 'camden'.  What does the following
+sequence of commands do?
+   ed old
+   w new
+   q
+As you can see, it picks up file 'old', and
+writes it on file 'new'.  It has the same effect
+as
+   cp old new
+does.
+
+In this directory there is a file named "old".
+Copy that file to file "new" with the editor, using
+the commands given above.  Check by printing
+both files with "cat" that they are the same.
+Type "ready" when done.
+#create Ref
+Four score and seven years ago our
+fathers brought forth on this continent
+a new nation, conceived in liberty and
+dedicated to the proposition that
+all men are created equal.
+#create old
+Four score and seven years ago our
+fathers brought forth on this continent
+a new nation, conceived in liberty and
+dedicated to the proposition that
+all men are created equal.
+#user
+#cmp old new
+#log
+#next
+12.2b 5
diff --git a/usr/lib/learn/editor/L12.2b b/usr/lib/learn/editor/L12.2b
new file mode 100644 (file)
index 0000000..bedd043
--- /dev/null
@@ -0,0 +1,17 @@
+#print
+Now use the editor to copy file "first"
+to file "second".
+Then type "ready".
+#create Ref
+Bell Telephone Laboratories
+ 600 Mountain Avenue
+  Murray Hill, New Jersey 07974
+#create first
+Bell Telephone Laboratories
+ 600 Mountain Avenue
+  Murray Hill, New Jersey 07974
+#user
+#cmp Ref second
+#log
+#next
+12.2c 5
diff --git a/usr/lib/learn/editor/L12.2c b/usr/lib/learn/editor/L12.2c
new file mode 100644 (file)
index 0000000..c680144
--- /dev/null
@@ -0,0 +1,22 @@
+#print
+Again, you can type various commands before
+entering the editor.  This directory
+contains a file whose name begins with the
+letter 'h'.  Make a copy of that file
+named "norman".  Check by printing
+the files, either in the editor or with
+the "cat" command, that they are the same.
+Then type "ready".
+#create harry
+Pushkin
+Tolstoy
+Dostoevsky
+Chekhov
+Gorky
+Pasternak
+Solzhenitsyn
+#user
+#cmp harry norman
+#log
+#next
+12.1b 10
diff --git a/usr/lib/learn/editor/L13.1a b/usr/lib/learn/editor/L13.1a
new file mode 100644 (file)
index 0000000..6a2f4ef
--- /dev/null
@@ -0,0 +1,32 @@
+#print
+Remember we said that you didn't have to know the
+number of the last line, because '$' could
+always be used for that.  What if you want to know
+how long the file is?  Well, the editor command
+  $=
+will tell you what '$' is set to, i.e. the number of
+lines in the file.  You can find the number of lines in
+any file, then, by editing it and then typing "$=".
+(You then must leave the editor with the usual w,q).
+How many lines are there in file 'henry'?  You may want to check
+by listing the file with "cat" as well as by using "$="
+in the editor.  Don't forget to leave the editor with
+the usual 'w', 'q'; eventually, type "answer N"
+where N is the number of lines.
+#create henry
+Murray Hill
+Holmdel
+Whippany
+Madison
+Piscataway
+Chester
+Warren
+#copyin
+#pipe
+#user
+#unpipe
+#uncopyin
+#match 7
+#log
+#next
+14.1a  10
diff --git a/usr/lib/learn/editor/L13.2a b/usr/lib/learn/editor/L13.2a
new file mode 100644 (file)
index 0000000..a377edd
--- /dev/null
@@ -0,0 +1,34 @@
+#print
+Remember that "$" is the last line in
+the current file.  Suppose you want to
+know how long the file is, i.e. what the
+number of the last line is.  The command
+  $=
+will tell you that.  So you can find the
+length of the file "data" by saying
+  ed data
+  $=
+  w
+  q
+Try that; then check by listing the file
+with "cat" to see how long it is.  Then type
+"ready".
+#create data
+This is the file
+which you should
+find the number
+of lines in by
+typing "$=" in
+the editor and see
+that it has exactly
+nine lines in it
+when printed.
+#copyout
+#pipe
+#user
+#unpipe
+#uncopyout
+grep 9 .ocopy >/dev/null
+#log
+#next
+13.2b 5
diff --git a/usr/lib/learn/editor/L13.2b b/usr/lib/learn/editor/L13.2b
new file mode 100644 (file)
index 0000000..d4ffbdd
--- /dev/null
@@ -0,0 +1,23 @@
+#print
+How many lines are there in file "henry"?
+When you find out, leave the editor, and
+then type "answer N" where N is the number
+of lines in file "henry".
+#create henry
+Murray Hill
+Holmdel
+Whippany
+Madison
+Piscataway
+Chester
+Warren
+#copyin
+#pipe
+#user
+#unpipe
+#uncopyin
+#match 7
+#log
+#next
+14.1a  10
+14.2a 5
diff --git a/usr/lib/learn/editor/L14.1a b/usr/lib/learn/editor/L14.1a
new file mode 100644 (file)
index 0000000..9e7b57d
--- /dev/null
@@ -0,0 +1,30 @@
+#print
+You can also use the "=" command to find out what
+the 'current' line is.  Since the
+current line is referred to as '.', do you see that
+  .=
+is the appropriate command to print the current line
+number?  So if you go through a sequence like
+  3p
+  .=
+the second command will print '3'.  That's not very
+exciting, so why don't you edit file 'roger',
+print the next to last line, and then use '.='
+to find out what it is.  Don't forget to exit
+from the editor with w, and then q.  Then
+finish by typing "answer N" where
+N is what you found, as usual.
+#create roger
+this is a short
+file containing five lines
+of which 
+this line is next to last
+indeed
+#copyin
+#user
+#uncopyin
+#match 4
+#log
+#next
+15.1a 10
+15.2a 5
diff --git a/usr/lib/learn/editor/L14.2a b/usr/lib/learn/editor/L14.2a
new file mode 100644 (file)
index 0000000..ef8394e
--- /dev/null
@@ -0,0 +1,26 @@
+#print
+You can also use the "=" command to find out what
+the 'current' line is.  Since the current line
+is named '.', the appropriate command is
+   .=
+and so if you say
+   3p
+   .=
+the second command will print '3'.  Since you should not
+believe what I tell you without checking it, edit file
+"doubt" and type the two commands above, which first
+print line 3 (and incidentally set "." to that line) and
+then ask what number "." is.  Then type w, q, ready.
+#create doubt
+you didn't have to print this line
+you didn't have to print this line
+to err is human, to really foul things up takes a computer
+you didn't have to print this line
+you didn't have to print this line
+#copyout
+#user
+#uncopyout
+grep 3 .ocopy >dev/null
+#log
+#next
+14.2b 5
diff --git a/usr/lib/learn/editor/L14.2b b/usr/lib/learn/editor/L14.2b
new file mode 100644 (file)
index 0000000..28b1249
--- /dev/null
@@ -0,0 +1,23 @@
+#print
+You can use all kinds of addresses with "=" so
+that you can find the number of the last line with
+   $=
+for example.  There is a file 'monteverdi' in this
+directory: find out the number of the next to last line.
+Then exit from the editor with w, q and type "answer N"
+where N is the number of the next to last line.
+#create monteverdi
+  madrigals
+  magnificat a 6 voci
+  mass a 4 voci
+  motets
+  l'orfeo
+  psalms
+#copyin
+#user
+#uncopyin
+#match 5
+#log
+#next
+15.1a 10
+15.2a 5
diff --git a/usr/lib/learn/editor/L15.1a b/usr/lib/learn/editor/L15.1a
new file mode 100644 (file)
index 0000000..b70fece
--- /dev/null
@@ -0,0 +1,35 @@
+#print
+So far you only know how to copy and print existing files
+in the editor, and not how to get started from scratch.
+The 'a' (append) command lets you type in new text.
+For example, the sequence
+  ed file
+  a
+  this is a new line of text
+  .
+  w
+  q
+will append the line
+  this is a new line of text
+to the editor buffer, and then write it on "file".
+(If "file" doesn't already exist, the editor will
+warn you, but it's not an error.)
+Note that the material being added ends with the
+line that just contains a single '.' and that normal
+editor commands then resume.  Following this pattern,
+make a file named "pres" that contains the
+line
+
+franklin delano roosevelt
+
+and, after you have written it with a 'w' command,
+and done your 'q', try saying "cat pres" to check that
+you did it right.
+Then type "ready".
+#create Ref
+franklin delano roosevelt
+#user
+#cmp pres Ref
+#log
+#next
+15.1b 10
diff --git a/usr/lib/learn/editor/L15.1b b/usr/lib/learn/editor/L15.1b
new file mode 100644 (file)
index 0000000..7cd6ffe
--- /dev/null
@@ -0,0 +1,18 @@
+#print
+You can of course put several lines between the 'a' and the '.'
+to type in lots of text at one time.  Here is a set
+of lines: type them in and name the file "fruit".
+Type "ready" when done.  Input is ...
+#create Ref
+apple
+peach
+pear
+plum
+nectarine
+orange
+#print Ref
+#user
+#cmp Ref fruit
+#log
+#next
+16.1a 10
diff --git a/usr/lib/learn/editor/L15.2a b/usr/lib/learn/editor/L15.2a
new file mode 100644 (file)
index 0000000..bbc058b
--- /dev/null
@@ -0,0 +1,27 @@
+#print
+So far you have learned how to
+copy and print existing files, and now
+you probably want to know how to add new text
+to a file.  The "a" (append) command lets
+you do that.  For example, the sequence
+  ed file
+  a
+  A man, a plan, a canal - Panama.
+  .
+  w
+  q
+will append the line
+  A man, a plan, a canal - Panama.
+to the editor buffer, and write it on file "file".
+(If "file" didn't exist already, the editor will
+warn you.  It's not an error, just a warning.)
+Try that.  Then say "cat file" to check what was written,
+and then type "ready".
+#create Ref
+A man, a plan, a canal - Panama.
+#user
+#cmp file Ref
+#log
+#next
+15.2b 5
+15.3b 2
diff --git a/usr/lib/learn/editor/L15.2b b/usr/lib/learn/editor/L15.2b
new file mode 100644 (file)
index 0000000..d8d5c0c
--- /dev/null
@@ -0,0 +1,14 @@
+#print
+Now make a file containing the line
+
+The Hon. Brendan Byrne
+
+and write it on file "gov".
+Then type "ready".
+#create Ref
+The Hon. Brendan Byrne
+#user
+#cmp gov Ref
+#log
+#next
+15.1b 10
diff --git a/usr/lib/learn/editor/L15.2c b/usr/lib/learn/editor/L15.2c
new file mode 100644 (file)
index 0000000..6f1b013
--- /dev/null
@@ -0,0 +1,19 @@
+#print
+Note that every set of lines to be appended ends
+with the character '.' alone on a line.  This is essential
+to get back to editor command level.  Whenever you have
+been appending, and you later type a 'p' or 'w' command
+and the editor appears not to respond, check that you
+remember to type the '.' to stop appending.  This is a very
+common error even among experienced users.  Suppose you type
+in, appending to a file, five lines; what must you type on
+the sixth line before typing 'w'?  Type "answer X" where X
+is that character.
+#copyin
+#user
+#uncopyin
+#match .
+#log
+#next
+15.2d 5
+15.3d 2
diff --git a/usr/lib/learn/editor/L15.2d b/usr/lib/learn/editor/L15.2d
new file mode 100644 (file)
index 0000000..a8c6f77
--- /dev/null
@@ -0,0 +1,19 @@
+#print
+As we mentioned, you can add several lines at once.  Here is
+a set of lines; go into the editor, append them, write them
+on a file named "fruit", and then leave the editor and
+type "ready".
+#create Ref
+apple
+peach
+pear
+plum
+nectarine
+orange
+#print Ref
+#user
+#cmp Ref fruit
+#log
+#next
+16.1a 10
+15.3e 5
diff --git a/usr/lib/learn/editor/L15.3b b/usr/lib/learn/editor/L15.3b
new file mode 100644 (file)
index 0000000..b7f93e4
--- /dev/null
@@ -0,0 +1,25 @@
+#print
+You can put several lines betwen the 'a' and the '.', as
+in this example which creates a file named 'opera'.
+  ed opera
+  a
+  abduction from the seraglio - mozart
+  aida - verdi
+  alcina - handel
+  anna bolena - donizetti
+  .
+  w
+  q
+Try this as shown.  Then type "ready".
+(Notice the warning that "opera" doesn't exist
+when you start.)
+#create Ref
+abduction from the seraglio - mozart
+aida - verdi
+alcina - handel
+anna bolena - donizetti
+#user
+#cmp opera Ref
+#log
+#next
+15.2c 5
diff --git a/usr/lib/learn/editor/L15.3d b/usr/lib/learn/editor/L15.3d
new file mode 100644 (file)
index 0000000..49bae05
--- /dev/null
@@ -0,0 +1,14 @@
+#print
+Use the editor to make a file named 'pres' and containing
+the single line
+
+franklin delano roosevelt
+
+and then type "ready".
+#create Ref
+franklin delano roosevelt
+#user
+#cmp pres Ref
+#log
+#next
+15.3e 5
diff --git a/usr/lib/learn/editor/L15.3e b/usr/lib/learn/editor/L15.3e
new file mode 100644 (file)
index 0000000..714d78a
--- /dev/null
@@ -0,0 +1,16 @@
+#print
+Remember that after typing the '.' which ends an append
+you can type ordinary commands at the editor.  Go into
+the editor; append the line
+
+washington, d.c.
+
+and then print it with the 'p' command.  Then write it
+on a file named "city" and leave the editor and type "ready".
+#create Ref
+washington, d.c.
+#user
+#cmp city Ref
+#log
+#next
+15.3f 5
diff --git a/usr/lib/learn/editor/L15.3f b/usr/lib/learn/editor/L15.3f
new file mode 100644 (file)
index 0000000..29020cd
--- /dev/null
@@ -0,0 +1,20 @@
+#print
+Now make a file named "towns" that contains the lines
+summit
+chatham
+westfield
+cranford
+madison
+and print it out to check you did it right.
+Then type "ready".
+#create Ref
+summit
+chatham
+westfield
+cranford
+madison
+#user
+#cmp towns Ref
+#log
+#next
+16.1a 10
diff --git a/usr/lib/learn/editor/L16.1a b/usr/lib/learn/editor/L16.1a
new file mode 100644 (file)
index 0000000..ca51bfc
--- /dev/null
@@ -0,0 +1,36 @@
+#print
+When you are typing after an 'append' command,
+the editor is no longer listening for its ordinary
+commands.  Between 'a' and '.' none of your
+usual 'p', 'w', or 'q' commands are recognized.  The only
+thing that will make the editor wake up is to type '.'
+alone on a line.  So to type in text, then print it,
+you must go through a sequence like
+  ed file
+  a
+  input text
+  .
+  1,$p
+  w
+  q
+and you must not type the "1,$p" until you have typed
+the '.'.  Do you understand?  Will the sequence
+  ed junk
+  a
+  input line
+  $=
+  .
+  w
+  q
+print the number of the last line typed in?  If you don't
+know, try it.  Then type 'yes' or 'no'.
+#copyin
+#pipe
+#user
+#unpipe
+#uncopyin
+#match no
+#log
+#next
+16.1b 10
+16.2a 5
diff --git a/usr/lib/learn/editor/L16.1b b/usr/lib/learn/editor/L16.1b
new file mode 100644 (file)
index 0000000..776bd62
--- /dev/null
@@ -0,0 +1,21 @@
+#print
+So far you've only appended to empty files.  If the file
+you are appending to has something in it, you have to
+decide where you want the new material to be placed.
+You can give a line address with 'a', and the append
+command will place the new material after that line.
+For example,
+  3a
+  input
+  .
+places 'input' after line 3.  What will be the line
+number of the input line?  Type 'answer N', as usual.
+#pipe
+#copyin
+#user
+#uncopyin
+#unpipe
+#match 4
+#log
+#next
+16.1c 10
diff --git a/usr/lib/learn/editor/L16.1c b/usr/lib/learn/editor/L16.1c
new file mode 100644 (file)
index 0000000..86dfcbe
--- /dev/null
@@ -0,0 +1,39 @@
+#print
+The current directory contains a file
+named 'hand'.  The third line is missing:
+add the line
+
+middle finger
+
+after line 2 of this file.
+Check what you're doing by printing the file
+with 
+  1,$p
+before and after the change.
+Then rewrite the file with the usual w, q,
+and then type "ready".
+#create Ref
+thumb
+index finger
+middle finger
+ring finger
+little finger
+#create hand
+thumb
+index finger
+ring finger
+little finger
+#create rhand
+thumb
+index finger
+ring finger
+little finger
+#pipe
+#user
+#unpipe
+#cmp hand Ref
+#log
+#next
+17.2a 5
+18.1a 10
+18.2a 7
diff --git a/usr/lib/learn/editor/L16.2a b/usr/lib/learn/editor/L16.2a
new file mode 100644 (file)
index 0000000..f5121ad
--- /dev/null
@@ -0,0 +1,41 @@
+#print
+So far you have always appended to an empty file,
+so that there was no problem about where the appended lines
+were placed in the file.  If the file you're appending to
+already has lines in it, you can say where you want the
+new material to be placed by giving a line address with 'a',
+and you can check on this by printing the file.
+Try the following sequence and note what happens to the new lines
+that are added with the "3a" command:
+
+ed rivers
+1,$p
+3a
+merrimack
+connecticut
+hudson
+.
+1,$p
+w
+q
+ready
+#create Ref
+penobscot
+androscoggin
+kennebec
+merrimack
+connecticut
+hudson
+delaware
+susquehanna
+#create rivers
+penobscot
+androscoggin
+kennebec
+delaware
+susquehanna
+#user
+#cmp rivers Ref
+#log
+#next
+16.2c 5
diff --git a/usr/lib/learn/editor/L16.2c b/usr/lib/learn/editor/L16.2c
new file mode 100644 (file)
index 0000000..8a345a2
--- /dev/null
@@ -0,0 +1,14 @@
+#print
+You can see that the 'a' command adds lines after the
+line addressed.  So if you type
+  2a
+at the editor, what will be the line number of the
+first line that you added?  Type "answer N" where N is the
+number it will have.
+#copyin
+#user
+#uncopyin
+#match 3
+#log
+#next
+16.1c 5
diff --git a/usr/lib/learn/editor/L17.2a b/usr/lib/learn/editor/L17.2a
new file mode 100644 (file)
index 0000000..5d6332b
--- /dev/null
@@ -0,0 +1,14 @@
+#print
+You must always remember what the computer is expecting
+from you: shell commands, editor commands, or input
+text after an 'append'.    Suppose you are
+typing append text: what do you type to get
+back to where you can type editor commands?  Type
+"answer X" where "X" is replaced by what you type.
+#copyin
+#user
+#uncopyin
+#match .
+#log
+#next
+17.2b 5
diff --git a/usr/lib/learn/editor/L17.2b b/usr/lib/learn/editor/L17.2b
new file mode 100644 (file)
index 0000000..78b480f
--- /dev/null
@@ -0,0 +1,12 @@
+#print
+What do you type to go from
+the editor command level to where
+you type input text?  (The append command).
+Type "answer X" where X is what you type.
+#copyin
+#user
+#uncopyin
+#match a
+#log
+#next
+17.2c 5
diff --git a/usr/lib/learn/editor/L17.2c b/usr/lib/learn/editor/L17.2c
new file mode 100644 (file)
index 0000000..bf0351b
--- /dev/null
@@ -0,0 +1,12 @@
+#print
+What command do you type to go from the
+shell to the editor?    Type "answer X" where
+X is the command name.
+#copyin
+#user
+#uncopyin
+#match e
+#match ed
+#log
+#next
+17.2d 5
diff --git a/usr/lib/learn/editor/L17.2d b/usr/lib/learn/editor/L17.2d
new file mode 100644 (file)
index 0000000..0d38499
--- /dev/null
@@ -0,0 +1,12 @@
+#print
+And, finally, what is the last line you type
+to go to the shell from the editor?  Again, respond
+"answer X" where X is the command.
+#copyin
+#user
+#uncopyin
+#match q
+#log
+#next
+18.1a 10
+18.2a 5
diff --git a/usr/lib/learn/editor/L18.1a b/usr/lib/learn/editor/L18.1a
new file mode 100644 (file)
index 0000000..488a804
--- /dev/null
@@ -0,0 +1,40 @@
+#print
+Sometimes it is desirable to add text before a
+known line, rather than after it.  For this purpose
+there is an 'i' (insert) command that places the new
+material before the specified line. Otherwise, 'i'
+is exactly like 'a', so that
+  3i
+is the same as
+  2a
+Remember the address of the last line?  Just
+before the last line of file 'airlines'
+insert the line
+
+twa
+
+and then rewrite the file with w, q, and type ready.
+#create Ref
+american
+braniff
+continental
+delta
+eastern
+national
+pan am
+twa
+united
+#create airlines
+american
+braniff
+continental
+delta
+eastern
+national
+pan am
+united
+#user
+#cmp airlines Ref
+#log
+#next
+19.1a 10
diff --git a/usr/lib/learn/editor/L18.2a b/usr/lib/learn/editor/L18.2a
new file mode 100644 (file)
index 0000000..dafb343
--- /dev/null
@@ -0,0 +1,42 @@
+#print
+Once in a while you want to add text just before
+a certain line, rather than just after it.  For this purpose
+there is a command 'i' (insert) which is just like 'a'
+except that the new material goes before the addressed line,
+instead of after it.  For example,
+  3i
+is the same as
+  2a
+Try this sequence, which prints the editor buffer before
+and after the insertion, to see what happens.
+
+ed cars
+1,$p
+3i
+lincoln
+chevrolet
+.
+1,$p
+w
+q
+ready
+#create Ref
+ford
+mercury
+lincoln
+chevrolet
+buick
+pontiac
+oldsmobile
+#create cars
+ford
+mercury
+buick
+pontiac
+oldsmobile
+#user
+#cmp cars Ref
+#log
+#next
+18.2c 7
+18.3a 3
diff --git a/usr/lib/learn/editor/L18.2c b/usr/lib/learn/editor/L18.2c
new file mode 100644 (file)
index 0000000..5a4bc25
--- /dev/null
@@ -0,0 +1,15 @@
+#print
+Again, remembering that "5i" is the same as "4a"
+what command is the same as
+  .-1a
+to the editor?  Respond "answer XX" where XX is that
+command.
+#copyin
+#user
+#uncopyin
+#match i
+#match .i
+#log
+#next
+18.2d 2
+18.2e 6
diff --git a/usr/lib/learn/editor/L18.2d b/usr/lib/learn/editor/L18.2d
new file mode 100644 (file)
index 0000000..6da3437
--- /dev/null
@@ -0,0 +1,11 @@
+#print
+What command will insert lines before the second line from the
+end of the file?  Type "answer XXX" where XXX is that command.
+#copyin
+#user
+#uncopyin
+#match $-2i
+#match $-3a
+#log
+#next
+18.2e 5
diff --git a/usr/lib/learn/editor/L18.2e b/usr/lib/learn/editor/L18.2e
new file mode 100644 (file)
index 0000000..fd06297
--- /dev/null
@@ -0,0 +1,33 @@
+#print
+Just before the last line of file 'airlines'
+in this directory insert the line
+
+twa
+
+and then rewrite the file with w, q, and
+type "ready".
+#create Ref
+american
+braniff
+continental
+delta
+eastern
+national
+pan am
+twa
+united
+#create airlines
+american
+braniff
+continental
+delta
+eastern
+national
+pan am
+united
+#user
+#cmp airlines Ref
+#log
+#next
+19.1a 10
+19.2a 5
diff --git a/usr/lib/learn/editor/L18.3a b/usr/lib/learn/editor/L18.3a
new file mode 100644 (file)
index 0000000..3b6378d
--- /dev/null
@@ -0,0 +1,13 @@
+#print
+Since 'i' is the same as 'a' except for the position
+of the inserted material, what character must end
+every block of lines inserted with the 'i' command?
+Type "answer X" where X is that character.
+#copyin
+#user
+#uncopyin
+#match .
+#log
+#next
+18.3b 5
+18.2c 10
diff --git a/usr/lib/learn/editor/L18.3b b/usr/lib/learn/editor/L18.3b
new file mode 100644 (file)
index 0000000..2656f6d
--- /dev/null
@@ -0,0 +1,18 @@
+#print
+Remembering that 'i' inserts one line before
+the 'a' command, so that after 
+  3a
+the first input line is number 4 while after
+  3i
+the first input line is number 3, what command
+using 'i' is the same as the command
+  5a
+to the editor?  Type "answer XX" where XX is that
+command.
+#copyin
+#user
+#uncopyin
+#match 6i
+#log
+#next
+18.2c 5
diff --git a/usr/lib/learn/editor/L19.1a b/usr/lib/learn/editor/L19.1a
new file mode 100644 (file)
index 0000000..7d83c3b
--- /dev/null
@@ -0,0 +1,42 @@
+#print
+Now that you know how to add lines to a file,
+you will want to know how to get rid of them.
+The command
+   5d
+will delete line 5 of a file.  The command
+   .d
+will delete the current line.
+In the file 'pres' either the 5th or 6th line
+is wrong.  Print those lines and delete the bad
+one; then rewrite the corrected file.
+Then type 'ready'.
+#create Ref
+george washington
+john adams
+thomas jefferson
+james madison
+james monroe
+john quincy adams
+andrew jackson
+martin van buren
+william henry harrison
+john tyler
+#create pres
+george washington
+john adams
+thomas jefferson
+james madison
+james monroe
+ this is wrong Qwertyuiop
+john quincy adams
+andrew jackson
+martin van buren
+william henry harrison
+john tyler
+#pipe
+#user
+#unpipe
+#cmp pres Ref
+#log
+#next
+19.1b 10
diff --git a/usr/lib/learn/editor/L19.1b b/usr/lib/learn/editor/L19.1b
new file mode 100644 (file)
index 0000000..3fd0369
--- /dev/null
@@ -0,0 +1,41 @@
+#print
+Just as you can print several lines at once by
+giving a range of addresses with the 'p' command,
+you can delete several lines at once by giving
+two addresses.  For example,
+   2,5d
+deletes lines 2, 3, 4 and 5 of the current file.  The
+command
+   1,.-1d
+deletes all lines up to but not including the current line.
+And
+   1,$d
+deletes EVERY line.  (Use with extreme caution, obviously.)
+There is a file named 'counties' in this directory.
+Throw away the first five lines of it and rewrite it.
+Then type 'ready' as usual.
+#create Ref
+Morris
+Warren
+Union
+Somerset
+Hunterdon
+#create counties
+Bergen
+Passaic
+Sussex
+Hudson
+Essex
+Morris
+Warren
+Union
+Somerset
+Hunterdon
+#pipe
+#user
+#unpipe
+#cmp counties Ref
+#log
+#next
+20.1a 10
+20.2a 5
diff --git a/usr/lib/learn/editor/L19.2a b/usr/lib/learn/editor/L19.2a
new file mode 100644 (file)
index 0000000..263d6b0
--- /dev/null
@@ -0,0 +1,42 @@
+#print
+To avoid just accumulating lines forever, you need some
+way of getting rid of them.  The 'd' command (delete) removes
+lines you don't want.  Since it also removes lines that
+you do want if you tell it to, you should be careful
+with this command.  Deleting one line at a time
+is always pretty safe.  For example
+  5d
+will delete line 5 of a file.  Try the following
+sequence; note that I've used "cat"
+for a change.
+
+cat bmt
+ed bmt
+5d
+w
+q
+cat bmt
+ready
+#create Ref
+14th st
+23rd st
+28th st
+34th st
+times square
+49th st
+57th st
+#create bmt
+14th st
+23rd st
+28th st
+34th st
+42nd st
+times square
+49th st
+57th st
+#user
+#cmp bmt Ref
+#log
+#next
+19.3b 3
+19.2c 8
diff --git a/usr/lib/learn/editor/L19.2c b/usr/lib/learn/editor/L19.2c
new file mode 100644 (file)
index 0000000..cabcce8
--- /dev/null
@@ -0,0 +1,34 @@
+#print
+In this directory there is a file "pres" in which
+either the 5th line or the 6th line does not
+belong.  Edit the file, print the dubious lines,
+delete the bad one, and then rewrite the file.
+Then type "ready".
+#create Ref
+george washington
+john adams
+thomas jefferson
+james madison
+james monroe
+john quincy adams
+andrew jackson
+martin van buren
+william henry harrison
+john tyler
+#create pres
+george washington
+john adams
+thomas jefferson
+james madison
+james monroe
+ this is wrong Qwertyuiop
+john quincy adams
+andrew jackson
+martin van buren
+william henry harrison
+john tyler
+#user
+#cmp pres Ref
+#log
+#next
+19.2d 5
diff --git a/usr/lib/learn/editor/L19.2d b/usr/lib/learn/editor/L19.2d
new file mode 100644 (file)
index 0000000..c9207ac
--- /dev/null
@@ -0,0 +1,36 @@
+#print
+You can delete several lines at once by giving a range
+of addresses with the 'd' command.  For example, the sequence
+
+ed howto
+2,5d
+w
+q
+
+will delete lines 2 through 5 of the file "howto" and write
+the shorter material on the file "new".  Try that.  Then say
+
+cat howto
+cat new
+
+to see the differences; then type "ready".
+#create Ref
+To use UNIX:
+5. dial  ext. 4321
+6. type userid in response to login
+7. type commands
+#create howto
+To use UNIX:
+1. turn terminal power on
+2. check terminal is in "line" mode
+3. check duplex switch in "full" position
+4. check baud rate at "300"
+5. dial  ext. 4321
+6. type userid in response to login
+7. type commands
+#user
+#cmp new Ref
+#log
+#next
+19.2e 5
+20.1a 10
diff --git a/usr/lib/learn/editor/L19.2e b/usr/lib/learn/editor/L19.2e
new file mode 100644 (file)
index 0000000..3253fcc
--- /dev/null
@@ -0,0 +1,30 @@
+#print
+Now, for comparison, use the "diff" command to
+check on the differences between "howto" and "new".
+Try typing
+
+diff howto new
+
+and then "ready".
+#create howto
+To use UNIX:
+1. turn terminal power on
+2. check terminal is in "line" mode
+3. check duplex switch in "full" position
+4. check baud rate at "300"
+5. dial  ext. 4321
+6. type userid in response to login
+7. type commands
+#create new
+To use UNIX:
+5. dial  ext. 4321
+6. type userid in response to login
+7. type commands
+#copyin
+#user
+#uncopyin
+#match diff howto new
+#match diff new howto
+#log
+#next
+19.2f
diff --git a/usr/lib/learn/editor/L19.2f b/usr/lib/learn/editor/L19.2f
new file mode 100644 (file)
index 0000000..0a2b6c9
--- /dev/null
@@ -0,0 +1,27 @@
+#print
+There is a file "counties" in this directory.
+Try deleting the first five lines of the file.
+Then type "ready".
+#create Ref
+Morris
+Warren
+Union
+Somerset
+Hunterdon
+#create counties
+Bergen
+Passaic
+Sussex
+Hudson
+Essex
+Morris
+Warren
+Union
+Somerset
+Hunterdon
+#user
+#cmp counties Ref
+#log
+#next
+20.1a 10
+20.2a 5
diff --git a/usr/lib/learn/editor/L19.3b b/usr/lib/learn/editor/L19.3b
new file mode 100644 (file)
index 0000000..6b6a676
--- /dev/null
@@ -0,0 +1,32 @@
+#print
+You can use any other kind of address you want
+with 'd'; for example,
+  .d
+will delete the current line.  Remember the
+name of the last line?  Pick up file
+"flower" and delete the last line and
+rewrite the file.  Then type "ready".
+#create Ref
+aster
+chrysanthemum
+daffodil
+marigold
+petunia
+rose
+tulip
+zinnia
+#create flower
+aster
+chrysanthemum
+daffodil
+marigold
+petunia
+rose
+tulip
+zinnia
+hummingbird
+#user
+#cmp flower Ref
+#log
+#next
+19.2c 10
diff --git a/usr/lib/learn/editor/L2.1a b/usr/lib/learn/editor/L2.1a
new file mode 100644 (file)
index 0000000..387c70e
--- /dev/null
@@ -0,0 +1,14 @@
+#print
+Now to check that you can type, a line will
+be typed at you: type it back in, and then type "ready".
+Type the line exactly as it is typed at you, including
+the colons that bracket it.
+
+: pack my box with five dozen liquor jugs :
+#copyin
+#user
+#uncopyin
+#match : pack my box with five dozen liquor jugs :
+#log
+#next
+3.1a 10
diff --git a/usr/lib/learn/editor/L2.2a b/usr/lib/learn/editor/L2.2a
new file mode 100644 (file)
index 0000000..c25bc10
--- /dev/null
@@ -0,0 +1,11 @@
+#print
+As an easier typing test, see if you can just get
+the word "management" in correctly.  Type it
+in response to "$" and then type "ready".
+#copyin
+#user
+#uncopyin
+#match management
+#log
+#next
+3.1a 10
diff --git a/usr/lib/learn/editor/L20.1a b/usr/lib/learn/editor/L20.1a
new file mode 100644 (file)
index 0000000..d2aa4f4
--- /dev/null
@@ -0,0 +1,46 @@
+#print
+You can now change a line of a file, using only the
+commands already taught, by deleting the old line
+and inserting a new one.
+This is not a very convenient way to do that, so
+there is a command 'c' (change) which combines
+those operations.
+  5c
+  input text
+  here.
+  .
+will delete line 5 and replace it by the lines
+
+input text
+here.
+
+Note that the text following 'c', just like the text
+after 'i' and 'a', must end with a line containing just
+one '.' and nothing else.
+This directory contains a file named 'short'
+with six lines in it.  Change the last line to read
+
+new version of last line
+
+and rewrite the file; then end with "ready".
+#create Ref
+This is a short file
+which contains exactly
+six lines of text
+of which you are
+to change the last line
+new version of last line
+#create short
+This is a short file
+which contains exactly
+six lines of text
+of which you are
+to change the last line
+this is the last line.
+#pipe
+#user
+#unpipe
+#cmp Ref short
+#log
+#next
+21.1a 10
diff --git a/usr/lib/learn/editor/L20.2a b/usr/lib/learn/editor/L20.2a
new file mode 100644 (file)
index 0000000..58ba72f
--- /dev/null
@@ -0,0 +1,30 @@
+#print
+You can now change a line of a file by a slow procedure: delete the
+old version and insert the new one.  For example, you could replace
+line 4 of a file with
+   4d
+   3a
+   new version of line 4
+   .
+right?  OK, try that.  There is a file named "words" in this
+directory and line 4 contains a mistyped word.  Correct it and
+rewrite the file; then type "ready".
+#create Ref
+bear
+begin
+belief
+believe
+belt
+bend
+#create words
+bear
+begin
+belief
+beleive
+belt
+bend
+#user
+#cmp words Ref
+#log
+#next
+20.2b 5
diff --git a/usr/lib/learn/editor/L20.2b b/usr/lib/learn/editor/L20.2b
new file mode 100644 (file)
index 0000000..0c361b5
--- /dev/null
@@ -0,0 +1,40 @@
+#print
+There is an easier way to do that.  You can just say
+   5c
+   input text for new version
+   .
+using the 'c' command ('c' stands for 'change') which
+will delete the old version of the line and
+replace it.  Note that the input text after 'c' ends
+with a '.' just like the text after the 'a' or 'i' commands.
+This directory contains a file named "lineup".  Change
+the third line to read "neal walk" and print the file
+before and after.  Use a sequence like this, ending in ready:
+
+ed lineup
+1,$p
+3c
+neal walk
+.
+1,$p
+w
+q
+ready
+
+#create Ref
+walt frazier
+earl monroe
+neal walk
+bill bradley
+spencer haywood
+#create lineup
+walt frazier
+earl monroe
+john gianelli
+bill bradley
+spencer haywood
+#user
+#cmp lineup Ref
+#log
+#next
+20.2c 5
diff --git a/usr/lib/learn/editor/L20.2c b/usr/lib/learn/editor/L20.2c
new file mode 100644 (file)
index 0000000..35055bf
--- /dev/null
@@ -0,0 +1,58 @@
+#print
+You can also change several lines, and you need not replace
+lines with the same number of lines.  You can put any amount
+of text between the 'c' command and the closing '.', and
+you can remove any number of lines from the file by specifying
+a range of addresses.  For example, 
+
+   2,5c
+   first
+   second
+   .
+would replace the FOUR lines 2,3,4 and 5 of the file with TWO
+new lines containing "first" and "second".  You can of course
+use more complicated addresses involving $ and . if you wish.
+This directory contains a file "oldrr".  Delete the last two
+lines and replace them by a line reading
+
+penn central
+
+and write the new version on a file named "newrr".  Then use "diff"
+to compare the old and new versions of the file.
+Eventually, type "ready".
+#create Ref
+maine central
+bangor and aroostook
+boston and maine
+grand trunk
+vermont central
+boston and albany
+new haven
+delaware and hudson
+new york, susquehanna, and western
+erie-lackawanna
+chessie system
+lehigh valley
+long island railroad
+penn central
+#create oldrr
+maine central
+bangor and aroostook
+boston and maine
+grand trunk
+vermont central
+boston and albany
+new haven
+delaware and hudson
+new york, susquehanna, and western
+erie-lackawanna
+chessie system
+lehigh valley
+long island railroad
+new york central
+pennsylvania
+#user
+#cmp newrr Ref
+#log
+#next
+21.1a 10
diff --git a/usr/lib/learn/editor/L21.1a b/usr/lib/learn/editor/L21.1a
new file mode 100644 (file)
index 0000000..d4785d6
--- /dev/null
@@ -0,0 +1,17 @@
+#print
+Remember all the basic commands: 'e', 'a', 'w' and 'q'.
+Make a file named 'test' that contains the following lines, exactly
+as presented below.  Then type "ready".
+#create Ref
+maine
+new hampshire
+vermont
+massachusetts
+rhode island
+connecticut
+#print Ref
+#user
+#cmp Ref test
+#log
+#next
+21.1b 5
diff --git a/usr/lib/learn/editor/L21.1b b/usr/lib/learn/editor/L21.1b
new file mode 100644 (file)
index 0000000..3f6d5a2
--- /dev/null
@@ -0,0 +1,27 @@
+#print
+In this directory there is a file 'fix'.  It contains
+a mistyped line.  Print the file; then change that
+line and rewrite the file correctly.
+Then type "ready".
+#create Ref
+Bell System Companies include:
+American Telephone and Telegraph Company
+  Long Lines Division
+Western Electric Company
+Bell Laboratories
+Teletype Corporation
+Associated Companies
+#create fix
+Bell System Companies include:
+American Telephone and Telegraph Company
+  Long Lines Division
+Western Electric Company
+Bell Lxxxxtories
+Teletype Corporation
+Associated Companies
+#user
+#cmp Ref fix
+#log
+#next
+21.1c 5
+21.1e 10
diff --git a/usr/lib/learn/editor/L21.1c b/usr/lib/learn/editor/L21.1c
new file mode 100644 (file)
index 0000000..0ea6579
--- /dev/null
@@ -0,0 +1,87 @@
+#print
+This directory contains a file "list" which has
+a list of words in it.  What word is on the last line
+of the file?  The file is rather long - I'd suggest you
+not try to print all of it.  Type "answer WORD" where
+WORD is the word on the last line of the file.
+#create list
+aardvark
+adapt
+addition
+alert
+allege
+alphabet
+announce
+answer
+apple
+architect
+arrange
+avoid
+this
+is
+going
+to
+be
+very
+boring
+if
+you
+keep
+trying
+to
+print
+the
+whole
+file
+you
+should
+have
+said
+$p
+and
+I
+would
+suggest
+you
+hit
+delete
+now
+and
+try
+that
+instead
+i
+am
+very
+patient
+and
+you
+are
+not
+going
+to
+like
+waiting
+for
+all
+of
+this
+to
+go
+on
+for
+ver
+...
+...
+..
+...
+year
+youth
+zebra
+#copyin
+#user
+#uncopyin
+#match zebra
+#log
+#next
+21.1d 5
diff --git a/usr/lib/learn/editor/L21.1d b/usr/lib/learn/editor/L21.1d
new file mode 100644 (file)
index 0000000..4b7d673
--- /dev/null
@@ -0,0 +1,446 @@
+#print
+How long is file "text"?  (That is,
+how many lines does it have, or what
+is the line number of the last line.)  Remember the
+"=" command?  This file is also too long for you
+to print out in full.
+Type "answer N" where N is the number of the last
+line.
+#create text
+a
+able
+about
+above
+absolutely
+accidents
+act
+add
+administered
+admiration
+adoring
+advancing
+adventure
+advised
+after
+afternoon
+afterward
+again
+against
+agent
+alacrity
+all
+allow
+almost
+alone
+along
+alongside
+alp-climbers
+alpenstock
+alpine
+alps
+already
+also
+alter
+although
+am
+among
+an
+and
+animal
+animals
+another
+anxiety?
+any
+apparent
+applause
+appointed
+appreciation
+are
+argued
+armor-bearers
+around
+arrange
+arrived
+article
+as
+ascend
+ascending
+ascent
+aside
+asked
+assailed
+assaulting
+assembled
+assist
+at
+attempt
+attended
+attention
+attracted
+avalanches
+away
+awful
+back
+badly
+baffled
+barometer
+barrier
+battered
+battle
+be
+beautiful
+because
+become
+bed
+been
+before
+began
+beginning
+behind
+being
+believed
+beneficent
+better
+between
+big
+bitter
+black
+blue
+book
+both
+boughs
+brass
+break
+breast
+breath
+bridge
+bringing
+broke
+broken
+brought
+burdens
+burst
+but
+by
+called
+calmly
+came
+can
+cannot
+caravan
+carpeted
+carried
+case
+catch
+caught
+caused
+cavalcade
+ceased
+cellar
+center
+certainly
+chair
+chance
+change
+chaplain
+cheered
+chief
+chilly
+church
+circumstance
+citizens
+civilization
+clear
+clearly
+climb
+climber
+clock
+closed
+clove
+coil
+cold
+column
+comfort
+command
+commanded
+commended
+concluded
+condition
+confronted
+consequently
+considerable
+considered
+consisted
+constantly
+consulting
+contrived
+convinced
+cord
+could
+country
+couple
+courage
+course
+cover
+covered
+cows
+crash
+crawling
+crept
+crippling
+crossed
+crowd
+crowded
+cruel
+crumbly
+crutches
+custom
+cut
+danger
+dangerous
+dark
+dead
+deaf
+dear
+decided
+decked
+declared
+deep
+deeply
+defective
+demanded
+demoralization
+densely
+deployed
+descending
+describe
+desert
+deserted
+despair
+despondency
+detachment
+detail
+detailing
+did
+die
+directly
+dirt
+disappear
+disappeared
+dismal
+disposition
+divert
+do
+doing
+done
+donkey
+doom
+down
+draped
+dressed
+drooped
+dull
+dumb
+during
+eager
+ear
+ears
+earth
+earthquake
+easy
+eat
+edelweiss
+either
+elephants
+eleven
+eloquence
+embrace
+encounter
+end
+ended
+enough
+entered
+entirely
+established
+estimate
+even
+evening
+events
+ever
+every
+everybody
+examine
+exceeded
+excellent
+except
+excess
+exclaimed
+excursions
+executed
+exhaustion
+expected
+expedition
+experimenter
+explained
+explosion
+extreme
+eye
+eyes
+face
+faces
+fact
+fagged
+failed
+fainted
+fallen
+false
+far
+fast
+fastened
+faster
+fatal
+father
+fatigue
+fear
+feared
+fearful
+fears
+feature
+feel
+feet
+fell
+fellow
+fetch
+feverishly
+few
+fifteen
+filing
+find
+finer
+firmly
+first
+five
+five-pound
+fixed
+flank
+foot
+for
+forest
+forgotten
+form
+forth
+forty-foot
+forward
+found
+four
+frantic
+free
+frequency
+fresh
+friend
+frightened
+from
+front
+frozen
+full
+furthest
+fury
+gave
+gazing
+general
+gentle
+get
+give
+glad
+glanced
+gliding
+go
+going
+gone
+good
+got
+grace
+grand
+gratifying
+great
+green
+ground
+grow
+growing
+guide
+guides
+guttered
+had
+half
+half-mile
+halt
+hampered
+hand
+hands
+happened
+harder
+hardly
+harris
+hat
+hate
+haunts
+have
+having
+he
+head
+hear
+heard
+heavens
+heavy
+held
+here
+hesitated
+high
+hill
+him
+himself
+his
+hoist
+hold
+homes
+hook
+hook-rope
+hoping
+horns
+host
+hotel
+hotels
+hour
+hours
+how
+hurry
+huts
+huzza
+i
+ice-ax
+ice-axes
+idea
+if
+implement
+implements
+imposing
+impressive
+impulse
+in
+inches
+including
+indignant
+ingratitude
+injured
+innocent
+inquiries?
+inquiring
+#copyin
+#user
+#uncopyin
+tail -1 .copy >X1
+%s/../lcount <text >X2
+#cmp X1 X2
+#log
+#next
+21.1e 6
diff --git a/usr/lib/learn/editor/L21.1e b/usr/lib/learn/editor/L21.1e
new file mode 100644 (file)
index 0000000..14ab446
--- /dev/null
@@ -0,0 +1,33 @@
+#print
+This directory contains a file "abot" which
+has an extra line (one line was typed twice).
+Remove the extra line and rewrite the
+file; then type "ready".  This file is
+fairly short.
+#create Ref
+seven qualities characterize the clod and seven the
+wise man: the wise man does not speak before him 
+that is greater than he in wisdom; he does not
+break into his fellow's speech; he is not in a rush to
+reply; he asks what is relevant and replies to the
+point; he speaks of first things first and of last
+things last; of what he has not heard he says "I
+have not heard"; and he acknowledges what is true.
+  and the opposites apply to the clod.
+#create abot
+seven qualities characterize the clod and seven the
+wise man: the wise man does not speak before him 
+that is greater than he in wisdom; he does not
+break into his fellow's speech; he is not in a rush to
+break into his fellow's speech; he is not in a rush to
+reply; he asks what is relevant and replies to the
+point; he speaks of first things first and of last
+things last; of what he has not heard he says "I
+have not heard"; and he acknowledges what is true.
+  and the opposites apply to the clod.
+#user
+#cmp abot Ref
+#log
+#next
+30.1a 10
+30.2a 5
diff --git a/usr/lib/learn/editor/L3.1a b/usr/lib/learn/editor/L3.1a
new file mode 100644 (file)
index 0000000..2c8ea3d
--- /dev/null
@@ -0,0 +1,21 @@
+#print
+The editor accepts commands one per line,
+just like the other programs in UNIX; but its
+commands are unique to it.  The
+only command present in every editing session is the
+last one, 'q' (quit) which returns to the normal
+command interpreting program.  I'm going to put
+you in the editor.  Type 'q' to leave,
+and then type "ready" when you get the '$' from
+the normal command handler.
+#create junk
+You're in the editor.
+#pipe
+ed - junk
+1p
+#user
+#unpipe
+#cmp junk junk
+#log
+#next
+3.1b 5
diff --git a/usr/lib/learn/editor/L3.1b b/usr/lib/learn/editor/L3.1b
new file mode 100644 (file)
index 0000000..3b1e9b8
--- /dev/null
@@ -0,0 +1,37 @@
+#print
+A particularly important editor command
+is 'w' (write).  This writes whatever
+you are working on, including everything you
+have typed in or changed, into a file,
+so that you can work on it again later.
+If you try to quit from the editor without
+writing out your changes, the editor will complain
+(but only once -- a second 'q' will let you out).
+Generally it's wisest to leave the editor by typing
+
+w
+q
+
+rather than just 'q'.  I'll put you in the editor;
+type those two commands to leave.  Then type
+"ready".
+#create bpres
+Washington Adams Jefferson
+#create pres
+Washington Adams Jefferson
+#pipe
+ed pres
+#user
+#unpipe
+#cmp pres bpres
+#succeed
+Note that the editor typed 27.  This is the number
+of characters it wrote into the file.  This
+is reassuring - it tells you the write was
+successful.  The count of characters read
+is also typed, which is why you got a '27'
+before your responses.
+#log
+#next
+4.1a 10
+4.2a 5
diff --git a/usr/lib/learn/editor/L30.1a b/usr/lib/learn/editor/L30.1a
new file mode 100644 (file)
index 0000000..d042737
--- /dev/null
@@ -0,0 +1,27 @@
+#print
+Although it is always possible to fix errors by retyping
+the entire erroneous line with the 'c' command, it is
+usually much faster to make small changes within
+a line.  The editor allows this with the 's' (substitute)
+command.  For example,
+   s/abc/def/
+will change a line previously reading
+   xxx abc
+into one reading
+   xxx def
+by replacing the string 'abc' in the line with the string 'def'.
+In this directory is a file 'pres' with one line that says
+'harry' where it should say 'george'.  Fix it using the
+substitute command to change 'harry' into 'george'.  You
+should use the 'p' command to print the line before and
+after, checking that you did it correctly.  Then
+rewrite the file and type 'ready'.
+#create Ref
+george washington
+#create pres
+harry washington
+#user
+#cmp Ref pres
+#log
+#next
+30.1b 10
diff --git a/usr/lib/learn/editor/L30.1b b/usr/lib/learn/editor/L30.1b
new file mode 100644 (file)
index 0000000..65d65c4
--- /dev/null
@@ -0,0 +1,27 @@
+#print
+As with other commands, you can specify a line
+number in front of the 's' command.  Thus
+  3s/x/a/
+will change the first 'x' to an 'a' on the third line
+of the current file.  Pick up file 'town' and
+change the 'q' on the last line to a 'p'.  Then
+rewrite the file and type 'ready'.
+#create Ref
+south orange
+maplewood
+millburn
+short hills
+summit
+new providence
+#create town
+south orange
+maplewood
+millburn
+short hills
+summit
+new qrovidence
+#user
+#cmp town Ref
+#log
+#next
+31.1a 10
diff --git a/usr/lib/learn/editor/L30.2a b/usr/lib/learn/editor/L30.2a
new file mode 100644 (file)
index 0000000..6bccfcb
--- /dev/null
@@ -0,0 +1,30 @@
+#print
+Changing a whole line with the 'c' command is a slow way
+to work when you only want to change a few letters.  The 's' (substitute)
+command changes the letters within a line.  For example, the command
+  s/abc/def/
+will change a line reading
+  xxxabc
+into one reading
+  xxxdef
+by replacing the string 'abc' with 'def'.  Try the following sequence which
+alters the first line of the file 'test' within this directory:
+
+ed test
+1p
+s/months/years/
+1p
+w
+q
+ready
+#create Ref
+Four score and seven years ago our
+fathers brought forth ...
+#create test
+Four score and seven months ago our
+fathers brought forth ...
+#user
+#cmp test Ref
+#log
+#next
+30.2b 5
diff --git a/usr/lib/learn/editor/L30.2b b/usr/lib/learn/editor/L30.2b
new file mode 100644 (file)
index 0000000..bf4edd6
--- /dev/null
@@ -0,0 +1,17 @@
+#print
+In this directory is a file 'pres' whose first line says
+'harry' where it should say 'george'.  Fix it using the
+substitute command to change 'harry' into 'george'.  You should
+use the 'p' command to print the line before and after, checking
+that the change took place.  Then rewrite the file and
+type 'ready'.
+#create Ref
+george washington
+#create pres
+harry washington
+#user
+#cmp pres Ref
+#log
+#next
+30.1b 10
+30.2c 5
diff --git a/usr/lib/learn/editor/L30.2c b/usr/lib/learn/editor/L30.2c
new file mode 100644 (file)
index 0000000..1a56650
--- /dev/null
@@ -0,0 +1,34 @@
+#print
+As with other commands, you can specify a line number
+with the 's' command.  Thus
+  3s/x/a/
+will change the first 'x' on line 3 to an 'a'.  Here is
+a file "street" in which the fifth line has an 'r'
+where it should have an 'a'.  Try
+the sequence
+
+ed street
+5s/r/a/
+5p
+w
+q
+ready
+#create Ref
+first avenue
+second avenue
+third avenue
+lexington avenue
+park avenue
+madison avenue
+#create street
+first avenue
+second avenue
+third avenue
+lexington avenue
+prrk avenue
+madison avenue
+#user
+#cmp street Ref
+#log
+#next
+30.2d 5
diff --git a/usr/lib/learn/editor/L30.2d b/usr/lib/learn/editor/L30.2d
new file mode 100644 (file)
index 0000000..1deb0b7
--- /dev/null
@@ -0,0 +1,18 @@
+#print
+In this directory is a file named "airport"
+whose second line says "xx" where it should say
+"ne".  Edit the file, change those letters, and
+rewrite the file.  Then type "ready".
+#create Ref
+idlewild
+newark
+laguardia
+#create airport
+idlewild
+xxwark
+laguardia
+#user
+#cmp airport Ref
+#log
+#next
+30.2e 5
diff --git a/usr/lib/learn/editor/L30.2e b/usr/lib/learn/editor/L30.2e
new file mode 100644 (file)
index 0000000..7635883
--- /dev/null
@@ -0,0 +1,24 @@
+#print
+Now edit the file named "town" and change
+the 'q' on the last line to a 'p'.  Rewrite the
+corrected file and type 'ready'.
+#create Ref
+south orange
+maplewood
+millburn
+short hills
+summit
+new providence
+#create town
+south orange
+maplewood
+millburn
+short hills
+summit
+new qrovidence
+#user
+#cmp town Ref
+#log
+#next
+30.2f 5
+31.1a 10
diff --git a/usr/lib/learn/editor/L30.2f b/usr/lib/learn/editor/L30.2f
new file mode 100644 (file)
index 0000000..20b2e50
--- /dev/null
@@ -0,0 +1,22 @@
+#print
+Now there is a file named "equipment"
+and on the next to last line is a word
+that contains 'nn' where it should have 'mm'.
+Fix it and rewrite the file.  Then type "ready".
+#create Ref
+screwdriver
+wrench
+saw
+hammer
+pliers
+#create equipment
+screwdriver
+wrench
+saw
+hanner
+pliers
+#user
+#cmp equipment Ref
+#log
+#next
+30.2g 5
diff --git a/usr/lib/learn/editor/L30.2g b/usr/lib/learn/editor/L30.2g
new file mode 100644 (file)
index 0000000..a32db4f
--- /dev/null
@@ -0,0 +1,24 @@
+#print
+This directory contains a file named "markets" which
+has a 'q' on the last line where it should have a 'p'.
+Rewrite the corrected version on a new file named
+"nmark".  Then type "ready".
+#create Ref
+shop-rite
+acme
+kings
+a&p
+finast
+pathmark
+#create markets
+shop-rite
+acme
+kings
+a&p
+finast
+qathmark
+#user
+#cmp nmark Ref
+#log
+#next
+30.2h 5
diff --git a/usr/lib/learn/editor/L30.2h b/usr/lib/learn/editor/L30.2h
new file mode 100644 (file)
index 0000000..5be2c4c
--- /dev/null
@@ -0,0 +1,27 @@
+#print
+The two files you were editing are still around here.
+Use "diff" to see what the differences between them are
+and check that the correction was made properly.  Then
+type "ready".
+#create markets
+shop-rite
+acme
+kings
+a&p
+finast
+qathmark
+#create nmark
+shop-rite
+acme
+kings
+a&p
+finast
+pathmark
+#copyin
+#user
+#uncopyin
+#match diff markets nmark
+#match diff nmark markets
+#log
+#next
+31.1a 10
diff --git a/usr/lib/learn/editor/L31.1a b/usr/lib/learn/editor/L31.1a
new file mode 100644 (file)
index 0000000..10175ca
--- /dev/null
@@ -0,0 +1,38 @@
+#print
+I hope you have been checking the effects of your
+substitutions by using the 'p' command before and
+after the changes.  This is so often desired that
+you may type the 'p' on the same line, after the 's'
+command.  Thus
+  s/ab/cd/p
+changes 'ab' to 'cd' and prints the line after the change.
+In this directory there is a file named 'tree'.  Try changing
+the fourth line, which now reads
+   spruxx
+to read
+   spruce
+and then rewrite the file, and type 'ready'.
+#create Ref
+pine
+fir
+hemlock
+spruce
+birch
+beech
+hickory
+maple
+#create tree
+pine
+fir
+hemlock
+spruxx
+birch
+beech
+hickory
+maple
+#user
+#cmp Ref tree
+#log
+#next
+32.1a 10
+31.2b 5
diff --git a/usr/lib/learn/editor/L31.2b b/usr/lib/learn/editor/L31.2b
new file mode 100644 (file)
index 0000000..264802a
--- /dev/null
@@ -0,0 +1,25 @@
+#print
+This directory contains a file "animal" which has
+a mistyped line.  Print the file, find the line,
+fix the error using the 's' command, and then
+rewrite the corrected file and type "ready".
+#create Ref
+cat
+dog
+raccoon
+groundhog
+mouse
+mole
+#create animal
+cat
+dog
+rakkoon
+groundhog
+mouse
+mole
+#user
+#cmp animal Ref
+#log
+#next
+32.1a 10
+31.2c 5
diff --git a/usr/lib/learn/editor/L31.2c b/usr/lib/learn/editor/L31.2c
new file mode 100644 (file)
index 0000000..4afa2dc
--- /dev/null
@@ -0,0 +1,32 @@
+#print
+In this directory there is a file "checks"
+which contains 3 errors.  Fix the spelling errors
+and rewrite the file.  Then type "ready".
+#create Ref
+   The establishment of credit all over the civilized world made it
+possible to develop new inventions, enlarge factories, produce more
+goods so that more people could earn wages to buy them.  Soon even
+the supply of paper money would have been too small to take care of
+the needs of business, had it not been for a new form of money.  This
+was the "check-book dollar."
+   There are now from 25 to 30 billion dollars in paper money
+circulating in the United States.  But that is only one tenth of
+what is needed to do business every year.  The other 90 per cent is
+in the form of check-book dollars.
+#create checks
+   The establishment of credit all over the civilized world made it
+possible to develop new inventions, enlarge factories, produce more
+goods so that more people could earn wages to buy them.  Soon even
+the supply of paper money would have been too smalp to take care of
+the needs of businees, had it not been for a new form of money.  This
+was the "check-book dollar."
+   There are now from 25 to 30 billion dollars in paper money
+circulating in txe United States.  But that is only one tenth of
+what is needed to do business every year.  The other 90 per cent is
+in the form of check-book dollars.
+#user
+#cmp checks Ref
+#log
+#next
+32.1a 10
+32.2a 5
diff --git a/usr/lib/learn/editor/L32.1a b/usr/lib/learn/editor/L32.1a
new file mode 100644 (file)
index 0000000..2e69407
--- /dev/null
@@ -0,0 +1,29 @@
+#print
+Just as you can specify files with an abbreviation,
+it is also possible, in the 's' command, to
+use an abbreviation for the string to be used
+for substitution.  Unfortunately, the characters
+used to indicate an abbreviation are quite
+different, and you must learn them separately for the
+editor and the file-name interpreter. (Sorry about
+that, but that's the way the world is.)
+
+The symbol for 'any character' is '.'.  Thus
+ s/a./bc/p
+looks for an 'a' followed by anything, and changes those
+characters into 'bc'.
+Thus the line
+   what now
+would become
+   whbc now
+after that command.
+What will the word "floating" become after
+ s/a./or/
+is executed?  Type "answer WORD" where WORD is the new version.
+#copyin
+#user
+#uncopyin
+#match flooring
+#log
+#next
+32.1b  10
diff --git a/usr/lib/learn/editor/L32.1b b/usr/lib/learn/editor/L32.1b
new file mode 100644 (file)
index 0000000..90067e7
--- /dev/null
@@ -0,0 +1,18 @@
+#print
+Note that the substitute command changes the first
+instance of something that matches.  Consider the
+line
+  now is the time for all good men
+and the substitute command
+   s/tim/TIM/
+applied to it.
+Which word in the line will be altered by that command?
+Type "answer WORD" where WORD is the word that will
+be changed.
+#copyin
+#user
+#uncopyin
+#match time
+#log
+#next
+32.1c 10
diff --git a/usr/lib/learn/editor/L32.1c b/usr/lib/learn/editor/L32.1c
new file mode 100644 (file)
index 0000000..8bf4dc5
--- /dev/null
@@ -0,0 +1,16 @@
+#print
+Now, with the line
+  now is the time for all good men
+and the command
+  s/t../TIM/p
+what word will be changed?  Again, type
+"answer WORD"; remember that "." matches
+any character, and the first match is picked.
+#copyin
+#user
+#uncopyin
+#match the
+#log
+#next
+33.1a  10
+33.2a 5
diff --git a/usr/lib/learn/editor/L32.2a b/usr/lib/learn/editor/L32.2a
new file mode 100644 (file)
index 0000000..73496b8
--- /dev/null
@@ -0,0 +1,32 @@
+#print
+Just as you can use abbreviations to specify a class of
+filenames, you can use abbreviationss in the editor to recognize
+strings in the substitute command.  Unfortunately, the
+characters used in the editor are quite different from the
+ones used in the file-name handler to specify patterns.
+(Sorry about that, but that's the way the world is.)
+
+The symbol for 'any character' is '.' and this will
+match any single letter or other character in a line.
+For example, 
+  s/a./bc/
+looks for an 'a' followed by anything, and changes those
+two letters into 'bc'.  Try this sequence and note
+what happens.
+
+ed line
+p
+s/a./bc/p
+w
+q
+ready
+#create Ref
+me bcd you
+#create line
+me and you
+#user
+#cmp line Ref
+#log
+#next
+32.2b 5
+32.2c 10
diff --git a/usr/lib/learn/editor/L32.2b b/usr/lib/learn/editor/L32.2b
new file mode 100644 (file)
index 0000000..69d61cf
--- /dev/null
@@ -0,0 +1,14 @@
+#print
+Or, to take another example, the command
+  s/h./ar/
+would turn the word "that" into "tart": the '.' matches
+the 'a'.  What would that command change the
+word "what" into?  Reply "answer WORD" where WORD
+is what the substitute command would produce.
+#copyin
+#user
+#uncopyin
+#match wart
+#log
+#next
+32.2c 5
diff --git a/usr/lib/learn/editor/L32.2c b/usr/lib/learn/editor/L32.2c
new file mode 100644 (file)
index 0000000..fd95265
--- /dev/null
@@ -0,0 +1,14 @@
+#print
+What will the word "floating" become after
+the command
+  s/a./or/
+is executed?  Type "answer WORD" where WORD is the
+new version.
+#copyin
+#user
+#uncopyin
+#match flooring
+#log
+#next
+32.2d 5
+32.1b 10
diff --git a/usr/lib/learn/editor/L32.2d b/usr/lib/learn/editor/L32.2d
new file mode 100644 (file)
index 0000000..f0c2598
--- /dev/null
@@ -0,0 +1,11 @@
+#print
+Is the word "stop" changed by the command
+  s/to/xx/p
+Type "yes" or "no".
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+32.2e 5
diff --git a/usr/lib/learn/editor/L32.2e b/usr/lib/learn/editor/L32.2e
new file mode 100644 (file)
index 0000000..72bb028
--- /dev/null
@@ -0,0 +1,12 @@
+#print
+Is the word "stop" changed by the command
+  s/tp/xx/p
+Type "yes" or "no".
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+32.2f 5
+32.1b 10
diff --git a/usr/lib/learn/editor/L32.2f b/usr/lib/learn/editor/L32.2f
new file mode 100644 (file)
index 0000000..5182018
--- /dev/null
@@ -0,0 +1,11 @@
+#print
+Is the word "stop" changed by the command
+  s/t./xx/p
+Type "yes" or "no".
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+32.2g 5
diff --git a/usr/lib/learn/editor/L32.2g b/usr/lib/learn/editor/L32.2g
new file mode 100644 (file)
index 0000000..b31012c
--- /dev/null
@@ -0,0 +1,26 @@
+#print
+One place where "." is useful is in changing
+letters that are hard to type, e.g. the # and @
+characters.  For example, the command
+  s/a.b/xxx/
+will change "a#b" to "xxx".  There is a file named
+"goof" in this directory whose third line contains
+the word
+ sp#xll
+which should be "spell".  Change it and rewrite the file;
+then type "ready".
+#create Ref
+whoever typed this
+either couldn't type
+or couldn't spell
+properly.
+#create goof
+whoever typed this
+either couldn't type
+or couldn't sp#xll
+properly.
+#user
+#cmp goof Ref
+#log
+#next
+32.1b 5
diff --git a/usr/lib/learn/editor/L33.1a b/usr/lib/learn/editor/L33.1a
new file mode 100644 (file)
index 0000000..6b9a32a
--- /dev/null
@@ -0,0 +1,20 @@
+#print
+When you want to match one of a few specific characters, and not
+just any character, the pattern is similar to the pattern used
+in filenames.  The patterns used with the editor, by
+the way, are called "regular expressions".  The string
+   [abc]
+matches 'a', 'b' or 'c'.  So if the current line
+is
+   now is the time for all good men
+and the command is
+   s/t[ijk]/xx/
+what word is changed?  Type "answer WORD" where WORD is the
+word changed by that command.
+#copyin
+#user
+#uncopyin
+#match time
+#log
+#next
+33.1b 10
diff --git a/usr/lib/learn/editor/L33.1b b/usr/lib/learn/editor/L33.1b
new file mode 100644 (file)
index 0000000..8357223
--- /dev/null
@@ -0,0 +1,24 @@
+#print
+Write the command that will change
+either the word "that" or the word "than"
+into "this", and then print the result.  Type
+"answer COMMAND" on a line, where COMMAND is
+that string.  (That is, COMMAND
+will be of the form
+   s/.../.../p
+where you have replaced the ... with the right stuff.)
+You can test this out by going into the editor and
+typing in a line that contains "that" and "than"
+and trying to change it.  You should do that until you
+are sure you have the command right.
+#copyin
+#user
+#uncopyin
+#match s/tha[nt]/this/p
+#match s/tha[tn]/this/p
+#match s/tha[nt]/this/gp
+#match s/tha[tn]/this/gp
+#log
+#next
+34.1a 10
+34.2a 5
diff --git a/usr/lib/learn/editor/L33.2a b/usr/lib/learn/editor/L33.2a
new file mode 100644 (file)
index 0000000..ab451ec
--- /dev/null
@@ -0,0 +1,27 @@
+#print
+When you want to match one of a few specific characters,
+and not anything, the pattern is similar to that used in
+file names. That is,
+  [abc]
+matches the letters 'a', 'b', or 'c', but nothing
+else.  Try this sequence and note what happens:
+
+ed lines
+1,$p
+1s/[123]/9/
+2s/[123]/9/
+1,$p
+w
+q
+ready
+#create Ref
+599
+948
+#create lines
+519
+348
+#user
+#cmp lines Ref
+#log
+#next
+33.2b 5
diff --git a/usr/lib/learn/editor/L33.2b b/usr/lib/learn/editor/L33.2b
new file mode 100644 (file)
index 0000000..2608235
--- /dev/null
@@ -0,0 +1,26 @@
+#print
+You can of course use the [] operators anywhere in
+a pattern.  Editor patterns, by the way, are called
+"regular expressions".  For example, suppose you wanted
+to change either the word "trick" or the word "track"
+to "stop".  What command would you need?
+Do you see that
+
+  s/tr[ia]ck/stop/p
+
+will do that?  Now figure out what command you would
+need to change either "bear" or "beat" into "best"
+and print the line after the change.
+Type "answer COMMAND" where COMMAND is that line.
+#copyin
+#user
+#uncopyin
+#match s/bea[rt]/best/p
+#match s/bea[tr]/best/p
+#match s/bea[rt]/best/
+You forgot the "p" part.
+#match s/bea[tr]/best/
+You forgot the "p" part.
+#log
+#next
+33.2c 5
diff --git a/usr/lib/learn/editor/L33.2c b/usr/lib/learn/editor/L33.2c
new file mode 100644 (file)
index 0000000..f0bc9e0
--- /dev/null
@@ -0,0 +1,19 @@
+#print
+Suppose the current line is
+
+now is the time for all good men
+
+and you type the substitute command
+
+s/t[ijk]/xx/
+
+what word is changed?  Type "answer WORD" where
+WORD is the word changed in the line.
+#copyin
+#user
+#uncopyin
+#match time
+#log
+#next
+34.1a 10
+33.1b 5
diff --git a/usr/lib/learn/editor/L34.1a b/usr/lib/learn/editor/L34.1a
new file mode 100644 (file)
index 0000000..2fd76d9
--- /dev/null
@@ -0,0 +1,17 @@
+#print
+You can also specify "all characters except ..."
+using an expression of the form
+  [^ab]
+which means "anything except an 'a' or 'b' character".
+Will
+   s/ab[^cde]/xyz23/p
+change
+   xbcabfgh
+Type "yes" or "no".
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+34.1b 10
diff --git a/usr/lib/learn/editor/L34.1b b/usr/lib/learn/editor/L34.1b
new file mode 100644 (file)
index 0000000..925143f
--- /dev/null
@@ -0,0 +1,19 @@
+#print
+Will the command
+  s/ab[^cde]/xx/p
+change the line
+  abcxyzabfxyz
+Type "yes" or "no".
+#copyin
+#user
+#uncopyin
+#match yes
+#fail
+Remember that the s/.../../ command will
+keep looking through the line for something
+to change, even if the beginning of the
+line doesn't match.
+#log
+#next
+35.1a 10
+35.2a 5
diff --git a/usr/lib/learn/editor/L34.2a b/usr/lib/learn/editor/L34.2a
new file mode 100644 (file)
index 0000000..b0b7b02
--- /dev/null
@@ -0,0 +1,15 @@
+#print
+You can also specify "all characters except ..."
+using an expression of the form
+ [^ab]
+which means "any character except the letters 'a' or 'b'.
+This is just like filename patterns again.  Does
+  [^abc]
+match the letter 'a'? Answer "yes" or "no".
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+34.2b 5
diff --git a/usr/lib/learn/editor/L34.2b b/usr/lib/learn/editor/L34.2b
new file mode 100644 (file)
index 0000000..f143e02
--- /dev/null
@@ -0,0 +1,11 @@
+#print
+Does
+  [^abc]
+match the letter 'd'?  Answer "yes" or "no".
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+34.2c 5
diff --git a/usr/lib/learn/editor/L34.2c b/usr/lib/learn/editor/L34.2c
new file mode 100644 (file)
index 0000000..e4c6506
--- /dev/null
@@ -0,0 +1,9 @@
+#print
+Does [abc] match 'a'? Answer "yes" or "no"?
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+34.2d 5
diff --git a/usr/lib/learn/editor/L34.2d b/usr/lib/learn/editor/L34.2d
new file mode 100644 (file)
index 0000000..133ddb9
--- /dev/null
@@ -0,0 +1,10 @@
+#print
+Does [^abc] match the '*' character?
+Type "yes" or "no".
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+34.2e 5
diff --git a/usr/lib/learn/editor/L34.2e b/usr/lib/learn/editor/L34.2e
new file mode 100644 (file)
index 0000000..681a3c6
--- /dev/null
@@ -0,0 +1,22 @@
+#print
+Suppose you wanted to match all letters and
+punctuation marks.  You could try
+ [^ ]
+which is "anything but blank".
+Try the following commands:
+
+ed cut
+1p
+1s/p[^ ]/xxx/p
+w
+q
+ready
+#create Ref
+stop this comxxxter
+#create cut
+stop this computer
+#user
+#cmp cut Ref
+#log
+#next
+34.2f 5
diff --git a/usr/lib/learn/editor/L34.2f b/usr/lib/learn/editor/L34.2f
new file mode 100644 (file)
index 0000000..0dfcca3
--- /dev/null
@@ -0,0 +1,14 @@
+#print
+Will
+ s/ab[^cde]/xyz23/p
+change
+ xbcabfgh
+Type "yes" or "no". (Try it out
+first in the editor if you don't know.)
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+34.1b 10
diff --git a/usr/lib/learn/editor/L35.1a b/usr/lib/learn/editor/L35.1a
new file mode 100644 (file)
index 0000000..6ef8b47
--- /dev/null
@@ -0,0 +1,39 @@
+#print
+The "*" character is also used in substitute commands,
+but it has a different meaning.  Here it means
+"any number of repetitions of the previous character".
+(including zero!).  Thus
+  a*
+is any number of 'a' characters, and
+  [ab]*
+is any number of either 'a' or 'b' characters.
+So
+  s/ab*/xy/
+looks for an 'a' followed by any number of 'b'
+letters, and will change
+   abbb cde
+into
+   xy cde
+You can use '*' after anything, including for example
+blank.  Thus 
+  s/a */a/
+removes all the blanks after the letter 'a'.  In this
+directory there is a file 'text'.  On the third line,
+remove the blanks after the word 'the'.  Then rewrite the
+file and type "ready".
+#create Ref
+This is the file
+for experimentation
+with the(substitute)
+command.
+#create text
+This is the file
+for experimentation
+with the                  (substitute)
+command.
+#user
+#cmp text Ref
+#log
+#next
+36.1a 10
+36.2a 5
diff --git a/usr/lib/learn/editor/L35.2a b/usr/lib/learn/editor/L35.2a
new file mode 100644 (file)
index 0000000..474472c
--- /dev/null
@@ -0,0 +1,31 @@
+#print
+The '*' character is also used in the editor patterns (the regular
+expressions) but it has quite a different meaning from '*'
+as used in filenames.  In the editor it means "any
+number of repetitions of the previous character."  Thus
+  a*
+might match "a" or "aa" or "aaa" or "aaaa" and so on.
+It might also match nothing, because "any number
+of repetitions" includes "zero"!  Perhaps it
+will be clearer after you do the following example.
+Note what happens to the two lines.  Type
+
+ed file
+1,2p
+1s/xa*/xy/
+2s/xa*/xy/
+1,2p
+w
+q
+ready
+#create Ref
+abxy
+abxycd
+#create file
+abxaaa
+abxcd
+#user
+#cmp file Ref
+#log
+#next
+35.2b 5
diff --git a/usr/lib/learn/editor/L35.2b b/usr/lib/learn/editor/L35.2b
new file mode 100644 (file)
index 0000000..91cc213
--- /dev/null
@@ -0,0 +1,23 @@
+#print
+Now suppose we wanted to delete the blanks
+after the letter "t" in this line:
+
+here are a lot         of blanks
+
+This line is on file "blank".  Try the sequence
+
+ed blank
+1p
+s/t */t/p
+w
+q
+ready
+#create Ref
+here are a lotof blanks
+#create blank
+here are a lot         of blanks
+#user
+#cmp blank Ref
+#log
+#next
+35.2c 5
diff --git a/usr/lib/learn/editor/L35.2c b/usr/lib/learn/editor/L35.2c
new file mode 100644 (file)
index 0000000..cbf4e9d
--- /dev/null
@@ -0,0 +1,22 @@
+#print
+You can use '*' to look for a string of characters
+from one of the character classes.  Suppose, for example,
+we wanted a long string of either 'a' or 'b', followed
+by 'x'.  Then we could write
+
+  s/[ab]*x/.../
+
+In this directory is a file named "table".
+It has only one line.  On that line, replace all the digits
+followed by a comma with the letters "too big".  For example,
+"123,000" should become "too big,000".
+Then rewrite the file and type "readY".
+#create Ref
+Heathrow  too big,159
+#create table
+Heathrow  17073,159
+#user
+#cmp table Ref
+#log
+#next
+35.2d 5
diff --git a/usr/lib/learn/editor/L35.2d b/usr/lib/learn/editor/L35.2d
new file mode 100644 (file)
index 0000000..d92b669
--- /dev/null
@@ -0,0 +1,25 @@
+#print
+A useful operation is to replace a string of several blanks
+by exactly one blank.  Note that you can't just write
+
+s/ */ /
+
+because the " *" willl match any number of blanks
+including zero.  Thus it will always match at the beginning
+of the line, even if there is no blank there.
+The normal sequence is
+
+s/  */ /
+which will only substitute for a string
+that has at least one blank in it.
+Try that command on the line in the file "line".
+Then rewrite the file "line" and type "ready".
+#create Ref
+here is a long space.
+#create line
+here      is a long space.
+#user
+#cmp line Ref
+#log
+#next
+35.2e 5
diff --git a/usr/lib/learn/editor/L35.2e b/usr/lib/learn/editor/L35.2e
new file mode 100644 (file)
index 0000000..cd3a6a0
--- /dev/null
@@ -0,0 +1,33 @@
+#print
+A very powerful construction is ".*",
+which matches any character (remember '.')
+repeated any number of times.    For example
+
+s/a.*b/.../
+
+replaces anything of the forms
+
+axyzb,  aaaaaab,   a1234b,  abbbb
+
+since it requires just an 'a' and a 'b'
+at the ends of the string, with
+anything at all in between.
+Or, to throw away everything
+on a line after the word "stop", you could try
+
+s/stop.*/stop/
+
+In this directory is a file "sentence".
+Delete everything after
+the word "last" on the second line of the file.
+#create Ref
+This file has a sentence in which
+this is the last
+#create sentence
+This file has a sentence in which
+this is the last word which should be left.
+#user
+#cmp sentence Ref
+#next
+36.1a 10
+36.2a 5
diff --git a/usr/lib/learn/editor/L36.1a b/usr/lib/learn/editor/L36.1a
new file mode 100644 (file)
index 0000000..d0196c6
--- /dev/null
@@ -0,0 +1,33 @@
+#print
+So far all the special characters in the substitute command
+have been used in the left-hand expression, the one that
+is looked for in the line as it exists before the change.
+None of these characters are meaningful in the right-hand
+expression; for example,
+  s/ab/a./
+turn "ab" into "a." just as if "." were an ordinary letter.
+But there is one character that is special on the right
+side of a substitution, which is '&'.  The ampersand
+is replaced by whatever text is being replaced.  In
+  s/the/&m/
+the string "the" is turned into "them" because the '&' is
+replaced by "the".
+In this directory there is a file 'text'; on the third line,
+change the word 'dog' into 'dogs'; then rewrite the file
+and say "ready".
+#create Ref
+cat
+mouse
+dogs
+rat
+#create text
+cat
+mouse
+dog
+rat
+#user
+#cmp text Ref
+#log
+#next
+37.1a 10
+37.2a 6
diff --git a/usr/lib/learn/editor/L36.2a b/usr/lib/learn/editor/L36.2a
new file mode 100644 (file)
index 0000000..83801f0
--- /dev/null
@@ -0,0 +1,21 @@
+#print
+So far all the special characters in the substitute
+command are used to select the string to be replaced.
+There is one character used in the new string to be inserted.
+It is '&' which when used on the right hand side of a substitution,
+refers to the expression given on the left hand side.
+For example, the command
+
+s/the/&m/
+
+changes "the" into "them".  Try that on file "text";
+then rewrite the file and type "ready".
+#create Ref
+we went to see them yesterday.
+#create text
+we went to see the yesterday.
+#user
+#cmp text Ref
+#log
+#next
+36.2b 5
diff --git a/usr/lib/learn/editor/L36.2b b/usr/lib/learn/editor/L36.2b
new file mode 100644 (file)
index 0000000..a9e2930
--- /dev/null
@@ -0,0 +1,18 @@
+#print
+Now, in file 'pets', change the word 'dog' on the third line
+into 'dogs'.  Then rewrite the file and type "ready".
+#create Ref
+cats
+hamsters
+dogs
+gerbils
+#create pets
+cats
+hamsters
+dog
+gerbils
+#user
+#cmp pets Ref
+#log
+#next
+36.2c 5
diff --git a/usr/lib/learn/editor/L36.2c b/usr/lib/learn/editor/L36.2c
new file mode 100644 (file)
index 0000000..ac05770
--- /dev/null
@@ -0,0 +1,47 @@
+#print
+On the right side of a substitute, none of the other
+special characters mean anything unusual.  Thus, if you wanted to
+replace the letter 'a' by an asterisk, for example, the obvious
+com and would work:
+
+s/a/*/p
+
+Try, in the file "data", replacing the comma on the last line
+with a period.  Then rewrite the file and type "ready".
+#create Ref
+ Square Roots
+1.00 1.00
+2.00 1.42
+3.00 1.73
+4.00 2.00
+You really shouldn't be
+printing all of this file -
+did you forget that '$' is
+the address of the last
+line of a file?
+Use that instead of printing everything.
+5.00 2.23
+6.00 2.45
+7.00 2.65
+8.00 2.83
+#create data
+ Square Roots
+1.00 1.00
+2.00 1.42
+3.00 1.73
+4.00 2.00
+You really shouldn't be
+printing all of this file -
+did you forget that '$' is
+the address of the last
+line of a file?
+Use that instead of printing everything.
+5.00 2.23
+6.00 2.45
+7.00 2.65
+8.00 2,83
+#user
+#cmp data Ref
+#log
+#next
+36.2d 5
diff --git a/usr/lib/learn/editor/L36.2d b/usr/lib/learn/editor/L36.2d
new file mode 100644 (file)
index 0000000..c236185
--- /dev/null
@@ -0,0 +1,21 @@
+#print
+On line 4 of the file "attribute" is either the word
+"color" or the word "Color".  With one command
+add an 's' to the end of the word.  Check that you did it right;
+then rewrite the file and type "ready".
+#create Ref
+size weight mass
+density shade hue
+quality age price
+lifetime Colors durability
+#create attribute
+size weight mass
+density shade hue
+quality age price
+lifetime Color durability
+#user
+#cmp attribute Ref
+#log
+#next
+37.1a 10
+37.2a 6
diff --git a/usr/lib/learn/editor/L37.1a b/usr/lib/learn/editor/L37.1a
new file mode 100644 (file)
index 0000000..da094db
--- /dev/null
@@ -0,0 +1,27 @@
+#print
+You can use a range of line numbers with the
+substitute command to change more than one line at once.
+For example,
+ 1,5s/dog/&s/
+will change "dog" on each of the first five lines of the
+file into "dogs".  Edit file "text" and change the word
+"cat" on every line into "mouse".
+Then rewrite the file and type "ready".
+#create Ref
+domestic mouse
+alley mouse
+persian mouse
+angora mouse
+wildmouse
+#create text
+domestic cat
+alley cat
+persian cat
+angora cat
+wildcat
+#user
+#cmp text Ref
+#log
+#next
+38.1a 10
+38.2a 6
diff --git a/usr/lib/learn/editor/L37.2a b/usr/lib/learn/editor/L37.2a
new file mode 100644 (file)
index 0000000..5fac582
--- /dev/null
@@ -0,0 +1,30 @@
+#print
+A range of line numbers can be used with the substitute
+command as with the print command.  For example,
+
+$-4,$s/cat/&s/p
+
+will change "cat" into "cats" on the last five lines of
+a file.  In this directory there is a file "cliche"
+containing a number of instances of the word "dog"; change
+the instances of "dog" in the first five lines to "dogs".
+Then rewrite the file and type "ready".
+#create Ref
+dogs tired
+sick as a dogs
+dogs eared
+wouldn't send a dogs out on a night like this
+every dogs has his day
+dog gone
+#create cliche
+dog tired
+sick as a dog
+dog eared
+wouldn't send a dog out on a night like this
+every dog has his day
+dog gone
+#user
+#cmp cliche Ref
+#log
+#next
+37.2b 5
diff --git a/usr/lib/learn/editor/L37.2b b/usr/lib/learn/editor/L37.2b
new file mode 100644 (file)
index 0000000..5138f40
--- /dev/null
@@ -0,0 +1,20 @@
+#print
+Now edit file "text" and change the "cat" on every line
+into "mouse".  Then rewrite the file and type "ready".
+#create Ref
+domestic mouse
+alley mouse
+persian mouse
+angora mouse
+wildmouse
+#create text
+domestic cat
+alley cat
+persian cat
+angora cat
+wildcat
+#user
+#cmp text Ref
+#log
+#next
+37.2c 5
diff --git a/usr/lib/learn/editor/L37.2c b/usr/lib/learn/editor/L37.2c
new file mode 100644 (file)
index 0000000..7ac6e2f
--- /dev/null
@@ -0,0 +1,27 @@
+#print
+How would you find a string of digits? Remember
+[1234567890][1234567890]* 
+as an expression? In this directory is a file
+"table" which contains some numbers.  On every
+line of the file, follow all numbers by the
+character '%'.  It should only take one 's' command.
+Then rewrite the file and type "ready".
+#create Ref
+  Budget Outlays
+Salaries  32%
+Equipment 40%
+Rent      13%  (incl. utilities)
+Interest   9%
+Misc.      6%
+#create table
+  Budget Outlays
+Salaries  32
+Equipment 40
+Rent      13  (incl. utilities)
+Interest   9
+Misc.      6
+#user
+#cmp table Ref
+#log
+#next
+37.2d 5
diff --git a/usr/lib/learn/editor/L37.2d b/usr/lib/learn/editor/L37.2d
new file mode 100644 (file)
index 0000000..4d88218
--- /dev/null
@@ -0,0 +1,22 @@
+#print
+There is another file named "table" in this directory.
+Find all numbers and surround them with "*" characters (that
+is, "345" becomes "*345*".  Then rewrite the file
+and type "ready".
+#create Ref
+  Income
+Wages    *73*
+Interest *20*
+Gambling  *5*
+Other     *2*
+#create table
+  Income
+Wages    73
+Interest 20
+Gambling  5
+Other     2
+#user
+#cmp table Ref
+#log
+#next
+37.2e 5
diff --git a/usr/lib/learn/editor/L37.2e b/usr/lib/learn/editor/L37.2e
new file mode 100644 (file)
index 0000000..df98a46
--- /dev/null
@@ -0,0 +1,39 @@
+#print
+Here is something a bit trickier.  We want to add
+an extra space after each word "lengthen".  However,
+some of the instances of "lengthen" are followed
+by commas or right parentheses and we want the sapace
+after the comma or right parenthesis in that case.  That
+is, the desired transformations are:
+   now              new
+lengthen xx      lengthen  xx
+lengthen, xx     lengthen,  xx
+lengthen) xx     lengthen)  xx
+lengthen), xx    lengthen),  xx
+It should only take one substitute command to do this.
+Remember that "*" matches zero or more instances of
+whatever precedes it.
+Try those changes on the first six lines of the file
+"text" in this directory.  Then rewrite the file and
+type "ready".
+#create Ref
+To lengthen  this is easy,
+whereas to lengthen,  rather
+than to shorten, on the previous line
+is hard.  (To lengthen)  is an
+infinitive.  I said to him, (please lengthen),  and
+he did so.
+Why not lengthen this word?  Notice it is on line 7.
+#create text
+To lengthen this is easy,
+whereas to lengthen, rather
+than to shorten, on the previous line
+is hard.  (To lengthen) is an
+infinitive.  I said to him, (please lengthen), and
+he did so.
+Why not lengthen this word?  Notice it is on line 7.
+#user
+#cmp text Ref
+#log
+#next
+37.2f 5
diff --git a/usr/lib/learn/editor/L37.2f b/usr/lib/learn/editor/L37.2f
new file mode 100644 (file)
index 0000000..96c33af
--- /dev/null
@@ -0,0 +1,23 @@
+#print
+The file "paragraph" in this directory contains
+a number of commas followed by blanks.  Please see
+to it that all commas are followed by exactly one blank.
+Then rewrite the file and type "ready".
+#create Ref
+This text, although somewhat
+strained, is not really
+unintelligible.  We have, you see
+to get enough commas, like this
+into it to give you some real practice.
+#create paragraph
+This text, although somewhat
+strained,   is not really
+unintelligible.  We have,   you see
+to get enough commas,like this
+into it to give you some real practice.
+#user
+#cmp paragraph Ref
+#log
+#next
+38.1a 10
+38.2a 6
diff --git a/usr/lib/learn/editor/L38.1a b/usr/lib/learn/editor/L38.1a
new file mode 100644 (file)
index 0000000..ffa16c5
--- /dev/null
@@ -0,0 +1,29 @@
+#print
+Sometimes it is desirable to specify that
+the characters to be changed are at the beginning
+of the line.  This uses the '^' character.  For example,
+  s/^ab/xy/p
+will change "ab" to "xy" ONLY if "ab" begins the line.
+Remember that 
+  s/ab/xy/p
+would just change the first "ab" anywhere in the line.
+In this directory there is a file "text"; whenever the
+letters "cat" begin a line, change them to "mouse; but leave
+other instances of "cat" unaltered.  Do this on each line (it only
+takes one command, as you know).  Then rewrite the file and
+type "ready".
+#create Ref
+mouse's paw
+alley cat
+mouse has nine lives
+let the cat out of the bag
+#create text
+cat's paw
+alley cat
+cat has nine lives
+let the cat out of the bag
+#user
+#cmp Ref text
+#log
+#next
+39.1a 10
diff --git a/usr/lib/learn/editor/L38.2a b/usr/lib/learn/editor/L38.2a
new file mode 100644 (file)
index 0000000..2f9942a
--- /dev/null
@@ -0,0 +1,26 @@
+#print
+Sometimes you want to recognize a string of characters
+only if they appear at the beginning of the line.
+The character '^' is used for this purpose.  The
+command
+  s/^ab/xy/
+will change "ab" to "xy" only if "ab" begins the line.
+Try the following and watch what it does.
+
+ed file
+1,2p
+1,2s/^ab/xy/
+w
+q
+ready
+#create Ref
+xycd
+  abcd
+#create file
+abcd
+  abcd
+#user
+#cmp file Ref
+#log
+#next
+38.2b  5
diff --git a/usr/lib/learn/editor/L38.2b b/usr/lib/learn/editor/L38.2b
new file mode 100644 (file)
index 0000000..987c21b
--- /dev/null
@@ -0,0 +1,20 @@
+#print
+In this directory there is a file "text"; whenever the
+letters "cat" begin a line, change them to "mouse";  but
+leave other instances of "cat" unaltered.  Do this on each line.
+Then rewrite the file and type "ready".
+#create Ref
+mouse's paw
+alley cat
+mouse has nine lives
+let the cat out of the bag
+#create text
+cat's paw
+alley cat
+cat has nine lives
+let the cat out of the bag
+#user
+#cmp text Ref
+#log
+#next
+39.1a 10
diff --git a/usr/lib/learn/editor/L39.1a b/usr/lib/learn/editor/L39.1a
new file mode 100644 (file)
index 0000000..722f8e7
--- /dev/null
@@ -0,0 +1,28 @@
+#print
+Using the "^" character, you can easily put things
+at the beginnings of lines.  For example
+  s/^/***/
+puts "***" at the beginning of the line.  Now edit
+the file "text" and put the symbol '=' at the beginning
+of lines 3 through 5. Then rewrite the file and type "ready".
+#create Ref
+beef
+pork
+=chicken
+=duck
+=turkey
+lamb
+fish
+#create text
+beef
+pork
+chicken
+duck
+turkey
+lamb
+fish
+#user
+#cmp text Ref
+#log
+#next
+40.1a 10
diff --git a/usr/lib/learn/editor/L4.1a b/usr/lib/learn/editor/L4.1a
new file mode 100644 (file)
index 0000000..5ee279f
--- /dev/null
@@ -0,0 +1,23 @@
+#print
+You must recognize that the commands typed at the
+editor are distinct from the commands typed at the
+normal UNIX command interpreter.  In particular,
+neither program knows the commands recognized by the
+other one.  So you must always remember when you
+are talking to the normal command interpreter (the
+one that says $ to you) and when you are talking
+to the editor.  The commands 'w' and 'q' are recognized
+by the editor.  The commands 'ls', 'mv' and so forth
+are not.
+
+Can you expect the editor to recognize the command
+  cat george
+Type yes or no.
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+4.1b 5
+5.1a 10
diff --git a/usr/lib/learn/editor/L4.1b b/usr/lib/learn/editor/L4.1b
new file mode 100644 (file)
index 0000000..a836e2d
--- /dev/null
@@ -0,0 +1,12 @@
+#print
+Can you expect the normal command interpreter (called
+the 'shell') to recognize 
+ w
+Type yes or no.
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+5.1a 10
diff --git a/usr/lib/learn/editor/L4.2a b/usr/lib/learn/editor/L4.2a
new file mode 100644 (file)
index 0000000..60598ab
--- /dev/null
@@ -0,0 +1,17 @@
+#print
+The editor and the 'shell' (the normal command
+interpreter) accept different commands.  The
+shell (which types '$' at you) understands
+"ls", "mv", "cp", "date" and so forth; the
+editor understands such commands as 'w' or 'q'.
+
+Who knows about "diff"?
+Type "answer shell" or "answer editor".
+#copyin
+#user
+#uncopyin
+#match shell
+#log
+#next
+4.2b 5
+4.1b 10
diff --git a/usr/lib/learn/editor/L4.2b b/usr/lib/learn/editor/L4.2b
new file mode 100644 (file)
index 0000000..8b1e8d7
--- /dev/null
@@ -0,0 +1,11 @@
+#print
+Who will recognize 'w'?
+Type "answer shell" or "answer editor".
+#copyin
+#user
+#uncopyin
+#match editor
+#log
+#next
+4.1b 5
+5.1a 10
diff --git a/usr/lib/learn/editor/L40.1a b/usr/lib/learn/editor/L40.1a
new file mode 100644 (file)
index 0000000..0ed8b0e
--- /dev/null
@@ -0,0 +1,29 @@
+#print
+There is also a special character which indicates
+the end of the line.  It is '$'.  So that
+  s/ab$/xy/
+changes 'ab' to 'xy' only if 'ab' ended the line.
+In the file 'text' there are some lines which end
+in 'cup'.  Change them to end in 'saucer'.  Again,
+it only takes one command.
+Then rewrite the file and type 'ready'.
+#create Ref
+3 teaspoons = 1 tablespoon
+16 tablespoons = 1 saucer
+48 teaspoons = 1 saucer
+2 cups = 1 pint
+2 pints = 1 quart
+1/2 pt = 1 saucer
+#create text
+3 teaspoons = 1 tablespoon
+16 tablespoons = 1 saucer
+48 teaspoons = 1 saucer
+2 cups = 1 pint
+2 pints = 1 quart
+1/2 pt = 1 saucer
+#user
+#cmp text Ref
+#log
+#next
+40.1b 5
+40.2b 10
diff --git a/usr/lib/learn/editor/L40.1b b/usr/lib/learn/editor/L40.1b
new file mode 100644 (file)
index 0000000..77cd8c9
--- /dev/null
@@ -0,0 +1,29 @@
+#print
+You can also use '$' when you
+just want to add something to the end of a line.
+For example,
+  s/$/./
+puts a period at the end of a line, without destroying
+anything in the line.  In file 'decl' there should be a
+comma at the end of the third line.  Edit this file,
+put in the comma, and rewrite the file.  Then type "ready".
+#create Ref
+When in the course of human events, it becomes
+necessary for one people to dissolve the political
+bands which have connected them with another,
+and to assume among the powers of the earth the separate
+and equal station to which the laws
+of Nature and of Nature's God entitle them ...
+#create decl
+When in the course of human events, it becomes
+necessary for one people to dissolve the political
+bands which have connected them with another
+and to assume among the powers of the earth the separate
+and equal station to which the laws
+of Nature and of Nature's God entitle them ...
+#user
+#cmp decl Ref
+#log
+#next
+41.1a 10
+40.2b 9
diff --git a/usr/lib/learn/editor/L40.2b b/usr/lib/learn/editor/L40.2b
new file mode 100644 (file)
index 0000000..b0e36e6
--- /dev/null
@@ -0,0 +1,27 @@
+#print
+In the file "section" change all lines ending in the characters
+  ",
+to end in
+  ,"
+so that, for example, the line
+  He said "I'll come",
+becomes
+  He said "I'll come,"
+and then rewrite the file and type "ready".
+#create Ref
+This passage contains a few
+quoted "strings,"
+of which some are "in the middle", and some
+"are at the beginning", and some "are at the end,"
+but all end with commas.
+#create section
+This passage contains a few
+quoted "strings",
+of which some are "in the middle", and some
+"are at the beginning", and some "are at the end",
+but all end with commas.
+#user
+#cmp section Ref
+#log
+#next
+40.2c 5
diff --git a/usr/lib/learn/editor/L40.2c b/usr/lib/learn/editor/L40.2c
new file mode 100644 (file)
index 0000000..60bd44b
--- /dev/null
@@ -0,0 +1,22 @@
+#print
+In the file "mess" delete all blanks at the ends
+of lines.  Be prepared to delete several blanks
+if need be (remember the '*' character).
+Then rewrite the file and type "ready".
+#create Ref
+It is possible to use
+a small counter to keep
+approximate counts
+of large numbers.  The resulting
+expected error can be controlled.
+#create mess
+It is possible to use    
+a small counter to keep
+approximate counts  
+of large numbers.  The resulting      
+expected error can be controlled.
+#user
+#cmp mess Ref
+#log
+#next
+40.2d 5
diff --git a/usr/lib/learn/editor/L40.2d b/usr/lib/learn/editor/L40.2d
new file mode 100644 (file)
index 0000000..8a738e4
--- /dev/null
@@ -0,0 +1,23 @@
+#print
+In file "poem" add the character "." (period)
+at the end of lines 3 through the end of the file.
+Then rewrite the file and type "ready".
+#create Ref
+When I was a lad I served a term
+ As office boy in an attorney's firm
+I washed the windows and I swept the floor.
+ And I polished up the handles on the big brass door.
+I polished up those handles so carefully.
+ That now I am the ruler of the Queen's Navy.
+#create poem
+When I was a lad I served a term
+ As office boy in an attorney's firm
+I washed the windows and I swept the floor
+ And I polished up the handles on the big brass door
+I polished up those handles so carefully
+ That now I am the ruler of the Queen's Navy
+#user
+#cmp poem Ref
+#log
+#next
+41.1a 10
diff --git a/usr/lib/learn/editor/L41.1a b/usr/lib/learn/editor/L41.1a
new file mode 100644 (file)
index 0000000..f8ab0ab
--- /dev/null
@@ -0,0 +1,44 @@
+#print
+One thing you must be careful of is that the substitute
+command does not know about word boundaries.  It will
+change the first occurrence of a letter string it matches
+without regard to blanks or punctuation around it.  Thus,
+if the current line is
+   i would rather be the king
+and you type
+   s/the/a/p
+you get
+   i would raar be the king
+instead of
+   i would rather be a king
+Right?  You should always print lines after changing them
+to avoid missing such errors.  You can defend against them
+by increasing the amount of context you specify; in this
+case, for example, you could say
+   s/the /a /p
+and get
+   i would rather be a king
+Often the "$" operator is useful here, if you want to
+change the last thing on the line.  In the file 'text',
+the third line reads
+  never, never, never, never, never
+Edit this file to make the third line read
+  never, never, never, never, or hardly ever
+Rewrite the file and type "ready".
+#create Ref
+why should a dog, a horse, a rat, have life,
+and thou no breath at all? thou'lt come no more,
+never, never, never, never, or hardly ever
+pray you, undo this button.  thank you, sir.
+#create text
+why should a dog, a horse, a rat, have life,
+and thou no breath at all? thou'lt come no more,
+never, never, never, never, never
+pray you, undo this button.  thank you, sir.
+#user
+#cmp text Ref
+#log
+#next
+42.1a 10
+41.1b 5
+42.2a 6
diff --git a/usr/lib/learn/editor/L41.1b b/usr/lib/learn/editor/L41.1b
new file mode 100644 (file)
index 0000000..9d02aec
--- /dev/null
@@ -0,0 +1,19 @@
+#print
+There is a mistyped word in the third line of the file "problem".
+Fix it, rewrite the file, and type "ready".
+#create Ref
+The computer costs too much.
+No one knows how to use it.
+The switchboard in the main office is broken.
+It takes too long to get anything done.
+#create problem
+The computer costs too much.
+No one knows how to use it.
+The switchboard in thb main office is broken.
+It takes too long to get anything done.
+#user
+#cmp problem Ref
+#log
+#next
+42.1a 10
+42.2a 5
diff --git a/usr/lib/learn/editor/L42.1a b/usr/lib/learn/editor/L42.1a
new file mode 100644 (file)
index 0000000..4d04eb1
--- /dev/null
@@ -0,0 +1,28 @@
+#print
+Normally the 's' command only changes
+the first instance on a line of the expression
+it is looking for.  Sometimes you want to change
+more than one instance.  If you put a 'g' after the
+command, as in
+  s/cat/dog/g
+all instances of 'cat' will be changed to 'dog'. To
+print the result you must say
+  s/cat/dog/gp
+('pg' at the end doesn't work, sorry).
+Edit file 'stuff' in this directory to change every
+instance of 'green' to 'red' on every line.
+Then rewrite the file and type "ready".
+#create Ref
+red light, village red
+red book, red paper, red pencil
+red car, red sign, redhorn
+#create stuff
+green light, village green
+green book, green paper, green pencil
+green car, green sign, greenhorn
+#user
+#cmp stuff Ref
+#log
+#next
+43.1a 10
+43.2a 5
diff --git a/usr/lib/learn/editor/L42.2a b/usr/lib/learn/editor/L42.2a
new file mode 100644 (file)
index 0000000..ba649d4
--- /dev/null
@@ -0,0 +1,24 @@
+#print
+Normally the 's' command only changes the first instance
+on a line of the expression it is recognizing.  Sometimes you want
+to change everything.  For example, try the following sequence,
+and note the difference between the changes on the two lines.
+
+ed test
+1,2p
+1s/cat/cats/p
+2s/cat/cats/gp
+w
+q
+ready
+#create Ref
+the cats in the catalog is a persian cat
+the cats in the catsalog is a persian cats
+#create test
+the cat in the catalog is a persian cat
+the cat in the catalog is a persian cat
+#user
+#cmp test Ref
+#log
+#next
+42.2b 5
diff --git a/usr/lib/learn/editor/L42.2b b/usr/lib/learn/editor/L42.2b
new file mode 100644 (file)
index 0000000..dc2dd43
--- /dev/null
@@ -0,0 +1,18 @@
+#print
+Now pick up the file 'stuff', change all instances of "green"
+everywhere to "red", and then rewrite the file and type "ready".
+#create Ref
+red light, village red
+red book, red paper, red pencil
+red car, red sign, redhorn
+red with envy
+#create stuff
+green light, village green
+green book, green paper, green pencil
+green car, green sign, greenhorn
+green with envy
+#user
+#cmp stuff Ref
+#log
+#next
+42.2c 5
diff --git a/usr/lib/learn/editor/L42.2c b/usr/lib/learn/editor/L42.2c
new file mode 100644 (file)
index 0000000..5f1557a
--- /dev/null
@@ -0,0 +1,31 @@
+#print
+Remember the procedures with '*' for changing one or more
+of something into one something.  Pick up the file
+"sloppy" and on every line, whereever there are several
+blanks in a row change them to one blank.  This can be done
+with one command; it is a very common task. Then rewrite the file
+and type "ready".
+#create Ref
+It seems that medieval art
+ Alone retains its zest
+To charm and please its devotees
+ We've done our level best
+We're not quite sure that all we do
+ Has the Early English ring
+But as far as we can tell
+ It's something like this sort of thing.
+#create sloppy
+It seems   that medieval   art
+ Alone retains   its zest
+To   charm and please its   devotees
+   We've done our    level best
+We're not quite  sure that all we do
+ Has the Early English ring
+But as far as we    can   tell
+ It's something like   this sort of thing.
+#user
+#cmp sloppy Ref
+#log
+#next
+43.1a 10
+43.2a 5
diff --git a/usr/lib/learn/editor/L43.1a b/usr/lib/learn/editor/L43.1a
new file mode 100644 (file)
index 0000000..e73468e
--- /dev/null
@@ -0,0 +1,29 @@
+#print
+Note that there is quite a list of special characters
+recognized by the editor:
+ . [ * ^ $ & /
+What do you do when you want to specifically use
+one of these characters as itself, rather than
+for its funny meaning?  You must precede it by a backslash,
+as in
+  s/\./,/p
+which will change the line
+  x, y. and z
+into
+  x, y, and z
+easily.  The same works for all the other special
+characters.  What command would change
+  *
+into
+  c
+Type "answer COMMAND" where COMMAND is of the form
+  s/.././p
+#copyin
+#user
+#uncopyin
+#match s/\*/c/p
+#match s/\*/c/
+You forgot the "p" on the end.
+#log
+#next
+44.1a 10
diff --git a/usr/lib/learn/editor/L43.2a b/usr/lib/learn/editor/L43.2a
new file mode 100644 (file)
index 0000000..f8af90e
--- /dev/null
@@ -0,0 +1,32 @@
+#print
+Note that there is quite a list of characters that
+are special to the editor:
+ . [ * ^ $ & /
+What do you do when you want to use one of these
+characters as itself, rather than for its special meaning?
+You must precede it by a backlash.  For example, how
+would you turn
+ ".
+into
+ ."
+Try the following sequence:
+
+ed test
+1,3p
+1,3s/"\./."/p
+w
+q
+ready
+#create Ref
+This is a "quoted word."
+Here is "another."
+Be "careful."  Especially with dots.
+#create test
+This is a "quoted word".
+Here is "another".
+Be "careful".  Especially with dots.
+#user
+#cmp test Ref
+#log
+#next
+43.2b 5
diff --git a/usr/lib/learn/editor/L43.2b b/usr/lib/learn/editor/L43.2b
new file mode 100644 (file)
index 0000000..68bf60a
--- /dev/null
@@ -0,0 +1,15 @@
+#print
+Pick up the file "line" and change
+ x, y. and z
+into
+ x, y, and z
+Then rewrite the file and type "ready".
+#create Ref
+ x, y, and z
+#create line
+ x, y. and z
+#user
+#cmp line Ref
+#log
+#next
+43.2c 5
diff --git a/usr/lib/learn/editor/L43.2c b/usr/lib/learn/editor/L43.2c
new file mode 100644 (file)
index 0000000..30b606e
--- /dev/null
@@ -0,0 +1,23 @@
+#print
+This is trickier.  Change all sequences of several
+asterisks into one asterisk.  E.g.
+ *** xxx ****
+becomes
+ * xxx *
+The file is named "stars"; edit it
+and then rewrite it.  Then type "ready".
+#create Ref
+   List of phone numbers
+  * 6377 *
+  * 4582 *
+  * 3968 *
+#create stars
+   List of phone numbers
+  ** 6377 ***
+  **** 4582 ****
+  * 3968 ***
+#user
+#cmp stars Ref
+#log
+#next
+43.2d 5
diff --git a/usr/lib/learn/editor/L43.2d b/usr/lib/learn/editor/L43.2d
new file mode 100644 (file)
index 0000000..ab4195b
--- /dev/null
@@ -0,0 +1,19 @@
+#print
+This is trickier.  File "name" contains
+ A T and T Co.
+Change it to read
+ A T & T Co.
+Then rewrite it and type "ready".
+#create Ref
+ A T & T Co.
+#create name
+ A T and T Co.
+#user
+#cmp name Ref
+#succeed
+I hope you used
+ s/and/\&/p
+and did not retype the line.
+#log
+#next
+44.1a 5
diff --git a/usr/lib/learn/editor/L44.1a b/usr/lib/learn/editor/L44.1a
new file mode 100644 (file)
index 0000000..7ae6dd6
--- /dev/null
@@ -0,0 +1,43 @@
+#print
+You have now learned quite a bit about substitute commands.
+Here is a larger task to perform.  There is a file 'song' in
+this directory.  Edit it; print it out, and notice that
+there are six mistyped words in it.  Fix all of them
+and rewrite the file.  Then type "ready".
+#create Ref
+Oh, say can you see
+ by the dawn's early light
+What so proudly we hailed
+ at the twilight's last gleaming
+Whose broad stripes and bright stars
+ through the perilous night
+O'er the ramparts we watched
+ were so gallantly streaming
+And the rocket's red glare,
+ the bombs bursting in air
+Gave proof through the night
+ that our flag was still there
+Oh, say does that star spangled banner yet wave
+ o'er the land of the free
+And the home of the brave?
+#create song
+Oh, say can yuo see
+ by the dawn's early light
+What so proudly we hailed
+ at the twilight's last glieaming
+Whose broad stxripes and bright stxars
+ through the perilous night
+O'er the ramparts we watched
+ were so gallantly streammming
+And the rocket's red glare,
+ the bombs bursting in air
+Gave proof through thre night
+ that our flag was still there
+Oh, say does that star spangled banner yet wave
+ o'er the land of the free
+And the home of the brave?
+#user
+#cmp song Ref
+#log
+#next
+44.1b 10
diff --git a/usr/lib/learn/editor/L44.1b b/usr/lib/learn/editor/L44.1b
new file mode 100644 (file)
index 0000000..ffe35d4
--- /dev/null
@@ -0,0 +1,35 @@
+#print
+There is a file named "paragraph" in this directory.
+It contains three spelling errors, one line is duplicated,
+and the last line is missing (the paragraph should end
+"has been carefully coded and is now well under control.").
+Fix it up and rewrite it.  Then type "ready".
+#create Ref
+Held at arm's length, this program looks pretty impressive.
+There is a large assortment of data declarations, followed
+by a computation that is evidently complex enough
+to warrant a sub-procedure.  Declarations are neatly
+aligned, and the executable statements are staggered so
+as to indicate several levels of control nesting.
+There are text strings to suggest the intent of the program,
+and mnemonic identifiers to give hints about how the results
+are obtained.  The general impression conveyed is that
+this is a moderately complicated problem that
+has been carefully coded and is now well under control.
+#create paragraph
+Held at arm's length, this program looks pretty impressive.
+There is a large assortment of dta declarations, followed
+by a computation that is evidently complex enough
+to warrant a sub-procedure.  Declarations are neatly
+aligned, and the executable statements are stagggered so
+as to indicate several levels of control nesting.
+as to indicate several levels of control nesting.
+There are text strings to suggest the intent of the program,
+and mnemonic identifiers to give hints about how the results
+are obtained.  The genreal impression conveyed is that
+this is a moderately complicated problem that
+#user
+#cmp Ref paragraph
+#log
+#next
+44.1c 10
diff --git a/usr/lib/learn/editor/L44.1c b/usr/lib/learn/editor/L44.1c
new file mode 100644 (file)
index 0000000..d3fee4d
--- /dev/null
@@ -0,0 +1,49 @@
+#print
+There is a file "list" in this directory which contains
+some names.  Here are the addresses: add them on
+lines after the name (i.e. the file should look like:
+
+    Joe Blow
+    45 Western Ave.
+    Elmira, N\19Y 10445
+
+    Sam Jones
+    97 Fifth St.
+    Oshkosh, WI 52302
+ ...
+when you are done).
+
+ Name     address is
+Ford     1600 Pennsylvania Ave., Washington, DC 20515
+Fenwick  1 Morris St., Morristown, NJ 07960
+Rinaldo  308 Main St., Orange, NJ 07050
+Rodino   907 Broad St., Newark NJ 07102
+#create Ref
+The Hon. Gerald Ford
+1600 Pennsylvania Ave.
+Washington, DC 20515
+
+The Hon. Millicent Fenwick
+1 Morris St.
+Morristown, NJ 07960
+
+The Hon. Matthew Rinaldo
+308 Main St.
+Orange, NJ 07050
+
+The Hon. Peter Rodino
+907 Broad St.
+Newark, NJ 07102
+#create list
+The Hon. Gerald Ford
+
+The Hon. Millicent Fenwick
+
+The Hon. Matthew Rinaldo
+
+The Hon. Peter Rodino
+#user
+#cmp Ref list
+#log
+#next
+44.1d 10
diff --git a/usr/lib/learn/editor/L44.1d b/usr/lib/learn/editor/L44.1d
new file mode 100644 (file)
index 0000000..5ac83dd
--- /dev/null
@@ -0,0 +1,54 @@
+#print
+In file "locs" is a list of Bell Labs locations.
+Bring it up to date by
+ a) replace "Raritan River" by "Piscataway"
+ b) delete "Denville".
+ c) insert "Atlanta".
+ d) spell "Merrimack Valley" correctly.
+#create Ref
+Allentown
+Atlanta
+Centennial Park
+Chester
+Columbus
+Crawford Hill
+Denver
+Grand Forks
+Guilford Center
+Holmdel
+Indianapolis
+Indian Hill
+Kwajalein
+Madison
+Merrimack Valley
+Murray Hill
+Piscataway
+Reading
+Warren
+Whippany
+#create locs
+Allentown
+Centennial Park
+Chester
+Columbus
+Crawford Hill
+Denver
+Denville
+Grand Forks
+Guilford Center
+Holmdel
+Indianapolis
+Indian Hill
+Kwajalein
+Madison
+Merimack Valley
+Murray Hill
+Raritan River
+Reading
+Warren
+Whippany
+#user
+#cmp locs Ref
+#log
+#next
+44.1e
diff --git a/usr/lib/learn/editor/L44.1e b/usr/lib/learn/editor/L44.1e
new file mode 100644 (file)
index 0000000..042df33
--- /dev/null
@@ -0,0 +1,26 @@
+#print
+As you've probably noticed, the backslash character "\"
+is rather special to the editor (and to other programs
+as well).  So what do you do when you have to somehow
+get a backslash into some text, or to edit it in
+or out?
+
+Getting it in in the first place is quite easy: when
+you are appending with "a" (or inserting with "i", or
+changing with "c", or reading with "r"), there's
+nothing special about "\" at all.  To verify this,
+add the line
+
+Two backslashes \\ do not equal one forward slash.
+
+to the file "junk", re-write it, then type "ready".
+#create Ref
+This is a file with a silly line in it.
+Two backslashes \\ do not equal one forward slash.
+#create junk
+This is a file with a silly line in it.
+#user
+#cmp Ref junk
+#log
+#next
+44.1f 10
diff --git a/usr/lib/learn/editor/L44.1f b/usr/lib/learn/editor/L44.1f
new file mode 100644 (file)
index 0000000..b169287
--- /dev/null
@@ -0,0 +1,32 @@
+#print
+The next step is to learn how to edit a line
+that contains a backslash.  On the left side of an "s"
+command, you place a "\" before the "\" to turn off
+its special meaning, just as for any other special
+character like "*" or "[".  For example,
+if you have the line
+   c = '\n'
+you can change it into
+   c = 'n'
+with the command
+   s/\\n/n/
+or
+   s/\\//
+(Your choice.)
+
+Practice by removing all the backslashes from the
+file "junk"; when you're done, re-write it and
+type "ready".
+#create Ref
+Now is the time for all good
+men to come to the aid of
+their party, or something like that.
+#create junk
+Now is \the \tim\\e for all good
+m\\en \to com\\e \to \the aid of
+\their par\ty, or som\\e\thing like \tha\t.
+#user
+#cmp Ref junk
+#log
+#next
+44.1g 10
diff --git a/usr/lib/learn/editor/L44.1g b/usr/lib/learn/editor/L44.1g
new file mode 100644 (file)
index 0000000..b0eb263
--- /dev/null
@@ -0,0 +1,121 @@
+#print
+Of course, you can also search for lines that
+contain backslashes; again, it's simply a matter
+of doubling the backslash in the search pattern.
+That is,
+   /\\/
+finds the next line with a backslash.
+
+Find the second occurrence of "\n\n" in the file
+"prog.c", and type "answer N", where N is its
+line number.
+#create prog.c
+
+int  nsave  = 0;
+
+selunit()
+{
+  char fnam[20], s[50];
+  static char dobuff[50];
+  char posslev[20][20];
+  int diff[20], i, k, m, n, best, alts, statb[20];
+  FILE *f;
+  char zb[200];
+  static char saved[20];
+
+  while (ask) {
+    printf("What lesson? ");
+    fflush(stdout);
+    gets(dobuff);
+    if (strcmp(dobuff, "bye") == 0)
+      wrapup(0);
+    level = todo = dobuff;
+    sprintf(s, "../L%s", dobuff);
+    if (access(s, 04) == 0)
+      return;
+    printf("no such lesson\n");
+  }
+  alts = 0;
+retry:
+  f=scrin;
+  if (f==NULL) {
+    sprintf(fnam, "../L%s", level);
+    f = fopen(fnam, "r");
+    if (f==NULL) {
+      fprintf(stderr, "No script for lesson %s.\n", level);
+      wrapup(1);
+    }
+    while (fgets(zb, 200, f)) {
+      trim(zb);
+      if (strcmp(zb, "#next")==0)
+        break;
+    }
+  }
+  if (feof(f)) {
+    printf("Congratulations\n\n.You have finished this sequence.\n");
+    fflush(stdout);
+    todo = 0;
+    return;
+  }
+  for(i=0; fgets(s, 50, f); i++) {
+    sscanf(s, "%s %d", &posslev[i], &diff[i]);
+  }
+  best = -1;
+  /* cycle through lessons from random start */
+  /* first try the current place, failing that back up to
+       last place there are untried alternatives (but only one backup) */
+  n = grand()%i;
+  for(k=0; k<i; k++) {
+    m = (n+k)%i;
+    if (already(posslev[m])) continue;
+    if (best<0) best=m;
+    /* real alternatives */
+    alts++;
+    if (abs(diff[m]-speed) < abs(diff[best]-speed))
+      best=m;
+  }
+  if (best < 0 && nsave) {
+    nsave--;
+    strcpy(level, saved);
+    goto retry;
+  }
+  if (best <0) {
+    /* lessons exhausted or missing */
+    printf("Sorry, there are no alternative lessons at this stage.\n");
+    printf("See someone for help.\n\n");
+    fflush(stdout);
+    todo = 0;
+    return;
+  }
+  strcpy (dobuff, posslev[best]);
+  if (alts>1) {
+    nsave=1;
+    strcpy (saved, level);
+  }
+  todo = dobuff;
+  fclose(f);
+}
+
+abs(x)
+{
+  return(x>=0? x: -x);
+}
+
+grand()
+{
+  static int garbage;
+  int a[2], b;
+
+  time(a);
+  b = a[1]+10*garbage++;
+  return(b&077777);
+}
+#copyin
+#user
+#uncopyin
+#match 73
+#bad 43
+The second\b\b\b\b\b\b______ one.
+#log
+#next
+44.1h 10
diff --git a/usr/lib/learn/editor/L44.1h b/usr/lib/learn/editor/L44.1h
new file mode 100644 (file)
index 0000000..c8db43e
--- /dev/null
@@ -0,0 +1,29 @@
+#print
+The next trick is to substitute a "\" into a line.
+The same idea holds: simply double the backslash,
+but this time on the right side of the "s" command.
+
+In the file "prog.c", convert every
+   'n'
+into
+   "\n"
+Re-write the file, and type "ready".
+#create Ref
+  x = "\n";
+  y = 'nop';
+  z = 'lmn';
+  q = "n";
+  r = "\n"+1;
+  s = "\n" - "\n";
+#create prog.c
+  x = 'n';
+  y = 'nop';
+  z = 'lmn';
+  q = "n";
+  r = 'n'+1;
+  s = 'n' - 'n';
+#user
+#cmp Ref prog.c
+#log
+#next
+44.1i 10
diff --git a/usr/lib/learn/editor/L44.1i b/usr/lib/learn/editor/L44.1i
new file mode 100644 (file)
index 0000000..df4964c
--- /dev/null
@@ -0,0 +1,19 @@
+#print
+One last one with "\".  Add the following to
+the end of the first line in file "temp",
+separated by a single blank.
+
+/* &"\n" isn't &'\n' */
+
+You can do it by re-typing the line, but it's
+a nice exercise to use "s".
+Type "ready" after you have re-written the file.
+#create Ref
+p = &"\n"; /* &"\n" isn't &'\n' */
+#create temp
+p = &"\n";
+#user
+#cmp temp Ref
+#log
+#next
+45.1a 10
diff --git a/usr/lib/learn/editor/L45.1a b/usr/lib/learn/editor/L45.1a
new file mode 100644 (file)
index 0000000..c2174f9
--- /dev/null
@@ -0,0 +1,36 @@
+#print
+There is one last class of substitutions that
+you should know about:  converting one line 
+into two or more by substituting a newline
+into the middle.  Suppose you want to split the
+line
+   Now is the time for all good men
+into
+   Now is the time
+   for all good men
+without re-typing.  The substitute command is
+   s/time /time\
+   /
+The backslash indicates that a newline is to be
+inserted at that point; the rest of the "s"
+command is actually typed on a new line.
+
+Practice by splitting the first line in file
+"btl" into
+
+Bell Laboratories
+Murray Hill, NJ 07974
+
+using the "s" command as illustrated above.
+Be sure to delete the comma and space properly.
+Re-write the file, then type "ready".
+#create Ref
+Bell Laboratories
+Murray Hill, NJ 07974
+#create btl
+Bell Laboratories, Murray Hill, NJ 07974
+#user
+#cmp btl Ref
+#log
+#next
+45.1b
diff --git a/usr/lib/learn/editor/L45.1b b/usr/lib/learn/editor/L45.1b
new file mode 100644 (file)
index 0000000..a02865e
--- /dev/null
@@ -0,0 +1,34 @@
+#print
+The opposite command to splitting is joining.
+But this isn't done with a "s" as you might expect;
+it uses an entirely separate command called "j"
+(for "join").  To join two or more adjacent (!)
+lines, such as lines 3 through 6, simply type
+   3,6j
+You can add a "p" at the end to see the result.
+
+If you don't specify any lines, "j" by itself joins
+line "." and ".+1".
+In no case does "j" add any extra blanks -- you have
+to put them in for yourself if you want them.
+
+The file "split" has six lines.  Convert it into
+three lines by joining 1 and 2, 3 and 4, and 5 and 6.
+Make sure that the words are separated by spaces.
+Re-write, then type "ready".
+#create Ref
+Check your arithmetic: avoid costly mistakes.
+Attach W-2 forms: they must be attached to your return.
+Sign your return: your spouse must sign too.
+#create split
+Check your arithmetic:
+avoid costly mistakes.
+Attach W-2 forms:
+they must be attached to your return.
+Sign your return:
+your spouse must sign too.
+#user
+#cmp Ref split
+#log
+#next
+50.1a
diff --git a/usr/lib/learn/editor/L5.1a b/usr/lib/learn/editor/L5.1a
new file mode 100644 (file)
index 0000000..0dc34fd
--- /dev/null
@@ -0,0 +1,29 @@
+#print
+The most frequently used editor command is
+  p
+which prints out a line.  Try that now.
+Type the command sequence
+
+p
+w
+q
+
+to print out a line, and then write out the file.
+Then type "ready".
+#create Ref
+This is the line to be printed. Don't forget w, then q.
+56
+#create file
+This is the line to be printed. Don't forget w, then q.
+#copyout
+#pipe
+ed file
+#user
+#unpipe
+#uncopyout
+tail -2 .ocopy >X2
+#cmp Ref X2
+#log
+#next
+6.1a 5
+6.2a 2
diff --git a/usr/lib/learn/editor/L50.1a b/usr/lib/learn/editor/L50.1a
new file mode 100644 (file)
index 0000000..81bd91d
--- /dev/null
@@ -0,0 +1,36 @@
+#print
+So far all the addresses you have used have been
+either line numbers, '$', or '.' (or combinations
+thereof).  The most useful addresses are none of
+those, but are specifications of lines by content.
+Anything you can ask the substitute command
+to find in a line, you can ask the editor to find
+in a file.  In particular,
+ /xx/p
+is a valid command with a line address 
+ /xx/
+and the 'p' command operator.  The address
+ /xx/
+means 'the next line containing an "xx"'.
+So this command prints out the next line which
+has an "xx" on it.  Edit the file 'text' and
+print the line which has 'cat' on it.  Then
+leave the editor and type "ready".
+#create text
+This is a short list of
+things you might find
+in the Sears, Roebuck
+catalog.
+ tools
+ furniture
+ electrical parts
+ clothes
+ appliances
+ garden equipment.
+#copyout
+#user
+#uncopyout
+grep catalog\. .ocopy >/dev/null
+#log
+#next
+50.1b 10
diff --git a/usr/lib/learn/editor/L50.1b b/usr/lib/learn/editor/L50.1b
new file mode 100644 (file)
index 0000000..0dd3895
--- /dev/null
@@ -0,0 +1,31 @@
+#print
+You can use all the special characters in the
+search commands.  For example,
+ /^cat/p
+prints the first line that BEGINS with 'cat'.
+You can even leave out the 'p':
+ /^cat/
+does the same thing.
+
+Now go into file 'text' with the editor and
+print the first line that ENDS with 'dog'.
+Then leave the editor and type 'ready'.
+#create text
+This is a file which
+contains several occurrences
+of the word 'dog' in several
+places.  It would be a doggone
+shame if you didn't find
+the right dog
+to print out.
+#copyout
+#user
+#uncopyout
+grep 'dog$' text >X1
+grep 'dog' .ocopy >X3
+tail -1 X3 >X2
+#cmp X1 X2
+#log
+#next
+50.1c 10
+50.2c 5
diff --git a/usr/lib/learn/editor/L50.1c b/usr/lib/learn/editor/L50.1c
new file mode 100644 (file)
index 0000000..3ed8c33
--- /dev/null
@@ -0,0 +1,54 @@
+#print
+You can use other commands than 'p' with these
+context search addresses, of course.  For example,
+ /abc.e/s/ab/xx/p
+will
+ (1) search for the next line containing the
+     expression "abc.e", which matches any line that
+     has an 'a', then a 'b', then a 'c', then
+     anything, then an 'e' (so that it matches
+     "abcde", "abcxe", "abc9e", but not "abceq");
+ (2) on that line, change the first "ab" to an "xx".
+Edit file 'county'; find the line with 'pacific' on it
+and change it to 'ocean'.  Then rewrite the file
+and type "ready".
+#create Ref
+passaic
+bergen
+sussex
+hudson
+essex
+warren
+morris
+hunderdon
+somerset
+union
+ocean
+monmouth
+middlesex
+mercer
+cumberland
+cape may
+#create county
+passaic
+bergen
+sussex
+hudson
+essex
+warren
+morris
+hunderdon
+somerset
+union
+pacific
+monmouth
+middlesex
+mercer
+cumberland
+cape may
+#user
+#cmp county Ref
+#log
+#next
+51.1a 10
+50.2e 5
diff --git a/usr/lib/learn/editor/L50.2c b/usr/lib/learn/editor/L50.2c
new file mode 100644 (file)
index 0000000..72853d2
--- /dev/null
@@ -0,0 +1,23 @@
+#print
+Edit file "junk" and print the first line
+that contains either "color" or "Color".
+Then leave the editor and type "ready".
+#create junk
+this file contains
+a few random lines
+much noise
+bright Colors
+other stuff
+colored paper
+and color by Technicolor
+#create x2
+bright Colors
+#copyout
+#user
+#uncopyout
+grep olor .ocopy >x1
+#cmp x1 x2
+#log
+#next
+50.2d 5
+50.1c 10
diff --git a/usr/lib/learn/editor/L50.2d b/usr/lib/learn/editor/L50.2d
new file mode 100644 (file)
index 0000000..48ad257
--- /dev/null
@@ -0,0 +1,33 @@
+#print
+In file "text" print the first
+line which contains any of the
+words "them", "these", "their", or "there"
+(you need only distinguish "the"; that is,
+look for the letters "t", "h", and "e" followed
+by something other than a blank).  Delete the
+line you find ; then rewrite the file
+and type "ready".
+#create Ref
+the leaves do not have enough room to hold all the food
+that plants make.  much of the food has to be stored in remote parts
+of the plant.
+we eat the parts of plants where the most food is stored.  the
+carrot plant stores food in its roots.  We eat the roots of carrots.
+the celery plant stores food in its leaf stalks, which are the parts
+the fruits of these plants to get the stored food in them.
+   some kinds of plants have ways of protecting their stored food.
+#create text
+the leaves do not have enough room to hold all the food
+that plants make.  much of the food has to be stored in remote parts
+of the plant.
+we eat the parts of plants where the most food is stored.  the
+carrot plant stores food in its roots.  We eat the roots of carrots.
+the celery plant stores food in its leaf stalks, which are the parts
+we eat.  many kinds of plants store food in their fruits.  we eat
+the fruits of these plants to get the stored food in them.
+   some kinds of plants have ways of protecting their stored food.
+#user
+#cmp text Ref
+#log
+#next
+50.1c 10
diff --git a/usr/lib/learn/editor/L50.2e b/usr/lib/learn/editor/L50.2e
new file mode 100644 (file)
index 0000000..73408a0
--- /dev/null
@@ -0,0 +1,28 @@
+#print
+Please edit a file named "news" and find the
+first word containing the three letters "ufa".
+Make the word plural, rewrite the file, and
+type "ready".
+#create Ref
+It was announced today in
+Washington that the GNP was
+up at an annual rate of 8.2 %
+in the third quarter of 1975.
+Fishing and agriculture declined
+slightly but manufactures increased
+substantially.  The overall gain
+was impressive and confirms economic recovery.
+#create news
+It was announced today in
+Washington that the GNP was
+up at an annual rate of 8.2 %
+in the third quarter of 1975.
+Fishing and agriculture declined
+slightly but manufacture increased
+substantially.  The overall gain
+was impressive and confirms economic recovery.
+#user
+#cmp news Ref
+#log
+#next
+50.2f 10
diff --git a/usr/lib/learn/editor/L50.2f b/usr/lib/learn/editor/L50.2f
new file mode 100644 (file)
index 0000000..f25f715
--- /dev/null
@@ -0,0 +1,343 @@
+#print
+Look in the file "story".  Somewhere is a line
+containing the word "season".  Find it, and find
+what line number it has.  Leave the editor
+and type "answer N" where N is the line number
+of the line containing the word "season".
+The file is too long for you to print it all,
+by the way.
+#create story
+All
+of
+the
+Big
+Cats,
+as
+well
+as
+the
+lesser
+ones,
+have
+wonderful
+eyes.
+They
+can
+see
+clearly
+even
+on
+a
+dark
+night.
+this
+is
+because
+of
+the
+way
+they
+are
+made.
+There
+is
+a
+sort
+of
+window
+in
+each
+eye.
+This
+window
+is
+called
+the
+pupil.
+It
+is
+black
+and
+is
+placed
+in
+the
+center
+of
+the
+colored
+part
+of
+the
+eye.
+The
+pupil
+lets
+light
+come
+in
+and
+reach
+a
+kind
+of
+mirror
+at
+the
+back
+of
+each
+eye.
+These
+mirrors
+reflect
+everything
+that
+is
+in
+front
+of
+the
+eyes.
+Right
+away
+a
+special
+nerve
+carries
+these
+reflected
+pictures
+to
+the
+brain.
+I'm
+learning
+to
+be
+a
+detective
+--
+not
+the
+kind
+who
+solves
+crimes
+from
+fingerprints,
+pieces
+of
+clothing,
+or
+the
+cross-examining
+of
+witnesses
+--
+I'm
+learning
+to
+be
+a
+nature
+detective.
+The
+mysteries
+I
+trace
+happen
+in
+the
+woods,
+in
+the
+park,
+and
+in
+my
+own
+backyard.
+Animals
+come
+and
+go
+when
+I'm
+not
+there
+to
+see
+them,
+but
+usually
+they
+leave
+clues
+behind.
+From
+such
+clues
+and
+other
+animal
+signs,
+you
+and
+I
+will
+piece
+together
+some
+exciting
+stories.
+We
+will
+detect
+which
+animals
+went
+where,
+what
+they
+did,
+and
+sometimes
+what
+they
+ate.
+Whenever
+there
+is
+snow
+on
+the
+ground,
+you
+are
+sure
+to
+find
+track
+stories
+written
+in
+it.
+Animals
+travel
+by
+air
+by
+water
+and
+by
+land.
+Some
+run
+very
+fast.
+Some
+hop
+or
+jump
+along
+the
+ground.
+Others
+walk
+more
+slowly,
+or
+crawl
+still
+more
+slowly.
+Do
+you
+know
+that
+plants
+are
+travelers,
+too?
+And
+that
+they
+also
+travel
+by
+land,
+by
+water
+and
+by
+air?
+Most
+plants
+stay
+in
+the
+same
+spot
+from
+the
+time
+they
+begin
+to
+grow
+until
+they
+die.
+But
+the
+next
+season
+you
+find
+many
+of
+them
+growing
+in
+new
+places.
+How
+do
+they
+get
+there?
+Some
+plants
+travel
+by
+land.
+They
+have
+seeds
+that
+fall
+to
+the
+ground
+and
+grow
+there.
+Others
+send
+out
+offshoots
+or
+sprouts
+which
+start
+new
+plants
+nearby.
+#copyin
+#user
+#uncopyin
+#match 286
+#log
+#next
+50.2g 10
diff --git a/usr/lib/learn/editor/L50.2g b/usr/lib/learn/editor/L50.2g
new file mode 100644 (file)
index 0000000..3690bbb
--- /dev/null
@@ -0,0 +1,52 @@
+#print
+The file "amend" contains an erroneous copy of the first
+four amendments to the Constitution.  Find the line
+saying "suspicion" and change it to read
+"but upon probable cause, supported by oath or affirmation,"
+and then rewrite the file and type "ready".
+#create Ref
+1. Congress shall make no law respecting an establishment of religion,
+or prohibiting the free exercise thereof; or abridging the freedom of speech,
+or of the press; or the right of the people peaceably to assemble,
+and to petition the Government for a redress of grievances.
+
+2. A well regulated Militia, being necessary to the security
+of a free State, the right of the people to keep and bear arms
+shall not be infringed.
+
+3. No Soldier shall, in time of peace, be quartered
+in any house without the consent of the Owner, nor in time
+of war, but in a manner to be prescribed by law.
+
+4. The right of the people to be secure in their persons,
+houses, papers, and effects, against unreasonable searches and
+seizures, shall not be violated, and no Warrants shall issue,
+but upon probable cause, supported by oath or affirmation,
+and particularly describing the place to be searched, and the
+persons or things to be seized.
+#create amend
+1. Congress shall make no law respecting an establishment of religion,
+or prohibiting the free exercise thereof; or abridging the freedom of speech,
+or of the press; or the right of the people peaceably to assemble,
+and to petition the Government for a redress of grievances.
+
+2. A well regulated Militia, being necessary to the security
+of a free State, the right of the people to keep and bear arms
+shall not be infringed.
+
+3. No Soldier shall, in time of peace, be quartered
+in any house without the consent of the Owner, nor in time
+of war, but in a manner to be prescribed by law.
+
+4. The right of the people to be secure in their persons,
+houses, papers, and effects, against unreasonable searches and
+seizures, shall not be violated, and no Warrants shall issue,
+but upon suspicion,
+and particularly describing the place to be searched, and the
+persons or things to be seized.
+#user
+#cmp amend Ref
+#log
+#next
+51.1a 10
+51.2a 5
diff --git a/usr/lib/learn/editor/L51.1a b/usr/lib/learn/editor/L51.1a
new file mode 100644 (file)
index 0000000..3012c34
--- /dev/null
@@ -0,0 +1,25 @@
+#print
+You can also use relative addresses of the +1 or -1
+sort with context searches.  For example, to
+print the line after a line containing "cat",
+you can say
+  /cat/+1p
+How would you print the line before the next line
+containing the word "help" at the beginning
+of the line?  Try some experiments if you want,
+but in the end type "answer COMMAND" where COMMAND
+is the correct command to do that.
+#copyin
+#user
+#uncopyin
+#match /^help/-1p
+#match /^help/-1
+#match /^help/-
+#match /^help/-p
+#succeed
+The "p" isn't necessary, of course.
+#cmp X1 X2
+#log
+#next
+52.1a 10
+52.2a 5
diff --git a/usr/lib/learn/editor/L51.2a b/usr/lib/learn/editor/L51.2a
new file mode 100644 (file)
index 0000000..5b1ffb2
--- /dev/null
@@ -0,0 +1,83 @@
+#print
+You can also use relative addresses of the +1 or -1
+sort with context searches.  For example, to print the
+line after the line containing "cat", you could say
+
+  /cat/+1p
+
+Here is a file "text".  Print the line before the line
+containing "florin".  Then leave the editor and type "ready".
+#create text
+   The United Netherlands are a confederacy of republics,
+or rather of aristocracies of a very remarkable texture, yet
+confirming all the lessons derived from those which we
+have already reviewed.
+   The union is composed of seven coequal and sovereign
+states, and each state or province is a composition of
+equal and independent cities.  In all important cases, not
+only the provinces but the cities must be unanimous.
+   The sovereignty of the union is represented by the
+States-General, consisting usually of about fifty deputies
+appointed by the provinces.  They hold their seats, some
+for life, some for six, three, and one years; from two
+provinces they continue in appointment during pleasure.
+   The States-General have authority to enter into
+treaties and alliances; to make war and peace; to raise
+armies and equip fleets; to ascertain quotas and
+demand contributions.  In all these cases, however, unanimity
+and sanction of their constituents are requisite.
+They have authority to appoint and receive ambassadors;
+to execute treaties and alliances already formed; to
+provide for the collection of duties on imports and exports;
+to regulate the mint with a saving to the provincial
+rights; to govern as sovereigns the dependent territories.
+The provinces are restrained, unless with the general
+consent, from entering into foreign treaties; from
+establishing imposts injurious to others, or charging
+their neighbors with higher duties than their own subjects.  A
+council of state, a chamber of accounts, with five colleges
+of admiralty, aid and fortify the federal administration.
+   The executive magistrate of the Union is the
+stadtholder, who is now an hereditary prince.  His principal
+weight and influence in the republic are derived from his
+independent title; from his great patrimonial estates;
+from his family connections with some of the chief
+potentates of Europe; and, more that all, perhaps, from his
+being stadtholder in the several provinces, as well as for
+the Union; in which provincial quality he has the
+appointment of town magistrates under certain regulations,
+executes provincial decrees, presides when he pleases in
+the provincial tribunals, and has throughout the power
+of pardon.
+   As stadtholder of the Union, he has, however,
+considerable prerogatives.
+   In his political capacity he has authority to settle
+disputes between the provinces, when other methods fail; to
+assist at the deliberations of the States-General and at
+their particular conferences; to give audiences to foreign
+ambassadors and to keep agents for his particular affairs
+at foreign courts.
+   In his military capacity he commands the federal
+troops, provides for garrisons, and in general regulates
+military affairs; disposes of all appointments, from
+colonels to ensigns, and of the governments and posts of
+fortified towns.
+   In his marine capacity he is admiral-general and
+superintends and directs every thing relative to naval forces
+and other naval affairs; presides in the admiralties in
+person or by proxy; appoints lieutenant-admirals and
+other officers; and establishes councils of war, whose
+sentences are not executed till he approves them.
+   His revenue, exclusive of his private income, amounts
+to 300,000 florins.  The standing army which he commands
+consists of about 40,000 men.
+#create x2
+   His revenue, exclusive of his private income, amounts
+#copyout
+#user
+#uncopyout
+grep exclusive .ocopy >x1
+#cmp x1 x2
+#log
+#next
+51.2b 5
diff --git a/usr/lib/learn/editor/L51.2b b/usr/lib/learn/editor/L51.2b
new file mode 100644 (file)
index 0000000..0d093f3
--- /dev/null
@@ -0,0 +1,21 @@
+#print
+Suppose you have a memo in a file and
+the line with the title is preceded by a line
+with "TL" on it.  What command would print
+the title?  Reply
+
+answer COMMAND
+
+where COMMAND is the search-and-print command to do that.
+#copyin
+#user
+#uncopyin
+#match /TL/+1p
+#match /TL/+
+#match /TL/1
+#match /TL/1p
+#match /TL/+p
+#match /TL/+1
+#log
+#next
+51.2c 5
diff --git a/usr/lib/learn/editor/L51.2c b/usr/lib/learn/editor/L51.2c
new file mode 100644 (file)
index 0000000..7f42cca
--- /dev/null
@@ -0,0 +1,93 @@
+#print
+How would you look for a blank line?  Do you
+understand
+
+  /^$/p
+
+Note this command: it looks for the beginning of the
+line, followed immediately by the end of the line.  If
+there are any characters in between, it will keep
+looking for a line with no\b\b__ characters at all.  All right.
+The file "text" contains an extraneous blank line.
+Delete it and rewrite the file.
+#create Ref
+   When the people of America reflect that they are now
+called upon to decide a question, which in its consequences
+must prove one of the most important that ever
+engaged their attention, the propriety of their taking a
+very comprehensive, as well as a very serious, view of it
+will be evident.
+   Nothing is more certain than the indispensable necessity
+of government; and it is equally undeniable that
+whenever and however it is instituted, the people must
+cede to it some of their natural rights, in order to vest it
+with requisite powers.  It is well worthy of consideration,
+therefore, whether it would conduce more to the interest
+of the people of America that they should, to all
+general purposes, be one nation, under one federal government,
+than that they should divide themselves into
+separate confederacies and give to the head of each the
+same kind of powers which they are advised to place in
+one national government.
+   It has until lately been a received and uncontradicted
+opinion that the prosperity of the people of America
+depended on their continuing firmly united, and the wishes,
+prayers, and efforts of our best and wisest citizens have
+been constantly directed to that object.  But politicians
+now appear who insist that this opinion is erroneous,
+and that instead of looking for safety and happiness in
+union, we ought to seek it in a division of the States
+into distinct confederacies or sovereignties.  However
+extraordinary this new doctrine may appear, it nevertheless
+has its advocates; and certain characters who were
+much opposed to it formerly are at present of the number.
+Whatever may be the arguments or inducements
+which have wrought this change in the sentiments and
+declarations of these gentlemen, it certainly would not be
+wise in the people at large to adopt these new political
+tenets without being fully convinced that they are founded
+in truth and sound policy.
+#create text
+   When the people of America reflect that they are now
+called upon to decide a question, which in its consequences
+must prove one of the most important that ever
+engaged their attention, the propriety of their taking a
+very comprehensive, as well as a very serious, view of it
+will be evident.
+   Nothing is more certain than the indispensable necessity
+of government; and it is equally undeniable that
+whenever and however it is instituted, the people must
+cede to it some of their natural rights, in order to vest it
+with requisite powers.  It is well worthy of consideration,
+therefore, whether it would conduce more to the interest
+of the people of America that they should, to all
+general purposes, be one nation, under one federal government,
+than that they should divide themselves into
+separate confederacies and give to the head of each the
+same kind of powers which they are advised to place in
+one national government.
+   It has until lately been a received and uncontradicted
+opinion that the prosperity of the people of America
+depended on their continuing firmly united, and the wishes,
+prayers, and efforts of our best and wisest citizens have
+been constantly directed to that object.  But politicians
+now appear who insist that this opinion is erroneous,
+and that instead of looking for safety and happiness in
+union, we ought to seek it in a division of the States
+into distinct confederacies or sovereignties.  However
+extraordinary this new doctrine may appear, it nevertheless
+has its advocates; and certain characters who were
+much opposed to it formerly are at present of the number.
+Whatever may be the arguments or inducements
+which have wrought this change in the sentiments and
+declarations of these gentlemen, it certainly would not be
+wise in the people at large to adopt these new political
+
+tenets without being fully convinced that they are founded
+in truth and sound policy.
+#user
+#cmp Ref text
+#log
+#next
+52.1a 10
+52.2a 5
diff --git a/usr/lib/learn/editor/L52.1a b/usr/lib/learn/editor/L52.1a
new file mode 100644 (file)
index 0000000..c1d36b7
--- /dev/null
@@ -0,0 +1,71 @@
+#print
+A very powerful tool is to use pairs of addresses
+which include searches.  For example, to print
+all lines from the present line to the next line
+containing "stop", say
+  .,/stop/p
+(remember that "." is the present line).  In this
+directory is a file "outline".  Find the line that
+begins "B.3.i".  Note that this line, and the next
+few lines, should begin "A..." for consistency.
+(Print the whole file to see what's wrong).
+Change all lines from this line to
+the line beginning "B.3.v" to begin "A.3".
+Then rewrite the file and type "ready".
+#create Ref
+First section
+A.1.i    Introduction
+A.1.ii   Definitions
+Second section
+A.2.i    Scope
+A.2.ii   Date effective
+A.2.iii  Who covered
+Third section
+A.3.i    Governing committee
+A.3.ii   Chairman's election
+A.3.iii  Board terms
+A.3.iv   Board elections
+A.3.v    Removal procedure
+Fourth section
+A.4.i    Meetings
+A.4.ii   Place of meeting
+A.4.iii  Frequency of meetings
+Fifth section
+A.5.i    Record keeping
+A.5.ii   Corresponding secretary
+A.5.iii  Recording secretary
+A.5.iv   Financial records
+#create outline
+First section
+A.1.i    Introduction
+A.1.ii   Definitions
+Second section
+A.2.i    Scope
+A.2.ii   Date effective
+A.2.iii  Who covered
+Third section
+B.3.i    Governing committee
+B.3.ii   Chairman's election
+B.3.iii  Board terms
+B.3.iv   Board elections
+B.3.v    Removal procedure
+Fourth section
+A.4.i    Meetings
+A.4.ii   Place of meeting
+A.4.iii  Frequency of meetings
+Fifth section
+A.5.i    Record keeping
+A.5.ii   Corresponding secretary
+A.5.iii  Recording secretary
+A.5.iv   Financial records
+#user
+#cmp outline Ref
+#succeed
+You got it right: I hope you found that the easiest
+way to change the file would be with the commands
+ /B.3.i/p
+ .,/B.3.v/s/B/A/
+or some such series.
+#log
+#next
+52.1b 10
diff --git a/usr/lib/learn/editor/L52.1b b/usr/lib/learn/editor/L52.1b
new file mode 100644 (file)
index 0000000..2ccba77
--- /dev/null
@@ -0,0 +1,60 @@
+#print
+Even more powerful is to use two context
+searches for the pair of addresses
+in front of a command.  For example
+  /abc/,/def/p
+will print all lines from the one that
+contains "abc" to the one that contains
+"def".  In this directory is a file
+"phone".  On every line between
+"Pinson" and "Johnson" change "tel" to "ext".
+(Again, print the whole file first to see
+what's going on here and why the file is bad.)
+Then rewrite the corrected file and
+type "ready".
+#create Ref
+ telephone numbers
+
+McIlroy M D       ext 6050
+Aho A V           ext 4862
+Baker B S         ext 6503
+Cherry L L        ext 6067
+Knowlton K        ext 2328
+Morris R          ext 3878
+Ossanna J F       ext 3520
+Thompson K        ext 2394
+
+Pinson E N        ext 2582
+Bourne S R        ext 7419
+Elliot R J        ext 2879
+Fraser A G        ext 3685
+Johnson S C       ext 3968
+Kernighan B W     ext 6021
+Ritchie D M       ext 3770
+Vollaro J R       ext 6321
+#create phone
+ telephone numbers
+
+McIlroy M D       ext 6050
+Aho A V           ext 4862
+Baker B S         ext 6503
+Cherry L L        ext 6067
+Knowlton K        ext 2328
+Morris R          ext 3878
+Ossanna J F       ext 3520
+Thompson K        ext 2394
+
+Pinson E N        tel 2582
+Bourne S R        tel 7419
+Elliot R J        tel 2879
+Fraser A G        tel 3685
+Johnson S C       tel 3968
+Kernighan B W     ext 6021
+Ritchie D M       ext 3770
+Vollaro J R       ext 6321
+#user
+#cmp phone Ref
+#log
+#next
+53.1a 10
+52.2c 5
diff --git a/usr/lib/learn/editor/L52.2a b/usr/lib/learn/editor/L52.2a
new file mode 100644 (file)
index 0000000..f8858c6
--- /dev/null
@@ -0,0 +1,61 @@
+#print
+You can use pairs of addresses which involve searches.  For example,
+to print all lines from the first line until the next line containing
+"stop", say
+
+  1,/stop/p
+
+In this directory is a file "list".  Print all lines from
+the first line to a line containing "023".  Then leave the editor
+and type "ready".
+#create list
+bio011
+bio012
+bio013
+bio014
+bio015
+bio016
+bio017
+bio021
+bio022
+bio023
+bio024
+bio025
+bio026
+bio027
+bio028
+bio031
+bio032
+bio033
+bio034
+bio035
+bio036
+bio037
+bio038
+bio041
+bio042
+bio043
+bio044
+bio045
+bio046
+bio047
+bio051
+#create x2
+bio011
+bio012
+bio013
+bio014
+bio015
+bio016
+bio017
+bio021
+bio022
+bio023
+#copyout
+#user
+#uncopyout
+grep bio .ocopy >x1
+#cmp x1 x2
+#log
+#next
+52.2b 5
diff --git a/usr/lib/learn/editor/L52.2b b/usr/lib/learn/editor/L52.2b
new file mode 100644 (file)
index 0000000..ce292b2
--- /dev/null
@@ -0,0 +1,65 @@
+#print
+In this directory is a file "outline".  Find the line that
+begins "B.3.i".  Note that this line, and the next few
+lines, should begin "A"... for  consistency.
+(Print the whole file to see what is going on.  It's fairly short.)
+Change all lines from the line beginning "B.3.i" to the line
+beginning "B.3.v" to begin "A.3".  Then rewrite the file
+and type "ready".
+#create Ref
+First section
+A.1.i    Introduction
+A.1.ii   Definitions
+Second section
+A.2.i    Scope
+A.2.ii   Date effective
+A.2.iii  Who covered
+Third section
+A.3.i    Governing committee
+A.3.ii   Chairman's election
+A.3.iii  Board terms
+A.3.iv   Board elections
+A.3.v    Removal procedure
+Fourth section
+A.4.i    Meetings
+A.4.ii   Place of meeting
+A.4.iii  Frequency of meetings
+Fifth section
+A.5.i    Record keeping
+A.5.ii   Corresponding secretary
+A.5.iii  Recording secretary
+A.5.iv   Financial records
+#create outline
+First section
+A.1.i    Introduction
+A.1.ii   Definitions
+Second section
+A.2.i    Scope
+A.2.ii   Date effective
+A.2.iii  Who covered
+Third section
+B.3.i    Governing committee
+B.3.ii   Chairman's election
+B.3.iii  Board terms
+B.3.iv   Board elections
+B.3.v    Removal procedure
+Fourth section
+A.4.i    Meetings
+A.4.ii   Place of meeting
+A.4.iii  Frequency of meetings
+Fifth section
+A.5.i    Record keeping
+A.5.ii   Corresponding secretary
+A.5.iii  Recording secretary
+A.5.iv   Financial records
+#user
+#cmp outline Ref
+#succeed
+You got it right: I hope you found that the easiest
+way to change the file would be with the commands
+ /B.3.i/p
+ .,/B.3.v/s/B/A/
+or some such series.
+#log
+#next
+52.1b 10
diff --git a/usr/lib/learn/editor/L52.2c b/usr/lib/learn/editor/L52.2c
new file mode 100644 (file)
index 0000000..b9d31ba
--- /dev/null
@@ -0,0 +1,56 @@
+#print
+In this directory is a file "memo".  Between the line
+containing "I." and the line containing "II."
+change all multiple blanks to one blank.
+Then rewrite the file and type "ready".
+#create Ref
+.TL
+The  Time  Has  Come
+.AU
+Joe Idiot
+.AI
+Bell  Labs
+Murray  Hill, NJ 07974
+.SH
+I. Introduction
+.PP
+This document describes the problems of
+designing complex systems without adequately
+trained manpower. The solution adopted was
+to trick 90% of the staff into thinking they
+were working on the system when in fact they were not.
+This let the remaining 1:0% of the staff actually get
+the thing built.
+.SH
+II. Details
+.PP
+The project   began on   June 1, 1974.   It was completed
+on Sept. 1, 1975   and has worked successfully   since then.
+#create memo
+.TL
+The  Time  Has  Come
+.AU
+Joe Idiot
+.AI
+Bell  Labs
+Murray  Hill, NJ 07974
+.SH
+I. Introduction
+.PP
+This document describes the problems  of
+designing  complex systems  without  adequately
+trained manpower.  The solution adopted   was
+to  trick  90% of the staff  into  thinking  they
+were working on the system when in fact they were not.
+This  let  the   remaining  1:0% of the staff actually   get
+the thing built.
+.SH
+II. Details
+.PP
+The project   began on   June 1, 1974.   It was completed
+on Sept. 1, 1975   and has worked successfully   since then.
+#user
+#cmp memo Ref
+#log
+#next
+53.1a 10
diff --git a/usr/lib/learn/editor/L53.1a b/usr/lib/learn/editor/L53.1a
new file mode 100644 (file)
index 0000000..c3c5a8b
--- /dev/null
@@ -0,0 +1,22 @@
+#print
+Note that the // searches always go forward.
+Sometimes you want to go backward, to find
+some expression on a line before the
+one you are now working on.
+In that case you can search with a command like
+  ?abc?p
+which prints the nearest preceding line which
+contains 'abc'.  What command would print
+the nearest previous line that ends in "cat"?
+Type "answer COMMAND" when you figure it out.
+#copyin
+#user
+#uncopyin
+#match ?cat$?p
+The "p" isn't needed, but use it if you like too.
+#match ?cat$?
+#cmp X1 X2
+#log
+#next
+54.1a 10
+53.2b 7
diff --git a/usr/lib/learn/editor/L53.2b b/usr/lib/learn/editor/L53.2b
new file mode 100644 (file)
index 0000000..f3b1315
--- /dev/null
@@ -0,0 +1,416 @@
+#print
+There is a big file "federal" in this directory.
+It contains the following mistyped words:
+  Typed as   Should be
+cotnend       contend
+aalarm        alarm
+exedient      expedient
+drabel        durable
+ugdes         judges
+trame         trample
+viws          views
+
+Fix things up, rewrite the file, and then type "ready".
+#create Ref
+Among the numerous advantages promised by a well-constructed
+Union, none deserves to be more accurately
+developed than its tendency to break and control the violence
+of faction.
+The friend of popular governments never finds himself
+so much alarmed for their character and fate as when he
+contemplates their propensity to this dangerous vice.
+He will not fail, therefore, to set a due value on
+any plan which, without violating the principles to which
+he is attached, provides a proper cure for it.
+The instability, injustice, and confusion introduced into the public
+councils have, in truth, been the mortal diseases under
+which popular governments have everywhere perished, as
+they continue to be the favorite and fruitful topics from
+which the adversaries to liberty derive their most specious
+declamations.
+The valuable improvements made by the American constitutions
+on the popular models, both ancient
+and modern, cannot certainly be too much admired;
+but it would be an unwarrantable partiality to contend
+that they have as effectually obviated the danger on this
+side, as was wished and expected.
+Complaints are everywhere heard from our most considerate and virtuous
+citizens, equally the friends of public and private faith
+and of public and personal liberty, that out governments
+are too unstable, that the public good is disregarded in
+the conflicts of rival parties, and that measures are too
+often decided, not according to the rules of justice and
+the rights of the minor party, but by the superior force
+of an interested and overbearing majority.
+However anxiously we may wish that these complaints had no
+foundation, the evidence of known facts will not permit
+us to deny that they are in some degree true.
+It will be found, indeed, on a candid review of our situation, that
+some of the distresses under which we labor have been
+erroneously charged on the operation of our governments;
+but it will be found, at the same time, that other
+causes will not alone account for many of our heaviest
+misfortunes; and, particularly, for that prevailing and increasing
+distrust of public engagements and alarm for
+private rights which are echoed from one end of the
+continent to the other.
+These must be chiefly, if not wholly,
+effects of the unsteadiness and injustice with
+which a factious spirit has tainted out public administration.
+   By a faction I understand a number of citizens,
+whether amounting to a majority or minority of the whole,
+who are united and actuated by some common impulse
+of passion, or of interest, adverse to the rights of other
+citizens, or to the permanent and aggregate interests of
+the community.
+   There are two methods of curing the mischiefs of
+faction: The one,
+by removing its causes; the other, by controlling
+its effects.
+   There are again two methods of removing the causes of faction:
+The one, by destroying the liberty which is essential to its existence;
+The other, by giving to every
+citizen the same opinions, the same passions, and the
+same interests.
+   It could never be more truly said than of the first
+remedy that it was worse than the disease.
+Liberty is to
+faction what air is to fire, an ailment without which it
+instantly expires.
+But it could not be less folly to
+abolish liberty, which is essential to political life,
+because it nourishes faction than it would be to wish the
+annihilation of air, which is essential to animal life,
+because it imparts to dire its destructive agency.
+   The second expedient is as impracticable as the first
+would be unwise.
+As long as the reason of man continues
+fallible, and he is at liberty to exercise it, different 
+opinions will be formed.
+As long as the connection subsists
+between his reason and his self-love, his opinions and his
+passions will have a reciprocal influence on each other;
+and the former will be objects to which the latter will
+attach themselves.
+The diversity in the faculties of men,
+from which the rights of property originate, is not less an
+insuperable obstacle to the uniformity of interests.
+The protection of these faculties is the first object of
+government.
+From the protection of different and unequal
+faculties of acquiring property, the possession of
+different degrees and kinds of property immediately results;
+and from the influence of these on the sentiments and views
+of the respective proprietors ensues a division of the
+society into different interests and parties.
+   The latent causes of faction are thus sown in the
+nature of man; and we see them everywhere brought
+into different degrees of activity, according to the
+different circumstances of civil society.
+A zeal for different opinions
+concerning religion, concerning government, and
+many other points, as well of speculation as of practice;
+an attachment to different leaders ambitiously contending
+for pre-eminence and power; or to persons of other
+descriptions whose fortunes have been interesting to the
+human passions, have, in turn, divided mankind into
+parties, inflamed them with mutual animosity, and
+rendered them much more disposed to vex and oppress each
+other than to co-operate for their common goal.
+So strong is this propensity of mankind to fall into mutual
+animosities that where no substantial occasion presents
+itself the most frivolous and fanciful distinctions have
+been sufficient to kindle their unfriendly passions and
+excite their most violent conflicts.
+But the most common and durable
+source of factions has been the verious
+and unequal distribution of property.
+Those who hold and those who are without
+property have ever formed distinct
+interests in society.
+Those who are creditors, and those
+who are debtors, fall under a like discrimination.
+A landed interest, a manufacturing interest,
+a mercantile interest, a moneyed interest,
+with many lesser interests, grow up of
+necessity in civilized nations, and divided them into
+different classes, actuated by different sentiments and views.
+The regulation of these various and interfering interests
+involves the spirit of party and faction in the necessary
+and ordinary operations of government.
+   No man is allowed to be a judge in has own cause,
+because his interest would certainly bias his judgement,
+and, not improbably, corrupt his integrity.
+With equal, nay with greater reason, a body
+of men are unfit to be both judges and parties at the same time;
+yet what are many of the most important acts of
+legislation but so many judicial determinations,
+not indeed concerning the
+rights of single person, but concerning the rights of large
+bodies of citizens?
+And what are the different classes of legislators but
+advocates and parties to the causes which
+they determine?
+Is a law proposed concerning private
+debts?
+It is a question to which the creditors are parties
+one one side and the debtors on the other.
+Justice ought to hold the balance
+between them.
+Yet the parties are, and must be,
+themselves the judges; and the most numerous
+party, or in other words, the most powerful faction must
+be expected to prevail.
+Shall domestic manufacturers be
+encouraged, and in what degree, by restrictions on foreign
+manufacturers?
+are questions which would be differently
+decided by the landed and the manufacturing classes, and
+probably by neither with a sole regard to justice and the
+public good.
+The apportionment of taxes on the various
+descriptions of property is an act which seems to require
+the most exact impartiality; yet there is, perhaps, no
+legislative act in which greater opportunity and
+temptation are given to a predominant party to trample on the
+rules of justice.
+Every shilling with which they overburden the inferior
+number is a shilling saved to their own pockets.
+   It is in vain to say that enlightened statesmen will be
+able to adjust these clashing interests and render them
+all subservient to the public good.
+Enlightened statesmen will not
+always be at the helm.
+Nor, in many cases, can
+such an adjustment be made at all without taking into
+view indirect and remote considerations, which will rarely
+prevail over the immediate interest which one party may
+find in disregarding the rights of another or the good of
+the whole.
+   The inference to which we are brought is that the causes
+of faction cannot be removed and that relief is only to be
+sought in the means of controlling its effects.
+   If a faction consists of less than a majority, relief is
+supplied by the republican principle, which enables the
+majority to defeat its sinister views by regular vote.
+It may clog the administration, it may convulse the society;
+But it will be unable to execute and mask its violence
+under the forms of the Constitution.
+When a majority is included in a faction,
+The form of popular government, on
+the other hand, enables it to sacrifice to its ruling passion
+or interest both the public good and the rights of other
+citizens.
+To secure the public good and private rights
+against the danger of such a faction, and at the same
+time to preserve the spirit and form of popular
+government, is than the great object to which our inquiries
+are directed.
+Let me add that it is the great desideratum by which
+alone this form of government can be rescued from
+the opprobrium under which it has so long labored and
+be recommended to the esteem and adoption of mankind.
+#create federal
+Among the numerous advantages promised by a well-constructed
+Union, none deserves to be more accurately
+developed than its tendency to break and control the violence
+of faction.
+The friend of popular governments never finds himself
+so much alarmed for their character and fate as when he
+contemplates their propensity to this dangerous vice.
+He will not fail, therefore, to set a due value on
+any plan which, without violating the principles to which
+he is attached, provides a proper cure for it.
+The instability, injustice, and confusion introduced into the public
+councils have, in truth, been the mortal diseases under
+which popular governments have everywhere perished, as
+they continue to be the favorite and fruitful topics from
+which the adversaries to liberty derive their most specious
+declamations.
+The valuable improvements made by the American constitutions
+on the popular models, both ancient
+and modern, cannot certainly be too much admired;
+but it would be an unwarrantable partiality to cotnend
+that they have as effectually obviated the danger on this
+side, as was wished and expected.
+Complaints are everywhere heard from our most considerate and virtuous
+citizens, equally the friends of public and private faith
+and of public and personal liberty, that out governments
+are too unstable, that the public good is disregarded in
+the conflicts of rival parties, and that measures are too
+often decided, not according to the rules of justice and
+the rights of the minor party, but by the superior force
+of an interested and overbearing majority.
+However anxiously we may wish that these complaints had no
+foundation, the evidence of known facts will not permit
+us to deny that they are in some degree true.
+It will be found, indeed, on a candid review of our situation, that
+some of the distresses under which we labor have been
+erroneously charged on the operation of our governments;
+but it will be found, at the same time, that other
+causes will not alone account for many of our heaviest
+misfortunes; and, particularly, for that prevailing and increasing
+distrust of public engagements and aalarm for
+private rights which are echoed from one end of the
+continent to the other.
+These must be chiefly, if not wholly,
+effects of the unsteadiness and injustice with
+which a factious spirit has tainted out public administration.
+   By a faction I understand a number of citizens,
+whether amounting to a majority or minority of the whole,
+who are united and actuated by some common impulse
+of passion, or of interest, adverse to the rights of other
+citizens, or to the permanent and aggregate interests of
+the community.
+   There are two methods of curing the mischiefs of
+faction: The one,
+by removing its causes; the other, by controlling
+its effects.
+   There are again two methods of removing the causes of faction:
+The one, by destroying the liberty which is essential to its existence;
+The other, by giving to every
+citizen the same opinions, the same passions, and the
+same interests.
+   It could never be more truly said than of the first
+remedy that it was worse than the disease.
+Liberty is to
+faction what air is to fire, an ailment without which it
+instantly expires.
+But it could not be less folly to
+abolish liberty, which is essential to political life,
+because it nourishes faction than it would be to wish the
+annihilation of air, which is essential to animal life,
+because it imparts to dire its destructive agency.
+   The second exedient is as impracticable as the first
+would be unwise.
+As long as the reason of man continues
+fallible, and he is at liberty to exercise it, different 
+opinions will be formed.
+As long as the connection subsists
+between his reason and his self-love, his opinions and his
+passions will have a reciprocal influence on each other;
+and the former will be objects to which the latter will
+attach themselves.
+The diversity in the faculties of men,
+from which the rights of property originate, is not less an
+insuperable obstacle to the uniformity of interests.
+The protection of these faculties is the first object of
+government.
+From the protection of different and unequal
+faculties of acquiring property, the possession of
+different degrees and kinds of property immediately results;
+and from the influence of these on the sentiments and views
+of the respective proprietors ensues a division of the
+society into different interests and parties.
+   The latent causes of faction are thus sown in the
+nature of man; and we see them everywhere brought
+into different degrees of activity, according to the
+different circumstances of civil society.
+A zeal for different opinions
+concerning religion, concerning government, and
+many other points, as well of speculation as of practice;
+an attachment to different leaders ambitiously contending
+for pre-eminence and power; or to persons of other
+descriptions whose fortunes have been interesting to the
+human passions, have, in turn, divided mankind into
+parties, inflamed them with mutual animosity, and
+rendered them much more disposed to vex and oppress each
+other than to co-operate for their common goal.
+So strong is this propensity of mankind to fall into mutual
+animosities that where no substantial occasion presents
+itself the most frivolous and fanciful distinctions have
+been sufficient to kindle their unfriendly passions and
+excite their most violent conflicts.
+But the most common and drabel
+source of factions has been the verious
+and unequal distribution of property.
+Those who hold and those who are without
+property have ever formed distinct
+interests in society.
+Those who are creditors, and those
+who are debtors, fall under a like discrimination.
+A landed interest, a manufacturing interest,
+a mercantile interest, a moneyed interest,
+with many lesser interests, grow up of
+necessity in civilized nations, and divided them into
+different classes, actuated by different sentiments and views.
+The regulation of these various and interfering interests
+involves the spirit of party and faction in the necessary
+and ordinary operations of government.
+   No man is allowed to be a judge in has own cause,
+because his interest would certainly bias his judgement,
+and, not improbably, corrupt his integrity.
+With equal, nay with greater reason, a body
+of men are unfit to be both ugdes and parties at the same time;
+yet what are many of the most important acts of
+legislation but so many judicial determinations,
+not indeed concerning the
+rights of single person, but concerning the rights of large
+bodies of citizens?
+And what are the different classes of legislators but
+advocates and parties to the causes which
+they determine?
+Is a law proposed concerning private
+debts?
+It is a question to which the creditors are parties
+one one side and the debtors on the other.
+Justice ought to hold the balance
+between them.
+Yet the parties are, and must be,
+themselves the judges; and the most numerous
+party, or in other words, the most powerful faction must
+be expected to prevail.
+Shall domestic manufacturers be
+encouraged, and in what degree, by restrictions on foreign
+manufacturers?
+are questions which would be differently
+decided by the landed and the manufacturing classes, and
+probably by neither with a sole regard to justice and the
+public good.
+The apportionment of taxes on the various
+descriptions of property is an act which seems to require
+the most exact impartiality; yet there is, perhaps, no
+legislative act in which greater opportunity and
+temptation are given to a predominant party to trame on the
+rules of justice.
+Every shilling with which they overburden the inferior
+number is a shilling saved to their own pockets.
+   It is in vain to say that enlightened statesmen will be
+able to adjust these clashing interests and render them
+all subservient to the public good.
+Enlightened statesmen will not
+always be at the helm.
+Nor, in many cases, can
+such an adjustment be made at all without taking into
+view indirect and remote considerations, which will rarely
+prevail over the immediate interest which one party may
+find in disregarding the rights of another or the good of
+the whole.
+   The inference to which we are brought is that the causes
+of faction cannot be removed and that relief is only to be
+sought in the means of controlling its effects.
+   If a faction consists of less than a majority, relief is
+supplied by the republican principle, which enables the
+majority to defeat its sinister viws by regular vote.
+It may clog the administration, it may convulse the society;
+But it will be unable to execute and mask its violence
+under the forms of the Constitution.
+When a majority is included in a faction,
+The form of popular government, on
+the other hand, enables it to sacrifice to its ruling passion
+or interest both the public good and the rights of other
+citizens.
+To secure the public good and private rights
+against the danger of such a faction, and at the same
+time to preserve the spirit and form of popular
+government, is than the great object to which our inquiries
+are directed.
+Let me add that it is the great desideratum by which
+alone this form of government can be rescued from
+the opprobrium under which it has so long labored and
+be recommended to the esteem and adoption of mankind.
+#user
+#cmp federal Ref
+#log
+#next
+54.1a 10
diff --git a/usr/lib/learn/editor/L54.1a b/usr/lib/learn/editor/L54.1a
new file mode 100644 (file)
index 0000000..d813f6e
--- /dev/null
@@ -0,0 +1,40 @@
+#print
+A time-saving feature of context searches is
+that the editor remembers the last regular expression
+mentioned, and if you just say // or ??
+with no expression, it assumes the same one.  Thus
+ /abc/s//def/
+searches for a line with 'abc', and, on finding it,
+changes the 'abc' to 'def'.    Similarly
+ /qqq/s///
+finds a 'qqq' and then throws it away, as if the
+command were
+ /qqq/s/qqq//
+In this directory is a file 'error' which contains
+"servixe" as a mistyping for "service".  Find
+the bad instance and fix it, if possible with one command.
+Then rewrite the file and type 'ready'.
+#create Ref
+This file contains many copies
+of the word service
+but in all of those lines
+with service in them
+the next line has a
+service that is spelled
+wrong unlike the other
+services.
+#create error
+This file contains many copies
+of the word service
+but in all of those lines
+with service in them
+the next line has a
+servixe that is spelled
+wrong unlike the other
+services.
+#user
+#cmp error Ref
+#log
+#next
+55.1a 10
+54.1b 8
diff --git a/usr/lib/learn/editor/L54.1b b/usr/lib/learn/editor/L54.1b
new file mode 100644 (file)
index 0000000..0f90c39
--- /dev/null
@@ -0,0 +1,43 @@
+#print
+The fact that the system remembers the last regular expression
+it had is particularly useful when the regular expression is
+complex.  Suppose, for example, you know that the
+words "first" and "second" appear on the same line and you wish
+to delete them and everything between them.  You could write
+  /first.*second/s/first.*second//p
+but isn't it easier to do
+  /first.*second/s///p
+Edit the file "passage"; the words "twentieth" and "impending" appear
+on the same line.  Replace them and everything between
+them by the word "impending" (i.e. delete from "twentieth"
+up to but not including "impending").  One command, if you can.
+Then rewrite the file and type ready.
+#create Ref
+   America's rise to world power is a consequence of the nation's
+geographic position, natural resources, and dynamic energy.  For
+the first century and more of national history, however, continental
+expansion and internal developments largely absorbed the energies
+of the American people.  Every dictate of public interest emphasized
+the importance of avoiding all entanglements that might involve the
+young republic in foreign rivalries and foreign wars.  Only with the
+impending shifts
+in the European balance of power, and the growth of American economic
+and industrial strength create a situation that made impossible a
+continued aloofness from international affairs.
+#create passage
+   America's rise to world power is a consequence of the nation's
+geographic position, natural resources, and dynamic energy.  For
+the first century and more of national history, however, continental
+expansion and internal developments largely absorbed the energies
+of the American people.  Every dictate of public interest emphasized
+the importance of avoiding all entanglements that might involve the
+young republic in foreign rivalries and foreign wars.  Only with the
+twentieth century did a rapidly contracting world, impending shifts
+in the European balance of power, and the growth of American economic
+and industrial strength create a situation that made impossible a
+continued aloofness from international affairs.
+#user
+#cmp passage Ref
+#log
+#next
+55.1a 10
diff --git a/usr/lib/learn/editor/L55.1a b/usr/lib/learn/editor/L55.1a
new file mode 100644 (file)
index 0000000..56c8fe5
--- /dev/null
@@ -0,0 +1,34 @@
+#print
+This is an easy unit.  If you just hit
+"newline" (or "carriage return", whatever it
+is labeled on your terminal), the
+editor will simply print the next line
+as you can see by trying this out.  Edit the
+file "pres"; print some line; then hit return
+or newline, and watch the editor print the
+next line.  Is there any difference between
+newline and ".+1p" as a command?  When you
+think you know, leave the editor and type "yes" or "no".
+#create pres
+George Washington
+John Adams
+Thomas Jefferson
+James Madison
+James Monroe
+John Quincy Adams
+Andrew Jackson
+Martin van Buren
+William Henry Harrison
+John Tyler
+James K. Polk
+Franklin Pierce
+Millard Fillmore
+James Buchanan
+Abraham Lincoln
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+56.1a 10
diff --git a/usr/lib/learn/editor/L56.1a b/usr/lib/learn/editor/L56.1a
new file mode 100644 (file)
index 0000000..6ac814f
--- /dev/null
@@ -0,0 +1,37 @@
+#print
+Is there just as easy a way of
+printing the immediately preceding line?
+Not quite, but almost.  The line
+
+-
+
+will print the line just before the line you
+are on.  What's the equivalent command
+in terms of "." and "p"?  Type "answer COMMAND"
+when you figure it out.  Again, you can experiment
+first; the same file named "pres" is in this directory.
+#create pres
+George Washington
+John Adams
+Thomas Jefferson
+James Madison
+James Monroe
+John Quincy Adams
+Andrew Jackson
+Martin van Buren
+William Henry Harrison
+John Tyler
+James K. Polk
+Franklin Pierce
+Millard Fillmore
+James Buchanan
+Abraham Lincoln
+#copyin
+#user
+#uncopyin
+#match .-1p
+The "p" isn't needed.
+#match .-1
+#log
+#next
+57.1a 10
diff --git a/usr/lib/learn/editor/L57.1a b/usr/lib/learn/editor/L57.1a
new file mode 100644 (file)
index 0000000..c03026f
--- /dev/null
@@ -0,0 +1,48 @@
+#print
+For symmetry, you can use
+
++
+
+instead of either ".+1p" or an empty
+line (just a newline).  The only advantage
+that + has is that you can repeat it:
+
+++
+
+prints the second following line, and 
+
++++
+
+the third.  The same is true of -.
+If the current line is line number 10,
+what line number is -- going to be?
+(Hint:  you can find out by editing a file
+such as "pres", saying "10p", and then
+saying "--", and then saying ".=" - remember
+the "=" command?)
+When you find out, type "answer N" where
+N is the number.
+#create pres
+George Washington
+John Adams
+Thomas Jefferson
+James Madison
+James Monroe
+John Quincy Adams
+Andrew Jackson
+Martin van Buren
+William Henry Harrison
+John Tyler
+James K. Polk
+Franklin Pierce
+Millard Fillmore
+James Buchanan
+Abraham Lincoln
+#copyin
+#user
+#uncopyin
+#match 8
+#log
+#next
+60.1a 10
+60.2a 5
diff --git a/usr/lib/learn/editor/L6.1a b/usr/lib/learn/editor/L6.1a
new file mode 100644 (file)
index 0000000..0e697aa
--- /dev/null
@@ -0,0 +1,41 @@
+#print
+You may well ask how the editor knows which line to print.
+The editor keeps track of the 'current line', which
+is usually the last line you touched in any way.
+When you begin editing a file, for example, the
+current line is the last line.
+If you want to print any particular line, however,
+that is easy.  For example, to print the 3rd line you say
+
+3p
+
+To print the first line
+
+1p
+
+(That's a one, no matter how much it looks like the letter "l".)
+Here is a file: I'll put you into the editor
+with that file as the 'current file' - print the 4th line,
+then type 'w', 'q', and 'ready' as usual.
+#create Ref
+james madison
+91
+#create file
+george washington
+john adams
+thomas jefferson
+james madison
+james monroe
+john quincy adams
+#print file
+#copyout
+#pipe
+ed file
+#user
+#unpipe
+#uncopyout
+tail -2 .ocopy >X2
+#cmp Ref X2
+#log
+#next
+7.1a 10
diff --git a/usr/lib/learn/editor/L6.2a b/usr/lib/learn/editor/L6.2a
new file mode 100644 (file)
index 0000000..4df8247
--- /dev/null
@@ -0,0 +1,40 @@
+#print
+How does the editor choose a line to print?
+It always remembers a 'current line', which
+is the last line of the file originally,
+but you can choose any line you want.  The command
+
+3p
+
+prints the third line of the file, for example.
+And
+
+1p
+
+prints the first line.  Note that is the digit one
+there, not the letter l, no matter how much alike they
+look.  I'll put you into the editor with the
+file listed below: print the first line,
+then type 'w', 'q' and 'ready' as usual.
+#create Ref
+george washington
+91
+#create file
+george washington
+john adams
+thomas jefferson
+james madison
+james monroe
+john quincy adams
+#print file
+#copyout
+#pipe
+ed file
+#user
+#unpipe
+#uncopyout
+tail -2 .ocopy >X2
+#cmp Ref X2
+#log
+#next
+6.2b 5
diff --git a/usr/lib/learn/editor/L6.2b b/usr/lib/learn/editor/L6.2b
new file mode 100644 (file)
index 0000000..2c47996
--- /dev/null
@@ -0,0 +1,26 @@
+#print
+Same thing again, but this time print the
+fifth line in the file.  Then type "w", "q",
+and "ready".
+#create Ref
+james monroe
+91
+#create file
+george washington
+john adams
+thomas jefferson
+james madison
+james monroe
+john quincy adams
+#print file
+#copyout
+#pipe
+ed file
+#user
+#unpipe
+#uncopyout
+tail -2 .ocopy >X2
+#cmp Ref X2
+#log
+#next
+7.1a 10
diff --git a/usr/lib/learn/editor/L60.1a b/usr/lib/learn/editor/L60.1a
new file mode 100644 (file)
index 0000000..78874c8
--- /dev/null
@@ -0,0 +1,61 @@
+#print
+So far you have always dealt with one file at a time.
+Suppose you wanted to combine two files - there is nothing
+we have covered so far that will do that.  But the
+editor does have a command 'r' (read)
+
+r file
+
+which reads in the contents of "file" without throwing
+away what you already have.  So that you can combine
+the files "cat" and "dog" (and name the result "animal")
+by saying
+
+ed
+r cat
+r dog
+w animal
+q
+
+In this directory are four files named
+for continents.  Combine them into
+one file named "world".
+(Read the files in alphabetical order,
+as they are listed).  You may want to list
+the input files and the combined files
+with "cat" to see what they look like.
+When done, type "ready" as usual.
+#create Ref
+This is file
+'africa' and will be listed first.
+------
+this file will
+have to do
+for both american
+continents
+-----
+  File "asia"
+  is indented
+  two spaces.
+Europe's file is only one line long.
+#create africa
+This is file
+'africa' and will be listed first.
+#create america
+------
+this file will
+have to do
+for both american
+continents
+-----
+#create asia
+  File "asia"
+  is indented
+  two spaces.
+#create europe
+Europe's file is only one line long.
+#user
+#cmp Ref world
+#log
+#next
+60.1b 10
diff --git a/usr/lib/learn/editor/L60.1b b/usr/lib/learn/editor/L60.1b
new file mode 100644 (file)
index 0000000..b990cc6
--- /dev/null
@@ -0,0 +1,78 @@
+#print
+You can, of course, use the 'r' command
+with an address.  Any editor command can be used
+with an address (except 'q').  For example, there
+is a file 'phone' in this directory.
+If you print it, you'll see that one department
+is missing from the list; it is on file 'filler'.
+Edit 'phone'; read in 'filler' after the line
+saying '1273'.  Then rewrite 'phone', leave the
+editor, and say "ready".
+#create Ref
+ telephone numbers
+
+Department 1271
+McIlroy M D       ext 6050
+Aho A V           ext 4862
+Baker B S         ext 6503
+Cherry L L        ext 6067
+Knowlton K        ext 2328
+Morris R          ext 3878
+Ossanna J F       ext 3520
+Thompson K        ext 2394
+
+Department 1273
+Pinson E N        ext 2582
+Bourne S R        ext 7419
+Elliot R J        ext 2879
+Fraser A G        ext 3685
+Johnson S C       ext 3968
+Kernighan B W     ext 6021
+Ritchie D M       ext 3770
+Vollaro J R       ext 6321
+
+Department 1274
+Brown W S         ext 4822
+Blue J L          ext 6558
+Feldman S I       ext 2059
+Hall A D          ext 4006
+Lesk M E          ext 6377
+Schryer N L       ext 2912
+Warner D D        ext 2833
+#create filler
+Pinson E N        ext 2582
+Bourne S R        ext 7419
+Elliot R J        ext 2879
+Fraser A G        ext 3685
+Johnson S C       ext 3968
+Kernighan B W     ext 6021
+Ritchie D M       ext 3770
+Vollaro J R       ext 6321
+#create phone
+ telephone numbers
+
+Department 1271
+McIlroy M D       ext 6050
+Aho A V           ext 4862
+Baker B S         ext 6503
+Cherry L L        ext 6067
+Knowlton K        ext 2328
+Morris R          ext 3878
+Ossanna J F       ext 3520
+Thompson K        ext 2394
+
+Department 1273
+
+Department 1274
+Brown W S         ext 4822
+Blue J L          ext 6558
+Feldman S I       ext 2059
+Hall A D          ext 4006
+Lesk M E          ext 6377
+Schryer N L       ext 2912
+Warner D D        ext 2833
+#user
+#cmp phone Ref
+#log
+#next
+61.1a 10
diff --git a/usr/lib/learn/editor/L60.2a b/usr/lib/learn/editor/L60.2a
new file mode 100644 (file)
index 0000000..e622960
--- /dev/null
@@ -0,0 +1,60 @@
+#print
+Suppose you wanted to combine two files?  No editor command you
+have learned so far will do that. The command 'r' is just what the doctor
+ordered.  It reads in a file, without throwing away the existing buffer.
+So, for example,
+  ed para1
+  r para2
+  w both
+  q
+will edit "para1"; then read in "para2" at the end; and then
+write the combined stuff on "both".  Try that, with those names,
+in this directory.  Then type "ready".
+#create Ref
+   We say that matter is anything which occupies space and has
+weight.  Matter possesses inertia, which is a resistance to change
+of position or motion.  It may be acted on by forces which may set
+it in motion, or change its motion.  While all these statements
+are descriptive of matter, they do not provide us with a completely
+satisfactory definition.  Scientists, with their great knowledge
+of the properties and behavior of matter, are not yet able to
+define it precisely.  Nature still holds many secrets to challenge
+the minds of men.
+   The quantity of matter which a body possesses is known as its
+mass.
+   When one end of a long glass tube that is open at both ends is
+placed in water, forces cause the water to rise in the tube to a
+certain height.  The finer the bore of the tube, the higher the
+water rises.  A tube with a hairlike bore is called a capillary
+tube and the liquid rise in it is called capillarity.  How could
+you show that this rise is not due to atmospheric pressure?
+   Seemingly, water rises in capillary tubes because the adhesive
+forces between glass and water molecules are greater than the cohesive
+forces between water molecules.
+#create para1
+   We say that matter is anything which occupies space and has
+weight.  Matter possesses inertia, which is a resistance to change
+of position or motion.  It may be acted on by forces which may set
+it in motion, or change its motion.  While all these statements
+are descriptive of matter, they do not provide us with a completely
+satisfactory definition.  Scientists, with their great knowledge
+of the properties and behavior of matter, are not yet able to
+define it precisely.  Nature still holds many secrets to challenge
+the minds of men.
+   The quantity of matter which a body possesses is known as its
+mass.
+#create para2
+   When one end of a long glass tube that is open at both ends is
+placed in water, forces cause the water to rise in the tube to a
+certain height.  The finer the bore of the tube, the higher the
+water rises.  A tube with a hairlike bore is called a capillary
+tube and the liquid rise in it is called capillarity.  How could
+you show that this rise is not due to atmospheric pressure?
+   Seemingly, water rises in capillary tubes because the adhesive
+forces between glass and water molecules are greater than the cohesive
+forces between water molecules.
+#user
+#cmp both Ref
+#log
+#next
+60.2b 5
diff --git a/usr/lib/learn/editor/L60.2b b/usr/lib/learn/editor/L60.2b
new file mode 100644 (file)
index 0000000..f98b9ea
--- /dev/null
@@ -0,0 +1,109 @@
+#print
+You can of course combine many files.  Make a file
+"total" which contains the pieces "first", "second",
+"third", and "fourth" in that order.  Then type "ready".
+#create Ref
+   It has been already observed that the federal government
+ought to possess the power of providing for the support
+of the national forces; in which proposition was intended
+to be included the expense of raising troops, of building
+and equipping fleets, and all other expenses in any wise
+connected with military arrangements and operations.  But
+these are not the only objects to which the jurisdiction of
+the Union in respect to revenue must necessarily be empowered
+to extend.  It must embrace a provision for the
+support of the national civil list; for the payment of the
+national debts contracted, or that may be contracted;
+and, in general, for all those matters which will call for
+disbursements out of the national treasury.  The conclusion
+is that there must be interwoven in the frame of the
+government a general power of taxation, in one shape or
+another.
+   Money is, with propriety, considered as the vital principle
+of the body politic; as that which sustains its life and
+motion and enables it to perform its most essential functions.
+A complete power, therefore, to procure a regular
+and adequate supply of revenue, as far as the resources
+of the community will permit, may be regarded
+as an indispensable ingredient in every constitution.
+From a deficiency in this particular, one of two evils
+must ensue:  either the people must be subjected to
+continual plunder, as a substitute for a more eligible
+mode of supplying the public wants, or the government
+must sink into a fatal atrophy, and, in a short course of
+time, perish.
+   In the Ottoman or Turkish empire the sovereign,
+though in other respects absolute master of the lives and
+fortunes of his subjects, has no right to impose a new tax.
+The consequence is that he permits the bashaws or governors
+of provinces to pillage the people at discretion,
+and, in turn, squeezes out of them the sums of which he
+stands in need to satisfy his own exigencies and those of
+the state.  In America, from a like cause, the government
+of the Union has gradually dwindled into a state of decay,
+approaching nearly to annihilation.  Who can doubt that
+the happiness of the people in both countries would be
+promoted by competent authorities in the proper hands
+to provide the revenues which the necessities of the public
+might require?
+   The present Confederation, feeble as it is, intended to
+repose in the United States an unlimited power of providing
+for the pecuniary wants of the Union.  But proceeding
+upon an erroneous principle, it has been done in
+such a manner as entirely to have frustrated the intention.
+#create first
+   It has been already observed that the federal government
+ought to possess the power of providing for the support
+of the national forces; in which proposition was intended
+to be included the expense of raising troops, of building
+and equipping fleets, and all other expenses in any wise
+connected with military arrangements and operations.  But
+these are not the only objects to which the jurisdiction of
+the Union in respect to revenue must necessarily be empowered
+to extend.  It must embrace a provision for the
+support of the national civil list; for the payment of the
+national debts contracted, or that may be contracted;
+and, in general, for all those matters which will call for
+disbursements out of the national treasury.  The conclusion
+is that there must be interwoven in the frame of the
+government a general power of taxation, in one shape or
+another.
+#create fourth
+   The present Confederation, feeble as it is, intended to
+repose in the United States an unlimited power of providing
+for the pecuniary wants of the Union.  But proceeding
+upon an erroneous principle, it has been done in
+such a manner as entirely to have frustrated the intention.
+#create second
+   Money is, with propriety, considered as the vital principle
+of the body politic; as that which sustains its life and
+motion and enables it to perform its most essential functions.
+A complete power, therefore, to procure a regular
+and adequate supply of revenue, as far as the resources
+of the community will permit, may be regarded
+as an indispensable ingredient in every constitution.
+From a deficiency in this particular, one of two evils
+must ensue:  either the people must be subjected to
+continual plunder, as a substitute for a more eligible
+mode of supplying the public wants, or the government
+must sink into a fatal atrophy, and, in a short course of
+time, perish.
+#create third
+   In the Ottoman or Turkish empire the sovereign,
+though in other respects absolute master of the lives and
+fortunes of his subjects, has no right to impose a new tax.
+The consequence is that he permits the bashaws or governors
+of provinces to pillage the people at discretion,
+and, in turn, squeezes out of them the sums of which he
+stands in need to satisfy his own exigencies and those of
+the state.  In America, from a like cause, the government
+of the Union has gradually dwindled into a state of decay,
+approaching nearly to annihilation.  Who can doubt that
+the happiness of the people in both countries would be
+promoted by competent authorities in the proper hands
+to provide the revenues which the necessities of the public
+might require?
+#user
+#cmp total Ref
+#next
+60.2c 5
diff --git a/usr/lib/learn/editor/L60.2c b/usr/lib/learn/editor/L60.2c
new file mode 100644 (file)
index 0000000..488a3b0
--- /dev/null
@@ -0,0 +1,57 @@
+#print
+You can use an address on the 'r' command to read input at a particular
+location in the file.  Thus
+  5r name
+reads file "name" and appends its contents after line 5 o f the file.
+You can use any kind of address, including a search.  Here is a file "chem".
+Find the line in file "chem" which contains the word "eight";
+read the file "more" and append it after that line.  Then rewrite
+"chem" and type "ready".
+#create Ref
+   When elements combine to form compounds, the electrons in the
+outermost shell of the atoms are the only ones that take part in the
+reaction.  These electrons are either transferred from the outer
+shell of one atom to the outer shell of another, or, in some cases,
+shared with the electrons in the outer shell of the second atom.
+   Whether the electrons are transfered to the second atom or shared,
+this atom completes its quota of eight electrons in the outer shell.
+   An oxide is a compound containing oxygen and one other element.
+The simplest of the oxides is H2O -- pure water, or hydrogen oxide.
+Carbon dioxide is CO2 and is formed during the burning of organic
+matter such as wood, paper, gasoline, or coal.  In the same burning
+process, H2O is formed and energy is released, generally as heat,
+sometimes as light.  Carbon dioxide is in the breath you just
+exhaled.  This gas is given off by decaying plant and animal matter.
+Decay is a burning process.
+   Oxidation is a word that covers all the different ways things
+burn.  When something oxidizes, it is burning.
+   Compounds which are formed by the interchange of electrons are
+called ionic compounds.  The ions formed are said to possess
+electrovalence.
+#create chem
+   When elements combine to form compounds, the electrons in the
+outermost shell of the atoms are the only ones that take part in the
+reaction.  These electrons are either transferred from the outer
+shell of one atom to the outer shell of another, or, in some cases,
+shared with the electrons in the outer shell of the second atom.
+   Whether the electrons are transfered to the second atom or shared,
+this atom completes its quota of eight electrons in the outer shell.
+   Compounds which are formed by the interchange of electrons are
+called ionic compounds.  The ions formed are said to possess
+electrovalence.
+#create more
+   An oxide is a compound containing oxygen and one other element.
+The simplest of the oxides is H2O -- pure water, or hydrogen oxide.
+Carbon dioxide is CO2 and is formed during the burning of organic
+matter such as wood, paper, gasoline, or coal.  In the same burning
+process, H2O is formed and energy is released, generally as heat,
+sometimes as light.  Carbon dioxide is in the breath you just
+exhaled.  This gas is given off by decaying plant and animal matter.
+Decay is a burning process.
+   Oxidation is a word that covers all the different ways things
+burn.  When something oxidizes, it is burning.
+#user
+#cmp chem Ref
+#log
+#next
+60.2d 5
diff --git a/usr/lib/learn/editor/L60.2d b/usr/lib/learn/editor/L60.2d
new file mode 100644 (file)
index 0000000..8a17876
--- /dev/null
@@ -0,0 +1,52 @@
+#print
+This is trickier.  Read the file "text".  Look for a line saying
+"insert file ... here".  Delete that line, and in its
+place (after the preceding line) read in the file asked for.
+Then rewrite "text" and type "ready".
+#create Ref
+   The severity of the judicial and penal system was partly
+caused by the defects of the police.  Only a small proportion of
+criminals were caught, and even when arrests were made, but little
+evidence was collected.  The officers, so far from being scientific
+were not even properly professional.  For although the constable of
+each village and the watchman of each town were paid to guard peace
+land property, they were yet neither specially fitted nor trained
+for that employment.  In a country village the case was even worse.
+For there the magistrates could only afford to hire the part-service
+of a farmer-constable.
+   It is a striking fact that until recently democracy never
+flourished except in very small states -- for the most part in cities.
+It is true that in both the Persian and the Roman empires a measure
+of self-government was accorded to local communities, but only in
+respect to purely local affairs; in no large state as a whole was
+democratic government found to be practicable.  One essential reason
+is that until recently the means of communication were too slow and
+uncertain to create the necessary solidarity of interest and similarity
+of information over large areas.
+#create inside
+land property, they were yet neither specially fitted nor trained
+for that employment.  In a country village the case was even worse.
+For there the magistrates could only afford to hire the part-service
+of a farmer-constable.
+   It is a striking fact that until recently democracy never
+flourished except in very small states -- for the most part in cities.
+It is true that in both the Persian and the Roman empires a measure
+of self-government was accorded to local communities, but only in
+#create text
+   The severity of the judicial and penal system was partly
+caused by the defects of the police.  Only a small proportion of
+criminals were caught, and even when arrests were made, but little
+evidence was collected.  The officers, so far from being scientific
+were not even properly professional.  For although the constable of
+each village and the watchman of each town were paid to guard peace
+ ***  insert file "inside" here  ***
+respect to purely local affairs; in no large state as a whole was
+democratic government found to be practicable.  One essential reason
+is that until recently the means of communication were too slow and
+uncertain to create the necessary solidarity of interest and similarity
+of information over large areas.
+#user
+#cmp text Ref
+#log
+#next
+61.1a 10
diff --git a/usr/lib/learn/editor/L61.1a b/usr/lib/learn/editor/L61.1a
new file mode 100644 (file)
index 0000000..407be43
--- /dev/null
@@ -0,0 +1,27 @@
+#print
+Note that usually you just type 'w' without a file name,
+and the editor buffer is written on the 'current file'.
+What is the 'current file' when you have executed an 'r'
+command?  Well, it doesn't change.  But rather than
+be in doubt, there is a command
+  f
+which prints the current file name.
+You can change the current file name with
+  f name
+so that you can copy file 'old' to 'new' with
+  ed old
+  f new
+  w
+  q
+Try that: copy file 'first' to 'second' in this
+directory.  Then type "ready".
+#create first
+This is the
+file to be copied
+using the 'f' command.
+#user
+#cmp first second
+#log
+#next
+62.1a 10
+62.2a 5
diff --git a/usr/lib/learn/editor/L62.1a b/usr/lib/learn/editor/L62.1a
new file mode 100644 (file)
index 0000000..4b8eb90
--- /dev/null
@@ -0,0 +1,67 @@
+#print
+Frequently you will want to move one or more lines
+from one place in a file to another.    The command
+
+5,10m30
+
+will pick up lines 5 through 10 and move them after line 30.
+You can of course use context searches for addresses:
+
+/ab/,/cd/m/xx/
+
+finds a line containing "ab", then one containing "cd",
+and moves the section of the file they bracket after the
+next line containing "xx".
+Or you can use ".", "$", etc.:
+
+.,.+2m$
+
+moves the three lines starting at "." to the end.
+
+There is a file "word" which
+is out of order; re-arrange it to be alphabetical.
+#create Ref
+bands
+becomes
+course
+dissolve
+events
+for
+have
+human
+in
+it
+necessary
+of
+one
+people
+political
+the
+to
+when
+which
+#create word
+bands
+becomes
+course
+in
+it
+necessary
+of
+one
+people
+political
+dissolve
+events
+for
+have
+human
+the
+to
+when
+which
+#user
+#cmp word Ref
+#log
+#next
+63.1a 10
diff --git a/usr/lib/learn/editor/L62.2a b/usr/lib/learn/editor/L62.2a
new file mode 100644 (file)
index 0000000..553438a
--- /dev/null
@@ -0,0 +1,59 @@
+#print
+A very useful command in the UNIX editor
+is the 'm' command, which moves a lot of
+lines from one place to another in a file. For example, 
+  5,10m20
+picks up lines 5 through 10 and moves them after line 20.  Try
+that on the file "list" in this directory: move lines 5 to 10 after 
+line 20, rewrite the file, and type "ready".
+#create Ref
+ computer languages
+
+fortran
+cobol
+snobol
+comit
+lex
+yacc
+c
+tmg
+ratfor
+basic
+bon
+bcpl
+algol 60
+algol 68
+pl/i
+pl/c
+pl/360
+apl
+altran
+formac
+#create list
+ computer languages
+
+fortran
+cobol
+algol 60
+algol 68
+pl/i
+pl/c
+pl/360
+apl
+snobol
+comit
+lex
+yacc
+c
+tmg
+ratfor
+basic
+bon
+bcpl
+altran
+formac
+#user
+#cmp list Ref
+#log
+#next
+62.2b 5
diff --git a/usr/lib/learn/editor/L62.2b b/usr/lib/learn/editor/L62.2b
new file mode 100644 (file)
index 0000000..ebb674d
--- /dev/null
@@ -0,0 +1,32 @@
+#print
+ You can of course use any kind of addresses for the three addresses
+in the 'm' command.  Think of the command as
+  "from address-1 until address-2 gather up and MOVE to address-3".
+OK.  In the file "story" move the lines from the line
+that contains "back" until the line containing "prevail" to the
+end of the file.  Then rewrite "story" and type "ready".
+#create Ref
+   Only twice in the nation's history has daylight-savings time been
+uniformly observed throughout the land -- during World War I, the first
+DST was tried, and again during World War II.  Immediately after
+both wars, however, many areas abandoned DST altogether.
+   Last week the House voted 292 to 93 to require all states to move
+their clocks ahead an hour on the last Sunday in April, and set them
+back again on the last Sunday in October -- unless a state legislature
+specifically votes to stay on standard time.  In that case, local
+options are out and standard time must prevail through the state.
+#create story
+   Only twice in the nation's history has daylight-savings time been
+uniformly observed throughout the land -- during World War I, the first
+DST was tried, and again during World War II.  Immediately after
+both wars, however, many areas abandoned DST altogether.
+back again on the last Sunday in October -- unless a state legislature
+specifically votes to stay on standard time.  In that case, local
+options are out and standard time must prevail through the state.
+   Last week the House voted 292 to 93 to require all states to move
+their clocks ahead an hour on the last Sunday in April, and set them
+#user
+#cmp story Ref
+#log
+#next
+62.2c 5
diff --git a/usr/lib/learn/editor/L62.2c b/usr/lib/learn/editor/L62.2c
new file mode 100644 (file)
index 0000000..ecd799f
--- /dev/null
@@ -0,0 +1,49 @@
+#print
+In this directory is a file "word" which should be in alphabetical
+order but is not; put it in order by picking up a block of lines
+and relocating them.  Then rewrite the file and type "ready".
+#create Ref
+bands
+becomes
+course
+dissolve
+events
+for
+have
+human
+in
+it
+necessary
+of
+one
+people
+political
+the
+to
+when
+which
+#create word
+bands
+becomes
+course
+in
+it
+necessary
+of
+one
+people
+political
+dissolve
+events
+for
+have
+human
+the
+to
+when
+which
+#user
+#cmp word Ref
+#log
+#next
+63.1a 10
diff --git a/usr/lib/learn/editor/L63.1a b/usr/lib/learn/editor/L63.1a
new file mode 100644 (file)
index 0000000..a1f0acc
--- /dev/null
@@ -0,0 +1,43 @@
+#print
+Line 0 is a legitimate address for a few commands;
+you can append text at the beginning of a file
+by typing
+   0a
+and you can move lines to the beginning of a files
+by using
+   m0
+Move the last three lines of file "tax" to the beginning,
+then type "ready".
+#create Ref
+If you sustain an "overall foreign loss"
+for any taxable year,
+a recapture provision
+will treat a part of
+foreign income realized
+in a later year
+as income from
+U. S. sources.
+
+These rules generally apply
+to losses sustained in taxable
+years beginning after
+December 31, 1975.
+#create tax
+will treat a part of
+foreign income realized
+in a later year
+as income from
+U. S. sources.
+
+These rules generally apply
+to losses sustained in taxable
+years beginning after
+December 31, 1975.
+If you sustain an "overall foreign loss"
+for any taxable year,
+a recapture provision
+#user
+#cmp Ref tax
+#log
+#next
+63.1b 10
diff --git a/usr/lib/learn/editor/L63.1b b/usr/lib/learn/editor/L63.1b
new file mode 100644 (file)
index 0000000..9b92488
--- /dev/null
@@ -0,0 +1,13 @@
+#print
+What command will move the current line
+to the beginning of the file?  Type 
+"answer COMMAND", where COMMAND is the command.
+#copyin
+#user
+#uncopyin
+#match m0
+#match .m0
+"m0" is easier.
+#log
+#next
+63.1c 10
diff --git a/usr/lib/learn/editor/L63.1c b/usr/lib/learn/editor/L63.1c
new file mode 100644 (file)
index 0000000..0ef79dc
--- /dev/null
@@ -0,0 +1,13 @@
+#print
+What command will move the current line
+to the end of the file?  Type 
+"answer COMMAND", where COMMAND is the command.
+#copyin
+#user
+#uncopyin
+#match m$
+#match .m$
+"m$" is easier.
+#log
+#next
+63.1d 10
diff --git a/usr/lib/learn/editor/L63.1d b/usr/lib/learn/editor/L63.1d
new file mode 100644 (file)
index 0000000..999926f
--- /dev/null
@@ -0,0 +1,12 @@
+#print
+Will the command
+  m+
+interchange lines "." and ".+1"?
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+63.1e 10
diff --git a/usr/lib/learn/editor/L63.1e b/usr/lib/learn/editor/L63.1e
new file mode 100644 (file)
index 0000000..6233947
--- /dev/null
@@ -0,0 +1,13 @@
+#print
+Will the command
+  m-
+interchange lines "." and ".-1"?
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match no
+You actually need "m--".
+#log
+#next
+64.1a 10
diff --git a/usr/lib/learn/editor/L64.1a b/usr/lib/learn/editor/L64.1a
new file mode 100644 (file)
index 0000000..93cf045
--- /dev/null
@@ -0,0 +1,34 @@
+#print
+Another command similar to 'm' is 't';
+the command
+  5,8t15
+picks up lines 5 through 8 and makes a copy of them,
+which it places after line 15.  It differs from
+'m' only in that the lines remain in their old place
+as well as appearing in their new place.  (Just like "cp"
+and "mv" with files).  In this directory is a file
+"double".  Using the editor,  find the line containing
+"-------" and make a copy of it at the
+end of the file.
+#create Ref
+------------
+This file should be
+bracketed by the
+dashes but as it
+is given to you
+there are only dashes
+at the top.
+------------
+#create double
+------------
+This file should be
+bracketed by the
+dashes but as it
+is given to you
+there are only dashes
+at the top.
+#user
+#cmp double Ref
+#log
+#next
+64.1b 10
diff --git a/usr/lib/learn/editor/L64.1b b/usr/lib/learn/editor/L64.1b
new file mode 100644 (file)
index 0000000..3c66753
--- /dev/null
@@ -0,0 +1,14 @@
+#print
+Another exercise in the effective use of the 't'
+command:  What command should be typed to make
+a second copy of the current line?
+Type "answer XX", where XX is the command.
+#copyin
+#user
+#uncopyin
+#match t.
+#match .t.
+You could just say "t.".
+#log
+#next
+65.1a 10
diff --git a/usr/lib/learn/editor/L65.1a b/usr/lib/learn/editor/L65.1a
new file mode 100644 (file)
index 0000000..f51beaf
--- /dev/null
@@ -0,0 +1,37 @@
+#print
+A strange, and not often important command, is the 'l'
+(list) command.  When it is needed, though, it is vital.
+It is almost identical to 'p' (print) except that control
+characters (like tab or backspace) are printed in a way
+that lets you see what they are no matter what the terminal does.
+From time to time strange characters will
+sneak into your files; they won't show when you print
+them, and yet they will confuse you.  For example,
+you might be unable to find a line by searching
+for it with
+ /abc/
+and yet it would print as "abc" if there were
+a funny character in the line between 'a' and 'b'.
+Funny characters are generated by hitting the control
+keys on the terminal; they print as '\' followed
+by a number.
+There is a file "weird" in this directory.  Print
+it both with "1,$p" and "1,$l"
+and observe the difference.  Then leave the editor.
+Which word on the last line has a funny character in it?
+Type "answer WORD" where WORD is that word (without the funny
+symbol).
+#create weird
+This line      has     tabs    in      it.
+So             does            this    one.
+Here is a line with\b\b\b\b____ backspaces of a useful sort.
+These back\b\b\bspaces\b\b\b\bonly\b\b\bconfuse matters.
+
+there's a strange character in th\ 1is line even though it prints ok.
+#copyin
+#user
+#uncopyin
+#match this
+#log
+#next
+66.1a 10
diff --git a/usr/lib/learn/editor/L66.1a b/usr/lib/learn/editor/L66.1a
new file mode 100644 (file)
index 0000000..8ae60e5
--- /dev/null
@@ -0,0 +1,102 @@
+#print
+The file "memo" contains several paragraphs,
+where a paragraph starts at any line that begins with
+a blank.  It is desired to remove those blanks at the beginning
+of lines, and instead mark the paragraphs by inserting
+a line containing only
+
+.PP
+
+before each paragraph.  Change the file in that
+way and then rewrite it; then type "ready".
+#create Ref
+The Ascent of the Riffelberg
+by Mark Twain
+
+.PP
+I sat silent some time, then turned to Harris and said:
+``My mind is made up.''
+Something in my tone struck him; and when he glanced
+at my eye and read what was written there, his face paled
+perceptibly.  He hesitated a moment, then said:
+``Speak.''
+.PP
+I answered, with perfect calmness:
+``I WILL ASCEND THE RIFFELBERG.''
+.PP
+If I had shot my poor friend he could not have fallen from
+his chair more suddenly.  If I had been his father he
+could not have pleaded harder to get me to give up my
+purpose.  But I turned a deaf ear to all he said.  When he
+perceived at last that nothing could alter my determination,
+he ceased to urge, and for a while the deep silence was broken only
+by his sobs.  I sat in marble resolution, with my
+eyes fixed upon vacancy, for in spirit I was already
+wrestling with the perils of the mountains, and my friend sat
+gazing at me in adoring admiration through his tears.  At
+last he threw himself upon me in a loving embrace and
+exclaimed in broken tones:
+``Your Harris will never desert you.  We will die together!''
+.PP
+I cheered the noble fellow with praises, and soon his fears
+were forgotten and he was eager for the adventure.  He
+wanted to summon the guides at once and leave at two in
+the morning, as he supposed the custom was; but I explained that nobody
+was looking at that hour; and that the start in the dark
+was not usually made from the village but
+from the first night's resting-place on the mountainside.  I
+said we would leave the village at 3 or 4 p.m. on the morrow;
+meantime he could notify the guides, and also let the public
+know of the attempt which we proposed to make.
+.PP
+I went to bed, but not to sleep.  No man can sleep when
+he is about to undertake one of these Alpine exploits.  I
+tossed feverishly all night long, and was glad enough when
+I heard the clock strike half past eleven and knew it was
+time to get up for dinner.
+#create memo
+The Ascent of the Riffelberg
+by Mark Twain
+
+  I sat silent some time, then turned to Harris and said:
+``My mind is made up.''
+Something in my tone struck him; and when he glanced
+at my eye and read what was written there, his face paled
+perceptibly.  He hesitated a moment, then said:
+``Speak.''
+  I answered, with perfect calmness:
+``I WILL ASCEND THE RIFFELBERG.''
+  If I had shot my poor friend he could not have fallen from
+his chair more suddenly.  If I had been his father he
+could not have pleaded harder to get me to give up my
+purpose.  But I turned a deaf ear to all he said.  When he
+perceived at last that nothing could alter my determination,
+he ceased to urge, and for a while the deep silence was broken only
+by his sobs.  I sat in marble resolution, with my
+eyes fixed upon vacancy, for in spirit I was already
+wrestling with the perils of the mountains, and my friend sat
+gazing at me in adoring admiration through his tears.  At
+last he threw himself upon me in a loving embrace and
+exclaimed in broken tones:
+``Your Harris will never desert you.  We will die together!''
+  I cheered the noble fellow with praises, and soon his fears
+were forgotten and he was eager for the adventure.  He
+wanted to summon the guides at once and leave at two in
+the morning, as he supposed the custom was; but I explained that nobody
+was looking at that hour; and that the start in the dark
+was not usually made from the village but
+from the first night's resting-place on the mountainside.  I
+said we would leave the village at 3 or 4 p.m. on the morrow;
+meantime he could notify the guides, and also let the public
+know of the attempt which we proposed to make.
+  I went to bed, but not to sleep.  No man can sleep when
+he is about to undertake one of these Alpine exploits.  I
+tossed feverishly all night long, and was glad enough when
+I heard the clock strike half past eleven and knew it was
+time to get up for dinner.
+#user
+#cmp memo Ref
+#log
+#next
+70.1a 10
+70.2a 5
diff --git a/usr/lib/learn/editor/L7.1a b/usr/lib/learn/editor/L7.1a
new file mode 100644 (file)
index 0000000..379e1da
--- /dev/null
@@ -0,0 +1,37 @@
+#print
+Although specifying lines by line number is
+easy to understand, it is hard to do in a long
+file.  You will therefore want to learn other
+ways of addressing lines.  The 'current line'
+is addressed with the symbol 
+  .
+so that it can be printed, for example with
+  .p
+just as you could print a line by "3p".
+Try that in this file; the current line is
+set to the last line of the current file.
+Try ".p"; then "w", "q", and "ready" as usual.
+Here's the full file -
+
+#create Ref
+john quincy adams
+91
+#create file
+george washington
+john adams
+thomas jefferson
+james madison
+james monroe
+john quincy adams
+#print file
+#copyout
+#pipe
+ed file
+#user
+#unpipe
+#uncopyout
+tail -2 .ocopy >X1
+#cmp X1 Ref
+#log
+#next
+7.1b 10
diff --git a/usr/lib/learn/editor/L7.1b b/usr/lib/learn/editor/L7.1b
new file mode 100644 (file)
index 0000000..84e229e
--- /dev/null
@@ -0,0 +1,41 @@
+#print
+As I said, '.' is set to the last line touched
+by any command in the editor.  So if you type
+  3p
+. will be set to line 3; and then 
+  .p
+will print the same line.
+Try that - 
+with the usual trailer, the commands should be
+
+3p
+.p
+w
+q
+ready
+The file is the same as before.
+#create Ref
+3p
+.p
+w
+q
+#create file
+george washington
+john adams
+thomas jefferson
+james madison
+james monroe
+john quincy adams
+#pipe
+#copyin
+ed file
+#user
+#uncopyin
+#unpipe
+tail -4  .copy >X1
+#cmp X1 Ref
+#log
+#next
+8.1a 10
+8.2a 6
+7.2c 2
diff --git a/usr/lib/learn/editor/L7.2c b/usr/lib/learn/editor/L7.2c
new file mode 100644 (file)
index 0000000..81aeabc
--- /dev/null
@@ -0,0 +1,29 @@
+#print
+Now, print the fourth line in this file twice,
+using the same pattern.  The file is the same,
+and you should put the usual finish (w, q, ready)
+after printing the line.
+#create Ref
+4p
+.p
+w
+q
+#create file
+george washington
+john adams
+thomas jefferson
+james madison
+james monroe
+john quincy adams
+#pipe
+#copyin
+ed file
+#user
+#uncopyin
+#unpipe
+tail -4  .copy >X1
+#cmp X1 Ref
+#log
+#next
+8.1a 10
+8.2a 5
diff --git a/usr/lib/learn/editor/L70.1a b/usr/lib/learn/editor/L70.1a
new file mode 100644 (file)
index 0000000..0104989
--- /dev/null
@@ -0,0 +1,49 @@
+#print
+Perhaps the most powerful command in the editor is the 'g' 
+(global) command.   This always precedes a second command
+on the same command line; it selects those file lines
+on which the second command is to be executed.
+For example
+  g/abc/s/def/ghi/p
+says: "Find all lines in the file which
+contain the string "abc"; change the first
+"def" on any such line into "ghi".  The command
+after the 'g' may be any command, of course.
+Needless to say, the expressions after the 'g' may
+include all the special characters.
+Edit the file "towns" so that each line beginning
+with "-" has " (county seat)" added at its end.
+Rewrite the file and type "ready".
+#create Ref
+-newark (county seat)
+  east orange
+  south orange
+  maplewood
+-elizabeth (county seat)
+  linden
+  cranford
+  westfield
+-morristown (county seat)
+  madison
+  chatham
+  dover
+#create towns
+-newark
+  east orange
+  south orange
+  maplewood
+-elizabeth
+  linden
+  cranford
+  westfield
+-morristown
+  madison
+  chatham
+  dover
+#user
+#cmp towns Ref
+#log
+#next
+71.1a 10
+70.2e 9
+70.2d 6
diff --git a/usr/lib/learn/editor/L70.2a b/usr/lib/learn/editor/L70.2a
new file mode 100644 (file)
index 0000000..afb862b
--- /dev/null
@@ -0,0 +1,30 @@
+#print
+Perhaps the most powerful editor command is the 'g'
+(global) command.  This command selects sets of lines
+on which other commands are executed.  For example,
+  g/abc/p
+prints all lines on which 'abc' appears.  In this directory
+is a file "story".  Print all lines on which the word
+"of" appears.  Then leave the editor and type "ready".
+#create Ref
+   The people of the United States are in a sense becoming a nation
+of the United States in the future, it will be because that system
+did too good a job of filling many of the needs of the people.
+#create story
+   The people of the United States are in a sense becoming a nation
+on a tiger.  They must learn to consume more and more or, they are
+warned, their magnificent economic machine may turn and devour them.
+They must be induced to step up their individual consumption higher
+and higher, whether they have any pressing need for the goods or
+not.  Their ever-expanding economy demands it.
+   If modifications are forced upon the private-enterprise system
+of the United States in the future, it will be because that system
+did too good a job of filling many of the needs of the people.
+#copyout
+#user
+#uncopyout
+grep of .ocopy >x1
+#cmp x1 Ref
+#log
+#next
+70.2b 5
diff --git a/usr/lib/learn/editor/L70.2b b/usr/lib/learn/editor/L70.2b
new file mode 100644 (file)
index 0000000..b302fcf
--- /dev/null
@@ -0,0 +1,84 @@
+#print
+You can use any command with 'g', not just 'p'. For example
+ g/xx/s/a/b/
+changes 'a' to 'b' on every line containing 'xx'.  As an
+example of the global command used with 'd', try this:
+In file "cities" there is a list of cities with their states and
+zip codes.  Delete all cities which are in New Jersey (i.e. all
+lines containing NJ). Then rewrite the file and type "ready".
+#create Ref
+Albany NY 12201
+Atlanta GA 30301
+Baltimore MD 21233
+Boston MA 02109
+Bridgeport CN 06601
+Buffalo NY 14240
+Chicago IL 60607
+Dallas TX 75221
+Denver CO 80201
+Detroit MI 48226
+Hartford CN 06101
+Houston TX 77052
+Indianapolis IN 46204
+Los Angeles CA 90053
+Miami FL 33101
+Milwaukee WI 53201
+Minneapolis MN 55401
+New York NY 10001
+Philadelphia PA 19104
+Phoenix AR 85026
+Pittsburgh PA 15230
+Providence RI 02904
+Rochester NY 14603
+San Diego CA 92101
+San Francisco CA 94101
+Seattle WA 98101
+St. Louis MO 63166
+Syracuse NY 13201
+Utica NY 13503
+Washington DC 20013
+Yonkers NY 10598
+#create cities
+Albany NY 12201
+Atlanta GA 30301
+Baltimore MD 21233
+Boston MA 02109
+Bridgeport CN 06601
+Buffalo NY 14240
+Camden NJ 08101
+Chicago IL 60607
+Dallas TX 75221
+Denver CO 80201
+Detroit MI 48226
+Elizabeth NJ 07207
+Hartford CN 06101
+Houston TX 77052
+Indianapolis IN 46204
+Jersey City NJ 07303
+Los Angeles CA 90053
+Miami FL 33101
+Milwaukee WI 53201
+Minneapolis MN 55401
+New York NY 10001
+Newark NJ 07101
+Paterson NJ 07510
+Philadelphia PA 19104
+Phoenix AR 85026
+Pittsburgh PA 15230
+Providence RI 02904
+Rochester NY 14603
+San Diego CA 92101
+San Francisco CA 94101
+Seattle WA 98101
+St. Louis MO 63166
+Syracuse NY 13201
+Trenton NJ 08608
+Utica NY 13503
+Washington DC 20013
+Yonkers NY 10598
+#user
+#cmp cities Ref
+#log
+#next
+70.2c 5
+70.2d 10
diff --git a/usr/lib/learn/editor/L70.2c b/usr/lib/learn/editor/L70.2c
new file mode 100644 (file)
index 0000000..cf3ce54
--- /dev/null
@@ -0,0 +1,84 @@
+#print
+In this directory is another copy of the
+"cities" file as you modified it,
+and the previous version named "ocities".
+Use "diff" to find out how many lines you deleted.
+Reply "answer N" where N is the number of
+lines you removed from "cities".
+#create cities
+Albany NY 12201
+Atlanta GA 30301
+Baltimore MD 21233
+Boston MA 02109
+Bridgeport CN 06601
+Buffalo NY 14240
+Chicago IL 60607
+Dallas TX 75221
+Denver CO 80201
+Detroit MI 48226
+Hartford CN 06101
+Houston TX 77052
+Indianapolis IN 46204
+Los Angeles CA 90053
+Miami FL 33101
+Milwaukee WI 53201
+Minneapolis MN 55401
+New York NY 10001
+Philadelphia PA 19104
+Phoenix AR 85026
+Pittsburgh PA 15230
+Providence RI 02904
+Rochester NY 14603
+San Diego CA 92101
+San Francisco CA 94101
+Seattle WA 98101
+St. Louis MO 63166
+Syracuse NY 13201
+Utica NY 13503
+Washington DC 20013
+Yonkers NY 10598
+#create ocities
+Albany NY 12201
+Atlanta GA 30301
+Baltimore MD 21233
+Boston MA 02109
+Bridgeport CN 06601
+Buffalo NY 14240
+Camden NJ 08101
+Chicago IL 60607
+Dallas TX 75221
+Denver CO 80201
+Detroit MI 48226
+Elizabeth NJ 07207
+Hartford CN 06101
+Houston TX 77052
+Indianapolis IN 46204
+Jersey City NJ 07303
+Los Angeles CA 90053
+Miami FL 33101
+Milwaukee WI 53201
+Minneapolis MN 55401
+New York NY 10001
+Newark NJ 07101
+Paterson NJ 07510
+Philadelphia PA 19104
+Phoenix AR 85026
+Pittsburgh PA 15230
+Providence RI 02904
+Rochester NY 14603
+San Diego CA 92101
+San Francisco CA 94101
+Seattle WA 98101
+St. Louis MO 63166
+Syracuse NY 13201
+Trenton NJ 08608
+Utica NY 13503
+Washington DC 20013
+Yonkers NY 10598
+#copyin
+#user
+#uncopyin
+#match 6
+#log
+#next
+70.2d 10
diff --git a/usr/lib/learn/editor/L70.2d b/usr/lib/learn/editor/L70.2d
new file mode 100644 (file)
index 0000000..beb4bd0
--- /dev/null
@@ -0,0 +1,92 @@
+#print
+There is another file of cities with ZIP codes and states
+in this directory, but it was typed in wrong.  Some cities
+in New Jersey are labeled as being in New York.  However the
+ZIP codes are right.  Since the cities in New Jersey are
+exactly those with zip codes beginning 07, if you
+can execute the substitute command to change NY to NJ on all
+lines with " 07" in them, all will be well.
+Don't forget the blank before the 07 - some ZIP
+codes have "07" in the middle, remember.
+Change file "cities" and rewrite it.  Then type "ready".
+#create Ref
+Albany NY 12201
+Atlanta GA 30301
+Baltimore MD 21233
+Boston MA 02109
+Bridgeport CN 06601
+Buffalo NY 14240
+Camden NJ 08101
+Chicago IL 60607
+Dallas TX 75221
+Denver CO 80201
+Detroit MI 48226
+Elizabeth NJ 07207
+Hartford CN 06101
+Houston TX 77052
+Indianapolis IN 46204
+Jersey City NJ 07303
+Los Angeles CA 90053
+Miami FL 33101
+Milwaukee WI 53201
+Minneapolis MN 55401
+New York NY 10001
+Newark NJ 07101
+Paterson NJ 07510
+Philadelphia PA 19104
+Phoenix AR 85026
+Pittsburgh PA 15230
+Providence RI 02904
+Rochester NY 14603
+San Diego CA 92101
+San Francisco CA 94101
+Seattle WA 98101
+St. Louis MO 63166
+Syracuse NY 13201
+Trenton NJ 08608
+Utica NY 13503
+Washington DC 20013
+Yonkers NY 10598
+#create cities
+Albany NY 12201
+Atlanta GA 30301
+Baltimore MD 21233
+Boston MA 02109
+Bridgeport CN 06601
+Buffalo NY 14240
+Camden NJ 08101
+Chicago IL 60607
+Dallas TX 75221
+Denver CO 80201
+Detroit MI 48226
+Elizabeth NY 07207
+Hartford CN 06101
+Houston TX 77052
+Indianapolis IN 46204
+Jersey City NY 07303
+Los Angeles CA 90053
+Miami FL 33101
+Milwaukee WI 53201
+Minneapolis MN 55401
+New York NY 10001
+Newark NY 07101
+Paterson NY 07510
+Philadelphia PA 19104
+Phoenix AR 85026
+Pittsburgh PA 15230
+Providence RI 02904
+Rochester NY 14603
+San Diego CA 92101
+San Francisco CA 94101
+Seattle WA 98101
+St. Louis MO 63166
+Syracuse NY 13201
+Trenton NJ 08608
+Utica NY 13503
+Washington DC 20013
+Yonkers NY 10598
+#user
+#cmp cities Ref
+#log
+#next
+70.2e 5
diff --git a/usr/lib/learn/editor/L70.2e b/usr/lib/learn/editor/L70.2e
new file mode 100644 (file)
index 0000000..ffc1bcd
--- /dev/null
@@ -0,0 +1,95 @@
+#print
+There is a file "cities" in this directory in which each line
+contains a city, state and ZIP code.  But it was typed
+in by a member of management and is really botched - every
+NJ city is labeled as being in NY.  But the Zip codes are right -
+if you can change NY to NJ on each line containing a ZIP code
+beginning with either 07 or 08 all will be fixed up.  Each line
+looks like
+  St. Louis MO 63166
+and (1) remember the [] operators? and (2) don't forget
+that digits appear in the middle of ZIP codes.
+You may want to check what you're doing by writing the current
+version on a different file name and using "diff" to check
+on the changes.
+#create Ref
+Albany NY 12201
+Atlanta GA 30301
+Baltimore MD 21233
+Boston MA 02109
+Bridgeport CN 06601
+Buffalo NY 14240
+Camden NJ 08101
+Chicago IL 60607
+Dallas TX 75221
+Denver CO 80201
+Detroit MI 48226
+Elizabeth NJ 07207
+Hartford CN 06101
+Houston TX 77052
+Indianapolis IN 46204
+Jersey City NJ 07303
+Los Angeles CA 90053
+Miami FL 33101
+Milwaukee WI 53201
+Minneapolis MN 55401
+New York NY 10001
+Newark NJ 07101
+Paterson NJ 07510
+Philadelphia PA 19104
+Phoenix AR 85026
+Pittsburgh PA 15230
+Providence RI 02904
+Rochester NY 14603
+San Diego CA 92101
+San Francisco CA 94101
+Seattle WA 98101
+St. Louis MO 63166
+Syracuse NY 13201
+Trenton NJ 08608
+Utica NY 13503
+Washington DC 20013
+Yonkers NY 10598
+#create cities
+Albany NY 12201
+Atlanta GA 30301
+Baltimore MD 21233
+Boston MA 02109
+Bridgeport CN 06601
+Buffalo NY 14240
+Camden NY 08101
+Chicago IL 60607
+Dallas TX 75221
+Denver CO 80201
+Detroit MI 48226
+Elizabeth NY 07207
+Hartford CN 06101
+Houston TX 77052
+Indianapolis IN 46204
+Jersey City NY 07303
+Los Angeles CA 90053
+Miami FL 33101
+Milwaukee WI 53201
+Minneapolis MN 55401
+New York NY 10001
+Newark NY 07101
+Paterson NY 07510
+Philadelphia PA 19104
+Phoenix AR 85026
+Pittsburgh PA 15230
+Providence RI 02904
+Rochester NY 14603
+San Diego CA 92101
+San Francisco CA 94101
+Seattle WA 98101
+St. Louis MO 63166
+Syracuse NY 13201
+Trenton NJ 08608
+Utica NY 13503
+Washington DC 20013
+Yonkers NY 10598
+#user
+#cmp cities Ref
+#log
+#next
+70.2f 5
diff --git a/usr/lib/learn/editor/L70.2f b/usr/lib/learn/editor/L70.2f
new file mode 100644 (file)
index 0000000..b5aa2eb
--- /dev/null
@@ -0,0 +1,90 @@
+#print
+Remember the search for blank lines with nothing on them? /^$/.
+Pick up the file "table" and delete all blank lines; then rewrite
+it and type "ready".
+#create Ref
+Albany NY 12201
+Atlanta GA 30301
+Baltimore MD 21233
+Boston MA 02109
+Bridgeport CN 06601
+Buffalo NY 14240
+Camden NJ 08101
+Chicago IL 60607
+Dallas TX 75221
+Denver CO 80201
+Detroit MI 48226
+Elizabeth NJ 07207
+Hartford CN 06101
+Houston TX 77052
+Indianapolis IN 46204
+Jersey City NJ 07303
+Los Angeles CA 90053
+Miami FL 33101
+Milwaukee WI 53201
+Minneapolis MN 55401
+New York NY 10001
+Newark NJ 07101
+Paterson NJ 07510
+Philadelphia PA 19104
+Phoenix AR 85026
+Pittsburgh PA 15230
+Providence RI 02904
+Rochester NY 14603
+San Diego CA 92101
+San Francisco CA 94101
+Seattle WA 98101
+St. Louis MO 63166
+Syracuse NY 13201
+Trenton NJ 08608
+Utica NY 13503
+Washington DC 20013
+Yonkers NY 10598
+#create table
+Albany NY 12201
+Atlanta GA 30301
+Baltimore MD 21233
+Boston MA 02109
+Bridgeport CN 06601
+Buffalo NY 14240
+Camden NJ 08101
+Chicago IL 60607
+
+Dallas TX 75221
+Denver CO 80201
+Detroit MI 48226
+
+Elizabeth NJ 07207
+Hartford CN 06101
+Houston TX 77052
+Indianapolis IN 46204
+Jersey City NJ 07303
+Los Angeles CA 90053
+Miami FL 33101
+
+Milwaukee WI 53201
+Minneapolis MN 55401
+New York NY 10001
+Newark NJ 07101
+Paterson NJ 07510
+Philadelphia PA 19104
+Phoenix AR 85026
+Pittsburgh PA 15230
+
+
+Providence RI 02904
+Rochester NY 14603
+San Diego CA 92101
+San Francisco CA 94101
+Seattle WA 98101
+St. Louis MO 63166
+Syracuse NY 13201
+Trenton NJ 08608
+Utica NY 13503
+Washington DC 20013
+Yonkers NY 10598
+#user
+#cmp table Ref
+#log
+#next
+70.2g 5
diff --git a/usr/lib/learn/editor/L70.2g b/usr/lib/learn/editor/L70.2g
new file mode 100644 (file)
index 0000000..3f34982
--- /dev/null
@@ -0,0 +1,36 @@
+#print
+Here is a file "values".  Whenever the word
+"liter" appears in it, add at the end of that
+line the characters 
+  (1 liter = 1.06 quart)
+The parentheses should appear in the final
+file, and there should be one space before the
+left parenthesis.  When done, rewrite
+the file and type "ready".
+#create Ref
+gasoline: .52/gallon
+milk: 35/qt
+rice: .30/lb
+acetic acid: 1.20/liter (1 liter = 1.06 quart)
+apples: .35/lb
+cider: .55/liter (1 liter = 1.06 quart)
+butter: .79/lb
+soda: .42/liter (1 liter = 1.06 quart)
+eggs: .89/doz
+cream: 1.25/liter (1 liter = 1.06 quart)
+#create values
+gasoline: .52/gallon
+milk: 35/qt
+rice: .30/lb
+acetic acid: 1.20/liter
+apples: .35/lb
+cider: .55/liter
+butter: .79/lb
+soda: .42/liter
+eggs: .89/doz
+cream: 1.25/liter
+#user
+#cmp values Ref
+#log
+#next
+71.1a 5
diff --git a/usr/lib/learn/editor/L71.1a b/usr/lib/learn/editor/L71.1a
new file mode 100644 (file)
index 0000000..1f665f3
--- /dev/null
@@ -0,0 +1,108 @@
+#print
+After the global command has selected the lines
+to which the second command is to be applied, it sets '.' (the
+current line) to each of these lines in turn as it executes
+the controlled command.  Thus you can reference the line
+before or after the selected line.  For example,
+  g/xx/.-1s/ab/cd/
+changes 'ab' to 'cd' on the line BEFORE each line with xx.
+And
+  g/xx/$t.+1
+inserts a copy of the last line in the file two lines
+after each line with 'xx' on it.
+In this directory, the file 'memo' has paragraphs indicated
+by lines beginning ".PP".  Add two blanks to the beginning of
+the line after each ".PP", and then delete the ".PP" lines.
+This should take only two commands.  Rewrite the file and then
+type "ready".
+#create Ref
+The Ascent of the Riffelberg
+by Mark Twain
+
+  I sat silent some time, then turned to Harris and said:
+``My mind is made up.''
+Something in my tone struck him; and when he glanced
+at my eye and read what was written there, his face paled
+perceptibly.  He hesitated a moment, then said:
+``Speak.''
+  I answered, with perfect calmness:
+``I WILL ASCEND THE RIFFELBERG.''
+  If I had shot my poor friend he could not have fallen from
+his chair more suddenly.  If I had been his father he
+could not have pleaded harder to get me to give up my
+purpose.  But I turned a deaf ear to all he said.  When he
+perceived at last that nothing could alter my determination,
+he ceased to urge, and for a while the deep silence was broken only
+by his sobs.  I sat in marble resolution, with my
+eyes fixed upon vacancy, for in spirit I was already
+wrestling with the perils of the mountains, and my friend sat
+gazing at me in adoring admiration through his tears.  At
+last he threw himself upon me in a loving embrace and
+exclaimed in broken tones:
+``Your Harris will never desert you.  We will die together!''
+  I cheered the noble fellow with praises, and soon his fears
+were forgotten and he was eager for the adventure.  He
+wanted to summon the guides at once and leave at two in
+the morning, as he supposed the custom was; but I explained that nobody
+was looking at that hour; and that the start in the dark
+was not usually made from the village but
+from the first night's resting-place on the mountainside.  I
+said we would leave the village at 3 or 4 p.m. on the morrow;
+meantime he could notify the guides, and also let the public
+know of the attempt which we proposed to make.
+  I went to bed, but not to sleep.  No man can sleep when
+he is about to undertake one of these Alpine exploits.  I
+tossed feverishly all night long, and was glad enough when
+I heard the clock strike half past eleven and knew it was
+time to get up for dinner.
+#create memo
+The Ascent of the Riffelberg
+by Mark Twain
+
+.PP
+I sat silent some time, then turned to Harris and said:
+``My mind is made up.''
+Something in my tone struck him; and when he glanced
+at my eye and read what was written there, his face paled
+perceptibly.  He hesitated a moment, then said:
+``Speak.''
+.PP
+I answered, with perfect calmness:
+``I WILL ASCEND THE RIFFELBERG.''
+.PP
+If I had shot my poor friend he could not have fallen from
+his chair more suddenly.  If I had been his father he
+could not have pleaded harder to get me to give up my
+purpose.  But I turned a deaf ear to all he said.  When he
+perceived at last that nothing could alter my determination,
+he ceased to urge, and for a while the deep silence was broken only
+by his sobs.  I sat in marble resolution, with my
+eyes fixed upon vacancy, for in spirit I was already
+wrestling with the perils of the mountains, and my friend sat
+gazing at me in adoring admiration through his tears.  At
+last he threw himself upon me in a loving embrace and
+exclaimed in broken tones:
+``Your Harris will never desert you.  We will die together!''
+.PP
+I cheered the noble fellow with praises, and soon his fears
+were forgotten and he was eager for the adventure.  He
+wanted to summon the guides at once and leave at two in
+the morning, as he supposed the custom was; but I explained that nobody
+was looking at that hour; and that the start in the dark
+was not usually made from the village but
+from the first night's resting-place on the mountainside.  I
+said we would leave the village at 3 or 4 p.m. on the morrow;
+meantime he could notify the guides, and also let the public
+know of the attempt which we proposed to make.
+.PP
+I went to bed, but not to sleep.  No man can sleep when
+he is about to undertake one of these Alpine exploits.  I
+tossed feverishly all night long, and was glad enough when
+I heard the clock strike half past eleven and knew it was
+time to get up for dinner.
+#user
+#cmp memo Ref
+#log
+#next
+72.1a 10
+72.2a 5
diff --git a/usr/lib/learn/editor/L72.1a b/usr/lib/learn/editor/L72.1a
new file mode 100644 (file)
index 0000000..c1fb039
--- /dev/null
@@ -0,0 +1,48 @@
+#print
+A command related to the global command is the 'v' command.
+It also selects lines on which a second command is executed; the
+difference between 'g' and 'v' is that the selected lines
+for the 'v' command are all those on which the expression
+is NOT found.  Thus
+  v/abc/s/x/y/g
+changes 'x' to 'y' on all lines NOT containing an 'abc'.
+There is a file 'price' in this directory.  Find all lines
+that do NOT begin with blank and prefix three asterisks
+to them.  Then rewrite the file and type "ready".
+#create Ref
+***beef
+  shoulder 1.39/lb
+  flank    1.59/lb
+  sirloin  2.19/lb
+  round    1.89/lb
+***fish
+  sword    3.99/lb
+  cod      1.99/lb
+  blues    2.49/lb
+  stripers 3.49/lb
+  flounder 2.99/lb
+***pork
+  shoulder  .89/lb
+  loin     1.59/lb
+  bacon    1.19/lb
+#create price
+beef
+  shoulder 1.39/lb
+  flank    1.59/lb
+  sirloin  2.19/lb
+  round    1.89/lb
+fish
+  sword    3.99/lb
+  cod      1.99/lb
+  blues    2.49/lb
+  stripers 3.49/lb
+  flounder 2.99/lb
+pork
+  shoulder  .89/lb
+  loin     1.59/lb
+  bacon    1.19/lb
+#user
+#cmp price Ref
+#log
+#next
+73.1a 10
diff --git a/usr/lib/learn/editor/L72.2a b/usr/lib/learn/editor/L72.2a
new file mode 100644 (file)
index 0000000..d286e31
--- /dev/null
@@ -0,0 +1,33 @@
+#print
+A command related to the 'g' command is the 'v' command.  The
+'v' command also selects lines on which another command is to
+be executed;  the difference between 'g' and 'v' is that
+the 'v' command selects all lines on which the specified
+expression is NOT found.  Thus 
+  v/ly$/p
+prints all lines which do NOT end in "ly".
+Or
+ v/e/p
+prints all lines WITHOUT an 'e'in them.
+Are there any lines in file "story"
+without an 'i'?  Find out using the editor; then
+leave the editor and type "yes" or "no".
+#create story
+   Credit "rationing," already being imposed by major banks in
+big cities, may soon spread to banks large and small in every corner
+of the United States.  Result:  Speculative loans may become hard
+to get anywhere.
+   Working in near-secrecy, a committee of the powerful American
+Bankers Association is drafting an unprecedented policy statement
+aimed at getting bankers across the country to be far choosier in
+making business loans.  The ABA it is believed, is being driven to
+this move partly by a nagging fear that the Federal Government will
+impose lending guidelines if banks fail to tighten up voluntarily.
+   The ABA's task is delicate.
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+72.2b 10
diff --git a/usr/lib/learn/editor/L72.2b b/usr/lib/learn/editor/L72.2b
new file mode 100644 (file)
index 0000000..b6a9d19
--- /dev/null
@@ -0,0 +1,54 @@
+#print
+Edit the file "cities" to remove all lines NOT
+containing "NJ".  Then rewrite the file
+and type "ready".
+#create Ref
+Camden NJ 08101
+Elizabeth NJ 07207
+Jersey City NJ 07303
+Newark NJ 07101
+Paterson NJ 07510
+Trenton NJ 08608
+#create cities
+Albany NY 12201
+Atlanta GA 30301
+Baltimore MD 21233
+Boston MA 02109
+Bridgeport CN 06601
+Buffalo NY 14240
+Camden NJ 08101
+Chicago IL 60607
+Dallas TX 75221
+Denver CO 80201
+Detroit MI 48226
+Elizabeth NJ 07207
+Hartford CN 06101
+Houston TX 77052
+Indianapolis IN 46204
+Jersey City NJ 07303
+Los Angeles CA 90053
+Miami FL 33101
+Milwaukee WI 53201
+Minneapolis MN 55401
+New York NY 10001
+Newark NJ 07101
+Paterson NJ 07510
+Philadelphia PA 19104
+Phoenix AR 85026
+Pittsburgh PA 15230
+Providence RI 02904
+Rochester NY 14603
+San Diego CA 92101
+San Francisco CA 94101
+Seattle WA 98101
+St. Louis MO 63166
+Syracuse NY 13201
+Trenton NJ 08608
+Utica NY 13503
+Washington DC 20013
+Yonkers NY 10598
+#user
+#cmp cities Ref
+#log
+#next
+72.2c 10
diff --git a/usr/lib/learn/editor/L72.2c b/usr/lib/learn/editor/L72.2c
new file mode 100644 (file)
index 0000000..4218185
--- /dev/null
@@ -0,0 +1,42 @@
+#print
+There is a file "price" in this directory.  Find all
+lines which don't begin with blank and put three asterisks
+at the beginning of each such line.  Then rewrite
+the file and type "ready".
+#create Ref
+***beef
+  shoulder 1.39/lb
+  flank    1.59/lb
+  sirloin  2.19/lb
+  round    1.89/lb
+***fish
+  sword    3.99/lb
+  cod      1.99/lb
+  blues    2.49/lb
+  stripers 3.49/lb
+  flounder 2.99/lb
+***pork
+  shoulder  .89/lb
+  loin     1.59/lb
+  bacon    1.19/lb
+#create price
+beef
+  shoulder 1.39/lb
+  flank    1.59/lb
+  sirloin  2.19/lb
+  round    1.89/lb
+fish
+  sword    3.99/lb
+  cod      1.99/lb
+  blues    2.49/lb
+  stripers 3.49/lb
+  flounder 2.99/lb
+pork
+  shoulder  .89/lb
+  loin     1.59/lb
+  bacon    1.19/lb
+#user
+#cmp price Ref
+#log
+#next
+72.2d 10
diff --git a/usr/lib/learn/editor/L72.2d b/usr/lib/learn/editor/L72.2d
new file mode 100644 (file)
index 0000000..6f6fd89
--- /dev/null
@@ -0,0 +1,27 @@
+#print
+There is a file "song" in this directory. Find all lines
+which don't end in "." and put a comma at the end of
+these lines.  Then rewrite the file and type "ready".
+#create Ref
+It seems that Early English art,
+ Alone retains its zest.
+To charm and please its devotees,
+ We've done our level best.
+We're not quite sure that all we do,
+ Has the Early English ring,
+But as far as we can tell,
+ It's something lIke this sort of thing.
+#create song
+It seems that Early English art
+ Alone retains its zest.
+To charm and please its devotees
+ We've done our level best.
+We're not quite sure that all we do
+ Has the Early English ring
+But as far as we can tell
+ It's something lIke this sort of thing.
+#user
+#cmp song Ref
+#log
+#next
+73.1a 10
diff --git a/usr/lib/learn/editor/L73.1a b/usr/lib/learn/editor/L73.1a
new file mode 100644 (file)
index 0000000..158d0d9
--- /dev/null
@@ -0,0 +1,34 @@
+#print
+Back early in this sequence we made clear that
+the shell (the normal command interpreter) and the
+editor were distinct and they didn't pay any attention
+to each other's commands.
+Sometimes you are in the editor and you really want
+to execute a shell command.  You can do that
+by prefixing it with !.  For example,
+  !ls
+will list your directory.
+Remember that "date" is the shell command
+to find out what time it is.
+Try editing the file 'bridge'; print it out,
+then, without leaving the editor, ask for the
+time and then leave the editor and say "ready".
+#create bridge
+brooklyn
+manhattan
+williamsburg
+queensborough
+george washington
+triborough
+bronx whitestone
+throgs neck
+#create X2
+!date
+#copyin
+#user
+#uncopyin
+grep date .copy | tail -1 >X1
+#cmp X1 X2
+#log
+#next
+74.1a 10
diff --git a/usr/lib/learn/editor/L74.1a b/usr/lib/learn/editor/L74.1a
new file mode 100644 (file)
index 0000000..08be154
--- /dev/null
@@ -0,0 +1,80 @@
+#print
+Here's a last review exercise.  In the file "cities" is a list
+of cities with populations and Zip codes.  The following cities
+were omitted: add them in alphabetical order
+  St. Louis  622,236  MO 63166
+  Columbus 539,677 OH 43216
+Then, edit the file so that
+ (a) the blanks, if any, at the beginnings of lines and
+ends of lines are removed.
+ (b) each interior string of blanks is replaced by a single tab,
+except for the blanks within "Los Angeles", "New Orleans",
+"New York", "San Antonio", "San Diego", "San Francisco",
+and "St. Louis".
+ (c) Spell "Washington" and "Indianapolis" correctly.
+Then rewrite the file and type "ready".
+#create Ref
+Atlanta        496,973 GA      30301
+Baltimore      905,759 MD      21233
+Boston 641,071 MA      02109
+Bridgeport     156,542 CN      06601
+Buffalo        462,768 NY      14240
+Chicago        3,366,957       IL      60607
+Cleveland      750,903 OH      44101
+Columbus       539,677 OH      43216
+Dallas 844,401 TX      75221
+Denver 514,678 CO      80201
+Detroit        1,511,482       MI      48226
+Hartford       158,017 CN      06101
+Houston        1,232,802       TX      77052
+Indianapolis   774,624 IN      46201
+Los Angeles    2,809,596       CA      92101
+Miami  334,859 FL      33101
+Milwaukee      717,099 WI      53201
+Minneapolis    434,400 MN      55401
+New Orleans    593,471 LA      70140
+New York       7,894,862       NY      10001
+Newark 382,417 NJ      07901
+Omaha  347,328 NE      68108
+Philadephia    1,948,609       PA      19104
+Phoenix        581,562 AR      85026
+Pittsburgh     520,117 PA      15230
+San Antonio    654,153 TX      78205
+San Diego      696,769 CA      92101
+San Francisco  715,674 CA      94101
+Seattle        530,831 WA      98101
+St. Louis      622,236 MO      63166
+Washington     756,510 DC      20013
+#create cities
+  Atlanta  496,973  GA     30301
+  Baltimore  905,759  MD  21233
+Boston  641,071  MA  02109 
+Bridgeport  156,542   CN  06601
+  Buffalo  462,768  NY  14240
+  Chicago     3,366,957  IL  60607
+Cleveland  750,903  OH  44101 
+Dallas  844,401  TX  75221
+Denver  514,678  CO  80201
+Detroit  1,511,482   MI  48226
+Hartford  158,017  CN  06101 
+Houston  1,232,802   TX  77052
+Indianpolis  774,624  IN  46201
+Los Angeles  2,809,596  CA  92101 
+Miami     334,859  FL  33101 
+  Milwaukee  717,099  WI  53201
+Minneapolis  434,400  MN  55401
+New Orleans  593,471  LA  70140
+New York  7,894,862   NY  10001 
+Newark     382,417  NJ  07901
+  Omaha     347,328  NE  68108 
+  Philadephia  1,948,609  PA  19104 
+Phoenix  581,562   AR  85026
+Pittsburgh  520,117  PA  15230
+  San Antonio  654,153  TX  78205
+  San Diego  696,769  CA  92101 
+  San Francisco  715,674  CA  94101 
+  Seattle  530,831  WA  98101 
+Washinggton  756,510  DC  20013 
+#user
+#cmp cities Ref
+#log
diff --git a/usr/lib/learn/editor/L8.1a b/usr/lib/learn/editor/L8.1a
new file mode 100644 (file)
index 0000000..ee421a4
--- /dev/null
@@ -0,0 +1,38 @@
+#print
+To move around, you can use simple arithmetic
+when specifying what to print.  For example,
+  3+1p
+is the same as
+  4p
+as an editor command.  Now that's not very interesting;
+but if the '.' current line pointer is line 3,
+then using
+  .+1p
+instead of 4p is helpful.
+For example, print the 3rd and 4th
+lines of the familiar file using first "3p" to
+get to line 3 and then ".+1p" to print the next line.
+End as usual with w, q, and ready.
+#create Ref
+thomas jefferson
+james madison
+91
+#create file
+george washington
+john adams
+thomas jefferson
+james madison
+james monroe
+john quincy adams
+#copyout
+#pipe
+ed file
+#user
+#unpipe
+#uncopyout
+tail -3 .ocopy >X1
+#cmp Ref X1
+#log
+#next
+9.1a 10
+8.1b 7
diff --git a/usr/lib/learn/editor/L8.1b b/usr/lib/learn/editor/L8.1b
new file mode 100644 (file)
index 0000000..852bc4f
--- /dev/null
@@ -0,0 +1,18 @@
+#print
+You can also use "-" in addresses.  For example,
+the line before the current line is line ".-1"
+and can be printed with ".-1p" or even just ".-1".
+How would you print the line two lines before the current
+line?  Type "answer COMMAND" where COMMAND is
+the command you would type to print that line.
+#copyin
+#user
+#uncopyin
+#match .-2p
+#match .-2
+#match -2
+#match --
+#log
+#next
+9.1a 10
+9.2a 5
diff --git a/usr/lib/learn/editor/L8.2a b/usr/lib/learn/editor/L8.2a
new file mode 100644 (file)
index 0000000..631b6f6
--- /dev/null
@@ -0,0 +1,44 @@
+#print
+You can give addresses involving simple arithmetic
+to move around in the file.  For example, 
+  3+1p
+is the same as
+  4p
+in the editor.  Now that's not interesting, but
+if the current line (".") is line 3, then
+  .+1p
+is also 4p; it prints the next line. For example,
+you can print the 3rd and 4th lines of this file
+using
+   3p
+   .+1p
+   w
+   q
+where "3p" prints the third line, as usual,
+and then ".+1p" prints the next or fourth line.
+Try that.  Type "ready" when done.
+#create Ref
+caslon
+century schoolbook
+86
+#create file
+baskerville
+bodoni
+caslon
+century schoolbook
+futura
+helvetica
+news gothic
+times roman
+#copyout
+#pipe
+ed file
+#user
+#unpipe
+#uncopyout
+tail -3 .ocopy >X1
+#cmp Ref X1
+#log
+#next
+8.2b 5
+9.1a 10
diff --git a/usr/lib/learn/editor/L8.2b b/usr/lib/learn/editor/L8.2b
new file mode 100644 (file)
index 0000000..f7aeef5
--- /dev/null
@@ -0,0 +1,26 @@
+#print
+Using the same scheme, print lines 2 and 3 of this file.
+Then rewrite it and leave and type "ready".
+#create Ref
+john adams
+thomas jefferson
+91
+#create file
+george washington
+john adams
+thomas jefferson
+james madison
+james monroe
+john quincy adams
+#copyout
+#pipe
+ed file
+#user
+#unpipe
+#uncopyout
+tail -3 .ocopy >X1
+#cmp Ref X1
+#log
+#next
+8.2c 3
+8.1b 8
diff --git a/usr/lib/learn/editor/L8.2c b/usr/lib/learn/editor/L8.2c
new file mode 100644 (file)
index 0000000..bd33aac
--- /dev/null
@@ -0,0 +1,36 @@
+#print
+You can also use "-" in addresses.
+For example, you can print the
+line before the current line with
+  .-1p
+as a command.  Again, I'll put
+you in the editor; print the fifth
+line and then the fourth, using this
+command to print lines in reverse
+order.  Then leave with w, q, and ready.
+#create Ref
+carrots
+squash
+83
+#create file
+broccoli
+mushrooms
+cauliflower
+squash
+carrots
+lettuce
+string beans
+peas
+lima beans
+#copyout
+#pipe
+ed file
+#user
+#unpipe
+#uncopyout
+tail -3 .ocopy >X1
+#cmp Ref X1
+#log
+#next
+9.1a 10
+9.2a 5
diff --git a/usr/lib/learn/editor/L9.1a b/usr/lib/learn/editor/L9.1a
new file mode 100644 (file)
index 0000000..7d5a1e7
--- /dev/null
@@ -0,0 +1,34 @@
+#print
+Printing only one line at a time gets pretty
+slow.  You can print several lines with
+commands like
+  1,3p
+which prints lines 1, 2 and 3.
+Again, I'll put you into the editor
+with the familiar file.  Print lines
+2 through 5 of it; then type w, q and ready.
+#create Ref
+john adams
+thomas jefferson
+james madison
+james monroe
+91
+#create file
+george washington
+john adams
+thomas jefferson
+james madison
+james monroe
+john quincy adams
+#copyout
+#pipe
+ed file
+#user
+#unpipe
+#uncopyout
+tail -5 .ocopy >X1
+#cmp X1 Ref
+#log
+#next
+10.1a 10
+9.2e 5
diff --git a/usr/lib/learn/editor/L9.2a b/usr/lib/learn/editor/L9.2a
new file mode 100644 (file)
index 0000000..2ccb8da
--- /dev/null
@@ -0,0 +1,36 @@
+#print
+You can print several lines at once by
+using commands like
+  1,3p
+which prints lines 1, 2 and 3.  Again,
+I'll put you into the editor.  Print
+lines 1 to 3 of the file;  then type
+w, q and ready.
+Your commands should look like
+  1,3p
+  w
+  q
+  ready
+#create Ref
+george washington
+john adams
+thomas jefferson
+91
+#create file
+george washington
+john adams
+thomas jefferson
+james madison
+james monroe
+john quincy adams
+#copyout
+#pipe
+ed file
+#user
+#unpipe
+#uncopyout
+tail -4 .ocopy >X1
+#cmp X1 Ref
+#log
+#next
+9.2b 5
diff --git a/usr/lib/learn/editor/L9.2b b/usr/lib/learn/editor/L9.2b
new file mode 100644 (file)
index 0000000..3f9aca8
--- /dev/null
@@ -0,0 +1,34 @@
+#print
+You can of course use any kind of line
+numbers for the addresses in the
+"p" command.  Just as you did before,
+print lines 2 through 5 of this file,
+and then type w, q, and ready.
+#create Ref
+mushrooms
+cauliflower
+squash
+carrots
+83
+#create file
+broccoli
+mushrooms
+cauliflower
+squash
+carrots
+lettuce
+string beans
+peas
+lima beans
+#copyout
+#pipe
+ed file
+#user
+#unpipe
+#uncopyout
+tail -5 .ocopy >X1
+#cmp X1 Ref
+#log
+#next
+9.3c 3
+9.2d 7
diff --git a/usr/lib/learn/editor/L9.2d b/usr/lib/learn/editor/L9.2d
new file mode 100644 (file)
index 0000000..ed4e408
--- /dev/null
@@ -0,0 +1,36 @@
+#print
+The "." operator can be used with multiple
+addresses to refer to the current line
+in either the first or second position (or both).
+For example, you could print from the current line
+to the 6th line with
+  .,6p
+and similarly for any other line.  I'll put
+you in the editor again, with the current line
+set in the middle of a short file; print from
+the current line position to the fifth line, and
+then type w, q and ready.
+#create Ref
+ 2. UNIX
+  3. hardware
+  4. software
+  5. manuals
+97
+#create file
+ 2. UNIX
+  3. hardware
+  4. software
+  5. manuals
+you shouldn't have printed this line.
+#copyout
+#pipe
+ed file
+1t1
+#user
+#unpipe
+#uncopyout
+tail -5 .ocopy >X1
+#cmp X1 Ref
+#log
+#next
+9.2e 5
diff --git a/usr/lib/learn/editor/L9.2e b/usr/lib/learn/editor/L9.2e
new file mode 100644 (file)
index 0000000..15ac77a
--- /dev/null
@@ -0,0 +1,21 @@
+#print
+You can also employ addresses using arithmetic with
+this kind of command.  For example, what "p" command
+would you type to print from line 2 to the line
+before the current line of the file?  Remember what
+the line before the current line is: 
+  .-1
+right?
+Type "answer COMMAND" where COMMAND is the specified
+"p" command.
+#copyin
+#user
+#uncopyin
+#match 2,.-1p
+#match 2,-p
+#match 2,.-p
+#log
+#next
+10.1a 10
+10.2a 5
+10.3a 2
diff --git a/usr/lib/learn/editor/L9.3c b/usr/lib/learn/editor/L9.3c
new file mode 100644 (file)
index 0000000..859ccb0
--- /dev/null
@@ -0,0 +1,44 @@
+#print
+You can make up addresses for the 'p' command
+using '.' for the current line when there are
+two addresses, also.  For example, you could
+print from the first line up to the present
+line with
+  1,.p
+and I suggest you try that now.  After
+that command, type the usual
+  w
+  q
+  ready
+#create Ref
+83
+broccoli
+mushrooms
+cauliflower
+squash
+carrots
+lettuce
+string beans
+peas
+lima beans
+83
+#create file
+broccoli
+mushrooms
+cauliflower
+squash
+carrots
+lettuce
+string beans
+peas
+lima beans
+#copyout
+#pipe
+ed file
+#user
+#unpipe
+#uncopyout
+#cmp .ocopy Ref
+#log
+#next
+9.2d 5
diff --git a/usr/lib/learn/eqn/Init b/usr/lib/learn/eqn/Init
new file mode 100755 (executable)
index 0000000..6d29206
--- /dev/null
@@ -0,0 +1,14 @@
+if test x$term != x
+then
+       true
+       exit
+fi
+echo 'I need to know what kind of terminal you are using.
+I will put you out of learn. Type these commands
+
+term=xxx       (where xxx is one of 300, 300S, 450, etc.)
+               (with no spaces!)
+export term
+
+Then type "learn eqn" again.'
+false
diff --git a/usr/lib/learn/eqn/L0 b/usr/lib/learn/eqn/L0
new file mode 100644 (file)
index 0000000..4da0083
--- /dev/null
@@ -0,0 +1,2 @@
+#next
+0.1a
diff --git a/usr/lib/learn/eqn/L0.1a b/usr/lib/learn/eqn/L0.1a
new file mode 100644 (file)
index 0000000..357826f
--- /dev/null
@@ -0,0 +1,49 @@
+#once #create message
+.EQ
+delim $$
+.EN
+.pl 1
+.ll 55
+This script is designed to teach you the "eqn" language
+for typing mathematics. 
+There are two versions of the program. "eqn" is for
+use on the phototypesetter; "neqn" is for use on a
+terminal like a DASI or GSI, or a Model 37 teletype.
+The lessons are mostly written under the assumption
+that you will be using neqn on a DASI or GSI or teletype;
+a few things that are specific to eqn on the typesetter are
+left to the end.
+
+The terminal MUST be a DASI or GSI or teletype,
+or you will get some rather startling results
+from this script.
+
+To verify that everything is working, this message
+should come out with subscripts, superscripts, Greek
+letters and so on.  If it doesn't, we're in
+trouble.
+.sp
+Summation sign: $ sum $
+.sp
+Letter pi: $ pi $
+.sp
+Subscript and superscript: $ x sub i ~=~ y sup j $
+.sp
+If this looks ok, type yes.  Otherwise, type no.
+.pl 1
+#
+#once neqn message | nroff -T$term
+#copyin
+#user
+#uncopyin
+#match yes
+#fail
+Do you have the right kind of terminal?
+If you are using a DASI or GSI, make
+sure the switch labeled "PLOT" inside the cover
+is set to ON.
+If these fail, call for help;
+otherwise type yes the next time.
+#log
+#next
+1.1a
diff --git a/usr/lib/learn/eqn/L1.1a b/usr/lib/learn/eqn/L1.1a
new file mode 100644 (file)
index 0000000..fbcee8d
--- /dev/null
@@ -0,0 +1,35 @@
+#print
+To properly print a file containing an equation,
+you have to type a longer-than-usual command line.
+If you are using a DASI or GSI, to print a file
+"math" that contains mathematics, you must say
+
+  neqn math | nroff -Txxx
+
+where "-Txxx" describes the terminal you are using.
+This is usually one of
+  -T300
+  -T300S
+  -T450
+It is very important that you get this line right.
+If you don't, you'll not be happy with your output.
+
+In this directory is a file called "Example"; print
+it properly, using whichever command line is 
+appropriate to your terminal.
+Then type "ready".
+#once #create Example
+This is a little file that contains an
+example of a subscript and superscript:
+.ce
+.EQ
+a sub i + b sub i ~=~ c sub i sup 2
+.EN
+.pl 1
+#copyin
+#user
+#uncopyin
+grep 'neqn Example *| *nroff -T' <.copy >/dev/null
+#log
+#next
+1.1b 10
diff --git a/usr/lib/learn/eqn/L1.1b b/usr/lib/learn/eqn/L1.1b
new file mode 100644 (file)
index 0000000..60c00a6
--- /dev/null
@@ -0,0 +1,51 @@
+#print
+Most technical papers and memos consist of normal text
+interspersed with occasional (or frequent) mathematical
+expressions, such as the ones in the last lesson.
+To tell neqn that something is mathematics, not normal
+text, you must surround it by two "commands":
+
+   A line that begins with
+   .EQ
+   marks the start of an expression.
+
+   A line that begins with
+   .EN
+   marks the end of the expression.
+
+Thus, the lines
+.EQ
+x=y+1
+.EN
+represent the equation
+
+x=y+1
+
+The file "Example" in this directory has a line that contains
++ and - signs.  Make that line into an equation
+by adding .EQ and .EN before and after.
+Print "Example" with neqn and nroff (and the appropriate -Txxx),
+then type "ready".
+#once #create Ref
+This is a tiny little text
+that includes one equation
+or at least it will when you find this line:
+.ce
+.EQ
+a = b + c - d
+.EN
+and convert it into an equation.
+.pl 1
+#once #create Example
+This is a tiny little text
+that includes one equation
+or at least it will when you find this line:
+.ce
+a = b + c - d
+and convert it into an equation.
+.pl 1
+#user
+#cmp Ref Example
+#log
+#next
+1.1c 10
diff --git a/usr/lib/learn/eqn/L1.1c b/usr/lib/learn/eqn/L1.1c
new file mode 100644 (file)
index 0000000..77edb1f
--- /dev/null
@@ -0,0 +1,39 @@
+#print
+It is usually wise to do your formatting with
+the "-ms" macro package developed by Mike Lesk, since
+it does a lot of dirty work for you without any effort
+on your part.
+One of the things "-ms" does is to arrange that equations
+are "displayed" - that is, that they are neatly centered
+and set off from the surrounding text.
+Most of the "-ms" package is described in another script
+called "macros", which you may have already learned.
+For now, we need only know this much: to use "-ms"
+with neqn, add "-ms" to your command line, right after
+the word "nroff", like this
+
+  neqn files... | nroff -ms -Txxx
+
+Notice where the "-ms" goes.
+
+In this directory is a file called "Example".
+To prove that you can type the "-ms" in the right place,
+print "Example" with "-ms", then type "ready".
+#once #create Example
+.PP
+This is a tiny little text
+that includes one equation
+or at least it will when you find this line:
+.EQ
+x sub i = y sub i
+.EN
+and convert it into an equation.
+(Naturally I changed it.)
+.pl 1
+#copyin
+#user
+#uncopyin
+grep 'neqn Example *| *nroff -ms' <.copy >/dev/null
+#log
+#next
+1.1d 10
diff --git a/usr/lib/learn/eqn/L1.1d b/usr/lib/learn/eqn/L1.1d
new file mode 100644 (file)
index 0000000..949d4fa
--- /dev/null
@@ -0,0 +1,34 @@
+#print
+The "-ms" package lets you do some other nice things as
+well.  For example, you can arrange for a number to be
+placed on an equation, in the right margin:
+
+  a = b + c - d                               (1.23)
+
+by placing the number after the .EQ on the same line,
+like this:
+
+.EQ (1.23)
+
+You must leave a space between .EQ and the number.
+
+In the file "Example", number the equation "17.1a"
+and print it properly with neqn and nroff -ms.
+(Don't forget -Txxx for your terminal.)
+Then type "ready".
+#once #create Example
+.PP
+This is a tiny little text
+that includes one equation
+or at least it will when you find this line:
+.EQ
+x sub i = y sub i + z sub i
+.EN
+and convert it into an equation.
+(Naturally I changed it again.)
+.pl 1
+#user
+grep '\.EQ  *17\.1a$' <Example >/dev/null
+#log
+#next
+1.1e 10
diff --git a/usr/lib/learn/eqn/L1.1e b/usr/lib/learn/eqn/L1.1e
new file mode 100644 (file)
index 0000000..bec107f
--- /dev/null
@@ -0,0 +1,30 @@
+#print
+So far all the equations have been centered, which is what
+"-ms" does unless you tell it differently.
+You can also arrange for equations to be left-adjusted -
+that is, right up against the left margin - by saying
+  .EQ L
+If there is a number, place it _____\b\b\b\b\bafter the L, separated by a
+space, like this:
+  .EQ L (3a)
+
+Make the equation in "Example" left-justified with
+the number (3.1a) in the right margin and print it
+to make sure everything works.  Then type "ready".
+#once #create Example
+.PP
+This is a tiny little text
+(which you're undoubtedly sick of by now)
+that includes one equation
+or at least it will when you find this line:
+.EQ
+x sup i = y sup i
+.EN
+and convert it into an equation.
+(Naturally I changed it.)
+.pl 1
+#user
+grep '\.EQ  *L  *(3.1a)$' <Example >/dev/null
+#log
+#next
+1.1f 10
diff --git a/usr/lib/learn/eqn/L1.1f b/usr/lib/learn/eqn/L1.1f
new file mode 100644 (file)
index 0000000..72d7e53
--- /dev/null
@@ -0,0 +1,87 @@
+#print
+You can also make equations that are ________\b\b\b\b\b\b\b\bindented a fixed amount from
+the left margin, with the command
+  .EQ I
+Again, if there is an equation number, it follows the I.
+
+Convert all the equations in "Example" to indented ones.
+(Naturally I've changed it.)
+You can do this with a single editor command.
+
+Print "Example" with neqn and nroff -ms,
+then type "ready".
+#once #create Ref
+.LP
+     EQUIVALENCES OF ONE SORT AND ANOTHER
+.LP
+.EQ I (2.01)
+bold x sup { n alpha } (t) ~->~ bold x sup alpha ( bold X ,t).
+.EN
+.sp
+.EQ I (2.02)
+sum from n F( bold x sup { n alpha } (t))
+~->~ 1 over OMEGA INT F( bold x sup alpha ( bold X ,t))d bold \|X
+.EN
+.EQ I (2.03)
+bold x ( bold X ,t) ~==~
+sum from  { alpha =1} to  N
+rho sup alpha  over rho sup 0 bold x sup alpha ( bold X ,t)
+.EN
+.EQ I (2.08)
+sum from  {alpha =1} to  N
+U sup { mu alpha } V sup { mu alpha } ~=~ delta sup { mu nu }
+.EN
+.EQ I (2.06)
+bold y sup { T mu } ( bold X ,t) 
+~==~ sum from  {alpha =1} to  N
+U sup { mu alpha }
+bold x sup alpha
+( bold X ,t)
+.EN
+.EQ I
+~ partial over {partial d} 
+ ( epsilon sub 0 bold E sup T times  bold B ) sub i  
+- m sub ij,\|j ~=~
+-q sup D E sub i sup T
+-( bold ~j sup D times bold B ) sub i
+.EN
+#once #create Example
+.LP
+     EQUIVALENCES OF ONE SORT AND ANOTHER
+.LP
+.EQ (2.01)
+bold x sup { n alpha } (t) ~->~ bold x sup alpha ( bold X ,t).
+.EN
+.sp
+.EQ (2.02)
+sum from n F( bold x sup { n alpha } (t))
+~->~ 1 over OMEGA INT F( bold x sup alpha ( bold X ,t))d bold \|X
+.EN
+.EQ (2.03)
+bold x ( bold X ,t) ~==~
+sum from  { alpha =1} to  N
+rho sup alpha  over rho sup 0 bold x sup alpha ( bold X ,t)
+.EN
+.EQ (2.08)
+sum from  {alpha =1} to  N
+U sup { mu alpha } V sup { mu alpha } ~=~ delta sup { mu nu }
+.EN
+.EQ (2.06)
+bold y sup { T mu } ( bold X ,t) 
+~==~ sum from  {alpha =1} to  N
+U sup { mu alpha }
+bold x sup alpha
+( bold X ,t)
+.EN
+.EQ
+~ partial over {partial d} 
+ ( epsilon sub 0 bold E sup T times  bold B ) sub i  
+- m sub ij,\|j ~=~
+-q sup D E sub i sup T
+-( bold ~j sup D times bold B ) sub i
+.EN
+#user
+#cmp Ref Example
+#log
+#next
+2.1a 10
diff --git a/usr/lib/learn/eqn/L10.1a b/usr/lib/learn/eqn/L10.1a
new file mode 100644 (file)
index 0000000..71423a9
--- /dev/null
@@ -0,0 +1,77 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.LP
+The next topic goes back to the problem of formatting
+equations on the page.  Sometimes it is desirable to
+line up one part of an equation with some part
+of a previous equation - for example, equals signs
+are often lined up like this:
+.EQ I
+x mark = y sub i
+.EN
+.EQ I
+lineup = z sub i
+.EN
+.EQ I
+x sub i + y sub i lineup = z sub i
+.EN
+
+To achieve this, you have to do several things.
+(1) tell neqn to remember the place where things are
+to be lined up, which is done by saying
+"mark" just before the thing you want remembered:
+  .EQ I
+  x mark = y sub i
+  .EN
+.br
+(2) Then, in successive equations, telling neqn
+to line up something on the previous mark, with
+"lineup":
+   .EQ I
+   lineup = z sub i
+   .EN
+.br
+(3) You ____\b\b\b\bhave __\b\bto use either ".EQ I" or ".EQ L";
+you can't line things up in a centered equation.
+
+For practice, modify "Example" so the
+equations are lined up on the equals signs, then
+type "ready".
+.pl 1
+#once #create Ref
+.LP
+A test of mark and lineup:
+.EQ I
+x sub i ~ mark =~ 1
+.EN
+.EQ I
+x sub i + y sub i ~ lineup = ~2
+.EN
+.pl 1
+#once #create Example
+.LP
+A test of mark and lineup:
+.EQ I
+x sub i ~ =~ 1
+.EN
+.EQ I
+x sub i + y sub i ~ =~ 2
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#fail
+Don't forget that tilde is a real character;
+put the mark and lineup after it.
+Remember .EQ I.
+#log
+#next
+10.1b 10
diff --git a/usr/lib/learn/eqn/L10.1b b/usr/lib/learn/eqn/L10.1b
new file mode 100644 (file)
index 0000000..5b5c389
--- /dev/null
@@ -0,0 +1,42 @@
+#print
+More practice with mark and lineup.
+Modify "Example" so the + signs are lined up in
+all of the equations, then type "ready".
+#once #create Ref
+.LP
+.EQ I
+x ~==~ a sub i ~ mark + ~ b sub i ~-~ c sub i
+.EN
+.EQ I
+lineup + ~ d sub i - e sub i
+.EN
+.EQ I
+lineup + ~ f sub i - g sub i
+.EN
+.EQ I
+lineup + ~ ...
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ I
+x ~==~ a sub i ~ + ~ b sub i ~-~ c sub i
+.EN
+.EQ I
++ ~ d sub i - e sub i
+.EN
+.EQ I
++ ~ f sub i - g sub i
+.EN
+.EQ I
++ ~ ...
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+10.1c 10
diff --git a/usr/lib/learn/eqn/L10.1c b/usr/lib/learn/eqn/L10.1c
new file mode 100644 (file)
index 0000000..88e2c24
--- /dev/null
@@ -0,0 +1,25 @@
+#print
+There are several warnings in order about mark and lineup.
+First, remember that you must use ".EQ I" or ".EQ L".
+Second, there can only be one mark or one lineup in any given
+equation.
+Finally, what you are doing must make sense, or
+your results may be not what you wanted.
+
+Does this sequence produce output with the equals signs
+lined up?
+  .EQ L
+  x mark = y
+  .EN
+  .EQ L
+  x+y mark = z
+  .EN
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+11.1a 10
+10.2c 5
diff --git a/usr/lib/learn/eqn/L10.2c b/usr/lib/learn/eqn/L10.2c
new file mode 100644 (file)
index 0000000..53e1397
--- /dev/null
@@ -0,0 +1,17 @@
+#print
+Does this sequence produce output with the equals signs
+lined up?
+  .EQ I
+  x mark = y
+  .EN
+  .EQ I
+  x+y mark = z
+  .EN
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+11.1a 10
diff --git a/usr/lib/learn/eqn/L11.1a b/usr/lib/learn/eqn/L11.1a
new file mode 100644 (file)
index 0000000..a03f703
--- /dev/null
@@ -0,0 +1,46 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.LP
+We have introduced a fair number of "magic" words like
+sub and sup and over and pi and sum.  What happens if
+you need to print an equation that contains one of these
+words __\b\bas ____\b\b\b\btext, like this:
+.EQ
+e sub "pi"
+.EN
+
+The way to turn off special meanings of magic words is
+to enclose them in the double quotes "...".  The $e sub "pi"$
+was printed with
+  .EQ
+  e sub "pi"
+  .EN
+
+Using this knowledge, modify file "Example" so it produces output
+that looks like the following, then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+lim "sup" f( "pi" ) = p cdot i
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+lim sup f( pi ) = p cdot i
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+11.1b 10
diff --git a/usr/lib/learn/eqn/L11.1b b/usr/lib/learn/eqn/L11.1b
new file mode 100644 (file)
index 0000000..06fa225
--- /dev/null
@@ -0,0 +1,34 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.LP
+The quoting mechanism can also be used to turn off the special meaning
+of things like the dollar sign and braces.
+Modify "Example" so it prints the following output, then
+type "ready".
+.pl 1
+#
+#once #create Ref
+.EQ
+delim $$
+.EN
+.LP
+The cost of processing is proportional to
+$characters over "$"$.
+.pl 1
+#once #create Example
+.LP
+The cost of processing is proportional to
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+11.1c 10
diff --git a/usr/lib/learn/eqn/L11.1c b/usr/lib/learn/eqn/L11.1c
new file mode 100644 (file)
index 0000000..3b669c8
--- /dev/null
@@ -0,0 +1,31 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.LP
+Modify "Example" so it prints the following output, then
+type "ready".
+.pl 1
+#once #create Ref
+.EQ
+delim $$
+.EN
+.LP
+The cost of processing is proportional to
+${ "{" characters "}" } over "$"$.
+.pl 1
+#once #create Example
+.LP
+The cost of processing is proportional to
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+11.1d 10
diff --git a/usr/lib/learn/eqn/L11.1d b/usr/lib/learn/eqn/L11.1d
new file mode 100644 (file)
index 0000000..8b75ceb
--- /dev/null
@@ -0,0 +1,18 @@
+#print
+One thing to keep in mind, although it generally
+isn't going to affect you, is that the quote "
+is a delimiter just like blank or tilde -
+it turns off subscripts and superscripts, and so
+on. 
+Experiment a bit, and decide if
+  e sup "{t}"
+is the same as
+  e sup "{"t"}"
+Type yes if they are the same, no if they are different.
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+11.1e 10
diff --git a/usr/lib/learn/eqn/L11.1e b/usr/lib/learn/eqn/L11.1e
new file mode 100644 (file)
index 0000000..2c4a356
--- /dev/null
@@ -0,0 +1,26 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.LP
+Sometimes there will be a need for a subscript or superscript
+that has nothing to the left of it, as in references like
+  $"" sup 1$Smith, J. `A great paper...'
+
+Experiment and decide if you can get this effect
+by writing simply
+  %sup 1%Smith, J.....
+
+Type yes if this works, no if it does not.
+.pl 1
+#
+#once neqn message | nroff -T$term %s/tinyms -
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+11.1f 10
diff --git a/usr/lib/learn/eqn/L11.1f b/usr/lib/learn/eqn/L11.1f
new file mode 100644 (file)
index 0000000..0a726f4
--- /dev/null
@@ -0,0 +1,48 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.LP
+The way to handle the problem of a subscript or superscript
+on nothing is to provide something to hang the subscript
+or superscript on. 
+One possibility is to use a tilde, but that has a real width,
+and might spoil the appearance of the output.
+The best solution is this:
+
+  "" sup 1 ...
+
+The expression "" has no width, so everything works
+out properly.  The use of "" may seem a bit unnatural
+but it's an idiom that you get used to quite quickly.
+
+For practice, modify "Example" so it produces
+output that looks like this,
+then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+"" sup + H sub 2 ~ "<=>" ~ "" sup - H ~+~ "" sup + H
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+xxx
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#fail
+Don't forget spaces; don't forget to quote
+things when needed (including <=>).
+#log
+#next
+11.1g 10
diff --git a/usr/lib/learn/eqn/L11.1g b/usr/lib/learn/eqn/L11.1g
new file mode 100644 (file)
index 0000000..66216e1
--- /dev/null
@@ -0,0 +1,32 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.LP
+For practice, modify "Example" so it produces
+output that looks like this,
+then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+{ lim ~ "sup" } bar ~f(x) ~=~ x
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+xxx
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+12.1a 10
diff --git a/usr/lib/learn/eqn/L12.1a b/usr/lib/learn/eqn/L12.1a
new file mode 100644 (file)
index 0000000..a9382b6
--- /dev/null
@@ -0,0 +1,53 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.LP
+The next step is to learn how to put big parentheses,
+brackets, braces or bars around equations, like this:
+.EQ
+left | a sup 2 over b sub i right |
+.EN
+
+This is done with two new words called "left" and "right".
+To put bars around something, you simply say, in the middle
+of an equation,
+  left |  something  right |
+and the job is done.
+"something" can indeed be anything, from a single letter
+up to some horribly complicated mess.
+The bars grow to the right height to cover the
+"something", automatically.
+To produce the example above, all that was needed was
+   .EQ
+   left | a sup 2 over b sub i right |
+   .EN
+
+For practice, modify file "Example" so it produces output
+that looks like this, then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+left |
+{a over b ~+~ c over d} over 2
+right |
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+replace me
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+12.1b 10
diff --git a/usr/lib/learn/eqn/L12.1b b/usr/lib/learn/eqn/L12.1b
new file mode 100644 (file)
index 0000000..6886309
--- /dev/null
@@ -0,0 +1,29 @@
+#print
+Bars are not the only characters you can put 
+around an equation.
+If you say
+  left (  thing  right )
+you will get large parentheses around "thing".
+You can also use [ and ] for large square brackets
+and { and } for large braces.
+
+The main problem is that on your terminal there is
+no good way for neqn to draw large braces
+or brackets or parens.  So neqn replaces all of these
+with bars.
+Use the right character anyway, though - things do
+work properly on the typesetter.  And who knows, some day
+neqn may get improved as well.
+
+With the current version of neqn, does the input
+  left { a over b right }
+produce the same output as
+  left [ a over b right ]
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+12.1c 10
diff --git a/usr/lib/learn/eqn/L12.1c b/usr/lib/learn/eqn/L12.1c
new file mode 100644 (file)
index 0000000..20bf122
--- /dev/null
@@ -0,0 +1,44 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.LP
+Of course the thing with bars or braces around it can
+still be part of larger expressions: the input
+   .EQ
+   left | {a over b ~+~ c over d} over 2 right | over a+b+c+d
+   .EN
+produces
+.EQ
+left | {a over b ~+~ c over d} over 2 right | over a+b+c+d
+.EN
+
+For practice, modify file "Example" so it produces output
+that looks like this, then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+left |
+{a over b ~+~ c over d} over 2
+right |
+sup half
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+replace me
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+12.1d 10
diff --git a/usr/lib/learn/eqn/L12.1d b/usr/lib/learn/eqn/L12.1d
new file mode 100644 (file)
index 0000000..32f1d48
--- /dev/null
@@ -0,0 +1,21 @@
+#print
+.LP
+The "right" part of a left-right construction can be
+omitted if it is not used; just leave that part out.
+The main thing to watch out for is that now you will
+need braces to enclose the entire construction, "left" and all -
+otherwise neqn will not know where to stop in
+figuring out how high the thing is.
+
+For example, will
+  left "{" a + b over c over d
+produce the same output as
+   { left "{" a } + b over c over d
+Answer yes or no after experimenting.
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+12.1e 10
diff --git a/usr/lib/learn/eqn/L12.1e b/usr/lib/learn/eqn/L12.1e
new file mode 100644 (file)
index 0000000..fc78d36
--- /dev/null
@@ -0,0 +1,43 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.PP
+There are also occasions when you want to omit
+the left part and keep the right part.
+This is a bit more complicated, since for obscure
+reasons neqn won't let you actually leave the
+left part out completely.
+But you can ask it to print no character,
+instead of using bars, by saying
+   left ""  thing  right |
+.LP
+This is similar to the way we used quotes before, to get
+a zero-width thing before a superscript.
+
+For practice, modify file "Example" so it produces output
+that looks like this, then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+left ""
+int from 0 to {2 pi} sin (x) dx ~=~
+cos (x) right | sub 0 sup {2 pi}
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+replace me
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
diff --git a/usr/lib/learn/eqn/L2.1a b/usr/lib/learn/eqn/L2.1a
new file mode 100644 (file)
index 0000000..cf2956c
--- /dev/null
@@ -0,0 +1,38 @@
+#print
+You may have noticed that neqn threw away the spaces
+in several of the examples we did.  For example, in
+.EQ
+a = b + c - d
+.EN
+the output equation looks like
+a=b+c-d
+regardless of spaces in the input.
+
+Spaces are always thrown away, and so are new lines - you
+can type an equation on as many lines as you like.
+This latitude is permitted mainly to make it easy to type equations -
+longer equations are easier to edit when they are typed
+as a series of short input lines instead of one giant
+one.
+
+Will the printed output of this equation
+.EQ
+a
++
+b
++
+c
+.EN
+be any different from this one?
+.EQ
+a+b+c
+.EN
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+2.1b 10
+2.2a 5
diff --git a/usr/lib/learn/eqn/L2.1b b/usr/lib/learn/eqn/L2.1b
new file mode 100644 (file)
index 0000000..277f17e
--- /dev/null
@@ -0,0 +1,50 @@
+#print
+Since spaces are thrown away, what do you do when
+you want spaces? The answer is that you have to ask for
+them explicitly.
+If you type a "~" (tilde) it will be replaced by a space
+on output; use one tilde for each space.
+Thus to get
+a + b
+you need
+.EQ
+a~+~b
+.EN
+
+Modify the equation in file "Example" so there is one space
+around each of the operators =, + and -, so it looks like
+
+a = b + c - d
+
+Print it with neqn and nroff -ms to verify it.
+Type "ready" when done.
+#once #create Ref
+.PP
+You probably thought you were done with this ridiculous
+example of just
+.EQ
+a ~=~
+b ~+~ c
+~-~d
+.EN
+Sorry, but you will probably even see it again.
+.pl 1
+#once neqn Ref | nroff >X1 &
+#once #create Example
+.PP
+You probably thought you were done with this ridiculous
+example of just
+.EQ
+a =
+b + c
+-d
+.EN
+Sorry, but you will probably even see it again.
+.pl 1
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+2.1c 10
+2.2b 5
diff --git a/usr/lib/learn/eqn/L2.1c b/usr/lib/learn/eqn/L2.1c
new file mode 100644 (file)
index 0000000..37a4b31
--- /dev/null
@@ -0,0 +1,57 @@
+#once #create message
+.nf
+.EQ
+delim $$
+.EN
+Several of the examples we did earlier had Greek letters
+and other mathematical symbols in them.
+The way to get things like $pi$ and $sum$ and $int$ is
+rather easy - you just spell out their names, like this:
+
+$pi$ is pi
+
+$sum$ is sum
+
+$int$ is int
+
+and so on.
+The main thing you must always remember about these names
+is that when they appear in an equation, they must be
+separated from surrounding symbols by blanks or tildes,
+OR THEY WILL NOT BE RECOGNIZED.
+
+For practice, modify "Example" so the symbol $partial$
+is replaced by $sum$ everywhere it appears.
+Type "ready" when you're done.
+.pl 1
+#once #create Ref
+.PP
+The symbol
+.EQ
+sum
+.EN
+often appears in lines like
+.EQ
+{ sum x } over { sum y } = y over x
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1  &
+#once neqn message | nroff -T$term
+#once #create Example
+.PP
+The symbol
+.EQ
+partial
+.EN
+often appears in lines like
+.EQ
+{ partial x } over { partial y } = y over x
+.EN
+.pl 1
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+2.1d 10
diff --git a/usr/lib/learn/eqn/L2.1d b/usr/lib/learn/eqn/L2.1d
new file mode 100644 (file)
index 0000000..22bb134
--- /dev/null
@@ -0,0 +1,57 @@
+#print
+The file "Chars" contains a longer list of characters that
+you can obtain with neqn.
+Print the file "Chars" with neqn and nroff -ms, then
+type "ready".  (Don't forget -Txxx.)
+#once #create Chars
+.LP
+.EQ
+delim $$
+.EN
+.nf
+$alpha$        alpha
+$beta$ beta
+$gamma$        gamma
+$GAMMA$        GAMMA
+$delta$        delta
+$DELTA$        DELTA
+$epsilon$      epsilon
+$zeta$ zeta
+$eta$  eta
+$THETA$        THETA
+$theta$        theta
+$lambda$       lambda
+$LAMBDA$       LAMBDA
+$mu$   mu
+$nu$   nu
+$xi$   xi
+$pi$   pi
+$PI$   PI
+$rho$  rho
+$sigma$        sigma
+$SIGMA$        SIGMA
+$tau$  tau
+$phi$  phi
+$PHI$  PHI
+$psi$  psi
+$PSI$  PSI
+$omega$        omega
+$OMEGA$        OMEGA
+$partial$      partial
+$integral$     integral
+$int$  int
+$sum$  sum
+$prod$ prod
+$<=$   <=
+$>=$   >=
+$==$   ==
+$cdot$ cdot
+$...$  ...
+.pl 1
+#copyin
+#user
+#uncopyin
+grep 'neqn Chars *| *nroff' <.copy >/dev/null
+#log
+#next
+2.1e 10
diff --git a/usr/lib/learn/eqn/L2.1e b/usr/lib/learn/eqn/L2.1e
new file mode 100644 (file)
index 0000000..bf6eb69
--- /dev/null
@@ -0,0 +1,34 @@
+#once #create message
+.ND
+.PP
+For practice, in this directory there is a file called
+"Example".  It contains an equation.  Make it
+look like this:
+.EQ
+int from i to j f( pi ) ~=~ LAMBDA (x)
+.EN
+by changing the character names as appropriate
+and adding spaces where needed.
+Type "ready" when you're satisfied.
+.pl 1
+#once neqn message | nroff -T$term %s/tinyms -
+#once #create Ref
+.LP
+.EQ
+int from i to j f( pi ) ~=~ LAMBDA (x)
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+sum from i to j f(q) = lambda (x)
+.EN
+.pl 1
+#once neqn Ref | nroff >X2 &
+#user
+neqn Example | nroff >X1
+#cmp X1 X2
+#log
+#next
+2.1f 10
+2.2e 5
diff --git a/usr/lib/learn/eqn/L2.1f b/usr/lib/learn/eqn/L2.1f
new file mode 100644 (file)
index 0000000..70acf0e
--- /dev/null
@@ -0,0 +1,46 @@
+#once #create message
+.ND
+.LP
+One of the most common problems in using neqn is forgetting
+to leave spaces or tildes around "magic" words like "pi"
+or "int" or "sum".  The result is that the magic words
+cease to be magic, and just look like ordinary strings
+of letters.
+
+In the file "Example", there are several such errors.
+Find them, and fix them so the output looks
+like this, then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+sum ~=~ pi ~+~1
+.EN
+.EQ
+a~=~ pi (x)
+.EN
+.EQ
+alpha ~=~ beta ~+~ gamma ~+~ delta
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+sum=pi+1
+.EN
+.EQ
+a=pi(x)
+.EN
+.EQ
+alpha=beta+gamma+delta
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+3.1a 10
diff --git a/usr/lib/learn/eqn/L2.2a b/usr/lib/learn/eqn/L2.2a
new file mode 100644 (file)
index 0000000..e7820cd
--- /dev/null
@@ -0,0 +1,25 @@
+#print
+Will the output from the first equation below be different
+from the second? 
+
+.EQ
+X      =       Y
++Z
+.EN
+
+.EQ
+x      =       y
++       z
+.EN
+
+Answer yes if they will be different,
+no if they will be the same.
+#copyin
+#user
+#uncopyin
+#match yes
+#fail
+Look more closely at ____\b\b\b\bwhat letters are being printed.
+#log
+#next
+2.1b 10
diff --git a/usr/lib/learn/eqn/L2.2b b/usr/lib/learn/eqn/L2.2b
new file mode 100644 (file)
index 0000000..13bcad1
--- /dev/null
@@ -0,0 +1,38 @@
+#print
+One more example of spaces before getting on to something
+new.
+In the file "Example", change the spacing so the equation
+reads
+
+a = b+c-d
+
+Print the example with "-ms".
+Type "ready" when you're done.
+#once #create Ref
+.PP
+Here it is again.  One example goes a long way.
+.EQ
+a ~=~
+b + c
+-d
+.EN
+Sorry, but you will probably even see it again.
+.pl 1
+#once #create Example
+.PP
+Here it is again.  One example goes a long way.
+.EQ
+a =
+b + c
+-d
+.EN
+Sorry, but you will probably even see it again.
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+2.1c 10
diff --git a/usr/lib/learn/eqn/L2.2e b/usr/lib/learn/eqn/L2.2e
new file mode 100644 (file)
index 0000000..a4b3dac
--- /dev/null
@@ -0,0 +1,37 @@
+#print
+Make the two equations in "Example" look like these two,
+then type "ready".
+
+#once #create Ref
+.ND
+.LP
+.EQ (1.1)
+PI ~=~ ( pi sub 1 , pi sub 2 ,..., pi sub n )
+.EN
+.EQ (1.2)
+pi bar ~=~ sum ( alpha , beta )
+.EN
+.pl 1
+#once #create Example
+.ND
+.LP
+.EQ
+PHI = ( phi sub 1 , phi sub 2 ,..., phi sub n )
+.EN
+.EQ
+phi bar = sum (A,B)
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#fail
+Don't forget equation numbering and spaces
+where needed.  Print file "Chars" if you've forgotten
+the character names.
+#log
+#next
+2.1f
diff --git a/usr/lib/learn/eqn/L3.1a b/usr/lib/learn/eqn/L3.1a
new file mode 100644 (file)
index 0000000..a33f089
--- /dev/null
@@ -0,0 +1,53 @@
+#once #create message
+.ND
+.PP
+Now that we have some of the preliminaries out of the way,
+we can get on to doing real mathematics.
+I have been slipping small things into the example files
+as we go along so that you will at least have seen
+some common neqn constructions.
+
+One of the most frequent is the word "sub", which
+indicates a subscript, like this:
+
+   .EQ
+   x sub i + y sub j
+   .EN
+
+which produces
+.EQ
+x sub i + y sub j
+.EN
+The main thing to notice is that the blanks are delimiters -
+the subscript of "x" is "i"; the blank after the "i" marks
+the end of the subscript.
+
+Modify the file "Example" so the equation in it looks like
+this:
+.EQ
+x sub alpha ~=~ y sub pi ~+~ z sub pi
+.EN
+Then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+x sub alpha ~=~ y sub pi ~+~ z sub pi
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+xxx
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+3.1b 10
+3.2a 5
diff --git a/usr/lib/learn/eqn/L3.1b b/usr/lib/learn/eqn/L3.1b
new file mode 100644 (file)
index 0000000..6fe31e2
--- /dev/null
@@ -0,0 +1,41 @@
+#once #create message
+.ND
+.PP
+Naturally there is a superscript operation that's exactly
+like "sub", except that it goes up instead of down.
+It is called "sup".  To make
+.EQ
+x sup i+j
+.EN
+for example, you type
+   .EQ
+   x sup i+j
+   .EN
+
+Make the file "Example" produce the same output
+as the following, then type "ready".
+#once #create Ref
+.LP
+.EQ
+x sup alpha ~=~ y sup pi ~+~ z sup pi
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+xxx
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#fail
+Don't forget that there are spaces
+around the = and +.
+#cmp X1 X2
+#log
+#next
+3.1c 10
diff --git a/usr/lib/learn/eqn/L3.1c b/usr/lib/learn/eqn/L3.1c
new file mode 100644 (file)
index 0000000..2cc13fd
--- /dev/null
@@ -0,0 +1,39 @@
+#once #create message
+.ND
+.PP
+Subscripts and superscripts can appear in the same equation,
+and any subscripted or superscripted thing can have
+a subscript or superscript.
+For example, you can say
+
+   .EQ
+   x sub i sub j ~+~ y sup i sup j
+   .EN
+
+to get
+.EQ
+x sub i sub j ~+~ y sup i sup j
+.EN
+Modify "Example" to produce the following output, then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+2 sup 2 sup 2 sup 2 ~=~ 65536
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+xxx
+.EN
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+3.1d 10
+3.2c 5
diff --git a/usr/lib/learn/eqn/L3.1d b/usr/lib/learn/eqn/L3.1d
new file mode 100644 (file)
index 0000000..d3848c1
--- /dev/null
@@ -0,0 +1,49 @@
+#once #create message
+.ND
+.PP
+There is one special construction with subscripts
+and superscripts that you have to be aware of, although
+it almost always does what you want automatically.
+When something has both a subscript and a superscript,
+it is usually printed as
+.EQ
+x sub i sup j
+.EN
+instead of
+.EQ
+{x sub i} sup j
+.EN
+To produce this effect, with the superscript _____\b\b\b\b\babove the
+subscript instead of to the right, you have to type
+the subscript ______\b\b\b\b\b\bbefore the superscript, like this:
+
+   .EQ
+   x sub i sup j
+   .EN
+
+That's all there is to it.
+
+Modify "Example" to produce the following output, then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+x sub ij sup kmn = y sub i sub j
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+xxx
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+3.1e 10
+3.2d 5
diff --git a/usr/lib/learn/eqn/L3.1e b/usr/lib/learn/eqn/L3.1e
new file mode 100644 (file)
index 0000000..49fdba7
--- /dev/null
@@ -0,0 +1,41 @@
+#once #create message
+.ND
+.PP
+One common typing error that you should watch out for
+is forgetting to end a superscript or subscript
+with a blank or other delimiter (like tilde).
+For instance, you often see output like
+.EQ
+f(x sup 2)=1
+.EN
+because there wasn't a space left between the 2 and the ).
+What we really wanted, of course, was
+.EQ
+f(x sup 2 )=1
+.EN
+
+Modify "Example" to produce this output, then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+g( x sup pi ) 
+= pi (gx sup 2 )
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+g( x sup pi) 
+=pi(gxsup2)
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+4.1a 10
diff --git a/usr/lib/learn/eqn/L3.2a b/usr/lib/learn/eqn/L3.2a
new file mode 100644 (file)
index 0000000..9c55cd5
--- /dev/null
@@ -0,0 +1,14 @@
+#print
+Do
+   x sub i +y sub j
+and
+   x sub i+y sub j
+produce the same output?
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+3.1b 10
diff --git a/usr/lib/learn/eqn/L3.2c b/usr/lib/learn/eqn/L3.2c
new file mode 100644 (file)
index 0000000..267c01e
--- /dev/null
@@ -0,0 +1,25 @@
+#once #create message
+.ND
+.PP
+Modify "Example" to produce this output, then type "ready".
+#once #create Ref
+.LP
+.EQ
+x sup 2 + y sup 2 = z sup 2
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+xxx
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+3.1d 10
diff --git a/usr/lib/learn/eqn/L3.2d b/usr/lib/learn/eqn/L3.2d
new file mode 100644 (file)
index 0000000..ee3fd49
--- /dev/null
@@ -0,0 +1,17 @@
+#print
+Does the equation
+
+  x sup pi sub i
+
+produce the same output as
+
+  x sub i sup pi
+
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+3.1e 10
diff --git a/usr/lib/learn/eqn/L4.1a b/usr/lib/learn/eqn/L4.1a
new file mode 100644 (file)
index 0000000..a494290
--- /dev/null
@@ -0,0 +1,42 @@
+#once #create message
+.ND
+.EQ
+delim $$
+.EN
+.LP
+The next neqn word to learn is "over", which makes
+fractions like
+.EQ
+a+b over c
+.EN
+In fact that line was made by
+   .EQ
+   a+b over c
+   .EN
+To begin with an easy one, reproduce
+the equation below in the file "Example", then type
+ready.
+(To get $>=$, type ">=".)
+.pl 1
+#once #create Ref
+.LP
+.EQ
+x+1 over y+1 ~>=~ x over y
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+replace me
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+4.1b 10
+4.2a 5
diff --git a/usr/lib/learn/eqn/L4.1b b/usr/lib/learn/eqn/L4.1b
new file mode 100644 (file)
index 0000000..a989edd
--- /dev/null
@@ -0,0 +1,33 @@
+#once #create message
+.ND
+.LP
+Of course you can use reserved words like "pi" or "int"
+with the "over" construction.  For example, modify
+"Example" so its output looks like the following, then
+type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+alpha over beta ~=~ pi over 2
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+replace me
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#fail
+The names are alpha, beta and pi.
+I hope your trouble wasn't any more
+complicated than that.
+#log
+#next
+4.1c 10
diff --git a/usr/lib/learn/eqn/L4.1c b/usr/lib/learn/eqn/L4.1c
new file mode 100644 (file)
index 0000000..5ebbd5b
--- /dev/null
@@ -0,0 +1,20 @@
+#print
+Does the neqn input
+  .EQ
+  a
+  over
+  b
+  .EN
+produce the same output as the input
+  .EQ
+  a over b
+  .EN
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+4.1d 10
+4.2c 5
diff --git a/usr/lib/learn/eqn/L4.1d b/usr/lib/learn/eqn/L4.1d
new file mode 100644 (file)
index 0000000..1eea10d
--- /dev/null
@@ -0,0 +1,41 @@
+#once #create message
+.ND
+.LP
+You can put fractions over fractions with multiple "over"'s
+just as you can do multiple subscripts and superscripts,
+although fractions within fractions are much
+less common (probably because they are harder for
+people to read).
+Anyway, if you want, for example, something like
+.EQ
+a over b over c
+.EN
+you just type
+  .EQ
+  a over b over c
+  .EN
+
+As a drill, change "Example" so it produces an equation
+that looks like the following one, then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+x over x+x over x+x+x
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+right here
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+5.1a
diff --git a/usr/lib/learn/eqn/L4.2a b/usr/lib/learn/eqn/L4.2a
new file mode 100644 (file)
index 0000000..223612e
--- /dev/null
@@ -0,0 +1,28 @@
+#once #create message
+.ND
+.LP
+Another practice one for using "over".
+Modify the file "Example" so it produces
+output that looks like this one, then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+a + b over c + d = e over f
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+replace me
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+4.1b 10
diff --git a/usr/lib/learn/eqn/L4.2c b/usr/lib/learn/eqn/L4.2c
new file mode 100644 (file)
index 0000000..84b786f
--- /dev/null
@@ -0,0 +1,19 @@
+#print
+Does the neqn input
+  .EQ
+  ~a
+  over
+  b~
+  .EN
+produce the same output as the input
+  .EQ
+  a~ over ~b
+  .EN
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+4.1d 10
diff --git a/usr/lib/learn/eqn/L5.1a b/usr/lib/learn/eqn/L5.1a
new file mode 100644 (file)
index 0000000..1434e1e
--- /dev/null
@@ -0,0 +1,45 @@
+#once #create message
+.ND
+.EQ
+delim $$
+.EN
+.LP
+So far we have carefuly skirted around a potential
+problem; maybe you've wondered about it.
+Suppose we want to produce an equation that looks
+like this:
+.EQ
+x sup { pi + 1 }
+.EN
+The superscript is complicated, in that it contains
+both a $pi$ and a +1, which has to be separated
+from the $pi$ by a blank.
+But I already told you that a blank terminates
+the superscript.  What's going on?
+
+As the first step to finding out, will the input
+equation
+
+  x sup pi + 1
+
+produce the output
+
+  $x sup {pi + 1}$ ?
+Answer yes or no.
+(You can play with the file "Example" if you like.)
+.pl 1
+#once #create Example
+.LP
+.EQ
+replace me
+.EN
+.pl 1
+#
+#once neqn message | nroff -T$term %s/tinyms -
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+5.1b
diff --git a/usr/lib/learn/eqn/L5.1b b/usr/lib/learn/eqn/L5.1b
new file mode 100644 (file)
index 0000000..64e952f
--- /dev/null
@@ -0,0 +1,47 @@
+#once #create message
+.ND
+.EQ
+delim $$
+.EN
+.LP
+The problem is really that we need a way to tell neqn
+that in spite of blanks, a group of things (like the $pi$
+and the +1) have to be kept together as a single superscript.
+The way that this is done is to enclose the group in
+braces - the characters { and } - like this:
+
+  .EQ
+  x sup {pi + 1}
+  .EN
+
+This tells neqn that everything inside the braces belongs
+to the superscript, in spite of blanks and tildes.
+(You don't need blanks before and after braces themselves -
+like tildes, they act as delimiters.)
+
+Modify the file "Example" so that the output looks like
+the following, then type "ready".
+(To get $==$, type "==".)
+.pl 1
+#once #create Ref
+.LP
+.EQ
+x sup {pi +1} == y sup z sup {alpha + beta}
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+replace me
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+5.1c 10
+5.2b 5
diff --git a/usr/lib/learn/eqn/L5.1c b/usr/lib/learn/eqn/L5.1c
new file mode 100644 (file)
index 0000000..2b77825
--- /dev/null
@@ -0,0 +1,40 @@
+#once #create message
+.ND
+.EQ
+delim $$
+.EN
+.LP
+Braces are an exceedingly useful construction.
+Wherever you have a place where you could have used
+a single thing like the letter "x", you can plug in
+anything in braces, and the whole thing will
+be positioned properly.  You can use braces with sub and sup
+and over, and all the other magic words we
+haven't seen yet.
+
+First let's use braces with "over".
+Modify "Example" to produce this output, then
+type "ready".
+(Recall that $partial$ is called "partial".)
+.pl 1
+#once #create Ref
+.LP
+.EQ
+{partial y} over {partial x} ~=~ alpha over {alpha +1}
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+replace me
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+5.1d 10
diff --git a/usr/lib/learn/eqn/L5.1d b/usr/lib/learn/eqn/L5.1d
new file mode 100644 (file)
index 0000000..7b22c33
--- /dev/null
@@ -0,0 +1,57 @@
+#once #create message
+.ND
+.EQ
+delim $$
+.EN
+.LP
+You will get lots of practice
+using braces as we go along.
+One thing to keep in mind is that
+braces can appear ______\b\b\b\b\b\bwithin braces.
+(Remember that I said that anywhere you
+could use an "x" you could put something in
+braces instead.  So to get this:
+.EQ
+e sup {x sup {pi +1} + y sup {pi +1}}
+.EN
+you can type
+
+  e sup {x sup {pi +1} + y sup {pi +1}}
+
+The big superscript (the one on the "e") has
+a pair of braces that take in everything.
+Then the "x" and the "y" each have braces
+to delimit their superscripts.
+Of course the braces have to go in the right
+places, or you won't get the output you
+want.
+
+To verify that you are still following this
+lesson, modify "Example" so it looks like
+this, then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+e sup { - {x sup {pi +1} + y sup {pi +1}} over 2}
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+e sup {x sup {pi +1} + y sup {pi +1}}
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#fail
+Don't forget that you need braces for the overall superscript,
+and also for the "over" part.
+#log
+#next
+5.1e 10
+5.2d 5
diff --git a/usr/lib/learn/eqn/L5.1e b/usr/lib/learn/eqn/L5.1e
new file mode 100644 (file)
index 0000000..79a845a
--- /dev/null
@@ -0,0 +1,40 @@
+#print
+Once you start using braces, there are a number of
+mistakes that you can make.  For example, you can
+leave a brace out, or you can get them out of order
+(Like } xxx { ), or you can get them in illegal places.
+For all of these, neqn tells you "syntax error",
+then tries to say what file and line numbers are
+involved.
+The line numbers are often not exact, but
+they are very close.  When you get such a message,
+print a line or two before and after the line
+numbers named in the syntax error message.
+
+The file "Example" contains a syntax error.
+What line does neqn believe it begins on?
+Type "answer N", where N is the line number.
+#once #create Example
+.LP
+.EQ 3
+e sup -x sup 2 + e sup -x sub i sup 2 + e sup{-x sub i}sup 2
+.EN
+.EQ 4
+   e sup{-{x sub i sup 2 + y sub i sup 2}over 2}
+= e sup{- x over y}
+.EN
+.EQ 5
+a over b = c over d = A over B times C over D
+.EN
+.EQ 8
+B sub a sub 2 +
+B sub a sup 2 +B{ sub a}sup 2 + (B sub a ) sup 2 + (B sup 2 ) sub a
++B sup 2 sup x
+.EN
+#copyin
+#user
+#uncopyin
+#match 13
+#log
+#next
+5.1f 10
diff --git a/usr/lib/learn/eqn/L5.1f b/usr/lib/learn/eqn/L5.1f
new file mode 100644 (file)
index 0000000..14b48bd
--- /dev/null
@@ -0,0 +1,11 @@
+#print
+Is the construction
+  a {sup pi +1}
+legal in neqn? Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+5.1g 10
diff --git a/usr/lib/learn/eqn/L5.1g b/usr/lib/learn/eqn/L5.1g
new file mode 100644 (file)
index 0000000..046420c
--- /dev/null
@@ -0,0 +1,17 @@
+#print
+It is often possible to leave out braces,
+but when you do be sure that you get the
+answer you really wanted.
+For example, does
+  x sup a over b
+produce the same output as
+  x sup {a over b}
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+5.1h 10
+5.2g 5
diff --git a/usr/lib/learn/eqn/L5.1h b/usr/lib/learn/eqn/L5.1h
new file mode 100644 (file)
index 0000000..af14087
--- /dev/null
@@ -0,0 +1,48 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.LP
+One thing that you will occasionally need
+is to be able to get a literal { or } in your
+output, for an expression like
+.EQ
+{ "{" a + b "}" } over 2
+.EN
+The way to do this is to place the braces
+that are really to appear ______\b\b\b\b\b\binside ______\b\b\b\b\b\bquotes,
+like this:
+   .EQ
+   { "{" a + b "}" } over 2
+   .EN
+.br
+The quotes temporarily turn off the special meaning
+of the braces so that you can have them printed.
+
+The file "Example" has a lot of square brackets in
+it.  Modify them so they are all braces when they are
+printed - so they look like this - then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+f"{" x sub 1 ,..., x sub n "}" ~=~ "{" x sub 1 ,..., x sub n "}"
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+f[ x sub 1 ,..., x sub n ] ~=~ [ x sub 1 ,..., x sub n ]
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+6.1a 10
diff --git a/usr/lib/learn/eqn/L5.2b b/usr/lib/learn/eqn/L5.2b
new file mode 100644 (file)
index 0000000..924e401
--- /dev/null
@@ -0,0 +1,32 @@
+#once #create message
+.ND
+.EQ
+delim $$
+.EN
+.LP
+Try another example with braces, for practice.
+Make the file "Example" produce output that looks
+like this line, then type "ready".
+(The character $rho$ is "rho".)
+.pl 1
+#once #create Ref
+.LP
+.EQ
+alpha sub i sup {pi + rho + 1} ~=~ 1
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+replace me
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+5.1c 10
diff --git a/usr/lib/learn/eqn/L5.2d b/usr/lib/learn/eqn/L5.2d
new file mode 100644 (file)
index 0000000..a6ab2e1
--- /dev/null
@@ -0,0 +1,31 @@
+#once #create message
+.ND
+.EQ
+delim $$
+.EN
+.LP
+Modify "Example" so it produces this output, then
+type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+{partial e sup {-{x sup 2 + y sup 2} over 2}} over
+{partial x} ~=~ f(x)
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+xxxx
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+5.1e 10
diff --git a/usr/lib/learn/eqn/L5.2g b/usr/lib/learn/eqn/L5.2g
new file mode 100644 (file)
index 0000000..c3238cc
--- /dev/null
@@ -0,0 +1,13 @@
+#print
+Does
+  x sup a over b
+produce the same output as
+  {x sup a} over b
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+5.1h 10
diff --git a/usr/lib/learn/eqn/L6.1a b/usr/lib/learn/eqn/L6.1a
new file mode 100644 (file)
index 0000000..fc51f1f
--- /dev/null
@@ -0,0 +1,60 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.LP
+So far every equation you have typed in
+has been "displayed" - neatly centered or indented, and
+offset from the surrounding text.
+But not all equations are like that.
+Very often they appear right in the middle of
+running text as subscripts like $x sub i$ or special characters
+like $pi$ or $partial$.  How are these done?
+
+The idea is this.  Two characters (which may be identical)
+are set aside as "delimiters".  When the
+left delimiter is seen anywhere in ___\b\b\bany line,
+it marks the beginning of an in-line equation.
+The end is marked by the right delimiter.  Between the
+delimiters, all the normal rules of neqn apply.
+
+Suppose we say the delimiters are % signs.
+Then to get $pi$, you have to type %pi%. 
+
+To make sure that you can do this much, find the
+$pi$, $alpha$ and $sum$ characters in "Example"
+and make them into in-line equations.
+Use % and % as the delimiter characters.
+(This is the most frequent choice, by the way.)
+Type "ready" when you're done.
+.pl 1
+#once #create Ref
+.EQ
+delim $$
+.EN
+.LP
+This line contains some $pi$ and $alpha$ Greek
+and $sum$ as well.  Don't forget that spaces
+inside dollar signs are ignored, while spaces
+outside them are significant.
+.pl 1
+#once #create Example
+.EQ
+delim $$
+.EN
+.LP
+This line contains some pi and alpha Greek
+and sum as well.  Don't forget that spaces
+inside dollar signs are ignored, while spaces
+outside them are significant.
+.pl 1
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+6.1b
diff --git a/usr/lib/learn/eqn/L6.1b b/usr/lib/learn/eqn/L6.1b
new file mode 100644 (file)
index 0000000..743e5ff
--- /dev/null
@@ -0,0 +1,37 @@
+#print
+There is one other thing you have to do before
+you can use a character as a delimiter - you
+have to tell neqn that you are going to.
+To do this, as the very first thing in your
+input you must put these three lines:
+
+.EQ
+delim $$
+.EN
+
+(If you like, other characters than $ can be used,
+but we will stick to dollar signs here.)
+Until you do this, $ signs have no special
+significance to neqn.
+
+Modify the file "Example" by adding the "delim"
+lines to the beginning, and check that $ signs are
+now significant.  Type "ready" when you are done.
+#once #create Ref
+.EQ
+delim $$
+.EN
+.LP
+Now is the $times$ for all good $mu$ $epsilon$ $nu$
+to come to the aid of their party.
+.pl 1
+#once #create Example
+.LP
+Now is the $times$ for all good $mu$ $epsilon$ $nu$
+to come to the aid of their party.
+.pl 1
+#user
+#cmp Ref example
+#log
+#next
+6.1c 10
diff --git a/usr/lib/learn/eqn/L6.1c b/usr/lib/learn/eqn/L6.1c
new file mode 100644 (file)
index 0000000..bebfcb4
--- /dev/null
@@ -0,0 +1,27 @@
+#print
+One thing to keep in mind is that outside of
+$ signs, spaces are significant just as they
+were before.  Inside $ signs, spaces are significant
+only as delimiters, and will not add any space
+to the output.
+Furthermore, inside delimiters, new lines also
+don't matter, just as they didn't matter between
+the .EQ and .EN.
+
+Do the lines
+
+Let $alpha$ be the size of the vector $pi$.
+
+and
+
+Let $ alpha $ be the size of the vector $ pi $.
+
+produce the same output?
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+6.1d 10
diff --git a/usr/lib/learn/eqn/L6.1d b/usr/lib/learn/eqn/L6.1d
new file mode 100644 (file)
index 0000000..2552ccd
--- /dev/null
@@ -0,0 +1,18 @@
+#print
+Do the inputs
+
+Let $x sub i$ and $y sub i$ be $>= z sub i$.
+
+and
+
+Let $x sub i$ and $y sub i$ be $>=$ $z sub i$.
+
+produce the same output?
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+7.1a
diff --git a/usr/lib/learn/eqn/L7.1a b/usr/lib/learn/eqn/L7.1a
new file mode 100644 (file)
index 0000000..f41f56b
--- /dev/null
@@ -0,0 +1,48 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.LP
+The next construction we're going to look at
+is one for putting things above and below other
+things, in a rather specialized way.
+For example, if you want something like
+.EQ
+sum from i to j
+.EN
+you type
+  .EQ
+  sum from i to j
+  .EN
+The words "from" and "to" are more magic, like
+sub or sup or over.  The "from" part is centered
+under the main piece; the "to" part is centered
+above it.
+As a warmup, modify "Example" so it produces
+output that looks like the following, then type
+ready.
+.pl 1
+#once #create Ref
+.EQ
+delim $$
+.EN
+.LP
+Let $Q( pi )$ be $sum from {i= pi sub 1} to {i= pi sub 2} x sub i$.
+.pl 1
+#once #create Example
+.EQ
+delim $$
+.EN
+.LP
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+7.1b 10
diff --git a/usr/lib/learn/eqn/L7.1b b/usr/lib/learn/eqn/L7.1b
new file mode 100644 (file)
index 0000000..d9ece99
--- /dev/null
@@ -0,0 +1,50 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.LP
+As you might expect from our previous discussions,
+any part of a
+
+  thing from thing to thing
+
+construction can be as complicated as you wish.
+The only limitation is that the individual "thing"'s
+may well need braces around them to make it
+clear to neqn which part goes with which.
+
+For example, suppose you want
+.EQ
+sum from {pi = 0} to {pi = n}
+.EN
+Then you have to ensure that the $pi =0$ and
+$pi =n$ parts are included in braces or
+they will not work right.
+
+Modify file "Example" so the output looks like
+the example above, then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+sum from {pi = 0} to {pi =n}
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+sum from pi = 0 to pi = n
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+7.1c 10
+7.2b 5
diff --git a/usr/lib/learn/eqn/L7.1c b/usr/lib/learn/eqn/L7.1c
new file mode 100644 (file)
index 0000000..0d20a68
--- /dev/null
@@ -0,0 +1,35 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.LP
+It is also quite permissible to leave out
+either the "from" part or the "to" part
+of a from-to construction.  For example,
+modify "Example" so its output looks like this,
+then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+lim from {x-> pi /2} ( tan~x) sup {sin~2x}~=~1
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+lim from xxx ( tan~x) sup {sin~2x}~=~1
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+7.1d 10
+7.2c 5
diff --git a/usr/lib/learn/eqn/L7.1d b/usr/lib/learn/eqn/L7.1d
new file mode 100644 (file)
index 0000000..72eb0c4
--- /dev/null
@@ -0,0 +1,37 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.LP
+Let's do one more example of from-to for practice
+before we go on to the next topic.
+Modify "Example" so it produces output that looks
+like this, then type "ready".
+.pl 1
+#once #create Ref
+.EQ
+delim $$
+.EN
+.LP
+Let $Q( pi )$ be $sum from {i= pi sub 1} to {i= pi sub 2} x sub i$.
+.pl 1
+#once #create Example
+.EQ
+delim $$
+.EN
+.LP
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#fail
+Don't forget to set delimiters before the .LP line,
+and get the spaces right around the dollar signs.
+#log
+#next
+8.1a 10
diff --git a/usr/lib/learn/eqn/L7.2b b/usr/lib/learn/eqn/L7.2b
new file mode 100644 (file)
index 0000000..281237b
--- /dev/null
@@ -0,0 +1,17 @@
+#print
+Does the input
+
+  sum from {i = -n} to {i = +n}
+
+produce the same output as the input
+
+  sum from i=-n to i=+n
+
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+7.1c
diff --git a/usr/lib/learn/eqn/L7.2c b/usr/lib/learn/eqn/L7.2c
new file mode 100644 (file)
index 0000000..5bb518f
--- /dev/null
@@ -0,0 +1,30 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.LP
+Modify file "Example" so it looks like this,
+then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+sum to N+n-m x sub mn > 0
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+xxx
+.EN
+.pl 1
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+7.1d 10
diff --git a/usr/lib/learn/eqn/L8.1a b/usr/lib/learn/eqn/L8.1a
new file mode 100644 (file)
index 0000000..06caba4
--- /dev/null
@@ -0,0 +1,49 @@
+#once #create message
+.ND
+.LP
+The next neqn operation is called "sqrt" - it makes
+square root signs over things, like this:
+.EQ
+sqrt a+b
+.EN
+(They don't look very good on a terminal, unfortunately.)
+This one is very easy - to print the line above, you
+say
+   .EQ
+   sqrt a+b
+   .EN
+The "sqrt" operates on the first thing it finds
+so if you want something more complicated, like
+.EQ
+sqrt {pi +1}
+.EN
+you have to use braces to enclose the entire
+thing.  This one was printed with
+   .EQ
+   sqrt {pi +1}
+   .EN
+And that's all there is to sqrt.
+
+Modify "Example" so it looks like this, then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+f(x) ~=~ sqrt {ax sup 2 +bx+c}
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+f(x)....
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+8.1b 10
diff --git a/usr/lib/learn/eqn/L8.1b b/usr/lib/learn/eqn/L8.1b
new file mode 100644 (file)
index 0000000..d6bf449
--- /dev/null
@@ -0,0 +1,34 @@
+#once #create message
+.ND
+.LP
+Since "sqrt thing" is really a single object, you
+often don't need braces around it, although there
+may well be braces around "thing" itself.
+For example, you can say
+  .EQ
+  1 over sqrt {ax sup2 +bx+c}
+  .EN
+to produce
+.EQ
+1 over sqrt {ax sup 2 +bx+c}
+.EN
+Does the input
+   .EQ
+   e sup sqrt {pi x}
+   .EN
+produce the same output as
+   .EQ
+   e sup {sqrt {pi x}}
+   .EN
+Answer yes or no.
+.pl 1
+#
+#once neqn message | nroff -T$term %s/tinyms -
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+9.1a 10
+8.2b 5
diff --git a/usr/lib/learn/eqn/L8.2b b/usr/lib/learn/eqn/L8.2b
new file mode 100644 (file)
index 0000000..c4c7478
--- /dev/null
@@ -0,0 +1,17 @@
+#print
+Does the input
+   .EQ
+   e sup sqrt {pi x}
+   .EN
+produce the same output as
+   .EQ
+   e sup sqrt pi x
+   .EN
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+9.1a 10
diff --git a/usr/lib/learn/eqn/L9.1a b/usr/lib/learn/eqn/L9.1a
new file mode 100644 (file)
index 0000000..4a07a8f
--- /dev/null
@@ -0,0 +1,66 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.LP
+The next step is to learn about "diacriticals", which
+is a big word for funny marks on symbols, like
+a bar over something ($x bar$), or a tilde or hat on
+something ($x tilde ,~a hat$), or perhaps a dot 
+or dotdot ($T dot ,~U dotdot$), or even an
+underlining like $abc under$.
+
+These are all easy.  Each funny character
+has a name, and all you have to do is put the name
+after the thing you want the character on.
+Thus
+  x hat makes $x hat$
+  y bar makes $y bar$
+  T dot makes $T dot$
+  x tilde makes $x tilde$ (notice that we spell tilde)
+  u dotdot makes $u dotdot$ (looks ugly on a terminal)
+.br
+and
+  i under makes $i under$.
+
+Except for "bar" and "under", these are almost always
+attached to just a single letter.
+If you want to put a bar over something longer, like
+${2 pi +1} bar$, simply enclose the thing in braces:
+
+  {2 pi +1} bar
+
+Modify "Example" to produce output that looks like this,
+then type "ready".
+.pl 1
+#once #create Ref
+.EQ
+delim $$
+.EN
+.LP
+Let $x bar$, $y bar$, and $z bar$ be the components of $pi bar$.
+Let ${alpha +1} bar$ be the mean value of $alpha hat$.
+.pl 1
+#once #create Example
+.EQ
+delim $$
+.EN
+.LP
+Let x bar, y bar, and z bar be the components of pi bar.
+Let alpha +1 bar be the mean value of alpha hat.
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#fail
+Don't forget to set delimiters at the beginning,
+and get the spaces right around the dollar signs.
+#log
+#next
+9.1b 10
+9.2a 5
diff --git a/usr/lib/learn/eqn/L9.1b b/usr/lib/learn/eqn/L9.1b
new file mode 100644 (file)
index 0000000..32ef65c
--- /dev/null
@@ -0,0 +1,48 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.LP
+You sometimes have to make explicit what you
+mean when you say "bar", by putting in braces
+to enclose the parts that you want the bar
+to be over. 
+For example, what has to be done to make
+the output
+.EQ
+{x sub i} bar
+.EN
+Find out (by putting braces in the right place
+if necessary) in the file "Example", then
+type "ready" after you have successfully modified it.
+.pl 1
+#once #create Ref
+.EQ
+delim $$
+.EN
+.LP
+.EQ
+{x sub i} bar
+.EN
+.pl 1
+#once #create Example
+.EQ
+delim $$
+.EN
+.LP
+.EQ
+x sub i bar
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+10.1a 10
+9.2b 5
diff --git a/usr/lib/learn/eqn/L9.2a b/usr/lib/learn/eqn/L9.2a
new file mode 100644 (file)
index 0000000..8d1e6cd
--- /dev/null
@@ -0,0 +1,31 @@
+#once #create message
+.ND
+.tr %$
+.EQ
+delim $$
+.EN
+.LP
+Modify "Example" to produce output that looks like this,
+then type "ready".
+.pl 1
+#once #create Ref
+.LP
+.EQ
+x bar ~=~ E(x) bar ~/~ E( x bar )
+.EN
+.pl 1
+#once #create Example
+.LP
+.EQ
+xxxx
+.EN
+.pl 1
+#
+#once neqn Ref | nroff >X1 &
+#once neqn message Ref | nroff -T$term %s/tinyms -
+#user
+neqn Example | nroff >X2
+#cmp X1 X2
+#log
+#next
+9.1b 10
diff --git a/usr/lib/learn/eqn/L9.2b b/usr/lib/learn/eqn/L9.2b
new file mode 100644 (file)
index 0000000..521f27d
--- /dev/null
@@ -0,0 +1,20 @@
+#print
+Which equation prints a longer bar?
+
+   xyz sub i bar
+
+or
+
+   x yz sub i bar
+
+Type "answer N", where N is 1 if it's
+the first one, 2 if it's the second, and
+0 if they are the same length.
+#copyin
+#user
+#uncopyin
+#match 0
+#log
+#next
+10.1a 10
+9.3b 5
diff --git a/usr/lib/learn/eqn/L9.3b b/usr/lib/learn/eqn/L9.3b
new file mode 100644 (file)
index 0000000..a7a3029
--- /dev/null
@@ -0,0 +1,13 @@
+#print
+Does
+  ax bar
+produce the same output as
+  a x bar
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+10.1a 10
diff --git a/usr/lib/learn/eqn/tinyms b/usr/lib/learn/eqn/tinyms
new file mode 100644 (file)
index 0000000..676465f
--- /dev/null
@@ -0,0 +1,24 @@
+.\" short set of macros to simulate behavior of
+.\" most common -ms macros:
+.\"   .PP, .LP, .EQ, .EN
+.\"
+.de PP
+.br
+.sp
+.ll 60n
+.fi
+.ti +5n
+..
+.de LP
+.br
+.sp
+.ll 60n
+.fi
+..
+.de EQ
+.sp
+.ce
+..
+.de EN
+.sp
+..
diff --git a/usr/lib/learn/files/L0 b/usr/lib/learn/files/L0
new file mode 100644 (file)
index 0000000..bab7601
--- /dev/null
@@ -0,0 +1,2 @@
+#next
+0.1a 10
diff --git a/usr/lib/learn/files/L0.1a b/usr/lib/learn/files/L0.1a
new file mode 100644 (file)
index 0000000..f13b557
--- /dev/null
@@ -0,0 +1,36 @@
+#print
+This course will help you learn about basic file
+handling commands.  You should first understand
+the special characters # and @: 
+  # cancels the previous character typed;
+  @ cancels the line being typed.
+If you make a typing mistake, you can use these characters to
+correct it before you finish the line and the computer won't
+ever know about it.  For example, what will the
+computer really receive if you type
+
+st#he@
+thf#e
+
+at it?  Reply "answer WORD" where WORD is the word
+as it will be interpreted.  For example, if
+you think it will get 'dog', type
+
+answer dog
+
+If you think it will receive the word "bark", type
+
+answer bark
+
+Don't forget to leave a space between "answer" and the word
+and to hit RETURN at the end of the line.
+Don't use any quotation marks in your answer.
+#copyin
+#user
+#uncopyin
+#match the
+#bad answerthe
+Leave a space between "answer" and "the".
+#log
+#next
+0.1b 5
diff --git a/usr/lib/learn/files/L0.1b b/usr/lib/learn/files/L0.1b
new file mode 100644 (file)
index 0000000..14c0b30
--- /dev/null
@@ -0,0 +1,28 @@
+#print
+You should also understand a few simple commands.
+When UNIX types a "$" at you, you can type a command.
+For example, if you type "date" the computer will tell
+you the current date and time. If you see "$" and type "who",
+UNIX will tell you who is logged on at present.  There are
+many other commands, too.  You must type a RETURN at the
+end of each command line.
+
+Try the "date" command now: find out what
+date it is, and after the computer has responded, type "ready".
+And don't forget the RETURN!
+#copyin
+#user
+#uncopyin
+grep date .copy >/dev/null
+#bad day
+You were supposed to type "date" (without quotes).
+The computer is very intolerant of spelling errors.
+Try again.
+#bad "date"
+Don't type those quote marks. Try again.
+#bad time
+The time command does not tell you the wall-clock time.
+Try date next time.
+#log
+#next
+0.1c 5
diff --git a/usr/lib/learn/files/L0.1c b/usr/lib/learn/files/L0.1c
new file mode 100644 (file)
index 0000000..938f51e
--- /dev/null
@@ -0,0 +1,27 @@
+#print
+The computer keeps track of information in "files."
+A file might contain a letter to a friend,
+or a memo (or part of it) that you are typing,
+or any number of other things.
+You can list the names of your files
+by typing the command "ls".
+Try "ls" now; then type "ready".
+Remember that each command must go on a separate line
+and each line must be ended with RETURN.
+#create letter
+Dear John:
+I'm terribly sorry...
+#create memo
+This is a memo.
+#create memo1
+Another memo.
+#copyin
+#user
+#uncopyin
+grep '^ls' .copy >/dev/null
+#bad "ls"
+Don't type the quotes, please. Try again.
+#log
+#next
+0.1d 10
diff --git a/usr/lib/learn/files/L0.1d b/usr/lib/learn/files/L0.1d
new file mode 100644 (file)
index 0000000..a9e48d3
--- /dev/null
@@ -0,0 +1,30 @@
+#print
+File names are essentially arbitrary,
+although usually one names files sensibly:
+the files that make up a memo
+might be called "memo1", "memo2", etc.
+
+The contents of a file are also entirely up to you:
+for example, a file named "memo" could contain
+
+   Analysis of Irregular Statistics
+        John B. Pencilpusher
+
+  Bell Laboratories, Murray Hill, NJ
+    ....
+
+To get at the information in a file,
+you have to use the file name,
+which in this case is "memo". 
+
+Is there a difference between the name of a file
+and the contents of a file?
+Type "yes" or "no".
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+1.1a    10
+1.2a    5
diff --git a/usr/lib/learn/files/L1.1a b/usr/lib/learn/files/L1.1a
new file mode 100644 (file)
index 0000000..26a5d9a
--- /dev/null
@@ -0,0 +1,12 @@
+#print
+The "ls" command will list the names of the files
+in your directory.  Is there a file named "junk"
+present?  Find out and then type "yes" or "no".
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+2.1a 10
+2.2a 5
diff --git a/usr/lib/learn/files/L1.2a b/usr/lib/learn/files/L1.2a
new file mode 100644 (file)
index 0000000..93d258f
--- /dev/null
@@ -0,0 +1,15 @@
+#print
+Use the "ls" command to determine if there is a file
+named for a state in the current directory.
+Find out and type "yes" or "no".
+(Don't use the list you got earlier - I've changed things.)
+#create texas
+dallas, houston, etc.
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+2.1a  10
+2.2a  5
diff --git a/usr/lib/learn/files/L1.2b b/usr/lib/learn/files/L1.2b
new file mode 100644 (file)
index 0000000..f801740
--- /dev/null
@@ -0,0 +1,25 @@
+#print
+You can use the "ls" command to find out how
+many files you have in your directory.
+How many files are there in the current
+directory now?  Make another list - the list of files
+that you made before is no longer right because I added
+some files to the directory.  When you find out
+how many files there are in this directory, type
+"answer N" where N is the number of files.
+#create a1
+file a1
+#create a2
+file a2
+#create X1
+file a1
+#copyin
+#user
+#uncopyin
+ls | %s/../lcount >X1
+tail -1 .copy >X2
+#cmp X1 X2
+#log
+#next
+2.1a 10
+2.2a 5
diff --git a/usr/lib/learn/files/L10.1a b/usr/lib/learn/files/L10.1a
new file mode 100644 (file)
index 0000000..a7eeec7
--- /dev/null
@@ -0,0 +1,21 @@
+#print
+When you are done with something, you will want to know
+how to get rid of the file it is on.  The command
+for that is "rm" (remove).  For example
+  rm junk
+throws away the file named "junk".  Once it
+is gone, it is really gone - there is no way
+to "undo" a remove command.  Hence this command
+should be used with caution.
+In this directory there is one file named
+for a baseball player.  Remove it.
+Then type "ready".
+#create kernighan
+#create yastrzemski
+#user
+test ! -r yastrzemski && test -r kernighan
+#log
+#next
+11.1a 10
+11.2a 5
+11.3a 2
diff --git a/usr/lib/learn/files/L10.2a b/usr/lib/learn/files/L10.2a
new file mode 100644 (file)
index 0000000..e76c627
--- /dev/null
@@ -0,0 +1,15 @@
+#print
+The way to get rid of a file you are finished with
+is with the "rm" (remove) command.  For example,
+  rm junk
+will get rid of the file named "junk".
+In this directory there is a file named "harry" -
+remove it.
+Then type "ready".
+#create harry
+#user
+test ! -r harry
+#log
+#next
+10.2b 5
+10.3a 2
diff --git a/usr/lib/learn/files/L10.2b b/usr/lib/learn/files/L10.2b
new file mode 100644 (file)
index 0000000..08af6c0
--- /dev/null
@@ -0,0 +1,18 @@
+#print
+You can remove several files at once with the "rm" command.
+And you can use the familiar "*" and "?" characters
+to abbreviate several file names.  BUT BE CAREFUL -
+"rm" is irreversible, and it is all too easy to type something
+like "rm *" and get rid of all your files.
+In this directory are two files named 
+"part1" and "part2".
+Remove both; then type "ready".
+#create part1
+#create part2
+#user
+test ! -r part1 && test ! -r part2
+#log
+#next
+11.1a 10
+11.2a 5
+11.3a 2
diff --git a/usr/lib/learn/files/L10.3a b/usr/lib/learn/files/L10.3a
new file mode 100644 (file)
index 0000000..b443cad
--- /dev/null
@@ -0,0 +1,15 @@
+#print
+When you are done with something, you will want to
+get rid of the file containing it.  The command for that
+is "rm" (remove).  For example
+  rm junk
+throws away the file named "junk".  Try that -
+there's a file named "junk" in this directory, as you can
+verify by doing an "ls".  Try another "ls" after the "rm junk";
+then type "ready".
+#create junk
+#user
+test ! -r junk
+#log
+#next
+10.3b 2
diff --git a/usr/lib/learn/files/L10.3b b/usr/lib/learn/files/L10.3b
new file mode 100644 (file)
index 0000000..516b558
--- /dev/null
@@ -0,0 +1,12 @@
+#print
+Often you will use "ls" with "rm"
+to first find the name of a file, and then remove it.
+This directory contains one file whose name begins with "g".
+Find out what it is and remove it.
+Then type "ready".
+#create george
+#user
+test ! -r george
+#log
+#next
+10.3c 2
diff --git a/usr/lib/learn/files/L10.3c b/usr/lib/learn/files/L10.3c
new file mode 100644 (file)
index 0000000..6d5c108
--- /dev/null
@@ -0,0 +1,15 @@
+#print
+You can remove several files at once with the
+"rm" command; for example,
+  rm tom dick harry
+will remove the files "tom", "dick", and "harry".
+There are two files in this directory named
+for birds: get rid of both.
+Then type "ready".
+#create eagle
+#create bluejay
+#user
+test ! -r eagle && test ! -r bluejay
+#log
+#next
+10.3d 2
diff --git a/usr/lib/learn/files/L10.3d b/usr/lib/learn/files/L10.3d
new file mode 100644 (file)
index 0000000..4b68bea
--- /dev/null
@@ -0,0 +1,23 @@
+#print
+You can also use "*" and "?" with
+the "rm" command.  BUT BE VERY CAREFUL
+since, for example, "rm *" will throw away
+ALL the files in a directory.
+In this directory are some files named
+chunk1, chunk2, chunk3 and chunk4.
+Get rid of them.  Then type "ready".
+#create X1
+#
+ls >X2
+#create chunk1
+#create chunk2
+#create chunk3
+#create chunk4
+#user
+ls >X1
+#cmp X1 X2
+#log
+#next
+11.1a 10
+11.2a 5
+11.3a 2
diff --git a/usr/lib/learn/files/L11.1a b/usr/lib/learn/files/L11.1a
new file mode 100644 (file)
index 0000000..47e4e53
--- /dev/null
@@ -0,0 +1,42 @@
+#print
+To create a second copy of a file, the easiest
+way is to use the "cp" (copy) command.
+If you tell the computer
+  cp x y
+a copy of file "x" is made and named "y".
+Note that this is similar to "mv" in that a new
+file named "y" appears, but the difference is
+that the old file is not removed.
+(If there was already a file named "y", though, the
+old contents are lost; be careful.)
+
+In this directory there is a file which has
+a five letter name whose first four letters
+are "part".
+Print it out; it will tell you to copy
+it and what to call the copy.
+Do that and then type "ready".
+#create X1
+#create george
+#create part00
+this is not the right file and you shouldn't
+have printed it.  Use
+ part?
+not
+ part*
+in this example.
+#create part3
+This is the file "part3".  I hope you
+used a command like
+  ls part?
+or
+  cat part?
+to find it.
+Make a copy of this file on file "george".
+#user
+#cmp george part3
+#log
+#next
+12.1a 10
+12.2a 5
+12.3a 2
diff --git a/usr/lib/learn/files/L11.2a b/usr/lib/learn/files/L11.2a
new file mode 100644 (file)
index 0000000..7c397e7
--- /dev/null
@@ -0,0 +1,16 @@
+#print
+To make a new copy of a file, the easiest
+way is to use the "cp" command.
+If you type 
+  cp x y
+a copy of file "x" is made and named "y".
+This directory contains a file named "george";
+make a copy named  "steve".
+Then type "ready".
+#create george
+this is file george
+#user
+#cmp steve george
+#log
+#next
+11.2b 5
diff --git a/usr/lib/learn/files/L11.2b b/usr/lib/learn/files/L11.2b
new file mode 100644 (file)
index 0000000..f4154e9
--- /dev/null
@@ -0,0 +1,26 @@
+#print
+Contrast 
+ cp old new
+with 
+ mv old new
+as commands; both cause "new" to appear,
+but "cp" does not remove "old".
+Both, by the way, destroy anything
+that happened to be around named "new".
+There is a file in this directory
+whose name ends in "x".  Use "ls"
+with the "*x" construction to find its name;
+then copy it to file "new", and type "ready".
+#create new
+old new
+#create pix
+new new
+#create xip
+nothing
+#user
+#cmp pix new
+#log
+#next
+12.1a 10
+12.2a 5
+12.3a 2
diff --git a/usr/lib/learn/files/L11.3a b/usr/lib/learn/files/L11.3a
new file mode 100644 (file)
index 0000000..e019f83
--- /dev/null
@@ -0,0 +1,17 @@
+#print
+To make a copy of a file, you can use the
+"cp" (copy) command.  For example
+ cp old new
+will make a copy of file "old", named "new".
+This directory contains a file named "old";
+try the "cp" command to make a file named "new".
+Print the file to check on the copy.
+When done, type "ready".
+#create old
+The Brooklyn Museum is at 188 Eastern Parkway,
+Brooklyn, NY 11238.
+#user
+#cmp old new
+#log
+#next
+11.3b 2
diff --git a/usr/lib/learn/files/L11.3b b/usr/lib/learn/files/L11.3b
new file mode 100644 (file)
index 0000000..9b3b47b
--- /dev/null
@@ -0,0 +1,13 @@
+#print
+Now there is a file named "good"
+in this directory.  Make a copy named "better",
+then type ready.
+#create good
+This file has 
+three lines
+in it.
+#user
+#cmp good better
+#log
+#next
+11.3c 2
diff --git a/usr/lib/learn/files/L11.3c b/usr/lib/learn/files/L11.3c
new file mode 100644 (file)
index 0000000..a76c551
--- /dev/null
@@ -0,0 +1,22 @@
+#print
+This is a little trickier.  The directions
+for this step are in a file whose
+name begins with "p".  Print that file;
+it will tell you what to do.  Then type "ready".
+#create delaware
+narrowsburg
+port jervis
+delaware water gap
+easton
+trenton
+philadelphia
+#create pub
+Make a copy of the file "delaware" which is
+named "hudson".
+#user
+#cmp delaware hudson
+#log
+#next
+12.1a 10
+12.2a 5
+12.3a 2
diff --git a/usr/lib/learn/files/L12.1a b/usr/lib/learn/files/L12.1a
new file mode 100644 (file)
index 0000000..5cd4f7c
--- /dev/null
@@ -0,0 +1,42 @@
+#print
+Another very useful command is the command
+ diff x y
+which compares two files.  It will not print
+any output if the two files are the same, but
+if the files are different it will print
+out the lines that are changed in the two files,
+indicating the lines from the first file (x) by a leading "<"
+and the lines from the second file (y) by a leading ">".
+There are two files in this directory named "old" and "new".
+Why don't you first print both files, and then
+try using "diff" to compare them?  Suppose the files
+were hundreds of lines long, and you needed to know
+the single difference - do you see how valuable "diff" can be?
+As evidence that you did at least half of this,
+type "answer word" where "word" is the word added to the
+second file.
+#create new
+Four score and seven
+years ago our fathers
+brought forth on this
+continent a new nation,
+conceived in liberty
+and dedicated to the 
+proposition that all
+men are created equal.
+#create old
+Four score and seven
+years ago our fathers
+brought forth on this
+continent a new nation,
+conceived in liberty
+and dedicated the 
+proposition that all
+men are created equal.
+#copyin
+#user
+#uncopyin
+#match to
+#log
+#next
+13.1a
diff --git a/usr/lib/learn/files/L12.2a b/usr/lib/learn/files/L12.2a
new file mode 100644 (file)
index 0000000..79ee4e1
--- /dev/null
@@ -0,0 +1,25 @@
+#print
+To compare two files, you can use the command
+"diff" (differences); the line
+  diff xx yy
+will compare the files xx and yy and tell you about
+any differences between them.  If the files are the same,
+the command says nothing.  Are the files
+"tom" and "dick" the same in this directory?
+Find out (print them if you feel insecure)
+and reply "yes" or "no".
+#create dick
+This stuff is not only in
+file tom but also
+in file dick
+#create tom
+This stuff is not only in
+file tom but also
+in file dick
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+12.2b 5
diff --git a/usr/lib/learn/files/L12.2b b/usr/lib/learn/files/L12.2b
new file mode 100644 (file)
index 0000000..bb462a8
--- /dev/null
@@ -0,0 +1,27 @@
+#print
+Now are the files "dick" and "harry" the same?
+Again reply "yes" or "no".
+If there are differences between files, "diff" prints
+the lines that are different, indicating those
+from the first file by "<" and those from
+the second file by ">".
+#create dick
+new york
+bridgeport
+new haven
+new london
+providence
+boston
+#create harry
+new york
+bridgeport
+new haven
+providence
+boston
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+12.2c 5
diff --git a/usr/lib/learn/files/L12.2c b/usr/lib/learn/files/L12.2c
new file mode 100644 (file)
index 0000000..e3870bd
--- /dev/null
@@ -0,0 +1,29 @@
+#print
+This directory contains two files named "old" and "new";
+What word is in one file but not the other?  Find
+out.  Reply "answer WORD" where WORD is that word.
+#create new
+Four score and seven
+years ago our fathers
+brought forth on this
+continent a new nation,
+conceived in liberty
+and dedicated to the 
+proposition that all
+men are created equal.
+#create old
+Four score and seven
+years ago our fathers
+brought forth on this
+continent a new nation,
+conceived in liberty
+and dedicated the 
+proposition that all
+men are created equal.
+#copyin
+#user
+#uncopyin
+#match to
+#log
+#next
+13.1a
diff --git a/usr/lib/learn/files/L12.3a b/usr/lib/learn/files/L12.3a
new file mode 100644 (file)
index 0000000..4ebd592
--- /dev/null
@@ -0,0 +1,21 @@
+#print
+A very useful command is the command
+  diff x y
+which compares the two files x and y and tells
+you any differences between the files.  If the files
+are the same, it says nothing.  To test that,
+copy file "george" onto file "harry";
+then say
+  diff george harry
+to verify that the files are the same.
+#create george
+london bridge
+is falling down.
+#copyin
+#user
+#uncopyin
+#match diff george harry
+#match diff harry george
+#log
+#next
+12.3b 2
diff --git a/usr/lib/learn/files/L12.3b b/usr/lib/learn/files/L12.3b
new file mode 100644 (file)
index 0000000..536b593
--- /dev/null
@@ -0,0 +1,18 @@
+#print
+Are the files "memo1" and "memo2" the same?
+If they are different, "diff" will print the
+lines that are not the same.
+Reply "yes" or "no".
+#create memo1
+A quick brown fox jumps over the lazy dog.
+We were away a year ago.
+#create memo2
+A quick brown fox jumps over the lazy dog.
+We were away a year ago.
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+12.3c 2
diff --git a/usr/lib/learn/files/L12.3c b/usr/lib/learn/files/L12.3c
new file mode 100644 (file)
index 0000000..e8afede
--- /dev/null
@@ -0,0 +1,22 @@
+#print
+Are the files "old" and "new" in this directory the same?
+Again, if they are not, "diff" will print out the differences
+marking the lines in the first file named by "<" and the
+lines in the second file by ">".  Check the results of
+diff by printing the files.  Then type "yes" or "no".
+#create new
+This file has three
+lines of text in
+it to read.
+and this has one more.
+#create old
+This file has three
+lines of text in
+it to read.
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+12.2c 5
diff --git a/usr/lib/learn/files/L13.1a b/usr/lib/learn/files/L13.1a
new file mode 100644 (file)
index 0000000..2887447
--- /dev/null
@@ -0,0 +1,16 @@
+#print
+Let's do a quick review of the things covered
+in the files course. To begin, how many files
+are there in the current directory? Type "answer N",
+where N is the number that you found.
+#create X1
+#create X2
+#copyin
+#user
+#uncopyin
+ls | %s/../lcount >X1
+tail -1 .copy >X2
+#cmp X1 X2
+#log
+#next
+13.1b 5
diff --git a/usr/lib/learn/files/L13.1b b/usr/lib/learn/files/L13.1b
new file mode 100644 (file)
index 0000000..1161cc9
--- /dev/null
@@ -0,0 +1,19 @@
+#print
+There is a file in this directory whose name begins
+with 'z'. Do what it tells you to, then type "ready".
+#create X1
+#create X2
+#create zip
+Rename the file named "mary" to "joe".
+#create joe
+I am a file
+#
+rm -f mary
+ls >X1
+mv joe mary
+#user
+ls >X2
+#cmp X1 X2
+#log
+#next
+13.1c 5
diff --git a/usr/lib/learn/files/L13.1c b/usr/lib/learn/files/L13.1c
new file mode 100644 (file)
index 0000000..8a5edf3
--- /dev/null
@@ -0,0 +1,24 @@
+#print
+There are two files in this directory whose names begin with
+the letter 'r'. On what line do they differ?
+Type "answer N", where N is the line number where they
+first are different.
+#create ref
+This is a very short file
+which contains several lines
+some one of which will be changed
+in the other version, and your
+job is to find out which.
+#create refnew
+This is a very short file
+which contains several lines
+some  one of which will be changed
+in the other version, and your
+job is to find out which.
+#copyin
+#user
+#uncopyin
+#match 3
+#log
+#next
+13.1d
diff --git a/usr/lib/learn/files/L13.1d b/usr/lib/learn/files/L13.1d
new file mode 100644 (file)
index 0000000..dd55663
--- /dev/null
@@ -0,0 +1,17 @@
+#print
+There are several files in this directory whose names
+begin with "easy". Remove them, then type "ready".
+#create X1
+#create X2
+#
+ls >X2
+#create easy1
+#create easyer
+#create easyrider
+#create easyenough
+#user
+ls >X1
+#cmp X1 X2
+#log
+#next
+13.1e
diff --git a/usr/lib/learn/files/L13.1e b/usr/lib/learn/files/L13.1e
new file mode 100644 (file)
index 0000000..03b9b4c
--- /dev/null
@@ -0,0 +1,16 @@
+#print
+This one is tougher than the last one. There are
+several files in this directory whose names
+begin with "hard". Remove them, then type "ready".
+#create X1
+#create X2
+#
+ls >X2
+cp X1 "hard\b 1"
+cp X1 "hard\b er"
+#user
+ls >X1
+#cmp X1 X2
+#log
+#next
+13.1f
diff --git a/usr/lib/learn/files/L13.1f b/usr/lib/learn/files/L13.1f
new file mode 100644 (file)
index 0000000..d164bc9
--- /dev/null
@@ -0,0 +1,23 @@
+#print
+Suppose you have two files named "dick" and "jane", and you
+want to interchange them, so that "dick" contains whatever
+was originally in "jane", and "jane" contains what was in "dick".
+Will this sequence of commands do the job?
+
+mv dick jane
+mv jane dick
+
+There are two files named "john" and "mary"
+in this directory, if you wish to experiment.
+When you have decided, type yes or no.
+#create john
+this is originally file john
+#create mary
+this is originally file mary
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+13.1g
diff --git a/usr/lib/learn/files/L13.1g b/usr/lib/learn/files/L13.1g
new file mode 100644 (file)
index 0000000..5c348bf
--- /dev/null
@@ -0,0 +1,20 @@
+#print
+Suppose that we really do want to interchange the contents
+of the files "dick" and "jane". One way to do it is
+to move the contents of "dick" into some temporary file,
+then move "jane" onto "dick" (which of course clobbers
+the old contents of "dick", but we saved them already),
+then finally to move the temporary copy of "dick" to
+"jane". There are two files named "dick" and "jane" in this
+directory. Interchange their contents, then type "ready".
+#create Ref
+short file for dick
+#create dick
+short file for dick
+#create jane
+another file for jane
+#create Ref1
+another file for jane
+#user
+cmp -s jane Ref && cmp -s dick Ref1
+#log
diff --git a/usr/lib/learn/files/L2.1a b/usr/lib/learn/files/L2.1a
new file mode 100644 (file)
index 0000000..3d6a7a3
--- /dev/null
@@ -0,0 +1,21 @@
+#print
+The "mv" command changes the names of files.
+For example, "mv bob bill" changes the name
+of file "bob" to be "bill".  If there was already
+a file named "bill", the old version is destroyed.
+
+There is a file in
+the current directory whose name begins with
+the letter "g", like "grant" or "grover".
+Find out what the file name really is, and
+then change that file to have the name "john".
+Then type "ready".
+#create george
+this should become john
+#user
+test -r john
+#log
+#next
+3.1a 10
+3.2a 5
+3.3a 2
diff --git a/usr/lib/learn/files/L2.2a b/usr/lib/learn/files/L2.2a
new file mode 100644 (file)
index 0000000..b522ee0
--- /dev/null
@@ -0,0 +1,17 @@
+#print
+The "mv" command changes the names of files.
+For example, "mv thomas james" changes the
+name of the file "thomas" to be "james".
+
+There is a file in the current directory named
+"thomas".  Change that file to have the
+name "james".  Then type "ready".
+(The "mv" command, by the way, is like many
+UNIX commands in that it is silent unless there is an error.)
+#create thomas
+xx
+#user
+test -r james
+#log
+#next
+2.2b 5
diff --git a/usr/lib/learn/files/L2.2b b/usr/lib/learn/files/L2.2b
new file mode 100644 (file)
index 0000000..e38143c
--- /dev/null
@@ -0,0 +1,24 @@
+#print
+Now your directory contains a file with a name
+that starts with "a" (like "adam", "arthur", etc.).
+Find it and change its name to "martin".
+Then type "ready".
+By the way, if there was already a file around
+named "martin", the old version is clobbered
+by the new one.
+#create andrew
+stuff
+#user
+test -r martin
+#fail
+Do you remember that the "ls" command will
+tell you the names of the files in the current
+directory? Thus you can use "ls" to tell you
+what your file names are; and then you can use
+"mv" to change the name of the file
+beginning with "a" to "martin".
+#log
+#next
+3.1a 10
+3.2a 5
+3.3a 2
diff --git a/usr/lib/learn/files/L3.1a b/usr/lib/learn/files/L3.1a
new file mode 100644 (file)
index 0000000..dfaabea
--- /dev/null
@@ -0,0 +1,34 @@
+#print
+The "cat" command prints the contents of one or more files.
+In fact, it is named "cat" as an abbreviation
+for "concatenate".  To print the files named "dog"
+and "mouse" in succession, you could type either
+  cat dog
+  cat mouse
+or just
+  cat dog mouse
+If you print them with one command,
+the contents are printed in sequence with nothing
+between them.
+
+How many lines are there in all the files
+whose names begin with "b"?  Find out, then type
+"answer N" where N is the total number of lines.
+#create ben
+the file ben has
+a total of three
+short lines.
+#create bernie
+this file has
+two lines.
+#create bruce
+only one line here.
+#copyin
+#user
+#uncopyin
+#match 6
+#log
+#next
+4.1a  10
+4.2a    5
+4.3a    2
diff --git a/usr/lib/learn/files/L3.2a b/usr/lib/learn/files/L3.2a
new file mode 100644 (file)
index 0000000..593f8cc
--- /dev/null
@@ -0,0 +1,23 @@
+#print
+The command "cat" will print files.  For example, you
+can print the file named "food" by typing "cat food".
+Your current directory has a file named "sam" and a
+file named "steve".  Which is longer?  Find out and
+type "answer sam" or "answer steve", giving the name
+of the longer file.
+#create sam
+this is the file sam.  it contains
+only two lines of text.
+#create steve
+this file is named steve.  it is a
+file which contains five lines of text.
+this is of course a very short file
+by any ordinary standards, although
+on UNIX most files are rather short.
+#copyin
+#user
+#uncopyin
+#match steve
+#log
+#next
+3.2b 5
diff --git a/usr/lib/learn/files/L3.2b b/usr/lib/learn/files/L3.2b
new file mode 100644 (file)
index 0000000..e99f3ba
--- /dev/null
@@ -0,0 +1,32 @@
+#print
+The "cat" command can also print several files
+at once.  In fact, it is named "cat" as an abbreviation
+for "concatenate".  To print the files named "dog"
+and "mouse" in succession, you could either
+type:
+  cat dog
+  cat mouse
+or just
+  cat dog mouse
+If you print them with one command,
+the files are listed in sequence with nothing
+between them.
+
+This directory contains two files
+named "chester" and "charley".  What is the
+longest word in either file?  Type "answer WORD"
+where WORD is the longest word you find.
+#create charley
+most of this file is short but at one place
+there is a surprisingly long word.
+#create chester
+and of the but here now stop go
+#copyin
+#user
+#uncopyin
+#match surprisingly
+#log
+#next
+4.1a  10
+4.2a    5
+4.3a    2
diff --git a/usr/lib/learn/files/L3.3a b/usr/lib/learn/files/L3.3a
new file mode 100644 (file)
index 0000000..1b082b2
--- /dev/null
@@ -0,0 +1,18 @@
+#print
+A file can be printed on your terminal
+by using the "cat" command.  Just say
+"cat file" where "file" is the file name.
+For example, there is a file named
+"food" in this directory.  List it
+by saying "cat food"; then type "ready".
+#create food
+  this is the file
+  named food.
+#copyout
+#user
+#uncopyout
+tail -2 .ocopy >X1
+#cmp X1 food
+#log
+#next
+3.3b  2
diff --git a/usr/lib/learn/files/L3.3b b/usr/lib/learn/files/L3.3b
new file mode 100644 (file)
index 0000000..525d4d2
--- /dev/null
@@ -0,0 +1,23 @@
+#print
+Of course, you can print any file with "cat".
+In particular, it is common to first use
+"ls" to find the name of a file and then "cat"
+to print it.  Note the difference between
+"ls", which tells you the name of the files,
+and "cat", which tells you the contents.
+
+One file in the current directory is named for
+a President.  Print the file, then type "ready".
+#create roosevelt
+  this file is named roosevelt
+  and contains three lines of
+  text.
+#copyout
+#user
+#uncopyout
+cp .ocopy X2
+tail -3 .ocopy >X1
+#cmp X1 roosevelt
+#log
+#next
+3.2b 2
diff --git a/usr/lib/learn/files/L4.1a b/usr/lib/learn/files/L4.1a
new file mode 100644 (file)
index 0000000..cbc3f2d
--- /dev/null
@@ -0,0 +1,17 @@
+#print
+The "ls" command may be given with one
+or more file names.  In that case,
+it will tell which which of the files exist.
+How many of the files "doug", "dave", and
+"dennis" exist in this directory?  Find out
+and then type "answer N" where N is the number
+you found.
+#create dennis
+#create doug
+#copyin
+#user
+#uncopyin
+#match 2
+#log
+#next
+5.1a  10
diff --git a/usr/lib/learn/files/L4.2a b/usr/lib/learn/files/L4.2a
new file mode 100644 (file)
index 0000000..596ff43
--- /dev/null
@@ -0,0 +1,19 @@
+#print
+If a file name is given with the "ls" command,
+it tells you whether that file exists.
+The file name is listed if the file exists;
+if it doesn't, a complaint is typed.
+For example,
+  ls george
+will type "george" if the file exists,
+and "george not found" if it is missing.
+
+Is there a file named "alexander" in the
+current directory?  Find out, then type "yes" or "no".
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+4.2b 10
diff --git a/usr/lib/learn/files/L4.2b b/usr/lib/learn/files/L4.2b
new file mode 100644 (file)
index 0000000..e0e97bc
--- /dev/null
@@ -0,0 +1,21 @@
+#print
+You can inquire about several files at once
+with the "ls" command.  If you type, for example,
+   ls fee fi fo fum
+you will be told which of the four files "fee", "fi", "fo",
+and "fum" exist.  In the current directory only one
+of the files "grover", "gerald", or "george" exists.
+Find out which one; then rename it "grant".
+Type "ready" when you are done.
+#create gerald
+file
+#create garbage
+garbage it is.
+#user
+#create X1
+file
+#
+cmp -s X1 grant && test ! -r gerald
+#log
+#next
+5.1a  10
diff --git a/usr/lib/learn/files/L4.3a b/usr/lib/learn/files/L4.3a
new file mode 100644 (file)
index 0000000..fa380b9
--- /dev/null
@@ -0,0 +1,20 @@
+#print
+You can use the "ls" command to ask whether
+a single file exists without listing the entire
+directory.  For example, "ls george" will list
+"george" if there is a file with that name, and
+complain if there is not one.  This directory
+contains a file named "arthur" but no file named
+"alan".  You can verify that by typing the
+ordinary "ls" command.  Then try typing "ls arthur"
+to see what happens, and follow that by "ls alan".
+Then type "ready".
+#create arthur
+xxx
+#copyin
+#user
+#uncopyin
+grep 'ls arthur' .copy >/dev/null && grep 'ls alan' .copy >/dev/null
+#log
+#next
+4.3b 0
diff --git a/usr/lib/learn/files/L4.3b b/usr/lib/learn/files/L4.3b
new file mode 100644 (file)
index 0000000..3aec872
--- /dev/null
@@ -0,0 +1,20 @@
+#print
+With the "ls" command, you can inquire about several
+specific files at once.  For example, in the previous
+case, you could type
+
+ls arthur alan
+
+and be told about both files.
+
+Which one of the files "bruce" and "ben" exists?
+Type "answer NAME", where NAME is the one you find.
+#create bruce
+bruce
+#copyin
+#user
+#uncopyin
+#match bruce
+#log
+#next
+4.3c 2
diff --git a/usr/lib/learn/files/L4.3c b/usr/lib/learn/files/L4.3c
new file mode 100644 (file)
index 0000000..11b9ade
--- /dev/null
@@ -0,0 +1,16 @@
+#print
+Your directory contains only one of the following
+files: "richard", "robert", "ralph", "roger".  Find out
+which one exists, and print the contents of that file
+on your terminal (remember the "cat" command?).
+Then type "ready".
+#create robert
+this is the contents of file
+robert which you had to print.
+#copyin
+#user
+#uncopyin
+grep 'cat rob' .copy >/dev/null
+#log
+#next
+5.1a  10
diff --git a/usr/lib/learn/files/L5.1a b/usr/lib/learn/files/L5.1a
new file mode 100644 (file)
index 0000000..6e206f4
--- /dev/null
@@ -0,0 +1,34 @@
+#print
+Most UNIX commands, like "ls" and "cat", let you
+specify any number of file names after the command.
+To make this as easy as possible, there are some
+ways to abbreviate file names.  This is usually
+faster and more accurate than typing out the list in full.
+
+For example, when the character "?" is used in a file name,
+it will represent any character that might be
+in a file name.  That is, the name "a?" is
+an abbreviation for the files "a1", "a2", "aa",
+and so forth.  You can say
+  ls a?
+and if there are any file names beginning with
+"a" that are exactly two letters long, the computer
+will tell you their names.  Try that here.
+First list all the file names with "ls"; then type
+  ls a?
+to get all the two letter names beginning with "a".
+Then type "ready".
+#create a1
+#create a12
+#create abcdef
+#create ax
+#create aa
+#copyin
+#user
+#uncopyin
+grep '^ls a?$' .copy >/dev/null
+#log
+#next
+5.1b 0
+5.1c 5
+5.1e 10
diff --git a/usr/lib/learn/files/L5.1b b/usr/lib/learn/files/L5.1b
new file mode 100644 (file)
index 0000000..7f4b44c
--- /dev/null
@@ -0,0 +1,20 @@
+#print
+Will the name
+  xyz
+be selected by the pattern
+  x?
+in an "ls" command?
+Type "yes" or "no".  If you
+have trouble, there is such a file
+in the current directory,
+so you can find out by trial and error.
+(For example, you might do an ordinary "ls"
+and then try "ls x?" and compare the results.)
+#create xyz
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+5.1c 0
diff --git a/usr/lib/learn/files/L5.1c b/usr/lib/learn/files/L5.1c
new file mode 100644 (file)
index 0000000..39b8895
--- /dev/null
@@ -0,0 +1,26 @@
+#print
+The "?" may appear anywhere in the name.
+For example you can type
+  a?bc
+to match the list of names
+  axbc, aybc, a3bc
+and so forth.
+But the number of characters must always agree.
+How many of the following file names
+are matched by "x?xx"?
+  x1xx, y1xx, x1xxa, xxx
+Type "answer N" where N is the number of matching names.
+You can experiment in the current directory to
+check your answer before typing it.
+#create x1xx
+#create x1xxa
+#create y1xx
+#create xxx
+#copyin
+#user
+#uncopyin
+#match 1
+#log
+#next
+5.1d 0
+5.1e 5
diff --git a/usr/lib/learn/files/L5.1d b/usr/lib/learn/files/L5.1d
new file mode 100644 (file)
index 0000000..38ebe84
--- /dev/null
@@ -0,0 +1,14 @@
+#print
+Will the name
+  ?xx
+match "axx"?  Again, you may
+experiment before typing your
+answer.
+#create axx
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+5.1e 0
diff --git a/usr/lib/learn/files/L5.1e b/usr/lib/learn/files/L5.1e
new file mode 100644 (file)
index 0000000..03c4142
--- /dev/null
@@ -0,0 +1,29 @@
+#print
+Not only may the ? appear anywhere in a name,
+but there may be several ? characters in it.
+For example,
+  g??rge
+will match "george" and "goerge", among others.
+And "a??" will match "abc" or "a11" (but NOT "ax").
+Look at the files in the current directory and decide
+how many names the pattern
+   a?b?c
+will select.  Again, you can try this out
+by comparing an ordinary "ls" with "ls a?b?c"
+to see what happens.  When you figure
+out how many names are selected,
+type "answer N" where N is the number of file names.
+#create a0b0c
+#create a0bc
+#create a0x0c
+#create a1bxc
+#create aabbc
+#create azbzcz
+#copyin
+#user
+#uncopyin
+#match 3
+#log
+#next
+6.1a 5
+6.2a 2
diff --git a/usr/lib/learn/files/L6.1a b/usr/lib/learn/files/L6.1a
new file mode 100644 (file)
index 0000000..0eead33
--- /dev/null
@@ -0,0 +1,33 @@
+#print
+Since the "?" character only matches single characters,
+it isn't useful for such questions as "how many files
+have names beginning with g?"  There is another character,
+  *
+which can be used in patterns for file names, and which matches
+any number of characters of any sort.  Thus
+   g*
+matches anything beginning with g.
+And
+   *x
+matches anything ending in x.  
+There is one file in this directory whose name ends
+in "memo".  Find out that file name
+and print the contents of the file.  Then type "ready".
+#create mymemo
+This is the 7-line file "mymemo";  you should
+have typed "ls *memo", which would print
+"mymemo", and then typed the
+command "cat mymemo".
+Or just plain "cat *memo" would have worked.
+But whatever you did, you got it right
+and now you can type "ready".
+#copyout
+#user
+#uncopyout
+tail -7 .ocopy >X2
+#cmp mymemo X2
+#log
+#next
+6.1b 0
+6.1c 5
+6.1e 10
diff --git a/usr/lib/learn/files/L6.1b b/usr/lib/learn/files/L6.1b
new file mode 100644 (file)
index 0000000..f7f0d01
--- /dev/null
@@ -0,0 +1,14 @@
+#print
+Will the file name "abcd"
+be matched by "a*d"?  Again,
+if you are not sure, you can experiment
+in this directory with commands like
+"ls" and "ls a*d".
+#create abcd
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+6.1c
diff --git a/usr/lib/learn/files/L6.1c b/usr/lib/learn/files/L6.1c
new file mode 100644 (file)
index 0000000..bf8d884
--- /dev/null
@@ -0,0 +1,13 @@
+#print
+There is one file in this directory whose name begins
+with "g".  Rename it so the "g" at the beginning
+of the name is replaced by "h".
+Then type ready.
+#create g23
+g23, of course
+#user
+test -r h23 && test ! -r g23
+#log
+#next
+6.1d 0
+6.1e 5
diff --git a/usr/lib/learn/files/L6.1d b/usr/lib/learn/files/L6.1d
new file mode 100644 (file)
index 0000000..dcf8678
--- /dev/null
@@ -0,0 +1,16 @@
+#print
+What does "*b*" match?  Clearly, any file
+with a "b" anywhere in its name.  Similarly,
+how many files in this directory have
+"se" somewhere in their name?
+Type "answer N" when you figure it out.
+#create arise
+#create reset
+#create set
+#copyin
+#user
+#uncopyin
+#match 3
+#log
+#next
+6.1e
diff --git a/usr/lib/learn/files/L6.1e b/usr/lib/learn/files/L6.1e
new file mode 100644 (file)
index 0000000..cc640d4
--- /dev/null
@@ -0,0 +1,19 @@
+#print
+There is exactly one file name which matches both
+   ab*
+and
+    a?d
+in the current directory.  What is it?
+Type "answer NAME" where NAME is its name.
+#create abc
+#create abd
+#create add
+#copyin
+#user
+#uncopyin
+#match abd
+#log
+#next
+7.1a 10
+7.2a 5
+7.3a 2
diff --git a/usr/lib/learn/files/L6.2a b/usr/lib/learn/files/L6.2a
new file mode 100644 (file)
index 0000000..b94e7b5
--- /dev/null
@@ -0,0 +1,34 @@
+#print
+Since the '?' character only matches single
+characters in file names, it is not useful for
+questions like "how many files have names which
+begin with the letter g?"  There is another character
+  *
+which can be used in patterns for file names
+and matches any number of any kind of characters.
+So
+  g*
+selects all file names beginning with g, and
+  *x
+selects all file names which end in x.  Try
+  ls *x
+How many files match?
+Compare with an ordinary
+  ls
+if you like.  Type "answer N" eventually where
+N is the number of files whose names end in "x".
+#create abcx
+#create abcxdef
+#create memox
+#create memoy
+#create memoz
+#create x
+#create x53x
+#copyin
+#user
+#uncopyin
+#match 4
+#log
+#next
+6.2b 8
+6.1a 1
diff --git a/usr/lib/learn/files/L6.2b b/usr/lib/learn/files/L6.2b
new file mode 100644 (file)
index 0000000..faaf442
--- /dev/null
@@ -0,0 +1,22 @@
+#print
+There is one file in this directory whose name ends
+in "memo".  Find out that file name and print
+the contents of the file.  Then type "ready".
+#create mymemo
+This is the 7-line file "mymemo";  you should
+have typed "ls *memo", which would print
+"mymemo", and then typed the
+command "cat mymemo".
+Or just plain "cat *memo" would have worked.
+But whatever you did, you got it right
+and now you can type "ready".
+#copyout
+#user
+#uncopyout
+tail -7 .ocopy >X2
+#cmp mymemo X2
+#log
+#next
+6.1b 0
+6.1c 5
+6.1e 10
diff --git a/usr/lib/learn/files/L7.1a b/usr/lib/learn/files/L7.1a
new file mode 100644 (file)
index 0000000..871f82f
--- /dev/null
@@ -0,0 +1,38 @@
+#print
+Sometimes ? is too flexible, and you
+only want to allow a few characters.  For example,
+you might want to abbreviate
+  ls memo.ab memo.ac
+without picking up "memo.ad", memo.ae", etc.
+You can match one of a set of particular characters by 
+putting them in brackets "[]" in the list you use with "ls".
+For example,
+  [bc]
+matches either b or c but no other letters,
+so "ls memo.a[bc]" is the abbreviation for
+"ls memo.ab memo.ac".
+You can have as many characters as needed between [ and ].
+
+Type the "ls" command that recognizes
+  a1cat
+  a2cat
+  a3cat
+and no other files.  Then type "ready".
+#create a1bat
+#create a1cat
+#create a2cat
+#create a3cat
+#create a4cat
+#create acat
+#copyin
+#user
+#uncopyin
+#match ls a[123]cat
+#match ls a[1-3]cat
+#match ls a1cat a2cat a3cat
+You were supposed to use a[123]cat.
+Imagine doing it your way with 10 files.
+#log
+#next
+8.1a 10
+8.2a 5
diff --git a/usr/lib/learn/files/L7.2a b/usr/lib/learn/files/L7.2a
new file mode 100644 (file)
index 0000000..5f51b4b
--- /dev/null
@@ -0,0 +1,30 @@
+#print
+Sometimes ? is too flexible, and you
+only want to allow a few characters.  For example,
+you might want to abbreviate
+  ls memo.ab memo.ac
+without picking up "memo.ad", "memo.ae", and so forth.
+You can match one of a set of particular characters by 
+putting them in brackets "[]" in the list you use with "ls".
+For example,
+  [bc]
+matches either b or c but no other letters.  Thus
+  ls memo.a[bc]
+will list exactly "memo.ab" and "memo.ac" if present.
+
+How many of the files
+  xya, xyb, xyc, xyd
+exist in this directory?
+Type "answer N" where N is the number.
+#create xyb
+#create xyc
+#create xye
+#create xyf
+#create xy1
+#copyin
+#user
+#uncopyin
+#match 2
+#log
+#next
+7.2b 10
diff --git a/usr/lib/learn/files/L7.2b b/usr/lib/learn/files/L7.2b
new file mode 100644 (file)
index 0000000..a86c7f8
--- /dev/null
@@ -0,0 +1,32 @@
+#print
+You can put any number of characters between [..]
+characters, as in
+  [abcdef]
+which matches any of the six letters from a to f;
+and you can put something like that anywhere in a pattern
+for a file name.  For example,
+  ls [abcd]x
+matches any of
+ ax, bx, cx, dx
+You can also combine this with other operators such as
+* or ?.  For example,
+  ls [ab]?
+matches all two-letter names beginning with a or b.
+How would you ask for all names, of any length, ending
+in 1 2 or 3?
+You can experiment in this directory; eventually,
+type the "ls" command you decide on followed by "ready".
+#create a1
+#create a12
+#create a1a
+#create a2
+#create a23
+#create aa1
+#create abc1
+#copyin
+#user
+#uncopyin
+#match ls *[123]
+#log
+#next
+8.1a 10
diff --git a/usr/lib/learn/files/L7.3a b/usr/lib/learn/files/L7.3a
new file mode 100644 (file)
index 0000000..f757a51
--- /dev/null
@@ -0,0 +1,28 @@
+#print
+Sometimes ? is too flexible, and you
+only want to allow a few characters.  For example,
+you might want to abbreviate
+  ls memo.ab memo.ac
+without picking up "memo.ad", "!"memo.ae", and so forth.
+You can match one of a set of particular characters by 
+putting them in brackets "[]" in the list you use with "ls".
+For example,
+  [bc]
+matches either b or c but no other letters.
+Thus the command
+  ls memo.a[bc]
+would match "memo.ab", "memo.ac", and nothing else.
+Try that command in this directory: type a plain
+"ls" first, and then "ls memo.a[bc]".
+How many files does "ls memo.a[bc]" match?
+Type "answer N" where N is the number.
+#create memo.ab
+#create memo.abc
+#create memo.bc
+#copyin
+#user
+#uncopyin
+#match 1
+#log
+#next
+7.3b 2
diff --git a/usr/lib/learn/files/L7.3b b/usr/lib/learn/files/L7.3b
new file mode 100644 (file)
index 0000000..1d3b107
--- /dev/null
@@ -0,0 +1,17 @@
+#print
+You can use the [] characters anywhere you want
+in a file name.  For example,
+ ls a[bc]d
+would match abd or acd, right?
+What is the command that finds out how
+many files are named "ax" or "bx"?
+Type that command, then "ready".
+#create ax
+#create bx
+#copyin
+#user
+#uncopyin
+#match ls [ab]x
+#log
+#next
+7.3c 2
diff --git a/usr/lib/learn/files/L7.3c b/usr/lib/learn/files/L7.3c
new file mode 100644 (file)
index 0000000..8b87957
--- /dev/null
@@ -0,0 +1,23 @@
+#print
+You can put any number of characters between the
+brackets.  For example,
+  ab[123456789]
+could match up to 9 names, of the sort
+  ab1, ab2, ab3, ab4, ab5, ...
+How many of the following names exist in this
+directory?
+  p1end, p2end, p3end, p4end, p5end
+Check with a ordinary "ls".  Type "answer N" when you
+know.
+#once #create p1end
+#once #create p3endx
+#once #create p4end
+#once #create p6end
+#copyin
+#user
+#uncopyin
+#match 2
+#log
+#next
+8.1a 10
+8.2a 5
diff --git a/usr/lib/learn/files/L8.1a b/usr/lib/learn/files/L8.1a
new file mode 100644 (file)
index 0000000..2228490
--- /dev/null
@@ -0,0 +1,25 @@
+#print
+Sometimes you want to request one of a limited
+range of characters.  This is possible with an
+expression like
+  [a-d]
+which matches a, b, c, or d.  Thus, to take
+some combinations
+  ab[c-f]
+matches
+  abc, abd, abe, abf
+Try typing "ls a[0-9]"
+and see how many files it matches.  Type that
+number in the form "answer N".
+#create a0
+#create a1
+#create a5
+#create ax
+#copyin
+#user
+#uncopyin
+#match 3
+#log
+#next
+9.1a 10
+9.2a 4
diff --git a/usr/lib/learn/files/L8.2a b/usr/lib/learn/files/L8.2a
new file mode 100644 (file)
index 0000000..6b59b79
--- /dev/null
@@ -0,0 +1,16 @@
+#print
+Will the command
+  ls georg[a-f]
+match the name
+  george
+Type yes or no.
+Experiment first if you want.
+#create george
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+8.2b 5
+9.1a 10
diff --git a/usr/lib/learn/files/L8.2b b/usr/lib/learn/files/L8.2b
new file mode 100644 (file)
index 0000000..8fd3ef8
--- /dev/null
@@ -0,0 +1,23 @@
+#print
+The command
+ ls [aeiou]*.c
+will match all but one of the following names.
+  e.c
+  alpha.c
+  edward
+  u23.c
+Which one?  Type "answer NAME" where NAME
+is the file that doesn't match.  You can experiment
+first, as usual.
+#create alpha.c
+#create e.c
+#create edward
+#create u23.c
+#copyin
+#user
+#uncopyin
+#match edward
+#log
+#next
+8.2c 5
+9.1a 10
diff --git a/usr/lib/learn/files/L8.2c b/usr/lib/learn/files/L8.2c
new file mode 100644 (file)
index 0000000..9a87646
--- /dev/null
@@ -0,0 +1,27 @@
+#print
+As an example more complicated than you will
+probably ever need, consider
+  ?[a-c]*
+which matches what?  Well the first character
+can be anything; the second must be a, b, or c; and
+nothing matters thereafter.    So it matches
+ aaa
+ abc
+ xa
+ 3c25
+but not
+ a
+ ghi
+and so forth.
+Will it match
+ %a25
+Try some experiments, then type yes or no.
+#create %a25
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+9.1a 10
+9.2a 4
diff --git a/usr/lib/learn/files/L9.1a b/usr/lib/learn/files/L9.1a
new file mode 100644 (file)
index 0000000..2da6ae3
--- /dev/null
@@ -0,0 +1,36 @@
+#print
+The patterns for selecting file names that have been discussed
+can be used with other commands than "ls".  For example,
+they can be used with the "cat" command to print files.
+It is common for a memo stored in several
+files to use files named "part1", "part2", etc.
+so that commands like
+  cat part*
+will print everything.
+In this directory there are several
+short files named "sec0", "sec1", "sec3",
+and so forth.
+There are various names of animals in the files;
+find out the largest animal named in the files
+and type "answer NAME" where NAME is that animal.
+#create sec0
+dog mouse cat 
+#create sec1
+rabbit weasel
+pig hamster
+#create sec2
+this file doesn't happen
+to have any animal names in it.
+#create sec3
+fox elephant sheep
+duck  rat
+#create sec4
+groundhog bobcat
+mole  beaver
+#copyin 
+#user
+#uncopyin
+#match elephant
+#log
+#next
+10.1a 10
diff --git a/usr/lib/learn/files/L9.2a b/usr/lib/learn/files/L9.2a
new file mode 100644 (file)
index 0000000..eac03df
--- /dev/null
@@ -0,0 +1,30 @@
+#print
+You can use patterns for file names with commands
+other than "ls".  For example, you can use them with
+the "cat" command to print files.
+This directory has three files named
+  parta
+  partb
+  partc
+You can use
+  cat part?
+to print all of them.  Try that; then
+type "ready".
+#create parta
+This is file parta;
+it has two lines.
+#create partb
+File partb here - has only one line.
+#create partc
+And now in file partc, which has
+the enormous total of
+three lines.
+#create partxxx
+You shouldn't have printed this one.
+#copyin
+#user
+#uncopyin
+grep 'cat part?' .copy >/dev/null
+#log
+#next
+9.2b 5
diff --git a/usr/lib/learn/files/L9.2b b/usr/lib/learn/files/L9.2b
new file mode 100644 (file)
index 0000000..64b9b09
--- /dev/null
@@ -0,0 +1,22 @@
+#print
+You can also use the "*" operator.  For example,
+print the contents of all the files in this
+directory whose names begin with the letter 'p'.
+Use just one "cat" command.
+Then type "ready".
+#create p1
+There are only two such files.  This is the first
+one and it is two lines long.
+#create ppx
+
+This is the second file.  Its first line
+is blank, and then there are three lines of
+text of which this is the last.
+#copyin
+#user
+#uncopyin
+grep 'cat p\*' .copy >/dev/null
+#log
+#next
+10.1a 10
+9.2c 5
diff --git a/usr/lib/learn/files/L9.2c b/usr/lib/learn/files/L9.2c
new file mode 100644 (file)
index 0000000..ed1c330
--- /dev/null
@@ -0,0 +1,26 @@
+#print
+And as an example of the [] operators again,
+print all the files in this directory whose
+names begin with either 'a' or 'c'.
+That will tell you to type either 'yes'
+or 'no' - do what it says.
+#create a1
+Type
+#create a2
+y
+#create b
+n
+o
+#create cxx
+e
+#create cz23
+s
+(on one line, please)
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+10.1a 10
+10.3a 2
diff --git a/usr/lib/learn/files/Lxxx b/usr/lib/learn/files/Lxxx
new file mode 100644 (file)
index 0000000..63e0543
--- /dev/null
@@ -0,0 +1,41 @@
+#print
+This course will help you learn about basic file
+handling commands.  You should first understand
+the special characters # and @: 
+  # cancels the previous character typed;
+  @ cancels the line being typed.
+If you make a typing mistake, you can use these characters to
+correct it before you finish the line and the computer won't
+ever know about it.  For example, what will the
+computer really receive if you type
+
+st#he@
+thf#e
+
+at it?  Reply "answer WORD" where WORD is the word
+as it will be interpreted.  For example, if
+you think it will get 'dog', type
+
+answer dog
+
+If you think it will receive the word "bark", type
+
+answer bark
+
+Don't forget to leave a space between "answer" and the word
+and to hit RETURN at the end of the line.
+Don't use any quotation marks in your answer.
+#copyin
+#user
+#uncopyin
+#match dog
+very funny, but i'll let you pass
+#match the
+that's the one i wanted
+#match bark
+very funny. good enough
+#bad answerthe
+don't type answerthe. try again.
+#log
+#next
+0.1b 5
diff --git a/usr/lib/learn/log/dummy b/usr/lib/learn/log/dummy
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/lib/learn/macros/L0 b/usr/lib/learn/macros/L0
new file mode 100644 (file)
index 0000000..40bb3a2
--- /dev/null
@@ -0,0 +1,2 @@
+#next
+1.1a 5
diff --git a/usr/lib/learn/macros/L1.1a b/usr/lib/learn/macros/L1.1a
new file mode 100644 (file)
index 0000000..905c08c
--- /dev/null
@@ -0,0 +1,23 @@
+#print
+This script deals with the use of the "-ms" macro
+package to produce Bell Laboratories style documents.
+Before trying it, you should be familiar with the
+editor.  To test that, please enter the file
+typed below, _______\b\b\b\b\b\b\bexactly __\b\bas __\b\bis, into file "decl".  Then
+type "ready".
+
+#create Ref
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+#print Ref
+#user
+#cmp decl Ref
+#log
+#next
+2.1a 10
diff --git a/usr/lib/learn/macros/L10.1a b/usr/lib/learn/macros/L10.1a
new file mode 100644 (file)
index 0000000..be79049
--- /dev/null
@@ -0,0 +1,52 @@
+#print
+What if you don't want the cover sheet?  Nroff has
+an option to print only special pages.  In particular,
+  nroff -ms -o1- files ...
+will begin printing at page 1, and skip page 0, the cover sheet.
+If you only want the cover sheet, you need the command
+  nroff -ms -o0 files ...
+which prints only page zero.  Try printing
+only the cover sheet of the file "decl".
+Then type "ready" as usual.
+#once nroff -ms -o0 decl >X1 &
+#create decl
+.RP
+.TL
+Declaration of Independence
+.AU
+Thomas Jefferson
+.AI
+The Continental Congress
+Philadelphia, Pa. 19104
+.AB
+This paper describes advances in scattering theory
+of colonies from mother countries.
+.AE
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#copyout
+#user
+#uncopyout
+tail -66 .ocopy >X2
+#cmp X1 X2
+#log
+#next
+11.1a 10
diff --git a/usr/lib/learn/macros/L11.1a b/usr/lib/learn/macros/L11.1a
new file mode 100644 (file)
index 0000000..a58f7d4
--- /dev/null
@@ -0,0 +1,96 @@
+#print
+The most complex format is the TM (technical memorandum)
+format.  If you use that, instead of the IM format,
+you get the usual "MEMORANDUM FOR FILE" message.  In addition,
+you usually want to specify the TM number, case numbers, and
+so forth.  The command line for TM format (which should also
+be the first line given) should read:
+
+  .TM memo-no. case-no. filing-no.
+
+so that, for example, the command line
+
+   .TM 75-1274-1 39199 39199-11
+
+indicates a TM number of 75-1274-1, a charging case number
+of 39199, and a filing case number of 39199-11.  Suppose the
+number for this memo is
+ 75-1776-1
+and the charging and filing cases are both
+ 12345
+Edit the file "decl" for TM format and run it off.
+#create Ref
+.TM 75-1776-1 12345 12345
+.TL
+Declaration of Independence
+.AU
+Thomas Jefferson
+.AI
+The Continental Congress
+Philadelphia, Pa. 19104
+.AB
+This paper describes advances in scattering theory
+of colonies from mother countries.
+.AE
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#once nroff -ms Ref >X1 &
+#create decl
+.IM
+.TL
+Declaration of Independence
+.AU
+Thomas Jefferson
+.AI
+The Continental Congress
+Philadelphia, Pa. 19104
+.AB
+This paper describes advances in scattering theory
+of colonies from mother countries.
+.AE
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#copyout
+#user
+#uncopyout
+tail -66 .ocopy >X2
+#cmp X1 X2
+#log
+#next
+12.1a 10
diff --git a/usr/lib/learn/macros/L12.1a b/usr/lib/learn/macros/L12.1a
new file mode 100644 (file)
index 0000000..a9b1c87
--- /dev/null
@@ -0,0 +1,100 @@
+#print
+With a TM you want a cover sheet.  The cover sheet doesn't look too
+nice when printed on a computer terminal, but you should
+know how to set it up so that you can put it on the typesetter,
+which does an attractive job of imitating the official  printed
+form.  Basically you must make two changes to get a cover sheet
+with normal formatting.  First, you should add to each .AU line
+the author's room number and extension.  For example,
+  .AU "MH 2C-569" "6377"
+  M. E. Lesk
+indicates that Lesk's room is MH 2C-569 and his extension is 6377.
+The room number is enclosed in quotes to indicate that it is one
+unit, even though it contains a blank.  The quotes around
+the extension are harmless but unnecessary.  Also, you
+must add the command
+  .CS 1 2 3 4 5 6
+after the ".AE" line.  The six numbers are (from left to right)
+the number of pages of text, number of pages of "other",
+the total number of pages, the number of references, the number
+of figures and the number of tables.  Try editing
+the usual file "decl" to indicate that Mr. Jefferson's
+room number is MH 2A-111 and his extension is 1776.
+Request a cover sheet with the above meaningless numbers,
+just to see where they go.  Then run off the document again.
+#create Ref
+.TM 75-1776-1 12345 12345
+.TL
+Declaration of Independence
+.AU "MH 2A-111" 1776
+Thomas Jefferson
+.AI
+The Continental Congress
+Philadelphia, Pa. 19104
+.AB
+This paper describes advances in scattering theory
+of colonies from mother countries.
+.AE
+.CS 1 2 3 4 5 6
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#once nroff -ms Ref >X1 &
+#create decl
+.TM 75-1776-1 12345 12345
+.TL
+Declaration of Independence
+.AU
+Thomas Jefferson
+.AI
+The Continental Congress
+Philadelphia, Pa. 19104
+.AB
+This paper describes advances in scattering theory
+of colonies from mother countries.
+.AE
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#copyout
+#user
+#uncopyout
+tail -132 .ocopy >X2
+#cmp X1 X2
+#log
+#next
+13.1a 10
diff --git a/usr/lib/learn/macros/L13.1a b/usr/lib/learn/macros/L13.1a
new file mode 100644 (file)
index 0000000..1375887
--- /dev/null
@@ -0,0 +1,104 @@
+#print
+A couple of details about TM formats.
+(1) The computer has this habit of putting the real date on things.
+Typically BTL authors wish to lie about the date.  There is a command
+for this:
+  .DA July 4, 1776
+will replace the current date everywhere by the specified date.
+(2) Also about the date: most people don't like it on each page.
+The normal date command is thus:
+  .ND July 4, 1776
+which says "no date on each page; in the TM heading area where
+the date is needed, use July 4, 1776".
+Either date command should be placed just after the .TM line.
+(3) There may be other keywords.  These are indicated by
+the sequence
+  .OK
+  word 1
+  word 2
+inserted before the .AB line.
+All right.  Change "decl" to show a date of July 4, 1776,
+using the ".ND" date command; and add as "other keywords"
+"Democracy" and "Tyranny".  Then run off ONLY the cover
+sheet (remember nroff -ms -o0 file ...?).  End with "ready".
+#create Ref
+.TM 75-1776-1 12345 12345
+.ND July 4, 1776
+.TL
+Declaration of Independence
+.AU "MH 2A-111" 1776
+Thomas Jefferson
+.AI
+The Continental Congress
+Philadelphia, Pa. 19104
+.OK
+Democracy
+Tyranny
+.AB
+This paper describes advances in scattering theory
+of colonies from mother countries.
+.AE
+.CS 1 2 3 4 5 6
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#once nroff -ms -o0 Ref >X1 &
+#create decl
+.TM 75-1776-1 12345 12345
+.TL
+Declaration of Independence
+.AU "MH 2A-111" 1776
+Thomas Jefferson
+.AI
+The Continental Congress
+Philadelphia, Pa. 19104
+.AB
+This paper describes advances in scattering theory
+of colonies from mother countries.
+.AE
+.CS 1 2 3 4 5 6
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#copyout
+#user
+#uncopyout
+tail -66 .ocopy >X2
+#cmp X1 X2
+#log
+#next
+14.1a 10
diff --git a/usr/lib/learn/macros/L14.1a b/usr/lib/learn/macros/L14.1a
new file mode 100644 (file)
index 0000000..fd8ef9b
--- /dev/null
@@ -0,0 +1,104 @@
+#print
+What if there are several authors?  Well, you use several .AU
+commands.  Suppose we promote Richard Henry Lee to co-author
+of our file "decl".  Then we could have
+  .TM memo and case numbers
+  .ND fake date
+  .TL
+  Declaration of Independence
+  .AU room and phone for Jefferson
+  Thomas Jefferson
+  .AU room and phone for Lee
+  Richard Henry Lee
+  .AI
+  as before ...
+as the top of the file.     Rearrange "decl" this way
+and run it off.  Then type "ready".
+Make Lee's room number MH 2B-222 and his extension 1824.
+#create Ref
+.TM 75-1776-1 12345 12345
+.ND July 4, 1776
+.TL
+Declaration of Independence
+.AU "MH 2A-111" 1776
+Thomas Jefferson
+.AU "MH 2B-222" 1824
+Richard Henry Lee
+.AI
+The Continental Congress
+Philadelphia, Pa. 19104
+.OK
+tyranny
+democracy
+.AB
+This paper describes advances in scattering theory
+of colonies from mother countries.
+.AE
+.CS 1 2 3 4 5 6
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#once nroff -ms Ref >X1 &
+#create decl
+.TM 75-1776-1 12345 12345
+.ND July 4, 1776
+.TL
+Declaration of Independence
+.AU "MH 2A-111" 1776
+Thomas Jefferson
+.AI
+The Continental Congress
+Philadelphia, Pa. 19104
+.OK
+tyranny
+democracy
+.AB
+This paper describes advances in scattering theory
+of colonies from mother countries.
+.AE
+.CS 1 2 3 4 5 6
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#copyout
+#user
+#uncopyout
+tail -132 .ocopy >X2
+#cmp X1 X2
+#log
+#next
+15.1a 10
diff --git a/usr/lib/learn/macros/L15.1a b/usr/lib/learn/macros/L15.1a
new file mode 100644 (file)
index 0000000..1418c23
--- /dev/null
@@ -0,0 +1,306 @@
+#print
+Here's a new document.  In the file "Ascent" is a supposed memo.
+It begins immediately with the text, but the paragraphs are
+marked with ".PP" commands.  Add the initial material
+as follows and run it of as a TM:
+  Title: Ascending the Riffelberg
+  Author: Mark Twain
+  Author's address:  Hannibal, Mo.
+  TM number: 75-1868-1
+  Case number 39199
+  File number: 39425-2
+  Author's room number:  MH 2C-520
+  Author's extension:  9876
+  Abstract:
+    Why climb Everest?
+    Because it is there, said Mallory.
+  Other keywords: Mountaineering
+  Cover sheet numbers: just use 1 2 3 4 5 6 
+OK?  You can still look at "decl" to see the format.
+#create Ref
+.TM 75-1868-1 39199 39425-2
+.TL
+Ascending the Riffelberg
+.AU "MH 2C-520" 9876
+Mark Twain
+.AI
+Hannibal, Mo.
+.OK
+Mountaineering
+.AB
+Why climb Everest?
+Because it is there, said Mallory.
+.AE
+.CS 1 2 3 4 5 6
+.PP
+I sat silent some time, then turned to Harris and said:
+``My mind is made up.''
+Something in my tone struck him; and when he glanced
+at my eye and read what was written there, his face paled
+perceptibly.  He hesitated a moment, then said:
+``Speak.''
+I answered, with perfect calmness:
+``I WILL ASCEND THE RIFFELBERG.''
+If I had shot my poor friend he could not have fallen from
+his chair more suddenly.  If I had been his father he
+could not have pleaded harder to get me to give up my
+purpose.  But I turned a deaf ear to all he said.  When he
+perceived at last that nothing could alter my determination,
+he ceased to urge, and for a while the deep silence was broken only
+by his sobs.  I sat in marble resolution, with my
+eyes fixed upon vacancy, for in spirit I was already
+wrestling with the perils of the mountains, and my friend sat
+gazing at me in adoring admiration through his tears.  At
+last he threw himself upon me in a loving embrace and
+exclaimed in broken tones:
+``Your Harris will never desert you.  We will die together!''
+I cheered the noble fellow with praises, and soon his fears
+were forgotten and he was eager for the adventure.  He
+wanted to summon the guides at once and leave at two in
+the morning, as he supposed the custom was; but I explained that nobody
+was looking at that hour; and that the start in the dark
+was not usually made from the village but
+from the first night's resting-place on the mountainside.  I
+said we would leave the village at 3 or 4 p.m. on the morrow;
+meantime he could notify the guides, and also let the public
+know of the attempt which we proposed to make.
+.PP
+I went to bed, but not to sleep.  No man can sleep when
+he is about to undertake one of these Alpine exploits.  I
+tossed feverishly all night long, and was glad enough when
+I heard the clock strike half past eleven and knew it was
+time to get up for dinner.  I rose, jaded and rusty, and went
+to the noon meal, where I found myself the center of interest and
+curiosity; for the news was already abroad.  It is not
+easy to eat calmly when you are a lion, but it is very
+pleasant, nevertheless.
+.PP
+As usual, at Zermatt, when a great ascent is about to be
+undertaken, everybody, native and foreign, laid aside his
+own projects and took up a good position to observe the
+start.  The expedition consisted of 198 persons, including
+the mules; or 205, including the cows.
+.PP
+It was full four o'clock in the afternoon before my cavalcade
+was entirely ready.  At that hour it began to move.  In
+point of numbers and spectacular effect, it was the most
+imposing expedition that had ever marched from Zermatt.
+.PP
+I commanded the chief guide to arrange the men and
+animals in single file, twelve feet apart, and lash them all
+together on a strong rope.  He objected that the first two
+miles was a dead level, with plenty of room, and that the
+rope was never used except in very dangerous places.  But I
+would not listen to that.  My reading had taught me that
+many serious accidents had happened in the Alps simply
+from not having the people tied up soon enough; I was not
+going to add one to the list.  The guide then obeyed my
+order.
+.PP
+When the procession stood at ease, roped together, and
+ready to move, I never saw a finer sight.  It was 3,122 feet
+long - over half a mile; every man but Harris and me was
+on foot, and had on his green veil and his blue goggles, and
+his white rag around his hat, and his coil of rope over one
+shoulder and under the other, and his ice-ax in his belt,
+and carried his Alpenstock in his left hand, his umbrella
+(closed) in his right, and his crutches slung at his back.
+.PP
+The burdens of the pack-mules and the horns of the cows
+were decked with the Edelweiss and the Alpine rose.
+.PP
+I and my agent were the only persons mounted.  We
+were in the post of danger in the extreme rear, and tied
+securely to five guides apiece.  Our armor-bearers carried our
+ice-axes, Alpenstocks, and other implements for us.  We
+were mounted upon very small donkeys, as a measure of
+safety; in time of peril we could straighten our legs and
+stand up, and let the donkey walk from under.  Still, I cannot
+recommend this sort of animal - at least for excursions
+of mere pleasure - because his ears interrupt the view.  I
+and my agent possessed the regulation mountaineering costumes,
+but concluded to leave them behind.  Out of respect
+for the great numbers of tourists of both sexes who would
+be assembled in front of the hotels to see us pass, and also
+out of respect for the many tourists whom we expected to
+encounter on our expedition, we decided to make the
+ascent in evening dress.
+.PP
+At fifteen minutes past four I gave the command to
+move, and my subordinates passed it along the line.  The
+great crowd in front of the Monte Rosa hotel parted in
+twain, with a cheer, as the procession approached; and as
+the head of it was filing by I gave the order - unlimber -
+make ready - hoist - and with one impulse up went my
+half-mile of umbrellas.  It was a beautiful sight, and a total
+surprise to the spectators.  Nothing like that had ever been
+seen in the Alps before.  The applause it brought forth was
+deeply gratifying to me, and I rode by with my plug hat in
+my hand to testify my appreciation of it.  It was the only
+testimony I could offer, for I was too full to speak.
+#once #create Ascent
+.PP
+I sat silent some time, then turned to Harris and said:
+``My mind is made up.''
+Something in my tone struck him; and when he glanced
+at my eye and read what was written there, his face paled
+perceptibly.  He hesitated a moment, then said:
+``Speak.''
+I answered, with perfect calmness:
+``I WILL ASCEND THE RIFFELBERG.''
+If I had shot my poor friend he could not have fallen from
+his chair more suddenly.  If I had been his father he
+could not have pleaded harder to get me to give up my
+purpose.  But I turned a deaf ear to all he said.  When he
+perceived at last that nothing could alter my determination,
+he ceased to urge, and for a while the deep silence was broken only
+by his sobs.  I sat in marble resolution, with my
+eyes fixed upon vacancy, for in spirit I was already
+wrestling with the perils of the mountains, and my friend sat
+gazing at me in adoring admiration through his tears.  At
+last he threw himself upon me in a loving embrace and
+exclaimed in broken tones:
+``Your Harris will never desert you.  We will die together!''
+I cheered the noble fellow with praises, and soon his fears
+were forgotten and he was eager for the adventure.  He
+wanted to summon the guides at once and leave at two in
+the morning, as he supposed the custom was; but I explained that nobody
+was looking at that hour; and that the start in the dark
+was not usually made from the village but
+from the first night's resting-place on the mountainside.  I
+said we would leave the village at 3 or 4 p.m. on the morrow;
+meantime he could notify the guides, and also let the public
+know of the attempt which we proposed to make.
+.PP
+I went to bed, but not to sleep.  No man can sleep when
+he is about to undertake one of these Alpine exploits.  I
+tossed feverishly all night long, and was glad enough when
+I heard the clock strike half past eleven and knew it was
+time to get up for dinner.  I rose, jaded and rusty, and went
+to the noon meal, where I found myself the center of interest and
+curiosity; for the news was already abroad.  It is not
+easy to eat calmly when you are a lion, but it is very
+pleasant, nevertheless.
+.PP
+As usual, at Zermatt, when a great ascent is about to be
+undertaken, everybody, native and foreign, laid aside his
+own projects and took up a good position to observe the
+start.  The expedition consisted of 198 persons, including
+the mules; or 205, including the cows.
+.PP
+It was full four o'clock in the afternoon before my cavalcade
+was entirely ready.  At that hour it began to move.  In
+point of numbers and spectacular effect, it was the most
+imposing expedition that had ever marched from Zermatt.
+.PP
+I commanded the chief guide to arrange the men and
+animals in single file, twelve feet apart, and lash them all
+together on a strong rope.  He objected that the first two
+miles was a dead level, with plenty of room, and that the
+rope was never used except in very dangerous places.  But I
+would not listen to that.  My reading had taught me that
+many serious accidents had happened in the Alps simply
+from not having the people tied up soon enough; I was not
+going to add one to the list.  The guide then obeyed my
+order.
+.PP
+When the procession stood at ease, roped together, and
+ready to move, I never saw a finer sight.  It was 3,122 feet
+long - over half a mile; every man but Harris and me was
+on foot, and had on his green veil and his blue goggles, and
+his white rag around his hat, and his coil of rope over one
+shoulder and under the other, and his ice-ax in his belt,
+and carried his Alpenstock in his left hand, his umbrella
+(closed) in his right, and his crutches slung at his back.
+.PP
+The burdens of the pack-mules and the horns of the cows
+were decked with the Edelweiss and the Alpine rose.
+.PP
+I and my agent were the only persons mounted.  We
+were in the post of danger in the extreme rear, and tied
+securely to five guides apiece.  Our armor-bearers carried our
+ice-axes, Alpenstocks, and other implements for us.  We
+were mounted upon very small donkeys, as a measure of
+safety; in time of peril we could straighten our legs and
+stand up, and let the donkey walk from under.  Still, I cannot
+recommend this sort of animal - at least for excursions
+of mere pleasure - because his ears interrupt the view.  I
+and my agent possessed the regulation mountaineering costumes,
+but concluded to leave them behind.  Out of respect
+for the great numbers of tourists of both sexes who would
+be assembled in front of the hotels to see us pass, and also
+out of respect for the many tourists whom we expected to
+encounter on our expedition, we decided to make the
+ascent in evening dress.
+.PP
+At fifteen minutes past four I gave the command to
+move, and my subordinates passed it along the line.  The
+great crowd in front of the Monte Rosa hotel parted in
+twain, with a cheer, as the procession approached; and as
+the head of it was filing by I gave the order - unlimber -
+make ready - hoist - and with one impulse up went my
+half-mile of umbrellas.  It was a beautiful sight, and a total
+surprise to the spectators.  Nothing like that had ever been
+seen in the Alps before.  The applause it brought forth was
+deeply gratifying to me, and I rode by with my plug hat in
+my hand to testify my appreciation of it.  It was the only
+testimony I could offer, for I was too full to speak.
+#once nroff -ms Ref >X1 &
+#create decl
+.TM 75-1776-1 12345 12345
+.ND July 4, 1776
+.TL
+Declaration of Independence
+.AU "MH 2A-111" 1776
+Thomas Jefferson
+.AU "MH 2B-222" 1824
+James Madison
+.AI
+The Continental Congress
+Philadelphia, Pa. 19104
+.OK
+tyranny
+democracy
+.AB
+This paper describes advances in scattering theory
+of colonies from mother countries.
+.AE
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#create script
+1,$-264d
+w
+q
+#copyout
+#user
+#uncopyout
+e - .ocopy <script
+#cmp X1 .ocopy
+#fail
+Sorry, that wasn't right.
+
+To see exactly what you are doing, after
+making your insertions, compare the file
+with file "Ref" using "diff".
+
+OK, maybe you'll get a chance to do it over:
+
+#log
diff --git a/usr/lib/learn/macros/L2.1a b/usr/lib/learn/macros/L2.1a
new file mode 100644 (file)
index 0000000..b1ea3db
--- /dev/null
@@ -0,0 +1,25 @@
+#print
+When you have some document typed in "-ms" style,
+you run it off on your terminal by saying:
+
+  nroff -ms file
+
+where "file" is the name of the file it is on.  For example,
+the file "decl" in this directory is in a suitable format
+for running off this way.  Do so.  Then type "ready".
+#create decl
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+#copyin
+#user
+#uncopyin
+#match nroff -ms decl
+#log
+#next
+3.1a 10
diff --git a/usr/lib/learn/macros/L3.1a b/usr/lib/learn/macros/L3.1a
new file mode 100644 (file)
index 0000000..c13e135
--- /dev/null
@@ -0,0 +1,70 @@
+#print
+The file "decl" began with ".PP".  All files sent
+to -ms MUST begin with a "-ms" command line.  You can
+tell these command lines, in general, because they
+begin with a period and have only capital letters on them.
+The ".PP" command indicates a new paragraph.
+So to add another paragraph to a file, you put a ".PP"
+in front and then type in the new text.  Here is the
+next paragraph of the declaration of independence.  Add
+it to the end of the file "decl" that you've been working
+with.  You can do that most easily by picking up the text
+from file "para2", or you can type it in again.  It is
+not necessary to keep every word on exactly
+the line it was, since the program will rearrange them.
+But the ".PP" must be on a line by itself.  Then
+run off the the new version.
+
+
+#create Ref
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#once nroff -ms Ref >X2 &
+#create decl
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+#create para2
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#print para2
+#copyout
+#user
+#uncopyout
+tail -66 .ocopy >X1
+#cmp X1 X2
+#log
+#next
+4.1a 10
diff --git a/usr/lib/learn/macros/L4.1a b/usr/lib/learn/macros/L4.1a
new file mode 100644 (file)
index 0000000..a6acce2
--- /dev/null
@@ -0,0 +1,65 @@
+#print
+Usually, of course, a document contains more than
+just paragraphs.  In particular, most
+documents have titles, which are entered with "-ms"
+by saying
+  .TL
+  title goes here
+  .PP
+  paragraphs of documents...
+There is the same "decl" file here: add a title
+"Declaration of Independence" and
+run it off again.
+#create Ref
+.TL
+Declaration of Independence
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#once nroff -ms Ref >X2 &
+#create decl
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#copyout
+#user
+#uncopyout
+tail -66 .ocopy >X1
+#cmp X1 X2
+#log
+#next
+5.1a 10
diff --git a/usr/lib/learn/macros/L5.1a b/usr/lib/learn/macros/L5.1a
new file mode 100644 (file)
index 0000000..cdcf816
--- /dev/null
@@ -0,0 +1,69 @@
+#print
+Also, most documents have one or more authors.
+Authors are indicated by a preceding line of ".AU".
+Thus you would say
+ .TL
+  title
+ .AU
+  author
+ .PP
+  text
+OK, edit "decl" again: the author is Thomas Jefferson.
+Insert this and run the document off.
+#create Ref
+.TL
+Declaration of Independence
+.AU
+Thomas Jefferson
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#once nroff -ms Ref >X2 &
+#create decl
+.TL
+Declaration of Independence
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#copyout
+#user
+#uncopyout
+tail -66 .ocopy >X1
+#cmp X1 X2
+#log
+#next
+6.1a 10
diff --git a/usr/lib/learn/macros/L6.1a b/usr/lib/learn/macros/L6.1a
new file mode 100644 (file)
index 0000000..ec640d4
--- /dev/null
@@ -0,0 +1,74 @@
+#print
+Usually, in addition to the author, you want
+to specify his address, 
+which is given after a command ".AI" (Author's institution).
+This should follow immediately after the author's name.
+In the usual file, "decl", put in Jefferson's
+address as
+
+The Continental Congress
+Philadelphia, Pa. 19104
+
+Then run it off and type "ready".
+#create Ref
+.TL
+Declaration of Independence
+.AU
+Thomas Jefferson
+.AI
+The Continental Congress
+Philadelphia, Pa. 19104
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#once nroff -ms Ref >X1   &
+#create decl
+.TL
+Declaration of Independence
+.AU
+Thomas Jefferson
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#copyout
+#user
+#uncopyout
+tail -66 .ocopy >X2
+#cmp X1 X2
+#log
+#next
+7.1a 10
diff --git a/usr/lib/learn/macros/L7.1a b/usr/lib/learn/macros/L7.1a
new file mode 100644 (file)
index 0000000..07de402
--- /dev/null
@@ -0,0 +1,80 @@
+#print
+Another standard feature of scientific papers, although
+not always present is an abstract.  It should be placed
+after the author's institution, but before the text,
+and surrounded by the commands ".AB" and ".AE".
+Let's make up an imaginary abstract - how about
+
+  This paper describes advances in scattering
+  theory of colonies from mother countries.
+
+Add this to the usual "decl" file and run it off.
+#create Ref
+.TL
+Declaration of Independence
+.AU
+Thomas Jefferson
+.AI
+The Continental Congress
+Philadelphia, Pa. 19104
+.AB
+This paper describes advances in scattering theory
+of colonies from mother countries.
+.AE
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#once nroff -ms Ref >X1 &
+#create decl
+.TL
+Declaration of Independence
+.AU
+Thomas Jefferson
+.AI
+The Continental Congress
+Philadelphia, Pa. 19104
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#copyout
+#user
+#uncopyout
+tail -66 .ocopy >X2
+#cmp X2 X1
+#log
+#next
+8.1a 10
diff --git a/usr/lib/learn/macros/L8.1a b/usr/lib/learn/macros/L8.1a
new file mode 100644 (file)
index 0000000..eb815f0
--- /dev/null
@@ -0,0 +1,82 @@
+#print
+So far we have run this off in a sort of proofreading format
+that includes all the data but doesn't really look like anything
+in the BTL style guide.  It is possible, preceding the
+title, to put one of three commands to indicate a particular
+Bell Laboratories format.  The simplest of these is .IM
+(internal memorandum).  Try putting .IM in front of the
+text; then run it off and see what it looks like.
+#create Ref
+.IM
+.TL
+Declaration of Independence
+.AU
+Thomas Jefferson
+.AI
+The Continental Congress
+Philadelphia, Pa. 19104
+.AB
+This paper describes advances in scattering theory
+of colonies from mother countries.
+.AE
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#once nroff -ms Ref >X1 &
+#create decl
+.TL
+Declaration of Independence
+.AU
+Thomas Jefferson
+.AI
+The Continental Congress
+Philadelphia, Pa. 19104
+.AB
+This paper describes advances in scattering theory
+of colonies from mother countries.
+.AE
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#copyout
+#user
+#uncopyout
+tail -66 .ocopy >X2
+#cmp X1 X2
+#log
+#next
+9.1a 10
diff --git a/usr/lib/learn/macros/L9.1a b/usr/lib/learn/macros/L9.1a
new file mode 100644 (file)
index 0000000..c5ca4f9
--- /dev/null
@@ -0,0 +1,83 @@
+#print
+The next format to mention is the RP (released paper)
+format.  If you use that, instead of the IM format,
+you get the standard Bell Labs released paper style.
+Change the first line of file "decl" to read
+  .RP
+and run it off.  Note that you get a cover page as well as the
+first page.
+#create Ref
+.RP
+.TL
+Declaration of Independence
+.AU
+Thomas Jefferson
+.AI
+The Continental Congress
+Philadelphia, Pa. 19104
+.AB
+This paper describes advances in scattering theory
+of colonies from mother countries.
+.AE
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#once nroff -ms Ref >X1 &
+#create decl
+.IM
+.TL
+Declaration of Independence
+.AU
+Thomas Jefferson
+.AI
+The Continental Congress
+Philadelphia, Pa. 19104
+.AB
+This paper describes advances in scattering theory
+of colonies from mother countries.
+.AE
+.PP
+When in the course of human events, it becomes
+necessary for one people to dissolve the political bands which have
+connected them with another, and to assume among the 
+powers of the earth the separate and equal station to which
+the laws of Nature and of Nature's God entitle them, a decent
+respect to the opinions of mankind requires that they should
+declare the causes which impel them to the separation.
+.PP
+We hold these truths to be self-evident, that all men
+are created equal, that they are endowed by their creator
+with certain unalienable rights, that among these are life, liberty,
+and the pursuit of happiness.  That to secure these rights,
+governments are instituted among men, deriving their just
+powers from the consent of the governed.  That whenever
+any form of government becomes destructive of these ends,
+it is the right of the people to alter or to abolish it, and
+to institute new government, laying its foundation on such
+principles and organizing its powers in such form, as to them
+shall seem most likely to effect their safety and happiness.
+#copyout
+#user
+#uncopyout
+tail -132 .ocopy >X2
+#cmp X1 X2
+#log
+#next
+10.1a 10
diff --git a/usr/lib/learn/morefiles/L0 b/usr/lib/learn/morefiles/L0
new file mode 100644 (file)
index 0000000..bab7601
--- /dev/null
@@ -0,0 +1,2 @@
+#next
+0.1a 10
diff --git a/usr/lib/learn/morefiles/L0.1a b/usr/lib/learn/morefiles/L0.1a
new file mode 100644 (file)
index 0000000..e6d4f44
--- /dev/null
@@ -0,0 +1,21 @@
+#print
+In the basic files course you learned about the "ls" command
+for listing the names of files in the current directory.
+You will now learn some of the extra abilities of "ls".
+UNIX maintains a lot more information about a file than just
+its name; this extra information includes the size of the
+file, the date and time it was last changed, the owner,
+and scattered other miscellany.  To see this "long" list of information,
+use the command "ls -l".  The "-l" is called an "optional argument",
+since it may or may not be present.
+
+To begin, try just "ls -l", then type "ready".
+#create junk
+this is garbage
+#copyin
+#user
+#uncopyin
+#match ls -l
+#log
+#next
+0.1b 10
diff --git a/usr/lib/learn/morefiles/L0.1b b/usr/lib/learn/morefiles/L0.1b
new file mode 100644 (file)
index 0000000..b787b60
--- /dev/null
@@ -0,0 +1,35 @@
+#print
+The first line, that says "total N", is a measure of how much
+file space is being used by the files in this directory.
+The part of the listing that says something like
+"-rw-rw-r--" gives the read and write
+permissions for the file -- in effect,
+who can do what to it.
+The second field is the number of "links" to the file.
+We won't worry about these two right now.
+
+The name in the third field is the owner of the file.
+The fourth field is the size of the file in characters,
+which is often interesting.  The rest of the listing
+is the date and time the file was last changed, and
+its name.
+
+What is the smallest file in this directory?
+(Don't use the previous list - I've changed things.)
+Type "answer name", where "name" is the name of the
+smallest file.
+#create kseq
+stuff
+#create jseq
+morestf
+#create X1
+morestuf
+#create X2
+moremore
+#copyin
+#user
+#uncopyin
+#match .copy
+#log
+#next
+0.1c 10
diff --git a/usr/lib/learn/morefiles/L0.1c b/usr/lib/learn/morefiles/L0.1c
new file mode 100644 (file)
index 0000000..a884e59
--- /dev/null
@@ -0,0 +1,13 @@
+#print
+How many characters are there in the file whose name begins
+with "r"?  Type "answer N", where N is the number of characters
+you found.
+#create ref
+hello world
+#copyin
+#user
+#uncopyin
+#match 12
+#log
+#next
+0.1d 10
diff --git a/usr/lib/learn/morefiles/L0.1d b/usr/lib/learn/morefiles/L0.1d
new file mode 100644 (file)
index 0000000..66404c1
--- /dev/null
@@ -0,0 +1,14 @@
+#print
+Is the file "ref" bigger than the file "ref1"?
+Answer yes or no.
+#create ref
+now is the time.
+#create ref1
+now is the time for all good men.
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+0.1e 10
diff --git a/usr/lib/learn/morefiles/L0.1e b/usr/lib/learn/morefiles/L0.1e
new file mode 100644 (file)
index 0000000..e9df942
--- /dev/null
@@ -0,0 +1,24 @@
+#print
+The list of file names from "ls" can also be obtained
+sorted by the date the file was most recently changed,
+with the newest files listed first.  This list is
+obtained by typing "ls -t".
+
+What is the oldest file in this directory?
+Type "answer name", where "name" is the oldest file.
+#create X1
+stuff
+#create X2
+stuff
+#create X3
+stuff
+#
+#copyin
+#user
+#uncopyin
+ls -t | tail -1 >X1
+tail -1 .copy >test
+#cmp X1 test
+#log
+#next
+0.1f 10
diff --git a/usr/lib/learn/morefiles/L0.1f b/usr/lib/learn/morefiles/L0.1f
new file mode 100644 (file)
index 0000000..c2d104b
--- /dev/null
@@ -0,0 +1,13 @@
+#print
+You can combine the optional arguments to "ls"; for example
+you can get the "long" list sorted by time of last change
+by saying
+  ls -lt
+Try that, then type "ready".
+#copyin
+#user
+#uncopyin
+#match ls -lt
+#log
+#next
+0.1g 10
diff --git a/usr/lib/learn/morefiles/L0.1g b/usr/lib/learn/morefiles/L0.1g
new file mode 100644 (file)
index 0000000..afe676d
--- /dev/null
@@ -0,0 +1,10 @@
+#print
+Is "ls -tl" identical to "ls -lt"?  Try it,
+then type yes or no.
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+1.1a 10
diff --git a/usr/lib/learn/morefiles/L1.1a b/usr/lib/learn/morefiles/L1.1a
new file mode 100644 (file)
index 0000000..83d452f
--- /dev/null
@@ -0,0 +1,243 @@
+#print
+One of the more useful programs on Unix is "spell", which
+looks for spelling mistakes in a set of files.  Although spell
+is not perfect, it does a reasonable job of presenting you
+with a list of possibilities.  To look for mistakes in a set
+of files, you simply say
+
+   spell filenames
+
+and of course you can use shorthands like *, ? and [] to name
+the files.  For practice, there are some files whose names begin
+with "memo" in this directory; somewhere in one of them
+is a legitimate spelling mistake.  Use spell to find it, then
+type "answer word", where "word" is the mistake.
+Spell may also output a number of words
+that aren't mistakes; you may have to select real errors
+from the false ones.
+
+By the way, spell takes a minute to run;
+go get a cup of coffee or something while you wait.
+#create memo1
+(This comes from a federalist paper by alexander hamilton.)
+   It has been mentioned as one of the advantages to be expected
+from the cooperation of the Senate, in the business
+of appointments, that it would contribute to the
+stability of the administration.  The consent of that body
+would be necessary to displace as well as to appoint.  A
+change of the Chief Magistrate, therefore, would not occasion
+so violent or so general a revolution in the officers
+of the government as might be expected if he were the
+sole disposer of offices.  Where a man in any station had
+given satisfactory evidence of his fitness for it, a new
+President would be restrained from attempting a change
+in favor of a person more agreeable to him by the apprehension
+that a discountenance of the Senate might frustrate
+the attempt, and bring some degree of discredit
+upon himself.  Those who can best estimate the value of
+a steady administration will be most disposed to prize a
+provision which connects the official existence of public
+men with the approbation or disapprobation of that body
+which, from the greater permanency of its own composition,
+will in all probability be less subject to inconstancy
+than any other member of the government.
+   To this union of the Senate with the President, in the
+article of appointments, it has in some cases been suggested
+that it would serve to give the President an undue
+influence over the Senate, and in others that it would
+have an opposite tendency - a strong proof that neither
+suggestion is true.
+   To state the first in its proper form is to refute it.  It
+amounts to this:  the President would have an improper
+influence over the Senate, because the Senate would
+have the power of restraining him.  This is an absurdity in
+terms.  It cannot admit of a doubt that the entire power
+of appointment would enable him much more effectually
+to establish a dangerous empire over that body than a
+mere power of nomination subject to their control.
+    Let us take a view of the converse of the proposition:
+"the Senate would influence the executive."  As I have
+had occasion to remark in several other instances, the indistinctness
+of the objection forbids a precise answer.  In
+what manner is this influence to be exerted?  In relation
+to what objects?  The power of influencing a person, in
+the sense in which it is here used, must imply a power of
+conferring a benefit upon him.  How could the Senate
+confer a benefit upon the President by the manner of employing
+their right of negative upon his nominations?  If it
+be said they might sometimes gratify him by an acquiescence
+in a favorite choice, when public motives might dictate a
+different conduct, I answer that the instances in which the
+President could be personally interested in the result would
+be too few to admit of his being materially affected by the
+#create memo2
+compliances of the Senate.  Besides this, it is evident that
+the POWER which can originate the disposition of honors
+and emoluments is more likely to attract than to be attracted
+by the POWER which can merely obstruct their
+course.  If by influencing the President be want restraining
+him, this is precisely what must have been intended.
+And it has been shown that the restraint would be salutary,
+at the same time that it would not be such as to
+destroy a single advantage to be looked for from the uncontrolled
+agency of that magistrate.  The right of nomination
+would produce all the good, without the ill.
+   Upon a comparison of the plan for the appointment of
+the officers of the proposed government with that which
+is established by the constitution of this State, a decided
+preference must be given to the former.  In that plan the
+power of nomination is unequivocally vested in the executive.
+And as there would be a necessity for submitting
+each nomination to the judgment of an entire branch of
+the legislature, the circumstances attending an appointment,
+from the mode of conducting it, would naturally
+become matters of notoriety, and the public would
+be at no loss to determine what part had been performed
+by the different actors.  The blame of a bad nomination
+would fall upon the President singly and absolutely.  The
+censure of rejecting a good one would lie entirely at the
+door of the senate, aggravated by the consideration
+of their having counteracted the good intentions of the
+executive.  If an ill appointment should be made, the executive,
+for nominating, and the Senate, for approving,
+would participate, though in different degrees, in the
+opprobrium and disgrace.
+   The reverse of all this characterizes the manner of appointment
+in this State.  The council of appointment consists
+of from three to five persons, of whom the governor
+is always one.  This small body, shut up in a private
+apartment, impenetrable to the public eye, proceed to the
+execution of the trust committed to them.  It is known
+that the governor claims the right of nomination upon
+the strength of some ambiguous expressions in the Constitution;
+but it is not known to what extent, or in what
+manner he exercises it; nor upon what occasions he is
+contradicted or opposed.  The censure of a bad appointment,
+on account of the uncertainty of its author and for
+want of a determinate object, has neither poignancy nor
+duration.  And while an unbounded field for cabal and intrigue
+lies open, all idea of responsibility is lost.  The
+most that the public can know is that the governor
+claims the right of nomination; that two out of the inconsiderable
+number of four men can too often be managed
+without much difficulty; that if some of the members of a
+#create memo3
+particular council should happen to be of an uncomplying
+character, it is frequently not impossible to get rid of their
+opposition by regulating the times of meeting in such a
+manner as to render their attendance inconvenient; and
+that from whatever cause it may proceed, a great
+number of very improper appointments are from time to
+time made.  Whether a governor of this State avails himself
+of the ascendant, he must necessarily have in this
+delicate and important part of the administration to prefer
+to offices men who are best qualified for them; or
+whether he prostitutes that advantage to the advancement
+of persons whose chief merit is their implicit devotion to
+his will and to the support of a despicable and dangerous
+system of personal influence are questions which, unfortunately
+for the community, can only be the subjects
+of speculation and conjecture.
+   Every mere council of appointment, however constituted,
+will be a conclave in which cabal and intrigue will
+have their full scope.  Their number, without an unwarrantable
+increase of expense, cannot be large enough to
+preclude a facility of combination.  And as each member
+will have his friends and connections to provide for,
+the desire of mutual gratification will beget a scandalous
+bartering of votes and bargaining for places.  The private
+attachments of one man might easily be satisfied, but to
+satisfy the private attachments of a dozen, or of twenty
+men, would occasion a monopoly of all the principal employments
+of the government in a few families and
+would lead more directly to an aristocracy or an oligarchy
+than any measure that could be contrived.  If, to avoid an
+accumulation of offices, there was to be a frequent change
+in the persons who were to be a frequent change
+in the persons who were to compose the council, this
+would involve the mischiefs of a mutable administration
+in their full extent.  Such a council would also be more
+liable to executive influence than the Senate, because
+they would be fewer in number, and would act less immediately
+under the public inspection.  Such a council, in
+fine, as a substitute for the plan of the convention, would
+be productive of an increase of expense, a multiplication
+of the evils which spring from favoritism and intrigue in
+the distribution of public honors, a decrease of stability
+in the administration of the government, and a diminution
+of the security against an undue influence of the
+executive.  And yet such a council has been warmly contended
+for as an essential amendment in the proposed
+Constitution.
+   I could not with propriety conclude my observations
+on the subject of appointments without taking notice of
+a scheme for which there have appeared some, though
+#create memo4
+but a few advocates; I mean that of uniting the House of
+Representatives in the power of making them.  I shall,
+however, do little more than mention it, as I cannot
+imagine that it is likely to gain the countenance of any
+considerable part of the community.  A body so fluctuating
+and at the same time so numerous can never be
+deemed proper for the exercise of that power.  Its unfitness
+will appear manifest to all when it is recollected that
+in half a century it may consist of three or four hundred
+persons.  All the advantages of the stability, both of the
+Executive and of the Senate, would be defeated by this
+union, and infinite delays and embarrassments would be
+occasioned.  The exampled of most of the States in their
+local constitutions encourages us to reprobate the idea.
+   The only remaining powers of the executive are comprehended
+in giving information to Congress of the state
+of the Union; in recommending to their consideration
+such measures as he shall judge expedient; in convening
+them, or either branch, upon extraordinary occasions; in
+adjourning them when they cannot themselves agree upon
+the time of adjournment; in receiving ambassadors and
+other public ministers; in faithfully executing the laws;
+and in commissioning all the officers of the United States.
+   Except some cavils about the power of convening either
+house of the legislature, and that of receiving ambassadors,
+no objection has been made to this class of
+authorities; nor could they possibly admit of any.  It required,
+indeed, an insatiable avidity for censure to invent
+exceptions to the parts which have been excepted to.  In
+regard to the power of convening either house of the legislature
+I shall barely remark that in respect to the Senate,
+at least, we can readily discover a good reason for it.  As
+this body has a concurrent power with the executive in
+the article of treaties, it might often be necessary to call
+it together with a view to this object, when it would be
+unnecessary and improper to convene the House of Representatives.
+As to the reception of ambassadors, what I
+have said in a former paper will furnish a sufficient answer.
+   We have now completed a survy of the structure and
+powers of the executive department which, I have endeavored
+to show, combines, as far as republican principles
+will admit, all the requisites to energy.  The
+remaining inquiry is:  does it also combine the requisites
+to safety, in the republican sense - due dependence on
+the people, a due responsibility?  The answer to this question
+has been anticipated in the investigation of its other
+characteristics, and is satisfactorily deducible from these
+circumstances; the election of the President once in four
+years by persons immediately chosen by the people for
+that purpose, and his being at all times liable to impeachment,
+trial, dismission from office, incapacity to serve
+in any other, and to the forfeiture of life and estate by subsequent
+prosecution in the common course of law.  But
+these precautions, great as they are, are not the only
+ones which the plan of the convention has provided in
+favor of the public security.  In the only instances in which
+the abuse of the executive authority was materially to be
+feared, the chief Magistrate of the United States, would,
+by that plan, be subjected to the control of a branch of
+the legislative body.  What more can an enlightened and
+reasonable people desire?
+#copyin
+#user
+#uncopyin
+#match survy
+#log
+#next
+1.1b 10
diff --git a/usr/lib/learn/morefiles/L1.1b b/usr/lib/learn/morefiles/L1.1b
new file mode 100644 (file)
index 0000000..19d8f1c
--- /dev/null
@@ -0,0 +1,242 @@
+#print
+Now that you know what word is wrong, you still have to find
+it in one of the memo files so you can correct it.  One way
+is to use the text editor "ed", but that is rather slow.  Better
+is to use the pattern-finding program "grep", which looks through
+a set of files to find a particular word.  To find all occurrences
+of "glop" in the files tom, dick and harry, you need only type
+
+   grep 'glop' tom dick harry
+
+The first thing is the word that grep is to search for;
+any remaining names are file names, which are searched in order.
+The quotes around the word to be searched for aren't
+always necessary, but it's a good habit to use them
+anyway.  Later on we'll see some examples where they are really
+needed.
+
+Use grep to find the memo file that contains the spelling error,
+and type "answer name", where "name" is the file you decide on.
+#create memo1
+(This comes from a federalist paper by alexander hamilton.)
+   It has been mentioned as one of the advantages to be expected
+from the cooperation of the Senate, in the business
+of appointments, that it would contribute to the
+stability of the administration.  The consent of that body
+would be necessary to displace as well as to appoint.  A
+change of the Chief Magistrate, therefore, would not occasion
+so violent or so general a revolution in the officers
+of the government as might be expected if he were the
+sole disposer of offices.  Where a man in any station had
+given satisfactory evidence of his fitness for it, a new
+President would be restrained from attempting a change
+in favor of a person more agreeable to him by the apprehension
+that a discountenance of the Senate might frustrate
+the attempt, and bring some degree of discredit
+upon himself.  Those who can best estimate the value of
+a steady administration will be most disposed to prize a
+provision which connects the official existence of public
+men with the approbation or disapprobation of that body
+which, from the greater permanency of its own composition,
+will in all probability be less subject to inconstancy
+than any other member of the government.
+   To this union of the Senate with the President, in the
+article of appointments, it has in some cases been suggested
+that it would serve to give the President an undue
+influence over the Senate, and in others that it would
+have an opposite tendency - a strong proof that neither
+suggestion is true.
+   To state the first in its proper form is to refute it.  It
+amounts to this:  the President would have an improper
+influence over the Senate, because the Senate would
+have the power of restraining him.  This is an absurdity in
+terms.  It cannot admit of a doubt that the entire power
+of appointment would enable him much more effectually
+to establish a dangerous empire over that body than a
+mere power of nomination subject to their control.
+    Let us take a view of the converse of the proposition:
+"the Senate would influence the executive."  As I have
+had occasion to remark in several other instances, the indistinctness
+of the objection forbids a precise answer.  In
+what manner is this influence to be exerted?  In relation
+to what objects?  The power of influencing a person, in
+the sense in which it is here used, must imply a power of
+conferring a benefit upon him.  How could the Senate
+confer a benefit upon the President by the manner of employing
+their right of negative upon his nominations?  If it
+be said they might sometimes gratify him by an acquiescence
+in a favorite choice, when public motives might dictate a
+different conduct, I answer that the instances in which the
+President could be personally interested in the result would
+be too few to admit of his being materially affected by the
+#create memo2
+compliances of the Senate.  Besides this, it is evident that
+the POWER which can originate the disposition of honors
+and emoluments is more likely to attract than to be attracted
+by the POWER which can merely obstruct their
+course.  If by influencing the President be want restraining
+him, this is precisely what must have been intended.
+And it has been shown that the restraint would be salutary,
+at the same time that it would not be such as to
+destroy a single advantage to be looked for from the uncontrolled
+agency of that magistrate.  The right of nomination
+would produce all the good, without the ill.
+   Upon a comparison of the plan for the appointment of
+the officers of the proposed government with that which
+is established by the constitution of this State, a decided
+preference must be given to the former.  In that plan the
+power of nomination is unequivocally vested in the executive.
+And as there would be a necessity for submitting
+each nomination to the judgment of an entire branch of
+the legislature, the circumstances attending an appointment,
+from the mode of conducting it, would naturally
+become matters of notoriety, and the public would
+be at no loss to determine what part had been performed
+by the different actors.  The blame of a bad nomination
+would fall upon the President singly and absolutely.  The
+censure of rejecting a good one would lie entirely at the
+door of the senate, aggravated by the consideration
+of their having counteracted the good intentions of the
+executive.  If an ill appointment should be made, the executive,
+for nominating, and the Senate, for approving,
+would participate, though in different degrees, in the
+opprobrium and disgrace.
+   The reverse of all this characterizes the manner of appointment
+in this State.  The council of appointment consists
+of from three to five persons, of whom the governor
+is always one.  This small body, shut up in a private
+apartment, impenetrable to the public eye, proceed to the
+execution of the trust committed to them.  It is known
+that the governor claims the right of nomination upon
+the strength of some ambiguous expressions in the Constitution;
+but it is not known to what extent, or in what
+manner he exercises it; nor upon what occasions he is
+contradicted or opposed.  The censure of a bad appointment,
+on account of the uncertainty of its author and for
+want of a determinate object, has neither poignancy nor
+duration.  And while an unbounded field for cabal and intrigue
+lies open, all idea of responsibility is lost.  The
+most that the public can know is that the governor
+claims the right of nomination; that two out of the inconsiderable
+number of four men can too often be managed
+without much difficulty; that if some of the members of a
+#create memo3
+particular council should happen to be of an uncomplying
+character, it is frequently not impossible to get rid of their
+opposition by regulating the times of meeting in such a
+manner as to render their attendance inconvenient; and
+that from whatever cause it may proceed, a great
+number of very improper appointments are from time to
+time made.  Whether a governor of this State avails himself
+of the ascendant, he must necessarily have in this
+delicate and important part of the administration to prefer
+to offices men who are best qualified for them; or
+whether he prostitutes that advantage to the advancement
+of persons whose chief merit is their implicit devotion to
+his will and to the support of a despicable and dangerous
+system of personal influence are questions which, unfortunately
+for the community, can only be the subjects
+of speculation and conjecture.
+   Every mere council of appointment, however constituted,
+will be a conclave in which cabal and intrigue will
+have their full scope.  Their number, without an unwarrantable
+increase of expense, cannot be large enough to
+preclude a facility of combination.  And as each member
+will have his friends and connections to provide for,
+the desire of mutual gratification will beget a scandalous
+bartering of votes and bargaining for places.  The private
+attachments of one man might easily be satisfied, but to
+satisfy the private attachments of a dozen, or of twenty
+men, would occasion a monopoly of all the principal employments
+of the government in a few families and
+would lead more directly to an aristocracy or an oligarchy
+than any measure that could be contrived.  If, to avoid an
+accumulation of offices, there was to be a frequent change
+in the persons who were to be a frequent change
+in the persons who were to compose the council, this
+would involve the mischiefs of a mutable administration
+in their full extent.  Such a council would also be more
+liable to executive influence than the Senate, because
+they would be fewer in number, and would act less immediately
+under the public inspection.  Such a council, in
+fine, as a substitute for the plan of the convention, would
+be productive of an increase of expense, a multiplication
+of the evils which spring from favoritism and intrigue in
+the distribution of public honors, a decrease of stability
+in the administration of the government, and a diminution
+of the security against an undue influence of the
+executive.  And yet such a council has been warmly contended
+for as an essential amendment in the proposed
+Constitution.
+   I could not with propriety conclude my observations
+on the subject of appointments without taking notice of
+a scheme for which there have appeared some, though
+#create memo4
+but a few advocates; I mean that of uniting the House of
+Representatives in the power of making them.  I shall,
+however, do little more than mention it, as I cannot
+imagine that it is likely to gain the countenance of any
+considerable part of the community.  A body so fluctuating
+and at the same time so numerous can never be
+deemed proper for the exercise of that power.  Its unfitness
+will appear manifest to all when it is recollected that
+in half a century it may consist of three or four hundred
+persons.  All the advantages of the stability, both of the
+Executive and of the Senate, would be defeated by this
+union, and infinite delays and embarrassments would be
+occasioned.  The exampled of most of the States in their
+local constitutions encourages us to reprobate the idea.
+   The only remaining powers of the executive are comprehended
+in giving information to Congress of the state
+of the Union; in recommending to their consideration
+such measures as he shall judge expedient; in convening
+them, or either branch, upon extraordinary occasions; in
+adjourning them when they cannot themselves agree upon
+the time of adjournment; in receiving ambassadors and
+other public ministers; in faithfully executing the laws;
+and in commissioning all the officers of the United States.
+   Except some cavils about the power of convening either
+house of the legislature, and that of receiving ambassadors,
+no objection has been made to this class of
+authorities; nor could they possibly admit of any.  It required,
+indeed, an insatiable avidity for censure to invent
+exceptions to the parts which have been excepted to.  In
+regard to the power of convening either house of the legislature
+I shall barely remark that in respect to the Senate,
+at least, we can readily discover a good reason for it.  As
+this body has a concurrent power with the executive in
+the article of treaties, it might often be necessary to call
+it together with a view to this object, when it would be
+unnecessary and improper to convene the House of Representatives.
+As to the reception of ambassadors, what I
+have said in a former paper will furnish a sufficient answer.
+   We have now completed a survy of the structure and
+powers of the executive department which, I have endeavored
+to show, combines, as far as republican principles
+will admit, all the requisites to energy.  The
+remaining inquiry is:  does it also combine the requisites
+to safety, in the republican sense - due dependence on
+the people, a due responsibility?  The answer to this question
+has been anticipated in the investigation of its other
+characteristics, and is satisfactorily deducible from these
+circumstances; the election of the President once in four
+years by persons immediately chosen by the people for
+that purpose, and his being at all times liable to impeachment,
+trial, dismission from office, incapacity to serve
+in any other, and to the forfeiture of life and estate by subsequent
+prosecution in the common course of law.  But
+these precautions, great as they are, are not the only
+ones which the plan of the convention has provided in
+favor of the public security.  In the only instances in which
+the abuse of the executive authority was materially to be
+feared, the chief Magistrate of the United States, would,
+by that plan, be subjected to the control of a branch of
+the legislative body.  What more can an enlightened and
+reasonable people desire?
+#copyin
+#user
+#uncopyin
+#match memo4
+#log
+#next
+1.1c 10
diff --git a/usr/lib/learn/morefiles/L1.1c b/usr/lib/learn/morefiles/L1.1c
new file mode 100644 (file)
index 0000000..377c8fe
--- /dev/null
@@ -0,0 +1,18 @@
+#print
+In this directory is a file named for an unsuccessful king.
+Read it and do what it tells you.
+#create Elizabeth1
+1. She was not a king
+2. She was generally successful
+#create George3
+Does the file George3 contain a backspace character
+any\b where in it?  Figure it out with grep, then type
+"answer N", where N is the line number where you found it.
+Type "answer 0" if there is no backspace.
+#copyin
+#user
+#uncopyin
+#match 2
+#log
+#next
+1.1d 10
diff --git a/usr/lib/learn/morefiles/L1.1d b/usr/lib/learn/morefiles/L1.1d
new file mode 100644 (file)
index 0000000..ee38cc4
--- /dev/null
@@ -0,0 +1,76 @@
+#print
+Print all lines in the file "memo" that contain
+a question mark "?".  Note that since the question mark
+is an abbreviation character (as in "ls ?"), you
+have to make sure that the command interpreter doesn't
+try to interpret it, but instead passes it to "grep"
+as a literal question mark. 
+
+The way to do this is simply to enclose it in quotes,
+as in
+  grep '?' files...
+
+Try listing all the lines with question marks, then type "ready".
+#create memo
+(This comes from a federalist paper by alexander hamilton.)
+   It has been mentioned as one of the advantages to be expected
+from the cooperation of the Senate, in the business
+of appointments, that it would contribute to the
+stability of the administration.  The consent of that body
+would be necessary to displace as well as to appoint.  A
+change of the Chief Magistrate, therefore, would not occasion
+so violent or so general a revolution in the officers
+of the government as might be expected if he were the
+sole disposer of offices.  Where a man in any station had
+given satisfactory evidence of his fitness for it, a new
+President would be restrained from attempting a change
+in favor of a person more agreeable to him by the apprehension
+that a discountenance of the Senate might frustrate
+the attempt, and bring some degree of discredit
+upon himself.  Those who can best estimate the value of
+a steady administration will be most disposed to prize a
+provision which connects the official existence of public
+men with the approbation or disapprobation of that body
+which, from the greater permanency of its own composition,
+will in all probability be less subject to inconstancy
+than any other member of the government.
+   To this union of the Senate with the President, in the
+article of appointments, it has in some cases been suggested
+that it would serve to give the President an undue
+influence over the Senate, and in others that it would
+have an opposite tendency - a strong proof that neither
+suggestion is true.
+   To state the first in its proper form is to refute it.  It
+amounts to this:  the President would have an improper
+influence over the Senate, because the Senate would
+have the power of restraining him.  This is an absurdity in
+terms.  It cannot admit of a doubt that the entire power
+of appointment would enable him much more effectually
+to establish a dangerous empire over that body than a
+mere power of nomination subject to their control.
+    Let us take a view of the converse of the proposition:
+"the Senate would influence the executive."  As I have
+had occasion to remark in several other instances, the indistinctness
+of the objection forbids a precise answer.  In
+what manner is this influence to be exerted?  In relation
+to what objects?  The power of influencing a person, in
+the sense in which it is here used, must imply a power of
+conferring a benefit upon him.  How could the Senate
+confer a benefit upon the President by the manner of employing
+their right of negative upon his nominations?  If it
+be said they might sometimes gratify him by an acquiescence
+in a favorite choice, when public motives might dictate a
+different conduct, I answer that the instances in which the
+President could be personally interested in the result would
+be too few to admit of his being materially affected by the
+#create 1
+#create x
+#copyout
+#user
+#uncopyout
+tail -3 .ocopy >X1
+grep '?' memo >X2
+#cmp X1 X2
+#log
+#next
+2.1a 10
diff --git a/usr/lib/learn/morefiles/L2.1a b/usr/lib/learn/morefiles/L2.1a
new file mode 100644 (file)
index 0000000..5160bdf
--- /dev/null
@@ -0,0 +1,30 @@
+#print
+Most of the programs we have studied so far produce their
+output on the terminal -- examples are "ls", "spell", "grep",
+"date", "who", and so on.  (Of course, some do not, like
+"mv", "cp", and "rm".)  In any case, it is sometimes useful
+to be able to capture the output of a program in a file,
+so it can be used in some later processing.  This is very easy.
+For example, to get the current date and time in a file called
+"now", you need only type
+
+   date >now
+
+The symbol ">" tells the command interpreter that output
+is to go into the file whose name follows.  If the file already
+exists, its old contents will be clobbered, so use discretion.
+
+Your task is to make a list of the files in this directory
+in the file "foo".
+When you have finished, type "ready".
+#create X1
+#create junk1
+asdfadfaf
+#create junk2
+qerqerqrq
+#user
+ls >X1
+#cmp X1 foo
+#log
+#next
+2.1b 10
diff --git a/usr/lib/learn/morefiles/L2.1b b/usr/lib/learn/morefiles/L2.1b
new file mode 100644 (file)
index 0000000..5689e95
--- /dev/null
@@ -0,0 +1,18 @@
+#print
+Now make a list of the files in this directory whose
+names begin with "t" in the file "foo".
+Type "ready" when you are done.
+#create X1
+#create foo
+#create this
+#create Ref
+that
+theother
+this
+#create that
+#create theother
+#user
+#cmp foo Ref
+#log
+#next
+2.1c 10
diff --git a/usr/lib/learn/morefiles/L2.1c b/usr/lib/learn/morefiles/L2.1c
new file mode 100644 (file)
index 0000000..d1ff869
--- /dev/null
@@ -0,0 +1,17 @@
+#print
+This time you have to get a list of the files whose names begin
+with "memo", but sorted in order of last change, most recent first,
+as produced by "ls -t".  Get the list in file "gorp",
+then type "ready".
+#create memo1
+first line
+#create memo3
+third line
+#create memo2
+second line
+#user
+ls -t memo* >X1
+#cmp X1 gorp
+#log
+#next
+2.1d 10
diff --git a/usr/lib/learn/morefiles/L2.1d b/usr/lib/learn/morefiles/L2.1d
new file mode 100644 (file)
index 0000000..97ef391
--- /dev/null
@@ -0,0 +1,10 @@
+#print
+If you type "ls >list", does the name "list" appear in the file
+called "list"?  Figure it out, then type yes or no.
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+2.1e 10
diff --git a/usr/lib/learn/morefiles/L2.1e b/usr/lib/learn/morefiles/L2.1e
new file mode 100644 (file)
index 0000000..6eef846
--- /dev/null
@@ -0,0 +1,25 @@
+#print
+If you make a mistake and type something like
+
+   xxxxx >precious
+
+where "xxxxx" is not\b\b\b___ the name of a legal UNIX
+command, what happens to the file "precious"?
+
+In this directory, there are several precious files.
+Experiment to see what happens.  When you have decided,
+type "answer harmless" if nothing happens to the files,
+or "answer disaster" if the file is clobbered.
+#create precious
+I am precious.
+#create precious1
+So am I.
+#create precious2
+Me too.
+#copyin
+#user
+#uncopyin
+#match disaster
+#log
+#next
+2.1f 10
diff --git a/usr/lib/learn/morefiles/L2.1f b/usr/lib/learn/morefiles/L2.1f
new file mode 100644 (file)
index 0000000..b7c7c33
--- /dev/null
@@ -0,0 +1,14 @@
+#print
+Obtain a long listing (with "ls -l") of all files in this directory
+whose names begin with capital letters, in a file
+called "names". 
+Type "ready" when you're done.
+#create STUFF
+#
+ls -l [A-Z]* >x1
+#user
+#cmp x1 names
+#log
+#next
+3.1a 10
+3.2a 5
diff --git a/usr/lib/learn/morefiles/L3.1a b/usr/lib/learn/morefiles/L3.1a
new file mode 100644 (file)
index 0000000..a2f8bac
--- /dev/null
@@ -0,0 +1,36 @@
+#print
+The notation ">" can be used by most programs to capture
+output on a file.  For example, 
+
+   cat henry >james
+
+makes a copy of "henry" in the file "james"; in fact this is
+essentially identical to
+
+   cp henry james
+
+"cat" is a bit more flexible, though, since you can concatenate
+several files onto one output.  Remember that
+
+   cat tom dick harry
+
+copies all three files onto the terminal?
+In this directory is a file named "john".
+Make a file called "mary" that contains ___\b\b\btwo copies of "john".
+Type "ready" when you're done.
+#create john
+Now is the time for all good
+men to come to the aid of their
+party
+#create X1
+Now is the time for all good
+men to come to the aid of their
+party
+Now is the time for all good
+men to come to the aid of their
+party
+#user
+#cmp X1 mary
+#log
+#next
+3.1b 10
diff --git a/usr/lib/learn/morefiles/L3.1b b/usr/lib/learn/morefiles/L3.1b
new file mode 100644 (file)
index 0000000..e48cc81
--- /dev/null
@@ -0,0 +1,40 @@
+#print
+How many spelling mistakes are there in the file "Ref",
+according to "spell"?
+Type "answer N", where N is the number you decide on.
+#create Ref
+Bianchi
+Blue
+Feldman
+McIlroy
+Roome
+Rosin
+Rosler
+Aho
+Bourne
+Dvorak
+Haley
+Harris
+Holt
+Johnson
+Mashey
+Mitze
+Muha
+Nelson
+Pinson
+Plauger
+Spivack
+Thompson
+Weinberger
+Lesk
+Ossanna
+#
+spell Ref | %s/../lcount >X2 &
+#copyin
+#user
+#uncopyin
+tail -1 .copy >X1
+#cmp X2 X1
+#log
+#next
+3.1c 10
diff --git a/usr/lib/learn/morefiles/L3.1c b/usr/lib/learn/morefiles/L3.1c
new file mode 100644 (file)
index 0000000..31f5635
--- /dev/null
@@ -0,0 +1,42 @@
+#print
+So far the only printing program we have seen
+is "cat", which just copies one or more files
+onto the terminal (or perhaps onto a file when used
+with ">").
+The next step up is the program "pr", which
+prints files so that each file begins on a
+new page, and the top of each page contains the date
+and time the file was changed, and a running page number.
+Use a single "pr" to print the two files in this directory
+whose names begin with "fed". 
+What page number is printed on the last page? Type "answer N"
+where N is the page number.
+#create fed1
+   After an unequivocal experience of the inefficacy of
+the subsisting federal government, you are called upon to
+deliberate on a new Constitution for the United States
+of America.  The subject speaks its own importance;
+comprehending in its consequences nothing less than the
+existence of the union, the safety and welfare of the
+parts of which it is composed, the fate of an empire in many
+respects the most interesting in the world.
+#create fed2
+It has been frequently remarked that it seems to have been
+reserved to the people of this country, by their conduct and
+example, to decide the important question, whether
+societies of men are really capable or not of establishing
+good government from reflection and choice, or whether
+they are forever destined to depend for their political
+constitutions on accident and force.  If there be any truth
+in the remark, the crisis at which we are arrived may with
+propriety be regarded as the era in which that
+decision is to be made; and a wrong election of the part
+we shall act may, in this view, deserve to be considered as
+the general misfortune of mankind.
+#copyin
+#user
+#uncopyin
+#match 1
+#log
+#next
+3.1d
diff --git a/usr/lib/learn/morefiles/L3.1d b/usr/lib/learn/morefiles/L3.1d
new file mode 100644 (file)
index 0000000..c7ecd1b
--- /dev/null
@@ -0,0 +1,125 @@
+#print
+The pr command has a number of other capabilities besides simple
+printing of files.  Probably the most useful is that it can do
+multi-column printing.  This is controlled by an optional
+argument:
+  pr -3 filenames
+will print in 3-column format, and 
+  pr -5 filenames
+prints in five columns.  You can use any number in place of 3 and 5,
+although as you get more columns they become narrower
+so things will fit.
+Notice that the optional argument comes ______\b\b\b\b\b\bbefore the files names.
+
+In this directory there is a list of words.  Find the list, print
+it in two columns, and find out what word appears at the top
+of the second column.  Type "answer WORD", where WORD
+is the word you decide on.
+#create wordlist
+a
+aardvark
+aardwolf
+Aaron
+Aaronic
+Ab
+aba
+abaca
+abaci
+aback
+abacus
+abacuses
+abaft
+abalone
+abandon
+abandoned
+abandoner
+abandonment
+abase
+abasement
+abash
+abashment
+abate
+abatement
+abater
+abatis
+abatises
+abattoir
+abaxial
+abbacy
+Abbasid
+abbatial
+abbe\b'
+abbess
+Abbevillian
+abbey
+abbot
+abbreviate
+abbreviation
+abbreviator
+Abby
+Abc
+Abcs
+Abc's
+abdicable
+abdicate
+abdication
+abdicator
+abdomen
+abdominal
+abdominally
+abdominous
+abduce
+abducent
+abduct
+abduction
+abductor
+abeam
+abecedarian
+abed
+Abel
+abele
+abelmosk
+aberrance
+aberrancy
+aberrant
+aberrantly
+aberration
+aberrational
+abet
+abetment
+abetted
+abetter
+abetting
+abettor
+abeyance
+abeyant
+abhominable
+abhor
+abhorred
+abhorrence
+abhorrent
+abhorrently
+abhorrer
+abhorring
+Abib
+abidance
+abide
+abided
+abider
+abiding
+Abigail
+abigail
+ability
+abiogeneses
+abiogenesis
+abiogenetic
+abiogenetical
+abiogenetically
+abiogenist
+#copyin
+#user
+#uncopyin
+#match abductor
+#log
+#next
+3.1e 10
diff --git a/usr/lib/learn/morefiles/L3.1e b/usr/lib/learn/morefiles/L3.1e
new file mode 100644 (file)
index 0000000..36f55d5
--- /dev/null
@@ -0,0 +1,116 @@
+#print
+Of course you can collect the output from "pr" in a file,
+just as you can with "cat".  For practice, there are several
+files in this directory whose names begin with "word".
+Prepare a list (with "pr", one file per page)
+of these files in the file "neat".
+Type "ready" when you have finished.
+#create word1
+a
+aard-vark
+aard-wolf
+Aar-on
+Aa-ron-ic
+Ab
+aba
+ab-a-ca
+aba-ci
+aback
+aba-cus
+aba-cus-es
+abaft
+ab-a-lo-ne
+aban-don
+aban-doned
+aban-don-er
+aban-don-ment
+abase
+abase-ment
+abash
+abash-ment
+abate
+abate-ment
+abat-er
+ab-a-tis
+ab-a-tis-es
+ab-at-toir
+ab-ax-i-al
+ab-ba-cy
+#create word2
+Ab-bas-id
+ab-ba-tial
+ab-be\b'
+ab-bess
+Abbe-vil-li-an
+ab-bey
+ab-bot
+ab-bre-vi-ate
+ab-bre-vi-a-tion
+ab-bre-vi-a-tor
+Abby
+Abc
+Abcs
+Abc's
+ab-di-ca-ble
+ab-di-cate
+ab-di-ca-tion
+ab-di-ca-tor
+ab-do-men
+ab-dom-i-nal
+ab-dom-i-nal-ly
+ab-dom-i-nous
+ab-duce
+ab-du-cent
+ab-duct
+ab-duc-tion
+ab-duc-tor
+abeam
+abe-ce-dar-i-an
+abed
+#create word3
+Abel
+abele
+abel-mosk
+ab-er-rance
+ab-er-ran-cy
+ab-er-rant
+ab-er-rant-ly
+ab-er-ra-tion
+ab-er-ra-tion-al
+abet
+abet-ment
+abet-ted
+abet-ter
+abet-ting
+abet-tor
+abey-ance
+abey-ant
+abhominable
+ab-hor
+ab-horred
+ab-hor-rence
+ab-hor-rent
+ab-hor-rent-ly
+ab-hor-rer
+ab-hor-ring
+Abib
+abid-ance
+abide
+abid-ed
+abid-er
+abid-ing
+Abigail
+ab-i-gail
+abil-i-ty
+abio-gen-e-ses
+abio-gen-e-sis
+abio-ge-net-ic
+abio-ge-net-i-cal
+abio-ge-net-i-cal-ly
+abi-og-e-nist
+#user
+pr word* >X1
+#cmp X1 neat
+#log
+#next
+3.1f 10
diff --git a/usr/lib/learn/morefiles/L3.1f b/usr/lib/learn/morefiles/L3.1f
new file mode 100644 (file)
index 0000000..ebc8cec
--- /dev/null
@@ -0,0 +1,167 @@
+#print
+This exercise combines several things you've learned already.
+In this directory is a file containing a list of words.
+Collect all of the words that contain "ly" into a file
+called "lywords".  (What program does that?)
+Then use "pr" to make another file called "neatly"
+that contains the list of words printed in one column.
+Type "ready" when you have made both files.
+#create words
+ampersand
+amphetamine
+amphiarthrosis
+amphibia
+amphibian
+amphibiotic
+amphibious
+amphibiously
+amphibiousness
+amphibole
+amphibolite
+amphibolitic
+amphibology
+amphibrach
+amphibrachic
+amphictyonic
+amphictyony
+amphidiploid
+amphidiploidy
+amphimacer
+amphimictic
+amphimictically
+amphimixis
+Amphion
+amphioxus
+amphiploid
+amphiploidy
+amphipod
+amphiprostyle
+amphiprostyle
+amphisbaena
+amphisbaenic
+amphistylar
+amphitheater
+amphitheatric
+amphitheatrical
+amphitheatrically
+Amphitrite
+amphitropous
+Amphitryon
+amphora
+amphorae
+amphoras
+amphoteric
+ample
+ampleness
+amplexicaul
+amplidyne
+amplification
+amplifier
+amplify
+amplitude
+amply
+ampoule
+ampul
+ampulla
+ampullae
+ampullar
+amputate
+amputation
+amputator
+amputee
+amtrac
+amtrack
+amuck
+amulet
+amuse
+amusement
+amuser
+amusing
+amusingly
+amusive
+Amy
+amygdalin
+amygdaloid
+amygdaloidal
+amyl
+amylaceous
+amylase
+amyloid
+amyloidal
+amylolysis
+amylolytic
+amylopsin
+amylose
+amylum
+amyotonia
+an
+an'
+ana
+an'a
+anabaptism
+Anabaptist
+anabases
+anabasis
+anabatic
+anabiosis
+anabiotic
+anabolic
+anabolism
+anabolite
+anabolitic
+anachronic
+anachronism
+anachronistic
+anachronistically
+anachronous
+anachronously
+anaclitic
+anacolutha
+anacoluthic
+anacoluthically
+anacoluthon
+anacoluthons
+anaconda
+Anacreontic
+anacreontic
+anacrusis
+anaculture
+anadem
+anadiplosis
+anadromous
+anaemia
+anaerobe
+anaerobic
+anaerobically
+anaesthesia
+anaesthetic
+anaglyph
+anaglyphic
+anagoge
+anagogic
+anagogical
+anagogically
+anagogy
+anagram
+anagrammatic
+anagrammatical
+anagrammatically
+anagrammatize
+anagrammed
+anagramming
+anal
+analcime
+analcite
+analects
+analemma
+analeptic
+analgesia
+analgesic
+analgetic
+#user
+grep ly words >X1
+pr lywords >X2
+cmp -s X1 lywords && cmp -s X2 neatly
+#log
+#next
+3.1a 10
diff --git a/usr/lib/learn/morefiles/L3.2a b/usr/lib/learn/morefiles/L3.2a
new file mode 100644 (file)
index 0000000..6c1a474
--- /dev/null
@@ -0,0 +1,25 @@
+#print
+Most of the examples we have been doing so far have been
+exercises in using "ls ... >file". 
+But ___\b\b\bany program that normally produces its output on your terminal
+can be made to put that same output into a file instead
+with ">". 
+For example, "cat" simply copies one or more files onto the
+terminal normally, so by using ">", you can get the same 
+information on a file instead. 
+In this directory there are two files whose names
+begin with "r".  Copy them onto a new file called 
+"combine". 
+Type "ready" when you're done.
+#create ref
+Now is the tuime
+#create ref1
+for all good men
+#create X1
+Now is the tuime
+for all good men
+#user
+#cmp X1 combine
+#log
+#next
+3.1a 10
diff --git a/usr/lib/learn/morefiles/L4.1a b/usr/lib/learn/morefiles/L4.1a
new file mode 100644 (file)
index 0000000..6cd5ba5
--- /dev/null
@@ -0,0 +1,25 @@
+#print
+You have already had some practice in using ">" to capture
+the output of a program.  In much the same way, it
+is possible to arrange for a program to take its input not
+from the terminal but from a file.
+Most UNIX programs are written so that they will read either
+the terminal or from a list of filenames.
+To have a program read from a file instead of the terminal,
+use the "<", like this:
+  pr <file
+As a simple experiment, determine if
+  pr <file
+is absolutely identical to
+  pr file
+Answer yes or no.
+#create junk
+you can use this file to play with.
+#copyin
+#user
+#uncopyin
+#match no
+#log
+#next
+4.1b 10
+4.2a 5
diff --git a/usr/lib/learn/morefiles/L4.1b b/usr/lib/learn/morefiles/L4.1b
new file mode 100644 (file)
index 0000000..26a8076
--- /dev/null
@@ -0,0 +1,38 @@
+#print
+Is there a difference between
+  grep the memo[12]
+and
+  cat memo[12] >temp
+  grep the <temp
+Answer yes or no.
+
+If you want to experiment, there are two files named "memo1" and
+"memo2" in this directory.
+#create memo1
+   There is not room enough in the leaves to hold all the food
+that plants make.  Much of the food has to be stored in other parts
+of the plant.
+   We eat the parts of plants where the most food is stored.  The
+carrot plant stores food in its roots.  We eat the roots of carrots.
+The celery plant stores food in its leaf stalks.  They are the parts
+we eat.  Many kinds of plants store food in their fruits.  We eat
+the fruits of these plants to get the stored food in them.
+   Some kinds of plants have ways of protecting their stored food.
+#create memo2
+   Goldfish grow very slowly in an aquarium.  They grow so slowly
+that it is hard to know that they grow at all.  If they are kept
+outdoors in a pool, they grow much faster and they grow much larger,
+too.  Sometimes they grow to be more than a foot long in an outdoor
+pool.
+   When goldfish are kept in an aquarium they often do not live very
+long.  Sometimes they die in a few weeks, but they may live as long
+as ten years.  Some people have kept goldfish in an outdoor pool for
+thirty years.
+   There are many different colors of goldfish.
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+4.1c 10
diff --git a/usr/lib/learn/morefiles/L4.1c b/usr/lib/learn/morefiles/L4.1c
new file mode 100644 (file)
index 0000000..d2c7e08
--- /dev/null
@@ -0,0 +1,42 @@
+#print
+There are two files called "story1" and "story2" in
+this directory.  Collect the outputs of
+  grep the story[12]
+and
+  cat story[12] >temp
+  grep the <temp
+on two files called "the1" and "the2".  Then
+run "diff" on "the1" and "the2", and
+collect the differences on a file called "difference".
+Type "ready" when you have finished all of this.
+#create story1
+   Some animals have six feet.  These animals are insects.
+Insects are little animals.  Insects creep with their six feet.
+Many insects have wings, too.
+   Ants are insects.  Many ants live together.  They live in ant
+hills.  Many ants travel together.  Ants creep on their six feet.
+Ants creep fast.  They creep around on the ground.  They creep in
+and out of ant hills.  They creep up and down plants.  They creep
+into houses.
+   Some ants have wings.  They do not have wings all the time.
+They grow wings to fly away.  They fly away to find new homes.
+Then they lose their wings.
+#create story2
+   "Will there be baby robins soon?" asked Bill.  "We will see,"
+said Miss Fox.  Joan said, "we have looked and looked.  I think
+there will be no baby birds."  Barbara said, "It takes many days.
+The eggs need to be warm all the time.  The mother bird warms them."
+Bill said, "The father bird helps, too."  Joan said, "I guess I did
+not think.  There may be baby birds after all."
+   One day Carl called, "Come and look.  I see four baby birds in
+the nest."  All the children ran to look.  "But they are not pretty,"  
+Joan said.  Bill said, "Joan is right."
+#user
+cat story[12] >X1
+grep the <X1 >X2
+grep the story[12] >X1
+diff X1 X2 >X3
+#cmp X3 difference
+#log
+#next
+4.1d 10
diff --git a/usr/lib/learn/morefiles/L4.1d b/usr/lib/learn/morefiles/L4.1d
new file mode 100644 (file)
index 0000000..8b3cae7
--- /dev/null
@@ -0,0 +1,130 @@
+#print
+Unix has several rather simple programs that are useful
+in their own right and as building blocks in more complicated
+operations.   One of the most frequently used is "wc",
+which counts lines, words, and characters in files.
+If you say
+  wc file
+or 
+  wc <file
+wc will print three numbers: the number of
+lines, words and characters in the file.
+(Some systems have an obsolete version of "wc" that
+doesn't count the characters.)
+If there is more than one file, as in
+  wc file1 file2 file3 file4
+then wc will list the counts for each file separately,
+and the total.
+
+What is the total number of words
+in the two files whose names begin with "memo"?
+Type "answer N", where N is the number of words.
+#create memo1
+   It has been mentioned as one of the advantages to be expected
+from the cooperation of the Senate, in the business
+of appointments, that it would contribute to the
+stability of the administration.  The consent of that body
+would be necessary to displace as well as to appoint.  A
+change of the Chief Magistrate, therefore, would not occasion
+so violent or so general a revolution in the officers
+of the government as might be expected if he were the
+sole disposer of offices.  Where a man in any station had
+given satisfactory evidence of his fitness for it, a new
+President would be restrained from attempting a change
+in favor of a person more agreeable to him by the apprehension
+that a discountenance of the Senate might frustrate
+the attempt, and bring some degree of discredit
+upon himself.  Those who can best estimate the value of
+a steady administration will be most disposed to prize a
+provision which connects the official existence of public
+men with the approbation or disapprobation of that body
+which, from the greater permanency of its own composition,
+will in all probability be less subject to inconstancy
+than any other member of the government.
+   To this union of the Senate with the President, in the
+article of appointments, it has in some cases been suggested
+that it would serve to give the President an undue
+influence over the Senate, and in others that it would
+have an opposite tendency - a strong proof that neither
+suggestion is true.
+   To state the first in its proper form is to refute it.  It
+amounts to this:  the President would have an improper
+influence over the Senate, because the Senate would
+have the power of restraining him.  This is an absurdity in
+terms.  It cannot admit of a doubt that the entire power
+of appointment would enable him much more effectually
+to establish a dangerous empire over that body than a
+mere power of nomination subject to their control.
+    Let us take a view of the converse of the proposition:
+"the Senate would influence the executive."  As I have
+had occasion to remark in several other instances, the indistinctness
+of the objection forbids a precise answer.  In
+what manner is this influence to be exerted?  In relation
+to what objects?  The power of influencing a person, in
+the sense in which it is here used, must imply a power of
+conferring a benefit upon him.  How could the Senate
+confer a benefit upon the President by the manner of employing
+their right of negative upon his nominations?  If it
+be said they might sometimes gratify him by an acquiescence
+in a favorite choice, when public motives might dictate a
+different conduct, I answer that the instances in which the
+President could be personally interested in the result would
+be too few to admit of his being materially affected by the
+#create memo2
+compliances of the Senate.  Besides this, it is evident that
+the POWER which can originate the disposition of honors
+and emoluments is more likely to attract than to be attracted
+by the POWER which can merely obstruct their
+course.  If by influencing the President be want restraining
+him, this is precisely what must have been intended.
+And it has been shown that the restraint would be salutary,
+at the same time that it would not be such as to
+destroy a single advantage to be looked for from the uncontrolled
+agency of that magistrate.  The right of nomination
+would produce all the good, without the ill.
+   Upon a comparison of the plan for the appointment of
+the officers of the proposed government with that which
+is established by the constitution of this State, a decided
+preference must be given to the former.  In that plan the
+power of nomination is unequivocally vested in the executive.
+And as there would be a necessity for submitting
+each nomination to the judgment of an entire branch of
+the legislature, the circumstances attending an appointment,
+from the mode of conducting it, would naturally
+become matters of notoriety, and the public would
+be at no loss to determine what part had been performed
+by the different actors.  The blame of a bad nomination
+would fall upon the President singly and absolutely.  The
+censure of rejecting a good one would lie entirely at the
+door of the senate, aggravated by the consideration
+of their having counteracted the good intentions of the
+executive.  If an ill appointment should be made, the executive,
+for nominating, and the Senate, for approving,
+would participate, though in different degrees, in the
+opprobrium and disgrace.
+   The reverse of all this characterizes the manner of appointment
+in this State.  The council of appointment consists
+of from three to five persons, of whom the governor
+is always one.  This small body, shut up in a private
+apartment, impenetrable to the public eye, proceed to the
+execution of the trust committed to them.  It is known
+that the governor claims the right of nomination upon
+the strength of some ambiguous expressions in the Constitution;
+but it is not known to what extent, or in what
+manner he exercises it; nor upon what occasions he is
+contradicted or opposed.  The censure of a bad appointment,
+on account of the uncertainty of its author and for
+want of a determinate object, has neither poignancy nor
+duration.  And while an unbounded field for cabal and intrigue
+lies open, all idea of responsibility is lost.  The
+most that the public can know is that the governor
+claims the right of nomination; that two out of the inconsiderable
+number of four men can too often be managed
+without much difficulty; that if some of the members of a
+#copyin
+#user
+#uncopyin
+#match 949
+#log
+#next
+4.1e 10
diff --git a/usr/lib/learn/morefiles/L4.1e b/usr/lib/learn/morefiles/L4.1e
new file mode 100644 (file)
index 0000000..8b794ea
--- /dev/null
@@ -0,0 +1,34 @@
+#print
+How many lines total are there in the two files called
+"chema" and "chemb" in this directory?  Use "wc".
+Type "answer N", where N is the total number of lines.
+#create chema
+   The baker said, "Now I shall put just the right amounts of water and
+yeast with the flour that is in the mixer.  Flour, water, and yeast
+together make the sponge.  Making sponge is the first step in making
+bread."
+   The baker closed the mixer.  Inside the machine, the flour and
+yeast and water went around and around until they were well mixed.
+Then the baker opened the mixer and the sponge dropped into a greased
+tub called a trough.
+   The baker pushed the trough into a warm room to let the sponge 
+rise.  It looked like dough, but it did not as yet have everything
+in it.
+#create chemb
+   Wash the blackboard.  Watch it dry.  The water goes into the air.
+When water goes into the air it evaporates.
+   Tie a damp cloth to one end of a stick.  Tie a bottle to the
+other end.  Put water in the bottle until the stick is level.  Watch
+the stick for a few minutes.  It does not stay level.
+   Water goes into the air when it evaporates.  It changes into
+water vapor.  You cannot see water vapor, but it is in the air all
+around you.
+   Cut a hole in the bottom of a cardboard box.  Hold the box
+against a cold window and blow into the hole.
+#copyin
+#user
+#uncopyin
+#match 21
+#log
+#next
+4.1f 10
diff --git a/usr/lib/learn/morefiles/L4.1f b/usr/lib/learn/morefiles/L4.1f
new file mode 100644 (file)
index 0000000..73ecd92
--- /dev/null
@@ -0,0 +1,48 @@
+#print
+Another useful command is "tail", which will print the last
+10 lines of a file.  This is handy when you want to see how 
+far something got before it stopped, or what the last thing
+in a file is.  To use "tail", all you need to say is
+  tail file
+What is the first word on the next to last line of the file
+called "Ref" in this directory.
+Type "answer WORD", where WORD is the word you found.
+#create Ref
+   Now Abraham Lincoln was master of the White House.  But he was
+President of only part of the United States.  For the Southern
+States has taken down the Star-Spangled Banner and raised the flag
+of the Confederacy in its stead.  Sad and silent, Lincoln gazed
+through his spyglass at the Confederate flag that fluttered in the
+wind on the other side of the Potomac River in Virginia.  He pondered
+how to get the Southern States back into the Union.  He needed
+quiet to think what to do.  But from morning till night the White
+House was crowded with people seeking his help.
+   About a hundred and fifty years after the pilgrims settled in
+this country, a young hunter picked up his gun.  He tossed it onto
+his shoulder and followed a buffalo trail across the mountains into
+what is now Kentucky.
+   His name was Daniel Boone.
+   He found wild country.  There were no settlers, no roads.  Indians
+hunted in the woods for food.  The country was beautiful and dangerous.
+But here was rich, free land -- miles and miles of it.
+   Many settlers, besides the Pilgrims, had come to the shores of
+America.  But they had stayed on the safe land between the sea and
+the mountains.
+   Columbus discovered America in 1492.  Later, other explorers
+visited the new land.  They told people in Europe of the forests,
+furs, and fish they found.  Many Europeans decided to settle in
+this wonderful land.  But some of the first settlers starved to
+death during the hard winters.  Others lived to build settlements
+or colonies for their mother countries.  Colonial America was
+beginning.  In 1607, three ships brought men from England to what
+is now Jamestown, Virginia.  They were looking for gold.
+   The leader, Captain John Smith, taught the men to build houses
+of stakes and branches.  They plastered the walls of the houses with
+mud.
+#copyin
+#user
+#uncopyin
+#match of
+#log
+#next
+4.1g 10
diff --git a/usr/lib/learn/morefiles/L4.1g b/usr/lib/learn/morefiles/L4.1g
new file mode 100644 (file)
index 0000000..7dd4f4f
--- /dev/null
@@ -0,0 +1,49 @@
+#print
+By default, "tail" prints the last 10 lines of its input.
+You can change this default amount by specifying a different
+amount as an optional argument.  For example,
+  tail -5 file
+prints the last 5 lines of "file". 
+Collect the last line of the file "Ref" in a new file
+called "last".  Type "ready" when you have finished.
+(By the way, there is a limit to how big the number can be,
+but it's usually at least 60 or 70 lines of normal text.)
+#create Ref
+   About a hundred and fifty years after the pilgrims settled in
+   Columbus discovered America in 1492.  Later, other explorers
+   He found wild country.  There were no settlers, no roads.  Indians
+   His name was Daniel Boone.
+   Many settlers, besides the Pilgrims, had come to the shores of
+   Now Abraham Lincoln was master of the White House.  But he was
+   The leader, Captain John Smith, taught the men to build houses
+America.  But they had stayed on the safe land between the sea and
+But here was rich, free land -- miles and miles of it.
+House was crowded with people seeking his help.
+President of only part of the United States.  For the Southern
+States has taken down the Star-Spangled Banner and raised the flag
+beginning.  In 1607, three ships brought men from England to what
+death during the hard winters.  Others lived to build settlements
+furs, and fish they found.  Many Europeans decided to settle in
+his shoulder and followed a buffalo trail across the mountains into
+how to get the Southern States back into the Union.  He needed
+hunted in the woods for food.  The country was beautiful and dangerous.
+is now Jamestown, Virginia.  They were looking for gold.
+mud.
+of stakes and branches.  They plastered the walls of the houses with
+of the Confederacy in its stead.  Sad and silent, Lincoln gazed
+or colonies for their mother countries.  Colonial America was
+quiet to think what to do.  But from morning till night the White
+the mountains.
+this country, a young hunter picked up his gun.  He tossed it onto
+this wonderful land.  But some of the first settlers starved to
+through his spyglass at the Confederate flag that fluttered in the
+visited the new land.  They told people in Europe of the forests,
+what is now Kentucky.
+wind on the other side of the Potomac River in Virginia.  He pondered
+#create X1
+wind on the other side of the Potomac River in Virginia.  He pondered
+#user
+#cmp X1 last
+#log
+#next
+5.1a 10
diff --git a/usr/lib/learn/morefiles/L4.2a b/usr/lib/learn/morefiles/L4.2a
new file mode 100644 (file)
index 0000000..7da4e62
--- /dev/null
@@ -0,0 +1,13 @@
+#print
+Is the command
+  cat <file
+identical to
+  cat file
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match yes
+#log
+#next
+4.1b 10
diff --git a/usr/lib/learn/morefiles/L5.1a b/usr/lib/learn/morefiles/L5.1a
new file mode 100644 (file)
index 0000000..d3d1887
--- /dev/null
@@ -0,0 +1,23 @@
+#print
+If you think back over some of the exercises you've done
+so far in this course, they have involved collecting the
+output of one program (like "cat" or "grep" or "ls") in
+a file, then using that file as the input to another
+program, like "pr" or "wc" or "grep".
+For example, you could use "ls" and "wc" to _____\b\b\b\b\bcount
+the number of files in a directory.  Do that now,
+then type "answer N", where N is the number of files.
+#create X2
+#create X1
+#create this
+#create stuff
+#create foo
+#copyin
+#user
+#uncopyin
+ls | %s/../lcount >X1
+tail -1 .copy >X2
+#cmp X1 X2
+#log
+#next
+5.1b 10
diff --git a/usr/lib/learn/morefiles/L5.1b b/usr/lib/learn/morefiles/L5.1b
new file mode 100644 (file)
index 0000000..89b0411
--- /dev/null
@@ -0,0 +1,22 @@
+#print
+It seems silly to use a temporary file when all that's really
+needed is to take the output from one program like "ls",
+and pass it directly to the input of another, like "wc".
+One of the original contributions of Unix is a clean
+way to do this, called a "pipe".  You can connect two
+programs with a pipe like this:
+  ls | wc
+and the output of the first program goes into the input of
+the second without any intervening file.
+
+Try this pair of commands in a pipeline.
+Try an ordinary "ls" command too, to verify that you
+got the right answer.  Then type "ready".
+#create X1
+#copyin
+#user
+#uncopyin
+grep 'ls *| *wc' .copy >/dev/null
+#log
+#next
+5.1c
diff --git a/usr/lib/learn/morefiles/L5.1c b/usr/lib/learn/morefiles/L5.1c
new file mode 100644 (file)
index 0000000..5df6f8e
--- /dev/null
@@ -0,0 +1,40 @@
+#print
+Another use for pipes is to replace a command sequence that we
+did earlier with "cat", "pr" and a temporary file.  If you have
+a bunch of small files, using "pr" on them directly wastes
+paper, since each file takes a page.  You could say
+  cat memo* >temp
+  pr temp
+  rm temp
+but this is a nuisance (and the output will
+have the title "temp" on each page).  So use
+a pipe instead.
+In this directory there are some files whose
+names begin with "word".  Use "cat", "pr" and a pipe
+to print them, then type "ready".
+#create word1
+now
+is
+the
+time
+for
+all
+#create word2
+good
+men
+to
+come
+to
+the
+aid
+#create word3
+of
+their
+party.
+#copyin
+#user
+#uncopyin
+grep 'cat word.*| *pr' <.copy >/dev/null
+#log
+#next
+5.1d 10
diff --git a/usr/lib/learn/morefiles/L5.1d b/usr/lib/learn/morefiles/L5.1d
new file mode 100644 (file)
index 0000000..fbc7d3b
--- /dev/null
@@ -0,0 +1,32 @@
+#print
+How many lines of output does the command
+  cat word* | pr
+produce, as computed by "wc"?
+Type "answer N", where N is the number of lines.
+(Try to use a pipe, not a temporary file.)
+#create word1
+Now
+is
+the
+time
+#create word2
+for
+all
+good
+men
+#create word3
+to
+come
+to
+the
+aid
+of
+their
+party
+#copyin
+#user
+#uncopyin
+#match 66
+#log
+#next
+5.1e 10
diff --git a/usr/lib/learn/morefiles/L5.1e b/usr/lib/learn/morefiles/L5.1e
new file mode 100644 (file)
index 0000000..5eacc5a
--- /dev/null
@@ -0,0 +1,19 @@
+#print
+Use "ls", "pr" and a pipe to make a neat list of the files
+in this directory, sorted by time of last change.
+Do not use a temporary file.
+Type "ready" when you are done.
+#create x1
+adfasdfasdfaf
+
+#create junk
+qerqer
+#create foo
+fofofofofo
+#copyin
+#user
+#uncopyin
+grep 'ls -[l]*t.*| *pr' <.copy >/dev/null
+#log
+#next
+6.1a 10
diff --git a/usr/lib/learn/morefiles/L6.1a b/usr/lib/learn/morefiles/L6.1a
new file mode 100644 (file)
index 0000000..f0a8b9e
--- /dev/null
@@ -0,0 +1,35 @@
+#print
+Of course it is still possible to use files with "<" and ">"
+to supply input to one end of a pipeline and to
+collect the output from the other end.
+In this directory are two files whose names begin
+with "bio".  Collect the last 15 lines of these two files
+(combined) in a file called "last", then type "ready".
+#create bio1
+   Roughly speaking, your eye is made of three balls, or layers,
+fitted tightly one inside the other.  the tough white outermost
+layer's function is to protect the others.  the middle layer gives
+the front of your eye its brown, gray, or blue color.  The inside
+of this layer is dark and full of tiny blood vessels.  The innermost
+layer, called the retina, is made of very special nerve cells that
+are sensitive to light and color.  A nerve cord connects the retina
+of each eye to your brain.
+   The front of your eye's two outer layers (the cornea) is clear,
+or open, to let light enter.
+#create bio2
+   We do not know when life began on the earth, and it seems likely
+that the answer to this question will remain forever hidden from us.
+What we do know is that it was some 500 million years ago when the
+plants and animals of early geologic history had reached a stage of
+development where they produced hard parts capable of being preserved
+as fossils.
+   At this distant date there seemingly was no land life; all life
+was in the sea.  Moreover, there were no vertebrates, or backboned
+animals, living -- at least none of sufficient complexity that they
+left hard structures to be preserved in the form of fossils.
+#user
+cat bio* | tail -15 >X1
+#cmp X1 last
+#log
+#next
+6.1b 10
diff --git a/usr/lib/learn/morefiles/L6.1b b/usr/lib/learn/morefiles/L6.1b
new file mode 100644 (file)
index 0000000..e85277c
--- /dev/null
@@ -0,0 +1,128 @@
+#print
+Several of the programs we have been using as examples,
+such as "grep" and "wc", have the property that when
+you use file names with them, the output includes
+the file names.  For example, if you say
+  grep pattern file1 file2 file3
+each line that contains "pattern" is printed out
+with "file1:" or whatever in front of it.
+
+Sometimes you would love to get rid of that file name, since
+you don't care a bit where the line came from,
+and the file name clutters up the output.
+One thing is to use "cat" to collect the files, and
+pipe into "grep"; in that case "grep" doesn't mention
+any file name because there isn't one.
+
+In this directory there are several files whose names end 
+in ".x".  Use a pipeline of "cat" and "grep" to print all the lines
+that contain the letters "ion", without any identifying filenames.
+Type "ready" when you're done.
+#create 0x
+ion, but this one is in the wrong file!
+#create 1.x
+o
+o'
+oaf
+oafish
+oafishly
+oafishness
+oak
+oaken
+oaks
+oakum
+oar
+oared
+oarfish
+oarlock
+oarsman
+oases
+oasis
+oat
+oatcake
+oaten
+oath
+oaths
+oatmeal
+obbligati
+obbligato
+obbligatos
+obconic
+obcordate
+obduracy
+obdurate
+#create 2.x
+obdurately
+obdurateness
+obeah
+obedience
+obedient
+obediently
+obeisance
+obeisant
+obeli
+obelisk
+obelize
+obelus
+obese
+obesity
+obey
+obeyer
+obfuscate
+obfuscation
+obfuscatory
+obi
+obit
+obituary
+object
+objectification
+objectify
+objection
+objectionable
+objectionableness
+objectionably
+objective
+#create 3.x
+objectively
+objectiveness
+objectivism
+objectivist
+objectivistic
+objectivity
+objectless
+objector
+objurgate
+objurgation
+objurgatory
+oblanceolate
+oblast
+oblate
+oblate
+oblateness
+oblation
+obligate
+obligately
+obligation
+obligatorily
+obligatory
+oblige
+obligee
+obliger
+obliging
+obligingly
+obligingness
+obligor
+oblique
+obliquely
+obliqueness
+obliquity
+obliterate
+#copyout
+#user
+#uncopyout
+grep ion <.ocopy >X1
+cat *.x | grep ion >X2
+#cmp X1 X2
+#log
+#next
+6.1c
diff --git a/usr/lib/learn/morefiles/L6.1c b/usr/lib/learn/morefiles/L6.1c
new file mode 100644 (file)
index 0000000..5594986
--- /dev/null
@@ -0,0 +1,23 @@
+#print
+In much the same way that you used "cat" and a pipe to
+get rid of the file names from the output of "grep",
+you can use "cat" and a pipe to get rid of the sub-totals
+from "wc", if you so desire.
+What is the total number of lines in the files in
+this directory whose names begin with capital letters?
+Type "answer N", where N is the number of lines.
+#create X1
+just to make sure.
+#create Stuff
+this has some more.
+#create Junk
+asdfadfasdfasdfasdfasf
+#copyin
+#user
+#uncopyin
+cat [A-Z]* | %s/../lcount >x1
+tail -1 .copy >x2
+#cmp x1 x2
+#log
+#next
+6.1d
diff --git a/usr/lib/learn/morefiles/L6.1d b/usr/lib/learn/morefiles/L6.1d
new file mode 100644 (file)
index 0000000..47446b5
--- /dev/null
@@ -0,0 +1,56 @@
+#print
+How many of the lines in the files "bio*" and "chem*"
+contain the letters "the"?  Type "answer N", where
+N is the number of lines.
+#create bio1
+   Roughly speaking, your eye is made of three balls, or layers,
+fitted tightly one inside the other.  the tough white outermost
+layer's function is to protect the others.  the middle layer gives
+the front of your eye its brown, gray, or blue color.  The inside
+of this layer is dark and full of tiny blood vessels.  The innermost
+layer, called the retina, is made of very special nerve cells that
+are sensitive to light and color.  A nerve cord connects the retina
+of each eye to your brain.
+   The front of your eye's two outer layers (the cornea) is clear,
+or open, to let light enter.
+#create bio2
+   We do not know when life began on the earth, and it seems likely
+that the answer to this question will remain forever hidden from us.
+What we do know is that it was some 500 million years ago when the
+plants and animals of early geologic history had reached a stage of
+development where they produced hard parts capable of being preserved
+as fossils.
+   At this distant date there seemingly was no land life; all life
+was in the sea.  Moreover, there were no vertebrates, or backboned
+animals, living -- at least none of sufficient complexity that they
+left hard structures to be preserved in the form of fossils.
+#create chema
+   The baker said, "Now I shall put just the right amounts of water and
+yeast with the flour that is in the mixer.  Flour, water, and yeast
+together make the sponge.  Making sponge is the first step in making
+bread."
+   The baker closed the mixer.  Inside the machine, the flour and
+yeast and water went around and around until they were well mixed.
+Then the baker opened the mixer and the sponge dropped into a greased
+tub called a trough.
+   The baker pushed the trough into a warm room to let the sponge 
+rise.  It looked like dough, but it did not as yet have everything
+in it.
+#create chemb
+   Wash the blackboard.  Watch it dry.  The water goes into the air.
+When water goes into the air it evaporates.
+   Tie a damp cloth to one end of a stick.  Tie a bottle to the
+other end.  Put water in the bottle until the stick is level.  Watch
+the stick for a few minutes.  It does not stay level.
+   Water goes into the air when it evaporates.  It changes into
+water vapor.  You cannot see water vapor, but it is in the air all
+around you.
+   Cut a hold in the bottom of a cardboard box.  Hold the box
+against a cold window and blow into the hole.
+#copyin
+#user
+#uncopyin
+#match 30
+#log
+#next
+6.1e
diff --git a/usr/lib/learn/morefiles/L6.1e b/usr/lib/learn/morefiles/L6.1e
new file mode 100644 (file)
index 0000000..c75d50e
--- /dev/null
@@ -0,0 +1,38 @@
+#print
+By the way, you can also use "grep" to print out ___\b\b\ball ___\b\b\bbut
+those lines that contain occurrences of a pattern:
+  grep -v pat files...
+prints all the lines in files... that don't contain
+any "pat".
+How many of the lines in "bio*" don't contain "the"?
+Type "answer N", where N is the number of lines.
+#create bio1
+   Roughly speaking, your eye is made of three balls, or layers,
+fitted tightly one inside the other.  the tough white outermost
+layer's function is to protect the others.  the middle layer gives
+the front of your eye its brown, gray, or blue color.  The inside
+of this layer is dark and full of tiny blood vessels.  The innermost
+layer, called the retina, is made of very special nerve cells that
+are sensitive to light and color.  A nerve cord connects the retina
+of each eye to your brain.
+   The front of your eye's two outer layers (the cornea) is clear,
+or open, to let light enter.
+#create bio2
+   We do not know when life began on the earth, and it seems likely
+that the answer to this question will remain forever hidden from us.
+What we do know is that it was some 500 million years ago when the
+plants and animals of early geologic history had reached a stage of
+development where they produced hard parts capable of being preserved
+as fossils.
+   At this distant date there seemingly was no land life; all life
+was in the sea.  Moreover, there were no vertebrates, or backboned
+animals, living -- at least none of sufficient complexity that they
+left hard structures to be preserved in the form of fossils.
+#copyin
+#user
+#uncopyin
+#match 6
+#log
+#next
+7.1a 10
+6.2e 5
diff --git a/usr/lib/learn/morefiles/L6.2e b/usr/lib/learn/morefiles/L6.2e
new file mode 100644 (file)
index 0000000..190a33c
--- /dev/null
@@ -0,0 +1,106 @@
+#print
+How many words in the file "o" do not contain a
+slash "/"?  Type "answer N", where N is the number of words.
+#create o
+o
+o'
+oaf
+oaf/ish
+oaf/ish/ly
+oaf/ish/ness
+oak
+oak/en
+oaks
+oa/kum
+oar
+oared
+oar/fish
+oar/lock
+oars/man
+oa/ses
+oa/sis
+oat
+oat/cake
+oat/en
+oath
+oaths
+oat/meal
+ob/bli/ga/ti
+ob/bli/ga/to
+obbligatos
+ob/con/ic
+ob/cor/date
+ob/du/ra/cy
+ob/du/rate
+ob/du/rate/ly
+ob/du/rate/ness
+obe/ah
+obe/di/ence
+obe/di/ent
+obe/di/ent/ly
+obei/sance
+obei/sant
+ob/e/li
+ob/e/lisk
+ob/e/lize
+ob/e/lus
+obese
+obe/si/ty
+obey
+obey/er
+ob/fus/cate
+ob/fus/ca/tion
+ob/fus/ca/to/ry
+obi
+obit
+obit/u/ary
+ob/ject
+ob/jec/ti/fi/ca/tion
+ob/jec/ti/fy
+ob/jec/tion
+ob/jec/tion/able
+ob/jec/tion/able/ness
+ob/jec/tion/ably
+ob/jec/tive
+ob/jec/tive/ly
+ob/jec/tive/ness
+ob/jec/tiv/ism
+ob/jec/tiv/ist
+ob/jec/tiv/is/tic
+ob/jec/tiv/i/ty
+ob/ject/less
+ob/jec/tor
+ob/jur/gate
+ob/jur/ga/tion
+ob/jur/ga/to/ry
+ob/lan/ceo/late
+oblast
+ob/late
+oblate
+oblate/ness
+obla/tion
+ob/li/gate
+ob/li/gate/ly
+ob/li/ga/tion
+oblig/a/to/ri/ly
+oblig/a/to/ry
+oblige
+ob/li/gee
+oblig/er
+oblig/ing
+oblig/ing/ly
+oblig/ing/ness
+ob/li/gor
+oblique
+oblique/ly
+oblique/ness
+obliq/ui/ty
+oblit/er/ate
+oblit/er/a/tion
+#copyin
+#user
+#uncopyin
+#match 19
+#log
+#next
+7.1a
diff --git a/usr/lib/learn/morefiles/L7.1a b/usr/lib/learn/morefiles/L7.1a
new file mode 100644 (file)
index 0000000..08e7087
--- /dev/null
@@ -0,0 +1,9 @@
+#print
+Do you think that you have learned anything
+from this script?
+Answer yes or no.
+#copyin
+#user
+#uncopyin
+#match yes
+#log
diff --git a/usr/lib/learn/play/dummy b/usr/lib/learn/play/dummy
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/lib/lex/ncform b/usr/lib/lex/ncform
deleted file mode 100644 (file)
index 8ca51b4..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-int yylineno =1;
-# define YYU(x) x
-# define NLSTATE yyprevious=YYNEWLINE
-char yytext[YYLMAX];
-struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
-char yysbuf[YYLMAX];
-char *yysptr = yysbuf;
-int *yyfnd;
-extern struct yysvf *yyestate;
-int yyprevious = YYNEWLINE;
-yylook(){
-       register struct yysvf *yystate, **lsp;
-       register struct yywork *yyt;
-       struct yysvf *yyz;
-       int yych;
-       struct yywork *yyr;
-# ifdef LEXDEBUG
-       int debug;
-# endif
-       char *yylastch;
-       /* start off machines */
-# ifdef LEXDEBUG
-       debug = 0;
-# endif
-       if (!yymorfg)
-               yylastch = yytext;
-       else {
-               yymorfg=0;
-               yylastch = yytext+yyleng;
-               }
-       for(;;){
-               lsp = yylstate;
-               yyestate = yystate = yybgin;
-               if (yyprevious==YYNEWLINE) yystate++;
-               for (;;){
-# ifdef LEXDEBUG
-                       if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
-# endif
-                       yyt = yystate->yystoff;
-                       if(yyt == yycrank){             /* may not be any transitions */
-                               yyz = yystate->yyother;
-                               if(yyz == 0)break;
-                               if(yyz->yystoff == yycrank)break;
-                               }
-                       *yylastch++ = yych = input();
-               tryagain:
-# ifdef LEXDEBUG
-                       if(debug){
-                               fprintf(yyout,"char ");
-                               allprint(yych);
-                               putchar('\n');
-                               }
-# endif
-                       yyr = yyt;
-                       if ( (int)yyt > (int)yycrank){
-                               yyt = yyr + yych;
-                               if (yyt <= yytop && yyt->verify+yysvec == yystate){
-                                       if(yyt->advance+yysvec == YYLERR)       /* error transitions */
-                                               {unput(*--yylastch);break;}
-                                       *lsp++ = yystate = yyt->advance+yysvec;
-                                       goto contin;
-                                       }
-                               }
-# ifdef YYOPTIM
-                       else if((int)yyt < (int)yycrank) {              /* r < yycrank */
-                               yyt = yyr = yycrank+(yycrank-yyt);
-# ifdef LEXDEBUG
-                               if(debug)fprintf(yyout,"compressed state\n");
-# endif
-                               yyt = yyt + yych;
-                               if(yyt <= yytop && yyt->verify+yysvec == yystate){
-                                       if(yyt->advance+yysvec == YYLERR)       /* error transitions */
-                                               {unput(*--yylastch);break;}
-                                       *lsp++ = yystate = yyt->advance+yysvec;
-                                       goto contin;
-                                       }
-                               yyt = yyr + YYU(yymatch[yych]);
-# ifdef LEXDEBUG
-                               if(debug){
-                                       fprintf(yyout,"try fall back character ");
-                                       allprint(YYU(yymatch[yych]));
-                                       putchar('\n');
-                                       }
-# endif
-                               if(yyt <= yytop && yyt->verify+yysvec == yystate){
-                                       if(yyt->advance+yysvec == YYLERR)       /* error transition */
-                                               {unput(*--yylastch);break;}
-                                       *lsp++ = yystate = yyt->advance+yysvec;
-                                       goto contin;
-                                       }
-                               }
-                       if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
-# ifdef LEXDEBUG
-                               if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
-# endif
-                               goto tryagain;
-                               }
-# endif
-                       else
-                               {unput(*--yylastch);break;}
-               contin:
-# ifdef LEXDEBUG
-                       if(debug){
-                               fprintf(yyout,"state %d char ",yystate-yysvec-1);
-                               allprint(yych);
-                               putchar('\n');
-                               }
-# endif
-                       ;
-                       }
-# ifdef LEXDEBUG
-               if(debug){
-                       fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
-                       allprint(yych);
-                       putchar('\n');
-                       }
-# endif
-               while (lsp-- > yylstate){
-                       *yylastch-- = 0;
-                       if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
-                               yyolsp = lsp;
-                               if(yyextra[*yyfnd]){            /* must backup */
-                                       while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
-                                               lsp--;
-                                               unput(*yylastch--);
-                                               }
-                                       }
-                               yyprevious = YYU(*yylastch);
-                               yylsp = lsp;
-                               yyleng = yylastch-yytext+1;
-                               yytext[yyleng] = 0;
-# ifdef LEXDEBUG
-                               if(debug){
-                                       fprintf(yyout,"\nmatch ");
-                                       sprint(yytext);
-                                       fprintf(yyout," action %d\n",*yyfnd);
-                                       }
-# endif
-                               return(*yyfnd++);
-                               }
-                       unput(*yylastch);
-                       }
-               if (yytext[0] == 0  /* && feof(yyin) */)
-                       {
-                       yysptr=yysbuf;
-                       return(0);
-                       }
-               yyprevious = yytext[0] = input();
-               if (yyprevious>0)
-                       output(yyprevious);
-               yylastch=yytext;
-# ifdef LEXDEBUG
-               if(debug)putchar('\n');
-# endif
-               }
-       }
-yyback(p, m)
-       int *p;
-{
-if (p==0) return(0);
-while (*p)
-       {
-       if (*p++ == m)
-               return(1);
-       }
-return(0);
-}
-       /* the following are only used in the lex library */
-yyinput(){
-       return(input());
-       }
-yyoutput(c)
-  int c; {
-       output(c);
-       }
-yyunput(c)
-   int c; {
-       unput(c);
-       }
diff --git a/usr/lib/lib.b b/usr/lib/lib.b
new file mode 100644 (file)
index 0000000..e09bf26
--- /dev/null
@@ -0,0 +1,192 @@
+scale = 20
+define e(x){
+       auto a, b, c, d, e, g, w, y
+
+       t = scale
+       scale = t + .434*x + 1
+
+       w = 0
+       if(x<0){
+               x = -x
+               w = 1
+       }
+       y = 0
+       while(x>2){
+               x = x/2
+               y = y + 1
+       }
+
+       a=1
+       b=1
+       c=b
+       d=1
+       e=1
+       for(a=1;1==1;a++){
+               b=b*x
+               c=c*a+b
+               d=d*a
+               g = c/d
+               if(g == e){
+                       g = g/1
+                       while(y--){
+                               g = g*g
+                       }
+                       scale = t
+                       if(w==1) return(1/g)
+                       return(g/1)
+               }
+               e=g
+       }
+}
+
+define l(x){
+       auto a, b, c, d, e, f, g, u, s, t
+       if(x <=0) return(1-10^scale)
+       t = scale
+
+       f=1
+       scale = scale + scale(x) - length(x) + 1
+       s=scale
+       while(x > 2){
+               s = s + (length(x)-scale(x))/2 + 1
+               if(s>0) scale = s
+               x = sqrt(x)
+               f=f*2
+       }
+       while(x < .5){
+               s = s + (length(x)-scale(x))/2 + 1
+               if(s>0) scale = s
+               x = sqrt(x)
+               f=f*2
+       }
+
+       scale = t + length(f) - scale(f) + 1
+       u = (x-1)/(x+1)
+
+       scale = scale + 1.1*length(t) - 1.1*scale(t)
+       s = u*u
+       b = 2*f
+       c = b
+       d = 1
+       e = 1
+       for(a=3;1==1;a=a+2){
+               b=b*s
+               c=c*a+d*b
+               d=d*a
+               g=c/d
+               if(g==e){
+                       scale = t
+                       return(u*c/d)
+               }
+               e=g
+       }
+}
+
+define s(x){
+       auto a, b, c, s, t, y, p, n, i
+       t = scale
+       y = x/.7853
+       s = t + length(y) - scale(y)
+       if(s<t) s=t
+       scale = s
+       p = a(1)
+
+       scale = 0
+       if(x>=0) n = (x/(2*p)+1)/2
+       if(x<0) n = (x/(2*p)-1)/2
+       x = x - 4*n*p
+       if(n%2!=0) x = -x
+
+       scale = t + length(1.2*t) - scale(1.2*t)
+       y = -x*x
+       a = x
+       b = 1
+       s = x
+       for(i=3; 1==1; i=i+2){
+               a = a*y
+               b = b*i*(i-1)
+               c = a/b
+               if(c==0){scale=t; return(s/1)}
+               s = s+c
+       }
+}
+
+define c(x){
+       auto t
+       t = scale
+       scale = scale+1
+       x = s(x+2*a(1))
+       scale = t
+       return(x/1)
+}
+
+define a(x){
+       auto a, b, c, d, e, f, g, s, t
+       if(x==0) return(0)
+       if(x==1)
+               if(scale<52)
+return(.7853981633974483096156608458198757210492923498437764/1)
+       t = scale
+       f=1
+       while(x > .5){
+               scale = scale + 1
+               x= -(1-sqrt(1.+x*x))/x
+               f=f*2
+       }
+       while(x < -.5){
+               scale = scale + 1
+               x = -(1-sqrt(1.+x*x))/x
+               f=f*2
+       }
+       s = -x*x
+       b = f
+       c = f
+       d = 1
+       e = 1
+       for(a=3;1==1;a=a+2){
+               b=b*s
+               c=c*a+d*b
+               d=d*a
+               g=c/d
+               if(g==e){
+                       scale = t
+                       return(x*c/d)
+               }
+               e=g
+       }
+}
+
+define j(n,x){
+auto a,b,c,d,e,g,i,s,k,t
+
+       t = scale
+       k = 1.36*x + 1.16*t - n
+       k = length(k) - scale(k)
+       if(k>0) scale = scale + k
+
+s= -x*x/4
+if(n<0){
+       n= -n
+       x= -x
+       }
+a=1
+c=1
+for(i=1;i<=n;i++){
+       a=a*x
+       c = c*2*i
+       }
+b=a
+d=1
+e=1
+for(i=1;1;i++){
+       a=a*s
+       b=b*i*(n+i) + a
+       c=c*i*(n+i)
+       g=b/c
+       if(g==e){
+               scale = t
+               return(g/1)
+               }
+       e=g
+       }
+}
diff --git a/usr/lib/llib-lc b/usr/lib/llib-lc
deleted file mode 100644 (file)
index 2e136c3..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-       /* LINTLIBRARY */
-#include <stdio.h>
-#include <sgtty.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <time.h>
-int    errno;
-int    alarm(s) unsigned s; { return(s); }
-char   *brk(a) char *a; { return(a); }
-int    chdir(s) char *s; { return(0); }
-int    chmod(s, m) char *s; { return(0); }
-int    chown(s, u, g) char *s; { return(0); }
-int    close(f) { return(0); }
-int    creat(s, m) char *s; { return(0); }
-int    dup(f) { return(f); }
-       /* VARARGS */
-       execl(f, a) char *f, *a; {;}
-       execv(s, v) char *s, *v[]; {;}
-       exit(s) {;}
-int    fork() { return(0); }
-int    fstat(f, b) struct stat *b; { return(0); }
-int    getgid() { return(1); }
-int    getegid() { return(1); }
-int    getpid() { return(1); }
-int    getuid() { return(1); }
-int    geteuid() { return(1); }
-int    gtty(f, b) struct sgttyb *b; { return(0); }
-int    kill(p, s) { return(0); }
-int    link(a, b) char *a, *b; { return(0); }
-long   lseek(f, o, d) long o; { return(0); }
-int    mknod(n, m, a) char *n; { return(0); }
-char   *mktemp(p) char *p; { return(p);}
-int    mount(s, n, f) char *s, *n; { return(0); }
-int    nice(p) { return(0); }
-int    open(f, m) char *f; { return(0); }
-       pause() {;}
-int    pipe(f) int f[2]; { return(0); }
-       profil(b, s, o, i) char *b; {;}
-int    ptrace(r, p, a, d) { return(0); }
-int    read(f, b, l) char *b; { return(l); }
-char   *sbrk(i) { return((char *)0); }
-int    seek(f, o, p) { return(0); }
-int    setgid(g) { return(0); }
-int    setuid(u) { return(0); }
-int    (*signal(c, f))() int (*f)(); { return(f); }
-int    stat(s, b) char *s; struct stat *b; { return(0); }
-char   *strcat(a, b) char *a, *b; { ; }
-int    strcmp(a, b) char *a, *b; { return(1); }
-char   *strcpy(a, b) char *a, *b; { ; }
-int    strlen(s) char *s; { return(1); }
-int    stty(f, b) struct sgttyb *b; { return(0); }
-long   tell(f) { return((long)0); }
-int    system(s) char *s; { return(0); }
-time_t time(t) time_t *t; { return( 0 );}
-int    unlink(s) char *s; { return(0); }
-int    wait(s) int *s; { return(1); }
-int    write(f, b, l) char *b; { return(l); }
-char   *calloc(n,s) unsigned n, s; { static char c[1]; return(c); }
-char   *malloc(n) unsigned n; {static char c; return(&c);}
-char   *realloc(p, n) char *p; unsigned n; { static char c; return(&c);}
-       free(p) char *p; {;}
-       fclose(f) FILE *f; {return(0);}
-       fflush(f) FILE *f; {return(0);}
-char   *fgets( s, l, f ) char *s; FILE *f; { return(s); }
-FILE   *fopen(s,m) char *s, *m; { return(stdin); }
-FILE   *freopen(s, m, f) char *s, *m; FILE *f; { return(stdin); }
-FILE   *fdopen(fd, m) char *m; { return(stdin);}
-       /* VARARGS */
-       fprintf( f, s ) FILE *f; char *s; {;}
-       fputs(s,f) char *s; FILE *f; {;}
-       fread( p, s, n, f ) char *p; FILE *f; {return(1);}
-       /* VARARGS */
-       fscanf( f, s ) FILE *f; char *s; {return(1);}
-int    fwrite( p, s, n, f ) char *p; FILE *f; {return(0);}
-       intss(){return(1); }
-       /* VARARGS */
-       printf( s ) char *s; {;}
-       rewind(f) FILE *f; {;}
-       /* VARARGS */
-       scanf( f ) char *f; {return(1); }
-       setbuf( f, b ) FILE *f; char *b; {;}
-       /* VARARGS */
-char   *sprintf( s, f ) char *s, *f; { return(s);}
-       /* VARARGS */
-       sscanf( s, f ) char *s, *f; { return(1); }
-       ungetc( c, f ) FILE *f; {  return(c); }
-char   *ctime(c) time_t *c;{ return(""); }
-struct tm *localtime(c) time_t *c; { return localtime(c); }
-struct tm *gmtime(c) time_t *c; { return gmtime(c); }
-char   *asctime(t) struct tm *t; { return(""); }
-       abort() {}
-int    abs(i) int i; { return(i); }
-double atof(s) char *s; { return(1.); }
-char   *crypt(k,s) char *k, *s; { return(""); }
-       setkey(k) char *k; {}
-       encrypt(s, i) char *s; {}
-char   *ecvt(v, n, d, s) double v; int *d, *s; { return(""); }
-char   *fcvt(v, n, d, s) double v; int *d, *s; { return(""); }
-char   *gcvt(v, n, b) double v; char *b; { return(""); }
-       monitor(l, h, b, s, n) int (*l)(), (*h)(); short *b; {}
-       perror(s) char *s; {}
-#include <setjmp.h>
-       setjmp(e) jmp_buf e; { return(0); }
-       sleep(i) unsigned i; {}
-struct _iobuf _iob[_NFILE];
-char   _ctype_[];
diff --git a/usr/lib/llib-lm b/usr/lib/llib-lm
deleted file mode 100644 (file)
index 3f78314..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*LINTLIBRARY*/
-#include <math.h>
-double acos(x)double x;{return x;}
-double asin(x)double x;{return x;}
-double atan(x)double x;{return x;}
-double atan2(x,y)double x,y;{return x;}
-double ceil(x)double x;{return x;}
-double cos(x)double x;{return x;}
-double cosh(x)double x;{return x;}
-double erf(x)double x;{return x;}
-double erfc(x)double x;{return x;}
-double exp(x)double x;{return x;}
-double fabs(x)double x;{return x;}
-double floor(x)double x;{return x;}
-double fmod(x,y)double x,y;{return x;}
-double gamma(x)double x;{return x;}
-double hypot(x,y)double x,y;{return x;}
-double j0(x)double x;{return x;}
-double j1(x)double x;{return x;}
-double jn(n,x)int n;double x;{return x;}
-double log(x)double x;{return x;}
-double log10(x)double x;{return x;}
-double pow(x,y)double x,y;{return x;}
-double sin(x)double x;{return x;}
-double sinh(x)double x;{return x;}
-double sqrt(x)double x;{return x;}
-double tan(x)double x;{return x;}
-double tanh(x)double x;{return x;}
-double y0(x)double x;{return x;}
-double y1(x)double x;{return x;}
-double yn(n,x)int n;double x;{return x;}
old mode 100644 (file)
new mode 100755 (executable)
index c4773af..303de3b
@@ -41,4 +41,4 @@ char  *sprintf( s, f ) char *s, *f; { return(s);}
        ungetc( c, f ) FILE *f; {  return(c); }
        wdleng(){return(0); }
 struct _iobuf _iob[_NFILE];
        ungetc( c, f ) FILE *f; {  return(c); }
        wdleng(){return(0); }
 struct _iobuf _iob[_NFILE];
-char   _ctype_[129];
+char   _ctype_[];
index cbe2af2..2eae178 100644 (file)
 .nr LL \\n(.l
 .ds ]H \\$1\|(\|\\$2\|)
 .ds ]D UNIX Programmer's Manual
 .nr LL \\n(.l
 .ds ]H \\$1\|(\|\\$2\|)
 .ds ]D UNIX Programmer's Manual
-.ds ]L \\$3
 .wh 0 }H
 .if t .wh -1i }F
 .if n .wh -1.167i }F
 .em }M
 .if \\n(nl .bp 1
 .wh 0 }H
 .if t .wh -1i }F
 .if n .wh -1.167i }F
 .em }M
 .if \\n(nl .bp 1
+.ds ]L \\$3
 .}E
 .DT
 .nr )I .5i
 .}E
 .DT
 .nr )I .5i
index 3b5d0e2..a6222e8 100644 (file)
@@ -5,10 +5,6 @@
 .if !\\n(IK .if !\\n(IF .if !\\n(IX .if !\\n(BE .di
 .ce 0
 .ul 0
 .if !\\n(IK .if !\\n(IF .if !\\n(IX .if !\\n(BE .di
 .ce 0
 .ul 0
-.if \\n(QP \{\
-.      ll +\\n(QIu
-.      in -\\n(QIu
-.      nr QP -1\}
 .if \\n(NX<=1 .if \\n(AJ=0 .ll \\n(LLu
 .if \\n(IF=0 \{\
 .      ps \\n(PS
 .if \\n(NX<=1 .if \\n(AJ=0 .ll \\n(LLu
 .if \\n(IF=0 \{\
 .      ps \\n(PS
 .if \\n(IP .in -\\n(I\\n(IRu
 .if \\n(IP=0 .nr I0 \\n(PIu
 .if \\n(IP .nr IP -1
 .if \\n(IP .in -\\n(I\\n(IRu
 .if \\n(IP=0 .nr I0 \\n(PIu
 .if \\n(IP .nr IP -1
+.if \\n(QP \{\
+.      ll +\\n(QIu
+.      in -\\n(QIu
+.      nr QP -1\}
 .ft 1
 .bd 1
 .ta 5n 10n 15n 20n 25n 30n 35n 40n 45n 50n 55n 60n 65n 70n 75n 80n
 .ft 1
 .bd 1
 .ta 5n 10n 15n 20n 25n 30n 35n 40n 45n 50n 55n 60n 65n 70n 75n 80n
 .rm RA
 .rm TM
 ..
 .rm RA
 .rm TM
 ..
-.      \" LT - letter
-.de LT
-.LP
-.rs
-.sp 6
-.ll 80n
-.ti 48
-\\*(DY
-.ll
-.br
-.sp 3
-..
 .de OK
 .br
 .di
 .de OK
 .br
 .di
 .nf
 .sp 3
 .ls 1
 .nf
 .sp 3
 .ls 1
-.pn 2
 .WB
 .ls 
 .sp 3v
 .WB
 .ls 
 .sp 3v
@@ -542,12 +529,6 @@ Computing Science Technical Report No. \\*(MN
 .nr TQ \\n(.i
 .nr HT 1
 .in 0
 .nr TQ \\n(.i
 .nr HT 1
 .in 0
-.mk #a
-.mk #b
-.mk #c
-.mk #d
-.mk #e
-.mk #f
 .TT
 .in \\n(TQu
 .mk #T
 .TT
 .in \\n(TQu
 .mk #T
@@ -568,18 +549,141 @@ Computing Science Technical Report No. \\*(MN
 .rr a| b| c| d| e| f| g| h| i| j| k| l| m|
 .rr a- b- c- d- e- f- g- h- i- j- k- l- m-
 ..
 .rr a| b| c| d| e| f| g| h| i| j| k| l| m|
 .rr a- b- c- d- e- f- g- h- i- j- k- l- m-
 ..
-.so /usr/lib/tmac/tmac.sdisp
+.      \"DS - display.  If .DS C, center; L, left-adjust; I, indent.
+.de DS
+.XD
+.KS
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.ps \\n(PS
+.if \\n(VS>40 .vs \\n(VSu
+.if \\n(VS<=39 .vs \\n(VSp
+..
+.de D
+.ID \\$1
+..
+.de CD
+.ce 1000
+..
+.de ID
+.if t .in +0.5i
+.if n .in +8
+.if \\n(.$ .if !"\\$1"I" .in \\n(OIu
+.if \\n(.$ .if !"\\$1"I" .in +\\$1n
+..
+.de LD
+..
+.de XD
+.nf
+.nr OI \\n(.i
+.if t .sp 0.5
+.if n .sp 1
+..
+.de BD \" block display: save everything, then center it.
+.nr BD 1
+.nf
+.di DD
+..
+.      \"DE - display end
+.de DE
+.ce 0
+.if \\n(BD>0 .DF
+.nr BD 0
+.KE
+.in \\n(OIu
+.if t .sp 0.5
+.if n .sp 1
+.fi
+..
+.de DF \" finish a block display to be recentered.
+.di
+.if \\n(dl>\\n(BD .nr BD \\n(dl
+.if \\n(BD<\\n(.l .in (\\n(.lu-\\n(BDu)/2u
+.nr EI \\n(.l-\\n(.i
+.ta \\n(EIuR
+.DD
+.in \\n(OIu
+..
+.      \"KS keep - for keep release features. As in IFM
 .de KS
 .de KS
-.so /usr/lib/tmac/tmac.skeep
-.]K
-.rn ]J KF
-.rn ]K KS
+.nr KN \\n(.u
+.if \\n(IK=0 .if \\n(IF=0 .KQ
+.nr IK +1
 ..
 ..
+.      \"KQ - real keep processor
+.de KQ
+.br
+.nr KI \\n(.i
+.ev 2
+.br
+.in \\n(KIu
+.ps \\n(PS
+.if \\n(VS>40 .vs \\n(VSu
+.if \\n(VS<=39 .vs \\n(VSp
+.ll \\n(LLu
+.lt \\n(LTu
+.if \\n(NX>1 .ll \\n(CWu
+.if \\n(NX>1 .lt \\n(CWu
+.di KK
+.nr TB 0
+..
+.      \"KF - floating keep
 .de KF
 .de KF
-.so /usr/lib/tmac/tmac.skeep
-.]J
-.rn ]K KS
-.rn ]J KF
+.nr KN \\n(.u
+.if !\\n(IK .FQ
+.nr IK +1
+..
+.      \"FQ real floating keep processor
+.de FQ
+.nr KI \\n(.i
+.ev 2
+.br
+.in \\n(KIu
+.ps \\n(PS
+.if \\n(VS>40 .vs \\n(VSu
+.if \\n(VS<=39 .vs \\n(VSp
+.ll \\n(LLu
+.lt \\n(LTu
+.if \\n(NX>1 .ll \\n(CWu
+.if \\n(NX>1 .lt \\n(CWu
+.di KK
+.nr TB 1
+..
+.      \"KE release - everything between keep and release is together
+.de KE
+.if \\n(IK .if !\\n(IK-1 .if \\n(IF=0 .RQ
+.if \\n(IK .nr IK -1
+..
+.      \"RQ real release
+.de RQ
+.br
+.di
+.nr NF 0
+.if \\n(dn-\\n(.t .nr NF 1
+.if \\n(TC .nr NF 1
+.if \\n(NF .if !\\n(TB .sp 200
+.if !\\n(NF .if \\n(TB .nr TB 0
+.nf
+.rs
+.nr TC 5
+.in 0
+.ls 1
+.if \\n(TB=0 .ev
+.if \\n(TB=0 .br
+.if \\n(TB=0 .ev 2
+.if \\n(TB=0 .KK
+.ls
+.ce 0
+.if \\n(TB=0 .rm KK
+.if \\n(TB .da KJ
+.if \\n(TB \!.KD \\n(dn
+.if \\n(TB .KK
+.if \\n(TB .di
+.nr TC \\n(TB
+.if \\n(KN .fi
+.in
+.ev
 ..
 .de EQ  \"equation, breakout and display
 .nr EF \\n(.u
 ..
 .de EQ  \"equation, breakout and display
 .nr EF \\n(.u
@@ -607,11 +711,11 @@ Computing Science Technical Report No. \\*(MN
 .if "\\n(.z"" .if \\n(ZN>0 .if !\\n(nl=\\n(PE .if n .sp 1
 .if !"\\n(.z"" .if \\n(ZN>0 .if !\\n(.d=\\n(PE .if t .sp .5
 .if !"\\n(.z"" .if \\n(ZN>0 .if !\\n(.d=\\n(PE .if n .sp 1
 .if "\\n(.z"" .if \\n(ZN>0 .if !\\n(nl=\\n(PE .if n .sp 1
 .if !"\\n(.z"" .if \\n(ZN>0 .if !\\n(.d=\\n(PE .if t .sp .5
 .if !"\\n(.z"" .if \\n(ZN>0 .if !\\n(.d=\\n(PE .if n .sp 1
-'pc
+.pc
 .if \\n(BD>0 .nr LE 0 \" can't mean centering in this case.
 .if \\n(MK>0 .if \\n(LE=1 .ds EE \\h'|10n'
 .if \\n(MK>0 .nr LE 0 \" don't center if mark/lineup
 .if \\n(BD>0 .nr LE 0 \" can't mean centering in this case.
 .if \\n(MK>0 .if \\n(LE=1 .ds EE \\h'|10n'
 .if \\n(MK>0 .nr LE 0 \" don't center if mark/lineup
-'lt \\n(.lu
+.lt \\n(.lu
 .if \\n(EP=0 .if \\n(ZN>0 .if \\n(LE>0 .tl \(ts\(ts\\*(10\(ts\\*(EL\(ts
 .if \\n(EP=0 .if \\n(ZN>0 .if \\n(LE=0 .if \\n(BD=0 .tl \(ts\\*(EE\\*(10\(ts\(ts\\*(EL\(ts
 .if \\n(EP=0 .if \\n(ZN>0 .if \\n(LE=0 .if \\n(BD>0 .if \\n(BD<\\w\(ts\\*(10\(ts .nr BD \\w\(ts\\*(10\(ts
 .if \\n(EP=0 .if \\n(ZN>0 .if \\n(LE>0 .tl \(ts\(ts\\*(10\(ts\\*(EL\(ts
 .if \\n(EP=0 .if \\n(ZN>0 .if \\n(LE=0 .if \\n(BD=0 .tl \(ts\\*(EE\\*(10\(ts\(ts\\*(EL\(ts
 .if \\n(EP=0 .if \\n(ZN>0 .if \\n(LE=0 .if \\n(BD>0 .if \\n(BD<\\w\(ts\\*(10\(ts .nr BD \\w\(ts\\*(10\(ts
@@ -625,8 +729,8 @@ Computing Science Technical Report No. \\*(MN
 .\".br \" GCOS patch
 .\".di \" GCOS patch
 .\".rm EZ \" GCOS patch
 .\".br \" GCOS patch
 .\".di \" GCOS patch
 .\".rm EZ \" GCOS patch
-'lt \\n(LLu
-'pc %
+.lt \\n(LLu
+.pc %
 .if \\n(YE>0 .if \\n(EF>0 .fi
 .rm EL 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 .rr 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 .if \\n(YE>0 .if \\n(EF>0 .fi
 .rm EL 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 .rr 10 11 12 13 14 15 16 17 18 19 20 21 22 23
@@ -1030,12 +1134,9 @@ Piscataway, New Jersey 08854
 .if !\\n(IP .nr IP +1
 .sp \\n(PDu
 .ne 3
 .if !\\n(IP .nr IP +1
 .sp \\n(PDu
 .ne 3
-.if \\n(.$=3 .nr I\\n(IR \\$3n
-.if \\n(.$=4 .nr I\\n(IR \\$4n
-.nr J\\n(IR \\n(IRu/2u
-.if \\n(.$=4 .nr J\\n(IR \\$3n
+.if \\n(.$-2 .nr I\\n(IR \\$3n
 .in +\\n(I\\n(IRu
 .in +\\n(I\\n(IRu
-.ta \\n(J\\n(IRu \\n(I\\n(IRu
+.ta \\n(I\\n(IRu/2u \\n(I\\n(IRu
 .ti -\\n(I\\n(IRu
 \0\\$1\t\\$2\t\c
 ..
 .ti -\\n(I\\n(IRu
 \0\\$1\t\\$2\t\c
 ..
@@ -1056,7 +1157,7 @@ Piscataway, New Jersey 08854
 .nr IS \\n(IP
 .RT
 .nr IP \\n(IS
 .nr IS \\n(IP
 .RT
 .nr IP \\n(IS
-.if \\n(IR>0 .nr IR -1
+.nr IR -1
 .if \\n(IP<=0 .in -\\n(I\\n(IRu
 ..
 .de TC
 .if \\n(IP<=0 .in -\\n(I\\n(IRu
 ..
 .de TC
@@ -1104,7 +1205,7 @@ Piscataway, New Jersey 08854
 .if t .ft 2
 .if "\\$1"" .if n .ul 1000
 .if !"\\$1"" .if n .ul 1
 .if t .ft 2
 .if "\\$1"" .if n .ul 1000
 .if !"\\$1"" .if n .ul 1
-.if t .if !"\\$1"" \&\\$1\|\\f\\n(PQ\\$2
+.if t .if !"\\$1"" \&\\$1\\f\\n(PQ\\$2
 .if n .if \\n(.$=1 \&\\$1
 .if n .if \\n(.$>1 \&\\$1\\c
 .if n .if \\n(.$>1 \\&\\$2
 .if n .if \\n(.$=1 \&\\$1
 .if n .if \\n(.$>1 \&\\$1\\c
 .if n .if \\n(.$>1 \\&\\$2
@@ -1115,8 +1216,7 @@ Piscataway, New Jersey 08854
 ..
 .      \"SM - make smaller size
 .de SM
 ..
 .      \"SM - make smaller size
 .de SM
-.if \\n(.$>0 \&\\$3\s-2\\$1\s0\\$2
-.if \\n(.$=0 .ps -2
+.ps -2
 ..
 .      \"LG - make larger size
 .de LG
 ..
 .      \"LG - make larger size
 .de LG
@@ -1272,7 +1372,13 @@ Naperville, Illinois 60540
 .ds v \\k:\\h'+\\w'e'u/4u'\\v'-0.6m'\\s6v\\s0\\v'0.6m'\\h'|\\n:u'
 .              \" cedilla
 .ds , \\k:\\h'\\w'c'u*0.4u'\\z,\\h'|\\n:u'
 .ds v \\k:\\h'+\\w'e'u/4u'\\v'-0.6m'\\s6v\\s0\\v'0.6m'\\h'|\\n:u'
 .              \" cedilla
 .ds , \\k:\\h'\\w'c'u*0.4u'\\z,\\h'|\\n:u'
-.so /usr/lib/tmac/tmac.srefs
+.de []
+.][ \\$1
+..
+.de ][
+.if \\$1>5 .tm Bad arg to []
+.[\\$1
+..
 .if n .ds [. [
 .if t .ds [. \s-2\v'-.4m'\f1
 .if n .ds .] ]
 .if n .ds [. [
 .if t .ds [. \s-2\v'-.4m'\f1
 .if n .ds .] ]
@@ -1281,6 +1387,107 @@ Naperville, Illinois 60540
 .if n .ds [c ""
 .if t .ds [o ``
 .if t .ds [c ''
 .if n .ds [c ""
 .if t .ds [o ``
 .if t .ds [c ''
+.de [5 \" tm style
+.FS
+.IP "\\*([F.\0"
+\\*([A, \\f2\\*([T\\f1,
+.ie \\n(TN \\*([M.
+.el Bell Laboratories internal memorandum (\\*([D).
+.RT
+.FE
+..
+.de [0 \" other
+.FS
+.IP "\\*([F.\0"
+.if !"\\*([A"" \\*([A,
+.if !"\\*([T"" \\f2\\*([T\\f1\c
+.if !"\\*([T"" .if !"\\*([O"" ,\ 
+.ie !"\\*([O"" \\*([O
+.el .if !"\\*([T"" \&.
+.if !"\\*([D"" \\*([D.
+.RT
+.FE
+..
+.de [1 \" journal article
+.FS
+.IP "\\*([F.\0"
+\\*([A,
+.if !"\\*([T"" \\*([o\\*([T,\\*([c
+.if "\\*([V"" \\f2\\*([J\\f1,
+.if !"\\*([V"" \\f2\\*([J\\f1
+.if !"\\*([V"" \{.if n Vol.\&
+\\f3\\*([V\\f1\c\}
+.if !"\\*([N"" (\\*([N)\c
+.if !"\\*([P"" \{\
+.ie \\n([P>0 \ pp.\&
+.el \ p.\&
+\\*([P\}
+.if !"\\*([I"" .if "\\*([R"" \\*([I,
+(\\*([D).
+.if !"\\*([O"" \\*([O
+.RT
+.FE
+..
+.de [2 \" book
+.FS
+.IP "\\*([F.\0"
+\\*([A, \\f2\\*([T,\\f1
+\\*([I\c
+.if !"\\*([C"" , \\*([C\c
+ (\\*([D).
+.if !"\\*([G"" Gov't. ordering no. \\*([G
+.if !"\\*([O"" \\*([O
+.RT
+.FE
+..
+.de [4 \" report
+.FS
+.IP "\\*([F.\0"
+\\*([A, \\*([o\\*([T,\\*([c
+\\*([R\c
+.if !"\\*([G"" \& (\\*([G)\c
+.if !"\\*([I"" ,  \\*([I\c
+.if !"\\*([C"" ,  \\*([C\c
+ (\\*([D).
+.if !"\\*([O"" \\*([O
+.RT
+.FE
+..
+.de [3 \" article in book
+.FS
+.IP "\\*([F.\0"
+\\*([A, \\*([o\\*([T,\\*([c
+.if !"\\*([P"" pp. \\*([P
+in \\f2\\*([B\\f1, \c
+.if !"\\*([E"" ed. \\*([E,\c
+.if !"\\*([I"" \\*([I\c
+.if !"\\*([C"" ,  \\*([C\c
+ (\\*([D).
+.if !"\\*([O"" \\*([O
+.RT
+.FE
+..
+.de [<
+.]<
+..
+.de ]<
+.SH
+References
+.LP
+.rm FS FE
+..
+.de [>
+.]>
+..
+.de ]>
+.sp
+..
+.de [-
+.]-
+..
+.de ]-
+.rm [V [P [A [T [N [C [B [O [R [I [E [D
+..
 .de UX
 .ie \\n(GA>0 \\$2\s-2UNIX\s0\\$1
 .el \{\
 .de UX
 .ie \\n(GA>0 \\$2\s-2UNIX\s0\\$1
 .el \{\
@@ -1301,9 +1508,9 @@ operating system
 ..
 .de QS
 .br
 ..
 .de QS
 .br
-.LP
 .in +\\n(QIu
 .ll -\\n(QIu
 .in +\\n(QIu
 .ll -\\n(QIu
+.LP
 ..
 .de QE
 .br
 ..
 .de QE
 .br
index 2357590..45950b3 100644 (file)
 ..
 .de [0 \" other
 .FS
 ..
 .de [0 \" other
 .FS
-.nr [: 0
-.if !"\\*([F"" .IP "\\*([F.\0"
-.if !"\\*([A"" \{.nr [: 1
-\\*([A\c\}
-.if !"\\*([T"" \{.if \\n([:>0 ,
-.nr [: 1
-\\f2\\*([T\\f1\c\}
-.if !"\\*([O""\{.if \\n([:>0 ,
-.nr [: 1
-.if \\n([O>0 .nr [: 0
-\\*([O\c
-.if \\n([O>0 \& \c\}
-.ie !"\\*([D"" \{.if \\n([:>0 ,
-.nr [: 1
-\\*([D\c\}
-.if \\n([:>0 \&.
+.IP "\\*([F.\0"
+.if !"\\*([A"" \\*([A,
+.if !"\\*([T"" \\f2\\*([T\\f1\c
+.if !"\\*([T"" .if !"\\*([O"" ,\ 
+.ie !"\\*([O"" \\*([O
+.el .if !"\\*([T"" \&.
+.if !"\\*([D"" \\*([D.
 .RT
 .FE
 ..
 .de [1 \" journal article
 .FS
 .RT
 .FE
 ..
 .de [1 \" journal article
 .FS
-.if !"\\*([F"" .IP "\\*([F.\0"
-.if !"\\*([A"" \\*([A,
+.IP "\\*([F.\0"
+\\*([A,
 .if !"\\*([T"" \\*([o\\*([T,\\*([c
 .if !"\\*([T"" \\*([o\\*([T,\\*([c
-\\f2\\*([J\\f1\c
-.if !"\\*([V"" .if n \& Vol.\&\c
-.if !"\\*([V"" \& \\f3\\*([V\\f1\c
+.if !"\\*([V"" .if t \\f2\\*([J\\f1
+.if "\\*([V"" .if t \\f2\\*([J\\f1,
+.if n \\f2\\*([J\\f1,
+.el \\f2\\*([J\\f1,
+.if !"\\*([V"" \{.if n Vol.\&
+\\f3\\*([V\\f1\c
+.if n ,\}
 .if !"\\*([N"" (\\*([N)\c
 .if !"\\*([P"" \{\
 .if !"\\*([N"" (\\*([N)\c
 .if !"\\*([P"" \{\
-.ie \\n([P>0 , pp.\c
-.el , p.\c
-\\*([P\c\}
-.if !"\\*([I"" .if "\\*([R"" , \\*([I\c
-.if !"\\*([O"" .if \\n([O=0 , \\*([O\c
-.if !"\\*([D"" \& (\\*([D)\c
-\&.
-.if !"\\*([O"" .if \\n([O>0  \\*([O
+.ie \\n([P>0 \ pp.\&
+.el \ p.\&
+\\*([P\}
+.if !"\\*([I"" .if "\\*([R"" \\*([I,
+(\\*([D).
+.if !"\\*([O"" \\*([O
 .RT
 .FE
 ..
 .de [2 \" book
 .FS
 .RT
 .FE
 ..
 .de [2 \" book
 .FS
-.if !"\\*([F"" .IP "\\*([F.\0"
-.if !"\\*([A"" \\*([A,
-.if !"\\*([T"" \\f2\\*([T,\\f1
+.IP "\\*([F.\0"
+\\*([A, \\f2\\*([T,\\f1
 \\*([I\c
 .if !"\\*([C"" , \\*([C\c
 \\*([I\c
 .if !"\\*([C"" , \\*([C\c
-.if !"\\*([D"" \& (\\*([D)\c
-\&.
-.if !"\\*([G"" Gov't. ordering no. \\*([G.
+ (\\*([D).
+.if !"\\*([G"" Gov't. ordering no. \\*([G
 .if !"\\*([O"" \\*([O
 .RT
 .FE
 ..
 .de [4 \" report
 .FS
 .if !"\\*([O"" \\*([O
 .RT
 .FE
 ..
 .de [4 \" report
 .FS
-.if !"\\*([F"" .IP "\\*([F.\0"
+.IP "\\*([F.\0"
 \\*([A, \\*([o\\*([T,\\*([c
 \\*([R\c
 .if !"\\*([G"" \& (\\*([G)\c
 .if !"\\*([I"" ,  \\*([I\c
 .if !"\\*([C"" ,  \\*([C\c
 \\*([A, \\*([o\\*([T,\\*([c
 \\*([R\c
 .if !"\\*([G"" \& (\\*([G)\c
 .if !"\\*([I"" ,  \\*([I\c
 .if !"\\*([C"" ,  \\*([C\c
-.if !"\\*[D"" \& (\\*[D)\c
-\&.
+ (\\*([D).
 .if !"\\*([O"" \\*([O
 .RT
 .FE
 ..
 .de [3 \" article in book
 .FS
 .if !"\\*([O"" \\*([O
 .RT
 .FE
 ..
 .de [3 \" article in book
 .FS
-.if !"\\*([F"" .IP "\\*([F.\0"
-.if !"\\*([A"" \\*([A,
-.if !"\\*([T"" \\*([o\\*([T,\\*([c
+.IP "\\*([F.\0"
+\\*([A, \\*([o\\*([T,\\*([c
 .if !"\\*([P"" pp. \\*([P
 .if !"\\*([P"" pp. \\*([P
-in \\f2\\*([B\\f1\c
-.if !"\\*([E"" , ed. \\*([E\c
-.if !"\\*([I"" , \\*([I\c
-.if !"\\*([C"" , \\*([C\c
-.if !"\\*([D"" \& (\\*([D)\c
-\&.
+in \\f2\\*([B\\f1, \c
+.if !"\\*([E"" ed. \\*([E, \c
+.if !"\\*([I"" \\*([I\c
+.if !"\\*([C"" ,  \\*([C\c
+ (\\*([D).
 .if !"\\*([O"" \\*([O
 .RT
 .FE
 .if !"\\*([O"" \\*([O
 .RT
 .FE
diff --git a/usr/lib/uucp/L-devices b/usr/lib/uucp/L-devices
deleted file mode 100644 (file)
index 455e9b6..0000000
+++ /dev/null
@@ -1 +0,0 @@
-tty0 dn1 300 
diff --git a/usr/lib/uucp/L-dialcodes b/usr/lib/uucp/L-dialcodes
deleted file mode 100644 (file)
index 1f45f5e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-inwats 800
diff --git a/usr/lib/uucp/L.sys b/usr/lib/uucp/L.sys
deleted file mode 100644 (file)
index e8975cc..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Format of these lines is:       sysname time to call : device needed : speed
-res70 Any ACU 300 mh0000        login nuucp assword: fatchance
diff --git a/usr/lib/uucp/USERFILE b/usr/lib/uucp/USERFILE
deleted file mode 100644 (file)
index a495a5c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-, /
diff --git a/usr/lib/yaccpar b/usr/lib/yaccpar
deleted file mode 100644 (file)
index 25e5c7a..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-#
-# define YYFLAG -1000
-# define YYERROR goto yyerrlab
-# define YYACCEPT return(0)
-# define YYABORT return(1)
-
-/*     parser for yacc output  */
-
-int yydebug = 0; /* 1 for debugging */
-YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
-int yychar = -1; /* current input token number */
-int yynerrs = 0;  /* number of errors */
-short yyerrflag = 0;  /* error recovery flag */
-
-yyparse() {
-
-       short yys[YYMAXDEPTH];
-       short yyj, yym;
-       register YYSTYPE *yypvt;
-       register short yystate, *yyps, yyn;
-       register YYSTYPE *yypv;
-       register short *yyxi;
-
-       yystate = 0;
-       yychar = -1;
-       yynerrs = 0;
-       yyerrflag = 0;
-       yyps= &yys[-1];
-       yypv= &yyv[-1];
-
- yystack:    /* put a state and value onto the stack */
-
-       if( yydebug  ) printf( "state %d, char 0%o\n", yystate, yychar );
-               if( ++yyps> &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
-               *yyps = yystate;
-               ++yypv;
-               *yypv = yyval;
-
- yynewstate:
-
-       yyn = yypact[yystate];
-
-       if( yyn<= YYFLAG ) goto yydefault; /* simple state */
-
-       if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
-       if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;
-
-       if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
-               yychar = -1;
-               yyval = yylval;
-               yystate = yyn;
-               if( yyerrflag > 0 ) --yyerrflag;
-               goto yystack;
-               }
-
- yydefault:
-       /* default state action */
-
-       if( (yyn=yydef[yystate]) == -2 ) {
-               if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
-               /* look through exception table */
-
-               for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
-
-               while( *(yyxi+=2) >= 0 ){
-                       if( *yyxi == yychar ) break;
-                       }
-               if( (yyn = yyxi[1]) < 0 ) return(0);   /* accept */
-               }
-
-       if( yyn == 0 ){ /* error */
-               /* error ... attempt to resume parsing */
-
-               switch( yyerrflag ){
-
-               case 0:   /* brand new error */
-
-                       yyerror( "syntax error" );
-               yyerrlab:
-                       ++yynerrs;
-
-               case 1:
-               case 2: /* incompletely recovered error ... try again */
-
-                       yyerrflag = 3;
-
-                       /* find a state where "error" is a legal shift action */
-
-                       while ( yyps >= yys ) {
-                          yyn = yypact[*yyps] + YYERRCODE;
-                          if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
-                             yystate = yyact[yyn];  /* simulate a shift of "error" */
-                             goto yystack;
-                             }
-                          yyn = yypact[*yyps];
-
-                          /* the current yyps has no shift onn "error", pop stack */
-
-                          if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
-                          --yyps;
-                          --yypv;
-                          }
-
-                       /* there is no state on the stack with an error shift ... abort */
-
-       yyabort:
-                       return(1);
-
-
-               case 3:  /* no shift yet; clobber input char */
-
-                       if( yydebug ) printf( "error recovery discards char %d\n", yychar );
-
-                       if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
-                       yychar = -1;
-                       goto yynewstate;   /* try again in the same state */
-
-                       }
-
-               }
-
-       /* reduction by production yyn */
-
-               if( yydebug ) printf("reduce %d\n",yyn);
-               yyps -= yyr2[yyn];
-               yypvt = yypv;
-               yypv -= yyr2[yyn];
-               yyval = yypv[1];
-               yym=yyn;
-                       /* consult goto table to find next state */
-               yyn = yyr1[yyn];
-               yyj = yypgo[yyn] + *yyps + 1;
-               if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
-               switch(yym){
-                       $A
-               }
-               goto yystack;  /* stack new state and value */
-
-       }
diff --git a/usr/lib/z b/usr/lib/z
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/man/break b/usr/man/break
new file mode 100644 (file)
index 0000000..4ae5b8c
--- /dev/null
@@ -0,0 +1,3 @@
+\a
+;
+:
diff --git a/usr/man/cattoc b/usr/man/cattoc
new file mode 100644 (file)
index 0000000..d021d21
--- /dev/null
@@ -0,0 +1,304 @@
+ac(1M) ac: login accounting.
+adb(1) adb: debugger.
+ar(1) ar: archive and library maintainer.
+ar11(1) ar11: PDP-11 compatible archive and library maintainer.
+arcv(1M) arcv: convert archives to new format.
+as(1) as: assembler.
+at(1) at: execute commands at a later time.
+awk(1) awk: pattern scanning and processing language.
+basename(1) basename: strip filename affixes.
+bc(1) bc: arbitrary-precision arithmetic language.
+cal(1) cal: print calendar.
+calendar(1) calendar: reminder service.
+call(1C) call: ring a telephone.
+cat(1) cat: catenate and print.
+cb(1) cb: C program beautifier.
+cc(1) cc: C compiler.
+cd(1) cd: change working directory.
+chmod(1) chmod: change mode.
+chown(1) chown, chgrp: change owner or group.
+clri(1M) clri: clear i-node.
+cmp(1) cmp: compare two files.
+col(1) col: filter reverse line feeds.
+comm(1) comm: select or reject lines common to two sorted files.
+cp(1) cp: copy.
+cron(1M) cron: clock daemon.
+crypt(1) crypt: encode/decode.
+cu(1C) cu: call UNIX.
+date(1) date: print and set the date.
+dc(1) dc: desk calculator.
+dcheck(1M) dcheck: file system directory consistency check.
+dd(1) dd: convert and copy a file.
+deroff(1) deroff: remove nroff, troff, tbl and eqn constructs.
+df(1M) df: disk free.
+diff(1) diff: differential file comparator.
+diff3(1) diff3: 3-way differential file comparison.
+du(1) du: summarize disk usage.
+dump(1M) dump: incremental file system dump.
+dumpdir(1M) dumpdir: print the names of files on a dump tape.
+echo(1) echo: echo arguments.
+ed(1) ed: text editor.
+eqn(1) eqn, neqn, checkeq: typeset mathematics.
+expr(1) expr: evaluate arguments as an expression.
+f77(1) f77: Fortran 77 compiler.
+file(1) file: determine file type.
+find(1) find: find files.
+graph(1G) graph: draw a graph.
+grep(1) grep, egrep, fgrep: search a file for a pattern.
+icheck(1M) icheck: file system storage consistency check.
+intro(1) intro: introduction to commands.
+iostat(1M) iostat: report I/O statistics.
+join(1) join: relational database operator.
+kill(1) kill: terminate a process with extreme prejudice.
+ld(1) ld: link editor.
+learn(1) learn: computer aided instruction about UNIX.
+lex(1) lex: generator of lexical analysis programs.
+lint(1) lint: a C program verifier.
+ln(1) ln: make a link.
+login(1) login: sign on.
+look(1) look: find lines in a sorted list.
+lorder(1) lorder: find ordering relation for an object library.
+lpr(1) lpr, vpr: line printer spooler.
+ls(1) ls: list contents of directory.
+m4(1) m4: macro processor.
+mail(1) mail: send or receive mail among users.
+make(1) make: maintain program groups.
+man(1) man: print sections of this manual.
+mesg(1) mesg: permit or deny messages.
+mkdir(1) mkdir: make a directory.
+mkfs(1M) mkfs: construct a file system.
+mknod(1M) mknod: build special file.
+mount(1M) mount, umount: mount and dismount file system.
+mv(1) mv: move or rename files.
+ncheck(1M) ncheck: generate names from i-numbers.
+newgrp(1) newgrp: log in to a new group.
+nice(1) nice, nohup: run a command at low priority.
+nm(1) nm: print name list.
+nohup(1) nohup: run a command immune to hangups.
+number(1) number: convert Arabic numerals to English.
+od(1) od: octal dump.
+passwd(1) passwd: change login password.
+plot(1G) plot: graphics filters.
+pr(1) pr: print file.
+prof(1) prof: display profile data.
+ps(1) ps: process status.
+pstat(1M) pstat: print system facts.
+ptx(1) ptx: permuted index.
+pwd(1) pwd: working directory name.
+quot(1M) quot: summarize file system ownership.
+ratfor(1) ratfor: rational Fortran dialect.
+rc(1) rc: Ratfor compiler.
+refer(1) refer, lookbib: find and insert literature references in documents.
+restor(1M) restor: incremental file system restore.
+rev(1) rev: reverse lines of a file.
+rm(1) rm, rmdir: remove (unlink) files.
+sa(1M) sa, accton: system accounting.
+sdb(1) sdb: C symbolic debugger.
+sed(1) sed: stream editor.
+sh(1) sh, for, case, if, while, \fB:\fP, \fB.\fP, break, continue, cd, eval, exec, exit, export, login, newgrp, read, readonly, set, shift, times, trap, umask, wait: command language.
+size(1) size: size of an object file.
+sleep(1) sleep: suspend execution for an interval.
+sort(1) sort: sort or merge files.
+spell(1) spell, spellin, spellout: find spelling errors.
+spline(1G) spline: interpolate smooth curve.
+split(1) split: split a file into pieces.
+strip(1) strip: remove symbols and relocation bits.
+struct(1) struct: structure Fortran programs.
+stty(1) stty: set terminal options.
+su(1) su: substitute user id temporarily.
+sum(1) sum: sum and count blocks in a file.
+sync(1M) sync: update the super block.
+tabs(1) tabs: set terminal tabs.
+tail(1) tail: deliver the last part of a file.
+tar(1) tar: tape archiver.
+tbl(1) tbl: format tables for nroff or troff.
+tc(1) tc: photypesetter simulator.
+tee(1) tee: pipe fitting.
+test(1) test: condition command.
+time(1) time: time a command.
+tk(1) tk: paginator for the Tektronix 4014.
+touch(1) touch: update date last modified of a file.
+tp(1) tp: manipulate tape archive.
+tr(1) tr: translate characters.
+troff(1) troff, nroff: text formatting and typesetting.
+true(1) true, false: provide truth values.
+tsort(1) tsort: topological sort.
+tty(1) tty: get terminal name.
+uniq(1) uniq: report repeated lines in a file.
+units(1) units: conversion program.
+uucp(1C) uucp, uulog: unix to unix copy.
+uudiff(1C) uudiff: directory comparison between machines.
+uulog(1C) uulog: uucp user log inquiry.
+uux(1C) uux: unix to unix command execution.
+wait(1) wait: await completion of process.
+wall(1M) wall: write to all users.
+wc(1) wc: word count.
+who(1) who: who is on the system.
+write(1) write: write to another user.
+xsend(1) xsend, xget, enroll: secret mail.
+yacc(1) yacc: yet another compiler-compiler.
+access(2) access: determine accessibility of file.
+acct(2) acct: turn accounting on or off.
+alarm(2) alarm: schedule signal after specified time.
+brk(2) brk, sbrk, break: change core allocation.
+chdir(2) chdir: change default directory.
+chmod(2) chmod: change mode of file.
+chown(2) chown: change owner and group of a file.
+close(2) close: close a file.
+creat(2) creat: create a new file.
+dup(2) dup, dup2: duplicate an open file descriptor.
+exec(2) execl, execv, execle, execve, execlp, execvp, exec, exece, environ: execute a file.
+exit(2) exit: terminate process.
+fork(2) fork: spawn new process.
+getpid(2) getpid: get process identification.
+getuid(2) getuid, getgid, geteuid, getegid: get user and group identity.
+indir(2) indir, syscall: indirect system call.
+intro(2) intro, errno: introduction to system calls and error numbers.
+ioctl(2) ioctl, stty, gtty: control device.
+kill(2) kill: send signal to a process.
+link(2) link: link to a file.
+lseek(2) lseek, tell: move read/write pointer.
+mknod(2) mknod: make a directory or a special file.
+mount(2) mount, umount: mount or remove file system.
+mpx(2) mpx: create and manipulate multiplexed files.
+nice(2) nice: set program priority.
+open(2) open: open for reading or writing.
+pause(2) pause: stop until signal.
+pipe(2) pipe: create an interprocess channel.
+profil(2) profil: execution time profile.
+ptrace(2) ptrace: process trace.
+read(2) read: read from file.
+setuid(2) setuid, setgid: set user and group ID.
+signal(2) signal: catch or ignore signals.
+stat(2) stat, fstat: get file status.
+stime(2) stime: set time.
+stty(2) stty, gtty: set and retrieve terminal modes.
+sync(2) sync: update super-block.
+time(2) time, ftime: get date and time.
+times(2) times: get process times.
+umask(2) umask: set file creation mode mask.
+unlink(2) unlink: remove directory entry.
+utime(2) utime: set file times.
+wait(2) wait: wait for process to terminate.
+write(2) write: write on a file.
+abort(3) abort: generate a fault.
+abs(3) abs: integer absolute value.
+assert(3x) assert: program verification.
+atof(3) atof, atoi, atol: convert ASCII to numbers.
+crypt(3) crypt, setkey, encrypt: DES encryption.
+ctime(3) ctime, localtime, gmtime, asctime, timezone: convert date and time to ASCII.
+ctype(3) isalpha, isupper, islower, isdigit, isalnum, isspace, ispunct, isprint, iscntrl, isascii: character classification.
+dbm(3x) dbminit, fetch, store, delete, firstkey, nextkey: data base subroutines.
+ecvt(3) ecvt, fcvt, gcvt: output conversion.
+end(3) end, etext, edata: last locations in program.
+exp(3M) exp, log, log10, pow, sqrt: exponential, logarithm, power, square root.
+fclose(3S) fclose, fflush: close or flush a stream.
+ferror(3S) feof, ferror, clearerr, fileno: stream status inquiries.
+floor(3M) fabs, floor, ceil: absolute value, floor, ceiling functions.
+fopen(3S) fopen, freopen, fdopen: open a stream.
+fread(3S) fread, fwrite: buffered binary input/output.
+frexp(3) frexp, ldexp, modf: split into mantissa and exponent.
+fseek(3S) fseek, ftell, rewind: reposition a stream.
+gamma(3M) gamma: log gamma function.
+getarg(3f) getarg, iargc: command arguments to Fortran.
+getc(3S) getc, getchar, fgetc, getw: get character or word from stream.
+getenv(3) getenv: value for environment name.
+getgrent(3) getgrent, getgrgid, getgrnam, setgrent, endgrent: get group file entry.
+getlogin(3) getlogin: get login name.
+getpass(3) getpass: read a password.
+getpw(3) getpw: get name from UID.
+getpwent(3) getpwent, getpwuid, getpwnam, setpwent, endpwent: get password file entry.
+gets(3S) gets, fgets: get a string from a stream.
+hypot(3M) hypot, cabs: euclidean distance.
+intro(3) intro: introduction to library functions.
+j0(3M) j0, j1, jn, y0, y1, yn: bessel functions.
+l3tol(3) l3tol, ltol3: convert between 3-byte integers and long integers.
+malloc(3) malloc, free, realloc, calloc: main memory allocator.
+mktemp(3) mktemp: make a unique file name.
+monitor(3) monitor: prepare execution profile.
+nlist(3) nlist: get entries from name list.
+perror(3) perror, sys_errlist, sys_nerr: system error messages.
+plot(3x) plot: openpl et al.: graphics interface.
+popen(3S) popen, pclose: initiate I/O to/from a process.
+printf(3S) printf, fprintf, sprintf: formatted output conversion.
+putc(3S) putc, putchar, fputc, putw: put character or word on a stream.
+puts(3S) puts, fputs: put a string on a stream.
+qsort(3) qsort: quicker sort.
+rand(3) rand, srand: random number generator.
+scanf(3S) scanf, fscanf, sscanf: formatted input conversion.
+setbuf(3S) setbuf: assign buffering to a stream.
+setjmp(3) setjmp, longjmp: non-local goto.
+sin(3M) sin, cos, tan, asin, acos, atan, atan2: trigonometric functions.
+sinh(3M) sinh, cosh, tanh: hyperbolic functions.
+sleep(3) sleep: suspend execution for interval.
+stdio(3S) stdio: standard buffered input/output package.
+string(3) strcat, strcatn, strcmp, strcmpn, strcpy, strcpyn, strlen, index, rindex: string operations.
+swab(3) swab: swap bytes.
+system(3) system: issue a shell command.
+ttyname(3) ttyname, isatty, ttyslot: find name of a terminal.
+ungetc(3S) ungetc: push character back into input stream.
+cat(4) cat: phototypesetter interface.
+dc(4) dc: DC-11 communications interface.
+dh(4) dh: DH-11 communications multiplexer.
+dn(4) dn: DN-11 ACU interface.
+dp(4) dp: DP-11 201 data-phone interface.
+dz(4) dz: DZ-11 communications multiplexer.
+hp(4) hp: RH-11/RP04, RP05, RP06, RM03 moving-head disk.
+hs(4) hs: RH11/RS03-RS04 fixed-head disk file.
+ht(4) ht: RH-11/TE-16 magtape interface.
+kl(4) kl: KL-11 or DL-11 asynchronous interface.
+lp(4) lp: line printer.
+mem(4) mem, kmem: main memory.
+null(4) null: data sink.
+pc(4) pc: PC-11 paper tape reader/punch.
+rf(4) rf: RF11/RS11 fixed-head disk file.
+rk(4) rk: RK-11/RK03 or RK05 disk.
+rp(4) rp: RP-11/RP03 moving-head disk.
+tc(4) tc: TC-11/TU56 DECtape.
+tm(4) tm: TM-11/TU-10 magtape interface.
+tty(4) tty: general terminal interface.
+vp(4) vp: Versatec printer-plotter.
+a.out(5) a.out: assembler and link editor output.
+acct(5) acct: execution accounting file.
+ar(5) ar: archive (library) file format.
+core(5) core: format of memory image file.
+dir(5) dir: format of directories.
+dump(5) dump, ddate: incremental dump format.
+environ(5) environ: user environment.
+filsys(5) filsys, flblk, ino: format of file system volume.
+group(5) group: group file.
+mpxio(5) mpxio: multiplexed i/o.
+mtab(5) mtab: mounted file system table.
+passwd(5) passwd: password file.
+plot(5) plot: graphics interface.
+tp(5) tp: DEC/mag tape formats.
+ttys(5) ttys: terminal initialization data.
+types(5) types: primitive system data types.
+utmp(5) utmp, wtmp: login records.
+wtmp(5) wtmp: user login history.
+arithmetic(6) arithmetic: provide drill in number facts.
+backgammon(6) backgammon: the game.
+bcd(6) bcd: convert to antique media.
+ching(6) ching, fortune: the book of changes and other cookies.
+hangman(6) hangman: guess the word.
+maze(6) maze: generate a maze problem.
+quiz(6) quiz: test your knowledge.
+wump(6) wump: the game of hunt-the-wumpus.
+ascii(7) ascii: map of ASCII character set.
+eqnchar(7) eqnchar: special character definitions for eqn.
+greek(7) greek: graphics for extended TTY-37 type-box.
+hier(7) hier: file system hierarchy.
+man(7) man: macros to typeset manual.
+ms(7) ms: macros for formatting manuscripts.
+term(7) terminals: conventional names.
+bproc(8) boot procedures: UNIX/32V startup.
+crash(8) crash: what to do when the system crashes.
+cron(8) cron: clock daemon.
+fget.demon(8) fget.demon, fget.odemon: fget daemons.
+getty(8) getty: set terminal mode.
+init(8) init: process control initialization.
+lpd(8) lpd: line printer daemon.
+makekey(8) makekey: generate encryption key.
+sticky(8) sticky: executable files with persistent text.
+sysgen(8) sysgen: UNIX/32V system generation from the distribution tape.
+update(8) update: periodically update the super block.
diff --git a/usr/man/ignore b/usr/man/ignore
new file mode 100644 (file)
index 0000000..35f29d0
--- /dev/null
@@ -0,0 +1,413 @@
+&
++
+- 1.1 1 2 3 4 5 6 7 8 9 10 0 1.0
+;
+A. B. C. D. E. F. G. H. I. J. K. L. M. N. O. P. Q. S. T. U. V. W. X. Y. Z.
+MERT
+UNIX
+UNIX/TS UNIX/RT
+\s
+\s-1
+\s-2
+\s0
+a
+about
+above
+across
+act
+action
+after
+again
+against
+ago
+air
+al.
+all
+almost
+along
+already
+also
+although
+always
+american
+among
+an
+and
+another
+any
+anything
+are
+area
+areas
+around
+as
+asked
+at
+available
+away
+back
+be
+became
+because
+become
+been
+before
+began
+behind
+being
+best
+better
+between
+big
+board
+body
+both
+boy
+brought
+business
+but
+by
+called
+came
+can
+cannot
+car
+case
+certain
+change
+children
+church
+city
+close
+college
+come
+community
+company
+could
+country
+course
+court
+day
+days
+death
+development
+did
+didn't
+different
+do
+does
+don't
+done
+door
+down
+during
+each
+early
+economic
+either
+end
+enough
+even
+ever
+every
+example
+experience
+eyes
+face
+fact
+family
+far
+federal
+feet
+felt
+few
+field
+find
+first
+five
+for
+force
+form
+found
+four
+free
+from
+gave
+general
+get
+give
+given
+go
+god
+going
+good
+got
+government
+great
+group
+had
+half
+hand
+hands
+has
+have
+having
+he
+head
+heard
+held
+help
+her
+here
+high
+him
+himself
+his
+history
+home
+house
+how
+however
+human
+i
+i'm
+if
+important
+in
+individual
+information
+interest
+into
+is
+it
+it's
+its
+itself
+job
+john
+just
+keep
+kind
+knew
+know
+known
+large
+last
+later
+law
+least
+left
+less
+let
+life
+light
+like
+line
+little
+local
+long
+look
+looked
+love
+made
+major
+make
+making
+man
+many
+matter
+may
+me
+means
+members
+men
+might
+mind
+miss
+moment
+money
+more
+most
+mr
+mrs
+much
+must
+my
+name
+national
+need
+never
+new
+next
+night
+no
+not
+nothing
+now
+number
+of
+off
+office
+often
+old
+on
+once
+one
+only
+open
+or
+order
+other
+others
+our
+out
+over
+own
+part
+past
+people
+per
+perhaps
+period
+place
+point
+political
+position
+possible
+power
+present
+president
+probably
+problem
+problems
+program
+public
+put
+question
+quite
+rather
+real
+really
+reason
+result
+right
+room
+said
+same
+saw
+say
+school
+second
+see
+seemed
+seems
+seen
+sense
+service
+set
+several
+shall
+she
+should
+show
+side
+since
+small
+so
+social
+society
+some
+something
+south
+special
+state
+states
+still
+street
+study
+such
+sure
+system
+take
+taken
+tell
+than
+that
+the
+their
+them
+themselves
+then
+there
+these
+they
+thing
+things
+think
+this
+those
+though
+thought
+three
+through
+thus
+time
+times
+to
+today
+together
+told
+too
+took
+toward
+true
+turn
+turned
+two
+under
+united
+until
+up
+upon
+us
+use
+used
+very
+want
+war
+was
+water
+way
+we
+week
+well
+went
+were
+west
+what
+when
+where
+whether
+which
+while
+white
+who
+whole
+whose
+why
+will
+with
+within
+without
+word
+words
+work
+world
+would
+year
+years
+yet
+york
+you
+young
+your
diff --git a/usr/man/man0/copyr b/usr/man/man0/copyr
new file mode 100644 (file)
index 0000000..0950af2
--- /dev/null
@@ -0,0 +1,14 @@
+.fp 3 G
+.ll 4.8i
+.in .75i
+.hy 0
+.vs 12p
+--
+.sp |8i
+Copyright 1979, Bell Telephone Laboratories, Incorporated.
+Holders of a UNIX\v'-4p'\s-2\fGTM\fP\s0\v'4p'/32V software
+license are permitted to copy this document, or any portion
+of it, as necessary for licensed use of the software,
+provided this copyright notice and statement of permission
+are included.
+.bp
index e0b286e..ce6079d 100644 (file)
@@ -1,3 +1,5 @@
+.af PN i
+.pn 5
 .de IR
 \fI\\$1\^\fR\\$2
 ..
 .de IR
 \fI\\$1\^\fR\\$2
 ..
@@ -6,16 +8,14 @@
 ..
 .TL
 INTRODUCTION TO VOLUME 1
 ..
 .TL
 INTRODUCTION TO VOLUME 1
-.af PN i
-.pn 3
 .LP
 This volume gives descriptions of the publicly available
 features of the
 .LP
 This volume gives descriptions of the publicly available
 features of the
-.UX
+.UX \s-2/32V\s0
 system.
 It does not attempt to provide perspective or tutorial
 information upon the
 system.
 It does not attempt to provide perspective or tutorial
 information upon the
-.UX
+.UX \s-2/32V\s0
 operating system,
 its facilities, or its implementation.
 Various documents on those topics are contained in
 operating system,
 its facilities, or its implementation.
 Various documents on those topics are contained in
@@ -67,13 +67,10 @@ These directories are searched automatically by the command interpreter.
 System calls are entries into the
 .UX
 supervisor.
 System calls are entries into the
 .UX
 supervisor.
-Every system call has one or more C language interfaces
-described in section 2.
-The underlying assembly language interface, coded with opcode
-.I sys,
-a synonym for
-.I trap,
-is given as well.
+Under
+\s-2UNIX/32V\s0
+the system call interface is identical to a C language
+procedure call; the equivalent C procedures are described in Section 2.
 .LP
 An assortment
 of subroutines is available;
 .LP
 An assortment
 of subroutines is available;
@@ -194,7 +191,7 @@ described.
 .LP
 In section 2 an
 .I assembler
 .LP
 In section 2 an
 .I assembler
-subsection carries the assembly language system interface.
+subsection carries the PDP-11 assembly-language system interface.
 .LP
 .RE
 At the beginning of the volume is a table of contents,
 .LP
 .RE
 At the beginning of the volume is a table of contents,
@@ -211,7 +208,8 @@ exist only to exercise a particular system call.
 HOW TO GET STARTED
 .LP
 This section sketches the basic information
 HOW TO GET STARTED
 .LP
 This section sketches the basic information
-you need to get started on \*(UX:
+you need to get started on
+.UX /32V:
 how to log in and log out,
 how to communicate through your terminal,
 and how to run a program.
 how to log in and log out,
 how to communicate through your terminal,
 and how to run a program.
@@ -231,7 +229,7 @@ from an appropriate terminal.
 terminals are typified by the TTY 43,
 the GE Terminet 300, the DASI 300S and 450, and most
 video terminals such as
 terminals are typified by the TTY 43,
 the GE Terminet 300, the DASI 300S and 450, and most
 video terminals such as
-the Datamedia 5120 or HP 2640.
+the Datamedia 1520 or HP 2640.
 You must also have a valid user name,
 which may be obtained, together with the telephone number, from the system administrators.
 The same telephone number
 You must also have a valid user name,
 which may be obtained, together with the telephone number, from the system administrators.
 The same telephone number
@@ -247,7 +245,8 @@ you are using.
 .I
 300-baud terminals:\ \ 
 .R
 .I
 300-baud terminals:\ \ 
 .R
-Such terminals include the GE Terminet 300 and most display terminals
+Such terminals include the GE Terminet 300, and
+most display terminals
 run with popular modems.
 These terminals generally have a speed
 switch which should be set at `300' (or `30' for
 run with popular modems.
 These terminals generally have a speed
 switch which should be set at `300' (or `30' for
@@ -385,7 +384,7 @@ The `break' or `interrupt' key causes an
 interrupt signal,
 .R
 as does the
 interrupt signal,
 .R
 as does the
-The \s8ASCII\s10 `delete' (or `rubout') character,
+\s8ASCII\s10 `delete' (or `rubout') character,
 which is not passed to programs.
 This signal
 generally causes whatever program
 which is not passed to programs.
 This signal
 generally causes whatever program
@@ -571,15 +570,13 @@ To enter the text of a source program into a
 file, use
 the editor
 .IR ed (1).
 file, use
 the editor
 .IR ed (1).
-The three principal languages in
+The two principal languages in
 .UX
 are
 provided by the C compiler
 .IR cc (1),
 .UX
 are
 provided by the C compiler
 .IR cc (1),
-the Fortran compiler
-.IR f77 (1),
-and the assembler
-.IR as (1).
+and the Fortran compiler
+.IR f77 (1).
 After the program text has been entered through 
 the editor
 and written on a file, you can give the file
 After the program text has been entered through 
 the editor
 and written on a file, you can give the file
@@ -590,11 +587,6 @@ will be left on a file in the current directory named `a.out'.
 .I mv
 to move it to a less
 exposed name soon.)\ 
 .I mv
 to move it to a less
 exposed name soon.)\ 
-If you wrote in assembly language, you will probably
-need to load the program with library subroutines; see
-.IR ld (1).
-The other two language processors call
-the loader automatically.
 .LP
 When you have finally gone through this entire process
 without provoking any diagnostics, the resulting program
 .LP
 When you have finally gone through this entire process
 without provoking any diagnostics, the resulting program
@@ -654,11 +646,11 @@ Status inquiries.\ \
 .R
 Various commands exist to provide you with useful
 information.
 .R
 Various commands exist to provide you with useful
 information.
-.IR Who (1)
+.IR who (1)
 prints a list of users presently logged in.
 prints a list of users presently logged in.
-.IR Date (1)
+.IR date (1)
 prints the current time and date.
 prints the current time and date.
-.IR Ls (1)
+.IR ls (1)
 will list the files in your directory or give
 summary information about particular files.
 .LP
 will list the files in your directory or give
 summary information about particular files.
 .LP
@@ -685,7 +677,8 @@ before the first `$'.
 CONVERTING FROM THE 6TH EDITION
 .LP
 There follows a catalogue of significant, mostly incompatible,
 CONVERTING FROM THE 6TH EDITION
 .LP
 There follows a catalogue of significant, mostly incompatible,
-changes that will affect old users converting to the 7th edition.
+changes that will affect old users converting from the sixth edition
+on a PDP-11.
 No attempt is made to list all new facilities, or even all
 minor, but easily spotted changes,
 just the bare essentials without which it will be
 No attempt is made to list all new facilities, or even all
 minor, but easily spotted changes,
 just the bare essentials without which it will be
@@ -711,32 +704,7 @@ have been affected similarly, since file lengths are now
 .I
 Assembly language.\ \ 
 .R
 .I
 Assembly language.\ \ 
 .R
-System entry points are no longer built in symbols.
-Their values must be obtained from
-.I /usr/include/sys.s,
-see
-.IR intro (2).
-All system calls modify r0.
-This means that sequences like
-.DS
-mov    file,r0
-sys    lseek,0,0,2
-sys    write,buf,n
-.DE
-will no longer work.
-(In fact, 
-.I lseek
-now modifies r1 as well, so be doubly cautious.)
-.LP
-The
-.IR sleep (2)
-entry point is gone; see the more general facility,
-.IR alarm,
-plus
-.I pause.
-.LP
-Few library functions have assembly language entry points any more.
-You will have to simulate the C calling sequence.
+This language is dead.  Necromancy will be severely punnished.
 .LP
 .I
 Stty and gtty.\ \ 
 .LP
 .I
 Stty and gtty.\ \ 
@@ -759,13 +727,13 @@ To convert to the new style, use
 .I 
 C language, lint.\ \ 
 .R
 .I 
 C language, lint.\ \ 
 .R
-The official syntax for initialization
+The syntax for initialization
 requires an equal sign = before an initializer,
 and brackets { } around compound initial values;
 arrays and structures are now initialized honestly.
 requires an equal sign = before an initializer,
 and brackets { } around compound initial values;
 arrays and structures are now initialized honestly.
-Two-address operators, such as =+ and =-, are now written
-+= and -= to avoid ambiguities, although the old
-style is still accepted.
+Assignment operators such as =+ and =\-
+are now written in the reverse order: +=, \-=.  This removes the possibility
+of ambiguity in constructs such as x=\-2, y=*p, and a=/*b.
 You will also certainly want to learn about
 .DS
 long integers
 You will also certainly want to learn about
 .DS
 long integers
@@ -820,7 +788,7 @@ All have been replaced by the clean, highly efficient,
 package.
 The first things to know are that
 .IR getchar (3)
 package.
 The first things to know are that
 .IR getchar (3)
-returns the integer EOF (\-1), which is not a possible byte value,
+returns the integer EOF (\-1) (which is not a possible byte value)
 on end of file, that 518-byte buffers are out, and that there
 is a defined FILE data type.
 .LP
 on end of file, that 518-byte buffers are out, and that there
 is a defined FILE data type.
 .LP
diff --git a/usr/man/man0/permindex b/usr/man/man0/permindex
deleted file mode 100644 (file)
index 6afb5c3..0000000
+++ /dev/null
@@ -1,1160 +0,0 @@
-.xx "" "" "abort \- generate IOT fault" "" abort(3)
-.xx "" "" "abs \- integer absolute value" "" abs(3)
-.xx "" "fabs, floor, ceil \-" "absolute value, floor, ceiling functions" "" floor(3)
-.xx "" "" "ac \- login accounting" "" ac(1)
-.xx "" "" "access \- determine accessibility of file" "" access(2)
-.xx "" "phys \- allow a process to" "access physical addresses" "" phys(2)
-.xx "" "access \- determine" "accessibility of file" "" access(2)
-.xx "" "ac \- login" "accounting" "" ac(1)
-.xx "" "sa, accton \- system" "accounting" "" sa(1)
-.xx "" "acct \- execution" "accounting file" "" acct(5)
-.xx "" "acct \- turn" "accounting on or off" "" acct(2)
-.xx "" "sa," "accton \- system accounting" "" sa(1)
-.xx "" "sin, cos, tan, asin," "acos, atan, atan2 \- trigonometric functions" "" sin(3)
-.xx "" "dn \- DN-11" "ACU interface" "" dn(4)
-.xx "" "" "adb \- debugger" "" adb(1)
-.xx "" "phys \- allow a process to access physical" "addresses" "" phys(2)
-.xx "" "basename \- strip filename" "affixes" "" basename(1)
-.xx "" "plot: openpl et" "al. \- graphics interface" "" plot(3)
-.xx "" "" "alarm \- schedule signal after specified time" "" alarm(2)
-.xx "" "brk, sbrk, break \- change core" "allocation" "" brk(2)
-.xx "" "malloc, free, realloc, calloc \- main memory" "allocator" "" malloc(3)
-.xx "" "lex \- generator of lexical" "analysis programs" "" lex(1)
-.xx "" "bcd, ppt \- convert to" "antique media" "" bcd(6)
-.xx "" "" "a.out \- assembler and link editor output" "" a.out(5)
-.xx "" "" "ar \- archive and library maintainer" "" ar(1)
-.xx "" "" "ar \- archive (library) file format" "" ar(5)
-.xx "" "bc \-" "arbitrary-precision arithmetic language" "" bc(1)
-.xx "" "tp \- manipulate tape" "archive" "" tp(1)
-.xx "" "ar \-" "archive and library maintainer" "" ar(1)
-.xx "" "ar \-" "archive (library) file format" "" ar(5)
-.xx "" "tar \- tape" "archiver" "" tar(1)
-.xx "" "arcv \- convert" "archives to new format" "" arcv(1)
-.xx "" "echo \- echo" "arguments" "" echo(1)
-.xx "" "expr \- evaluate" "arguments as an expression" "" expr(1)
-.xx "" "pow, gcd, rpow \- multiple precision integer" "arithmetic" "/msub, mult, mdiv, min, mout," mp(3)
-.xx "" "" "arithmetic \- provide drill in number facts" "" arithmetic(6)
-.xx "" "bc \- arbitrary-precision" "arithmetic language" "" bc(1)
-.xx "" "" "as \- assembler" "" as(1)
-.xx "" "asctime, timezone \- convert date and time to" "ASCII" "ctime, localtime, gmtime," ctime(3)
-.xx "" "" "ascii \- map of ASCII character set" "" ascii(7)
-.xx "" "atof, atoi, atol \- convert" "ASCII to numbers" "" atof(3)
-.xx "ASCII" "ctime, localtime, gmtime," "asctime, timezone \- convert date and time to" "" ctime(3)
-.xx "functions" "sin, cos, tan," "asin, acos, atan, atan2 \- trigonometric" "" sin(3)
-.xx "" "as \-" "assembler" "" as(1)
-.xx "" "a.out \-" "assembler and link editor output" "" a.out(5)
-.xx "" "" "assert \- program verification" "" assert(3)
-.xx "" "setbuf \-" "assign buffering to a stream" "" setbuf(3)
-.xx "" "" "at \- execute commands at a later time" "" at(1)
-.xx "" "sin, cos, tan, asin, acos," "atan, atan2 \- trigonometric functions" "" sin(3)
-.xx "" "" "atof, atoi, atol \- convert ASCII to numbers" "" atof(3)
-.xx "" "wait \-" "await completion of process" "" wait(1)
-.xx "language" "" "awk \- pattern scanning and processing" "" awk(1)
-.xx "" "" "backgammon \- the game" "" backgammon(6)
-.xx "" "" "banner \- make long posters" "" banner(6)
-.xx "" "" "bas \- basic" "" bas(1)
-.xx "" "store, delete, firstkey, nextkey \- data" "base subroutines" "dbminit, fetch," dbm(3)
-.xx "" "" "basename \- strip filename affixes" "" basename(1)
-.xx "" "bas \-" "basic" "" bas(1)
-.xx "" "" "bc \- arbitrary-precision arithmetic language" "" bc(1)
-.xx "" "" "bcd, ppt \- convert to antique media" "" bcd(6)
-.xx "" "cb \- C program" "beautifier" "" cb(1)
-.xx "" "j0, j1, jn, y0, y1, yn \-" "bessel functions" "" j0(3)
-.xx "" "fread, fwrite \- buffered" "binary input/output" "" fread(3)
-.xx "" "" "bj \- the game of black jack" "" bj(6)
-.xx "" "sync \- update the super" "block" "" sync(1)
-.xx "" "sync \- update super-" "block" "" sync(2)
-.xx "" "update \- periodically update the super" "block" "" update(8)
-.xx "" "sum \- sum and count" "blocks in a file" "" sum(1)
-.xx "" "ching, fortune \- the" "book of changes and other cookies" "" ching(6)
-.xx "" "" "boot \- startup procedures" "" boot(8)
-.xx "" "brk, sbrk," "break \- change core allocation" "" brk(2)
-.xx "export, login,/" "sh, for, case, if, while," "break, continue, cd, eval, exec, exit," "" sh(1)
-.xx "" "" "brk, sbrk, break \- change core allocation" "" brk(2)
-.xx "" "fread, fwrite \-" "buffered binary input/output" "" fread(3)
-.xx "" "stdio \- standard" "buffered input/output package" "" stdio(3)
-.xx "" "setbuf \- assign" "buffering to a stream" "" setbuf(3)
-.xx "" "mknod \-" "build special file" "" mknod(1)
-.xx "" "l3tol, ltol3 \- convert between 3-" "byte integers and long integers" "" l3tol(3)
-.xx "" "swab \- swap" "bytes" "" swab(3)
-.xx "" "cc, pcc \-" "C compiler" "" cc(1)
-.xx "" "cb \-" "C program beautifier" "" cb(1)
-.xx "" "lint \- a" "C program verifier" "" lint(1)
-.xx "" "hypot," "cabs \- euclidean distance" "" hypot(3)
-.xx "" "" "cal \- print calendar" "" cal(1)
-.xx "" "dc \- desk" "calculator" "" dc(1)
-.xx "" "cal \- print" "calendar" "" cal(1)
-.xx "" "" "calendar \- reminder service" "" calendar(1)
-.xx "" "indir \- indirect system" "call" "" indir(2)
-.xx "" "cu \-" "call UNIX" "" cu(1)
-.xx "" "malloc, free, realloc," "calloc \- main memory allocator" "" malloc(3)
-.xx "" "intro, errno \- introduction to system" "calls and error numbers" "" intro(2)
-.xx "exec, exit, export, login, newgrp,/" "sh, for," "case, if, while, break, continue, cd, eval," "" sh(1)
-.xx "" "" "cat \- catenate and print" "" cat(1)
-.xx "" "" "cat \- phototypesetter interface" "" cat(4)
-.xx "" "signal \-" "catch or ignore signals" "" signal(2)
-.xx "" "cat \-" "catenate and print" "" cat(1)
-.xx "" "" "cb \- C program beautifier" "" cb(1)
-.xx "" "" "cc, pcc \- C compiler" "" cc(1)
-.xx "" "" "cd \- change working directory" "" cd(1)
-.xx "" "sh, for, case, if, while, break, continue," "cd, eval, exec, exit, export, login, newgrp,/" "" sh(1)
-.xx "functions" "fabs, floor," "ceil \- absolute value, floor, ceiling" "" floor(3)
-.xx "" "brk, sbrk, break \-" "change core allocation" "" brk(2)
-.xx "" "chdir \-" "change default directory" "" chdir(2)
-.xx "" "passwd \-" "change login password" "" passwd(1)
-.xx "" "chmod \-" "change mode" "" chmod(1)
-.xx "" "chmod \-" "change mode of file" "" chmod(2)
-.xx "" "chown \-" "change owner and group of a file" "" chown(2)
-.xx "" "chown, chgrp \-" "change owner or group" "" chown(1)
-.xx "" "cd \-" "change working directory" "" cd(1)
-.xx "" "ching, fortune \- the book of" "changes and other cookies" "" ching(6)
-.xx "" "pipe \- create an interprocess" "channel" "" pipe(2)
-.xx "" "ungetc \- push" "character back into input stream" "" ungetc(3)
-.xx "" "ispunct, isprint, iscntrl, isascii \-" "character classification" "/isalnum, isspace," ctype(3)
-.xx "" "eqnchar \- special" "character definitions for eqn" "" eqnchar(7)
-.xx "" "getc, getchar, fgetc, getw \- get" "character or word from stream" "" getc(3)
-.xx "" "putc, putchar, fputc, putw \- put" "character or word on a stream" "" putc(3)
-.xx "" "ascii \- map of ASCII" "character set" "" ascii(7)
-.xx "" "tr \- translate" "characters" "" tr(1)
-.xx "" "" "chdir \- change default directory" "" chdir(2)
-.xx "" "dcheck \- file system directory consistency" "check" "" dcheck(1)
-.xx "" "icheck \- file system storage consistency" "check" "" icheck(1)
-.xx "" "eqn, neqn," "checkeq \- typeset mathematics" "" eqn(1)
-.xx "" "" "checkers \- game" "" checkers(6)
-.xx "" "chess \- the game of" "chess" "" chess(6)
-.xx "" "chown," "chgrp \- change owner or group" "" chown(1)
-.xx "other cookies" "" "ching, fortune \- the book of changes and" "" ching(6)
-.xx "" "" "chmod \- change mode" "" chmod(1)
-.xx "" "" "chmod \- change mode of file" "" chmod(2)
-.xx "" "" "chown \- change owner and group of a file" "" chown(2)
-.xx "" "" "chown, chgrp \- change owner or group" "" chown(1)
-.xx "" "isprint, iscntrl, isascii \- character" "classification" "/isalnum, isspace, ispunct," ctype(3)
-.xx "" "clri \-" "clear i-node" "" clri(1)
-.xx "" "feof, ferror," "clearerr, fileno \- stream status inquiries" "" ferror(3)
-.xx "" "cron \-" "clock daemon" "" cron(8)
-.xx "" "" "close \- close a file" "" close(2)
-.xx "" "fclose, fflush \-" "close or flush a stream" "" fclose(3)
-.xx "" "" "clri \- clear i-node" "" clri(1)
-.xx "" "" "cmp \- compare two files" "" cmp(1)
-.xx "" "" "col \- filter reverse line feeds" "" col(1)
-.xx "sorted files" "" "comm \- select or reject lines common to two" "" comm(1)
-.xx "" "system \- issue a shell" "command" "" system(3)
-.xx "" "test \- condition" "command" "" test(1)
-.xx "" "time \- time a" "command" "" time(1)
-.xx "" "nice, nohup \- run a" "command at low priority" "" nice(1)
-.xx "" "uux \- unix to unix" "command execution" "" uux(1)
-.xx "" "set, shift, times, trap, umask, wait \-" "command language" "/newgrp, read, readonly," sh(1)
-.xx "" "intro \- introduction to" "commands" "" intro(1)
-.xx "" "at \- execute" "commands at a later time" "" at(1)
-.xx "" "comm \- select or reject lines" "common to two sorted files" "" comm(1)
-.xx "" "diff \- differential file" "comparator" "" diff(1)
-.xx "" "cmp \-" "compare two files" "" cmp(1)
-.xx "" "diff3 \- 3-way differential file" "comparison" "" diff3(1)
-.xx "" "cc, pcc \- C" "compiler" "" cc(1)
-.xx "" "f77 \- Fortran 77" "compiler" "" f77(1)
-.xx "" "yacc \- yet another compiler-" "compiler" "" yacc(1)
-.xx "" "wait \- await" "completion of process" "" wait(1)
-.xx "" "test \-" "condition command" "" test(1)
-.xx "" "mkconf \- generate" "configuration tables" "" mkconf(1)
-.xx "" "dcheck \- file system directory" "consistency check" "" dcheck(1)
-.xx "" "icheck \- file system storage" "consistency check" "" icheck(1)
-.xx "" "mkfs \-" "construct a file system" "" mkfs(1)
-.xx "" "deroff \- remove nroff, troff, tbl and eqn" "constructs" "" deroff(1)
-.xx "" "ls \- list" "contents of directory" "" ls(1)
-.xx "login,/" "sh, for, case, if, while, break," "continue, cd, eval, exec, exit, export," "" sh(1)
-.xx "" "ioctl, stty, gtty \-" "control device" "" ioctl(2)
-.xx "" "init, rc \- process" "control initialization" "" init(8)
-.xx "" "terminals\-" "conventional names" "" term(7)
-.xx "" "ecvt, fcvt, gcvt \- output" "conversion" "" ecvt(3)
-.xx "" "printf, fprintf, sprintf \- formatted output" "conversion" "" printf(3)
-.xx "" "scanf, fscanf, sscanf \- formatted input" "conversion" "" scanf(3)
-.xx "" "units \-" "conversion program" "" units(1)
-.xx "" "dd \-" "convert and copy a file" "" dd(1)
-.xx "" "arcv \-" "convert archives to new format" "" arcv(1)
-.xx "" "atof, atoi, atol \-" "convert ASCII to numbers" "" atof(3)
-.xx "integers" "l3tol, ltol3 \-" "convert between 3-byte integers and long" "" l3tol(3)
-.xx "" "localtime, gmtime, asctime, timezone \-" "convert date and time to ASCII" "ctime," ctime(3)
-.xx "" "bcd, ppt \-" "convert to antique media" "" bcd(6)
-.xx "" "fortune \- the book of changes and other" "cookies" "ching," ching(6)
-.xx "" "cp \-" "copy" "" cp(1)
-.xx "" "uucp, uulog \- unix to unix" "copy" "" uucp(1)
-.xx "" "dd \- convert and" "copy a file" "" dd(1)
-.xx "" "" "core \- format of core image file" "" core(5)
-.xx "" "brk, sbrk, break \- change" "core allocation" "" brk(2)
-.xx "" "core \- format of" "core image file" "" core(5)
-.xx "" "mem, kmem \-" "core memory" "" mem(4)
-.xx "trigonometric functions" "sin," "cos, tan, asin, acos, atan, atan2 \-" "" sin(3)
-.xx "" "sinh," "cosh, tanh \- hyperbolic functions" "" sinh(3)
-.xx "" "wc \- word" "count" "" wc(1)
-.xx "" "sum \- sum and" "count blocks in a file" "" sum(1)
-.xx "" "" "cp \- copy" "" cp(1)
-.xx "" "" "crash \- what to do when the system crashes" "" crash(8)
-.xx "" "" "creat \- create a new file" "" creat(2)
-.xx "" "pipe \-" "create an interprocess channel" "" pipe(2)
-.xx "" "umask \- set file" "creation mode mask" "" umask(2)
-.xx "" "" "cron \- clock daemon" "" cron(8)
-.xx "" "" "crypt \- encode/decode" "" crypt(1)
-.xx "" "" "crypt, setkey, encrypt \- DES encryption" "" crypt(3)
-.xx "\- convert date and time to ASCII" "" "ctime, localtime, gmtime, asctime, timezone" "" ctime(3)
-.xx "" "" "cu \- call UNIX" "" cu(1)
-.xx "" "ttt," "cubic \- tic-tac-toe" "" ttt(6)
-.xx "" "spline \- interpolate smooth" "curve" "" spline(1)
-.xx "" "cron \- clock" "daemon" "" cron(8)
-.xx "" "prof \- display profile" "data" "" prof(1)
-.xx "" "ttys \- terminal initialization" "data" "" ttys(5)
-.xx "" "fetch, store, delete, firstkey, nextkey \-" "data base subroutines" "dbminit," dbm(3)
-.xx "" "null \-" "data sink" "" null(4)
-.xx "" "types \- primitive system" "data types" "" types(5)
-.xx "" "join \- relational" "database operator" "" join(1)
-.xx "" "du, dp \- DU-11 201" "data-phone interface" "" du(4)
-.xx "" "date \- print and set the" "date" "" date(1)
-.xx "" "time, ftime \- get" "date and time" "" time(2)
-.xx "" "gmtime, asctime, timezone \- convert" "date and time to ASCII" "ctime, localtime," ctime(3)
-.xx "" "touch \- update" "date last modified of a file" "" touch(1)
-.xx "nextkey \- data base subroutines" "" "dbminit, fetch, store, delete, firstkey," "" dbm(3)
-.xx "" "" "dc \- desk calculator" "" dc(1)
-.xx "check" "" "dcheck \- file system directory consistency" "" dcheck(1)
-.xx "" "" "dd \- convert and copy a file" "" dd(1)
-.xx "" "dump," "ddate \- incremental dump format" "" dump(5)
-.xx "" "adb \-" "debugger" "" adb(1)
-.xx "" "tp \-" "DEC/mag tape formats" "" tp(5)
-.xx "" "crypt \- encode/" "decode" "" crypt(1)
-.xx "" "tc \- TC-11/TU56" "DECtape" "" tc(4)
-.xx "" "chdir \- change" "default directory" "" chdir(2)
-.xx "" "eqnchar \- special character" "definitions for eqn" "" eqnchar(7)
-.xx "subroutines" "dbminit, fetch, store," "delete, firstkey, nextkey \- data base" "" dbm(3)
-.xx "" "tail \-" "deliver the last part of a file" "" tail(1)
-.xx "" "mesg \- permit or" "deny messages" "" mesg(1)
-.xx "constructs" "" "deroff \- remove nroff, troff, tbl and eqn" "" deroff(1)
-.xx "" "crypt, setkey, encrypt \-" "DES encryption" "" crypt(3)
-.xx "" "dup, dup2 \- duplicate an open file" "descriptor" "" dup(2)
-.xx "" "dc \-" "desk calculator" "" dc(1)
-.xx "" "access \-" "determine accessibility of file" "" access(2)
-.xx "" "file \-" "determine file type" "" file(1)
-.xx "" "ioctl, stty, gtty \- control" "device" "" ioctl(2)
-.xx "" "" "df \- disk free" "" df(1)
-.xx "" "" "diff \- differential file comparator" "" diff(1)
-.xx "" "" "diff3 \- 3-way differential file comparison" "" diff3(1)
-.xx "" "diff \-" "differential file comparator" "" diff(1)
-.xx "" "diff3 \- 3-way" "differential file comparison" "" diff3(1)
-.xx "" "" "dir \- format of directories" "" dir(5)
-.xx "" "mv \- move or rename files and" "directories" "" mv(1)
-.xx "" "cd \- change working" "directory" "" cd(1)
-.xx "" "chdir \- change default" "directory" "" chdir(2)
-.xx "" "ls \- list contents of" "directory" "" ls(1)
-.xx "" "mkdir \- make a" "directory" "" mkdir(1)
-.xx "" "dcheck \- file system" "directory consistency check" "" dcheck(1)
-.xx "" "unlink \- remove" "directory entry" "" unlink(2)
-.xx "" "pwd \- working" "directory name" "" pwd(1)
-.xx "" "mknod \- make a" "directory or a special file" "" mknod(2)
-.xx "" "hp \- RH-11/RP04, RP05, RP06 moving-head" "disk" "" hp(4)
-.xx "" "rk \- RK-11/RK03 or RK05" "disk" "" rk(4)
-.xx "" "rp \- RP-11/RP03 moving-head" "disk" "" rp(4)
-.xx "" "hs \- RH11/RS03-RS04 fixed-head" "disk file" "" hs(4)
-.xx "" "rf \- RF11/RS11 fixed-head" "disk file" "" rf(4)
-.xx "" "df \-" "disk free" "" df(1)
-.xx "" "du \- summarize" "disk usage" "" du(1)
-.xx "" "mount, umount \- mount and" "dismount file system" "" mount(1)
-.xx "" "prof \-" "display profile data" "" prof(1)
-.xx "" "hypot, cabs \- euclidean" "distance" "" hypot(3)
-.xx "" "" "dn \- DN-11 ACU interface" "" dn(4)
-.xx "" "\- find and insert literature references in" "documents" "refer, lookbib" refer(1)
-.xx "" "du," "dp \- DU-11 201 data-phone interface" "" du(4)
-.xx "" "reversi \- a game of" "dramatic reversals" "" reversi(6)
-.xx "" "graph \-" "draw a graph" "" graph(1)
-.xx "" "arithmetic \- provide" "drill in number facts" "" arithmetic(6)
-.xx "" "pk \- packet" "driver" "" pk(4)
-.xx "" "pkclose, pkread, pkwrite, pkfail \- packet" "driver simulator" "pkopen," pkopen(3)
-.xx "" "" "du \- summarize disk usage" "" du(1)
-.xx "" "" "du, dp \- DU-11 201 data-phone interface" "" du(4)
-.xx "" "dump \- incremental file system" "dump" "" dump(1)
-.xx "" "od \- octal" "dump" "" od(1)
-.xx "" "" "dump \- incremental file system dump" "" dump(1)
-.xx "" "" "dump, ddate \- incremental dump format" "" dump(5)
-.xx "" "dumpdir \- print the names of files on a" "dump tape" "" dumpdir(1)
-.xx "descriptor" "" "dup, dup2 \- duplicate an open file" "" dup(2)
-.xx "" "" "echo \- echo arguments" "" echo(1)
-.xx "" "" "ecvt, fcvt, gcvt \- output conversion" "" ecvt(3)
-.xx "" "" "ed \- text editor" "" ed(1)
-.xx "" "end, etext," "edata \- last locations in program" "" end(3)
-.xx "" "ed \- text" "editor" "" ed(1)
-.xx "" "sed \- stream" "editor" "" sed(1)
-.xx "" "a.out \- assembler and link" "editor output" "" a.out(5)
-.xx "" "grep," "egrep, fgrep \- search a file for a pattern" "" grep(1)
-.xx "" "crypt \-" "encode/decode" "" crypt(1)
-.xx "" "crypt, setkey," "encrypt \- DES encryption" "" crypt(3)
-.xx "" "makekey \- generate" "encryption key" "" makekey(8)
-.xx "program" "" "end, etext, edata \- last locations in" "" end(3)
-.xx "" "getgrent, getgrgid, getgrnam, setgrent," "endgrent \- get group file entry" "" getgrent(3)
-.xx "" "getpwent, getpwuid, getpwnam, setpwent," "endpwent \- get password file entry" "" getpwent(3)
-.xx "" "xsend, xget," "enroll \- secret mail" "" xsend(1)
-.xx "" "nlist \- get" "entries from name list" "" nlist(3)
-.xx "" "setgrent, endgrent \- get group file" "entry" "getgrent, getgrgid, getgrnam," getgrent(3)
-.xx "" "setpwent, endpwent \- get password file" "entry" "getpwent, getpwuid, getpwnam," getpwent(3)
-.xx "" "unlink \- remove directory" "entry" "" unlink(2)
-.xx "" "execle, execve, execlp, execvp, exec, exece," "environ \- execute a file" "execl, execv," exec(2)
-.xx "" "" "environ \- user environment" "" environ(5)
-.xx "" "getenv \- value for" "environment name" "" getenv(3)
-.xx "" "eqnchar \- special character definitions for" "eqn" "" eqnchar(7)
-.xx "" "deroff \- remove nroff, troff, tbl and" "eqn constructs" "" deroff(1)
-.xx "" "" "eqn, neqn, checkeq \- typeset mathematics" "" eqn(1)
-.xx "eqn" "" "eqnchar \- special character definitions for" "" eqnchar(7)
-.xx "error numbers" "intro," "errno \- introduction to system calls and" "" intro(2)
-.xx "" "perror, sys_errlist, sys_nerr \- system" "error messages" "" perror(3)
-.xx "" "errno \- introduction to system calls and" "error numbers" "intro," intro(2)
-.xx "" "spell, spellin, spellout \- find spelling" "errors" "" spell(1)
-.xx "" "pkon, pkoff \-" "establish packet protocol" "" pkon(2)
-.xx "" "end," "etext, edata \- last locations in program" "" end(3)
-.xx "" "hypot, cabs \-" "euclidean distance" "" hypot(3)
-.xx "" "for, case, if, while, break, continue, cd," "eval, exec, exit, export, login, newgrp,/" "sh," sh(1)
-.xx "" "expr \-" "evaluate arguments as an expression" "" expr(1)
-.xx "" "execl, execv, execle, execve, execlp, execvp," "exec, exece, environ \- execute a file" "" exec(2)
-.xx "" "/case, if, while, break, continue, cd, eval," "exec, exit, export, login, newgrp, read,/" "" sh(1)
-.xx "" "execv, execle, execve, execlp, execvp, exec," "exece, environ \- execute a file" "execl," exec(2)
-.xx "" "at \-" "execute commands at a later time" "" at(1)
-.xx "" "uux \- unix to unix command" "execution" "" uux(1)
-.xx "" "acct \-" "execution accounting file" "" acct(5)
-.xx "" "sleep \- suspend" "execution for an interval" "" sleep(1)
-.xx "" "sleep \- suspend" "execution for interval" "" sleep(3)
-.xx "" "monitor \- prepare" "execution profile" "" monitor(3)
-.xx "" "profil \-" "execution time profile" "" profil(2)
-.xx "exece, environ \- execute a file" "execl," "execv, execle, execve, execlp, execvp, exec," "" exec(2)
-.xx "" "" "exit \- terminate process" "" exit(2)
-.xx "" "/if, while, break, continue, cd, eval, exec," "exit, export, login, newgrp, read, readonly,/" "" sh(1)
-.xx "logarithm, power, square root" "" "exp, log, log10, pow, sqrt \- exponential," "" exp(3)
-.xx "" "frexp, ldexp, modf \- split into mantissa and" "exponent" "" frexp(3)
-.xx "" "exp, log, log10, pow, sqrt \-" "exponential, logarithm, power, square root" "" exp(3)
-.xx "" "/while, break, continue, cd, eval, exec, exit," "export, login, newgrp, read, readonly, set,/" "" sh(1)
-.xx "" "" "expr \- evaluate arguments as an expression" "" expr(1)
-.xx "" "" "f77 \- Fortran 77 compiler" "" f77(1)
-.xx "ceiling functions" "" "fabs, floor, ceil \- absolute value, floor," "" floor(3)
-.xx "" "factor, primes \-" "factor a number, generate large primes" "" factor(1)
-.xx "" "true," "false \- provide truth values" "" true(1)
-.xx "" "abort \- generate IOT" "fault" "" abort(3)
-.xx "" "" "fclose, fflush \- close or flush a stream" "" fclose(3)
-.xx "" "ecvt," "fcvt, gcvt \- output conversion" "" ecvt(3)
-.xx "" "fopen, freopen," "fdopen \- open a stream" "" fopen(3)
-.xx "status inquiries" "" "feof, ferror, clearerr, fileno \- stream" "" ferror(3)
-.xx "data base subroutines" "dbminit," "fetch, store, delete, firstkey, nextkey \-" "" dbm(3)
-.xx "" "fclose," "fflush \- close or flush a stream" "" fclose(3)
-.xx "stream" "getc, getchar," "fgetc, getw \- get character or word from" "" getc(3)
-.xx "" "gets," "fgets \- get a string from a stream" "" gets(3)
-.xx "" "grep, egrep," "fgrep \- search a file for a pattern" "" grep(1)
-.xx "" "access \- determine accessibility of" "file" "" access(2)
-.xx "" "acct \- execution accounting" "file" "" acct(5)
-.xx "" "chmod \- change mode of" "file" "" chmod(2)
-.xx "" "chown \- change owner and group of a" "file" "" chown(2)
-.xx "" "close \- close a" "file" "" close(2)
-.xx "" "core \- format of core image" "file" "" core(5)
-.xx "" "creat \- create a new" "file" "" creat(2)
-.xx "" "dd \- convert and copy a" "file" "" dd(1)
-.xx "" "execvp, exec, exece, environ \- execute a" "file" "execl, execv, execle, execve, execlp," exec(2)
-.xx "" "group \- group" "file" "" group(5)
-.xx "" "hs \- RH11/RS03-RS04 fixed-head disk" "file" "" hs(4)
-.xx "" "link \- link to a" "file" "" link(2)
-.xx "" "mknod \- build special" "file" "" mknod(1)
-.xx "" "mknod \- make a directory or a special" "file" "" mknod(2)
-.xx "" "passwd \- password" "file" "" passwd(5)
-.xx "" "pr \- print" "file" "" pr(1)
-.xx "" "read \- read from" "file" "" read(2)
-.xx "" "rev \- reverse lines of a" "file" "" rev(1)
-.xx "" "rf \- RF11/RS11 fixed-head disk" "file" "" rf(4)
-.xx "" "size \- size of an object" "file" "" size(1)
-.xx "" "sum \- sum and count blocks in a" "file" "" sum(1)
-.xx "" "tail \- deliver the last part of a" "file" "" tail(1)
-.xx "" "touch \- update date last modified of a" "file" "" touch(1)
-.xx "" "uniq \- report repeated lines in a" "file" "" uniq(1)
-.xx "" "write \- write on a" "file" "" write(2)
-.xx "" "" "file \- determine file type" "" file(1)
-.xx "" "diff \- differential" "file comparator" "" diff(1)
-.xx "" "diff3 \- 3-way differential" "file comparison" "" diff3(1)
-.xx "" "umask \- set" "file creation mode mask" "" umask(2)
-.xx "" "dup, dup2 \- duplicate an open" "file descriptor" "" dup(2)
-.xx "" "getgrnam, setgrent, endgrent \- get group" "file entry" "getgrent, getgrgid," getgrent(3)
-.xx "" "getpwnam, setpwent, endpwent \- get password" "file entry" "getpwent, getpwuid," getpwent(3)
-.xx "" "grep, egrep, fgrep \- search a" "file for a pattern" "" grep(1)
-.xx "" "ar \- archive (library)" "file format" "" ar(5)
-.xx "" "split \- split a" "file into pieces" "" split(1)
-.xx "" "mktemp \- make a unique" "file name" "" mktemp(3)
-.xx "" "stat, fstat \- get" "file status" "" stat(2)
-.xx "" "mkfs \- construct a" "file system" "" mkfs(1)
-.xx "" "mount, umount \- mount and dismount" "file system" "" mount(1)
-.xx "" "mount, umount \- mount or remove" "file system" "" mount(2)
-.xx "" "dcheck \-" "file system directory consistency check" "" dcheck(1)
-.xx "" "dump \- incremental" "file system dump" "" dump(1)
-.xx "" "hier \-" "file system hierarchy" "" hier(7)
-.xx "" "quot \- summarize" "file system ownership" "" quot(1)
-.xx "" "restor \- incremental" "file system restore" "" restor(1)
-.xx "" "icheck \-" "file system storage consistency check" "" icheck(1)
-.xx "" "mtab \- mounted" "file system table" "" mtab(5)
-.xx "" "filsys, flblk, ino \- format of" "file system volume" "" filsys(5)
-.xx "" "utime \- set" "file times" "" utime(2)
-.xx "" "file \- determine" "file type" "" file(1)
-.xx "" "basename \- strip" "filename affixes" "" basename(1)
-.xx "" "feof, ferror, clearerr," "fileno \- stream status inquiries" "" ferror(3)
-.xx "" "cmp \- compare two" "files" "" cmp(1)
-.xx "" "select or reject lines common to two sorted" "files" "comm \-" comm(1)
-.xx "" "find \- find" "files" "" find(1)
-.xx "" "rm, rmdir \- remove (unlink)" "files" "" rm(1)
-.xx "" "sort \- sort or merge" "files" "" sort(1)
-.xx "" "mv \- move or rename" "files and directories" "" mv(1)
-.xx "" "dumpdir \- print the names of" "files on a dump tape" "" dumpdir(1)
-.xx "volume" "" "filsys, flblk, ino \- format of file system" "" filsys(5)
-.xx "" "col \-" "filter reverse line feeds" "" col(1)
-.xx "" "plot \- graphics" "filters" "" plot(1)
-.xx "" "" "find \- find files" "" find(1)
-.xx "documents" "refer, lookbib \-" "find and insert literature references in" "" refer(1)
-.xx "" "find \-" "find files" "" find(1)
-.xx "" "look \-" "find lines in a sorted list" "" look(1)
-.xx "" "ttyname, isatty, ttyslot \-" "find name of a terminal" "" ttyname(3)
-.xx "" "lorder \-" "find ordering relation for an object library" "" lorder(1)
-.xx "" "spell, spellin, spellout \-" "find spelling errors" "" spell(1)
-.xx "" "dbminit, fetch, store, delete," "firstkey, nextkey \- data base subroutines" "" dbm(3)
-.xx "" "hs \- RH11/RS03-RS04" "fixed-head disk file" "" hs(4)
-.xx "" "rf \- RF11/RS11" "fixed-head disk file" "" rf(4)
-.xx "" "filsys," "flblk, ino \- format of file system volume" "" filsys(5)
-.xx "functions" "fabs," "floor, ceil \- absolute value, floor, ceiling" "" floor(3)
-.xx "" "fclose, fflush \- close or" "flush a stream" "" fclose(3)
-.xx "" "" "fopen, freopen, fdopen \- open a stream" "" fopen(3)
-.xx "" "" "fork \- spawn new process" "" fork(2)
-.xx "" "ar \- archive (library) file" "format" "" ar(5)
-.xx "" "arcv \- convert archives to new" "format" "" arcv(1)
-.xx "" "dump, ddate \- incremental dump" "format" "" dump(5)
-.xx "" "core \-" "format of core image file" "" core(5)
-.xx "" "dir \-" "format of directories" "" dir(5)
-.xx "" "filsys, flblk, ino \-" "format of file system volume" "" filsys(5)
-.xx "" "tbl \-" "format tables for nroff or troff" "" tbl(1)
-.xx "" "roff \-" "format text" "" roff(1)
-.xx "" "tp \- DEC/mag tape" "formats" "" tp(5)
-.xx "" "scanf, fscanf, sscanf \-" "formatted input conversion" "" scanf(3)
-.xx "" "printf, fprintf, sprintf \-" "formatted output conversion" "" printf(3)
-.xx "" "troff, nroff \- text" "formatting and typesetting" "" troff(1)
-.xx "" "ms \- macros for" "formatting manuscripts" "" ms(7)
-.xx "" "f77 \-" "Fortran 77 compiler" "" f77(1)
-.xx "" "ratfor \- rational" "Fortran dialect" "" ratfor(1)
-.xx "" "struct \- structure" "Fortran programs" "" struct(1)
-.xx "cookies" "ching," "fortune \- the book of changes and other" "" ching(6)
-.xx "conversion" "printf," "fprintf, sprintf \- formatted output" "" printf(3)
-.xx "stream" "putc, putchar," "fputc, putw \- put character or word on a" "" putc(3)
-.xx "" "puts," "fputs \- put a string on a stream" "" puts(3)
-.xx "" "" "fread, fwrite \- buffered binary input/output" "" fread(3)
-.xx "" "df \- disk" "free" "" df(1)
-.xx "allocator" "malloc," "free, realloc, calloc \- main memory" "" malloc(3)
-.xx "" "fopen," "freopen, fdopen \- open a stream" "" fopen(3)
-.xx "exponent" "" "frexp, ldexp, modf \- split into mantissa and" "" frexp(3)
-.xx "" "scanf," "fscanf, sscanf \- formatted input conversion" "" scanf(3)
-.xx "" "" "fseek, ftell, rewind \- reposition a stream" "" fseek(3)
-.xx "" "stat," "fstat \- get file status" "" stat(2)
-.xx "" "fseek," "ftell, rewind \- reposition a stream" "" fseek(3)
-.xx "" "time," "ftime \- get date and time" "" time(2)
-.xx "" "floor, ceil \- absolute value, floor, ceiling" "functions" "fabs," floor(3)
-.xx "" "intro \- introduction to library" "functions" "" intro(3)
-.xx "" "j0, j1, jn, y0, y1, yn \- bessel" "functions" "" j0(3)
-.xx "" "tan, asin, acos, atan, atan2 \- trigonometric" "functions" "sin, cos," sin(3)
-.xx "" "sinh, cosh, tanh \- hyperbolic" "functions" "" sinh(3)
-.xx "" "fread," "fwrite \- buffered binary input/output" "" fread(3)
-.xx "" "backgammon \- the" "game" "" backgammon(6)
-.xx "" "checkers \-" "game" "" checkers(6)
-.xx "" "moo \- guessing" "game" "" moo(6)
-.xx "" "bj \- the" "game of black jack" "" bj(6)
-.xx "" "chess \- the" "game of chess" "" chess(6)
-.xx "" "reversi \- a" "game of dramatic reversals" "" reversi(6)
-.xx "" "wump \- the" "game of hunt-the-wumpus" "" wump(6)
-.xx "" "hangman, words \- word" "games" "" words(6)
-.xx "" "itom, madd, msub, mult, mdiv, min, mout, pow," "gcd, rpow \- multiple precision integer/" "" mp(3)
-.xx "" "ecvt, fcvt," "gcvt \- output conversion" "" ecvt(3)
-.xx "" "maze \-" "generate a maze problem" "" maze(6)
-.xx "" "mkconf \-" "generate configuration tables" "" mkconf(1)
-.xx "" "makekey \-" "generate encryption key" "" makekey(8)
-.xx "" "abort \-" "generate IOT fault" "" abort(3)
-.xx "" "factor, primes \- factor a number," "generate large primes" "" factor(1)
-.xx "" "ncheck \-" "generate names from i-numbers" "" ncheck(1)
-.xx "" "rand, srand \- random number" "generator" "" rand(3)
-.xx "" "lex \-" "generator of lexical analysis programs" "" lex(1)
-.xx "or word from stream" "" "getc, getchar, fgetc, getw \- get character" "" getc(3)
-.xx "" "getuid, getgid, geteuid," "getegid \- get user and group identity" "" getuid(2)
-.xx "" "" "getenv \- value for environment name" "" getenv(3)
-.xx "identity" "getuid, getgid," "geteuid, getegid \- get user and group" "" getuid(2)
-.xx "endgrent \- get group file entry" "" "getgrent, getgrgid, getgrnam, setgrent," "" getgrent(3)
-.xx "" "" "getlogin \- get login name" "" getlogin(3)
-.xx "" "" "getpass \- read a password" "" getpass(3)
-.xx "" "" "getpid \- get process identification" "" getpid(2)
-.xx "" "" "getpw \- get name from UID" "" getpw(3)
-.xx "endpwent \- get password file entry" "" "getpwent, getpwuid, getpwnam, setpwent," "" getpwent(3)
-.xx "" "" "gets, fgets \- get a string from a stream" "" gets(3)
-.xx "" "" "getty \- set typewriter mode" "" getty(8)
-.xx "and group identity" "" "getuid, getgid, geteuid, getegid \- get user" "" getuid(2)
-.xx "" "getc, getchar, fgetc," "getw \- get character or word from stream" "" getc(3)
-.xx "time to ASCII" "ctime, localtime," "gmtime, asctime, timezone \- convert date and" "" ctime(3)
-.xx "" "setjmp, longjmp \- non-local" "goto" "" setjmp(3)
-.xx "" "graph \- draw a" "graph" "" graph(1)
-.xx "" "plot \-" "graphics filters" "" plot(1)
-.xx "" "plot: openpl et al. \-" "graphics interface" "" plot(3)
-.xx "" "plot \-" "graphics interface" "" plot(5)
-.xx "pattern" "" "grep, egrep, fgrep \- search a file for a" "" grep(1)
-.xx "" "chown, chgrp \- change owner or" "group" "" chown(1)
-.xx "" "newgrp \- log in to a new" "group" "" newgrp(1)
-.xx "" "" "group \- group file" "" group(5)
-.xx "" "getgrgid, getgrnam, setgrent, endgrent \- get" "group file entry" "getgrent," getgrent(3)
-.xx "" "setuid, setgid \- set user and" "group ID" "" setuid(2)
-.xx "" "getgid, geteuid, getegid \- get user and" "group identity" "getuid," getuid(2)
-.xx "" "chown \- change owner and" "group of a file" "" chown(2)
-.xx "" "make \- maintain program" "groups" "" make(1)
-.xx "" "ioctl, stty," "gtty \- control device" "" ioctl(2)
-.xx "" "moo \-" "guessing game" "" moo(6)
-.xx "" "" "hangman, words \- word games" "" words(6)
-.xx "" "" "hier \- file system hierarchy" "" hier(7)
-.xx "" "" "hp \- RH-11/RP04, RP05, RP06 moving-head disk" "" hp(4)
-.xx "" "" "hs \- RH11/RS03-RS04 fixed-head disk file" "" hs(4)
-.xx "" "" "ht \- RH-11/TU-16 magtape interface" "" ht(4)
-.xx "" "wump \- the game of" "hunt-the-wumpus" "" wump(6)
-.xx "" "sinh, cosh, tanh \-" "hyperbolic functions" "" sinh(3)
-.xx "" "" "hypot, cabs \- euclidean distance" "" hypot(3)
-.xx "check" "" "icheck \- file system storage consistency" "" icheck(1)
-.xx "" "setuid, setgid \- set user and group" "ID" "" setuid(2)
-.xx "" "su \- substitute user" "id temporarily" "" su(1)
-.xx "" "getpid \- get process" "identification" "" getpid(2)
-.xx "" "geteuid, getegid \- get user and group" "identity" "getuid, getgid," getuid(2)
-.xx "exit, export, login, newgrp,/" "sh, for, case," "if, while, break, continue, cd, eval, exec," "" sh(1)
-.xx "" "signal \- catch or" "ignore signals" "" signal(2)
-.xx "" "core \- format of core" "image file" "" core(5)
-.xx "" "dump, ddate \-" "incremental dump format" "" dump(5)
-.xx "" "dump \-" "incremental file system dump" "" dump(1)
-.xx "" "restor \-" "incremental file system restore" "" restor(1)
-.xx "" "ptx \- permuted" "index" "" ptx(1)
-.xx "" "strcmp, strncmp, strcpy, strncpy, strlen," "index, rindex \- string operations" "/strncat," string(3)
-.xx "" "" "indir \- indirect system call" "" indir(2)
-.xx "" "" "init, rc \- process control initialization" "" init(8)
-.xx "" "ttys \- terminal" "initialization data" "" ttys(5)
-.xx "" "popen, pclose \-" "initiate I/O to/from a process" "" popen(3)
-.xx "" "filsys, flblk," "ino \- format of file system volume" "" filsys(5)
-.xx "" "clri \- clear" "i-node" "" clri(1)
-.xx "" "scanf, fscanf, sscanf \- formatted" "input conversion" "" scanf(3)
-.xx "" "ungetc \- push character back into" "input stream" "" ungetc(3)
-.xx "" "fread, fwrite \- buffered binary" "input/output" "" fread(3)
-.xx "" "stdio \- standard buffered" "input/output package" "" stdio(3)
-.xx "" "ferror, clearerr, fileno \- stream status" "inquiries" "feof," ferror(3)
-.xx "" "refer, lookbib \- find and" "insert literature references in documents" "" refer(1)
-.xx "" "cat \- phototypesetter" "interface" "" cat(4)
-.xx "" "dn \- DN-11 ACU" "interface" "" dn(4)
-.xx "" "du, dp \- DU-11 201 data-phone" "interface" "" du(4)
-.xx "" "ht \- RH-11/TU-16 magtape" "interface" "" ht(4)
-.xx "" "plot: openpl et al. \- graphics" "interface" "" plot(3)
-.xx "" "plot \- graphics" "interface" "" plot(5)
-.xx "" "tm \- TM-11/TU-10 magtape" "interface" "" tm(4)
-.xx "" "tty \- general terminal" "interface" "" tty(4)
-.xx "" "spline \-" "interpolate smooth curve" "" spline(1)
-.xx "" "pipe \- create an" "interprocess channel" "" pipe(2)
-.xx "" "intro \-" "introduction to commands" "" intro(1)
-.xx "" "intro \-" "introduction to library functions" "" intro(3)
-.xx "numbers" "intro, errno \-" "introduction to system calls and error" "" intro(2)
-.xx "" "ncheck \- generate names from" "i-numbers" "" ncheck(1)
-.xx "" "iostat \- report" "I/O statistics" "" iostat(1)
-.xx "" "popen, pclose \- initiate" "I/O to/from a process" "" popen(3)
-.xx "" "" "ioctl, stty, gtty \- control device" "" ioctl(2)
-.xx "" "" "iostat \- report I/O statistics" "" iostat(1)
-.xx "" "abort \- generate" "IOT fault" "" abort(3)
-.xx "isascii/" "isalpha, isupper, islower, isdigit," "isalnum, isspace, ispunct, isprint, iscntrl," "" ctype(3)
-.xx "" "ttyname," "isatty, ttyslot \- find name of a terminal" "" ttyname(3)
-.xx "" "/isdigit, isalnum, isspace, ispunct, isprint," "iscntrl, isascii \- character classification" "" ctype(3)
-.xx "" "system \-" "issue a shell command" "" system(3)
-.xx "ispunct, isprint, iscntrl, isascii/" "isalpha," "isupper, islower, isdigit, isalnum, isspace," "" ctype(3)
-.xx "gcd, rpow \- multiple precision integer/" "" "itom, madd, msub, mult, mdiv, min, mout, pow," "" mp(3)
-.xx "" "" "j0, j1, jn, y0, y1, yn \- bessel functions" "" j0(3)
-.xx "" "bj \- the game of black" "jack" "" bj(6)
-.xx "" "j0, j1," "jn, y0, y1, yn \- bessel functions" "" j0(3)
-.xx "" "" "join \- relational database operator" "" join(1)
-.xx "" "makekey \- generate encryption" "key" "" makekey(8)
-.xx "" "" "kill \- send signal to a process" "" kill(2)
-.xx "prejudice" "" "kill \- terminate a process with extreme" "" kill(1)
-.xx "" "mem," "kmem \- core memory" "" mem(4)
-.xx "integers and long integers" "" "l3tol, ltol3 \- convert between 3-byte" "" l3tol(3)
-.xx "" "awk \- pattern scanning and processing" "language" "" awk(1)
-.xx "" "bc \- arbitrary-precision arithmetic" "language" "" bc(1)
-.xx "" "shift, times, trap, umask, wait \- command" "language" "/login, newgrp, read, readonly, set," sh(1)
-.xx "" "" "ld \- loader" "" ld(1)
-.xx "exponent" "frexp," "ldexp, modf \- split into mantissa and" "" frexp(3)
-.xx "" "" "lex \- generator of lexical analysis programs" "" lex(1)
-.xx "" "\- find ordering relation for an object" "library" "lorder" lorder(1)
-.xx "" "ar \- archive (" "library) file format" "" ar(5)
-.xx "" "intro \- introduction to" "library functions" "" intro(3)
-.xx "" "ar \- archive and" "library maintainer" "" ar(1)
-.xx "" "col \- filter reverse" "line feeds" "" col(1)
-.xx "" "comm \- select or reject" "lines common to two sorted files" "" comm(1)
-.xx "" "uniq \- report repeated" "lines in a file" "" uniq(1)
-.xx "" "look \- find" "lines in a sorted list" "" look(1)
-.xx "" "rev \- reverse" "lines of a file" "" rev(1)
-.xx "" "ln \- make a" "link" "" ln(1)
-.xx "" "" "link \- link to a file" "" link(2)
-.xx "" "a.out \- assembler and" "link editor output" "" a.out(5)
-.xx "" "link \-" "link to a file" "" link(2)
-.xx "" "" "lint \- a C program verifier" "" lint(1)
-.xx "" "look \- find lines in a sorted" "list" "" look(1)
-.xx "" "nlist \- get entries from name" "list" "" nlist(3)
-.xx "" "nm \- print name" "list" "" nm(1)
-.xx "" "ls \-" "list contents of directory" "" ls(1)
-.xx "" "refer, lookbib \- find and insert" "literature references in documents" "" refer(1)
-.xx "" "" "ln \- make a link" "" ln(1)
-.xx "" "ld \-" "loader" "" ld(1)
-.xx "convert date and time to ASCII" "ctime," "localtime, gmtime, asctime, timezone \-" "" ctime(3)
-.xx "" "end, etext, edata \- last" "locations in program" "" end(3)
-.xx "" "" "lock \- lock a process in primary memory" "" lock(2)
-.xx "" "newgrp \-" "log in to a new group" "" newgrp(1)
-.xx "logarithm, power, square root" "exp," "log, log10, pow, sqrt \- exponential," "" exp(3)
-.xx "" "" "login \- sign on" "" login(1)
-.xx "" "ac \-" "login accounting" "" ac(1)
-.xx "" "getlogin \- get" "login name" "" getlogin(3)
-.xx "" "/continue, cd, eval, exec, exit, export," "login, newgrp, read, readonly, set, shift,/" "" sh(1)
-.xx "" "passwd \- change" "login password" "" passwd(1)
-.xx "" "utmp, wtmp \-" "login records" "" utmp(5)
-.xx "" "setjmp," "longjmp \- non-local goto" "" setjmp(3)
-.xx "" "" "look \- find lines in a sorted list" "" look(1)
-.xx "references in documents" "refer," "lookbib \- find and insert literature" "" refer(1)
-.xx "object library" "" "lorder \- find ordering relation for an" "" lorder(1)
-.xx "" "" "ls \- list contents of directory" "" ls(1)
-.xx "" "" "lseek, tell \- move read/write pointer" "" lseek(2)
-.xx "long integers" "l3tol," "ltol3 \- convert between 3-byte integers and" "" l3tol(3)
-.xx "" "" "m4 \- macro processor" "" m4(1)
-.xx "" "ms \-" "macros for formatting manuscripts" "" ms(7)
-.xx "" "man \-" "macros to typeset manual" "" man(7)
-.xx "rpow \- multiple precision integer/" "itom," "madd, msub, mult, mdiv, min, mout, pow, gcd," "" mp(3)
-.xx "" "tp \- DEC/" "mag tape formats" "" tp(5)
-.xx "" "ht \- RH-11/TU-16" "magtape interface" "" ht(4)
-.xx "" "tm \- TM-11/TU-10" "magtape interface" "" tm(4)
-.xx "" "xsend, xget, enroll \- secret" "mail" "" xsend(1)
-.xx "" "" "mail \- send or receive mail among users" "" mail(1)
-.xx "" "malloc, free, realloc, calloc \-" "main memory allocator" "" malloc(3)
-.xx "" "make \-" "maintain program groups" "" make(1)
-.xx "" "ar \- archive and library" "maintainer" "" ar(1)
-.xx "" "" "make \- maintain program groups" "" make(1)
-.xx "" "mkdir \-" "make a directory" "" mkdir(1)
-.xx "" "mknod \-" "make a directory or a special file" "" mknod(2)
-.xx "" "ln \-" "make a link" "" ln(1)
-.xx "" "mktemp \-" "make a unique file name" "" mktemp(3)
-.xx "" "banner \-" "make long posters" "" banner(6)
-.xx "" "" "makekey \- generate encryption key" "" makekey(8)
-.xx "allocator" "" "malloc, free, realloc, calloc \- main memory" "" malloc(3)
-.xx "" "" "man \- macros to typeset manual" "" man(7)
-.xx "" "" "man \- print sections of this manual" "" man(1)
-.xx "" "tp \-" "manipulate tape archive" "" tp(1)
-.xx "" "frexp, ldexp, modf \- split into" "mantissa and exponent" "" frexp(3)
-.xx "" "man \- print sections of this" "manual" "" man(1)
-.xx "" "man \- macros to typeset" "manual" "" man(7)
-.xx "" "ms \- macros for formatting" "manuscripts" "" ms(7)
-.xx "" "umask \- set file creation mode" "mask" "" umask(2)
-.xx "" "eqn, neqn, checkeq \- typeset" "mathematics" "" eqn(1)
-.xx "" "" "maze \- generate a maze problem" "" maze(6)
-.xx "precision integer/" "itom, madd, msub, mult," "mdiv, min, mout, pow, gcd, rpow \- multiple" "" mp(3)
-.xx "" "bcd, ppt \- convert to antique" "media" "" bcd(6)
-.xx "" "" "mem, kmem \- core memory" "" mem(4)
-.xx "" "lock \- lock a process in primary" "memory" "" lock(2)
-.xx "" "mem, kmem \- core" "memory" "" mem(4)
-.xx "" "malloc, free, realloc, calloc \- main" "memory allocator" "" malloc(3)
-.xx "" "sort \- sort or" "merge files" "" sort(1)
-.xx "" "" "mesg \- permit or deny messages" "" mesg(1)
-.xx "" "perror, sys_errlist, sys_nerr \- system error" "messages" "" perror(3)
-.xx "precision/" "itom, madd, msub, mult, mdiv," "min, mout, pow, gcd, rpow \- multiple" "" mp(3)
-.xx "" "" "mkconf \- generate configuration tables" "" mkconf(1)
-.xx "" "" "mkdir \- make a directory" "" mkdir(1)
-.xx "" "" "mkfs \- construct a file system" "" mkfs(1)
-.xx "" "" "mknod \- build special file" "" mknod(1)
-.xx "" "" "mknod \- make a directory or a special file" "" mknod(2)
-.xx "" "" "mktemp \- make a unique file name" "" mktemp(3)
-.xx "" "chmod \- change" "mode" "" chmod(1)
-.xx "" "getty \- set typewriter" "mode" "" getty(8)
-.xx "" "umask \- set file creation" "mode mask" "" umask(2)
-.xx "" "chmod \- change" "mode of file" "" chmod(2)
-.xx "" "frexp, ldexp," "modf \- split into mantissa and exponent" "" frexp(3)
-.xx "" "touch \- update date last" "modified of a file" "" touch(1)
-.xx "" "" "monitor \- prepare execution profile" "" monitor(3)
-.xx "" "" "moo \- guessing game" "" moo(6)
-.xx "" "mount, umount \-" "mount and dismount file system" "" mount(1)
-.xx "" "mount, umount \-" "mount or remove file system" "" mount(2)
-.xx "system" "" "mount, umount \- mount and dismount file" "" mount(1)
-.xx "" "" "mount, umount \- mount or remove file system" "" mount(2)
-.xx "" "mtab \-" "mounted file system table" "" mtab(5)
-.xx "integer/" "itom, madd, msub, mult, mdiv, min," "mout, pow, gcd, rpow \- multiple precision" "" mp(3)
-.xx "" "mv \-" "move or rename files and directories" "" mv(1)
-.xx "" "lseek, tell \-" "move read/write pointer" "" lseek(2)
-.xx "" "hp \- RH-11/RP04, RP05, RP06" "moving-head disk" "" hp(4)
-.xx "" "rp \- RP-11/RP03" "moving-head disk" "" rp(4)
-.xx "" "" "ms \- macros for formatting manuscripts" "" ms(7)
-.xx "\- multiple precision integer/" "itom, madd," "msub, mult, mdiv, min, mout, pow, gcd, rpow" "" mp(3)
-.xx "" "" "mtab \- mounted file system table" "" mtab(5)
-.xx "multiple precision integer/" "itom, madd, msub," "mult, mdiv, min, mout, pow, gcd, rpow \-" "" mp(3)
-.xx "" "" "mv \- move or rename files and directories" "" mv(1)
-.xx "" "getenv \- value for environment" "name" "" getenv(3)
-.xx "" "getlogin \- get login" "name" "" getlogin(3)
-.xx "" "mktemp \- make a unique file" "name" "" mktemp(3)
-.xx "" "pwd \- working directory" "name" "" pwd(1)
-.xx "" "tty \- get terminal" "name" "" tty(1)
-.xx "" "getpw \- get" "name from UID" "" getpw(3)
-.xx "" "nlist \- get entries from" "name list" "" nlist(3)
-.xx "" "nm \- print" "name list" "" nm(1)
-.xx "" "ttyname, isatty, ttyslot \- find" "name of a terminal" "" ttyname(3)
-.xx "" "terminals\- conventional" "names" "" term(7)
-.xx "" "ncheck \- generate" "names from i-numbers" "" ncheck(1)
-.xx "" "dumpdir \- print the" "names of files on a dump tape" "" dumpdir(1)
-.xx "" "" "ncheck \- generate names from i-numbers" "" ncheck(1)
-.xx "" "eqn," "neqn, checkeq \- typeset mathematics" "" eqn(1)
-.xx "" "creat \- create a" "new file" "" creat(2)
-.xx "" "arcv \- convert archives to" "new format" "" arcv(1)
-.xx "" "newgrp \- log in to a" "new group" "" newgrp(1)
-.xx "" "fork \- spawn" "new process" "" fork(2)
-.xx "" "" "newgrp \- log in to a new group" "" newgrp(1)
-.xx "trap,/" "/cd, eval, exec, exit, export, login," "newgrp, read, readonly, set, shift, times," "" sh(1)
-.xx "" "dbminit, fetch, store, delete, firstkey," "nextkey \- data base subroutines" "" dbm(3)
-.xx "" "" "nice \- set program priority" "" nice(2)
-.xx "" "" "nice, nohup \- run a command at low priority" "" nice(1)
-.xx "" "" "nlist \- get entries from name list" "" nlist(3)
-.xx "" "" "nm \- print name list" "" nm(1)
-.xx "" "clri \- clear i-" "node" "" clri(1)
-.xx "" "nice," "nohup \- run a command at low priority" "" nice(1)
-.xx "" "setjmp, longjmp \-" "non-local goto" "" setjmp(3)
-.xx "" "troff," "nroff \- text formatting and typesetting" "" troff(1)
-.xx "" "tbl \- format tables for" "nroff or troff" "" tbl(1)
-.xx "" "deroff \- remove" "nroff, troff, tbl and eqn constructs" "" deroff(1)
-.xx "" "" "null \- data sink" "" null(4)
-.xx "" "arithmetic \- provide drill in" "number facts" "" arithmetic(6)
-.xx "" "factor, primes \- factor a" "number, generate large primes" "" factor(1)
-.xx "" "rand, srand \- random" "number generator" "" rand(3)
-.xx "" "atof, atoi, atol \- convert ASCII to" "numbers" "" atof(3)
-.xx "" "\- introduction to system calls and error" "numbers" "intro, errno" intro(2)
-.xx "" "ncheck \- generate names from i-" "numbers" "" ncheck(1)
-.xx "" "size \- size of an" "object file" "" size(1)
-.xx "" "lorder \- find ordering relation for an" "object library" "" lorder(1)
-.xx "" "od \-" "octal dump" "" od(1)
-.xx "" "" "open \- open for reading or writing" "" open(2)
-.xx "" "fopen, freopen, fdopen \-" "open a stream" "" fopen(3)
-.xx "" "dup, dup2 \- duplicate an" "open file descriptor" "" dup(2)
-.xx "" "open \-" "open for reading or writing" "" open(2)
-.xx "" "plot:" "openpl et al. \- graphics interface" "" plot(3)
-.xx "" "strncpy, strlen, index, rindex \- string" "operations" "/strncat, strcmp, strncmp, strcpy," string(3)
-.xx "" "join \- relational database" "operator" "" join(1)
-.xx "" "stty \- set terminal" "options" "" stty(1)
-.xx "" "lorder \- find" "ordering relation for an object library" "" lorder(1)
-.xx "" "a.out \- assembler and link editor" "output" "" a.out(5)
-.xx "" "fread, fwrite \- buffered binary input/" "output" "" fread(3)
-.xx "" "ecvt, fcvt, gcvt \-" "output conversion" "" ecvt(3)
-.xx "" "printf, fprintf, sprintf \- formatted" "output conversion" "" printf(3)
-.xx "" "stdio \- standard buffered input/" "output package" "" stdio(3)
-.xx "" "chown \- change" "owner and group of a file" "" chown(2)
-.xx "" "chown, chgrp \- change" "owner or group" "" chown(1)
-.xx "" "quot \- summarize file system" "ownership" "" quot(1)
-.xx "" "pk \-" "packet driver" "" pk(4)
-.xx "" "pkopen, pkclose, pkread, pkwrite, pkfail \-" "packet driver simulator" "" pkopen(3)
-.xx "" "pkon, pkoff \- establish" "packet protocol" "" pkon(2)
-.xx "" "tk \-" "paginator for the Tektronix 4014" "" tk(1)
-.xx "" "" "passwd \- change login password" "" passwd(1)
-.xx "" "" "passwd \- password file" "" passwd(5)
-.xx "" "getpass \- read a" "password" "" getpass(3)
-.xx "" "passwd \- change login" "password" "" passwd(1)
-.xx "" "passwd \-" "password file" "" passwd(5)
-.xx "" "getpwuid, getpwnam, setpwent, endpwent \- get" "password file entry" "getpwent," getpwent(3)
-.xx "" "grep, egrep, fgrep \- search a file for a" "pattern" "" grep(1)
-.xx "" "awk \-" "pattern scanning and processing language" "" awk(1)
-.xx "" "" "pause \- stop until signal" "" pause(2)
-.xx "" "cc," "pcc \- C compiler" "" cc(1)
-.xx "" "popen," "pclose \- initiate I/O to/from a process" "" popen(3)
-.xx "" "mesg \-" "permit or deny messages" "" mesg(1)
-.xx "" "ptx \-" "permuted index" "" ptx(1)
-.xx "messages" "" "perror, sys_errlist, sys_nerr \- system error" "" perror(3)
-.xx "" "du, dp \- DU-11 201 data-" "phone interface" "" du(4)
-.xx "" "cat \-" "phototypesetter interface" "" cat(4)
-.xx "" "tc \-" "photypesetter simulator" "" tc(1)
-.xx "addresses" "" "phys \- allow a process to access physical" "" phys(2)
-.xx "" "" "pipe \- create an interprocess channel" "" pipe(2)
-.xx "" "tee \-" "pipe fitting" "" tee(1)
-.xx "" "" "pk \- packet driver" "" pk(4)
-.xx "driver simulator" "pkopen," "pkclose, pkread, pkwrite, pkfail \- packet" "" pkopen(3)
-.xx "" "pkon," "pkoff \- establish packet protocol" "" pkon(2)
-.xx "packet driver simulator" "" "pkopen, pkclose, pkread, pkwrite, pkfail \-" "" pkopen(3)
-.xx "" "" "plot \- graphics filters" "" plot(1)
-.xx "" "" "plot \- graphics interface" "" plot(5)
-.xx "" "" "plot: openpl et al. \- graphics interface" "" plot(3)
-.xx "" "vp \- Versatec printer-" "plotter" "" vp(4)
-.xx "" "lseek, tell \- move read/write" "pointer" "" lseek(2)
-.xx "process" "" "popen, pclose \- initiate I/O to/from a" "" popen(3)
-.xx "" "banner \- make long" "posters" "" banner(6)
-.xx "" "itom, madd, msub, mult, mdiv, min, mout," "pow, gcd, rpow \- multiple precision integer/" "" mp(3)
-.xx "square root" "exp, log, log10," "pow, sqrt \- exponential, logarithm, power," "" exp(3)
-.xx "" "bcd," "ppt \- convert to antique media" "" bcd(6)
-.xx "" "" "pr \- print file" "" pr(1)
-.xx "" "bc \- arbitrary-" "precision arithmetic language" "" bc(1)
-.xx "" "mdiv, min, mout, pow, gcd, rpow \- multiple" "precision integer arithmetic" "/msub, mult," mp(3)
-.xx "" "monitor \-" "prepare execution profile" "" monitor(3)
-.xx "" "lock \- lock a process in" "primary memory" "" lock(2)
-.xx "" "primes \- factor a number, generate large" "primes" "factor," factor(1)
-.xx "" "types \-" "primitive system data types" "" types(5)
-.xx "" "cat \- catenate and" "print" "" cat(1)
-.xx "" "date \-" "print and set the date" "" date(1)
-.xx "" "cal \-" "print calendar" "" cal(1)
-.xx "" "pr \-" "print file" "" pr(1)
-.xx "" "nm \-" "print name list" "" nm(1)
-.xx "" "man \-" "print sections of this manual" "" man(1)
-.xx "" "pstat \-" "print system facts" "" pstat(1)
-.xx "" "dumpdir \-" "print the names of files on a dump tape" "" dumpdir(1)
-.xx "" "vp \- Versatec" "printer-plotter" "" vp(4)
-.xx "conversion" "" "printf, fprintf, sprintf \- formatted output" "" printf(3)
-.xx "" "nice, nohup \- run a command at low" "priority" "" nice(1)
-.xx "" "nice \- set program" "priority" "" nice(2)
-.xx "" "boot \- startup" "procedures" "" boot(8)
-.xx "" "exit \- terminate" "process" "" exit(2)
-.xx "" "fork \- spawn new" "process" "" fork(2)
-.xx "" "kill \- send signal to a" "process" "" kill(2)
-.xx "" "popen, pclose \- initiate I/O to/from a" "process" "" popen(3)
-.xx "" "wait \- await completion of" "process" "" wait(1)
-.xx "" "init, rc \-" "process control initialization" "" init(8)
-.xx "" "getpid \- get" "process identification" "" getpid(2)
-.xx "" "lock \- lock a" "process in primary memory" "" lock(2)
-.xx "" "ps \-" "process status" "" ps(1)
-.xx "" "times \- get" "process times" "" times(2)
-.xx "" "phys \- allow a" "process to access physical addresses" "" phys(2)
-.xx "" "wait \- wait for" "process to terminate" "" wait(2)
-.xx "" "ptrace \-" "process trace" "" ptrace(2)
-.xx "" "kill \- terminate a" "process with extreme prejudice" "" kill(1)
-.xx "" "awk \- pattern scanning and" "processing language" "" awk(1)
-.xx "" "m4 \- macro" "processor" "" m4(1)
-.xx "" "" "prof \- display profile data" "" prof(1)
-.xx "" "" "profil \- execution time profile" "" profil(2)
-.xx "" "monitor \- prepare execution" "profile" "" monitor(3)
-.xx "" "profil \- execution time" "profile" "" profil(2)
-.xx "" "prof \- display" "profile data" "" prof(1)
-.xx "" "end, etext, edata \- last locations in" "program" "" end(3)
-.xx "" "units \- conversion" "program" "" units(1)
-.xx "" "cb \- C" "program beautifier" "" cb(1)
-.xx "" "make \- maintain" "program groups" "" make(1)
-.xx "" "nice \- set" "program priority" "" nice(2)
-.xx "" "assert \-" "program verification" "" assert(3)
-.xx "" "lint \- a C" "program verifier" "" lint(1)
-.xx "" "lex \- generator of lexical analysis" "programs" "" lex(1)
-.xx "" "struct \- structure Fortran" "programs" "" struct(1)
-.xx "" "pkon, pkoff \- establish packet" "protocol" "" pkon(2)
-.xx "" "arithmetic \-" "provide drill in number facts" "" arithmetic(6)
-.xx "" "true, false \-" "provide truth values" "" true(1)
-.xx "" "" "ps \- process status" "" ps(1)
-.xx "" "" "pstat \- print system facts" "" pstat(1)
-.xx "" "" "ptrace \- process trace" "" ptrace(2)
-.xx "" "" "ptx \- permuted index" "" ptx(1)
-.xx "" "ungetc \-" "push character back into input stream" "" ungetc(3)
-.xx "" "puts, fputs \-" "put a string on a stream" "" puts(3)
-.xx "" "putc, putchar, fputc, putw \-" "put character or word on a stream" "" putc(3)
-.xx "" "" "puts, fputs \- put a string on a stream" "" puts(3)
-.xx "" "putc, putchar, fputc," "putw \- put character or word on a stream" "" putc(3)
-.xx "" "" "pwd \- working directory name" "" pwd(1)
-.xx "" "" "qsort \- quicker sort" "" qsort(3)
-.xx "" "" "quiz \- test your knowledge" "" quiz(6)
-.xx "" "" "quot \- summarize file system ownership" "" quot(1)
-.xx "" "" "rand, srand \- random number generator" "" rand(3)
-.xx "" "" "ratfor \- rational Fortran dialect" "" ratfor(1)
-.xx "" "init," "rc \- process control initialization" "" init(8)
-.xx "" "" "read \- read from file" "" read(2)
-.xx "" "getpass \-" "read a password" "" getpass(3)
-.xx "" "read \-" "read from file" "" read(2)
-.xx "" "/cd, eval, exec, exit, export, login, newgrp," "read, readonly, set, shift, times, trap,/" "" sh(1)
-.xx "" "open \- open for" "reading or writing" "" open(2)
-.xx "" "/exec, exit, export, login, newgrp, read," "readonly, set, shift, times, trap, umask,/" "" sh(1)
-.xx "" "lseek, tell \- move" "read/write pointer" "" lseek(2)
-.xx "" "malloc, free," "realloc, calloc \- main memory allocator" "" malloc(3)
-.xx "" "mail \- send or" "receive mail among users" "" mail(1)
-.xx "" "utmp, wtmp \- login" "records" "" utmp(5)
-.xx "references in documents" "" "refer, lookbib \- find and insert literature" "" refer(1)
-.xx "" "comm \- select or" "reject lines common to two sorted files" "" comm(1)
-.xx "" "lorder \- find ordering" "relation for an object library" "" lorder(1)
-.xx "" "join \-" "relational database operator" "" join(1)
-.xx "" "strip \- remove symbols and" "relocation bits" "" strip(1)
-.xx "" "calendar \-" "reminder service" "" calendar(1)
-.xx "" "unlink \-" "remove directory entry" "" unlink(2)
-.xx "" "mount, umount \- mount or" "remove file system" "" mount(2)
-.xx "" "deroff \-" "remove nroff, troff, tbl and eqn constructs" "" deroff(1)
-.xx "" "strip \-" "remove symbols and relocation bits" "" strip(1)
-.xx "" "rm, rmdir \-" "remove (unlink) files" "" rm(1)
-.xx "" "mv \- move or" "rename files and directories" "" mv(1)
-.xx "" "uniq \- report" "repeated lines in a file" "" uniq(1)
-.xx "" "iostat \-" "report I/O statistics" "" iostat(1)
-.xx "" "uniq \-" "report repeated lines in a file" "" uniq(1)
-.xx "" "fseek, ftell, rewind \-" "reposition a stream" "" fseek(3)
-.xx "" "" "restor \- incremental file system restore" "" restor(1)
-.xx "" "" "rev \- reverse lines of a file" "" rev(1)
-.xx "" "reversi \- a game of dramatic" "reversals" "" reversi(6)
-.xx "" "col \- filter" "reverse line feeds" "" col(1)
-.xx "" "rev \-" "reverse lines of a file" "" rev(1)
-.xx "" "" "reversi \- a game of dramatic reversals" "" reversi(6)
-.xx "" "fseek, ftell," "rewind \- reposition a stream" "" fseek(3)
-.xx "" "" "rf \- RF11/RS11 fixed-head disk file" "" rf(4)
-.xx "" "hp \-" "RH-11/RP04, RP05, RP06 moving-head disk" "" hp(4)
-.xx "" "hs \-" "RH11/RS03-RS04 fixed-head disk file" "" hs(4)
-.xx "" "ht \-" "RH-11/TU-16 magtape interface" "" ht(4)
-.xx "" "strncmp, strcpy, strncpy, strlen, index," "rindex \- string operations" "/strncat, strcmp," string(3)
-.xx "" "" "rk \- RK-11/RK03 or RK05 disk" "" rk(4)
-.xx "" "" "rm, rmdir \- remove (unlink) files" "" rm(1)
-.xx "" "" "roff \- format text" "" roff(1)
-.xx "" "sqrt \- exponential, logarithm, power, square" "root" "exp, log, log10, pow," exp(3)
-.xx "" "" "rp \- RP-11/RP03 moving-head disk" "" rp(4)
-.xx "" "hp \- RH-11/" "RP04, RP05, RP06 moving-head disk" "" hp(4)
-.xx "" "rp \-" "RP-11/RP03 moving-head disk" "" rp(4)
-.xx "" "/madd, msub, mult, mdiv, min, mout, pow, gcd," "rpow \- multiple precision integer arithmetic" "" mp(3)
-.xx "" "hs \- RH11/" "RS03-RS04 fixed-head disk file" "" hs(4)
-.xx "" "rf \- RF11/" "RS11 fixed-head disk file" "" rf(4)
-.xx "" "nice, nohup \-" "run a command at low priority" "" nice(1)
-.xx "" "" "sa, accton \- system accounting" "" sa(1)
-.xx "" "brk," "sbrk, break \- change core allocation" "" brk(2)
-.xx "conversion" "" "scanf, fscanf, sscanf \- formatted input" "" scanf(3)
-.xx "" "awk \- pattern" "scanning and processing language" "" awk(1)
-.xx "" "alarm \-" "schedule signal after specified time" "" alarm(2)
-.xx "" "grep, egrep, fgrep \-" "search a file for a pattern" "" grep(1)
-.xx "" "xsend, xget, enroll \-" "secret mail" "" xsend(1)
-.xx "" "man \- print" "sections of this manual" "" man(1)
-.xx "" "" "sed \- stream editor" "" sed(1)
-.xx "files" "comm \-" "select or reject lines common to two sorted" "" comm(1)
-.xx "" "mail \-" "send or receive mail among users" "" mail(1)
-.xx "" "kill \-" "send signal to a process" "" kill(2)
-.xx "" "ascii \- map of ASCII character" "set" "" ascii(7)
-.xx "" "umask \-" "set file creation mode mask" "" umask(2)
-.xx "" "utime \-" "set file times" "" utime(2)
-.xx "" "nice \-" "set program priority" "" nice(2)
-.xx "" "/exit, export, login, newgrp, read, readonly," "set, shift, times, trap, umask, wait \-/" "" sh(1)
-.xx "" "stty \-" "set terminal options" "" stty(1)
-.xx "" "tabs \-" "set terminal tabs" "" tabs(1)
-.xx "" "date \- print and" "set the date" "" date(1)
-.xx "" "stime \-" "set time" "" stime(2)
-.xx "" "getty \-" "set typewriter mode" "" getty(8)
-.xx "" "setuid, setgid \-" "set user and group ID" "" setuid(2)
-.xx "" "" "setbuf \- assign buffering to a stream" "" setbuf(3)
-.xx "" "setuid," "setgid \- set user and group ID" "" setuid(2)
-.xx "" "getgrent, getgrgid, getgrnam," "setgrent, endgrent \- get group file entry" "" getgrent(3)
-.xx "" "" "setjmp, longjmp \- non-local goto" "" setjmp(3)
-.xx "" "crypt," "setkey, encrypt \- DES encryption" "" crypt(3)
-.xx "" "getpwent, getpwuid, getpwnam," "setpwent, endpwent \- get password file entry" "" getpwent(3)
-.xx "" "" "setuid, setgid \- set user and group ID" "" setuid(2)
-.xx "cd, eval, exec, exit, export, login, newgrp,/" "" "sh, for, case, if, while, break, continue," "" sh(1)
-.xx "" "system \- issue a" "shell command" "" system(3)
-.xx "" "/export, login, newgrp, read, readonly, set," "shift, times, trap, umask, wait \- command/" "" sh(1)
-.xx "" "login \-" "sign on" "" login(1)
-.xx "" "pause \- stop until" "signal" "" pause(2)
-.xx "" "" "signal \- catch or ignore signals" "" signal(2)
-.xx "" "alarm \- schedule" "signal after specified time" "" alarm(2)
-.xx "" "kill \- send" "signal to a process" "" kill(2)
-.xx "" "signal \- catch or ignore" "signals" "" signal(2)
-.xx "" "pkread, pkwrite, pkfail \- packet driver" "simulator" "pkopen, pkclose," pkopen(3)
-.xx "" "tc \- photypesetter" "simulator" "" tc(1)
-.xx "trigonometric functions" "" "sin, cos, tan, asin, acos, atan, atan2 \-" "" sin(3)
-.xx "" "" "sinh, cosh, tanh \- hyperbolic functions" "" sinh(3)
-.xx "" "null \- data" "sink" "" null(4)
-.xx "" "" "size \- size of an object file" "" size(1)
-.xx "" "" "sleep \- suspend execution for an interval" "" sleep(1)
-.xx "" "" "sleep \- suspend execution for interval" "" sleep(3)
-.xx "" "spline \- interpolate" "smooth curve" "" spline(1)
-.xx "" "qsort \- quicker" "sort" "" qsort(3)
-.xx "" "tsort \- topological" "sort" "" tsort(1)
-.xx "" "" "sort \- sort or merge files" "" sort(1)
-.xx "" "comm \- select or reject lines common to two" "sorted files" "" comm(1)
-.xx "" "look \- find lines in a" "sorted list" "" look(1)
-.xx "" "fork \-" "spawn new process" "" fork(2)
-.xx "" "alarm \- schedule signal after" "specified time" "" alarm(2)
-.xx "errors" "" "spell, spellin, spellout \- find spelling" "" spell(1)
-.xx "" "" "spline \- interpolate smooth curve" "" spline(1)
-.xx "" "" "split \- split a file into pieces" "" split(1)
-.xx "" "frexp, ldexp, modf \-" "split into mantissa and exponent" "" frexp(3)
-.xx "" "printf, fprintf," "sprintf \- formatted output conversion" "" printf(3)
-.xx "root" "exp, log, log10, pow," "sqrt \- exponential, logarithm, power, square" "" exp(3)
-.xx "" "rand," "srand \- random number generator" "" rand(3)
-.xx "" "scanf, fscanf," "sscanf \- formatted input conversion" "" scanf(3)
-.xx "" "stdio \-" "standard buffered input/output package" "" stdio(3)
-.xx "" "boot \-" "startup procedures" "" boot(8)
-.xx "" "" "stat, fstat \- get file status" "" stat(2)
-.xx "" "iostat \- report I/O" "statistics" "" iostat(1)
-.xx "" "ps \- process" "status" "" ps(1)
-.xx "" "stat, fstat \- get file" "status" "" stat(2)
-.xx "" "feof, ferror, clearerr, fileno \- stream" "status inquiries" "" ferror(3)
-.xx "package" "" "stdio \- standard buffered input/output" "" stdio(3)
-.xx "" "" "stime \- set time" "" stime(2)
-.xx "" "pause \-" "stop until signal" "" pause(2)
-.xx "" "icheck \- file system" "storage consistency check" "" icheck(1)
-.xx "subroutines" "dbminit, fetch," "store, delete, firstkey, nextkey \- data base" "" dbm(3)
-.xx "strncpy, strlen, index, rindex \- string/" "" "strcat, strncat, strcmp, strncmp, strcpy," "" string(3)
-.xx "" "fclose, fflush \- close or flush a" "stream" "" fclose(3)
-.xx "" "fopen, freopen, fdopen \- open a" "stream" "" fopen(3)
-.xx "" "fseek, ftell, rewind \- reposition a" "stream" "" fseek(3)
-.xx "" "fgetc, getw \- get character or word from" "stream" "getc, getchar," getc(3)
-.xx "" "gets, fgets \- get a string from a" "stream" "" gets(3)
-.xx "" "fputc, putw \- put character or word on a" "stream" "putc, putchar," putc(3)
-.xx "" "puts, fputs \- put a string on a" "stream" "" puts(3)
-.xx "" "setbuf \- assign buffering to a" "stream" "" setbuf(3)
-.xx "" "ungetc \- push character back into input" "stream" "" ungetc(3)
-.xx "" "sed \-" "stream editor" "" sed(1)
-.xx "" "feof, ferror, clearerr, fileno \-" "stream status inquiries" "" ferror(3)
-.xx "" "gets, fgets \- get a" "string from a stream" "" gets(3)
-.xx "" "puts, fputs \- put a" "string on a stream" "" puts(3)
-.xx "" "strcpy, strncpy, strlen, index, rindex \-" "string operations" "/strncat, strcmp, strncmp," string(3)
-.xx "" "" "strip \- remove symbols and relocation bits" "" strip(1)
-.xx "" "basename \-" "strip filename affixes" "" basename(1)
-.xx "" "/strncat, strcmp, strncmp, strcpy, strncpy," "strlen, index, rindex \- string operations" "" string(3)
-.xx "" "" "struct \- structure Fortran programs" "" struct(1)
-.xx "" "" "stty \- set terminal options" "" stty(1)
-.xx "" "ioctl," "stty, gtty \- control device" "" ioctl(2)
-.xx "" "" "su \- substitute user id temporarily" "" su(1)
-.xx "" "store, delete, firstkey, nextkey \- data base" "subroutines" "dbminit, fetch," dbm(3)
-.xx "" "su \-" "substitute user id temporarily" "" su(1)
-.xx "" "" "sum \- sum and count blocks in a file" "" sum(1)
-.xx "" "du \-" "summarize disk usage" "" du(1)
-.xx "" "quot \-" "summarize file system ownership" "" quot(1)
-.xx "" "sync \- update the" "super block" "" sync(1)
-.xx "" "update \- periodically update the" "super block" "" update(8)
-.xx "" "sync \- update" "super-block" "" sync(2)
-.xx "" "sleep \-" "suspend execution for an interval" "" sleep(1)
-.xx "" "sleep \-" "suspend execution for interval" "" sleep(3)
-.xx "" "" "swab \- swap bytes" "" swab(3)
-.xx "" "strip \- remove" "symbols and relocation bits" "" strip(1)
-.xx "" "" "sync \- update super-block" "" sync(2)
-.xx "" "" "sync \- update the super block" "" sync(1)
-.xx "messages" "perror," "sys_errlist, sys_nerr \- system error" "" perror(3)
-.xx "" "mtab \- mounted file system" "table" "" mtab(5)
-.xx "" "mkconf \- generate configuration" "tables" "" mkconf(1)
-.xx "" "tbl \- format" "tables for nroff or troff" "" tbl(1)
-.xx "" "tabs \- set terminal" "tabs" "" tabs(1)
-.xx "" "" "tail \- deliver the last part of a file" "" tail(1)
-.xx "functions" "sin, cos," "tan, asin, acos, atan, atan2 \- trigonometric" "" sin(3)
-.xx "" "sinh, cosh," "tanh \- hyperbolic functions" "" sinh(3)
-.xx "" "dumpdir \- print the names of files on a dump" "tape" "" dumpdir(1)
-.xx "" "tp \- manipulate" "tape archive" "" tp(1)
-.xx "" "tar \-" "tape archiver" "" tar(1)
-.xx "" "tp \- DEC/mag" "tape formats" "" tp(5)
-.xx "" "" "tar \- tape archiver" "" tar(1)
-.xx "" "" "tbl \- format tables for nroff or troff" "" tbl(1)
-.xx "" "deroff \- remove nroff, troff," "tbl and eqn constructs" "" deroff(1)
-.xx "" "" "tc \- photypesetter simulator" "" tc(1)
-.xx "" "" "tc \- TC-11/TU56 DECtape" "" tc(4)
-.xx "" "" "tee \- pipe fitting" "" tee(1)
-.xx "" "tk \- paginator for the" "Tektronix 4014" "" tk(1)
-.xx "" "lseek," "tell \- move read/write pointer" "" lseek(2)
-.xx "" "su \- substitute user id" "temporarily" "" su(1)
-.xx "" "ttyname, isatty, ttyslot \- find name of a" "terminal" "" ttyname(3)
-.xx "" "ttys \-" "terminal initialization data" "" ttys(5)
-.xx "" "tty \- general" "terminal interface" "" tty(4)
-.xx "" "tty \- get" "terminal name" "" tty(1)
-.xx "" "stty \- set" "terminal options" "" stty(1)
-.xx "" "tabs \- set" "terminal tabs" "" tabs(1)
-.xx "" "" "terminals\- conventional names" "" term(7)
-.xx "" "wait \- wait for process to" "terminate" "" wait(2)
-.xx "" "kill \-" "terminate a process with extreme prejudice" "" kill(1)
-.xx "" "exit \-" "terminate process" "" exit(2)
-.xx "" "" "test \- condition command" "" test(1)
-.xx "" "quiz \-" "test your knowledge" "" quiz(6)
-.xx "" "roff \- format" "text" "" roff(1)
-.xx "" "ed \-" "text editor" "" ed(1)
-.xx "" "troff, nroff \-" "text formatting and typesetting" "" troff(1)
-.xx "" "ttt, cubic \-" "tic-tac-toe" "" ttt(6)
-.xx "" "alarm \- schedule signal after specified" "time" "" alarm(2)
-.xx "" "at \- execute commands at a later" "time" "" at(1)
-.xx "" "stime \- set" "time" "" stime(2)
-.xx "" "time, ftime \- get date and" "time" "" time(2)
-.xx "" "" "time \- time a command" "" time(1)
-.xx "" "" "time, ftime \- get date and time" "" time(2)
-.xx "" "profil \- execution" "time profile" "" profil(2)
-.xx "" "gmtime, asctime, timezone \- convert date and" "time to ASCII" "ctime, localtime," ctime(3)
-.xx "" "times \- get process" "times" "" times(2)
-.xx "" "utime \- set file" "times" "" utime(2)
-.xx "" "" "times \- get process times" "" times(2)
-.xx "" "/login, newgrp, read, readonly, set, shift," "times, trap, umask, wait \- command language" "" sh(1)
-.xx "" "ctime, localtime, gmtime, asctime," "timezone \- convert date and time to ASCII" "" ctime(3)
-.xx "" "" "tk \- paginator for the Tektronix 4014" "" tk(1)
-.xx "" "" "tm \- TM-11/TU-10 magtape interface" "" tm(4)
-.xx "" "tsort \-" "topological sort" "" tsort(1)
-.xx "" "" "touch \- update date last modified of a file" "" touch(1)
-.xx "" "" "tp \- DEC/mag tape formats" "" tp(5)
-.xx "" "" "tp \- manipulate tape archive" "" tp(1)
-.xx "" "" "tr \- translate characters" "" tr(1)
-.xx "" "ptrace \- process" "trace" "" ptrace(2)
-.xx "" "tr \-" "translate characters" "" tr(1)
-.xx "" "newgrp, read, readonly, set, shift, times," "trap, umask, wait \- command language" "/login," sh(1)
-.xx "" "sin, cos, tan, asin, acos, atan, atan2 \-" "trigonometric functions" "" sin(3)
-.xx "" "tbl \- format tables for nroff or" "troff" "" tbl(1)
-.xx "typesetting" "" "troff, nroff \- text formatting and" "" troff(1)
-.xx "" "deroff \- remove nroff," "troff, tbl and eqn constructs" "" deroff(1)
-.xx "" "" "true, false \- provide truth values" "" true(1)
-.xx "" "" "tsort \- topological sort" "" tsort(1)
-.xx "" "" "ttt, cubic \- tic-tac-toe" "" ttt(6)
-.xx "" "" "tty \- general terminal interface" "" tty(4)
-.xx "" "" "tty \- get terminal name" "" tty(1)
-.xx "terminal" "" "ttyname, isatty, ttyslot \- find name of a" "" ttyname(3)
-.xx "" "" "ttys \- terminal initialization data" "" ttys(5)
-.xx "" "ttyname, isatty," "ttyslot \- find name of a terminal" "" ttyname(3)
-.xx "" "tm \- TM-11/" "TU-10 magtape interface" "" tm(4)
-.xx "" "ht \- RH-11/" "TU-16 magtape interface" "" ht(4)
-.xx "" "tc \- TC-11/" "TU56 DECtape" "" tc(4)
-.xx "" "file \- determine file" "type" "" file(1)
-.xx "" "types \- primitive system data" "types" "" types(5)
-.xx "" "man \- macros to" "typeset manual" "" man(7)
-.xx "" "eqn, neqn, checkeq \-" "typeset mathematics" "" eqn(1)
-.xx "" "troff, nroff \- text formatting and" "typesetting" "" troff(1)
-.xx "" "getty \- set" "typewriter mode" "" getty(8)
-.xx "" "getpw \- get name from" "UID" "" getpw(3)
-.xx "" "" "umask \- set file creation mode mask" "" umask(2)
-.xx "" "read, readonly, set, shift, times, trap," "umask, wait \- command language" "/newgrp," sh(1)
-.xx "" "mount," "umount \- mount and dismount file system" "" mount(1)
-.xx "" "mount," "umount \- mount or remove file system" "" mount(2)
-.xx "stream" "" "ungetc \- push character back into input" "" ungetc(3)
-.xx "" "" "uniq \- report repeated lines in a file" "" uniq(1)
-.xx "" "mktemp \- make a" "unique file name" "" mktemp(3)
-.xx "" "" "units \- conversion program" "" units(1)
-.xx "" "cu \- call" "UNIX" "" cu(1)
-.xx "" "uux \- unix to" "unix command execution" "" uux(1)
-.xx "" "uucp, uulog \- unix to" "unix copy" "" uucp(1)
-.xx "" "uux \-" "unix to unix command execution" "" uux(1)
-.xx "" "uucp, uulog \-" "unix to unix copy" "" uucp(1)
-.xx "" "" "unlink \- remove directory entry" "" unlink(2)
-.xx "" "rm, rmdir \- remove (" "unlink) files" "" rm(1)
-.xx "" "" "update \- periodically update the super block" "" update(8)
-.xx "" "touch \-" "update date last modified of a file" "" touch(1)
-.xx "" "sync \-" "update super-block" "" sync(2)
-.xx "" "sync \-" "update the super block" "" sync(1)
-.xx "" "update \- periodically" "update the super block" "" update(8)
-.xx "" "du \- summarize disk" "usage" "" du(1)
-.xx "" "write \- write to another" "user" "" write(1)
-.xx "" "setuid, setgid \- set" "user and group ID" "" setuid(2)
-.xx "" "getuid, getgid, geteuid, getegid \- get" "user and group identity" "" getuid(2)
-.xx "" "environ \-" "user environment" "" environ(5)
-.xx "" "su \- substitute" "user id temporarily" "" su(1)
-.xx "" "mail \- send or receive mail among" "users" "" mail(1)
-.xx "" "wall \- write to all" "users" "" wall(1)
-.xx "" "" "utime \- set file times" "" utime(2)
-.xx "" "" "utmp, wtmp \- login records" "" utmp(5)
-.xx "" "" "uucp, uulog \- unix to unix copy" "" uucp(1)
-.xx "" "" "uux \- unix to unix command execution" "" uux(1)
-.xx "" "abs \- integer absolute" "value" "" abs(3)
-.xx "" "fabs, floor, ceil \- absolute" "value, floor, ceiling functions" "" floor(3)
-.xx "" "getenv \-" "value for environment name" "" getenv(3)
-.xx "" "true, false \- provide truth" "values" "" true(1)
-.xx "" "assert \- program" "verification" "" assert(3)
-.xx "" "lint \- a C program" "verifier" "" lint(1)
-.xx "" "vp \-" "Versatec printer-plotter" "" vp(4)
-.xx "" "filsys, flblk, ino \- format of file system" "volume" "" filsys(5)
-.xx "" "" "vp \- Versatec printer-plotter" "" vp(4)
-.xx "" "" "wait \- await completion of process" "" wait(1)
-.xx "" "readonly, set, shift, times, trap, umask," "wait \- command language" "/newgrp, read," sh(1)
-.xx "" "" "wait \- wait for process to terminate" "" wait(2)
-.xx "" "" "wall \- write to all users" "" wall(1)
-.xx "" "" "wc \- word count" "" wc(1)
-.xx "" "crash \-" "what to do when the system crashes" "" crash(8)
-.xx "export, login, newgrp,/" "sh, for, case, if," "while, break, continue, cd, eval, exec, exit," "" sh(1)
-.xx "" "" "who \- who is on the system" "" who(1)
-.xx "" "wc \-" "word count" "" wc(1)
-.xx "" "getchar, fgetc, getw \- get character or" "word from stream" "getc," getc(3)
-.xx "" "hangman, words \-" "word games" "" words(6)
-.xx "" "putchar, fputc, putw \- put character or" "word on a stream" "putc," putc(3)
-.xx "" "hangman," "words \- word games" "" words(6)
-.xx "" "cd \- change" "working directory" "" cd(1)
-.xx "" "pwd \-" "working directory name" "" pwd(1)
-.xx "" "" "write \- write on a file" "" write(2)
-.xx "" "" "write \- write to another user" "" write(1)
-.xx "" "write \-" "write on a file" "" write(2)
-.xx "" "lseek, tell \- move read/" "write pointer" "" lseek(2)
-.xx "" "wall \-" "write to all users" "" wall(1)
-.xx "" "write \-" "write to another user" "" write(1)
-.xx "" "open \- open for reading or" "writing" "" open(2)
-.xx "" "utmp," "wtmp \- login records" "" utmp(5)
-.xx "" "" "wump \- the game of hunt-the-wumpus" "" wump(6)
-.xx "" "xsend," "xget, enroll \- secret mail" "" xsend(1)
-.xx "" "j0, j1, jn," "y0, y1, yn \- bessel functions" "" j0(3)
-.xx "" "" "yacc \- yet another compiler-compiler" "" yacc(1)
diff --git a/usr/man/man0/ptx.in b/usr/man/man0/ptx.in
new file mode 100644 (file)
index 0000000..ff1fbd7
--- /dev/null
@@ -0,0 +1,57 @@
+.if t .pn 17\"PERMUTED INDEX
+.if n .pn 23
+.tr ~
+.ll 6.5i
+.lt 6.7i
+.po .5i
+.ds ET\"
+.de HD
+.po 0
+.lt 7.4i
+.tl '\(rn\(rn''\(rn\(rn'
+.lt
+.po
+'sp 18p
+.if e .tl '\\*(ET'''
+.if o .tl '''\\*(ET'
+'sp 18p
+.ns
+..
+.de FO
+'sp 18p
+.af % i
+.if e .tl '\s9\\*(Dt'- % -'\\*(Ed\s0'
+.if o .tl '\s9\\*(Ed'- % -'\\*(Dt\s0'
+'bp
+..
+.wh 0 HD
+.wh -60p FO
+.if \n(nl .bp
+.br
+.ds ET \s9\f2Permuted \|Index\fP\s0
+.ds Ed UNIX/32V version 1.0
+.ds Dt February \|1979
+.ce
+\f3PERMUTED \|INDEX\fP
+.sp 1v
+.ps 8
+.vs 9p
+.nf
+.cs 3 36
+.\"    backup from slotput 1, slot, 2
+.de xx
+.ds s1\"
+.if \w@\\$2@ .ds s1 ~~\"
+.ds s2 ~~~\"
+.ds s3\"
+.if \w@\\$4@ .ds s3 ~~\"
+.ds s4 ~~\"
+.ds s5 ~~\"
+.ds y \\*(s4\f3\ 1\fP\\*(s5
+.ta 6i-\w@\\*(s5@u
+\h"3i-\w@\\$1\\*(s1\\$2\\*(s2@u"\\$1\\*(s1\\$2\\*(s2\\$3\\*(s3\\$4\\*y\\$5
+..
+.so ptxx
+.cs 3
+.if n .ta 8n 16n 24n 32n 40n 48n 56n 64n 72n 80n
+.if t .ta .5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i 5.5i 6i 6.5i
diff --git a/usr/man/man0/ptxmac b/usr/man/man0/ptxmac
deleted file mode 100644 (file)
index 4d4d929..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-.de xx
-.if !""\\$1" \\$1\fI\a\fR\\$2\t\\$3\fI\a\fR\t\\$5
-.if !""\\$4" \t\\$2\t\\$3\fI\a\fR\\$4\t\\$5
-.if ""\\$1\\$4" \t\\$2\t\\$3\fI\a\fR\t\\$5
-..
-.cs I 30
-.TL
-PERMUTED INDEX
-.LP
-.SM
-.nr VS 9
-.vs \n(VSp
-.nf
-.ta 2.7iR 2.85iL 5.65iR 6.5iR
-.af PN i
-.pn 9
diff --git a/usr/man/man0/ptxx b/usr/man/man0/ptxx
new file mode 100644 (file)
index 0000000..7e9bedf
--- /dev/null
@@ -0,0 +1,1252 @@
+.xx "" "dp: DP-11" "201 data-phone interface." "" dp(4)
+.xx "" "l3tol, ltol3: convert between" "3-byte integers and long integers." "" l3tol(3)
+.xx "" "diff3:" "3-way differential file comparison." "" diff3(1)
+.xx "" "tk: paginator for the Tektronix" "4014." "" tk(1)
+.xx "" "f77: Fortran" "77 compiler." "" f77(1)
+.xx "" "" "abort: generate a fault." "" abort(3)
+.xx "" "" "abs: integer absolute value." "" abs(3)
+.xx "" "abs: integer" "absolute value." "" abs(3)
+.xx "" "fabs, floor, ceil:" "absolute value, floor, ceiling functions." "" floor(3M)
+.xx "" "" "ac: login accounting." "" ac(1M)
+.xx "" "" "access: determine accessibility of file." "" access(2)
+.xx "" "access: determine" "accessibility of file." "" access(2)
+.xx "" "ac: login" "accounting." "" ac(1M)
+.xx "" "sa, accton: system" "accounting." "" sa(1M)
+.xx "" "acct: execution" "accounting file." "" acct(5)
+.xx "" "acct: turn" "accounting on or off." "" acct(2)
+.xx "" "" "acct: execution accounting file." "" acct(5)
+.xx "" "" "acct: turn accounting on or off." "" acct(2)
+.xx "" "sa," "accton: system accounting." "" sa(1M)
+.xx "" "sin, cos, tan, asin," "acos, atan, atan2: trigonometric functions." "" sin(3M)
+.xx "" "dn: DN-11" "ACU interface." "" dn(4)
+.xx "" "" "adb: debugger." "" adb(1)
+.xx "" "basename: strip filename" "affixes." "" basename(1)
+.xx "" "learn: computer" "aided instruction about UNIX." "" learn(1)
+.xx "" "" "alarm: schedule signal after specified time." "" alarm(2)
+.xx "" "brk, sbrk, break: change core" "allocation." "" brk(2)
+.xx "" "malloc, free, realloc, calloc: main memory" "allocator." "" malloc(3)
+.xx "" "lex: generator of lexical" "analysis programs." "" lex(1)
+.xx "" "bcd: convert to" "antique media." "" bcd(6)
+.xx "" "" "a.out: assembler and link editor output." "" a.out(5)
+.xx "" "" "ar: archive and library maintainer." "" ar(1)
+.xx "" "" "ar: archive (library) file format." "" ar(5)
+.xx "maintainer." "" "ar11: PDP-11 compatible archive and library" "" ar11(1)
+.xx "" "number: convert" "Arabic numerals to English." "" number(1)
+.xx "" "bc:" "arbitrary-precision arithmetic language." "" bc(1)
+.xx "" "tp: manipulate tape" "archive." "" tp(1)
+.xx "" "ar:" "archive and library maintainer." "" ar(1)
+.xx "" "ar11: PDP-11 compatible" "archive and library maintainer." "" ar11(1)
+.xx "" "ar:" "archive (library) file format." "" ar(5)
+.xx "" "tar: tape" "archiver." "" tar(1)
+.xx "" "arcv: convert" "archives to new format." "" arcv(1M)
+.xx "" "" "arcv: convert archives to new format." "" arcv(1M)
+.xx "" "echo: echo" "arguments." "" echo(1)
+.xx "" "expr: evaluate" "arguments as an expression." "" expr(1)
+.xx "" "getarg, iargc: command" "arguments to Fortran." "" getarg(3f)
+.xx "" "bc: arbitrary-precision" "arithmetic language." "" bc(1)
+.xx "" "" "arithmetic: provide drill in number facts." "" arithmetic(6)
+.xx "" "gmtime, asctime, timezone: convert date and time to" "ASCII." "ctime, localtime," ctime(3)
+.xx "" "ascii: map of" "ASCII character set." "" ascii(7)
+.xx "" "" "ascii: map of ASCII character set." "" ascii(7)
+.xx "" "atof, atoi, atol: convert" "ASCII to numbers." "" atof(3)
+.xx "" "ctime, localtime, gmtime," "asctime, timezone: convert date and time to ASCII." "" ctime(3)
+.xx "" "sin, cos, tan," "asin, acos, atan, atan2: trigonometric functions." "" sin(3M)
+.xx "" "as:" "assembler." "" as(1)
+.xx "" "a.out:" "assembler and link editor output." "" a.out(5)
+.xx "" "" "assert: program verification." "" assert(3x)
+.xx "" "setbuf:" "assign buffering to a stream." "" setbuf(3S)
+.xx "" "kl: KL-11 or DL-11" "asynchronous interface." "" kl(4)
+.xx "" "sin, cos, tan, asin, acos," "atan, atan2: trigonometric functions." "" sin(3M)
+.xx "" "sin, cos, tan, asin, acos, atan," "atan2: trigonometric functions." "" sin(3M)
+.xx "" "" "atof, atoi, atol: convert ASCII to numbers." "" atof(3)
+.xx "" "atof," "atoi, atol: convert ASCII to numbers." "" atof(3)
+.xx "" "atof, atoi," "atol: convert ASCII to numbers." "" atof(3)
+.xx "" "wait:" "await completion of process." "" wait(1)
+.xx "" "" "awk: pattern scanning and processing language." "" awk(1)
+.xx "" "" "backgammon: the game." "" backgammon(6)
+.xx "" "fetch, store, delete, firstkey, nextkey: data" "base subroutines." "dbminit," dbm(3x)
+.xx "" "" "basename: strip filename affixes." "" basename(1)
+.xx "" "" "bc: arbitrary-precision arithmetic language." "" bc(1)
+.xx "" "" "bcd: convert to antique media." "" bcd(6)
+.xx "" "cb: C program" "beautifier." "" cb(1)
+.xx "" "j0, j1, jn, y0, y1, yn:" "bessel functions." "" j0(3M)
+.xx "" "fread, fwrite: buffered" "binary input/output." "" fread(3S)
+.xx "" "strip: remove symbols and relocation" "bits." "" strip(1)
+.xx "" "sync: update the super" "block." "" sync(1M)
+.xx "" "update: periodically update the super" "block." "" update(8)
+.xx "" "sum: sum and count" "blocks in a file." "" sum(1)
+.xx "" "ching, fortune: the" "book of changes and other cookies." "" ching(6)
+.xx "" "" "boot procedures: UNIX/32V startup." "" bproc(8)
+.xx "" "brk, sbrk," "break: change core allocation." "" brk(2)
+.xx "login,/" "sh, for, case, if, while, \fB:\fP, \fB.\fP," "break, continue, cd, eval, exec, exit, export," "" sh(1)
+.xx "" "" "brk, sbrk, break: change core allocation." "" brk(2)
+.xx "" "fread, fwrite:" "buffered binary input/output." "" fread(3S)
+.xx "" "stdio: standard" "buffered input/output package." "" stdio(3S)
+.xx "" "setbuf: assign" "buffering to a stream." "" setbuf(3S)
+.xx "" "mknod:" "build special file." "" mknod(1M)
+.xx "" "swab: swap" "bytes." "" swab(3)
+.xx "" "cc:" "C compiler." "" cc(1)
+.xx "" "cb:" "C program beautifier." "" cb(1)
+.xx "" "lint: a" "C program verifier." "" lint(1)
+.xx "" "sdb:" "C symbolic debugger." "" sdb(1)
+.xx "" "hypot," "cabs: euclidean distance." "" hypot(3M)
+.xx "" "" "cal: print calendar." "" cal(1)
+.xx "" "dc: desk" "calculator." "" dc(1)
+.xx "" "cal: print" "calendar." "" cal(1)
+.xx "" "" "calendar: reminder service." "" calendar(1)
+.xx "" "indir, syscall: indirect system" "call." "" indir(2)
+.xx "" "" "call: ring a telephone." "" call(1C)
+.xx "" "cu:" "call UNIX." "" cu(1C)
+.xx "" "malloc, free, realloc," "calloc: main memory allocator." "" malloc(3)
+.xx "" "intro, errno: introduction to system" "calls and error numbers." "" intro(2)
+.xx "cd, eval, exec, exit, export, login,/" "sh, for," "case, if, while, \fB:\fP, \fB.\fP, break, continue," "" sh(1)
+.xx "" "" "cat: catenate and print." "" cat(1)
+.xx "" "" "cat: phototypesetter interface." "" cat(4)
+.xx "" "signal:" "catch or ignore signals." "" signal(2)
+.xx "" "cat:" "catenate and print." "" cat(1)
+.xx "" "" "cb: C program beautifier." "" cb(1)
+.xx "" "" "cc: C compiler." "" cc(1)
+.xx "" "" "cd: change working directory." "" cd(1)
+.xx "" "/case, if, while, \fB:\fP, \fB.\fP, break, continue," "cd, eval, exec, exit, export, login, newgrp, read,/" "" sh(1)
+.xx "" "fabs, floor," "ceil: absolute value, floor, ceiling functions." "" floor(3M)
+.xx "" "fabs, floor, ceil: absolute value, floor," "ceiling functions." "" floor(3M)
+.xx "" "ching, fortune: the book of" "changes and other cookies." "" ching(6)
+.xx "" "pipe: create an interprocess" "channel." "" pipe(2)
+.xx "" "ungetc: push" "character back into input stream." "" ungetc(3S)
+.xx "" "isspace, ispunct, isprint, iscntrl, isascii:" "character classification." "/isdigit, isalnum," ctype(3)
+.xx "" "eqnchar: special" "character definitions for eqn." "" eqnchar(7)
+.xx "" "getc, getchar, fgetc, getw: get" "character or word from stream." "" getc(3S)
+.xx "" "putc, putchar, fputc, putw: put" "character or word on a stream." "" putc(3S)
+.xx "" "ascii: map of ASCII" "character set." "" ascii(7)
+.xx "" "tr: translate" "characters." "" tr(1)
+.xx "" "" "chdir: change default directory." "" chdir(2)
+.xx "" "dcheck: file system directory consistency" "check." "" dcheck(1M)
+.xx "" "icheck: file system storage consistency" "check." "" icheck(1M)
+.xx "" "eqn, neqn," "checkeq: typeset mathematics." "" eqn(1)
+.xx "" "chown," "chgrp: change owner or group." "" chown(1)
+.xx "cookies." "" "ching, fortune: the book of changes and other" "" ching(6)
+.xx "" "" "chmod: change mode." "" chmod(1)
+.xx "" "" "chmod: change mode of file." "" chmod(2)
+.xx "" "" "chown: change owner and group of a file." "" chown(2)
+.xx "" "" "chown, chgrp: change owner or group." "" chown(1)
+.xx "" "ispunct, isprint, iscntrl, isascii: character" "classification." "/isdigit, isalnum, isspace," ctype(3)
+.xx "" "clri:" "clear i-node." "" clri(1M)
+.xx "" "feof, ferror," "clearerr, fileno: stream status inquiries." "" ferror(3S)
+.xx "" "cron:" "clock daemon." "" cron(1M)
+.xx "" "cron:" "clock daemon." "" cron(8)
+.xx "" "" "clri: clear i-node." "" clri(1M)
+.xx "" "" "cmp: compare two files." "" cmp(1)
+.xx "" "" "col: filter reverse line feeds." "" col(1)
+.xx "files." "" "comm: select or reject lines common to two sorted" "" comm(1)
+.xx "" "system: issue a shell" "command." "" system(3)
+.xx "" "test: condition" "command." "" test(1)
+.xx "" "time: time a" "command." "" time(1)
+.xx "" "getarg, iargc:" "command arguments to Fortran." "" getarg(3f)
+.xx "" "nice, nohup: run a" "command at low priority." "" nice(1)
+.xx "" "uux: unix to unix" "command execution." "" uux(1C)
+.xx "" "nohup: run a" "command immune to hangups." "" nohup(1)
+.xx "" "readonly, set, shift, times, trap, umask, wait:" "command language." "/export, login, newgrp, read," sh(1)
+.xx "" "intro: introduction to" "commands." "" intro(1)
+.xx "" "at: execute" "commands at a later time." "" at(1)
+.xx "" "comm: select or reject lines" "common to two sorted files." "" comm(1)
+.xx "" "dc: DC-11" "communications interface." "" dc(4)
+.xx "" "dh: DH-11" "communications multiplexer." "" dh(4)
+.xx "" "dz: DZ-11" "communications multiplexer." "" dz(4)
+.xx "" "diff: differential file" "comparator." "" diff(1)
+.xx "" "cmp:" "compare two files." "" cmp(1)
+.xx "" "diff3: 3-way differential file" "comparison." "" diff3(1)
+.xx "" "uudiff: directory" "comparison between machines." "" uudiff(1C)
+.xx "" "ar11: PDP-11" "compatible archive and library maintainer." "" ar11(1)
+.xx "" "cc: C" "compiler." "" cc(1)
+.xx "" "f77: Fortran 77" "compiler." "" f77(1)
+.xx "" "rc: Ratfor" "compiler." "" rc(1)
+.xx "" "yacc: yet another" "compiler-compiler." "" yacc(1)
+.xx "" "wait: await" "completion of process." "" wait(1)
+.xx "" "learn:" "computer aided instruction about UNIX." "" learn(1)
+.xx "" "test:" "condition command." "" test(1)
+.xx "" "dcheck: file system directory" "consistency check." "" dcheck(1M)
+.xx "" "icheck: file system storage" "consistency check." "" icheck(1M)
+.xx "" "mkfs:" "construct a file system." "" mkfs(1M)
+.xx "" "deroff: remove nroff, troff, tbl and eqn" "constructs." "" deroff(1)
+.xx "" "ls: list" "contents of directory." "" ls(1)
+.xx "" "sh, for, case, if, while, \fB:\fP, \fB.\fP, break," "continue, cd, eval, exec, exit, export, login,/" "" sh(1)
+.xx "" "ioctl, stty, gtty:" "control device." "" ioctl(2)
+.xx "" "init: process" "control initialization." "" init(8)
+.xx "" "terminals:" "conventional names." "" term(7)
+.xx "" "ecvt, fcvt, gcvt: output" "conversion." "" ecvt(3)
+.xx "" "printf, fprintf, sprintf: formatted output" "conversion." "" printf(3S)
+.xx "" "scanf, fscanf, sscanf: formatted input" "conversion." "" scanf(3S)
+.xx "" "units:" "conversion program." "" units(1)
+.xx "" "dd:" "convert and copy a file." "" dd(1)
+.xx "" "number:" "convert Arabic numerals to English." "" number(1)
+.xx "" "arcv:" "convert archives to new format." "" arcv(1M)
+.xx "" "atof, atoi, atol:" "convert ASCII to numbers." "" atof(3)
+.xx "" "l3tol, ltol3:" "convert between 3-byte integers and long integers." "" l3tol(3)
+.xx "" "ctime, localtime, gmtime, asctime, timezone:" "convert date and time to ASCII." "" ctime(3)
+.xx "" "bcd:" "convert to antique media." "" bcd(6)
+.xx "" "ching, fortune: the book of changes and other" "cookies." "" ching(6)
+.xx "" "cp:" "copy." "" cp(1)
+.xx "" "uucp, uulog: unix to unix" "copy." "" uucp(1C)
+.xx "" "dd: convert and" "copy a file." "" dd(1)
+.xx "" "brk, sbrk, break: change" "core allocation." "" brk(2)
+.xx "" "" "core: format of memory image file." "" core(5)
+.xx "functions." "sin," "cos, tan, asin, acos, atan, atan2: trigonometric" "" sin(3M)
+.xx "" "sinh," "cosh, tanh: hyperbolic functions." "" sinh(3M)
+.xx "" "wc: word" "count." "" wc(1)
+.xx "" "sum: sum and" "count blocks in a file." "" sum(1)
+.xx "" "" "cp: copy." "" cp(1)
+.xx "" "" "crash: what to do when the system crashes." "" crash(8)
+.xx "" "crash: what to do when the system" "crashes." "" crash(8)
+.xx "" "" "creat: create a new file." "" creat(2)
+.xx "" "creat:" "create a new file." "" creat(2)
+.xx "" "pipe:" "create an interprocess channel." "" pipe(2)
+.xx "" "mpx:" "create and manipulate multiplexed files." "" mpx(2)
+.xx "" "umask: set file" "creation mode mask." "" umask(2)
+.xx "" "" "cron: clock daemon." "" cron(1M)
+.xx "" "" "cron: clock daemon." "" cron(8)
+.xx "" "" "crypt: encode/decode." "" crypt(1)
+.xx "" "" "crypt, setkey, encrypt: DES encryption." "" crypt(3)
+.xx "convert date and time to ASCII." "" "ctime, localtime, gmtime, asctime, timezone:" "" ctime(3)
+.xx "" "" "cu: call UNIX." "" cu(1C)
+.xx "" "spline: interpolate smooth" "curve." "" spline(1G)
+.xx "" "cron: clock" "daemon." "" cron(1M)
+.xx "" "cron: clock" "daemon." "" cron(8)
+.xx "" "lpd: line printer" "daemon." "" lpd(8)
+.xx "" "fget.demon, fget.odemon: fget" "daemons." "" fget.demon(8)
+.xx "" "prof: display profile" "data." "" prof(1)
+.xx "" "ttys: terminal initialization" "data." "" ttys(5)
+.xx "" "dbminit, fetch, store, delete, firstkey, nextkey:" "data base subroutines." "" dbm(3x)
+.xx "" "null:" "data sink." "" null(4)
+.xx "" "types: primitive system" "data types." "" types(5)
+.xx "" "join: relational" "database operator." "" join(1)
+.xx "" "dp: DP-11 201" "data-phone interface." "" dp(4)
+.xx "" "date: print and set the" "date." "" date(1)
+.xx "" "time, ftime: get" "date and time." "" time(2)
+.xx "" "localtime, gmtime, asctime, timezone: convert" "date and time to ASCII." "ctime," ctime(3)
+.xx "" "touch: update" "date last modified of a file." "" touch(1)
+.xx "" "" "date: print and set the date." "" date(1)
+.xx "data base subroutines." "" "dbminit, fetch, store, delete, firstkey, nextkey:" "" dbm(3x)
+.xx "" "" "dc: DC-11 communications interface." "" dc(4)
+.xx "" "" "dc: desk calculator." "" dc(1)
+.xx "" "dc:" "DC-11 communications interface." "" dc(4)
+.xx "" "" "dcheck: file system directory consistency check." "" dcheck(1M)
+.xx "" "" "dd: convert and copy a file." "" dd(1)
+.xx "" "dump," "ddate: incremental dump format." "" dump(5)
+.xx "" "adb:" "debugger." "" adb(1)
+.xx "" "sdb: C symbolic" "debugger." "" sdb(1)
+.xx "" "tp:" "DEC/mag tape formats." "" tp(5)
+.xx "" "tc: TC-11/TU56" "DECtape." "" tc(4)
+.xx "" "chdir: change" "default directory." "" chdir(2)
+.xx "" "eqnchar: special character" "definitions for eqn." "" eqnchar(7)
+.xx "" "dbminit, fetch, store," "delete, firstkey, nextkey: data base subroutines." "" dbm(3x)
+.xx "" "tail:" "deliver the last part of a file." "" tail(1)
+.xx "" "mesg: permit or" "deny messages." "" mesg(1)
+.xx "constructs." "" "deroff: remove nroff, troff, tbl and eqn" "" deroff(1)
+.xx "" "crypt, setkey, encrypt:" "DES encryption." "" crypt(3)
+.xx "" "dup, dup2: duplicate an open file" "descriptor." "" dup(2)
+.xx "" "dc:" "desk calculator." "" dc(1)
+.xx "" "access:" "determine accessibility of file." "" access(2)
+.xx "" "file:" "determine file type." "" file(1)
+.xx "" "ioctl, stty, gtty: control" "device." "" ioctl(2)
+.xx "" "" "df: disk free." "" df(1M)
+.xx "" "" "dh: DH-11 communications multiplexer." "" dh(4)
+.xx "" "dh:" "DH-11 communications multiplexer." "" dh(4)
+.xx "" "ratfor: rational Fortran" "dialect." "" ratfor(1)
+.xx "" "" "diff: differential file comparator." "" diff(1)
+.xx "" "" "diff3: 3-way differential file comparison." "" diff3(1)
+.xx "" "diff:" "differential file comparator." "" diff(1)
+.xx "" "diff3: 3-way" "differential file comparison." "" diff3(1)
+.xx "" "" "dir: format of directories." "" dir(5)
+.xx "" "dir: format of" "directories." "" dir(5)
+.xx "" "cd: change working" "directory." "" cd(1)
+.xx "" "chdir: change default" "directory." "" chdir(2)
+.xx "" "ls: list contents of" "directory." "" ls(1)
+.xx "" "mkdir: make a" "directory." "" mkdir(1)
+.xx "" "uudiff:" "directory comparison between machines." "" uudiff(1C)
+.xx "" "dcheck: file system" "directory consistency check." "" dcheck(1M)
+.xx "" "unlink: remove" "directory entry." "" unlink(2)
+.xx "" "pwd: working" "directory name." "" pwd(1)
+.xx "" "mknod: make a" "directory or a special file." "" mknod(2)
+.xx "" "hp: RH-11/RP04, RP05, RP06, RM03 moving-head" "disk." "" hp(4)
+.xx "" "rk: RK-11/RK03 or RK05" "disk." "" rk(4)
+.xx "" "rp: RP-11/RP03 moving-head" "disk." "" rp(4)
+.xx "" "hs: RH11/RS03-RS04 fixed-head" "disk file." "" hs(4)
+.xx "" "rf: RF11/RS11 fixed-head" "disk file." "" rf(4)
+.xx "" "df:" "disk free." "" df(1M)
+.xx "" "du: summarize" "disk usage." "" du(1)
+.xx "" "mount, umount: mount and" "dismount file system." "" mount(1M)
+.xx "" "prof:" "display profile data." "" prof(1)
+.xx "" "hypot, cabs: euclidean" "distance." "" hypot(3M)
+.xx "" "sysgen: UNIX/32V system generation from the" "distribution tape." "" sysgen(8)
+.xx "" "kl: KL-11 or" "DL-11 asynchronous interface." "" kl(4)
+.xx "" "" "dn: DN-11 ACU interface." "" dn(4)
+.xx "" "dn:" "DN-11 ACU interface." "" dn(4)
+.xx "" "lookbib: find and insert literature references in" "documents." "refer," refer(1)
+.xx "" "" "dp: DP-11 201 data-phone interface." "" dp(4)
+.xx "" "dp:" "DP-11 201 data-phone interface." "" dp(4)
+.xx "" "graph:" "draw a graph." "" graph(1G)
+.xx "" "arithmetic: provide" "drill in number facts." "" arithmetic(6)
+.xx "" "" "du: summarize disk usage." "" du(1)
+.xx "" "dump: incremental file system" "dump." "" dump(1M)
+.xx "" "od: octal" "dump." "" od(1)
+.xx "" "" "dump, ddate: incremental dump format." "" dump(5)
+.xx "" "dump, ddate: incremental" "dump format." "" dump(5)
+.xx "" "" "dump: incremental file system dump." "" dump(1M)
+.xx "" "dumpdir: print the names of files on a" "dump tape." "" dumpdir(1M)
+.xx "" "" "dumpdir: print the names of files on a dump tape." "" dumpdir(1M)
+.xx "" "" "dup, dup2: duplicate an open file descriptor." "" dup(2)
+.xx "" "dup," "dup2: duplicate an open file descriptor." "" dup(2)
+.xx "" "dup, dup2:" "duplicate an open file descriptor." "" dup(2)
+.xx "" "" "dz: DZ-11 communications multiplexer." "" dz(4)
+.xx "" "dz:" "DZ-11 communications multiplexer." "" dz(4)
+.xx "" "echo:" "echo arguments." "" echo(1)
+.xx "" "" "echo: echo arguments." "" echo(1)
+.xx "" "" "ecvt, fcvt, gcvt: output conversion." "" ecvt(3)
+.xx "" "" "ed: text editor." "" ed(1)
+.xx "" "end, etext," "edata: last locations in program." "" end(3)
+.xx "" "ed: text" "editor." "" ed(1)
+.xx "" "ld: link" "editor." "" ld(1)
+.xx "" "sed: stream" "editor." "" sed(1)
+.xx "" "a.out: assembler and link" "editor output." "" a.out(5)
+.xx "" "grep," "egrep, fgrep: search a file for a pattern." "" grep(1)
+.xx "" "crypt:" "encode/decode." "" crypt(1)
+.xx "" "crypt, setkey," "encrypt: DES encryption." "" crypt(3)
+.xx "" "crypt, setkey, encrypt: DES" "encryption." "" crypt(3)
+.xx "" "makekey: generate" "encryption key." "" makekey(8)
+.xx "" "" "end, etext, edata: last locations in program." "" end(3)
+.xx "" "getgrent, getgrgid, getgrnam, setgrent," "endgrent: get group file entry." "" getgrent(3)
+.xx "" "getpwent, getpwuid, getpwnam, setpwent," "endpwent: get password file entry." "" getpwent(3)
+.xx "" "number: convert Arabic numerals to" "English." "" number(1)
+.xx "" "xsend, xget," "enroll: secret mail." "" xsend(1)
+.xx "" "nlist: get" "entries from name list." "" nlist(3)
+.xx "" "getgrnam, setgrent, endgrent: get group file" "entry." "getgrent, getgrgid," getgrent(3)
+.xx "" "getpwnam, setpwent, endpwent: get password file" "entry." "getpwent, getpwuid," getpwent(3)
+.xx "" "unlink: remove directory" "entry." "" unlink(2)
+.xx "" "execv, execle, execve, execlp, execvp, exec, exece," "environ: execute a file." "execl," exec(2)
+.xx "" "" "environ: user environment." "" environ(5)
+.xx "" "environ: user" "environment." "" environ(5)
+.xx "" "getenv: value for" "environment name." "" getenv(3)
+.xx "" "eqnchar: special character definitions for" "eqn." "" eqnchar(7)
+.xx "" "deroff: remove nroff, troff, tbl and" "eqn constructs." "" deroff(1)
+.xx "" "" "eqn, neqn, checkeq: typeset mathematics." "" eqn(1)
+.xx "" "" "eqnchar: special character definitions for eqn." "" eqnchar(7)
+.xx "numbers." "intro," "errno: introduction to system calls and error" "" intro(2)
+.xx "" "perror, sys_errlist, sys_nerr: system" "error messages." "" perror(3)
+.xx "" "intro, errno: introduction to system calls and" "error numbers." "" intro(2)
+.xx "" "spell, spellin, spellout: find spelling" "errors." "" spell(1)
+.xx "" "plot: openpl" "et al.: graphics interface." "" plot(3x)
+.xx "" "end," "etext, edata: last locations in program." "" end(3)
+.xx "" "hypot, cabs:" "euclidean distance." "" hypot(3M)
+.xx "" "/if, while, \fB:\fP, \fB.\fP, break, continue, cd," "eval, exec, exit, export, login, newgrp, read,/" "" sh(1)
+.xx "" "expr:" "evaluate arguments as an expression." "" expr(1)
+.xx "" "execl, execv, execle, execve, execlp, execvp," "exec, exece, environ: execute a file." "" exec(2)
+.xx "" "/while, \fB:\fP, \fB.\fP, break, continue, cd, eval," "exec, exit, export, login, newgrp, read, readonly,/" "" sh(1)
+.xx "" "execl, execv, execle, execve, execlp, execvp, exec," "exece, environ: execute a file." "" exec(2)
+.xx "exece, environ: execute a file." "" "execl, execv, execle, execve, execlp, execvp, exec," "" exec(2)
+.xx "environ: execute a file." "execl, execv," "execle, execve, execlp, execvp, exec, exece," "" exec(2)
+.xx "file." "execl, execv, execle, execve," "execlp, execvp, exec, exece, environ: execute a" "" exec(2)
+.xx "" "sticky:" "executable files with persistent text." "" sticky(8)
+.xx "" "execve, execlp, execvp, exec, exece, environ:" "execute a file." "execl, execv, execle," exec(2)
+.xx "" "at:" "execute commands at a later time." "" at(1)
+.xx "" "uux: unix to unix command" "execution." "" uux(1C)
+.xx "" "acct:" "execution accounting file." "" acct(5)
+.xx "" "sleep: suspend" "execution for an interval." "" sleep(1)
+.xx "" "sleep: suspend" "execution for interval." "" sleep(3)
+.xx "" "monitor: prepare" "execution profile." "" monitor(3)
+.xx "" "profil:" "execution time profile." "" profil(2)
+.xx "environ: execute a file." "execl," "execv, execle, execve, execlp, execvp, exec, exece," "" exec(2)
+.xx "execute a file." "execl, execv, execle," "execve, execlp, execvp, exec, exece, environ:" "" exec(2)
+.xx "" "execl, execv, execle, execve, execlp," "execvp, exec, exece, environ: execute a file." "" exec(2)
+.xx "" "/\fB:\fP, \fB.\fP, break, continue, cd, eval, exec," "exit, export, login, newgrp, read, readonly, set,/" "" sh(1)
+.xx "" "" "exit: terminate process." "" exit(2)
+.xx "power, square root." "" "exp, log, log10, pow, sqrt: exponential, logarithm," "" exp(3M)
+.xx "" "frexp, ldexp, modf: split into mantissa and" "exponent." "" frexp(3)
+.xx "" "exp, log, log10, pow, sqrt:" "exponential, logarithm, power, square root." "" exp(3M)
+.xx "" "/\fB.\fP, break, continue, cd, eval, exec, exit," "export, login, newgrp, read, readonly, set, shift,/" "" sh(1)
+.xx "" "" "expr: evaluate arguments as an expression." "" expr(1)
+.xx "" "expr: evaluate arguments as an" "expression." "" expr(1)
+.xx "" "greek: graphics for" "extended TTY-37 type-box." "" greek(7)
+.xx "" "kill: terminate a process with" "extreme prejudice." "" kill(1)
+.xx "" "" "f77: Fortran 77 compiler." "" f77(1)
+.xx "functions." "" "fabs, floor, ceil: absolute value, floor, ceiling" "" floor(3M)
+.xx "" "arithmetic: provide drill in number" "facts." "" arithmetic(6)
+.xx "" "pstat: print system" "facts." "" pstat(1M)
+.xx "" "true," "false: provide truth values." "" true(1)
+.xx "" "abort: generate a" "fault." "" abort(3)
+.xx "export, login,/" "sh, for, case, if, while, \fB:\fP," "\fB.\fP, break, continue, cd, eval, exec, exit," "" sh(1)
+.xx "exit, export, login,/" "sh, for, case, if, while," "\fB:\fP, \fB.\fP, break, continue, cd, eval, exec," "" sh(1)
+.xx "" "" "fclose, fflush: close or flush a stream." "" fclose(3S)
+.xx "" "ecvt," "fcvt, gcvt: output conversion." "" ecvt(3)
+.xx "" "fopen, freopen," "fdopen: open a stream." "" fopen(3S)
+.xx "" "col: filter reverse line" "feeds." "" col(1)
+.xx "inquiries." "" "feof, ferror, clearerr, fileno: stream status" "" ferror(3S)
+.xx "" "feof," "ferror, clearerr, fileno: stream status inquiries." "" ferror(3S)
+.xx "subroutines." "dbminit," "fetch, store, delete, firstkey, nextkey: data base" "" dbm(3x)
+.xx "" "fclose," "fflush: close or flush a stream." "" fclose(3S)
+.xx "" "fget.demon, fget.odemon:" "fget daemons." "" fget.demon(8)
+.xx "" "getc, getchar," "fgetc, getw: get character or word from stream." "" getc(3S)
+.xx "" "" "fget.demon, fget.odemon: fget daemons." "" fget.demon(8)
+.xx "" "fget.demon," "fget.odemon: fget daemons." "" fget.demon(8)
+.xx "" "gets," "fgets: get a string from a stream." "" gets(3S)
+.xx "" "grep, egrep," "fgrep: search a file for a pattern." "" grep(1)
+.xx "" "access: determine accessibility of" "file." "" access(2)
+.xx "" "acct: execution accounting" "file." "" acct(5)
+.xx "" "chmod: change mode of" "file." "" chmod(2)
+.xx "" "chown: change owner and group of a" "file." "" chown(2)
+.xx "" "close: close a" "file." "" close(2)
+.xx "" "core: format of memory image" "file." "" core(5)
+.xx "" "creat: create a new" "file." "" creat(2)
+.xx "" "dd: convert and copy a" "file." "" dd(1)
+.xx "" "execlp, execvp, exec, exece, environ: execute a" "file." "execl, execv, execle, execve," exec(2)
+.xx "" "group: group" "file." "" group(5)
+.xx "" "hs: RH11/RS03-RS04 fixed-head disk" "file." "" hs(4)
+.xx "" "link: link to a" "file." "" link(2)
+.xx "" "mknod: build special" "file." "" mknod(1M)
+.xx "" "mknod: make a directory or a special" "file." "" mknod(2)
+.xx "" "passwd: password" "file." "" passwd(5)
+.xx "" "pr: print" "file." "" pr(1)
+.xx "" "read: read from" "file." "" read(2)
+.xx "" "rev: reverse lines of a" "file." "" rev(1)
+.xx "" "rf: RF11/RS11 fixed-head disk" "file." "" rf(4)
+.xx "" "size: size of an object" "file." "" size(1)
+.xx "" "sum: sum and count blocks in a" "file." "" sum(1)
+.xx "" "tail: deliver the last part of a" "file." "" tail(1)
+.xx "" "touch: update date last modified of a" "file." "" touch(1)
+.xx "" "uniq: report repeated lines in a" "file." "" uniq(1)
+.xx "" "write: write on a" "file." "" write(2)
+.xx "" "diff: differential" "file comparator." "" diff(1)
+.xx "" "diff3: 3-way differential" "file comparison." "" diff3(1)
+.xx "" "umask: set" "file creation mode mask." "" umask(2)
+.xx "" "dup, dup2: duplicate an open" "file descriptor." "" dup(2)
+.xx "" "" "file: determine file type." "" file(1)
+.xx "" "getgrgid, getgrnam, setgrent, endgrent: get group" "file entry." "getgrent," getgrent(3)
+.xx "" "getpwnam, setpwent, endpwent: get password" "file entry." "getpwent, getpwuid," getpwent(3)
+.xx "" "grep, egrep, fgrep: search a" "file for a pattern." "" grep(1)
+.xx "" "ar: archive (library)" "file format." "" ar(5)
+.xx "" "split: split a" "file into pieces." "" split(1)
+.xx "" "mktemp: make a unique" "file name." "" mktemp(3)
+.xx "" "stat, fstat: get" "file status." "" stat(2)
+.xx "" "mkfs: construct a" "file system." "" mkfs(1M)
+.xx "" "mount, umount: mount and dismount" "file system." "" mount(1M)
+.xx "" "mount, umount: mount or remove" "file system." "" mount(2)
+.xx "" "dcheck:" "file system directory consistency check." "" dcheck(1M)
+.xx "" "dump: incremental" "file system dump." "" dump(1M)
+.xx "" "hier:" "file system hierarchy." "" hier(7)
+.xx "" "quot: summarize" "file system ownership." "" quot(1M)
+.xx "" "restor: incremental" "file system restore." "" restor(1M)
+.xx "" "icheck:" "file system storage consistency check." "" icheck(1M)
+.xx "" "mtab: mounted" "file system table." "" mtab(5)
+.xx "" "filsys, flblk, ino: format of" "file system volume." "" filsys(5)
+.xx "" "utime: set" "file times." "" utime(2)
+.xx "" "file: determine" "file type." "" file(1)
+.xx "" "basename: strip" "filename affixes." "" basename(1)
+.xx "" "feof, ferror, clearerr," "fileno: stream status inquiries." "" ferror(3S)
+.xx "" "cmp: compare two" "files." "" cmp(1)
+.xx "" "comm: select or reject lines common to two sorted" "files." "" comm(1)
+.xx "" "find: find" "files." "" find(1)
+.xx "" "mpx: create and manipulate multiplexed" "files." "" mpx(2)
+.xx "" "mv: move or rename" "files." "" mv(1)
+.xx "" "rm, rmdir: remove (unlink)" "files." "" rm(1)
+.xx "" "sort: sort or merge" "files." "" sort(1)
+.xx "" "dumpdir: print the names of" "files on a dump tape." "" dumpdir(1M)
+.xx "" "sticky: executable" "files with persistent text." "" sticky(8)
+.xx "" "" "filsys, flblk, ino: format of file system volume." "" filsys(5)
+.xx "" "col:" "filter reverse line feeds." "" col(1)
+.xx "" "plot: graphics" "filters." "" plot(1G)
+.xx "" "dbminit, fetch, store, delete," "firstkey, nextkey: data base subroutines." "" dbm(3x)
+.xx "" "tee: pipe" "fitting." "" tee(1)
+.xx "" "hs: RH11/RS03-RS04" "fixed-head disk file." "" hs(4)
+.xx "" "rf: RF11/RS11" "fixed-head disk file." "" rf(4)
+.xx "" "filsys," "flblk, ino: format of file system volume." "" filsys(5)
+.xx "functions." "fabs," "floor, ceil: absolute value, floor, ceiling" "" floor(3M)
+.xx "" "fabs, floor, ceil: absolute value," "floor, ceiling functions." "" floor(3M)
+.xx "" "fclose, fflush: close or" "flush a stream." "" fclose(3S)
+.xx "" "" "fopen, freopen, fdopen: open a stream." "" fopen(3S)
+.xx "continue, cd, eval, exec, exit, export, login,/" "sh," "for, case, if, while, \fB:\fP, \fB.\fP, break," "" sh(1)
+.xx "" "" "fork: spawn new process." "" fork(2)
+.xx "" "ar: archive (library) file" "format." "" ar(5)
+.xx "" "arcv: convert archives to new" "format." "" arcv(1M)
+.xx "" "dump, ddate: incremental dump" "format." "" dump(5)
+.xx "" "dir:" "format of directories." "" dir(5)
+.xx "" "filsys, flblk, ino:" "format of file system volume." "" filsys(5)
+.xx "" "core:" "format of memory image file." "" core(5)
+.xx "" "tbl:" "format tables for nroff or troff." "" tbl(1)
+.xx "" "tp: DEC/mag tape" "formats." "" tp(5)
+.xx "" "scanf, fscanf, sscanf:" "formatted input conversion." "" scanf(3S)
+.xx "" "printf, fprintf, sprintf:" "formatted output conversion." "" printf(3S)
+.xx "" "troff, nroff: text" "formatting and typesetting." "" troff(1)
+.xx "" "ms: macros for" "formatting manuscripts." "" ms(7)
+.xx "" "getarg, iargc: command arguments to" "Fortran." "" getarg(3f)
+.xx "" "f77:" "Fortran 77 compiler." "" f77(1)
+.xx "" "ratfor: rational" "Fortran dialect." "" ratfor(1)
+.xx "" "struct: structure" "Fortran programs." "" struct(1)
+.xx "" "ching," "fortune: the book of changes and other cookies." "" ching(6)
+.xx "exit, export,/" "sh, for, case, if, while, \fB:" "\fP, \fB.\fP, break, continue, cd, eval, exec," "" sh(1)
+.xx "" "printf," "fprintf, sprintf: formatted output conversion." "" printf(3S)
+.xx "" "putc, putchar," "fputc, putw: put character or word on a stream." "" putc(3S)
+.xx "" "puts," "fputs: put a string on a stream." "" puts(3S)
+.xx "" "" "fread, fwrite: buffered binary input/output." "" fread(3S)
+.xx "" "df: disk" "free." "" df(1M)
+.xx "" "malloc," "free, realloc, calloc: main memory allocator." "" malloc(3)
+.xx "" "fopen," "freopen, fdopen: open a stream." "" fopen(3S)
+.xx "exponent." "" "frexp, ldexp, modf: split into mantissa and" "" frexp(3)
+.xx "" "scanf," "fscanf, sscanf: formatted input conversion." "" scanf(3S)
+.xx "" "" "fseek, ftell, rewind: reposition a stream." "" fseek(3S)
+.xx "" "stat," "fstat: get file status." "" stat(2)
+.xx "" "fseek," "ftell, rewind: reposition a stream." "" fseek(3S)
+.xx "" "time," "ftime: get date and time." "" time(2)
+.xx "" "gamma: log gamma" "function." "" gamma(3M)
+.xx "" "fabs, floor, ceil: absolute value, floor, ceiling" "functions." "" floor(3M)
+.xx "" "intro: introduction to library" "functions." "" intro(3)
+.xx "" "j0, j1, jn, y0, y1, yn: bessel" "functions." "" j0(3M)
+.xx "" "cos, tan, asin, acos, atan, atan2: trigonometric" "functions." "sin," sin(3M)
+.xx "" "sinh, cosh, tanh: hyperbolic" "functions." "" sinh(3M)
+.xx "" "fread," "fwrite: buffered binary input/output." "" fread(3S)
+.xx "" "backgammon: the" "game." "" backgammon(6)
+.xx "" "wump: the" "game of hunt-the-wumpus." "" wump(6)
+.xx "" "gamma: log" "gamma function." "" gamma(3M)
+.xx "" "" "gamma: log gamma function." "" gamma(3M)
+.xx "" "ecvt, fcvt," "gcvt: output conversion." "" ecvt(3)
+.xx "" "abort:" "generate a fault." "" abort(3)
+.xx "" "maze:" "generate a maze problem." "" maze(6)
+.xx "" "makekey:" "generate encryption key." "" makekey(8)
+.xx "" "ncheck:" "generate names from i-numbers." "" ncheck(1M)
+.xx "" "sysgen: UNIX/32V system" "generation from the distribution tape." "" sysgen(8)
+.xx "" "rand, srand: random number" "generator." "" rand(3)
+.xx "" "lex:" "generator of lexical analysis programs." "" lex(1)
+.xx "" "" "getarg, iargc: command arguments to Fortran." "" getarg(3f)
+.xx "from stream." "" "getc, getchar, fgetc, getw: get character or word" "" getc(3S)
+.xx "stream." "getc," "getchar, fgetc, getw: get character or word from" "" getc(3S)
+.xx "" "getuid, getgid, geteuid," "getegid: get user and group identity." "" getuid(2)
+.xx "" "" "getenv: value for environment name." "" getenv(3)
+.xx "" "getuid, getgid," "geteuid, getegid: get user and group identity." "" getuid(2)
+.xx "identity." "getuid," "getgid, geteuid, getegid: get user and group" "" getuid(2)
+.xx "get group file entry." "" "getgrent, getgrgid, getgrnam, setgrent, endgrent:" "" getgrent(3)
+.xx "file entry." "getgrent," "getgrgid, getgrnam, setgrent, endgrent: get group" "" getgrent(3)
+.xx "" "getgrent, getgrgid," "getgrnam, setgrent, endgrent: get group file entry." "" getgrent(3)
+.xx "" "" "getlogin: get login name." "" getlogin(3)
+.xx "" "" "getpass: read a password." "" getpass(3)
+.xx "" "" "getpid: get process identification." "" getpid(2)
+.xx "" "" "getpw: get name from UID." "" getpw(3)
+.xx "get password file entry." "" "getpwent, getpwuid, getpwnam, setpwent, endpwent:" "" getpwent(3)
+.xx "entry." "getpwent, getpwuid," "getpwnam, setpwent, endpwent: get password file" "" getpwent(3)
+.xx "password file entry." "getpwent," "getpwuid, getpwnam, setpwent, endpwent: get" "" getpwent(3)
+.xx "" "" "gets, fgets: get a string from a stream." "" gets(3S)
+.xx "" "" "getty: set terminal mode." "" getty(8)
+.xx "group identity." "" "getuid, getgid, geteuid, getegid: get user and" "" getuid(2)
+.xx "" "getc, getchar, fgetc," "getw: get character or word from stream." "" getc(3S)
+.xx "ASCII." "ctime, localtime," "gmtime, asctime, timezone: convert date and time to" "" ctime(3)
+.xx "" "setjmp, longjmp: non-local" "goto." "" setjmp(3)
+.xx "" "graph: draw a" "graph." "" graph(1G)
+.xx "" "" "graph: draw a graph." "" graph(1G)
+.xx "" "plot:" "graphics filters." "" plot(1G)
+.xx "" "greek:" "graphics for extended TTY-37 type-box." "" greek(7)
+.xx "" "plot: openpl et al.:" "graphics interface." "" plot(3x)
+.xx "" "plot:" "graphics interface." "" plot(5)
+.xx "" "" "greek: graphics for extended TTY-37 type-box." "" greek(7)
+.xx "" "" "grep, egrep, fgrep: search a file for a pattern." "" grep(1)
+.xx "" "chown, chgrp: change owner or" "group." "" chown(1)
+.xx "" "newgrp: log in to a new" "group." "" newgrp(1)
+.xx "" "make: maintain program" "groups." "" make(1)
+.xx "" "ioctl, stty," "gtty: control device." "" ioctl(2)
+.xx "" "stty," "gtty: set and retrieve terminal modes." "" stty(2)
+.xx "" "hangman:" "guess the word." "" hangman(6)
+.xx "" "" "hangman: guess the word." "" hangman(6)
+.xx "" "nohup: run a command immune to" "hangups." "" nohup(1)
+.xx "" "" "hier: file system hierarchy." "" hier(7)
+.xx "" "hier: file system" "hierarchy." "" hier(7)
+.xx "" "wtmp: user login" "history." "" wtmp(5)
+.xx "" "" "hp: RH-11/RP04, RP05, RP06, RM03 moving-head disk." "" hp(4)
+.xx "" "" "hs: RH11/RS03-RS04 fixed-head disk file." "" hs(4)
+.xx "" "" "ht: RH-11/TE-16 magtape interface." "" ht(4)
+.xx "" "wump: the game of" "hunt-the-wumpus." "" wump(6)
+.xx "" "sinh, cosh, tanh:" "hyperbolic functions." "" sinh(3M)
+.xx "" "" "hypot, cabs: euclidean distance." "" hypot(3M)
+.xx "" "getarg," "iargc: command arguments to Fortran." "" getarg(3f)
+.xx "" "" "icheck: file system storage consistency check." "" icheck(1M)
+.xx "" "setuid, setgid: set user and group" "ID." "" setuid(2)
+.xx "" "su: substitute user" "id temporarily." "" su(1)
+.xx "" "getpid: get process" "identification." "" getpid(2)
+.xx "" "getgid, geteuid, getegid: get user and group" "identity." "getuid," getuid(2)
+.xx "eval, exec, exit, export, login,/" "sh, for, case," "if, while, \fB:\fP, \fB.\fP, break, continue, cd," "" sh(1)
+.xx "" "signal: catch or" "ignore signals." "" signal(2)
+.xx "" "core: format of memory" "image file." "" core(5)
+.xx "" "nohup: run a command" "immune to hangups." "" nohup(1)
+.xx "" "dump, ddate:" "incremental dump format." "" dump(5)
+.xx "" "dump:" "incremental file system dump." "" dump(1M)
+.xx "" "restor:" "incremental file system restore." "" restor(1M)
+.xx "" "ptx: permuted" "index." "" ptx(1)
+.xx "" "strcatn, strcmp, strcmpn, strcpy, strcpyn, strlen," "index, rindex: string operations." "strcat," string(3)
+.xx "" "" "indir, syscall: indirect system call." "" indir(2)
+.xx "" "indir, syscall:" "indirect system call." "" indir(2)
+.xx "" "" "init: process control initialization." "" init(8)
+.xx "" "init: process control" "initialization." "" init(8)
+.xx "" "ttys: terminal" "initialization data." "" ttys(5)
+.xx "" "popen, pclose:" "initiate I/O to/from a process." "" popen(3S)
+.xx "" "filsys, flblk," "ino: format of file system volume." "" filsys(5)
+.xx "" "clri: clear" "i-node." "" clri(1M)
+.xx "" "scanf, fscanf, sscanf: formatted" "input conversion." "" scanf(3S)
+.xx "" "ungetc: push character back into" "input stream." "" ungetc(3S)
+.xx "" "fread, fwrite: buffered binary" "input/output." "" fread(3S)
+.xx "" "stdio: standard buffered" "input/output package." "" stdio(3S)
+.xx "" "feof, ferror, clearerr, fileno: stream status" "inquiries." "" ferror(3S)
+.xx "" "uulog: uucp user log" "inquiry." "" uulog(1C)
+.xx "" "refer, lookbib: find and" "insert literature references in documents." "" refer(1)
+.xx "" "learn: computer aided" "instruction about UNIX." "" learn(1)
+.xx "" "abs:" "integer absolute value." "" abs(3)
+.xx "" "ltol3: convert between 3-byte integers and long" "integers." "l3tol," l3tol(3)
+.xx "" "l3tol, ltol3: convert between 3-byte" "integers and long integers." "" l3tol(3)
+.xx "" "cat: phototypesetter" "interface." "" cat(4)
+.xx "" "dc: DC-11 communications" "interface." "" dc(4)
+.xx "" "dn: DN-11 ACU" "interface." "" dn(4)
+.xx "" "dp: DP-11 201 data-phone" "interface." "" dp(4)
+.xx "" "ht: RH-11/TE-16 magtape" "interface." "" ht(4)
+.xx "" "kl: KL-11 or DL-11 asynchronous" "interface." "" kl(4)
+.xx "" "plot: openpl et al.: graphics" "interface." "" plot(3x)
+.xx "" "plot: graphics" "interface." "" plot(5)
+.xx "" "tm: TM-11/TU-10 magtape" "interface." "" tm(4)
+.xx "" "tty: general terminal" "interface." "" tty(4)
+.xx "" "spline:" "interpolate smooth curve." "" spline(1G)
+.xx "" "pipe: create an" "interprocess channel." "" pipe(2)
+.xx "" "sleep: suspend execution for an" "interval." "" sleep(1)
+.xx "" "sleep: suspend execution for" "interval." "" sleep(3)
+.xx "error numbers." "" "intro, errno: introduction to system calls and" "" intro(2)
+.xx "" "" "intro: introduction to commands." "" intro(1)
+.xx "" "" "intro: introduction to library functions." "" intro(3)
+.xx "" "intro:" "introduction to commands." "" intro(1)
+.xx "" "intro:" "introduction to library functions." "" intro(3)
+.xx "" "intro, errno:" "introduction to system calls and error numbers." "" intro(2)
+.xx "" "ncheck: generate names from" "i-numbers." "" ncheck(1M)
+.xx "" "mpxio: multiplexed" "i/o." "" mpxio(5)
+.xx "" "iostat: report" "I/O statistics." "" iostat(1M)
+.xx "" "popen, pclose: initiate" "I/O to/from a process." "" popen(3S)
+.xx "" "" "ioctl, stty, gtty: control device." "" ioctl(2)
+.xx "" "" "iostat: report I/O statistics." "" iostat(1M)
+.xx "isascii:/" "isalpha, isupper, islower, isdigit," "isalnum, isspace, ispunct, isprint, iscntrl," "" ctype(3)
+.xx "isspace, ispunct, isprint, iscntrl, isascii:/" "" "isalpha, isupper, islower, isdigit, isalnum," "" ctype(3)
+.xx "" "isalnum, isspace, ispunct, isprint, iscntrl," "isascii: character classification." "/isdigit," ctype(3)
+.xx "" "ttyname," "isatty, ttyslot: find name of a terminal." "" ttyname(3)
+.xx "" "/isdigit, isalnum, isspace, ispunct, isprint," "iscntrl, isascii: character classification." "" ctype(3)
+.xx "iscntrl, isascii:/" "isalpha, isupper, islower," "isdigit, isalnum, isspace, ispunct, isprint," "" ctype(3)
+.xx "isprint, iscntrl, isascii:/" "isalpha, isupper," "islower, isdigit, isalnum, isspace, ispunct," "" ctype(3)
+.xx "" "islower, isdigit, isalnum, isspace, ispunct," "isprint, iscntrl, isascii: character/" "/isupper," ctype(3)
+.xx "" "/isupper, islower, isdigit, isalnum, isspace," "ispunct, isprint, iscntrl, isascii: character/" "" ctype(3)
+.xx "" "isalpha, isupper, islower, isdigit, isalnum," "isspace, ispunct, isprint, iscntrl, isascii:/" "" ctype(3)
+.xx "" "system:" "issue a shell command." "" system(3)
+.xx "ispunct, isprint, iscntrl, isascii:/" "isalpha," "isupper, islower, isdigit, isalnum, isspace," "" ctype(3)
+.xx "" "" "j0, j1, jn, y0, y1, yn: bessel functions." "" j0(3M)
+.xx "" "j0," "j1, jn, y0, y1, yn: bessel functions." "" j0(3M)
+.xx "" "j0, j1," "jn, y0, y1, yn: bessel functions." "" j0(3M)
+.xx "" "" "join: relational database operator." "" join(1)
+.xx "" "makekey: generate encryption" "key." "" makekey(8)
+.xx "" "" "kill: send signal to a process." "" kill(2)
+.xx "" "" "kill: terminate a process with extreme prejudice." "" kill(1)
+.xx "" "" "kl: KL-11 or DL-11 asynchronous interface." "" kl(4)
+.xx "" "kl:" "KL-11 or DL-11 asynchronous interface." "" kl(4)
+.xx "" "mem," "kmem: main memory." "" mem(4)
+.xx "" "quiz: test your" "knowledge." "" quiz(6)
+.xx "long integers." "" "l3tol, ltol3: convert between 3-byte integers and" "" l3tol(3)
+.xx "" "awk: pattern scanning and processing" "language." "" awk(1)
+.xx "" "bc: arbitrary-precision arithmetic" "language." "" bc(1)
+.xx "" "set, shift, times, trap, umask, wait: command" "language." "/export, login, newgrp, read, readonly," sh(1)
+.xx "" "" "ld: link editor." "" ld(1)
+.xx "" "frexp," "ldexp, modf: split into mantissa and exponent." "" frexp(3)
+.xx "" "" "learn: computer aided instruction about UNIX." "" learn(1)
+.xx "" "" "lex: generator of lexical analysis programs." "" lex(1)
+.xx "" "lex: generator of" "lexical analysis programs." "" lex(1)
+.xx "" "lorder: find ordering relation for an object" "library." "" lorder(1)
+.xx "" "ar: archive" "(library) file format." "" ar(5)
+.xx "" "intro: introduction to" "library functions." "" intro(3)
+.xx "" "ar: archive and" "library maintainer." "" ar(1)
+.xx "" "ar11: PDP-11 compatible archive and" "library maintainer." "" ar11(1)
+.xx "" "comm: select or reject" "lines common to two sorted files." "" comm(1)
+.xx "" "uniq: report repeated" "lines in a file." "" uniq(1)
+.xx "" "look: find" "lines in a sorted list." "" look(1)
+.xx "" "rev: reverse" "lines of a file." "" rev(1)
+.xx "" "ln: make a" "link." "" ln(1)
+.xx "" "ld:" "link editor." "" ld(1)
+.xx "" "a.out: assembler and" "link editor output." "" a.out(5)
+.xx "" "" "link: link to a file." "" link(2)
+.xx "" "link:" "link to a file." "" link(2)
+.xx "" "" "lint: a C program verifier." "" lint(1)
+.xx "" "look: find lines in a sorted" "list." "" look(1)
+.xx "" "nlist: get entries from name" "list." "" nlist(3)
+.xx "" "nm: print name" "list." "" nm(1)
+.xx "" "ls:" "list contents of directory." "" ls(1)
+.xx "" "refer, lookbib: find and insert" "literature references in documents." "" refer(1)
+.xx "" "" "ln: make a link." "" ln(1)
+.xx "and time to ASCII." "ctime," "localtime, gmtime, asctime, timezone: convert date" "" ctime(3)
+.xx "" "end, etext, edata: last" "locations in program." "" end(3)
+.xx "" "gamma:" "log gamma function." "" gamma(3M)
+.xx "" "newgrp:" "log in to a new group." "" newgrp(1)
+.xx "" "uulog: uucp user" "log inquiry." "" uulog(1C)
+.xx "power, square root." "exp," "log, log10, pow, sqrt: exponential, logarithm," "" exp(3M)
+.xx "square root." "exp, log," "log10, pow, sqrt: exponential, logarithm, power," "" exp(3M)
+.xx "" "exp, log, log10, pow, sqrt: exponential," "logarithm, power, square root." "" exp(3M)
+.xx "" "ac:" "login accounting." "" ac(1M)
+.xx "" "wtmp: user" "login history." "" wtmp(5)
+.xx "" "getlogin: get" "login name." "" getlogin(3)
+.xx "" "/break, continue, cd, eval, exec, exit, export," "login, newgrp, read, readonly, set, shift, times,/" "" sh(1)
+.xx "" "passwd: change" "login password." "" passwd(1)
+.xx "" "utmp, wtmp:" "login records." "" utmp(5)
+.xx "" "" "login: sign on." "" login(1)
+.xx "" "setjmp," "longjmp: non-local goto." "" setjmp(3)
+.xx "documents." "refer," "lookbib: find and insert literature references in" "" refer(1)
+.xx "library." "" "lorder: find ordering relation for an object" "" lorder(1)
+.xx "" "nice, nohup: run a command at" "low priority." "" nice(1)
+.xx "" "" "lp: line printer." "" lp(4)
+.xx "" "" "lpd: line printer daemon." "" lpd(8)
+.xx "" "" "lpr, vpr: line printer spooler." "" lpr(1)
+.xx "" "" "ls: list contents of directory." "" ls(1)
+.xx "" "" "lseek, tell: move read/write pointer." "" lseek(2)
+.xx "integers." "l3tol," "ltol3: convert between 3-byte integers and long" "" l3tol(3)
+.xx "" "" "m4: macro processor." "" m4(1)
+.xx "" "uudiff: directory comparison between" "machines." "" uudiff(1C)
+.xx "" "m4:" "macro processor." "" m4(1)
+.xx "" "ms:" "macros for formatting manuscripts." "" ms(7)
+.xx "" "man:" "macros to typeset manual." "" man(7)
+.xx "" "ht: RH-11/TE-16" "magtape interface." "" ht(4)
+.xx "" "tm: TM-11/TU-10" "magtape interface." "" tm(4)
+.xx "" "xsend, xget, enroll: secret" "mail." "" xsend(1)
+.xx "" "mail: send or receive" "mail among users." "" mail(1)
+.xx "" "" "mail: send or receive mail among users." "" mail(1)
+.xx "" "mem, kmem:" "main memory." "" mem(4)
+.xx "" "malloc, free, realloc, calloc:" "main memory allocator." "" malloc(3)
+.xx "" "make:" "maintain program groups." "" make(1)
+.xx "" "ar: archive and library" "maintainer." "" ar(1)
+.xx "" "ar11: PDP-11 compatible archive and library" "maintainer." "" ar11(1)
+.xx "" "" "makekey: generate encryption key." "" makekey(8)
+.xx "allocator." "" "malloc, free, realloc, calloc: main memory" "" malloc(3)
+.xx "" "mpx: create and" "manipulate multiplexed files." "" mpx(2)
+.xx "" "tp:" "manipulate tape archive." "" tp(1)
+.xx "" "frexp, ldexp, modf: split into" "mantissa and exponent." "" frexp(3)
+.xx "" "man: print sections of this" "manual." "" man(1)
+.xx "" "man: macros to typeset" "manual." "" man(7)
+.xx "" "ms: macros for formatting" "manuscripts." "" ms(7)
+.xx "" "ascii:" "map of ASCII character set." "" ascii(7)
+.xx "" "umask: set file creation mode" "mask." "" umask(2)
+.xx "" "eqn, neqn, checkeq: typeset" "mathematics." "" eqn(1)
+.xx "" "" "maze: generate a maze problem." "" maze(6)
+.xx "" "maze: generate a" "maze problem." "" maze(6)
+.xx "" "bcd: convert to antique" "media." "" bcd(6)
+.xx "" "" "mem, kmem: main memory." "" mem(4)
+.xx "" "mem, kmem: main" "memory." "" mem(4)
+.xx "" "malloc, free, realloc, calloc: main" "memory allocator." "" malloc(3)
+.xx "" "core: format of" "memory image file." "" core(5)
+.xx "" "sort: sort or" "merge files." "" sort(1)
+.xx "" "" "mesg: permit or deny messages." "" mesg(1)
+.xx "" "mesg: permit or deny" "messages." "" mesg(1)
+.xx "" "perror, sys_errlist, sys_nerr: system error" "messages." "" perror(3)
+.xx "" "" "mkdir: make a directory." "" mkdir(1)
+.xx "" "" "mkfs: construct a file system." "" mkfs(1M)
+.xx "" "" "mknod: build special file." "" mknod(1M)
+.xx "" "" "mknod: make a directory or a special file." "" mknod(2)
+.xx "" "" "mktemp: make a unique file name." "" mktemp(3)
+.xx "" "chmod: change" "mode." "" chmod(1)
+.xx "" "getty: set terminal" "mode." "" getty(8)
+.xx "" "umask: set file creation" "mode mask." "" umask(2)
+.xx "" "chmod: change" "mode of file." "" chmod(2)
+.xx "" "stty, gtty: set and retrieve terminal" "modes." "" stty(2)
+.xx "" "frexp, ldexp," "modf: split into mantissa and exponent." "" frexp(3)
+.xx "" "touch: update date last" "modified of a file." "" touch(1)
+.xx "" "" "monitor: prepare execution profile." "" monitor(3)
+.xx "" "mount, umount:" "mount and dismount file system." "" mount(1M)
+.xx "" "mount, umount:" "mount or remove file system." "" mount(2)
+.xx "" "" "mount, umount: mount and dismount file system." "" mount(1M)
+.xx "" "" "mount, umount: mount or remove file system." "" mount(2)
+.xx "" "mtab:" "mounted file system table." "" mtab(5)
+.xx "" "mv:" "move or rename files." "" mv(1)
+.xx "" "lseek, tell:" "move read/write pointer." "" lseek(2)
+.xx "" "hp: RH-11/RP04, RP05, RP06, RM03" "moving-head disk." "" hp(4)
+.xx "" "rp: RP-11/RP03" "moving-head disk." "" rp(4)
+.xx "" "" "mpx: create and manipulate multiplexed files." "" mpx(2)
+.xx "" "" "mpxio: multiplexed i/o." "" mpxio(5)
+.xx "" "" "ms: macros for formatting manuscripts." "" ms(7)
+.xx "" "" "mtab: mounted file system table." "" mtab(5)
+.xx "" "mpx: create and manipulate" "multiplexed files." "" mpx(2)
+.xx "" "mpxio:" "multiplexed i/o." "" mpxio(5)
+.xx "" "dh: DH-11 communications" "multiplexer." "" dh(4)
+.xx "" "dz: DZ-11 communications" "multiplexer." "" dz(4)
+.xx "" "" "mv: move or rename files." "" mv(1)
+.xx "" "getenv: value for environment" "name." "" getenv(3)
+.xx "" "getlogin: get login" "name." "" getlogin(3)
+.xx "" "mktemp: make a unique file" "name." "" mktemp(3)
+.xx "" "pwd: working directory" "name." "" pwd(1)
+.xx "" "tty: get terminal" "name." "" tty(1)
+.xx "" "terminals: conventional" "names." "" term(7)
+.xx "" "ncheck: generate" "names from i-numbers." "" ncheck(1M)
+.xx "" "dumpdir: print the" "names of files on a dump tape." "" dumpdir(1M)
+.xx "" "" "ncheck: generate names from i-numbers." "" ncheck(1M)
+.xx "" "eqn," "neqn, checkeq: typeset mathematics." "" eqn(1)
+.xx "" "" "newgrp: log in to a new group." "" newgrp(1)
+.xx "" "/continue, cd, eval, exec, exit, export, login," "newgrp, read, readonly, set, shift, times, trap,/" "" sh(1)
+.xx "" "dbminit, fetch, store, delete, firstkey," "nextkey: data base subroutines." "" dbm(3x)
+.xx "" "" "nice, nohup: run a command at low priority." "" nice(1)
+.xx "" "" "nice: set program priority." "" nice(2)
+.xx "" "" "nlist: get entries from name list." "" nlist(3)
+.xx "" "" "nm: print name list." "" nm(1)
+.xx "" "nice," "nohup: run a command at low priority." "" nice(1)
+.xx "" "" "nohup: run a command immune to hangups." "" nohup(1)
+.xx "" "setjmp, longjmp:" "non-local goto." "" setjmp(3)
+.xx "" "tbl: format tables for" "nroff or troff." "" tbl(1)
+.xx "" "troff," "nroff: text formatting and typesetting." "" troff(1)
+.xx "" "deroff: remove" "nroff, troff, tbl and eqn constructs." "" deroff(1)
+.xx "" "" "null: data sink." "" null(4)
+.xx "" "atof, atoi, atol: convert ASCII to" "numbers." "" atof(3)
+.xx "" "errno: introduction to system calls and error" "numbers." "intro," intro(2)
+.xx "" "number: convert Arabic" "numerals to English." "" number(1)
+.xx "" "size: size of an" "object file." "" size(1)
+.xx "" "lorder: find ordering relation for an" "object library." "" lorder(1)
+.xx "" "od:" "octal dump." "" od(1)
+.xx "" "" "od: octal dump." "" od(1)
+.xx "" "acct: turn accounting on or" "off." "" acct(2)
+.xx "" "login: sign" "on." "" login(1)
+.xx "" "plot:" "openpl et al.: graphics interface." "" plot(3x)
+.xx "" "strcpy, strcpyn, strlen, index, rindex: string" "operations." "strcat, strcatn, strcmp, strcmpn," string(3)
+.xx "" "join: relational database" "operator." "" join(1)
+.xx "" "stty: set terminal" "options." "" stty(1)
+.xx "" "lorder: find" "ordering relation for an object library." "" lorder(1)
+.xx "" "a.out: assembler and link editor" "output." "" a.out(5)
+.xx "" "ecvt, fcvt, gcvt:" "output conversion." "" ecvt(3)
+.xx "" "printf, fprintf, sprintf: formatted" "output conversion." "" printf(3S)
+.xx "" "chown: change" "owner and group of a file." "" chown(2)
+.xx "" "chown, chgrp: change" "owner or group." "" chown(1)
+.xx "" "quot: summarize file system" "ownership." "" quot(1M)
+.xx "" "stdio: standard buffered input/output" "package." "" stdio(3S)
+.xx "" "tk:" "paginator for the Tektronix 4014." "" tk(1)
+.xx "" "pc: PC-11" "paper tape reader/punch." "" pc(4)
+.xx "" "" "passwd: change login password." "" passwd(1)
+.xx "" "" "passwd: password file." "" passwd(5)
+.xx "" "getpass: read a" "password." "" getpass(3)
+.xx "" "passwd: change login" "password." "" passwd(1)
+.xx "" "passwd:" "password file." "" passwd(5)
+.xx "" "getpwuid, getpwnam, setpwent, endpwent: get" "password file entry." "getpwent," getpwent(3)
+.xx "" "grep, egrep, fgrep: search a file for a" "pattern." "" grep(1)
+.xx "" "awk:" "pattern scanning and processing language." "" awk(1)
+.xx "" "" "pause: stop until signal." "" pause(2)
+.xx "" "" "pc: PC-11 paper tape reader/punch." "" pc(4)
+.xx "" "pc:" "PC-11 paper tape reader/punch." "" pc(4)
+.xx "" "popen," "pclose: initiate I/O to/from a process." "" popen(3S)
+.xx "" "ar11:" "PDP-11 compatible archive and library maintainer." "" ar11(1)
+.xx "" "update:" "periodically update the super block." "" update(8)
+.xx "" "mesg:" "permit or deny messages." "" mesg(1)
+.xx "" "ptx:" "permuted index." "" ptx(1)
+.xx "messages." "" "perror, sys_errlist, sys_nerr: system error" "" perror(3)
+.xx "" "sticky: executable files with" "persistent text." "" sticky(8)
+.xx "" "cat:" "phototypesetter interface." "" cat(4)
+.xx "" "tc:" "photypesetter simulator." "" tc(1)
+.xx "" "split: split a file into" "pieces." "" split(1)
+.xx "" "" "pipe: create an interprocess channel." "" pipe(2)
+.xx "" "tee:" "pipe fitting." "" tee(1)
+.xx "" "" "plot: graphics filters." "" plot(1G)
+.xx "" "" "plot: graphics interface." "" plot(5)
+.xx "" "" "plot: openpl et al.: graphics interface." "" plot(3x)
+.xx "" "lseek, tell: move read/write" "pointer." "" lseek(2)
+.xx "" "" "popen, pclose: initiate I/O to/from a process." "" popen(3S)
+.xx "root." "exp, log, log10," "pow, sqrt: exponential, logarithm, power, square" "" exp(3M)
+.xx "" "exp, log, log10, pow, sqrt: exponential, logarithm," "power, square root." "" exp(3M)
+.xx "" "" "pr: print file." "" pr(1)
+.xx "" "kill: terminate a process with extreme" "prejudice." "" kill(1)
+.xx "" "monitor:" "prepare execution profile." "" monitor(3)
+.xx "" "types:" "primitive system data types." "" types(5)
+.xx "" "cat: catenate and" "print." "" cat(1)
+.xx "" "date:" "print and set the date." "" date(1)
+.xx "" "cal:" "print calendar." "" cal(1)
+.xx "" "pr:" "print file." "" pr(1)
+.xx "" "nm:" "print name list." "" nm(1)
+.xx "" "man:" "print sections of this manual." "" man(1)
+.xx "" "pstat:" "print system facts." "" pstat(1M)
+.xx "" "dumpdir:" "print the names of files on a dump tape." "" dumpdir(1M)
+.xx "" "lp: line" "printer." "" lp(4)
+.xx "" "lpd: line" "printer daemon." "" lpd(8)
+.xx "" "lpr, vpr: line" "printer spooler." "" lpr(1)
+.xx "" "vp: Versatec" "printer-plotter." "" vp(4)
+.xx "conversion." "" "printf, fprintf, sprintf: formatted output" "" printf(3S)
+.xx "" "nice, nohup: run a command at low" "priority." "" nice(1)
+.xx "" "nice: set program" "priority." "" nice(2)
+.xx "" "maze: generate a maze" "problem." "" maze(6)
+.xx "" "boot" "procedures: UNIX/32V startup." "" bproc(8)
+.xx "" "exit: terminate" "process." "" exit(2)
+.xx "" "fork: spawn new" "process." "" fork(2)
+.xx "" "kill: send signal to a" "process." "" kill(2)
+.xx "" "popen, pclose: initiate I/O to/from a" "process." "" popen(3S)
+.xx "" "wait: await completion of" "process." "" wait(1)
+.xx "" "init:" "process control initialization." "" init(8)
+.xx "" "getpid: get" "process identification." "" getpid(2)
+.xx "" "ps:" "process status." "" ps(1)
+.xx "" "times: get" "process times." "" times(2)
+.xx "" "wait: wait for" "process to terminate." "" wait(2)
+.xx "" "ptrace:" "process trace." "" ptrace(2)
+.xx "" "kill: terminate a" "process with extreme prejudice." "" kill(1)
+.xx "" "awk: pattern scanning and" "processing language." "" awk(1)
+.xx "" "m4: macro" "processor." "" m4(1)
+.xx "" "" "prof: display profile data." "" prof(1)
+.xx "" "" "profil: execution time profile." "" profil(2)
+.xx "" "monitor: prepare execution" "profile." "" monitor(3)
+.xx "" "profil: execution time" "profile." "" profil(2)
+.xx "" "prof: display" "profile data." "" prof(1)
+.xx "" "end, etext, edata: last locations in" "program." "" end(3)
+.xx "" "units: conversion" "program." "" units(1)
+.xx "" "lex: generator of lexical analysis" "programs." "" lex(1)
+.xx "" "struct: structure Fortran" "programs." "" struct(1)
+.xx "" "arithmetic:" "provide drill in number facts." "" arithmetic(6)
+.xx "" "true, false:" "provide truth values." "" true(1)
+.xx "" "" "ps: process status." "" ps(1)
+.xx "" "" "pstat: print system facts." "" pstat(1M)
+.xx "" "" "ptrace: process trace." "" ptrace(2)
+.xx "" "" "ptx: permuted index." "" ptx(1)
+.xx "" "ungetc:" "push character back into input stream." "" ungetc(3S)
+.xx "on a stream." "" "putc, putchar, fputc, putw: put character or word" "" putc(3S)
+.xx "stream." "putc," "putchar, fputc, putw: put character or word on a" "" putc(3S)
+.xx "" "" "puts, fputs: put a string on a stream." "" puts(3S)
+.xx "" "putc, putchar, fputc," "putw: put character or word on a stream." "" putc(3S)
+.xx "" "" "pwd: working directory name." "" pwd(1)
+.xx "" "" "qsort: quicker sort." "" qsort(3)
+.xx "" "qsort:" "quicker sort." "" qsort(3)
+.xx "" "" "quiz: test your knowledge." "" quiz(6)
+.xx "" "" "quot: summarize file system ownership." "" quot(1M)
+.xx "" "" "rand, srand: random number generator." "" rand(3)
+.xx "" "rand, srand:" "random number generator." "" rand(3)
+.xx "" "rc:" "Ratfor compiler." "" rc(1)
+.xx "" "" "ratfor: rational Fortran dialect." "" ratfor(1)
+.xx "" "ratfor:" "rational Fortran dialect." "" ratfor(1)
+.xx "" "" "rc: Ratfor compiler." "" rc(1)
+.xx "" "getpass:" "read a password." "" getpass(3)
+.xx "" "read:" "read from file." "" read(2)
+.xx "" "" "read: read from file." "" read(2)
+.xx "wait:/" "/cd, eval, exec, exit, export, login, newgrp," "read, readonly, set, shift, times, trap, umask," "" sh(1)
+.xx "" "pc: PC-11 paper tape" "reader/punch." "" pc(4)
+.xx "" "open: open for" "reading or writing." "" open(2)
+.xx "" "/cd, eval, exec, exit, export, login, newgrp, read," "readonly, set, shift, times, trap, umask, wait:/" "" sh(1)
+.xx "" "lseek, tell: move" "read/write pointer." "" lseek(2)
+.xx "" "malloc, free," "realloc, calloc: main memory allocator." "" malloc(3)
+.xx "" "mail: send or" "receive mail among users." "" mail(1)
+.xx "" "utmp, wtmp: login" "records." "" utmp(5)
+.xx "references in documents." "" "refer, lookbib: find and insert literature" "" refer(1)
+.xx "" "refer, lookbib: find and insert literature" "references in documents." "" refer(1)
+.xx "" "comm: select or" "reject lines common to two sorted files." "" comm(1)
+.xx "" "lorder: find ordering" "relation for an object library." "" lorder(1)
+.xx "" "join:" "relational database operator." "" join(1)
+.xx "" "strip: remove symbols and" "relocation bits." "" strip(1)
+.xx "" "calendar:" "reminder service." "" calendar(1)
+.xx "" "unlink:" "remove directory entry." "" unlink(2)
+.xx "" "mount, umount: mount or" "remove file system." "" mount(2)
+.xx "" "deroff:" "remove nroff, troff, tbl and eqn constructs." "" deroff(1)
+.xx "" "strip:" "remove symbols and relocation bits." "" strip(1)
+.xx "" "rm, rmdir:" "remove (unlink) files." "" rm(1)
+.xx "" "mv: move or" "rename files." "" mv(1)
+.xx "" "uniq: report" "repeated lines in a file." "" uniq(1)
+.xx "" "iostat:" "report I/O statistics." "" iostat(1M)
+.xx "" "uniq:" "report repeated lines in a file." "" uniq(1)
+.xx "" "fseek, ftell, rewind:" "reposition a stream." "" fseek(3S)
+.xx "" "" "restor: incremental file system restore." "" restor(1M)
+.xx "" "restor: incremental file system" "restore." "" restor(1M)
+.xx "" "stty, gtty: set and" "retrieve terminal modes." "" stty(2)
+.xx "" "" "rev: reverse lines of a file." "" rev(1)
+.xx "" "col: filter" "reverse line feeds." "" col(1)
+.xx "" "rev:" "reverse lines of a file." "" rev(1)
+.xx "" "fseek, ftell," "rewind: reposition a stream." "" fseek(3S)
+.xx "" "" "rf: RF11/RS11 fixed-head disk file." "" rf(4)
+.xx "" "rf:" "RF11/RS11 fixed-head disk file." "" rf(4)
+.xx "" "hp:" "RH-11/RP04, RP05, RP06, RM03 moving-head disk." "" hp(4)
+.xx "" "hs:" "RH11/RS03-RS04 fixed-head disk file." "" hs(4)
+.xx "" "ht:" "RH-11/TE-16 magtape interface." "" ht(4)
+.xx "" "strcmp, strcmpn, strcpy, strcpyn, strlen, index," "rindex: string operations." "strcat, strcatn," string(3)
+.xx "" "call:" "ring a telephone." "" call(1C)
+.xx "" "" "rk: RK-11/RK03 or RK05 disk." "" rk(4)
+.xx "" "rk: RK-11/RK03 or" "RK05 disk." "" rk(4)
+.xx "" "rk:" "RK-11/RK03 or RK05 disk." "" rk(4)
+.xx "" "" "rm, rmdir: remove (unlink) files." "" rm(1)
+.xx "" "hp: RH-11/RP04, RP05, RP06," "RM03 moving-head disk." "" hp(4)
+.xx "" "rm," "rmdir: remove (unlink) files." "" rm(1)
+.xx "" "pow, sqrt: exponential, logarithm, power, square" "root." "exp, log, log10," exp(3M)
+.xx "" "" "rp: RP-11/RP03 moving-head disk." "" rp(4)
+.xx "" "hp: RH-11/RP04," "RP05, RP06, RM03 moving-head disk." "" hp(4)
+.xx "" "hp: RH-11/RP04, RP05," "RP06, RM03 moving-head disk." "" hp(4)
+.xx "" "rp:" "RP-11/RP03 moving-head disk." "" rp(4)
+.xx "" "nice, nohup:" "run a command at low priority." "" nice(1)
+.xx "" "nohup:" "run a command immune to hangups." "" nohup(1)
+.xx "" "" "sa, accton: system accounting." "" sa(1M)
+.xx "" "brk," "sbrk, break: change core allocation." "" brk(2)
+.xx "" "" "scanf, fscanf, sscanf: formatted input conversion." "" scanf(3S)
+.xx "" "awk: pattern" "scanning and processing language." "" awk(1)
+.xx "" "alarm:" "schedule signal after specified time." "" alarm(2)
+.xx "" "" "sdb: C symbolic debugger." "" sdb(1)
+.xx "" "grep, egrep, fgrep:" "search a file for a pattern." "" grep(1)
+.xx "" "xsend, xget, enroll:" "secret mail." "" xsend(1)
+.xx "" "man: print" "sections of this manual." "" man(1)
+.xx "" "" "sed: stream editor." "" sed(1)
+.xx "" "comm:" "select or reject lines common to two sorted files." "" comm(1)
+.xx "" "mail:" "send or receive mail among users." "" mail(1)
+.xx "" "kill:" "send signal to a process." "" kill(2)
+.xx "" "calendar: reminder" "service." "" calendar(1)
+.xx "" "ascii: map of ASCII character" "set." "" ascii(7)
+.xx "" "/exec, exit, export, login, newgrp, read, readonly," "set, shift, times, trap, umask, wait: command/" "" sh(1)
+.xx "" "" "setbuf: assign buffering to a stream." "" setbuf(3S)
+.xx "" "setuid," "setgid: set user and group ID." "" setuid(2)
+.xx "" "getgrent, getgrgid, getgrnam," "setgrent, endgrent: get group file entry." "" getgrent(3)
+.xx "" "" "setjmp, longjmp: non-local goto." "" setjmp(3)
+.xx "" "crypt," "setkey, encrypt: DES encryption." "" crypt(3)
+.xx "" "getpwent, getpwuid, getpwnam," "setpwent, endpwent: get password file entry." "" getpwent(3)
+.xx "" "" "setuid, setgid: set user and group ID." "" setuid(2)
+.xx "continue, cd, eval, exec, exit, export, login,/" "" "sh, for, case, if, while, \fB:\fP, \fB.\fP, break," "" sh(1)
+.xx "" "system: issue a" "shell command." "" system(3)
+.xx "" "/exit, export, login, newgrp, read, readonly, set," "shift, times, trap, umask, wait: command language." "" sh(1)
+.xx "" "login:" "sign on." "" login(1)
+.xx "" "pause: stop until" "signal." "" pause(2)
+.xx "" "alarm: schedule" "signal after specified time." "" alarm(2)
+.xx "" "" "signal: catch or ignore signals." "" signal(2)
+.xx "" "kill: send" "signal to a process." "" kill(2)
+.xx "" "signal: catch or ignore" "signals." "" signal(2)
+.xx "" "tc: photypesetter" "simulator." "" tc(1)
+.xx "trigonometric functions." "" "sin, cos, tan, asin, acos, atan, atan2:" "" sin(3M)
+.xx "" "" "sinh, cosh, tanh: hyperbolic functions." "" sinh(3M)
+.xx "" "null: data" "sink." "" null(4)
+.xx "" "size:" "size of an object file." "" size(1)
+.xx "" "" "size: size of an object file." "" size(1)
+.xx "" "" "sleep: suspend execution for an interval." "" sleep(1)
+.xx "" "" "sleep: suspend execution for interval." "" sleep(3)
+.xx "" "spline: interpolate" "smooth curve." "" spline(1G)
+.xx "" "qsort: quicker" "sort." "" qsort(3)
+.xx "" "tsort: topological" "sort." "" tsort(1)
+.xx "" "sort:" "sort or merge files." "" sort(1)
+.xx "" "" "sort: sort or merge files." "" sort(1)
+.xx "" "comm: select or reject lines common to two" "sorted files." "" comm(1)
+.xx "" "look: find lines in a" "sorted list." "" look(1)
+.xx "" "fork:" "spawn new process." "" fork(2)
+.xx "" "alarm: schedule signal after" "specified time." "" alarm(2)
+.xx "" "" "spell, spellin, spellout: find spelling errors." "" spell(1)
+.xx "" "spell," "spellin, spellout: find spelling errors." "" spell(1)
+.xx "" "spell, spellin, spellout: find" "spelling errors." "" spell(1)
+.xx "" "spell, spellin," "spellout: find spelling errors." "" spell(1)
+.xx "" "" "spline: interpolate smooth curve." "" spline(1G)
+.xx "" "split:" "split a file into pieces." "" split(1)
+.xx "" "frexp, ldexp, modf:" "split into mantissa and exponent." "" frexp(3)
+.xx "" "" "split: split a file into pieces." "" split(1)
+.xx "" "lpr, vpr: line printer" "spooler." "" lpr(1)
+.xx "" "printf, fprintf," "sprintf: formatted output conversion." "" printf(3S)
+.xx "" "exp, log, log10, pow," "sqrt: exponential, logarithm, power, square root." "" exp(3M)
+.xx "" "log10, pow, sqrt: exponential, logarithm, power," "square root." "exp, log," exp(3M)
+.xx "" "rand," "srand: random number generator." "" rand(3)
+.xx "" "scanf, fscanf," "sscanf: formatted input conversion." "" scanf(3S)
+.xx "" "stdio:" "standard buffered input/output package." "" stdio(3S)
+.xx "" "boot procedures: UNIX/32V" "startup." "" bproc(8)
+.xx "" "" "stat, fstat: get file status." "" stat(2)
+.xx "" "iostat: report I/O" "statistics." "" iostat(1M)
+.xx "" "ps: process" "status." "" ps(1)
+.xx "" "stat, fstat: get file" "status." "" stat(2)
+.xx "" "feof, ferror, clearerr, fileno: stream" "status inquiries." "" ferror(3S)
+.xx "" "" "stdio: standard buffered input/output package." "" stdio(3S)
+.xx "" "" "sticky: executable files with persistent text." "" sticky(8)
+.xx "" "" "stime: set time." "" stime(2)
+.xx "" "pause:" "stop until signal." "" pause(2)
+.xx "" "icheck: file system" "storage consistency check." "" icheck(1M)
+.xx "subroutines." "dbminit, fetch," "store, delete, firstkey, nextkey: data base" "" dbm(3x)
+.xx "strlen, index, rindex: string operations." "" "strcat, strcatn, strcmp, strcmpn, strcpy, strcpyn," "" string(3)
+.xx "index, rindex: string operations." "strcat," "strcatn, strcmp, strcmpn, strcpy, strcpyn, strlen," "" string(3)
+.xx "rindex: string operations." "strcat, strcatn," "strcmp, strcmpn, strcpy, strcpyn, strlen, index," "" string(3)
+.xx "string operations." "strcat, strcatn, strcmp," "strcmpn, strcpy, strcpyn, strlen, index, rindex:" "" string(3)
+.xx "operations." "strcat, strcatn, strcmp, strcmpn," "strcpy, strcpyn, strlen, index, rindex: string" "" string(3)
+.xx "" "strcat, strcatn, strcmp, strcmpn, strcpy," "strcpyn, strlen, index, rindex: string operations." "" string(3)
+.xx "" "fclose, fflush: close or flush a" "stream." "" fclose(3S)
+.xx "" "fopen, freopen, fdopen: open a" "stream." "" fopen(3S)
+.xx "" "fseek, ftell, rewind: reposition a" "stream." "" fseek(3S)
+.xx "" "getchar, fgetc, getw: get character or word from" "stream." "getc," getc(3S)
+.xx "" "gets, fgets: get a string from a" "stream." "" gets(3S)
+.xx "" "putchar, fputc, putw: put character or word on a" "stream." "putc," putc(3S)
+.xx "" "puts, fputs: put a string on a" "stream." "" puts(3S)
+.xx "" "setbuf: assign buffering to a" "stream." "" setbuf(3S)
+.xx "" "ungetc: push character back into input" "stream." "" ungetc(3S)
+.xx "" "sed:" "stream editor." "" sed(1)
+.xx "" "feof, ferror, clearerr, fileno:" "stream status inquiries." "" ferror(3S)
+.xx "" "gets, fgets: get a" "string from a stream." "" gets(3S)
+.xx "" "puts, fputs: put a" "string on a stream." "" puts(3S)
+.xx "" "strcmpn, strcpy, strcpyn, strlen, index, rindex:" "string operations." "strcat, strcatn, strcmp," string(3)
+.xx "" "basename:" "strip filename affixes." "" basename(1)
+.xx "" "" "strip: remove symbols and relocation bits." "" strip(1)
+.xx "" "strcat, strcatn, strcmp, strcmpn, strcpy, strcpyn," "strlen, index, rindex: string operations." "" string(3)
+.xx "" "" "struct: structure Fortran programs." "" struct(1)
+.xx "" "struct:" "structure Fortran programs." "" struct(1)
+.xx "" "ioctl," "stty, gtty: control device." "" ioctl(2)
+.xx "" "" "stty, gtty: set and retrieve terminal modes." "" stty(2)
+.xx "" "" "stty: set terminal options." "" stty(1)
+.xx "" "" "su: substitute user id temporarily." "" su(1)
+.xx "" "fetch, store, delete, firstkey, nextkey: data base" "subroutines." "dbminit," dbm(3x)
+.xx "" "su:" "substitute user id temporarily." "" su(1)
+.xx "" "sum:" "sum and count blocks in a file." "" sum(1)
+.xx "" "" "sum: sum and count blocks in a file." "" sum(1)
+.xx "" "du:" "summarize disk usage." "" du(1)
+.xx "" "quot:" "summarize file system ownership." "" quot(1M)
+.xx "" "sync: update the" "super block." "" sync(1M)
+.xx "" "update: periodically update the" "super block." "" update(8)
+.xx "" "sync: update" "super-block." "" sync(2)
+.xx "" "sleep:" "suspend execution for an interval." "" sleep(1)
+.xx "" "sleep:" "suspend execution for interval." "" sleep(3)
+.xx "" "" "swab: swap bytes." "" swab(3)
+.xx "" "swab:" "swap bytes." "" swab(3)
+.xx "" "sdb: C" "symbolic debugger." "" sdb(1)
+.xx "" "strip: remove" "symbols and relocation bits." "" strip(1)
+.xx "" "" "sync: update super-block." "" sync(2)
+.xx "" "" "sync: update the super block." "" sync(1M)
+.xx "" "indir," "syscall: indirect system call." "" indir(2)
+.xx "" "perror," "sys_errlist, sys_nerr: system error messages." "" perror(3)
+.xx "distribution tape." "" "sysgen: UNIX/32V system generation from the" "" sysgen(8)
+.xx "" "perror, sys_errlist," "sys_nerr: system error messages." "" perror(3)
+.xx "" "mkfs: construct a file" "system." "" mkfs(1M)
+.xx "" "mount, umount: mount and dismount file" "system." "" mount(1M)
+.xx "" "mount, umount: mount or remove file" "system." "" mount(2)
+.xx "" "who: who is on the" "system." "" who(1)
+.xx "" "mtab: mounted file system" "table." "" mtab(5)
+.xx "" "tbl: format" "tables for nroff or troff." "" tbl(1)
+.xx "" "tabs: set terminal" "tabs." "" tabs(1)
+.xx "" "" "tabs: set terminal tabs." "" tabs(1)
+.xx "" "" "tail: deliver the last part of a file." "" tail(1)
+.xx "functions." "sin, cos," "tan, asin, acos, atan, atan2: trigonometric" "" sin(3M)
+.xx "" "sinh, cosh," "tanh: hyperbolic functions." "" sinh(3M)
+.xx "" "dumpdir: print the names of files on a dump" "tape." "" dumpdir(1M)
+.xx "" "UNIX/32V system generation from the distribution" "tape." "sysgen:" sysgen(8)
+.xx "" "tp: manipulate" "tape archive." "" tp(1)
+.xx "" "tar:" "tape archiver." "" tar(1)
+.xx "" "tp: DEC/mag" "tape formats." "" tp(5)
+.xx "" "pc: PC-11 paper" "tape reader/punch." "" pc(4)
+.xx "" "" "tar: tape archiver." "" tar(1)
+.xx "" "deroff: remove nroff, troff," "tbl and eqn constructs." "" deroff(1)
+.xx "" "" "tbl: format tables for nroff or troff." "" tbl(1)
+.xx "" "" "tc: photypesetter simulator." "" tc(1)
+.xx "" "" "tc: TC-11/TU56 DECtape." "" tc(4)
+.xx "" "tc:" "TC-11/TU56 DECtape." "" tc(4)
+.xx "" "" "tee: pipe fitting." "" tee(1)
+.xx "" "tk: paginator for the" "Tektronix 4014." "" tk(1)
+.xx "" "call: ring a" "telephone." "" call(1C)
+.xx "" "su: substitute user id" "temporarily." "" su(1)
+.xx "" "ttyname, isatty, ttyslot: find name of a" "terminal." "" ttyname(3)
+.xx "" "ttys:" "terminal initialization data." "" ttys(5)
+.xx "" "tty: general" "terminal interface." "" tty(4)
+.xx "" "getty: set" "terminal mode." "" getty(8)
+.xx "" "stty, gtty: set and retrieve" "terminal modes." "" stty(2)
+.xx "" "tty: get" "terminal name." "" tty(1)
+.xx "" "stty: set" "terminal options." "" stty(1)
+.xx "" "tabs: set" "terminal tabs." "" tabs(1)
+.xx "" "" "terminals: conventional names." "" term(7)
+.xx "" "wait: wait for process to" "terminate." "" wait(2)
+.xx "" "kill:" "terminate a process with extreme prejudice." "" kill(1)
+.xx "" "exit:" "terminate process." "" exit(2)
+.xx "" "" "test: condition command." "" test(1)
+.xx "" "quiz:" "test your knowledge." "" quiz(6)
+.xx "" "sticky: executable files with persistent" "text." "" sticky(8)
+.xx "" "ed:" "text editor." "" ed(1)
+.xx "" "troff, nroff:" "text formatting and typesetting." "" troff(1)
+.xx "" "alarm: schedule signal after specified" "time." "" alarm(2)
+.xx "" "at: execute commands at a later" "time." "" at(1)
+.xx "" "stime: set" "time." "" stime(2)
+.xx "" "time, ftime: get date and" "time." "" time(2)
+.xx "" "" "time, ftime: get date and time." "" time(2)
+.xx "" "times: get process" "times." "" times(2)
+.xx "" "utime: set file" "times." "" utime(2)
+.xx "" "export, login, newgrp, read, readonly, set, shift," "times, trap, umask, wait: command language." "/exit," sh(1)
+.xx "" "ctime, localtime, gmtime, asctime," "timezone: convert date and time to ASCII." "" ctime(3)
+.xx "" "" "tk: paginator for the Tektronix 4014." "" tk(1)
+.xx "" "" "tm: TM-11/TU-10 magtape interface." "" tm(4)
+.xx "" "tm:" "TM-11/TU-10 magtape interface." "" tm(4)
+.xx "" "popen, pclose: initiate I/O" "to/from a process." "" popen(3S)
+.xx "" "tsort:" "topological sort." "" tsort(1)
+.xx "" "" "touch: update date last modified of a file." "" touch(1)
+.xx "" "" "tp: DEC/mag tape formats." "" tp(5)
+.xx "" "" "tp: manipulate tape archive." "" tp(1)
+.xx "" "" "tr: translate characters." "" tr(1)
+.xx "" "ptrace: process" "trace." "" ptrace(2)
+.xx "" "tr:" "translate characters." "" tr(1)
+.xx "" "login, newgrp, read, readonly, set, shift, times," "trap, umask, wait: command language." "/exit, export," sh(1)
+.xx "" "sin, cos, tan, asin, acos, atan, atan2:" "trigonometric functions." "" sin(3M)
+.xx "" "tbl: format tables for nroff or" "troff." "" tbl(1)
+.xx "" "" "troff, nroff: text formatting and typesetting." "" troff(1)
+.xx "" "deroff: remove nroff," "troff, tbl and eqn constructs." "" deroff(1)
+.xx "" "" "true, false: provide truth values." "" true(1)
+.xx "" "true, false: provide" "truth values." "" true(1)
+.xx "" "" "tsort: topological sort." "" tsort(1)
+.xx "" "" "tty: general terminal interface." "" tty(4)
+.xx "" "" "tty: get terminal name." "" tty(1)
+.xx "" "greek: graphics for extended" "TTY-37 type-box." "" greek(7)
+.xx "" "" "ttyname, isatty, ttyslot: find name of a terminal." "" ttyname(3)
+.xx "" "" "ttys: terminal initialization data." "" ttys(5)
+.xx "" "ttyname, isatty," "ttyslot: find name of a terminal." "" ttyname(3)
+.xx "" "file: determine file" "type." "" file(1)
+.xx "" "greek: graphics for extended TTY-37" "type-box." "" greek(7)
+.xx "" "types: primitive system data" "types." "" types(5)
+.xx "" "" "types: primitive system data types." "" types(5)
+.xx "" "man: macros to" "typeset manual." "" man(7)
+.xx "" "eqn, neqn, checkeq:" "typeset mathematics." "" eqn(1)
+.xx "" "troff, nroff: text formatting and" "typesetting." "" troff(1)
+.xx "" "getpw: get name from" "UID." "" getpw(3)
+.xx "" "" "umask: set file creation mode mask." "" umask(2)
+.xx "" "newgrp, read, readonly, set, shift, times, trap," "umask, wait: command language." "/export, login," sh(1)
+.xx "" "mount," "umount: mount and dismount file system." "" mount(1M)
+.xx "" "mount," "umount: mount or remove file system." "" mount(2)
+.xx "" "" "ungetc: push character back into input stream." "" ungetc(3S)
+.xx "" "" "uniq: report repeated lines in a file." "" uniq(1)
+.xx "" "mktemp: make a" "unique file name." "" mktemp(3)
+.xx "" "" "units: conversion program." "" units(1)
+.xx "" "cu: call" "UNIX." "" cu(1C)
+.xx "" "learn: computer aided instruction about" "UNIX." "" learn(1)
+.xx "" "boot procedures:" "UNIX/32V startup." "" bproc(8)
+.xx "tape." "sysgen:" "UNIX/32V system generation from the distribution" "" sysgen(8)
+.xx "" "rm, rmdir: remove" "(unlink) files." "" rm(1)
+.xx "" "" "unlink: remove directory entry." "" unlink(2)
+.xx "" "touch:" "update date last modified of a file." "" touch(1)
+.xx "" "" "update: periodically update the super block." "" update(8)
+.xx "" "sync:" "update super-block." "" sync(2)
+.xx "" "sync:" "update the super block." "" sync(1M)
+.xx "" "update: periodically" "update the super block." "" update(8)
+.xx "" "du: summarize disk" "usage." "" du(1)
+.xx "" "write: write to another" "user." "" write(1)
+.xx "" "setuid, setgid: set" "user and group ID." "" setuid(2)
+.xx "" "getuid, getgid, geteuid, getegid: get" "user and group identity." "" getuid(2)
+.xx "" "environ:" "user environment." "" environ(5)
+.xx "" "su: substitute" "user id temporarily." "" su(1)
+.xx "" "uulog: uucp" "user log inquiry." "" uulog(1C)
+.xx "" "wtmp:" "user login history." "" wtmp(5)
+.xx "" "mail: send or receive mail among" "users." "" mail(1)
+.xx "" "wall: write to all" "users." "" wall(1M)
+.xx "" "" "utime: set file times." "" utime(2)
+.xx "" "" "utmp, wtmp: login records." "" utmp(5)
+.xx "" "uulog:" "uucp user log inquiry." "" uulog(1C)
+.xx "" "" "uucp, uulog: unix to unix copy." "" uucp(1C)
+.xx "" "" "uudiff: directory comparison between machines." "" uudiff(1C)
+.xx "" "uucp," "uulog: unix to unix copy." "" uucp(1C)
+.xx "" "" "uulog: uucp user log inquiry." "" uulog(1C)
+.xx "" "" "uux: unix to unix command execution." "" uux(1C)
+.xx "" "abs: integer absolute" "value." "" abs(3)
+.xx "" "fabs, floor, ceil: absolute" "value, floor, ceiling functions." "" floor(3M)
+.xx "" "getenv:" "value for environment name." "" getenv(3)
+.xx "" "true, false: provide truth" "values." "" true(1)
+.xx "" "assert: program" "verification." "" assert(3x)
+.xx "" "lint: a C program" "verifier." "" lint(1)
+.xx "" "vp:" "Versatec printer-plotter." "" vp(4)
+.xx "" "filsys, flblk, ino: format of file system" "volume." "" filsys(5)
+.xx "" "" "vp: Versatec printer-plotter." "" vp(4)
+.xx "" "lpr," "vpr: line printer spooler." "" lpr(1)
+.xx "" "" "wait: await completion of process." "" wait(1)
+.xx "" "read, readonly, set, shift, times, trap, umask," "wait: command language." "/export, login, newgrp," sh(1)
+.xx "" "wait:" "wait for process to terminate." "" wait(2)
+.xx "" "" "wait: wait for process to terminate." "" wait(2)
+.xx "" "" "wall: write to all users." "" wall(1M)
+.xx "" "" "wc: word count." "" wc(1)
+.xx "exec, exit, export, login,/" "sh, for, case, if," "while, \fB:\fP, \fB.\fP, break, continue, cd, eval," "" sh(1)
+.xx "" "hangman: guess the" "word." "" hangman(6)
+.xx "" "cd: change" "working directory." "" cd(1)
+.xx "" "pwd:" "working directory name." "" pwd(1)
+.xx "" "write:" "write on a file." "" write(2)
+.xx "" "wall:" "write to all users." "" wall(1M)
+.xx "" "write:" "write to another user." "" write(1)
+.xx "" "" "write: write on a file." "" write(2)
+.xx "" "" "write: write to another user." "" write(1)
+.xx "" "open: open for reading or" "writing." "" open(2)
+.xx "" "utmp," "wtmp: login records." "" utmp(5)
+.xx "" "" "wtmp: user login history." "" wtmp(5)
+.xx "" "" "wump: the game of hunt-the-wumpus." "" wump(6)
+.xx "" "xsend," "xget, enroll: secret mail." "" xsend(1)
+.xx "" "" "xsend, xget, enroll: secret mail." "" xsend(1)
+.xx "" "j0, j1, jn," "y0, y1, yn: bessel functions." "" j0(3M)
+.xx "" "j0, j1, jn, y0," "y1, yn: bessel functions." "" j0(3M)
+.xx "" "" "yacc: yet another compiler-compiler." "" yacc(1)
+.xx "" "j0, j1, jn, y0, y1," "yn: bessel functions." "" j0(3M)
index 6ec0ce6..7d6edaf 100644 (file)
@@ -1,33 +1,18 @@
-.de pg
-.ps8
---
-.ps16
-.fp 3 G
-.sp 3.0i
-.ti .25i
-UNIX\s-4\fG\v'-6p'TM\v'6p'\fP\s0 TIME-SHARING SYSTEM:
-.sp |4.0i
-.ps 18
+.ps20
+.sp 4.25i
 .ce
 .ce
-UNIX PROGRAMMER'S MANUAL
-.ps12
-.sp |4.5i
+UNIX/32V PROGRAMMER'S MANUAL
+.ps10
+.sp |5i
 .ft I
 .ce
 .ft I
 .ce
-Seventh Edition, Volume \\$1
-.sp |5.0i
+Version 1.0
+.sp |5.75i
 .ce
 .ce
-January, 1979
-.ps 10
-.sp |9.5i-1
+February, 1979
+.sp |-1.5i-1
 .ft R
 .ce
 Bell Telephone Laboratories, Incorporated
 .ce
 .ft R
 .ce
 Bell Telephone Laboratories, Incorporated
 .ce
-Murray Hill, New Jersey
-..
-.pg 1
-.bp
-.pg 2A
-.bp
-.pg 2B
+Holmdel, New Jersey
diff --git a/usr/man/man0/title] b/usr/man/man0/title]
new file mode 100644 (file)
index 0000000..74326a2
--- /dev/null
@@ -0,0 +1,33 @@
+.de pg
+.ps8
+--
+.ps16
+.fp 3 G
+.sp 3.0i
+.ti .25i
+UNIX\s-4\fG\v'-6p'TM\v'6p'\fP\s0/32V TIME-SHARING SYSTEM:
+.sp |4.0i
+.ps 18
+.ce
+UNIX PROGRAMMER'S MANUAL
+.ps12
+.sp |4.5i
+.ft I
+.ce
+Version 1.0, Volume \\$1
+.sp |5.0i
+.ce
+February, 1979
+.ps 10
+.sp |9.5i-1
+.ft R
+.ce
+Bell Telephone Laboratories, Incorporated
+.ce
+Holmdel, New Jersey
+..
+.pg 1
+...bp
+...pg 2A
+...bp
+...pg 2B
diff --git a/usr/man/man0/toc.in b/usr/man/man0/toc.in
new file mode 100644 (file)
index 0000000..2f4150e
--- /dev/null
@@ -0,0 +1,67 @@
+.if t .pn 11\"TABLE OF CONTENTS
+.if n .pn 15
+.tr ~
+.ll 6.5i
+.lt 6.5i
+.po .5i
+.ds ET\"
+.de HD
+.po 0
+.lt 7.4i
+.tl '\(rn\(rn''\(rn\(rn'
+.lt
+.po
+'sp 18p
+.if e .tl '\\*(ET'''
+.if o .tl '''\\*(ET'
+'sp 18p
+.ns
+..
+.de FO
+'sp 18p
+.af % i
+.if e .tl '\s9\\*(Dt'- % -'\\*(Ed\s0'
+.if o .tl '\s9\\*(Ed'- % -'\\*(Dt\s0'
+'bp
+..
+.wh 0 HD
+.wh -60p FO
+.if \n(nl .bp
+.br
+.ds ET \s9\f2Table \|of \|Contents\fP\s0
+.ds Ed UNIX/32V version 1.0
+.ds Dt February \|1979
+.ce
+\f3TABLE \|OF \|CONTENTS\fP
+.nr x .5i
+.in +\nxu
+.nf
+.ta \n(.lu-\nxuR
+.de xx
+\\$1\f3 \a \fP\\$2
+..
+.nr a 0 1
+.de t
+.sp 1v
+.ne .5i
+.cs 3
+.ti -.5i
+.ss 18
+\f3\s9\\n+a. \\$1\s0\fP
+.ss 12
+.if t .sp .5v
+.cs 3 36
+.so toc\\na
+..
+.t "Commands and Application Programs"
+.t "System Calls"
+.t "Subroutines"
+.t "Special Files"
+.t "File Formats"
+.t "Games"
+.t "Miscellaneous"
+.t "System Maintenance"
+.in -.5i
+.cs 3
+.if n .ta 8n 16n 24n 32n 40n 48n 56n 64n 72n 80n
+.if t .ta .5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i 5.5i 6i 6.5i
diff --git a/usr/man/man0/toc1 b/usr/man/man0/toc1
new file mode 100644 (file)
index 0000000..8fb8f08
--- /dev/null
@@ -0,0 +1,139 @@
+.xx "intro" "introduction to commands"
+.xx "ac" "login accounting"
+.xx "adb" "debugger"
+.xx "ar" "archive and library maintainer"
+.xx "ar11" "PDP-11 compatible archive and library maintainer"
+.xx "arcv" "convert archives to new format"
+.xx "as" "assembler"
+.xx "at" "execute commands at a later time"
+.xx "awk" "pattern scanning and processing language"
+.xx "basename" "strip filename affixes"
+.xx "bc" "arbitrary-precision arithmetic language"
+.xx "cal" "print calendar"
+.xx "calendar" "reminder service"
+.xx "call" "ring a telephone"
+.xx "cat" "catenate and print"
+.xx "cb" "C program beautifier"
+.xx "cc" "C compiler"
+.xx "cd" "change working directory"
+.xx "chmod" "change mode"
+.xx "chown" "change owner or group"
+.xx "clri" "clear i-node"
+.xx "cmp" "compare two files"
+.xx "col" "filter reverse line feeds"
+.xx "comm" "select or reject lines common to two sorted files"
+.xx "cp" "copy"
+.xx "cron" "clock daemon"
+.xx "crypt" "encode/decode"
+.xx "cu" "call UNIX"
+.xx "date" "print and set the date"
+.xx "dc" "desk calculator"
+.xx "dcheck" "file system directory consistency check"
+.xx "dd" "convert and copy a file"
+.xx "deroff" "remove nroff, troff, tbl and eqn constructs"
+.xx "df" "disk free"
+.xx "diff" "differential file comparator"
+.xx "diff3" "3-way differential file comparison"
+.xx "du" "summarize disk usage"
+.xx "dump" "incremental file system dump"
+.xx "dumpdir" "print the names of files on a dump tape"
+.xx "echo" "echo arguments"
+.xx "ed" "text editor"
+.xx "eqn" "typeset mathematics"
+.xx "expr" "evaluate arguments as an expression"
+.xx "f77" "Fortran 77 compiler"
+.xx "file" "determine file type"
+.xx "find" "find files"
+.xx "graph" "draw a graph"
+.xx "grep" "search a file for a pattern"
+.xx "icheck" "file system storage consistency check"
+.xx "iostat" "report I/O statistics"
+.xx "join" "relational database operator"
+.xx "kill" "terminate a process with extreme prejudice"
+.xx "ld" "link editor"
+.xx "learn" "computer aided instruction about UNIX"
+.xx "lex" "generator of lexical analysis programs"
+.xx "lint" "a C program verifier"
+.xx "ln" "make a link"
+.xx "login" "sign on"
+.xx "look" "find lines in a sorted list"
+.xx "lorder" "find ordering relation for an object library"
+.xx "lpr" "line printer spooler"
+.xx "ls" "list contents of directory"
+.xx "m4" "macro processor"
+.xx "mail" "send or receive mail among users"
+.xx "make" "maintain program groups"
+.xx "man" "print sections of this manual"
+.xx "mesg" "permit or deny messages"
+.xx "mkdir" "make a directory"
+.xx "mkfs" "construct a file system"
+.xx "mknod" "build special file"
+.xx "mount" "mount and dismount file system"
+.xx "mv" "move or rename files"
+.xx "ncheck" "generate names from i-numbers"
+.xx "newgrp" "log in to a new group"
+.xx "nice" "run a command at low priority"
+.xx "nm" "print name list"
+.xx "nohup" "run a command immune to hangups"
+.xx "number" "convert Arabic numerals to English"
+.xx "od" "octal dump"
+.xx "passwd" "change login password"
+.xx "plot" "graphics filters"
+.xx "pr" "print file"
+.xx "prof" "display profile data"
+.xx "ps" "process status"
+.xx "pstat" "print system facts"
+.xx "ptx" "permuted index"
+.xx "pwd" "working directory name"
+.xx "quot" "summarize file system ownership"
+.xx "ratfor" "rational Fortran dialect"
+.xx "rc" "Ratfor compiler"
+.xx "refer" "find and insert literature references in documents"
+.xx "restor" "incremental file system restore"
+.xx "rev" "reverse lines of a file"
+.xx "rm" "files"
+.xx "sa" "system accounting"
+.xx "sdb" "C symbolic debugger"
+.xx "sed" "stream editor"
+.xx "sh" "command language"
+.xx "size" "size of an object file"
+.xx "sleep" "suspend execution for an interval"
+.xx "sort" "sort or merge files"
+.xx "spell" "find spelling errors"
+.xx "spline" "interpolate smooth curve"
+.xx "split" "split a file into pieces"
+.xx "strip" "remove symbols and relocation bits"
+.xx "struct" "structure Fortran programs"
+.xx "stty" "set terminal options"
+.xx "su" "substitute user id temporarily"
+.xx "sum" "sum and count blocks in a file"
+.xx "sync" "update the super block"
+.xx "tabs" "set terminal tabs"
+.xx "tail" "deliver the last part of a file"
+.xx "tar" "tape archiver"
+.xx "tbl" "format tables for nroff or troff"
+.xx "tc" "photypesetter simulator"
+.xx "tee" "pipe fitting"
+.xx "test" "condition command"
+.xx "time" "time a command"
+.xx "tk" "paginator for the Tektronix 4014"
+.xx "touch" "update date last modified of a file"
+.xx "tp" "manipulate tape archive"
+.xx "tr" "translate characters"
+.xx "troff" "text formatting and typesetting"
+.xx "true" "provide truth values"
+.xx "tsort" "topological sort"
+.xx "tty" "get terminal name"
+.xx "uniq" "report repeated lines in a file"
+.xx "units" "conversion program"
+.xx "uucp" "unix to unix copy"
+.xx "uudiff" "directory comparison between machines"
+.xx "uulog" "uucp user log inquiry"
+.xx "uux" "unix to unix command execution"
+.xx "wait" "await completion of process"
+.xx "wall" "write to all users"
+.xx "wc" "word count"
+.xx "who" "who is on the system"
+.xx "write" "write to another user"
+.xx "xsend" "secret mail"
+.xx "yacc" "yet another compiler-compiler"
diff --git a/usr/man/man0/toc2 b/usr/man/man0/toc2
new file mode 100644 (file)
index 0000000..725a85e
--- /dev/null
@@ -0,0 +1,44 @@
+.xx "intro" "introduction to system calls and error numbers"
+.xx "access" "determine accessibility of file"
+.xx "acct" "turn accounting on or off"
+.xx "alarm" "schedule signal after specified time"
+.xx "brk" "change core allocation"
+.xx "chdir" "change default directory"
+.xx "chmod" "change mode of file"
+.xx "chown" "change owner and group of a file"
+.xx "close" "close a file"
+.xx "creat" "create a new file"
+.xx "dup" "duplicate an open file descriptor"
+.xx "exec" "execute a file"
+.xx "exit" "terminate process"
+.xx "fork" "spawn new process"
+.xx "getpid" "get process identification"
+.xx "getuid" "get user and group identity"
+.xx "indir" "indirect system call"
+.xx "ioctl" "control device"
+.xx "kill" "send signal to a process"
+.xx "link" "link to a file"
+.xx "lseek" "move read/write pointer"
+.xx "mknod" "make a directory or a special file"
+.xx "mount" "mount or remove file system"
+.xx "mpx" "create and manipulate multiplexed files"
+.xx "nice" "set program priority"
+.xx "open" "open for reading or writing"
+.xx "pause" "stop until signal"
+.xx "pipe" "create an interprocess channel"
+.xx "profil" "execution time profile"
+.xx "ptrace" "process trace"
+.xx "read" "read from file"
+.xx "setuid" "set user and group ID"
+.xx "signal" "catch or ignore signals"
+.xx "stat" "get file status"
+.xx "stime" "set time"
+.xx "stty" "set and retrieve terminal modes"
+.xx "sync" "update super-block"
+.xx "time" "get date and time"
+.xx "times" "get process times"
+.xx "umask" "set file creation mode mask"
+.xx "unlink" "remove directory entry"
+.xx "utime" "set file times"
+.xx "wait" "wait for process to terminate"
+.xx "write" "write on a file"
diff --git a/usr/man/man0/toc3 b/usr/man/man0/toc3
new file mode 100644 (file)
index 0000000..60bfbd3
--- /dev/null
@@ -0,0 +1,56 @@
+.xx "intro" "introduction to library functions"
+.xx "abort" "generate a fault"
+.xx "abs" "integer absolute value"
+.xx "assert" "program verification"
+.xx "atof" "convert ASCII to numbers"
+.xx "crypt" "DES encryption"
+.xx "ctime" "convert date and time to ASCII"
+.xx "ctype" "character classification"
+.xx "dbm" "data base subroutines"
+.xx "ecvt" "output conversion"
+.xx "end" "last locations in program"
+.xx "exp" "exponential, logarithm, power, square root"
+.xx "fclose" "close or flush a stream"
+.xx "ferror" "stream status inquiries"
+.xx "floor" "absolute value, floor, ceiling functions"
+.xx "fopen" "open a stream"
+.xx "fread" "buffered binary input/output"
+.xx "frexp" "split into mantissa and exponent"
+.xx "fseek" "reposition a stream"
+.xx "gamma" "log gamma function"
+.xx "getarg" "command arguments to Fortran"
+.xx "getc" "get character or word from stream"
+.xx "getenv" "value for environment name"
+.xx "getgrent" "get group file entry"
+.xx "getlogin" "get login name"
+.xx "getpass" "read a password"
+.xx "getpw" "get name from UID"
+.xx "getpwent" "get password file entry"
+.xx "gets" "get a string from a stream"
+.xx "hypot" "euclidean distance"
+.xx "j0" "bessel functions"
+.xx "l3tol" "convert between 3-byte integers and long integers"
+.xx "malloc" "main memory allocator"
+.xx "mktemp" "make a unique file name"
+.xx "monitor" "prepare execution profile"
+.xx "nlist" "get entries from name list"
+.xx "perror" "system error messages"
+.xx "plot" "graphics interface"
+.xx "popen" "initiate I/O to/from a process"
+.xx "printf" "formatted output conversion"
+.xx "putc" "put character or word on a stream"
+.xx "puts" "put a string on a stream"
+.xx "qsort" "quicker sort"
+.xx "rand" "random number generator"
+.xx "scanf" "formatted input conversion"
+.xx "setbuf" "assign buffering to a stream"
+.xx "setjmp" "non-local goto"
+.xx "sin" "trigonometric functions"
+.xx "sinh" "hyperbolic functions"
+.xx "sleep" "suspend execution for interval"
+.xx "stdio" "standard buffered input/output package"
+.xx "string" "string operations"
+.xx "swab" "swap bytes"
+.xx "system" "issue a shell command"
+.xx "ttyname" "find name of a terminal"
+.xx "ungetc" "push character back into input stream"
diff --git a/usr/man/man0/toc4 b/usr/man/man0/toc4
new file mode 100644 (file)
index 0000000..10b3cf4
--- /dev/null
@@ -0,0 +1,21 @@
+.xx "cat" "phototypesetter interface"
+.xx "dc" "DC-11 communications interface"
+.xx "dh" "DH-11 communications multiplexer"
+.xx "dn" "DN-11 ACU interface"
+.xx "dp" "DP-11 201 data-phone interface"
+.xx "dz" "DZ-11 communications multiplexer"
+.xx "hp" "RH-11/RP04, RP05, RP06, RM03 moving-head disk"
+.xx "hs" "RH11/RS03-RS04 fixed-head disk file"
+.xx "ht" "RH-11/TE-16 magtape interface"
+.xx "kl" "KL-11 or DL-11 asynchronous interface"
+.xx "lp" "line printer"
+.xx "mem" "main memory"
+.xx "null" "data sink"
+.xx "pc" "PC-11 paper tape reader/punch"
+.xx "rf" "RF11/RS11 fixed-head disk file"
+.xx "rk" "RK-11/RK03 or RK05 disk"
+.xx "rp" "RP-11/RP03 moving-head disk"
+.xx "tc" "TC-11/TU56 DECtape"
+.xx "tm" "TM-11/TU-10 magtape interface"
+.xx "tty" "general terminal interface"
+.xx "vp" "Versatec printer-plotter"
diff --git a/usr/man/man0/toc5 b/usr/man/man0/toc5
new file mode 100644 (file)
index 0000000..653ed67
--- /dev/null
@@ -0,0 +1,18 @@
+.xx "a.out" "assembler and link editor output"
+.xx "acct" "execution accounting file"
+.xx "ar" "file format"
+.xx "core" "format of memory image file"
+.xx "dir" "format of directories"
+.xx "dump" "incremental dump format"
+.xx "environ" "user environment"
+.xx "filsys" "format of file system volume"
+.xx "group" "group file"
+.xx "mpxio" "multiplexed i/o"
+.xx "mtab" "mounted file system table"
+.xx "passwd" "password file"
+.xx "plot" "graphics interface"
+.xx "tp" "DEC/mag tape formats"
+.xx "ttys" "terminal initialization data"
+.xx "types" "primitive system data types"
+.xx "utmp" "login records"
+.xx "wtmp" "user login history"
diff --git a/usr/man/man0/toc6 b/usr/man/man0/toc6
new file mode 100644 (file)
index 0000000..59a5f52
--- /dev/null
@@ -0,0 +1,8 @@
+.xx "arithmetic" "provide drill in number facts"
+.xx "backgammon" "the game"
+.xx "bcd" "convert to antique media"
+.xx "ching" "the book of changes and other cookies"
+.xx "hangman" "guess the word"
+.xx "maze" "generate a maze problem"
+.xx "quiz" "test your knowledge"
+.xx "wump" "the game of hunt-the-wumpus"
diff --git a/usr/man/man0/toc7 b/usr/man/man0/toc7
new file mode 100644 (file)
index 0000000..42b5f2e
--- /dev/null
@@ -0,0 +1,7 @@
+.xx "ascii" "map of ASCII character set"
+.xx "eqnchar" "special character definitions for eqn"
+.xx "greek" "graphics for extended TTY-37 type-box"
+.xx "hier" "file system hierarchy"
+.xx "man" "macros to typeset manual"
+.xx "ms" "macros for formatting manuscripts"
+.xx "term" "conventional names"
diff --git a/usr/man/man0/toc8 b/usr/man/man0/toc8
new file mode 100644 (file)
index 0000000..15646d5
--- /dev/null
@@ -0,0 +1,11 @@
+.xx "bproc" "UNIX/32V startup"
+.xx "crash" "what to do when the system crashes"
+.xx "cron" "clock daemon"
+.xx "fget.demon" "fget daemons"
+.xx "getty" "set terminal mode"
+.xx "init" "process control initialization"
+.xx "lpd" "line printer daemon"
+.xx "makekey" "generate encryption key"
+.xx "sticky" "executable files with persistent text"
+.xx "sysgen" "UNIX/32V system generation from the distribution tape"
+.xx "update" "periodically update the super block"
diff --git a/usr/man/man0/tocx1 b/usr/man/man0/tocx1
new file mode 100644 (file)
index 0000000..e61ab86
--- /dev/null
@@ -0,0 +1,139 @@
+ac(1m) ac: login accounting.
+adb(1) adb: debugger.
+ar(1) ar: archive and library maintainer.
+ar11(1) ar11: PDP-11 compatible archive and library maintainer.
+arcv(1m) arcv: convert archives to new format.
+as(1) as: assembler.
+at(1) at: execute commands at a later time.
+awk(1) awk: pattern scanning and processing language.
+basename(1) basename: strip filename affixes.
+bc(1) bc: arbitrary-precision arithmetic language.
+cal(1) cal: print calendar.
+calendar(1) calendar: reminder service.
+call(1c) call: ring a telephone.
+cat(1) cat: catenate and print.
+cb(1) cb: C program beautifier.
+cc(1) cc: C compiler.
+cd(1) cd: change working directory.
+chmod(1) chmod: change mode.
+chown(1) chown, chgrp: change owner or group.
+clri(1m) clri: clear i-node.
+cmp(1) cmp: compare two files.
+col(1) col: filter reverse line feeds.
+comm(1) comm: select or reject lines common to two sorted files.
+cp(1) cp: copy.
+cron(1m) cron: clock daemon.
+crypt(1) crypt: encode/decode.
+cu(1c) cu: call UNIX.
+date(1) date: print and set the date.
+dc(1) dc: desk calculator.
+dcheck(1m) dcheck: file system directory consistency check.
+dd(1) dd: convert and copy a file.
+deroff(1) deroff: remove nroff, troff, tbl and eqn constructs.
+df(1m) df: disk free.
+diff(1) diff: differential file comparator.
+diff3(1) diff3: 3-way differential file comparison.
+du(1) du: summarize disk usage.
+dump(1m) dump: incremental file system dump.
+dumpdir(1m) dumpdir: print the names of files on a dump tape.
+echo(1) echo: echo arguments.
+ed(1) ed: text editor.
+eqn(1) eqn, neqn, checkeq: typeset mathematics.
+expr(1) expr: evaluate arguments as an expression.
+f77(1) f77: Fortran 77 compiler.
+file(1) file: determine file type.
+find(1) find: find files.
+graph(1g) graph: draw a graph.
+grep(1) grep, egrep, fgrep: search a file for a pattern.
+icheck(1m) icheck: file system storage consistency check.
+intro(1) intro: introduction to commands.
+iostat(1m) iostat: report I/O statistics.
+join(1) join: relational database operator.
+kill(1) kill: terminate a process with extreme prejudice.
+ld(1) ld: link editor.
+learn(1) learn: computer aided instruction about UNIX.
+lex(1) lex: generator of lexical analysis programs.
+lint(1) lint: a C program verifier.
+ln(1) ln: make a link.
+login(1) login: sign on.
+look(1) look: find lines in a sorted list.
+lorder(1) lorder: find ordering relation for an object library.
+lpr(1) lpr, vpr: line printer spooler.
+ls(1) ls: list contents of directory.
+m4(1) m4: macro processor.
+mail(1) mail: send or receive mail among users.
+make(1) make: maintain program groups.
+man(1) man: print sections of this manual.
+mesg(1) mesg: permit or deny messages.
+mkdir(1) mkdir: make a directory.
+mkfs(1m) mkfs: construct a file system.
+mknod(1m) mknod: build special file.
+mount(1m) mount, umount: mount and dismount file system.
+mv(1) mv: move or rename files.
+ncheck(1m) ncheck: generate names from i-numbers.
+newgrp(1) newgrp: log in to a new group.
+nice(1) nice, nohup: run a command at low priority.
+nm(1) nm: print name list.
+nohup(1) nohup: run a command immune to hangups.
+number(1) number: convert Arabic numerals to English.
+od(1) od: octal dump.
+passwd(1) passwd: change login password.
+plot(1g) plot: graphics filters.
+pr(1) pr: print file.
+prof(1) prof: display profile data.
+ps(1) ps: process status.
+pstat(1m) pstat: print system facts.
+ptx(1) ptx: permuted index.
+pwd(1) pwd: working directory name.
+quot(1m) quot: summarize file system ownership.
+ratfor(1) ratfor: rational Fortran dialect.
+rc(1) rc: Ratfor compiler.
+refer(1) refer, lookbib: find and insert literature references in documents.
+restor(1m) restor: incremental file system restore.
+rev(1) rev: reverse lines of a file.
+rm(1) rm, rmdir: remove (unlink) files.
+sa(1m) sa, accton: system accounting.
+sdb(1) sdb: C symbolic debugger.
+sed(1) sed: stream editor.
+sh(1) sh, for, case, if, while, \fB:\fP, \fB.\fP, break, continue, cd, eval, exec, exit, export, login, newgrp, read, readonly, set, shift, times, trap, umask, wait: command language.
+size(1) size: size of an object file.
+sleep(1) sleep: suspend execution for an interval.
+sort(1) sort: sort or merge files.
+spell(1) spell, spellin, spellout: find spelling errors.
+spline(1g) spline: interpolate smooth curve.
+split(1) split: split a file into pieces.
+strip(1) strip: remove symbols and relocation bits.
+struct(1) struct: structure Fortran programs.
+stty(1) stty: set terminal options.
+su(1) su: substitute user id temporarily.
+sum(1) sum: sum and count blocks in a file.
+sync(1m) sync: update the super block.
+tabs(1) tabs: set terminal tabs.
+tail(1) tail: deliver the last part of a file.
+tar(1) tar: tape archiver.
+tbl(1) tbl: format tables for nroff or troff.
+tc(1) tc: photypesetter simulator.
+tee(1) tee: pipe fitting.
+test(1) test: condition command.
+time(1) time: time a command.
+tk(1) tk: paginator for the Tektronix 4014.
+touch(1) touch: update date last modified of a file.
+tp(1) tp: manipulate tape archive.
+tr(1) tr: translate characters.
+troff(1) troff, nroff: text formatting and typesetting.
+true(1) true, false: provide truth values.
+tsort(1) tsort: topological sort.
+tty(1) tty: get terminal name.
+uniq(1) uniq: report repeated lines in a file.
+units(1) units: conversion program.
+uucp(1c) uucp, uulog: unix to unix copy.
+uudiff(1c) uudiff: directory comparison between machines.
+uulog(1c) uulog: uucp user log inquiry.
+uux(1c) uux: unix to unix command execution.
+wait(1) wait: await completion of process.
+wall(1m) wall: write to all users.
+wc(1) wc: word count.
+who(1) who: who is on the system.
+write(1) write: write to another user.
+xsend(1) xsend, xget, enroll: secret mail.
+yacc(1) yacc: yet another compiler-compiler.
diff --git a/usr/man/man0/tocx2 b/usr/man/man0/tocx2
new file mode 100644 (file)
index 0000000..80c1b14
--- /dev/null
@@ -0,0 +1,44 @@
+access(2) access: determine accessibility of file.
+acct(2) acct: turn accounting on or off.
+alarm(2) alarm: schedule signal after specified time.
+brk(2) brk, sbrk, break: change core allocation.
+chdir(2) chdir: change default directory.
+chmod(2) chmod: change mode of file.
+chown(2) chown: change owner and group of a file.
+close(2) close: close a file.
+creat(2) creat: create a new file.
+dup(2) dup, dup2: duplicate an open file descriptor.
+exec(2) execl, execv, execle, execve, execlp, execvp, exec, exece, environ: execute a file.
+exit(2) exit: terminate process.
+fork(2) fork: spawn new process.
+getpid(2) getpid: get process identification.
+getuid(2) getuid, getgid, geteuid, getegid: get user and group identity.
+indir(2) indir, syscall: indirect system call.
+intro(2) intro, errno: introduction to system calls and error numbers.
+ioctl(2) ioctl, stty, gtty: control device.
+kill(2) kill: send signal to a process.
+link(2) link: link to a file.
+lseek(2) lseek, tell: move read/write pointer.
+mknod(2) mknod: make a directory or a special file.
+mount(2) mount, umount: mount or remove file system.
+mpx(2) mpx: create and manipulate multiplexed files.
+nice(2) nice: set program priority.
+open(2) open: open for reading or writing.
+pause(2) pause: stop until signal.
+pipe(2) pipe: create an interprocess channel.
+profil(2) profil: execution time profile.
+ptrace(2) ptrace: process trace.
+read(2) read: read from file.
+setuid(2) setuid, setgid: set user and group ID.
+signal(2) signal: catch or ignore signals.
+stat(2) stat, fstat: get file status.
+stime(2) stime: set time.
+stty(2) stty, gtty: set and retrieve terminal modes.
+sync(2) sync: update super-block.
+time(2) time, ftime: get date and time.
+times(2) times: get process times.
+umask(2) umask: set file creation mode mask.
+unlink(2) unlink: remove directory entry.
+utime(2) utime: set file times.
+wait(2) wait: wait for process to terminate.
+write(2) write: write on a file.
diff --git a/usr/man/man0/tocx3 b/usr/man/man0/tocx3
new file mode 100644 (file)
index 0000000..4245496
--- /dev/null
@@ -0,0 +1,56 @@
+abort(3) abort: generate a fault.
+abs(3) abs: integer absolute value.
+assert(3x) assert: program verification.
+atof(3) atof, atoi, atol: convert ASCII to numbers.
+crypt(3) crypt, setkey, encrypt: DES encryption.
+ctime(3) ctime, localtime, gmtime, asctime, timezone: convert date and time to ASCII.
+ctype(3) isalpha, isupper, islower, isdigit, isalnum, isspace, ispunct, isprint, iscntrl, isascii: character classification.
+dbm(3x) dbminit, fetch, store, delete, firstkey, nextkey: data base subroutines.
+ecvt(3) ecvt, fcvt, gcvt: output conversion.
+end(3) end, etext, edata: last locations in program.
+exp(3m) exp, log, log10, pow, sqrt: exponential, logarithm, power, square root.
+fclose(3s) fclose, fflush: close or flush a stream.
+ferror(3s) feof, ferror, clearerr, fileno: stream status inquiries.
+floor(3m) fabs, floor, ceil: absolute value, floor, ceiling functions.
+fopen(3s) fopen, freopen, fdopen: open a stream.
+fread(3s) fread, fwrite: buffered binary input/output.
+frexp(3) frexp, ldexp, modf: split into mantissa and exponent.
+fseek(3s) fseek, ftell, rewind: reposition a stream.
+gamma(3m) gamma: log gamma function.
+getarg(3f) getarg, iargc: command arguments to Fortran.
+getc(3s) getc, getchar, fgetc, getw: get character or word from stream.
+getenv(3) getenv: value for environment name.
+getgrent(3) getgrent, getgrgid, getgrnam, setgrent, endgrent: get group file entry.
+getlogin(3) getlogin: get login name.
+getpass(3) getpass: read a password.
+getpw(3) getpw: get name from UID.
+getpwent(3) getpwent, getpwuid, getpwnam, setpwent, endpwent: get password file entry.
+gets(3s) gets, fgets: get a string from a stream.
+hypot(3m) hypot, cabs: euclidean distance.
+intro(3) intro: introduction to library functions.
+j0(3m) j0, j1, jn, y0, y1, yn: bessel functions.
+l3tol(3) l3tol, ltol3: convert between 3-byte integers and long integers.
+malloc(3) malloc, free, realloc, calloc: main memory allocator.
+mktemp(3) mktemp: make a unique file name.
+monitor(3) monitor: prepare execution profile.
+nlist(3) nlist: get entries from name list.
+perror(3) perror, sys_errlist, sys_nerr: system error messages.
+plot(3x) plot: openpl et al.: graphics interface.
+popen(3s) popen, pclose: initiate I/O to/from a process.
+printf(3s) printf, fprintf, sprintf: formatted output conversion.
+putc(3s) putc, putchar, fputc, putw: put character or word on a stream.
+puts(3s) puts, fputs: put a string on a stream.
+qsort(3) qsort: quicker sort.
+rand(3) rand, srand: random number generator.
+scanf(3s) scanf, fscanf, sscanf: formatted input conversion.
+setbuf(3s) setbuf: assign buffering to a stream.
+setjmp(3) setjmp, longjmp: non-local goto.
+sin(3m) sin, cos, tan, asin, acos, atan, atan2: trigonometric functions.
+sinh(3m) sinh, cosh, tanh: hyperbolic functions.
+sleep(3) sleep: suspend execution for interval.
+stdio(3s) stdio: standard buffered input/output package.
+string(3) strcat, strcatn, strcmp, strcmpn, strcpy, strcpyn, strlen, index, rindex: string operations.
+swab(3) swab: swap bytes.
+system(3) system: issue a shell command.
+ttyname(3) ttyname, isatty, ttyslot: find name of a terminal.
+ungetc(3s) ungetc: push character back into input stream.
diff --git a/usr/man/man0/tocx4 b/usr/man/man0/tocx4
new file mode 100644 (file)
index 0000000..eed3094
--- /dev/null
@@ -0,0 +1,21 @@
+cat(4) cat: phototypesetter interface.
+dc(4) dc: DC-11 communications interface.
+dh(4) dh: DH-11 communications multiplexer.
+dn(4) dn: DN-11 ACU interface.
+dp(4) dp: DP-11 201 data-phone interface.
+dz(4) dz: DZ-11 communications multiplexer.
+hp(4) hp: RH-11/RP04, RP05, RP06, RM03 moving-head disk.
+hs(4) hs: RH11/RS03-RS04 fixed-head disk file.
+ht(4) ht: RH-11/TE-16 magtape interface.
+kl(4) kl: KL-11 or DL-11 asynchronous interface.
+lp(4) lp: line printer.
+mem(4) mem, kmem: main memory.
+null(4) null: data sink.
+pc(4) pc: PC-11 paper tape reader/punch.
+rf(4) rf: RF11/RS11 fixed-head disk file.
+rk(4) rk: RK-11/RK03 or RK05 disk.
+rp(4) rp: RP-11/RP03 moving-head disk.
+tc(4) tc: TC-11/TU56 DECtape.
+tm(4) tm: TM-11/TU-10 magtape interface.
+tty(4) tty: general terminal interface.
+vp(4) vp: Versatec printer-plotter.
diff --git a/usr/man/man0/tocx5 b/usr/man/man0/tocx5
new file mode 100644 (file)
index 0000000..1b106cf
--- /dev/null
@@ -0,0 +1,18 @@
+a.out(5) a.out: assembler and link editor output.
+acct(5) acct: execution accounting file.
+ar(5) ar: archive (library) file format.
+core(5) core: format of memory image file.
+dir(5) dir: format of directories.
+dump(5) dump, ddate: incremental dump format.
+environ(5) environ: user environment.
+filsys(5) filsys, flblk, ino: format of file system volume.
+group(5) group: group file.
+mpxio(5) mpxio: multiplexed i/o.
+mtab(5) mtab: mounted file system table.
+passwd(5) passwd: password file.
+plot(5) plot: graphics interface.
+tp(5) tp: DEC/mag tape formats.
+ttys(5) ttys: terminal initialization data.
+types(5) types: primitive system data types.
+utmp(5) utmp, wtmp: login records.
+wtmp(5) wtmp: user login history.
diff --git a/usr/man/man0/tocx6 b/usr/man/man0/tocx6
new file mode 100644 (file)
index 0000000..5b4c862
--- /dev/null
@@ -0,0 +1,8 @@
+arithmetic(6) arithmetic: provide drill in number facts.
+backgammon(6) backgammon: the game.
+bcd(6) bcd: convert to antique media.
+ching(6) ching, fortune: the book of changes and other cookies.
+hangman(6) hangman: guess the word.
+maze(6) maze: generate a maze problem.
+quiz(6) quiz: test your knowledge.
+wump(6) wump: the game of hunt-the-wumpus.
diff --git a/usr/man/man0/tocx7 b/usr/man/man0/tocx7
new file mode 100644 (file)
index 0000000..56c07fb
--- /dev/null
@@ -0,0 +1,7 @@
+ascii(7) ascii: map of ASCII character set.
+eqnchar(7) eqnchar: special character definitions for eqn.
+greek(7) greek: graphics for extended TTY-37 type-box.
+hier(7) hier: file system hierarchy.
+man(7) man: macros to typeset manual.
+ms(7) ms: macros for formatting manuscripts.
+term(7) terminals: conventional names.
diff --git a/usr/man/man0/tocx8 b/usr/man/man0/tocx8
new file mode 100644 (file)
index 0000000..8f6f643
--- /dev/null
@@ -0,0 +1,11 @@
+bproc(8) boot procedures: UNIX/32V startup.
+crash(8) crash: what to do when the system crashes.
+cron(8) cron: clock daemon.
+fget.demon(8) fget.demon, fget.odemon: fget daemons.
+getty(8) getty: set terminal mode.
+init(8) init: process control initialization.
+lpd(8) lpd: line printer daemon.
+makekey(8) makekey: generate encryption key.
+sticky(8) sticky: executable files with persistent text.
+sysgen(8) sysgen: UNIX/32V system generation from the distribution tape.
+update(8) update: periodically update the super block.
diff --git a/usr/man/man0/vaxpref b/usr/man/man0/vaxpref
new file mode 100644 (file)
index 0000000..fdea740
--- /dev/null
@@ -0,0 +1,70 @@
+.TL
+PREFACE
+.LP
+The
+.UX \s-2/32V\s0
+operating system for the VAX*-11
+.FS
+*VAX and PDP are Trademarks of Digital Equipment Corporation.
+.FE
+provides substantially the same facilities as the
+\s-2UNIX\s0
+system for the PDP*-11.
+.LP
+We acknowledge the work of many who came before us, and particularly thank
+G. K. Swanson, W. M. Cardoza, D. K. Sharma, and J. F. Jarvis for assistance
+with the implementation for the VAX-11/780.
+.sp 2
+.in 4i
+T. B. London
+.br
+J. F. Reiser
+.in 0
+.sp 4
+.ce
+\fIPreface to the Seventh Edition\fP
+.sp 2
+.LP
+Although this Seventh Edition no longer bears their byline,
+Ken Thompson and Dennis Ritchie remain the fathers
+and preceptors of the
+\s-2UNIX\s0
+time-sharing system.
+Many of the improvements here described bear their mark.
+Among many, many other people who have contributed to
+the further flowering of
+\s-2UNIX\s0,
+we wish especially to
+acknowledge the contributions of
+A. V. Aho,
+S. R. Bourne,
+L. L. Cherry,
+G. L. Chesson,
+S. I. Feldman,
+C. B. Haley,
+R. C. Haight,
+S. C. Johnson,
+M. E. Lesk,
+T. L. Lyon,
+L. E. McMahon,
+R. Morris,
+R. Muha,
+D. A. Nowitz,
+L. Wehr,
+and
+P. J. Weinberger.
+We appreciate also 
+the effective advice and criticism of
+T. A. Dolotta,
+A. G. Fraser,
+J. F. Maranzano,
+and
+J. R. Mashey;
+and we remember the important work of
+the late Joseph F. Ossanna.
+.sp 2
+.in 4i
+B. W. Kernighan
+.br
+M. D. McIlroy
+.in 0
index 6e032c3..40a7a30 100644 (file)
@@ -1,15 +1,15 @@
+.TH ADB 1 "UNIX/32V"
+.SH NAME
+adb \- debugger
+.SH SYNOPSIS
+.B adb
+[\fB\-w\fR] [ objfil [ corfil ] ]
 .ds TW \v'.25m'\s+2~\s-2\v'-.25m'
 .ds ST \v'.25m'*\v'-.25m'
 .ds IM \v'.1m'=\v'-.1m'\s-2\h'-.1m'>\h'.1m'\s+2
 .ds LE \(<=
 .ds LT \s-2<\s+2
 .ds GT \s-2>\s+2
 .ds TW \v'.25m'\s+2~\s-2\v'-.25m'
 .ds ST \v'.25m'*\v'-.25m'
 .ds IM \v'.1m'=\v'-.1m'\s-2\h'-.1m'>\h'.1m'\s+2
 .ds LE \(<=
 .ds LT \s-2<\s+2
 .ds GT \s-2>\s+2
-.TH ADB 1 
-.SH NAME
-adb \- debugger
-.SH SYNOPSIS
-.B adb
-[\fB\-w\fR] [ objfil [ corfil ] ]
 .SH DESCRIPTION
 .I Adb
 is a general purpose debugging program.
 .SH DESCRIPTION
 .I Adb
 is a general purpose debugging program.
@@ -119,12 +119,17 @@ The last
 typed.
 .TP 7.2n
 .I integer
 typed.
 .TP 7.2n
 .I integer
-An octal number if
-.I integer
-begins with a 0;
-a hexadecimal number if preceded by
-.BR # ;
-otherwise a decimal number.
+A number.  The prefixes 0o and 0O (``zero oh'') force interpretation
+in octal radix; the prefixes 0t and 0T force interpretation in
+decimal radix; the prefixes 0x and 0X force interpretation in
+hexadecimal radix.  Thus 0o20 = 0t16 = 0x10 = sixteen.
+If no prefix appears, then the
+.I default\ radix
+is used; see the $d command.  The default radix is initially hexadecimal.
+The hexadecimal digits are 0123456789abcdefABCDEF with the obvious
+values.  Note that a hexadecimal number whose most significant
+digit would otherwise be an alphabetic character must have a 0x
+(or 0X) prefix (or a leading zero if the default radix is hexadecimal).
 .TP 7.2n
 .IB integer . fraction
 A 32 bit floating point number.
 .TP 7.2n
 .IB integer . fraction
 A 32 bit floating point number.
@@ -149,7 +154,7 @@ the value of the register is obtained from
 the system header in
 .IR corfil .
 The register names are
 the system header in
 .IR corfil .
 The register names are
-.BR "r0 ... r5 sp pc ps" "."
+those printed by the $r command.
 .TP 7.2n
 .I symbol
 A
 .TP 7.2n
 .I symbol
 A
@@ -259,6 +264,8 @@ in
 .I  objfil
 are printed according to the format
 .IR f .
 .I  objfil
 are printed according to the format
 .IR f .
+.I dot
+is incremented by the sum of the increments for each format letter (q.v.).
 .TP
 .RI / f
 Locations starting at
 .TP
 .RI / f
 Locations starting at
@@ -266,7 +273,10 @@ Locations starting at
 in
 .I  corfil
 are printed according to the format
 in
 .I  corfil
 are printed according to the format
-.IR f .
+.I f
+and
+.I dot
+is incremented as for `?'.
 .TP
 .RI  = f
 The value of
 .TP
 .RI  = f
 The value of
@@ -287,7 +297,7 @@ Each format character may be preceded by a decimal integer
 that is a repeat count for the format character.
 While stepping through a format
 .I dot
 that is a repeat count for the format character.
 While stepping through a format
 .I dot
-is incremented temporarily
+is incremented
 by the amount given for each format letter.
 If no format is given then the last format is used.
 The format letters available are as follows.
 by the amount given for each format letter.
 If no format is given then the last format is used.
 The format letters available are as follows.
@@ -327,6 +337,16 @@ Print long decimal.
 .br
 .ns
 .TP
 .br
 .ns
 .TP
+.BR r " 2"
+Print in default radix.
+.br
+.ns
+.TP
+.BR R " 4"
+Print long default radix.
+.br
+.ns
+.TP
 .BR x "        2"
 Print 2 bytes in hexadecimal.
 .br
 .BR x "        2"
 Print 2 bytes in hexadecimal.
 .br
@@ -474,9 +494,6 @@ Nothing is printed.
 .RE
 .TP
 newline
 .RE
 .TP
 newline
-If the previous command temporarily incremented
-.IR dot ,
-make the increment permanent.
 Repeat the previous command with a
 .I count
 of 1.
 Repeat the previous command with a
 .I count
 of 1.
@@ -569,16 +586,6 @@ is set to \fBpc\fR.
 .br
 .ns
 .TP
 .br
 .ns
 .TP
-.B f
-Print the floating registers in
-single or double length.
-If the floating point status of
-.B ps
-is set to double (0200 bit)
-then double length is used anyway.
-.br
-.ns
-.TP
 .B b
 Print all breakpoints
 and their associated counts and commands.
 .B b
 Print all breakpoints
 and their associated counts and commands.
@@ -619,6 +626,18 @@ frames are printed.
 .br
 .ns
 .TP
 .br
 .ns
 .TP
+.B d
+Set the default radix to
+.I address
+and report the new value.
+Note that
+.I address
+is interpreted in the (old) current radix.
+Thus ``10$d'' never changes the default radix.
+To make decimal the default radix, use ``0t10$d''.
+.br
+.ns
+.TP
 .B e
 The names and values of
 external variables are printed.
 .B e
 The names and values of
 external variables are printed.
diff --git a/usr/man/man1/ar11.1 b/usr/man/man1/ar11.1
new file mode 100644 (file)
index 0000000..6ac283a
--- /dev/null
@@ -0,0 +1,134 @@
+.TH AR11 1 "UNIX/32V"
+.SH NAME
+ar11 \- PDP-11 compatible archive and library maintainer
+.SH SYNOPSIS
+.B ar
+key [ posname ] afile name ...
+.SH DESCRIPTION
+.I Ar
+maintains groups of files
+combined into a single archive file.
+Unlike ar, these archive files may also be manipulated by
+.I ar
+on the PDP-11.
+Its main use
+is to create and update library files as used by the loader.
+It can be used, though, for any similar purpose.
+.PP
+.I Key
+is one character from the set
+.B drqtpmx,
+optionally concatenated with
+one or more of
+.B vuaibcl.
+.I Afile
+is the archive file.
+The
+.I names
+are constituent files in the archive file.
+The meanings of the
+.I key
+characters are:
+.TP
+.B d
+Delete the named files from the archive file.
+.TP
+.B r
+Replace the named files in the archive file.
+If the optional character
+.B u
+is used with
+.B r,
+then only those files with
+modified dates later than
+the archive files are replaced.
+If an optional positioning character from the set
+.B abi
+is used, then the
+.I posname
+argument must be present
+and specifies that new files are to be placed
+after
+.RB ( a )
+or before
+.RB ( b
+or
+.BR i )
+.IR posname .
+Otherwise
+new files are placed at the end.
+.TP
+.B q
+Quickly append the named files to the end of the archive file.
+Optional positioning characters are invalid.
+The command does not check whether the added members
+are already in the archive.
+Useful only to avoid quadratic behavior when creating a large
+archive piece-by-piece.
+.TP
+.B t
+Print a table of contents of the archive file.
+If no names are given, all files in the archive are tabled.
+If names are given, only those files are tabled.
+.TP
+.B p
+Print the named files in the archive.
+.TP
+.B m
+Move the named files to the end of the archive.
+If a positioning character is present,
+then the
+.I posname
+argument must be present and,
+as in
+.B r,
+specifies where the files are to be moved.
+.TP
+.B x
+Extract the named files.
+If no names are given, all files in the archive are
+extracted.
+In neither case does
+.B x
+alter the archive file.
+.TP
+.B v
+Verbose.
+Under the verbose option,
+.I ar
+gives a file-by-file
+description of the making of a
+new archive file from the old archive and the constituent files.
+When used with
+.B t,
+it gives a long listing of all information about the files.
+When used with
+.pR B ,
+it precedes each file with a name.
+.TP
+.B c
+Create.
+Normally
+.I ar
+will create
+.I afile
+when it needs to.
+The create option suppresses the
+normal message that is produced when
+.I afile
+is created.
+.TP
+.B l
+Local.
+Normally
+.I ar
+places its temporary files in the directory /tmp.
+This option causes them to be placed in the local directory.
+.SH FILES
+/tmp/v*        temporaries
+.SH "SEE ALSO"
+ld(1), ar(5),
+lorder(1)
+.SH BUGS
+If the same file is mentioned twice in an argument list,
+it may be put in the archive twice.
index 33e68dd..3030716 100644 (file)
@@ -1,21 +1,24 @@
-.TH AS 1  PDP11
+.TH AS 1 "UNIX/32V"
 .SH NAME
 as \- assembler
 .SH SYNOPSIS
 .B as
 [
 .SH NAME
 as \- assembler
 .SH SYNOPSIS
 .B as
 [
-.B \-
+.B \-d124
 ] [
 .B \-o
 ] [
 .B \-o
-objfile
-] file ...
+objfile ] [ file ]
 .SH DESCRIPTION
 .I As
 .SH DESCRIPTION
 .I As
-assembles the concatenation of the named files.
-If the optional first argument
-.B \-
-is used,
-all undefined symbols in the assembly
+assembles the named file, or the standard input if no file is specified.
+The optional argument
+.B \-d
+may be used to specify the number of bytes to be assembled for offsets
+which involve forward or external references.  The default is four bytes,
+i.e.,
+.B \-d4
+\&.
+All undefined symbols in the assembly
 are treated as global.
 .PP
 The output of the assembly is left on the file
 are treated as global.
 .PP
 The output of the assembly is left on the file
@@ -23,13 +26,11 @@ The output of the assembly is left on the file
 if that is omitted,
 .B a.out
 is used.
 if that is omitted,
 .B a.out
 is used.
-It is executable if no errors occurred
-during the assembly,
-and if there were no unresolved external references.
 .SH FILES
 .SH FILES
-/lib/as2       pass 2 of the assembler
+.ta \w'/tmp/a[ab][a\-h]t\(**\ \ 'u
+/tmp/as\(**    temporary
 .br
 .br
-/tmp/atm[1-3]? temporary
+/tmp/a[ab][a\-h]t\(**  temporary
 .br
 a.out          object
 .SH "SEE ALSO"
 .br
 a.out          object
 .SH "SEE ALSO"
@@ -37,56 +38,8 @@ ld(1),
 nm(1),
 adb(1),
 a.out(5)
 nm(1),
 adb(1),
 a.out(5)
-.br
-.I "UNIX Assembler Manual"
-by D. M. Ritchie
 .SH DIAGNOSTICS
 .SH DIAGNOSTICS
-When
-an input file cannot be read, its name
-followed by a question mark is typed and assembly
-ceases.
-When syntactic or semantic errors occur, a single-character diagnostic is typed out
-together with the line number and the file name in which it
-occurred.
-Errors in pass 1 cause cancellation of pass 2.
-The possible errors are:
-.PP
-.ta 3
-)      Parentheses error
-.br
-]      Parentheses error
-.br
-<      String not terminated properly
-.br
-*      Indirection used illegally
-.br
-.li
-\fB.\fR        Illegal assignment to `\fB.\fR'
-.br
-a      Error in address
-.br
-b      Branch instruction is odd or too remote
-.br
-e      Error in expression
-.br
-f      Error in local (`f' or `b') type symbol
-.br
-g      Garbage (unknown) character
-.br
-i      End of file inside an if
-.br
-m      Multiply defined symbol as label
-.br
-o      Word quantity assembled at odd address
-.br
-p      `\fB.\fR' different in pass 1 and 2
-.br
-r      Relocation error
-.br
-u      Undefined symbol
-.br
-x      Syntax error
-.br
+Error messages are intended to be self explanatory.
 .SH BUGS
 Syntax errors can cause incorrect line numbers
 in following diagnostics.
 .SH BUGS
 Syntax errors can cause incorrect line numbers
 in following diagnostics.
index 229068a..ee4b40f 100644 (file)
@@ -54,7 +54,7 @@ programs are executed by periodic execution
 of the command
 .I /usr/lib/atrun
 from
 of the command
 .I /usr/lib/atrun
 from
-.IR cron (8).
+.IR cron (1).
 The granularity of
 .I at
 depends upon how often
 The granularity of
 .I at
 depends upon how often
@@ -86,7 +86,7 @@ are due
 pwd(1)
 .SH "SEE ALSO"
 calendar(1),
 pwd(1)
 .SH "SEE ALSO"
 calendar(1),
-cron(8)
+cron(1)
 .SH DIAGNOSTICS
 Complains about various syntax errors and times out of range.
 .SH BUGS
 .SH DIAGNOSTICS
 Complains about various syntax errors and times out of range.
 .SH BUGS
diff --git a/usr/man/man1/bas.1 b/usr/man/man1/bas.1
deleted file mode 100644 (file)
index b397990..0000000
+++ /dev/null
@@ -1,374 +0,0 @@
-.TH BAS 1 
-.SH NAME
-bas \- basic
-.SH SYNOPSIS
-.B bas
-[ file ]
-.SH DESCRIPTION
-.I Bas
-is a dialect of Basic.
-If a file argument is provided,
-the file is used for input before the terminal
-is read.
-.I Bas
-accepts lines of the form:
-.PP
-   statement
-   integer statement
-.PP
-Integer numbered statements
-(known as internal statements)
-are stored for later execution.
-They are stored in sorted ascending order.
-Non-numbered statements are immediately executed.
-The result of an immediate expression statement
-(that does not have `=' as its highest operator) is printed.
-Interrupts suspend computation.
-.PP
-Statements have the following syntax:
-.HP 5
-expression
-.br
-The expression is executed for its side
-effects (assignment or function call)
-or for printing as described above.
-.HP 5
-.B comment
-.li
-...
-.br
-This statement is ignored.
-It is used to interject commentary in a program.
-.HP 5
-.B done
-.br
-Return to system level.
-.HP 5
-.B dump
-.br
-The name and current value of every
-variable is printed.
-.HP 5
-.B edit
-.br
-The UNIX editor,
-.I ed,
-is invoked with the
-.I file
-argument.
-After the editor exits,
-this file is recompiled.
-.HP 5
-.B for
-name
-.B =
-expression expression statement
-.br
-.br
-.ns
-.HP 5
-.B for
-name
-.B =
-expression expression
-.br
-.li
-...
-.br
-.ns
-.HP 5
-.B next
-.br
-The
-.I for
-statement
-repetitively executes a
-statement (first form)
-or a group of statements (second form)
-under control of a named variable.
-The variable takes on the value of
-the first expression,
-then is incremented by one on each loop,
-not to exceed the value of
-the second expression.
-.HP 5
-.B goto
-expression
-.br
-The expression is evaluated, truncated to an integer
-and execution goes to the corresponding integer numbered statment.
-If executed from immediate mode,
-the internal statements are compiled first.
-.HP 5
-.B if
-expression statement
-.br
-.br
-.ns
-.HP 5
-.B if
-expression
-.br
-.li
-...
-.br
-.ns
-.HP 5
-[
-.B else
-.br
-.li
-... ]
-.br
-.ns
-.HP 5
-.B fi
-.br
-The statement (first form)
-or group of statements (second form)
-is executed if the expression evaluates
-to non-zero.
-In the second form,
-an optional
-.B else
-allows for a group of statements to be
-executed when the first group is not.
-.HP 5
-.B list
-[expression [expression]]
-.br
-.br list
-is used to print out the stored internal statements.
-If no arguments are given, all internal statements are printed.
-If one argument is given, only that
-internal statement is listed.
-If two arguments are given, all internal statements
-inclusively between the arguments are printed.
-.HP 5
-.B print
-list
-.br
-The list of expressions and strings are concatenated and
-printed.
-(A string is delimited by " characters.)
-.HP 5
-.B prompt
-list
-.br
-.I Prompt 
-is the same as
-.I print
-except that no newline character is
-printed.
-.HP 5
-.B return
-[expression]
-.br
-The expression is evaluated and the result is passed
-back as the value of a function call.
-If no expression is given, zero is returned.
-.HP 5
-.B run
-.br
-The internal statements are compiled.
-The symbol table is re-initialized.
-The random number generator is reset.
-Control is passed to the lowest numbered internal
-statement.
-.HP 5
-.B save
-[expression [expression]]
-.br
-.I Save
-is like
-.I list
-except that the output
-is written on the
-.I file
-argument.
-If no argument is given on the command,
-.B b.out
-is used.
-.PP
-Expressions have the following syntax:
-.HP 5
-name
-.br
-A name is used to specify a variable.
-Names are composed of a letter
-followed by letters and digits.
-The first four characters of a name are significant.
-.HP 5
-number
-.br
-A number is used to represent a constant value.
-A number is written in Fortran style,
-and contains digits, an optional decimal point,
-and possibly a scale factor consisting
-of an
-.B e
-followed by a possibly signed exponent.
-.HP 5
-.B (
-expression
-.B )
-.br
-Parentheses are used to alter normal order of evaluation.
-.HP 5
-_ expression
-.br
-The result is the negation of the expression.
-.HP 5
-expression operator expression
-.br
-Common functions of two arguments are abbreviated
-by the two arguments separated by an operator denoting the function.
-A complete list of operators is given below.
-.HP 5
-expression
-.B (
-[expression [
-.B ,
-expression] ... ]
-.B )
-.br
-Functions of an arbitrary number of arguments
-can be called by an expression followed by the arguments
-in parentheses separated by commas.
-The expression evaluates to the
-line number of the entry of the function in the
-internally stored statements.
-This causes the internal statements to be compiled.
-If the expression evaluates negative,
-a builtin function is called.
-The list of builtin functions appears below.
-.HP 5
-name
-.B [
-expression
-[
-.B ,
-expression
-] ...
-.B ]
-.br
-Each expression is truncated to an integer
-and used as a specifier for the name.
-The result is syntactically identical to a name.
-.B a[1,2]
-is the same as
-.B a[1][2].
-The truncated expressions are restricted to 
-values between 0 and 32767.
-.PP
-The following is the list of operators:
-.TP
-=
-=
-is the assignment operator.
-The left operand must be a name or an array element.
-The result is the right operand.
-Assignment binds right to left,
-.TP
-&  |
-&
-(logical and)
-has result zero if either of its arguments are zero.
-It has result one if both its arguments are non-zero.
-|
-(logical or)
-has result zero if both of its arguments are zero.
-It has result one if either of its arguments are non-zero.
-.TP
-<  <=  >  >=  ==  <>
-The relational operators
-(< less than, <= less than or equal,
-> greater than,
->= greater than or equal,
-== equal to,
-<> not equal to)
-return one if their arguments are in the specified
-relation.
-They return zero otherwise.
-Relational operators at the same level extend as follows:
-a>b>c is the same as a>b&b>c.
-.TP
-+ \-
-Add and subtract.
-.TP
-* /
-Multiply and divide.
-.TP
-^
-Exponentiation.
-.PP
-The following is a list of builtin functions:
-.TP 7
-.B arg(i)
-is the value of the
-.IR i " -th"
-actual parameter on the current level
-of function call.
-.TP 7
-.B exp(x)
-is the exponential function of
-.IR x .
-.TP 7
-.B log(x)
-is the natural logarithm of
-.IR x .
-.TP 7
-.B sqr(x)
-is the square root of
-.IR x .
-.TP 7
-.B sin(x)
-is the sine of
-.IR x ""
-(radians).
-.TP 7
-.B cos(x)
-is the cosine of
-.IR x ""
-(radians).
-.TP 7
-.B atn(x)
-is the arctangent of
-.IR x .
-Its value
-is between \-\(*p/2 and \(*p/2.
-.TP 7
-.B "rnd( )"
-is a uniformly distributed random
-number between zero and one.
-.TP 7
-.B "expr( )"
-is the only form of program input.
-A line is read from the input and
-evaluated as an expression.
-The resultant value is returned.
-.TP 7
-.B abs(x)
-is the absolute value of
-.IR x .
-.TP 7
-.B int(x)
-returns
-.I x
-truncated (towards 0) to an integer.
-.SH FILES
-/tmp/btm?      temporary
-.br
-b.out          save file
-.br
-/bin/ed        for
-.B edit
-.SH DIAGNOSTICS
-Syntax
-errors cause the incorrect line to be typed
-with an underscore where the parse failed.
-All other diagnostics are self explanatory.
-.SH BUGS
-Has been known to give core images.
-.br
-Catches interrupts even when they are turned off.
index 79444b1..98530de 100644 (file)
@@ -22,7 +22,7 @@ who has a file `calendar' in his login directory
 and sends him any positive results by
 .IR mail (1).
 Normally this is done daily in the wee hours under control of
 and sends him any positive results by
 .IR mail (1).
 Normally this is done daily in the wee hours under control of
-.IR cron (8).
+.IR cron (1).
 .SH FILES
 calendar
 .br
 .SH FILES
 calendar
 .br
@@ -34,7 +34,7 @@ calendar
 .br
 egrep, sed, mail subprocesses
 .SH "SEE ALSO"
 .br
 egrep, sed, mail subprocesses
 .SH "SEE ALSO"
-at(1), cron(8), mail(1)
+at(1), cron(1), mail(1)
 .SH BUGS
 Your calendar must be public information for you
 to get reminder service.
 .SH BUGS
 Your calendar must be public information for you
 to get reminder service.
diff --git a/usr/man/man1/call.1c b/usr/man/man1/call.1c
new file mode 100644 (file)
index 0000000..9f4ae99
--- /dev/null
@@ -0,0 +1,19 @@
+.TH CALL 1C 
+.SH NAME
+call \- ring a telephone
+.SH SYNOPSIS
+.B call
+phonenumber
+.SH DESCRIPTION
+.I Call
+places an outgoing call to the specified
+.IR phonenumber .
+Nothing special happens when the called party answers.
+.I Phonenumber
+may have any number of digits;
+a `+' sign may be used to specify a point at
+which to wait for a second dial tone.
+.SH FILES
+/dev/dn0
+.SH "SEE ALSO"
+cu(1), dn(5)
index ebeac0d..d7f4fd8 100644 (file)
@@ -1,38 +1,41 @@
-.TH CAT 1
+.TH CAT 1 
 .SH NAME
 cat \- catenate and print
 .SH SYNOPSIS
 .B cat
 [
 .B \-u
 .SH NAME
 cat \- catenate and print
 .SH SYNOPSIS
 .B cat
 [
 .B \-u
-] file ...
+]
+file ...
 .SH DESCRIPTION
 .I Cat
 reads each
 .I file
 .SH DESCRIPTION
 .I Cat
 reads each
 .I file
-in sequence and writes it on the standard output.
+in sequence
+and writes it on the standard output.
 Thus
 Thus
-.IP
+.PP
+.ti+15n
 cat file
 cat file
-.LP
-prints the file and
-.IP
+.PP
+prints the file, and
+.PP
+.ti+15n
 cat file1 file2 >file3
 cat file1 file2 >file3
-.LP
-concatenates the first two files and places the result
-on the third.
 .PP
 .PP
-If no
-.I file
-is given, or if the argument `\-' is encountered,
-.I cat 
-reads from the standard input.
-Output is buffered in 512-byte blocks unless the
-standard output is a terminal or the
+concatenates the first two files and places the result on the third.
+.PP
+If no input file is given,
+or if the argument `\-' is encountered,
+.I cat
+reads from the standard
+input file.
+Output is buffered in 512-byte blocks unless the standard
+output is a terminal or the
 .B \-u
 .B \-u
-option is present.
-.SH SEE ALSO
+option is specified.
+.SH "SEE ALSO"
 pr(1), cp(1)
 .SH BUGS
 pr(1), cp(1)
 .SH BUGS
-Beware of `cat a b >a' and `cat a b >b', which
-destroy input files before reading them.
+Beware of `cat a b >a' and `cat a b >b', which destroy
+the input files before reading them.
index bd63e70..4156f59 100644 (file)
@@ -1,12 +1,9 @@
-.TH CC 1  PDP11
+.TH CC 1 "UNIX/32V"
 .SH NAME
 .SH NAME
-cc, pcc \- C compiler
+cc \- C compiler
 .SH SYNOPSIS
 .B cc
 [ option ] ... file ...
 .SH SYNOPSIS
 .B cc
 [ option ] ... file ...
-.PP
-.B pcc
-[ option ] ... file ...
 .SH DESCRIPTION
 .I Cc
 is the UNIX C compiler.
 .SH DESCRIPTION
 .I Cc
 is the UNIX C compiler.
@@ -47,17 +44,10 @@ An execution profile can then be generated by
 use of
 .IR  prof (1).
 .TP
 use of
 .IR  prof (1).
 .TP
-.B \-f
-In systems without hardware floating-point,
-use a version of the C compiler which handles floating-point
-constants and
-loads the object program with the floating-point interpreter.
-Do not use if the hardware is present.
-.TP
 .SM
 .B \-O
 Invoke an
 .SM
 .B \-O
 Invoke an
-object-code optimizer.
+object-code improver.
 .TP
 .SM
 .B \-S
 .TP
 .SM
 .B \-S
@@ -65,19 +55,10 @@ Compile the named C programs, and leave the
 assembler-language output on corresponding files suffixed `.s'.
 .TP
 .SM
 assembler-language output on corresponding files suffixed `.s'.
 .TP
 .SM
-.B \-P
-Run only the macro preprocessor and place the result for
-each `.c' file in a corresponding `.i' file
-and has no `#' lines in it.
-.TP
-.SM
 .B \-E
 Run only the macro preprocessor
 .B \-E
 Run only the macro preprocessor
-and send the result to the
+on the named C programs, and send the result to the
 standard output.
 standard output.
-The output is intended for compiler debugging; it 
-is unacceptable as input to
-.IR cc .
 .TP
 .BI \-o " output"
 Name the final output file
 .TP
 .BI \-o " output"
 Name the final output file
@@ -95,7 +76,7 @@ Define the
 to the preprocessor,
 as if by
 `#define'.
 to the preprocessor,
 as if by
 `#define'.
-If no definition is given, the name is defined as 1.
+If no definition is given, the name is defined as "1".
 .TP
 .SM
 .BI \-U \*Sname
 .TP
 .SM
 .BI \-U \*Sname
@@ -119,7 +100,7 @@ then in directories on a standard list.
 .BI \-B \*Sstring
 Find substitute compiler passes in the files named
 .I string
 .BI \-B \*Sstring
 Find substitute compiler passes in the files named
 .I string
-with the suffixes cpp, c0, c1 and c2.
+with the suffixes cpp, ccom, and c2.
 If 
 .I string 
 is empty, use a standard backup version.
 If 
 .I string 
 is empty, use a standard backup version.
@@ -146,68 +127,43 @@ These programs, together with the results of any
 compilations specified, are loaded (in the order
 given) to produce an executable program with name
 .B a.out.
 compilations specified, are loaded (in the order
 given) to produce an executable program with name
 .B a.out.
-.PP
-The major purpose of the `portable C compiler',
-.I pcc,
-is to serve as a model
-on which to base other compilers.
-.I Pcc
-does not support options
-.BR \-f ,
-.BR \-E ,
-.BR \-B ,
-and
-.BR \-t .
-It provides, in addition to the language of
-.I cc,
-unsigned char type data and initialized bit fields.
 .SH FILES
 .SH FILES
-.ta \w'/usr/c/oc[102]  'u
+.ta \w'/usr/c/occom  'u
 file.c input file
 .br
 file.o object file
 .br
 a.out  loaded output
 .br
 file.c input file
 .br
 file.o object file
 .br
 a.out  loaded output
 .br
-/tmp/ctm?      temporaries for
-.I cc
+/tmp/ctm?      temporary
 .br
 /lib/cpp       preprocessor
 .br
 .br
 /lib/cpp       preprocessor
 .br
-/lib/c[01]     compiler for
-.I cc
+/lib/ccom      compiler
 .br
 .br
-/usr/c/oc[012] backup compiler for
-.I cc
+/usr/c/occom   backup compiler
 .br
 /usr/c/ocpp    backup preprocessor
 .br
 .br
 /usr/c/ocpp    backup preprocessor
 .br
-/lib/fc[01]    floating-point compiler
-.br
 /lib/c2        optional optimizer
 .br
 /lib/crt0.o    runtime startoff
 .br
 /lib/mcrt0.o   startoff for profiling
 .br
 /lib/c2        optional optimizer
 .br
 /lib/crt0.o    runtime startoff
 .br
 /lib/mcrt0.o   startoff for profiling
 .br
-/lib/fcrt0.o   startoff for floating-point interpretation
-.br
-/lib/libc.a    standard library, see
-.IR intro (3)
+/lib/lib[ac].a standard libraries, see (3)
 .br
 /usr/include   standard directory for `#include' files
 .br
 /usr/include   standard directory for `#include' files
-.br
-/tmp/pc*       temporaries for
-.I pcc
-.br
-/usr/lib/ccom  compiler for
-.I pcc
 .SH "SEE ALSO"
 B. W. Kernighan and D. M. Ritchie,
 .I The C Programming Language,
 Prentice-Hall,
 1978
 .br
 .SH "SEE ALSO"
 B. W. Kernighan and D. M. Ritchie,
 .I The C Programming Language,
 Prentice-Hall,
 1978
 .br
+B. W. Kernighan,
+.I
+Programming in C\(ema tutorial
+.br
 D. M. Ritchie,
 .I
 C Reference Manual
 D. M. Ritchie,
 .I
 C Reference Manual
@@ -218,20 +174,3 @@ The diagnostics produced by C itself are intended to be
 self-explanatory.
 Occasional messages may be produced by the assembler
 or loader.
 self-explanatory.
 Occasional messages may be produced by the assembler
 or loader.
-Of these, the most mystifying are from the assembler,
-.IR as (1),
-in particular `m', which means
-a multiply-defined external symbol (function
-or data).
-.SH BUGS
-.I Pcc
-is little tried on the PDP11; specialized
-code generated for that machine has not been
-well shaken down.
-The
-.B \-O
-optimizer was designed to work with
-.IR cc ;
-its use with
-.I pcc
-is suspect.
index 79efc38..5374efb 100644 (file)
@@ -54,7 +54,7 @@ option is given, this conversion is suppressed.
 .PP
 All control characters are removed from the input except space,
 backspace,
 .PP
 All control characters are removed from the input except space,
 backspace,
-tab, return, newline, ESC (033) followed by one of 789, SI, SO, and VT
+tab, return, newline, ESC (033) followed by one of 7, 8, 9, SI, SO, and VT
 (013).
 This last character is an alternate form of full reverse line feed, for
 compatibility with some other hardware conventions.
 (013).
 This last character is an alternate form of full reverse line feed, for
 compatibility with some other hardware conventions.
diff --git a/usr/man/man1/cron.1m b/usr/man/man1/cron.1m
new file mode 100644 (file)
index 0000000..959c7af
--- /dev/null
@@ -0,0 +1,56 @@
+.TH CRON 1M 
+.SH NAME
+cron \- clock daemon
+.SH SYNOPSIS
+.B /etc/cron
+.SH DESCRIPTION
+.I Cron
+executes commands at specified dates and times
+according to the instructions in the file
+/usr/lib/crontab.
+Since
+.I cron
+never exits,
+it should only be executed once.
+This is best done by running
+.I cron
+from the initialization
+process through the file
+/etc/rc;
+see
+.IR init (8).
+.PP
+Crontab
+consists of lines of six fields each.
+The fields are separated by spaces or tabs.
+The first five are integer patterns to
+specify the
+minute (0-59),
+hour (0-23),
+day of the month (1-31),
+month of the year (1-12),
+and day of the week (1-7 with 1=monday).
+Each of these patterns may
+contain a number in the range above;
+two numbers separated by
+a minus
+meaning a range inclusive;
+a list of numbers separated by
+commas meaning any of the numbers;
+or an asterisk meaning all legal values.
+The sixth field is a string
+that is executed by the Shell at the
+specified times.
+A percent character
+in this field is translated to a new-line
+character.
+Only the first line (up to a % or end of line)
+of the command field is executed by the Shell.
+The other lines are made available to the
+command as standard input.
+.PP
+Crontab is examined by
+.I cron
+every minute.
+.SH FILES
+/usr/lib/crontab
index 56aaab3..b16addf 100644 (file)
@@ -67,9 +67,9 @@ input records before starting copy
 .ns
 .TP
 .RI files= n
 .ns
 .TP
 .RI files= n
-copy
+skip
 .I n
 .I n
-files from (tape) input
+input files before starting copy
 .br
 .ns
 .TP 
 .br
 .ns
 .TP 
@@ -161,19 +161,17 @@ blocks.
 .PP
 For example, to read an EBCDIC tape blocked ten 80-byte
 EBCDIC card images per record into the ASCII file
 .PP
 For example, to read an EBCDIC tape blocked ten 80-byte
 EBCDIC card images per record into the ASCII file
-.IR x :
-.IP ""
+.I x:
+.IP
+.nf
 dd if=/dev/rmt0 of=x ibs=800 cbs=80 conv=ascii,lcase
 dd if=/dev/rmt0 of=x ibs=800 cbs=80 conv=ascii,lcase
+.fi
 .PP
 Note the use of raw magtape.
 .I Dd
 is especially suited to I/O on the raw
 physical devices because it allows reading
 and writing in arbitrary record sizes.
 .PP
 Note the use of raw magtape.
 .I Dd
 is especially suited to I/O on the raw
 physical devices because it allows reading
 and writing in arbitrary record sizes.
-.PP
-To skip over a file before copying from magnetic tape do
-.IP""
-(dd of=/dev/null; dd of=x) </dev/rmt0
 .SH "SEE ALSO"
 cp(1), tr(1)
 .SH DIAGNOSTICS
 .SH "SEE ALSO"
 cp(1), tr(1)
 .SH DIAGNOSTICS
index 9403a3c..e01f423 100644 (file)
@@ -93,5 +93,3 @@ diff(1)
 Text lines that consist of a single `.' will
 defeat
 .B \-e.
 Text lines that consist of a single `.' will
 defeat
 .B \-e.
-.br
-Files longer than 64K bytes won't work.
index 59ed53e..86213f8 100644 (file)
@@ -1,6 +1,6 @@
 .TH DU 1 
 .SH NAME
 .TH DU 1 
 .SH NAME
-du  \-  summarize disk usage
+du \-  summarize disk usage
 .SH SYNOPSIS
 .B du
 [
 .SH SYNOPSIS
 .B du
 [
index 3706b65..44d9fa7 100644 (file)
@@ -98,7 +98,7 @@ as far as desired.
 .SH FILES
 default filesystem and tape vary with installation.
 .br
 .SH FILES
 default filesystem and tape vary with installation.
 .br
-/etc/ddate: record dump dates of filesystem/level.
+/etc/ddate     record dump dates of filesystem/level.
 .SH "SEE ALSO"
 restor(1), dump(5), dumpdir(1)
 .SH DIAGNOSTICS
 .SH "SEE ALSO"
 restor(1), dump(5), dumpdir(1)
 .SH DIAGNOSTICS
index 6b169d1..455d05c 100644 (file)
@@ -3,9 +3,7 @@
 dumpdir \- print the names of files on a dump tape
 .SH SYNOPSIS
 .I dumpdir
 dumpdir \- print the names of files on a dump tape
 .SH SYNOPSIS
 .I dumpdir
-[
-.B f
-filename ]
+[f filename]
 .SH DESCRIPTION
 .I Dumpdir
 is used to read magtapes dumped with the
 .SH DESCRIPTION
 .I Dumpdir
 is used to read magtapes dumped with the
index 16b2ead..b3dc0f6 100644 (file)
@@ -1,6 +1,6 @@
 .TH ECHO 1 
 .SH NAME
 .TH ECHO 1 
 .SH NAME
-echo \- echo arguments 
+echo \- echo arguments
 .SH SYNOPSIS
 .B echo
 [
 .SH SYNOPSIS
 .B echo
 [
index 6248445..c1b52cc 100644 (file)
@@ -1,7 +1,7 @@
 .EQ
 delim $$
 .EN
 .EQ
 delim $$
 .EN
-.TH EQN 1 2/22/74
+.TH EQN 1
 .SH NAME
 eqn, neqn, checkeq  \-  typeset mathematics
 .SH SYNOPSIS
 .SH NAME
 eqn, neqn, checkeq  \-  typeset mathematics
 .SH SYNOPSIS
index 2b86249..6d24b9e 100644 (file)
@@ -107,13 +107,13 @@ given) to produce an executable program with name
 `a.out'.
 .SH FILES
 .nf
 `a.out'.
 .SH FILES
 .nf
-.ta \w'/usr/lib/f77rt0.o 'u
+.ta \w'/usr/lib/libF77.a   'u
 file.[fresc]   input file
 file.o object file
 a.out  loaded output
 ./fort[pid].?  temporary
 /usr/lib/f77pass1      compiler
 file.[fresc]   input file
 file.o object file
 a.out  loaded output
 ./fort[pid].?  temporary
 /usr/lib/f77pass1      compiler
-/lib/c1        pass 2
+/lib/f1        pass 2
 /lib/c2        optional optimizer
 /usr/lib/libF77.a      intrinsic function library
 /usr/lib/libI77.a      Fortran I/O library
 /lib/c2        optional optimizer
 /usr/lib/libF77.a      intrinsic function library
 /usr/lib/libI77.a      Fortran I/O library
diff --git a/usr/man/man1/factor.1 b/usr/man/man1/factor.1
deleted file mode 100644 (file)
index 44d579c..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-.TH FACTOR 1 
-.SH NAME
-factor, primes \- factor a number, generate large primes
-.SH SYNOPSIS
-.B factor
-[ number ]
-.PP
-.B primes
-.SH DESCRIPTION
-When
-.I factor
-is invoked without an argument, it waits for a number to be typed in.
-If you type in a positive
-number less than 2\u\s756\s0\d (about
-.if n 7.2e16)
-.if t 7.2\(mu10\u\s716\s0\d\|)
-it will factor the number and print its prime factors; each one is printed
-the proper number of times.
-Then it waits for another number.
-It exits if it encounters a zero or any non-numeric character.
-.PP
-If
-.I factor
-is invoked with an argument, it factors the number
-as above and then exits.
-.PP
-Maximum time to factor is proportional to
-.if n sqrt(n)
-.if t \(sr\o'\fIn\fR\(rn'
-and occurs when
-.I n
-is prime
-or the square of a prime.
-It takes 1 minute to factor a prime
-near
-10\u\s714\s0\d
-on a PDP11.
-.PP
-When
-.I primes
-is invoked, it waits for a number to be typed in.
-If you type in a positive
-number less than 2\u\s756\s0\d
-it will print all primes greater than or
-equal to this number.
-.SH DIAGNOSTICS
-`Ouch.' for input out of range or for garbage input.
diff --git a/usr/man/man1/false.1 b/usr/man/man1/false.1
new file mode 100644 (file)
index 0000000..0336736
--- /dev/null
@@ -0,0 +1 @@
+.so /usr/man/man1/true.1
index 18780de..76e6465 100644 (file)
@@ -24,12 +24,7 @@ family search the input
 for lines matching
 a pattern.
 Normally, each line found
 for lines matching
 a pattern.
 Normally, each line found
-is copied to the standard output;
-unless the
-.B \-h
-flag is used,
-the file name is shown if there is more than one input file.
-.PP
+is copied to the standard output.
 .I Grep
 patterns are limited regular expressions in the style of
 .IR ed (1);
 .I Grep
 patterns are limited regular expressions in the style of
 .IR ed (1);
@@ -40,13 +35,17 @@ it uses a fast deterministic algorithm that
 sometimes needs exponential space.
 .I Fgrep
 patterns are fixed strings; it is fast and compact.
 sometimes needs exponential space.
 .I Fgrep
 patterns are fixed strings; it is fast and compact.
-.PP
 The following options are recognized.
 .TP
 .B \-v
 All lines but those matching
 are printed.
 .TP
 The following options are recognized.
 .TP
 .B \-v
 All lines but those matching
 are printed.
 .TP
+.B \-x
+(Exact) only lines matched in their entirety are printed
+.RI ( fgrep
+only).
+.TP
 .B \-c
 Only a count of matching lines is printed.
 .TP
 .B \-c
 Only a count of matching lines is printed.
 .TP
@@ -56,7 +55,7 @@ separated by newlines.
 .TP
 .B \-n
 Each line is preceded by
 .TP
 .B \-n
 Each line is preceded by
-its line number in the file.
+its relative line number in the file.
 .TP
 .B \-b
 Each line is preceded by the block number
 .TP
 .B \-b
 Each line is preceded by the block number
@@ -64,18 +63,6 @@ on which it was found.
 This is sometimes useful in locating
 disk block numbers by context.
 .TP
 This is sometimes useful in locating
 disk block numbers by context.
 .TP
-.B \-s
-No output is produced, only status.
-.TP
-.B \-h
-Do not print filename headers with output lines.
-.TP
-.B \-y
-Lower case letters in the pattern will also match
-upper case letters in the input
-.RI ( grep
-only).
-.TP
 .BI \-e " expression"
 Same as a simple
 .I expression 
 .BI \-e " expression"
 Same as a simple
 .I expression 
@@ -91,15 +78,11 @@ or string list
 .RI ( fgrep ) 
 is taken from the
 .I file.
 .RI ( fgrep ) 
 is taken from the
 .I file.
-.TP
-.B \-x
-(Exact) only lines matched in their entirety are printed
-.RI ( fgrep
-only).
 .PP
 .PP
+In all cases the file name is shown if there is more than one input file.
 Care should be taken when
 using the characters
 Care should be taken when
 using the characters
-$ * [ ^ | ? \' " ( ) and \e in the
+$ * [ ^ | ( ) and \\ in the
 .I expression
 as they are
 also meaningful to the Shell.
 .I expression
 as they are
 also meaningful to the Shell.
@@ -118,10 +101,11 @@ In the following description `character' excludes
 newline:
 .IP
 A \e followed by a single character
 newline:
 .IP
 A \e followed by a single character
+other than newline
 matches that character.
 .IP
 matches that character.
 .IP
-The character ^
-($) matches the beginning (end) of a line.
+The character ^ ($) matches the beginning (end) of
+a line.
 .IP
 A 
 .B .
 .IP
 A 
 .B .
index b45787a..040c936 100644 (file)
@@ -20,8 +20,10 @@ Commands used primarily for system maintenance.
 .PP
 The word `local' at the foot of a page means that the
 command is not intended for general distribution.
 .PP
 The word `local' at the foot of a page means that the
 command is not intended for general distribution.
+The word `UNIX/32V' at the foot of a page means that some or all
+of the description applies only to the UNIX/32V system for the
+Digital Equipment Corporation VAX-11.
 .SH SEE ALSO
 .SH SEE ALSO
-.SH DIAGNOSTICS
 Section (6) for computer games.
 .PP
 .I How to get started,
 Section (6) for computer games.
 .PP
 .I How to get started,
index dbba3ba..f86d725 100644 (file)
@@ -1,4 +1,4 @@
-.TH IOSTAT 1M 
+.TH IOSTAT 1M UNIX/32V
 .SH NAME
 iostat \- report I/O statistics
 .SH SYNOPSIS
 .SH NAME
 iostat \- report I/O statistics
 .SH SYNOPSIS
@@ -10,9 +10,9 @@ iostat \- report I/O statistics
 delves into the system and reports certain statistics kept about
 input-output activity.
 Information is kept about up to three different disks
 delves into the system and reports certain statistics kept about
 input-output activity.
 Information is kept about up to three different disks
-(RF, RK, RP) and about typewriters.
+(RF, RK, RP) and about terminals.
 For each disk, IO completions and number of words transferred
 For each disk, IO completions and number of words transferred
-are counted; for typewriters collectively, the number
+are counted; for terminals collectively, the number
 of input and output characters are counted.
 Also, each sixtieth of a second,
 the state of each disk is examined
 of input and output characters are counted.
 Also, each sixtieth of a second,
 the state of each disk is examined
@@ -71,4 +71,4 @@ configurations of 4 system states and 8 IO states
 .B \-b
 Report on the usage of IO buffers.
 .SH FILES
 .B \-b
 Report on the usage of IO buffers.
 .SH FILES
-/dev/mem, /unix
+/dev/kmem, /unix
index 5adcae3..86bdda8 100644 (file)
@@ -1,9 +1,9 @@
-.TH LD 1 
+.TH LD 1 "UNIX/32V"
 .SH NAME
 .SH NAME
-ld \- loader
+ld \- link editor
 .SH SYNOPSIS
 .B ld
 .SH SYNOPSIS
 .B ld
-[ option ] file ...
+[ option ] ... file ...
 .SH DESCRIPTION
 .I Ld
 combines several
 .SH DESCRIPTION
 .I Ld
 combines several
@@ -21,7 +21,7 @@ run.
 (In the latter case, the
 .B \-r
 option must be given
 (In the latter case, the
 .B \-r
 option must be given
-to preserve the relocation bits.)
+to preserve the relocation bits.)
 The output of
 .I ld
 is left on
 The output of
 .I ld
 is left on
@@ -31,7 +31,7 @@ only if no errors occurred during the load.
 .PP
 The argument routines are concatenated in the order
 specified.  The entry point of the output is the
 .PP
 The argument routines are concatenated in the order
 specified.  The entry point of the output is the
-beginning of the first routine.
+beginning of the first routine (unless the \fB\-e\fP option is specified).
 .PP
 If any argument is a library, it is searched exactly once
 at the point it is encountered in the argument list.
 .PP
 If any argument is a library, it is searched exactly once
 at the point it is encountered in the argument list.
@@ -39,21 +39,10 @@ Only those routines defining an unresolved external
 reference are loaded.
 If a routine from a library
 references another routine in the library,
 reference are loaded.
 If a routine from a library
 references another routine in the library,
-and the library has not been processed by
-.IR ranlib (1),
 the referenced routine must appear after the
 referencing routine in the library.
 Thus the order of programs within libraries
 the referenced routine must appear after the
 referencing routine in the library.
 Thus the order of programs within libraries
-may be important.
-If the first member of a library is named
-`__.SYMDEF',
-then it is understood to be a dictionary for the
-library
-such
-as produced by
-.IR ranlib ;
-the dictionary is searched
-iteratively to satisfy as many references as possible.
+is important.
 .PP
 The symbols `\_etext', `\_edata' and `\_end'
 (`etext', `edata' and `end' in C)
 .PP
 The symbols `\_etext', `\_edata' and `\_end'
 (`etext', `edata' and `end' in C)
@@ -68,20 +57,21 @@ understands several options.
 Except for
 .BR \-l ,
 they should appear before the file names.
 Except for
 .BR \-l ,
 they should appear before the file names.
+.TP
+.B \-D
+Take the next argument as a hexadecimal number and pad the data segment
+with zero bytes to the indicated length.
 .TP 
 .TP 
-.B  \-s
-`Strip' the output, that is, remove the symbol table
-and relocation bits to save space (but impair the
-usefulness of the debugger).
-This information can also be removed by
-.IR  strip (1).
-.TP 
-.B  \-u
-Take the following argument as a symbol and enter
-it as undefined in the symbol table.  This is useful
-for loading wholly from a library, since initially the symbol
-table is empty and an unresolved reference is needed
-to force the loading of the first routine.
+.B  \-d
+Force definition of common storage
+even if the
+.B \-r
+flag is present.
+.TP
+.B \-e
+The following argument is taken to be the
+name of the entry point of the loaded
+program; location 0 is the default.
 .TP 
 .BI \-l x
 This
 .TP 
 .BI \-l x
 This
@@ -93,57 +83,24 @@ is a string.
 If that does not exist,
 .I ld
 tries
 If that does not exist,
 .I ld
 tries
-.RI `/usr/lib/lib x .a'.
+.RI `/usr/lib/lib x .a'
 A library is searched when its name is encountered,
 so the placement of a
 .B  \-l
 is significant.
 A library is searched when its name is encountered,
 so the placement of a
 .B  \-l
 is significant.
-.TP 
-.B  \-x
-Do not preserve local
-(non-.globl) symbols in the output symbol table; only enter
-external symbols.
-This option saves some space in the output file.
-.TP 
-.B  \-X
-Save local symbols
-except for those whose names begin with `L'.
-This option is used by
-.IR cc (1)
-to discard internally generated labels while
-retaining symbols local to routines.
-.TP 
-.B  \-r
-Generate relocation bits in the output file
-so that it can be the subject of another
-.I ld
-run.
-This flag also prevents final definitions from being
-given to common symbols,
-and suppresses the `undefined symbol' diagnostics.
-.TP 
-.B  \-d
-Force definition of common storage
-even if the
-.B \-r
-flag is present.
+.TP
+.B \-N
+Do not make the text portion read only or sharable.  (Use "magic number" 0407.)
 .TP 
 .B  \-n
 .TP 
 .B  \-n
-Arrange that
+Arrange (by giving the output file a 0410 "magic number") that
 when the output file is executed,
 the text portion will be read-only and shared
 among all users executing the file.
 This involves moving the data areas up to the first
 when the output file is executed,
 the text portion will be read-only and shared
 among all users executing the file.
 This involves moving the data areas up to the first
-possible 4K word boundary following the
-end of the text.
-.TP 
-.B  \-i
-When the output file is executed, the program
-text and data areas will live in separate address spaces.
-The only difference between this option
-and
-.B \-n
-is that here the data starts at location 0.
+possible 512 byte boundary following the
+end of the text.  This option is the default under UNIX/32V;
+the only other choice is \-N.
 .TP 
 .B  \-o
 The
 .TP 
 .B  \-o
 The
@@ -154,22 +111,53 @@ is used as the name of the
 .I ld
 output file, instead of
 .BR a.out .
 .I ld
 output file, instead of
 .BR a.out .
+.TP 
+.B  \-r
+Generate relocation bits in the output file
+so that it can be the subject of another
+.I ld
+run.
+This flag also prevents final definitions from being
+given to common symbols,
+and suppresses the `undefined symbol' diagnostics.
 .TP
 .TP
-.B \-e
-The following argument is taken to be the
-name of the entry point of the loaded
-program; location 0 is the default.
+.B \-S
+`Strip' the output by removing all symbols except locals and globals.
+.TP 
+.B  \-s
+`Strip' the output, that is, remove the symbol table
+and relocation bits to save space (but impair the
+usefulness of the debugger).
+This information can also be removed by
+.IR  strip (1).
 .TP
 .TP
-.B \-O
-This is an overlay file, only the text segment
-will be replaced by
-.IR exec (2).
-Shared data must have the same layout as in
-the program overlaid.
+.B \-T
+The next argument is a hexadecimal number which sets the text segment origin.
+The default origin is 0.
 .TP
 .TP
-.B \-D
-The next argument is a decimal number that sets
-the size of the data segment.
+.B \-t
+("trace")  Print the name of each file as it is processed.
+.TP 
+.B  \-u
+Take the following argument as a symbol and enter
+it as undefined in the symbol table.  This is useful
+for loading wholly from a library, since initially the symbol
+table is empty and an unresolved reference is needed
+to force the loading of the first routine.
+.TP 
+.B  \-X
+Save local symbols
+except for those whose names begin with `L'.
+This option is used by
+.IR cc (1)
+to discard internally-generated labels while
+retaining symbols local to routines.
+.TP 
+.B  \-x
+Do not preserve local
+(non-.globl) symbols in the output symbol table; only enter
+external symbols.
+This option saves some space in the output file.
 .SH FILES
 .ta \w'/usr/lib/lib*.a\ \ 'u
 /lib/lib*.a    libraries
 .SH FILES
 .ta \w'/usr/lib/lib*.a\ \ 'u
 /lib/lib*.a    libraries
@@ -178,5 +166,5 @@ the size of the data segment.
 .br
 a.out  output file
 .SH "SEE ALSO"
 .br
 a.out  output file
 .SH "SEE ALSO"
-as(1), ar(1), cc(1), ranlib(1)
+as(1), ar(1), cc(1)
 .SH BUGS
 .SH BUGS
diff --git a/usr/man/man1/learn.1 b/usr/man/man1/learn.1
new file mode 100644 (file)
index 0000000..5d426e0
--- /dev/null
@@ -0,0 +1,74 @@
+.TH LEARN 1
+.SH NAME
+learn \- computer aided instruction about UNIX
+.SH SYNOPSIS
+.B learn
+[
+.BR \- directory
+]
+[ subject [ lesson  [ speed ] ] ]
+.SH DESCRIPTION
+.I Learn
+gives CAI courses and practice in the use of UNIX.
+To get started
+simply type `learn'.
+The program will ask questions to find out what
+you want to do.
+The questions may be bypassed by naming a
+.I subject,
+and the last
+.I lesson
+number that
+.I learn
+told you in the previous session.
+You may also include a
+.I speed
+number that was given with the lesson number
+(but without the parentheses that
+.I learn
+places around the speed number).
+If
+.I lesson
+is `\-', 
+.I learn
+prompts for each lesson;
+this is useful for debugging.
+.PP
+The
+.I subjects
+presently handled are
+.IP " "
+.nf
+editor
+eqn
+files
+macros
+morefiles
+C
+.fi
+.PP
+The special command
+`bye' terminates a 
+.I learn
+session.
+.PP
+The
+.BI \- directory
+option allows one to exercise a script in
+a nonstandard place.
+.SH FILES
+/usr/learn and all dependent directories and files
+.SH BUGS
+The main strength of
+.I learn,
+that it asks the student to use the real
+UNIX, also makes possible baffling mistakes.
+It is helpful, especially for nonprogrammers,
+to have a UNIX initiate near at hand during the first
+sessions.
+.PP
+Occasionally lessons are incorrect, sometimes because the local version
+of a command operates in a non-standard way.
+Such lessons may be skipped,
+but it takes some sophistication to recognize
+the situation.
index bb76388..92a9611 100644 (file)
@@ -129,6 +129,7 @@ option for the next function.
 at the beginning of a file shuts off complaints about
 unused functions in this file.
 .SH FILES
 at the beginning of a file shuts off complaints about
 unused functions in this file.
 .SH FILES
+.ta \w'/usr/lib/llib-port  'u
 /usr/lib/lint[12] programs
 .br
 /usr/lib/llib-lc declarations for standard functions
 /usr/lib/lint[12] programs
 .br
 /usr/lib/llib-lc declarations for standard functions
index a1d8dd9..b38ebea 100644 (file)
@@ -41,12 +41,12 @@ Login is recognized by
 .IR sh (1)
 and executed directly (without forking).
 .SH FILES
 .IR sh (1)
 and executed directly (without forking).
 .SH FILES
-.ta \w'/usr/adm/wtmp\ \ 'u
+.ta \w'/usr/spool/mail/*\ \ 'u
 /etc/utmp      accounting
 .br
 /usr/adm/wtmp  accounting
 .br
 /etc/utmp      accounting
 .br
 /usr/adm/wtmp  accounting
 .br
-/usr/mail/*    mail
+/usr/spool/mail/*      mail
 .br
 /etc/motd      message-of-the-day
 .br
 .br
 /etc/motd      message-of-the-day
 .br
diff --git a/usr/man/man1/lookall.1 b/usr/man/man1/lookall.1
deleted file mode 100644 (file)
index 7a35e60..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-.TH LOOKALL 1
-.SH NAME
-lookall \- look through all text files on UNIX
-.SH SYNOPSIS
-.B lookall
-[
-.BI \-C n
-]
-.SH DESCRIPTION
-.I Lookall
-accepts keywords from the standard input, performs
-a search similar to that of
-.IR  refer (1),
-and writes the result on the standard output.
-.I Lookall
-consults, however, an index to all the text files on
-the system rather than just bibliographies.
-Only the first 50
-words of each file (roughly) were used to
-make the indexes.
-Blank lines are taken as delimiters between queries.
-.PP
-The
-.BI -C n
-option
-specifies a coordination level search: up to
-.IR n
-keywords may be missing
-from the answers, and the answers are listed
-with those containing the most keywords first.
-.PP
-The command sequence in
-.I /usr/dict/lookall/makindex
-regenerates the index.
-.SH FILES
-The directory
-.I /usr/dict/lookall
-contains the index files.
-.SH DIAGNOSTICS
-`Warning: index precedes file ...'
-means that a file has been changed since the index was made
-and it may be retrieved (or not retrieved) erroneously.
-.SH BUGS
-Coordination level searching doesn't work as described: only
-those acceptable items with the smallest number of
-missing keywords are retreived.
diff --git a/usr/man/man1/lookbib.1 b/usr/man/man1/lookbib.1
new file mode 100644 (file)
index 0000000..c782038
--- /dev/null
@@ -0,0 +1 @@
+.so /usr/man/man1/refer.1
diff --git a/usr/man/man1/lpr.1 b/usr/man/man1/lpr.1
new file mode 100644 (file)
index 0000000..bd5956b
--- /dev/null
@@ -0,0 +1,50 @@
+.TH LPR 1 
+.SH NAME
+lpr, vpr \- line printer spooler
+.SH SYNOPSIS
+.B lpr
+[ option ] ... [ file ] ...
+.br
+.B vpr
+[
+.B \-b
+banner ] [ file ] ...
+.SH DESCRIPTION
+.I Lpr 
+causes the
+.I files
+to be queued for printing on a line printer.
+If no files are named, the standard input is read.
+The following options are available:
+.TP
+.B \-r
+Remove the file when it has been queued.
+.TP
+.B \-c
+Copy the file to insulate against changes
+that may happen before printing.
+.TP
+.B \-m
+Report by
+.IR mail (1)
+when printing is complete.
+.TP
+.B \-n
+Do not report by mail.
+This is the default option.
+.PP
+.I Vpr
+is the program used by
+.I lpr
+when the online printer is a Versatec machine
+to insert an identifying
+.I banner
+before the output, strip overstrikes,
+and, where possible, remove blank lines to make
+66-line pages fit on 64 lines.
+.SH FILES
+/usr/lpd/* spool area
+.br
+/usr/bin/vpr for Versatec printer.
+.SH SEE ALSO
+opr(1), lpd(8)
index b3bcca8..58ce26c 100644 (file)
@@ -3,19 +3,19 @@
 mail  \-  send or receive mail among users
 .SH SYNOPSIS
 .B mail
 mail  \-  send or receive mail among users
 .SH SYNOPSIS
 .B mail
-person ...
+[
+.B +
+] [
+.B \-i
+] [ person ] ...
 .br
 .B mail
 .br
 .B mail
+.B "[ + ]"
 [
 [
-.B \-r
-] [
-.B \-q
-] [
-.B \-p
-] [
+.B \-i
+]
 .B \-f
 file
 .B \-f
 file
-]
 .LP
 .SH DESCRIPTION
 .I Mail
 .LP
 .SH DESCRIPTION
 .I Mail
@@ -25,15 +25,10 @@ a user's mail,
 message-by-message,
 in last-in, first-out order;
 the optional argument
 message-by-message,
 in last-in, first-out order;
 the optional argument
-.B \-r
+.B +
 causes first-in, first-out order.
 causes first-in, first-out order.
-If the
-.B \-p
-flag is given, the mail is printed with no questions asked;
-otherwise,
-for each message,
-.I mail
-reads a line from the standard input
+For each message,
+it reads a line from the standard input
 to direct disposition of the message.
 .TP
 newline
 to direct disposition of the message.
 .TP
 newline
@@ -69,22 +64,21 @@ Put unexamined mail back in the mailbox and stop.
 q
 Same as EOT.
 .TP
 q
 Same as EOT.
 .TP
-x
-Exit, without changing the mailbox file.
+.RI ! command
+Escape to the Shell to do
+.IR command .
 .TP
 .TP
-!command
-Escape to the Shell to do command.
-.TP
-?
+*
 Print a command summary.
 .PP
 Print a command summary.
 .PP
-An interrupt stops the printing of the current letter.
+.PP
+An interrupt normally causes termination of the command;
+the mail file is unchanged.
 The optional argument
 The optional argument
-.B \(miq
+.B \(mii
 causes
 .I mail
 causes
 .I mail
-to exit after interrupts
-without changing the mailbox.
+to continue after interrupts.
 .PP
 When
 .I persons
 .PP
 When
 .I persons
@@ -112,29 +106,30 @@ The
 option causes the named file, e.g. `mbox',
 to be printed as if it were the mail file.
 .PP
 option causes the named file, e.g. `mbox',
 to be printed as if it were the mail file.
 .PP
-Each user owns his own mailbox, which is by default generally
-readable but not writable.
-The command does not delete an empty mailbox nor change its mode,
-so a user may make it unreadable if desired.
-.PP
 When a user logs in he is informed of the presence
 of mail.
 .SH FILES
 When a user logs in he is informed of the presence
 of mail.
 .SH FILES
-/usr/spool/mail/*      mailboxes
-.br
+.ta \w'/usr/spool/mail/*.lock 'u
 /etc/passwd    to identify sender and locate persons
 .br
 /etc/passwd    to identify sender and locate persons
 .br
+.li
+/usr/spool/mail/*      incoming mail for user *
+.br
 mbox           saved mail
 .br
 /tmp/ma*       temp file
 .br
 mbox           saved mail
 .br
 /tmp/ma*       temp file
 .br
+/usr/spool/mail/*.lock lock for mail directory
+.br
 dead.letter    unmailable text
 .br
 dead.letter    unmailable text
 .br
-uux(1)
 .SH "SEE ALSO"
 .SH "SEE ALSO"
-xsend(1), write(1), uucp(1)
+write(1), uucp(1), uux(1)
 .SH BUGS
 .SH BUGS
-There is a locking mechanism intended to prevent
-two senders from accessing the same mailbox, but it
-is not perfect and races
-are possible.
+Race conditions sometimes result
+in a failure to remove a lock file.
+.PP
+Normally anybody can read your mail.
+An installation can overcome this by making
+.I mail
+a set-user-id command that owns the mail directory.
diff --git a/usr/man/man1/mkconf.1m b/usr/man/man1/mkconf.1m
deleted file mode 100644 (file)
index 73b332f..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-.TH MKCONF 1M
-.SH NAME
-mkconf \- generate configuration tables
-.SH SYNOPSIS
-mkconf
-.SH DESCRIPTION
-.I Mkconf
-examines a machine configuration table on its
-standard input.
-Its output is a pair of files
-.I l.s
-and
-.I c.c.
-The first is an assembler program that represents the interrupt vectors
-located in low memory addresses;
-the second contains initialized
-block and character device switch tables.
-.PP
-Input to
-.I mkconf
-is a sequence of lines.
-The following describe devices on the machine:
-.PP
-.RS 5
-.nf
-.DS
-pc     (PC11)
-lp     (LP11)
-rf     (RS11)
-hs     (RS03/RS04)
-tc     (TU56)
-rk     (RK03/RK05)
-tm     (TU10)
-rp     (RP03)
-hp     (RP04/5/6)
-ht     (TU16)
-dc*    (DC11)
-kl*    (KL11/DL11-ABC)
-dl*    (DL11-E)
-dp*    (DP11)
-dn*    (DN11)
-dh*    (DH11)
-dhdm*  (DM11-BB)
-du*    (DU11)
-.RE
-.fi
-.PP
-The devices marked with * may be preceded by a number telling
-how many are to be included.
-The console typewrite is automatically included;
-don't count it as part of the KL or DL specification.
-Count DN's in units of 4 (1 system unit).
-.PP
-The following lines are also accepted.
-.TP 5
-.BI "root " "dev minor"
-The specified block device (e.g.
-.BR hp )
-is used for the root.
-.I minor
-is a decimal number giving the minor device.
-This line must appear exactly once.
-.TP 5
-.BI "swap " "dev minor"
-The specified block device is used for swapping.
-If not given the root is used.
-.TP 5
-.BI "pipe " "dev minor"
-The specified block device
-is used to store pipes.
-If not given the root is used.
-.TP 5
-.BI "swplo " number
-.TP 5
-.BI "nswap " number
-Sets the origin (block number) and size of the area used for
-swapping.
-By default, the not very useful numbers
-4000 and 872.
-.TP 5
-.B pack
-Include the packet driver.
-By default it is left out.
-.TP 5
-.B mpx
-Include the multiplexor driver.
-By default it is left out.
-.SH FILES
-l.s, c.c       output files
-.SH SEE ALSO
-`Setting up Unix', in Volume 2.
-.SH BUGS
-The set of devices it knows about, the set of drivers included,
-and the set of devices on the machine
-are mutually incomparable.
-Some handwork is certain to be necessary.
-Because of floating vectors that may have been missed,
-It is mandatory to check the
-.I l.s
-file to make sure it corresponds with reality.
index 513ea16..69e73fd 100644 (file)
@@ -127,3 +127,4 @@ dir(5),
 bproc(8)
 .SH BUGS
 There should be some way to specify links.
 bproc(8)
 .SH BUGS
 There should be some way to specify links.
+There should be some way to specify bad blocks.
index 388acac..1ce2221 100644 (file)
@@ -40,7 +40,7 @@ systems must be mounted read-only
 or errors will occur when access times are updated,
 whether or not any explicit write is attempted.
 .SH FILES
 or errors will occur when access times are updated,
 whether or not any explicit write is attempted.
 .SH FILES
-/etc/mtab: mount table
+/etc/mtab      mount table
 .SH "SEE ALSO"
 mount(2),
 mtab(5)
 .SH "SEE ALSO"
 mount(2),
 mtab(5)
index 318df89..9b8dbcf 100644 (file)
@@ -1,6 +1,6 @@
 .TH MV 1 
 .SH NAME
 .TH MV 1 
 .SH NAME
-mv  \-  move or rename files and directories
+mv  \-  move or rename files
 .SH SYNOPSIS
 .B mv
 file1 file2
 .SH SYNOPSIS
 .B mv
 file1 file2
@@ -60,6 +60,9 @@ that of the copying process and any
 linking relationship with other files
 is lost.
 .PP
 linking relationship with other files
 is lost.
 .PP
+Directories may only be moved within the same parent
+directory.
+.PP
 .I Mv
 should take
 .B \-f
 .I Mv
 should take
 .B \-f
index 0fe1abd..2127c05 100644 (file)
@@ -39,7 +39,7 @@ prevent it from responding to interrupts by or
 stealing the input from
 the next person who logs in on the same terminal.
 .SH FILES
 stealing the input from
 the next person who logs in on the same terminal.
 .SH FILES
-nohup.out standard output and standard error file under
+nohup.out      standard output and standard error file under
 .I nohup
 .SH "SEE ALSO"
 nice(2)
 .I nohup
 .SH "SEE ALSO"
 nice(2)
diff --git a/usr/man/man1/nohup.1 b/usr/man/man1/nohup.1
new file mode 100644 (file)
index 0000000..dd15040
--- /dev/null
@@ -0,0 +1,25 @@
+.TH NOHUP 1 
+.SH NAME
+nohup \- run a command immune to hangups
+.SH SYNOPSIS
+.B nohup
+command [ arguments ]
+.SH DESCRIPTION
+.I Nohup
+executes
+.I command
+with signals 1, 3 and 13
+(hangup, quit and soft kill) ignored.
+The priority of the command is run at
+nice \-5.
+Signal 2 (interrupt) will be ignored if
+the command is run asynchronously
+(with &)
+from the shell.
+If the command whould have had a terminal as standard
+output,
+it is redirected to the file `nohup.out'.
+.SH FILES
+nohup.out      redirected standard output.
+.SH "SEE ALSO"
+nice(1), signal(2)
diff --git a/usr/man/man1/number.1 b/usr/man/man1/number.1
new file mode 100644 (file)
index 0000000..61246bd
--- /dev/null
@@ -0,0 +1,14 @@
+.TH NUMBER 1 
+.SH NAME
+number \- convert Arabic numerals to English
+.SH SYNOPSIS
+.B number
+.SH DESCRIPTION
+.I Number
+copies the standard input to the standard output,
+changing each decimal number to a fully spelled out version.
+Punctuation is added to make the output sound well when
+played through
+.IR speak (1).
+.SH "SEE ALSO"
+speak(1)
index 31338c7..043ec46 100644 (file)
@@ -4,7 +4,7 @@ od  \-  octal dump
 .SH SYNOPSIS
 .B od
 [
 .SH SYNOPSIS
 .B od
 [
-.B \-bcdox
+.B \-abcdox
 ] [ file ] [ [
 .B +
 ]offset[
 ] [ file ] [ [
 .B +
 ]offset[
index af5a1c6..a7984ae 100644 (file)
@@ -27,4 +27,4 @@ the owner must prove he knows the old password.
 login(1), passwd(5), crypt(3)
 .br
 Robert Morris and Ken Thompson,
 login(1), passwd(5), crypt(3)
 .br
 Robert Morris and Ken Thompson,
-.I Password Security: A Case History
+.I UNIX password security
diff --git a/usr/man/man1/prep.1 b/usr/man/man1/prep.1
deleted file mode 100644 (file)
index 3e8190e..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-.TH PREP 1 
-.SH NAME
-prep \- prepare text for statistical processing
-.SH SYNOPSIS
-.B prep
-[
-.B \-dio
-]
-file ...
-.SH DESCRIPTION
-.I Prep
-reads each
-.I file
-in sequence
-and writes it on the standard output,
-one `word' to a line.
-A word is a string of alphabetic characters
-and imbedded apostrophes,
-delimited by space or punctuation.
-Hyphented words are broken apart;
-hyphens at the end of lines are removed and the
-hyphenated parts are joined.
-Strings of digits are discarded.
-.PP
-The following option letters may appear in any order:
-.TP
-.B \-d
-Print the word number (in the input
-stream) with each word.
-.TP
-.B \-i
-Take the next
-.I file
-as an `ignore' file.
-These words will not appear in the output.
-(They will be counted, for purposes of the
-.B \-d
-count.)
-.TP
-.B \-o
-Take the next 
-.I file
-as an `only' file.
-Only these words will appear in the output.
-(All other words will also be counted for
-the 
-.B \-d
-count.)
-.TP
-.B \-p
-Include punctuation marks (single nonalphanumeric characters)
-as separate output lines.
-The punctuation marks are not counted for the
-.B \-d
-count.
-.PP
-Ignore and only files contain words, one per line.
-.SH SEE ALSO
-deroff(1)
index 88aa2d9..261829b 100644 (file)
@@ -1,4 +1,4 @@
-.TH PS 1  PDP11
+.TH PS 1 "UNIX/32V"
 .SH NAME
 ps \- process status
 .SH SYNOPSIS
 .SH NAME
 ps \- process status
 .SH SYNOPSIS
@@ -27,11 +27,12 @@ The long listing is columnar and contains
 .TP
 F
 Flags associated with the process.
 .TP
 F
 Flags associated with the process.
-01: in core;
+01: in memory;
 02: system process;
 02: system process;
-04: locked in core (e.g. for physical I/O);
+04: locked in memory (e.g. for physical I/O);
 10: being swapped;
 10: being swapped;
-20: being traced by another process.
+20: being traced by another process;
+200: partially swapped.
 .TP
 S
 The state of the process.
 .TP
 S
 The state of the process.
@@ -64,11 +65,11 @@ NICE
 Used in priority computation.
 .TP
 ADDR
 Used in priority computation.
 .TP
 ADDR
-The core address of the process if resident,
+The memory address of the process if resident,
 otherwise the disk address.
 .TP
 SZ
 otherwise the disk address.
 .TP
 SZ
-The size in blocks of the core image of the process.
+The size in blocks of the memory image of the process.
 .TP
 WCHAN
 The event for which the process is waiting or sleeping;
 .TP
 WCHAN
 The event for which the process is waiting or sleeping;
@@ -88,7 +89,7 @@ yet been waited for by the parent is marked <defunct>.
 .I Ps
 makes an educated guess as to the file name
 and arguments given when the process was created
 .I Ps
 makes an educated guess as to the file name
 and arguments given when the process was created
-by examining core memory or the swap area.
+by examining memory or the swap area.
 The method is inherently somewhat unreliable and in any event
 a process is entitled to destroy this information,
 so the names cannot be counted on too much.
 The method is inherently somewhat unreliable and in any event
 a process is entitled to destroy this information,
 so the names cannot be counted on too much.
@@ -99,7 +100,7 @@ option is specified,
 the file
 .I /usr/sys/core
 is used in place of
 the file
 .I /usr/sys/core
 is used in place of
-.IR /dev/mem .
+.IR /dev/kmem .
 This is used for
 postmortem system debugging.
 If a second argument is given,
 This is used for
 postmortem system debugging.
 If a second argument is given,
@@ -108,7 +109,7 @@ it is taken to be the file containing the system's namelist.
 .ta \w'/usr/sys/core 'u
 /unix          system namelist
 .br
 .ta \w'/usr/sys/core 'u
 /unix          system namelist
 .br
-/dev/mem       core memory
+/dev/kmem      kernel memory
 .br
 /usr/sys/core  alternate core file
 .br
 .br
 /usr/sys/core  alternate core file
 .br
@@ -121,4 +122,4 @@ Things can change while
 is running; the picture it gives is only a close
 approximation to reality.
 .br
 is running; the picture it gives is only a close
 approximation to reality.
 .br
-Some data printed for defunct processes is irrelevant
+Some data printed for defunct processes is irrelevant.
index 87222de..a89578e 100644 (file)
@@ -1,4 +1,4 @@
-.TH PSTAT 1M
+.TH PSTAT 1M "UNIX/32V"
 .SH NAME
 pstat \- print system facts
 .SH SYNOPSIS
 .SH NAME
 pstat \- print system facts
 .SH SYNOPSIS
@@ -14,7 +14,7 @@ If
 .I file
 is given, the tables are sought there, otherwise
 in
 .I file
 is given, the tables are sought there, otherwise
 in
-.I /dev/mem.
+.I /dev/kmem.
 The required namelist is taken from
 .I /unix.
 Options are
 The required namelist is taken from
 .I /unix.
 Options are
@@ -141,7 +141,9 @@ traced
 used in tracing
 .IP 0100
 locked in by
 used in tracing
 .IP 0100
 locked in by
-.IR lock (2).
+.IR lock (2)
+.IP 0200
+partially swapped.
 .RE
 .IP PRI
 Scheduling priority, see
 .RE
 .IP PRI
 Scheduling priority, see
@@ -260,10 +262,10 @@ The file offset, see
 .PD
 .PP
 .SH FILES
 .PD
 .PP
 .SH FILES
-.ta \w'/dev/mem  'u
+.ta \w'/dev/kmem  'u
 /unix  namelist
 .br
 /unix  namelist
 .br
-/dev/mem       default source of tables
+/dev/kmem      default source of tables
 .SH SEE ALSO
 ps(1), stat(2), filsys(5)
 .br
 .SH SEE ALSO
 ps(1), stat(2), filsys(5)
 .br
diff --git a/usr/man/man1/pubindex.1 b/usr/man/man1/pubindex.1
deleted file mode 100644 (file)
index 8aae75b..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-.TH PUBINDEX 1 local
-.SH NAME
-pubindex \- make inverted bibliographic index
-.SH SYNOPSIS
-.B pubindex
-[ file ] ...
-.SH DESCRIPTION
-.I Pubindex
-makes a hashed inverted index to
-the named
-.I files
-for use by
-.IR refer (1).
-The
-.I files
-contain bibliographic references separated by blank lines.
-A bibliographic reference is a set of lines
-that contain bibliographic information fields.
-Each field starts on a line beginning with a `%', followed
-by a key-letter, followed by a blank, and followed by the
-contents of the field, which continues until the next line
-starting with `%'.
-The most common key-letters and the corresponding fields are:
-.IP
-.nf
-A      Author name
-B      Title of book containing article referenced
-C      City
-D      Date
-d      Alternate date
-E      Editor of book containing article referenced
-G      Government (CFSTI) order number
-I      Issuer (publisher)
-J      Journal
-K      Other keywords to use in locating reference
-M      Technical memorandum number
-N      Issue number within volume
-O      Other commentary to be printed at end of reference
-P      Page numbers
-R      Report number
-r      Alternate report number
-T      Title of article, book, etc.
-V      Volume number
-X      Commentary unused by \fIpubindex\fR
-.fi
-.PP
-Except for `A', each field should only be given once.
-Only relevant fields should be supplied.
-An example is:
-.IP
-.nf
-%T 5-by-5 Palindromic Word Squares
-%A M. D. McIlroy
-%J Word Ways
-%V 9
-%P 199-202
-%D 1976
-.fi
-.SH FILES
-.I "x.ia, x.ib, x.ic"
-where 
-.I x
-is the first argument.
-.SH SEE ALSO
-refer(1)
index 8cda5ca..766f878 100644 (file)
@@ -30,7 +30,7 @@ Print count of number of files as well as space owned by each user.
 .SH FILES
 Default file system varies with system.
 .br
 .SH FILES
 Default file system varies with system.
 .br
-/etc/passwd to get user names
+/etc/passwd    to get user names
 .SH "SEE ALSO"
 ls(1), du(1)
 .SH BUGS
 .SH "SEE ALSO"
 ls(1), du(1)
 .SH BUGS
diff --git a/usr/man/man1/ranlib.1 b/usr/man/man1/ranlib.1
deleted file mode 100644 (file)
index 60bed02..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-.TH RANLIB 1
-.SH NAME
-ranlib \- convert archives to random libraries
-.SH SYNOPSIS
-.B ranlib
-archive ...
-.SH DESCRIPTION
-.I Ranlib
-converts each
-.I archive
-to a form which can be loaded
-more rapidly by the loader,
-by adding a table of contents named
-.B __.SYMDEF
-to the beginning of the archive.
-It uses
-.IR ar (1)
-to reconstruct the archive,
-so that sufficient temporary file space must
-be available in the file system containing the
-current directory.
-.SH SEE ALSO
-ld(1), ar(1)
-.SH BUGS
-Because generation of a library by
-.I ar
-and randomization by
-.I ranlib
-are separate,
-phase errors are possible.
-The loader
-.I ld
-warns when the modification date of
-a library is more recent than
-the creation of its dictionary;
-but this means you get the warning even if you
-only copy the library.
index 7dab36e..741ed77 100644 (file)
@@ -29,8 +29,8 @@ while (condition) statement
 for (expression; condition; expression) statement
 do limits statement
 repeat statement [ until (condition) ]
 for (expression; condition; expression) statement
 do limits statement
 repeat statement [ until (condition) ]
-break [n]
-next [n]
+break
+next
 .LP
 and some syntactic sugar to make programs easier to read and write:
 .TP
 .LP
 and some syntactic sugar to make programs easier to read and write:
 .TP
@@ -53,21 +53,6 @@ include:
 include filename
 .PP
 .fi
 include filename
 .PP
 .fi
-The option
-.B \-h
-causes quoted strings to be turned into
-27H constructs.
-.B \-C
-copies comments to the output, and attempts
-to format it neatly.
-Normally, continuation lines are marked with a &
-in column 1;
-the option
-.B \-6x
-makes the continuation character
-.B x
-and places it in column 6.
-.PP
 .I Ratfor
 is best used with
 .IR f77 (1).
 .I Ratfor
 is best used with
 .IR f77 (1).
diff --git a/usr/man/man1/rc.1 b/usr/man/man1/rc.1
new file mode 100644 (file)
index 0000000..2206be2
--- /dev/null
@@ -0,0 +1,106 @@
+.TH RC 1 
+.SH NAME
+rc \- Ratfor compiler
+.SH SYNOPSIS
+.B rc
+[ option ] [ file ] ...
+.SH DESCRIPTION
+.I Rc
+invokes the Ratfor preprocessor on a set of Ratfor source files.
+It accepts three types of arguments:
+.PP
+Arguments whose names end with `.r' are taken to be
+Ratfor source programs; they are 
+preprocessed into Fortran and compiled.
+Each subroutine or function `name' is placed on a separate file
+.I name.f,
+and its object code is left on
+.IR name.o .
+The main routine is on
+.I MAIN.f
+and
+.I MAIN.o;
+block data subprograms go on
+.I BLOCKDATA?.f
+and
+.IR BLOCKDATA?.o .
+The files resulting from a `.r' file are
+loaded into a single object file
+.I file.o,
+and the intermediate object and Fortran files are removed.
+.PP
+The following flags are interpreted by
+.IR rc .
+See
+.I ld
+and
+.IR  fc (1)
+for other flags.
+.TP 6
+.B  \-c
+Suppresses the loading phase of the compilation,
+as does any error in anything.
+.TP 6
+.B  \-f
+Save Fortran intermediate files.
+This is primarily for debugging.
+.TP 6
+.B  \-r
+Ratfor only; don't try to compile the Fortran.
+This implies
+.B \-f
+and
+.B \-c.
+.TP 6
+.B  \-v
+Don't list intermediate file names while compiling.
+.TP 6
+.B \-C
+Preserve comments in output, and format esthetically (indentation, mostly).
+.TP 6
+.BR \-6 x
+Place continuation character
+.IT x
+in column 6, instead of non-standard convention used
+by
+.IR fc (1).
+.PP
+Arguments whose names end with `.f' are taken to be
+Fortran source programs;
+they are compiled in the normal manner.
+(Only one Fortran routine is allowed in a `.f' file.)
+.PP
+Other arguments
+are taken
+to be either loader flag arguments, or Fortran-compatible
+object programs, typically produced by an earlier
+.I rc
+run,
+or perhaps libraries of Fortran-compatible routines.
+These programs, together with the results of any
+compilations specified, are loaded
+to produce an executable program with name
+.BR a.out .
+.SH FILES
+ratjunk                temporary
+.br
+/usr/fort/fc1  Fortran compiler
+.SH "SEE ALSO"
+B. W. Kernighan,
+.IR "RATFOR \- A preprocessor for a Rational Fortran" ,
+Bell Laboratories CSTR #55, 1977.
+.br
+fc(1) for Fortran flags and error messages
+.br
+ld(1) for loader flags
+.br
+f77(1) for the latest Fortran
+.SH DIAGNOSTICS
+Yes, both from
+.I rc
+itself and from Fortran.
+.SH BUGS
+#define and #include lines in
+`.f' files are not processed.
+.br
+fc(1) is unsupported.
index fe67f71..bf6dfb1 100644 (file)
@@ -43,8 +43,6 @@ Each file on the
 tape named by an 
 .I argument
 is extracted.
 tape named by an 
 .I argument
 is extracted.
-The file name has all `mount' prefixes removed;
-for example, /usr/bin/lpr is named /bin/lpr on the tape.
 The file extracted is placed in a file with a numeric name
 supplied by
 .I restor
 The file extracted is placed in a file with a numeric name
 supplied by
 .I restor
diff --git a/usr/man/man1/roff.1 b/usr/man/man1/roff.1
deleted file mode 100644 (file)
index a2eda76..0000000
+++ /dev/null
@@ -1,318 +0,0 @@
-.TH ROFF 1 
-.SH NAME
-roff  \-  format text
-.SH SYNOPSIS
-.B roff
-[ \fB+\fIn\fR ] [ \fB\-\fIn\fR ] [
-.B \-s
-] [
-.B \-h
-] file ...
-.PP
-.B nroff \-mr
-[ option ] ... file ...
-.br
-.B troff \-mr
-[ option ] ... file ...
-.SH DESCRIPTION
-.I Roff
-formats text according to control lines embedded
-in the text in the given files.
-Encountering a nonexistent file terminates printing.
-Incoming inter-terminal messages are turned off during printing.
-The optional flag arguments mean:
-.br
-.ns
-.TP 5
-.BI + n
-Start printing at the first page with number
-.IR n .
-.br
-.ns
-.TP 5
-.BI \- n
-Stop printing at the first page numbered higher
-than
-.IR n .
-.br
-.ns
-.TP 5
-.B  \-s
-Stop before each page (including the first)
-to allow paper manipulation;
-resume on receipt of an interrupt signal.
-.br
-.ns
-.TP 5
-.B  \-h
-Insert tabs in the output stream to replace
-spaces whenever appropriate.
-.PP
-.DT
-Input consists of intermixed
-.I "text lines,"
-which contain information to be formatted, and
-.I "request lines,"
-which contain instructions about how to format
-it.
-Request lines begin with a distinguished
-.I "control character,"
-normally a period.
-.PP
-Output lines may be
-.I filled
-as nearly as possible with words without regard to
-input lineation.
-Line
-.I breaks
-may be caused at specified places by
-certain commands, or by the appearance of an
-empty input line or an input line beginning with a space.
-.PP
-The capabilities of
-.I roff
-are specified in the attached Request Summary.
-Numerical values are denoted there by n or +n,
-titles by t, and single characters by c.
-Numbers denoted +n may be signed + or \-,
-in which case they signify relative changes to
-a quantity, otherwise they signify
-an absolute resetting.
-Missing n fields are ordinarily taken to be 1,
-missing t fields to be empty, and c fields to shut off
-the appropriate special interpretation.
-.PP
-Running titles usually appear at top and bottom of every
-page.
-They are set by requests like
-.PP
-.in +10
-.if t \&.he \(fmpart1\(fmpart2\(fmpart3\(fm
-.if n \&.he 'part1'part2'part3'
-.in -10
-.PP
-Part1 is left justified, part2 is centered,
-and part3 is right justified on the page.
-Any % sign in a title is replaced by the current
-page number.
-Any nonblank may serve as a quote.
-.PP
-ASCII tab characters are replaced in the input by a
-.I "replacement character,"
-normally a space,
-according to the
-column settings given by a .ta command.
-(See .tr for how to convert this character on output.)
-.PP
-Automatic hyphenation of filled output is done
-under control of .hy.
-When a word contains a designated
-.I "hyphenation character,"
-that character disappears from the output and
-hyphens can be introduced into
-the word at the marked places only.
-.PP
-The
-.B \-mr
-option of
-.I nroff
-or 
-.IR troff (1)
-simulates
-.I roff
-to the greatest extent possible.
-.SH FILES
-/usr/lib/suftab        suffix hyphenation tables
-.br
-/tmp/rtm?      temporary
-.br
-.SH BUGS
-.I Roff
-is the simplest of the text formatting
-programs, and is utterly frozen.
-.bp
-.tc |
-.tr |
-.in 0
-.ce
-REQUEST SUMMARY
-.PP
-.ul
-.ta \w'.tr cdef.. 'u +\w'Break 'u +\w'Initial 'u
-.di x
-                       \ka
-.br
-.di
-.in \nau
-.ti 0
-Request        Break   Initial Meaning
-.na
-.ti 0
-.li
-.ad    yes     yes     Begin adjusting right margins.
-.ti 0
-.li
-.ar    no      arabic  Arabic page numbers.
-.ti 0
-.li
-.br    yes     \-      Causes a line break \*- the filling of
-the current line is stopped.
-.ti 0
-.li
-.bl|n  yes     \-      Insert of n blank lines, on new page if necessary.
-.ti 0
-.li
-.bp|+n yes     n=1     Begin new page and number it n; no n means `+1'.
-.ti 0
-.li
-.cc|c  no      c=.     Control character becomes `c'.
-.ti 0
-.li
-.ce|n  yes     \-      Center the next n input lines,
-without filling.
-.ti 0
-.li
-.de|xx no      \-      Define parameterless macro 
-to be invoked by request `.xx'
-(definition ends on line beginning `\fB..\fR').
-.ti 0
-.li
-.ds    yes     no      Double space; same as `.ls 2'.
-.ti 0
-.li
-.ef|t  no      t=\*a\*a\*a\*a  Even foot title becomes t.
-.ti 0
-.li
-.eh|t  no      t=\*a\*a\*a\*a  Even head title becomes t.
-.ti 0
-.li
-.fi    yes     yes     Begin filling output lines.
-.ti 0
-.li
-.fo    no      t=\*a\*a\*a\*a  All foot titles are t.
-.ti 0
-.li
-.hc|c  no      none    Hyphenation character becomes `c'.
-.ti 0
-.li
-.he|t  no      t=\*a\*a\*a\*a  All head titles are t.
-.ti 0
-.li
-.hx    no      \-      Title lines are suppressed.
-.ti 0
-.li
-.hy|n  no      n=1     Hyphenation is done, if n=1;
-and is not done, if n=0.
-.ti 0
-.li
-.ig    no      \-      Ignore input lines through
-a line beginning with `\fB..\fR'.
-.ti 0
-.li
-.in|+n yes     \-      Indent n spaces from left margin.
-.ti 0
-.li
-.ix +n no      \-      Same as `.in' but without break.
-.ti 0
-.li
-.li|n  no      \-      Literal, treat next n lines as text.
-.ti 0
-.li
-.ll|+n no      n=65    Line length including indent is n characters.
-.ti 0
-.li
-.ls|+n yes     n=1     Line spacing set to n lines per output line.
-.ti 0
-.li
-.m1|n  no      n=2     Put n blank lines between the top
-of page and head title.
-.ti 0
-.li
-.m2|n  no      n=2     n blank lines put between head title
-and beginning of text on page.
-.ti 0
-.li
-.m3|n  no      n=1     n blank lines put between end of
-text and foot title.
-.ti 0
-.li
-.m4|n  no      n=3     n blank lines put between the foot title
-and the bottom of page.
-.ti 0
-.li
-.na    yes     no      Stop adjusting the right margin.
-.ti 0
-.li
-.ne|n  no      \-      Begin new page, if n output lines
-cannot fit on present page.
-.ti 0
-.li
-.nn|+n no      \-      The next n output lines are not numbered.
-.ti 0
-.li
-.n1    no      no      Add 5 to page offset;
-number lines in margin from 1 on each page.
-.ti 0
-.li
-.n2|n  no      no      Add 5 to page offset;
-number lines from n;
-stop if n=0.
-.ti 0
-.li
-.ni|+n no      n=0     Line numbers are indented n.
-.ti 0
-.li
-.nf    yes     no      Stop filling output lines.
-.ti 0
-.li
-.nx|file       \-      Switch input to `file'.
-.ti 0
-.li
-.of|t  no      t=\*a\*a\*a\*a  Odd foot title becomes t.
-.ti 0
-.li
-.oh|t  no      t=\*a\*a\*a\*a  Odd head title becomes t.
-.ti 0
-.li
-.pa|+n yes     n=1     Same as `.bp'.
-.ti 0
-.li
-.pl|+n no      n=66    Total paper length taken to be n lines.
-.ti 0
-.li
-.po|+n no      n=0     Page offset.
-All lines are preceded by n spaces.
-.ti 0
-.li
-.ro    no      arabic  Roman page numbers.
-.ti 0
-.li
-.sk|n  no      \-      Produce n blank pages starting next page.
-.ti 0
-.li
-.sp|n  yes     \-      Insert block of n blank lines,
-except at top of page.
-.ti 0
-.li
-.ss    yes     yes     Single space output lines,
-equivalent to `.ls 1'.
-.ti 0
-.li
-.ta|n|n..              \-      Pseudotab settings.
-Initial tab settings are columns 9 17 25 ...
-.ti 0
-.li
-.tc|c  no      space   Tab replacement character becomes `c'.
-.ti 0
-.li
-.ti|+n yes     \-      Temporarily indent next output
-line n spaces.
-.ti0
-.li
-.tr|cdef..     no      \-      Translate c into d, e into f, etc.
-.ti0
-.li
-.ul|n  no      \-      Underline the letters and numbers
-in the next n input lines.
-.br
-.tr ||
index 33bc88f..5fcc2f0 100644 (file)
@@ -31,7 +31,7 @@ which contains a count of the
 number of times each command was called and the time resources
 consumed.
 This condensation is desirable because on a large system
 number of times each command was called and the time resources
 consumed.
 This condensation is desirable because on a large system
-.I acct
+.I /usr/adm/acct
 can grow by 100 blocks per day.
 The summary file is read before the accounting file,
 so the reports include all available information.
 can grow by 100 blocks per day.
 The summary file is read before the accounting file,
 so the reports include all available information.
@@ -39,7 +39,7 @@ so the reports include all available information.
 If a file name is given as the last argument,
 that file will be treated
 as the accounting file;
 If a file name is given as the last argument,
 that file will be treated
 as the accounting file;
-.I sha
+.I /usr/adm/acct
 is the default.
 There are zillions of options:
 .PP
 is the default.
 There are zillions of options:
 .PP
@@ -94,7 +94,7 @@ then type the name of
 each command used
 .I n
 times or fewer.
 each command used
 .I n
 times or fewer.
-Await a reply from the typewriter;
+Await a reply from the terminal;
 if it begins with `y', add the command to
 the category `**junk**.'
 This is used to strip out garbage.
 if it begins with `y', add the command to
 the category `**junk**.'
 This is used to strip out garbage.
diff --git a/usr/man/man1/sdb.1 b/usr/man/man1/sdb.1
new file mode 100644 (file)
index 0000000..7e4d9b4
--- /dev/null
@@ -0,0 +1,289 @@
+.TH SDB 1 UNIX/32V
+.SH NAME
+sdb \- C symbolic debugger
+.SH SYNOPSIS
+.B sdb
+[ objfil [ corfil [ directory ] ] ]
+.SH DESCRIPTION
+.I Sdb
+is a symbolic debugger for C programs.
+It may be used to examine their files and to provide
+a controlled environment for their execution.
+.PP
+.I Objfil
+is an executable C program file
+which has been compiled with the -g (debug) option.
+The default for
+.I objfil
+is
+.B  a.out.
+.I Corfil
+is assumed to be a core image file produced after
+executing
+.IR objfil ;
+the default for
+.I corfil
+is
+.B  core.
+The core file need not be present.
+.PP
+It is useful to know that at any time there is a
+.I "current line"
+and
+.I "current file."
+If
+.I corfil
+exists then they are initially set to the line and file
+containing the source statement at which the process terminated or stopped.
+Otherwise, they are set to the first line in main.
+The current line and file may be changed with the source file
+examination commands.
+.PP
+Names of variables are written just as they are in C.
+Variables local to a procedure may be accessed using the form
+`procedure:variable'.
+If no procedure name is given, the procedure containing the
+current line is used by default.
+It is also possible to refer to structure members as `variable.member',
+pointers to structure members as `variable\(mi>member' and array elements
+as `variable[number]'.
+Combinations of these forms may also be used.
+.PP
+It is also possible to specify a variable by its address.
+All forms of integer constants which are valid in C may be used, so that
+addresses may be input in decimal, octal or hexadecimal.
+.PP
+Line numbers in the source program are referred to as `filename:number'
+or `procedure:number'.
+In either case the number is relative to the beginning of the file.
+If no procedure or file name is given,
+the current file is used by default.
+.sp 1
+.PP
+The commands for examining data in the program are:
+.TP 5
+.B t
+Print a stack trace of the terminated or stopped program.
+.TP 5
+variable/\fIm\fP
+Print the value of variable according to format 
+.I m.
+If 
+.I m
+is omitted,
+sdb chooses a format suitable for the variable's type
+as declared in the C program.
+Legal values for
+.I m
+are
+.RS
+.TP
+.BI c
+character
+.br
+.ns
+.TP
+.BI h
+16 bit integer in decimal
+.br
+.ns
+.TP
+.BI d
+int size integer in decimal
+.br
+.ns
+.TP
+.BI l
+32 bit integer in decimal
+.br
+.ns
+.TP
+.BI u
+int size bit integer in decimal, unsigned
+.br
+.ns
+.TP
+.BI o
+int size bit integer in octal
+.br
+.ns
+.TP
+.BI x
+int size bit integer in hexadecimal
+.br
+.ns
+.TP
+.BI f
+32 bit single precision floating point
+.br
+.ns
+.TP
+.BI g
+64 bit double precision floating point
+.br
+.ns
+.TP
+.BI s
+Assume variable is a string pointer and print characters until a null is 
+reached.
+.br
+.ns
+.TP
+.BI a
+Print characters starting at the variable's address until a null
+is reached.
+.RE
+.sp 1
+.ti +5
+.br
+The last variable may be redisplayed with the command `./'.
+.TP 5
+variable\fB=\fP
+Print the address of variable.
+.TP 5
+variable\fB!\fPvalue
+Set the variable to the given value.
+The value may be a number, character constant or a variable.
+.sp 1
+.PP
+The commands for examining source files are
+.TP 5
+\fBe\fP procedure
+.br
+.ns
+.TP 5
+\fBe\fP filename.c
+Set the current file to
+the file containing the named procedure
+or the named filename.
+Set the current line to the first line in the named
+procedure or file.
+All source files are assumed to be in
+.I directory.
+The default for 
+.I directory
+is the working directory.
+If no procedure or file name is given, the current procedure and file names
+are reported.
+.TP 5
+\fB/\fPregular expression\fB/\fP
+Search forward from the current line for a line containing
+a string matching the regular expression as in ed (1).
+The trailing `/' may be elided.
+.TP 5
+\fB?\fPregular expression\fB?\fP
+Search backward from the current line for a line containing
+a string matching the regular expression as in ed (1).
+The trailing `?' may be elided.
+.TP 5
+.B p
+Print the current line.
+.TP 5
+.B z
+Print the current line followed by the next 9 lines.
+Set the current line to the last line printed.
+.TP 5
+.B control-D
+Scroll.
+Print the next 10 lines.
+Set the current line to the last line printed.
+.TP 5
+.B w
+Window.
+Print the 10 lines around the current line.
+.TP 5
+number
+Set the current line to the given line number.
+Print the new current line.
+.TP 5
+\fIcount\fB +\fR
+Advance the current line by \fIcount\fP lines.
+Print the new current line.
+.TP 5
+\fIcount\fB \(mi\fR
+Retreat the current line by \fIcount\fP lines.
+Print the new current line.
+.TP 5
+.B newline
+Advance the current line by 1 line.
+Print the new current line.
+.sp 1
+.PP
+The commands for controlling the execution of the source program are
+.TP 5
+\fIcount\fB r \fIargs\fR
+Run the program with the given arguments.
+An argument beginning with `<' or `>' causes redirection for the
+standard input or output respectively.
+If \fIcount\fP is given,
+it specifies the number of breakpoints to be ignored.
+.TP 5
+\fIcount\fB c\fR
+Continue after a breakpoint or interrupt.
+If \fIcount\fP is given,
+it specifies the number of breakpoints to be ignored.
+.TP 5
+\fIcount\fB s\fR
+Run the program through \fIcount\fP lines.
+\fICount\fP defaults to one if it is omitted.
+.TP 5
+.B n
+Run the program until it reaches the next line.
+.TP 5
+procedure\fB(\fParg1,arg2,...\fB)\fP
+.br
+.ns
+.TP 5
+procedure\fB(\fParg1,arg2,...\fB)/\fP\fIm\fP
+Execute the named procedure with the given arguments.
+Arguments can be integer, character or string constants
+or names of variables accessible from the current procedure.
+The current implementation is limited to 14 arguments and a total
+length of 448 for string constants.
+The second form causes the value returned by the procedure to be
+printed according to format \fIm\fP.
+If no format is given, it defaults to `d'.
+.TP 5
+\fIlinenumber\fB b\fR
+Set a breakpoint at the given line.
+If a procedure name without a line number is given (e.g. `proc:'),
+a breakpoint is placed at the first line in the procedure.
+If no \fIlinenumber\fP is given, a list of the currently active
+breakpoints is printed.
+.TP 5
+\fIlinenumber\fB d\fR
+Delete a breakpoint at the given line.
+If no \fIlinenumber\fP is given then the breakpoints are deleted interactively:
+Each breakpoint location is printed and a line is read from the standard input.
+If the line begins with a `y' or `d' then the breakpoint is deleted.
+.sp 1
+.PP
+Miscellaneous commands.
+.TP 5
+.B q
+Exit the debugger.
+.TP 5
+\fB! \fIcommand\fR
+The command is interpreted by sh (1).
+.sp 1
+.PP
+The following commands also exist and are intended only for
+debugging the debugger.
+.TP 5
+.B a
+Toggle debug output.
+.TP 5
+.B x
+Print a list of procedures and files being debugged.
+.SH FILES
+a.out
+.br
+core
+.SH SEE\ ALSO
+adb(1)
+.SH DIAGNOSTICS
+Comments about inaccessible files, syntax errors,
+abnormal termination of commands, etc.
+.SH BUGS
+Undoubtedly,
+some features are actually bugs and vice versa.
index 673893e..57f07b6 100644 (file)
@@ -171,17 +171,12 @@ Append the contents of the pattern space to the hold space.
 .ns
 .TP
 .I text
 .ns
 .TP
 .I text
+.br
 Insert.
 Place
 .I text
 on the standard output.
 .TP
 Insert.
 Place
 .I text
 on the standard output.
 .TP
-(2)\|l
-List the pattern space on the standard output in an
-unambiguous form.
-Non-printing characters are spelled in two digit ascii,
-and long lines are folded.
-.TP
 (2)\|n
 Copy the pattern space to the standard output.
 Replace the pattern space with the next line of input.
 (2)\|n
 Copy the pattern space to the standard output.
 Replace the pattern space with the next line of input.
index 50f8648..a66882a 100644 (file)
@@ -1,41 +1,17 @@
-.ds OK [\|
-.ds CK \|]
-.ds LT \s-2<\s0
-.ds GT \s-2>\s0
-.ds LE \s-2<\s0
-.ds ST *
 .TH SH 1
 .SH NAME
 .TH SH 1
 .SH NAME
-sh,
-for,
-case,
-if,
-while,
-.BR : ,
-.BR . ,
-break,
-continue,
-cd,
-eval,
-exec,
-exit,
-export,
-login,
-newgrp,
-read,
-readonly,
-set,
-shift,
-times,
-trap,
-umask,
-wait
-\- command language
+sh, for, case, if, while, \fB:\fP, \fB.\fP, break, continue, cd, eval, exec, exit, export, login, newgrp, read, readonly, set, shift, times, trap, umask, wait \- command language
 .SH SYNOPSIS
 .B sh
 [
 .B \-ceiknrstuvx
 ] [ arg ] ...
 .SH SYNOPSIS
 .B sh
 [
 .B \-ceiknrstuvx
 ] [ arg ] ...
+.ds OK [\|
+.ds CK \|]
+.ds LT \s-2<\s0
+.ds GT \s-2>\s0
+.ds LE \s-2<\s0
+.ds ST *
 .SH DESCRIPTION
 .I Sh
 is a command programming language
 .SH DESCRIPTION
 .I Sh
 is a command programming language
@@ -984,7 +960,7 @@ Otherwise, the shell returns the exit status of
 the last command executed (see also
 .BR exit ).
 .SH BUGS
 the last command executed (see also
 .BR exit ).
 .SH BUGS
-If \*(LT\*(LT is used to provide standard input to an asynchronous
+IF \*(LT\*(LT is used to provide standard input to an asynchronous
 process invoked by &,
 the shell gets mixed up about naming the input document.
 A garbage file /tmp/sh* is created, and the shell complains about
 process invoked by &,
 the shell gets mixed up about naming the input document.
 A garbage file /tmp/sh* is created, and the shell complains about
index a805978..a3fbd15 100644 (file)
@@ -1,4 +1,4 @@
-.TH SIZE 1 
+.TH SIZE 1 "UNIX/32V"
 .SH NAME
 size \- size of an object file
 .SH SYNOPSIS
 .SH NAME
 size \- size of an object file
 .SH SYNOPSIS
@@ -9,7 +9,7 @@ size \- size of an object file
 prints the (decimal) number of bytes
 required by the
 text, data, and bss
 prints the (decimal) number of bytes
 required by the
 text, data, and bss
-portions, and their sum in octal and decimal,
+portions, and their sum in hex and decimal,
 of each object-file argument.
 If no file is specified,
 .B a.out
 of each object-file argument.
 If no file is specified,
 .B a.out
index 546ce20..bca5929 100644 (file)
@@ -1,4 +1,4 @@
-.TH SLEEP 1 
+.TH SLEEP 1 UNIX/32V
 .SH NAME
 sleep \- suspend execution for an interval
 .SH SYNOPSIS
 .SH NAME
 sleep \- suspend execution for an interval
 .SH SYNOPSIS
@@ -29,4 +29,4 @@ or to execute a command every so often, as in:
 alarm(2), sleep(3)
 .SH BUGS
 .I Time
 alarm(2), sleep(3)
 .SH BUGS
 .I Time
-must be less than 65536 seconds.
+must be less than 2147483647 seconds.
index ccc7c47..5b62e72 100644 (file)
@@ -161,7 +161,7 @@ unique representative from a set of equal lines predictable.
 .ti +8
 sort \-um +0 \-1 dates
 .SH FILES
 .ti +8
 sort \-um +0 \-1 dates
 .SH FILES
-/usr/tmp/stm*, /tmp/*: first and second tries for
+/usr/tmp/stm*, /tmp/*  first and second tries for
 temporary files
 .SH "SEE ALSO"
 uniq(1),
 temporary files
 .SH "SEE ALSO"
 uniq(1),
index aaa0c8b..357457a 100644 (file)
@@ -17,7 +17,7 @@ replace the original Fortran.
 Statement numbers appear only where still necessary.
 Cosmetic changes are made, including changing Hollerith strings
 into quoted strings
 Statement numbers appear only where still necessary.
 Cosmetic changes are made, including changing Hollerith strings
 into quoted strings
-and relational operators into symbols (.e.g. `.GT.' into `>').
+and relational operators into symbols (.e.g. ".GT." into ">").
 The output is appropriately indented.
 .PP
 The following options may occur in any order.
 The output is appropriately indented.
 .PP
 The following options may occur in any order.
@@ -26,8 +26,8 @@ The following options may occur in any order.
 Input is accepted in standard format, i.e.
 comments are specified by a c, C, or * in column 1, and continuation lines
 are specified by a nonzero, nonblank character in column 6.
 Input is accepted in standard format, i.e.
 comments are specified by a c, C, or * in column 1, and continuation lines
 are specified by a nonzero, nonblank character in column 6.
-Normally, a statement whose first nonblank character
-is not alphanumeric is treated as a continuation.
+Normally input is in the form accepted by 
+.IR f77 (1)
 .TP
 .B  \-i
 Do not turn computed goto statements into
 .TP
 .B  \-i
 Do not turn computed goto statements into
@@ -41,8 +41,8 @@ non-Ratfor switch of the form
 .IP
 .nf
 .ta 5 7
 .IP
 .nf
 .ta 5 7
-switch {
-               case pred1: code
+switch
+       {       case pred1: code
                case pred2: code
                case pred3: code
                default: code
                case pred2: code
                case pred3: code
                default: code
@@ -61,6 +61,19 @@ Generate goto's instead of multilevel break statements.
 .B  \-n
 Generate goto's instead of multilevel next statements.
 .TP
 .B  \-n
 Generate goto's instead of multilevel next statements.
 .TP
+.BI \-t n
+Make
+the nonzero integer
+.I n
+the lowest valued label in the output program
+(default 10).
+.TP
+.BI \-c n
+Increment successive labels
+in the output program
+by the nonzero integer
+.I n
+(default 1).
 .TP
 .BI \-e n
 If 
 .TP
 .BI \-e n
 If 
@@ -71,11 +84,12 @@ lead to an iteration of the loop.
 If
 .I n
 is nonzero,
 If
 .I n
 is nonzero,
-admit code segments with fewer than
-.I n
-statements to a loop
+admit a small code segments to a loop
 if otherwise the loop would have exits to several places including the segment,
 and the segment can be reached only from the loop.
 if otherwise the loop would have exits to several places including the segment,
 and the segment can be reached only from the loop.
+`Small' is close to, but not equal to, the
+number of statements in the code segment.
+Values of n under 10 are suggested.
 .SH FILES
 /tmp/struct*
 .br
 .SH FILES
 /tmp/struct*
 .br
@@ -83,18 +97,14 @@ and the segment can be reached only from the loop.
 .SH SEE ALSO
 f77(1)
 .SH BUGS
 .SH SEE ALSO
 f77(1)
 .SH BUGS
-Struct knows Fortran 66 syntax, but not full Fortran 77
-(alternate returns, IF...THEN...ELSE, etc.)
+Struct knows Fortran 66 syntax, but not full Fortran 77.
 .br
 If an input Fortran program contains identifiers which
 are reserved words in Ratfor, the structured
 version of the program
 will not be a valid Ratfor program.
 .br
 .br
 If an input Fortran program contains identifiers which
 are reserved words in Ratfor, the structured
 version of the program
 will not be a valid Ratfor program.
 .br
-Extended range DO's generate cryptic errors.
-.br
-Columns 73-80 are not special even when
-.B \-s
-is in effect.
+The labels generated cannot go above 32767.
 .br
 .br
-Will not generate Ratfor FOR statements.
+If you get a goto without a target, try
+.B \-e .
index 769ebb1..9a2e0d3 100644 (file)
@@ -107,21 +107,15 @@ reset erase and kill characters back to normal # and @
 .br
 .ns
 .TP 
 .br
 .ns
 .TP 
-.BI erase  \ c\fR
+.BI erase \ c\fR
 set erase character to
 .IR c .
 set erase character to
 .IR c .
-.I C
-can be of the form 
-.I `^X'
-which is interpreted as a `control X'.
 .br
 .ns
 .TP 
 .br
 .ns
 .TP 
-.BI kill  \ c\fR
+.BI kill \ c\fR
 set kill character to
 .IR c .
 set kill character to
 .IR c .
-.I `^X'
-works here also.
 .br
 .ns
 .TP
 .br
 .ns
 .TP
index cae6821..53e02d9 100644 (file)
@@ -36,7 +36,7 @@ function implies this.
 The named files are extracted from the tape.
 If the named file matches a directory whose contents 
 had been written onto the tape, this directory is (recursively) extracted.
 The named files are extracted from the tape.
 If the named file matches a directory whose contents 
 had been written onto the tape, this directory is (recursively) extracted.
-The owner, modification time, and mode are restored (if possible).
+The owner and mode are restored (if possible).
 If no file argument is given, the entire content of the
 tape is extracted.
 Note that if multiple entries specifying the same file
 If no file argument is given, the entire content of the
 tape is extracted.
 Note that if multiple entries specifying the same file
@@ -116,22 +116,13 @@ records. The default is 1, the maximum is 20. This option
 should only be used with raw magnetic tape archives (See
 .B f
 above).
 should only be used with raw magnetic tape archives (See
 .B f
 above).
-The block size is determined automatically when reading
-tapes (key letters `x' and `t').
 .TP 10
 .B l
 tells
 .I tar
 to complain if it cannot resolve all of the links
 to the files dumped. If this is not specified, no
 .TP 10
 .B l
 tells
 .I tar
 to complain if it cannot resolve all of the links
 to the files dumped. If this is not specified, no
-error messages are printed.
-.TP 10
-.B m
-tells
-.I tar
-to not restore the modification times.
-The mod time
-will be the time of extraction.
+error meesages are printed.
 .PP
 .SH FILES
 /dev/mt?
 .PP
 .SH FILES
 /dev/mt?
index e476140..250457e 100644 (file)
@@ -80,4 +80,7 @@ plot(1)
 .SH BUGS
 Font distinctions are lost.
 .br
 .SH BUGS
 Font distinctions are lost.
 .br
+.I tc's
+character set is limited to ASCII in just one size.
+.br
 The aspect ratio option is unbelievable.
 The aspect ratio option is unbelievable.
index c744041..ae95867 100644 (file)
@@ -26,7 +26,7 @@ true if the file exists and is writable.
 true if the file exists and is not a directory.
 .TP 
 .BR \-d " file"
 true if the file exists and is not a directory.
 .TP 
 .BR \-d " file"
-true if the file exists and is a directory.
+true if the file exists exists and is a directory.
 .TP 
 .BR \-s " file"
 true if the file exists and has a size greater than zero.
 .TP 
 .BR \-s " file"
 true if the file exists and has a size greater than zero.
index 45135e9..9f7848a 100644 (file)
@@ -13,7 +13,7 @@ spent in the system, and the time spent in execution
 of the command.
 Times are reported in seconds.
 .PP
 of the command.
 Times are reported in seconds.
 .PP
-The execution time can depend on what kind of memory
+On a PDP-11, the execution time can depend on what kind of memory
 the program happens to land in;
 the user time in MOS is often half what it is in core.
 .PP
 the program happens to land in;
 the user time in MOS is often half what it is in core.
 .PP
index ab83e32..8564eb2 100644 (file)
@@ -178,7 +178,6 @@ The integrity of that file may be secured by making
 a `set user-id' program.
 .SH FILES
 .ta \w'/usr/lib/tmac/tmac.*  'u
 a `set user-id' program.
 .SH FILES
 .ta \w'/usr/lib/tmac/tmac.*  'u
-/usr/lib/suftab        suffix hyphenation tables
 .br
 /tmp/ta*       temporary file
 .br
 .br
 /tmp/ta*       temporary file
 .br
@@ -207,6 +206,6 @@ col(1), tk(1)
 .RI ( nroff
 only)
 .br
 .RI ( nroff
 only)
 .br
-tc(1), gcat(1)
+tc(1)
 .RI ( troff
 only)
 .RI ( troff
 only)
diff --git a/usr/man/man1/uudiff.1c b/usr/man/man1/uudiff.1c
new file mode 100644 (file)
index 0000000..269ff8f
--- /dev/null
@@ -0,0 +1,81 @@
+.TH UUDIFF 1C 
+.SH NAME
+uudiff \- directory comparison between machines
+.SH SYNOPSIS
+.B uudiff
+[ -d ]
+local-name remote-name
+.SH DESCRIPTION
+.I Uudiff
+compares the files in the directory
+.I local-name
+and the directory
+.I remote-name,
+(where
+.I remote-name
+may be of the form
+.I system-name!directory-name
+and
+.I system-name
+is a 
+.I uucp
+Unix name).
+It reports (via mail)
+which files are added, deleted, or changed, and provides
+a
+.I diff(1)
+of altered printable files.
+.PP
+If a part of
+.I remote-name
+is omitted
+(either the system or the directory)
+the corresponding part of
+.I local-name
+is used.
+If
+.I local-name
+is a file, rather than a directory,
+.I remote-name
+is also assumed to be a file and the program degenerates into
+.IR diff(1) .
+.PP
+The option
+.B -d
+does not diff altered files; only
+the summary by file names is prepared.
+.SH FILES
+Lots.  Files zz[abcdeglmn]????? are used for scratch space;
+files brought back from the remote machine for
+.I diffing
+are stored (and left around) as
+.I name.?????
+and the final report is left in
+.I uudiff.?????
+(the exact name is reported by mail).
+.SH "SEE ALSO"
+diff(1), uucp(1)
+.SH DIAGNOSTICS
+Almost none.  Anything more serious than misspelling
+.I local-name
+causes unpredictable and obscure results.
+.SH BUGS
+In addition to the standard
+.I uucp
+requirements a hook is needed at the remote
+system, and at present is only installed
+on the systems "research" and "inter".
+.br
+This program is written in shell and should be translated
+to C so it could give diagnostics.
+.br
+Even if "remote-system" is the local system, uudiff
+is subject to delays in uucp traffic.
+.br
+It should probably write the standard output, instead of insisting
+on going into the background.
+.br
+Since checksums are used there is a probability of 1 in 2**32
+of missing differences between files.
+.br
+The ~userid syntax is not recognized.
diff --git a/usr/man/man1/uulog.1c b/usr/man/man1/uulog.1c
new file mode 100644 (file)
index 0000000..63c17b1
--- /dev/null
@@ -0,0 +1,29 @@
+.TH UULOG 1C
+.SH UULOG
+uulog \- uucp user log inquiry
+.SH SYNOPSIS
+.B uulog
+[ option ] ...
+.SH DESCRIPTION
+.I Uulog
+will search through the uucp log file and output
+the requested lines.
+.PP
+The requested lines are specified using one or more of the following
+options:
+.TP
+.BI -s sys
+Output lines which have
+.I sys
+as a prefix to the system name;
+.TP
+.BI -u user
+Output lines which have
+.I user
+as a prefix to the user who requested the work.
+.SH FILES
+/usr/uucp/spool - spool directory
+.br
+/usr/uucp/spool/LOGFILE
+.SH SEE ALSO
+uucp(1), uux(1)
index 5426c10..622d2f8 100644 (file)
@@ -41,7 +41,7 @@ will fail unless it is in proper format.
 .PP
 .SH SEE ALSO
 stat(2)
 .PP
 .SH SEE ALSO
 stat(2)
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (access = 33.)
 .br
 .B sys access; name; mode
 (access = 33.)
 .br
 .B sys access; name; mode
index 0d10fd5..ec11103 100644 (file)
@@ -30,7 +30,7 @@ No accounting is produced for programs running
 when a crash occurs.
 In particular nonterminating programs are never
 accounted for.
 when a crash occurs.
 In particular nonterminating programs are never
 accounted for.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (acct = 51.)
 .br
 .B sys acct; file
 (acct = 51.)
 .br
 .B sys acct; file
index 5a678fe..730553a 100644 (file)
@@ -1,4 +1,4 @@
-.TH ALARM 2 
+.TH ALARM 2 "UNIX/32V"
 .SH NAME
 alarm \- schedule signal after specified time
 .SH SYNOPSIS
 .SH NAME
 alarm \- schedule signal after specified time
 .SH SYNOPSIS
@@ -21,13 +21,13 @@ the signal may occur up to one second early;
 because of scheduling delays,
 resumption of execution of when the signal is
 caught may be delayed an arbitrary amount.
 because of scheduling delays,
 resumption of execution of when the signal is
 caught may be delayed an arbitrary amount.
-The longest specifiable delay time is 65535 seconds.
+The longest specifiable delay time is 2147483647 seconds.
 .PP
 The return value is the amount of time
 previously remaining in the alarm clock.
 .SH "SEE ALSO"
 pause(2), signal(2), sleep(3)
 .PP
 The return value is the amount of time
 previously remaining in the alarm clock.
 .SH "SEE ALSO"
 pause(2), signal(2), sleep(3)
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (alarm = 27.)
 .br
 (seconds in r0)
 (alarm = 27.)
 .br
 (seconds in r0)
index c52734d..f4b7d15 100644 (file)
@@ -12,7 +12,8 @@ sets the system's idea of the lowest location not used by the program
 to
 .I addr
 (rounded up to the next multiple of 64 bytes
 to
 .I addr
 (rounded up to the next multiple of 64 bytes
-on the PDP11, 256 bytes on the Interdata 8/32, 512 bytes on the VAX-11/780).
+on the PDP11, 256 bytes on the Interdata 8/32,
+and 512 bytes on a VAX-11).
 Locations not less than
 .I addr
 and below the stack pointer
 Locations not less than
 .I addr
 and below the stack pointer
@@ -47,7 +48,7 @@ registers would be required to implement the break.
 .SH BUGS
 Setting the break in the range
 0177701 to 0177777 (on the PDP11) is the same as setting it to zero.
 .SH BUGS
 Setting the break in the range
 0177701 to 0177777 (on the PDP11) is the same as setting it to zero.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (break = 17.)
 .br
 .B sys break; addr
 (break = 17.)
 .br
 .B sys break; addr
index 4e038eb..f2d1544 100644 (file)
@@ -1,14 +1,10 @@
-.TH "CHDIR" 2 
+.TH CHDIR 2 
 .SH NAME
 .SH NAME
-chdir, chroot \- change default directory
+chdir \- change default directory
 .SH SYNOPSIS
 .B chdir(dirname)
 .br
 .B char *dirname;
 .SH SYNOPSIS
 .B chdir(dirname)
 .br
 .B char *dirname;
-.PP
-.B chroot(dirname)
-.br
-.B char *dirname;
 .SH DESCRIPTION
 .I Dirname
 is the address of the pathname of a directory, terminated by a null byte.
 .SH DESCRIPTION
 .I Dirname
 is the address of the pathname of a directory, terminated by a null byte.
@@ -16,11 +12,6 @@ is the address of the pathname of a directory, terminated by a null byte.
 causes this directory
 to become the current working directory,
 the starting point for path names not beginning with `/'.
 causes this directory
 to become the current working directory,
 the starting point for path names not beginning with `/'.
-.PP
-.I Chroot
-sets the root directory, the
-starting point for path names beginning with `/'.
-The call is restricted to the super-user.
 .SH "SEE ALSO"
 cd(1)
 .SH DIAGNOSTICS
 .SH "SEE ALSO"
 cd(1)
 .SH DIAGNOSTICS
@@ -32,7 +23,3 @@ or is not searchable.
 (chdir = 12.)
 .br
 .B sys chdir; dirname
 (chdir = 12.)
 .br
 .B sys chdir; dirname
-.PP
-(chroot = 61.)
-.br
-.B sys chroot; dirname
index 3796d60..1b4410d 100644 (file)
@@ -26,7 +26,7 @@ combination of the following:
 .RE
 .PP
 If an executable file is set up for sharing
 .RE
 .PP
 If an executable file is set up for sharing
-(\fB\-n\fR or \fB\-i\fR option of
+(\fB\-n\fR option of
 .IR ld (1))
 then mode 1000 prevents the system from
 abandoning the swap-space image of the program-text portion
 .IR ld (1))
 then mode 1000 prevents the system from
 abandoning the swap-space image of the program-text portion
@@ -50,7 +50,7 @@ Zero is returned if the mode is changed;
 .I name
 cannot be found or if current user
 is neither the owner of the file nor the super-user.
 .I name
 cannot be found or if current user
 is neither the owner of the file nor the super-user.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (chmod = 15.)
 .br
 .B sys chmod; name; mode
 (chmod = 15.)
 .br
 .B sys chmod; name; mode
index 2b24ad0..376acf7 100644 (file)
@@ -26,7 +26,7 @@ chown(1), passwd(5)
 Zero is returned if the owner is changed;
 \-1 is returned
 on illegal owner changes.
 Zero is returned if the owner is changed;
 \-1 is returned
 on illegal owner changes.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (chown = 16.)
 .br
 .B sys chown; name; owner; group
 (chown = 16.)
 .br
 .B sys chown; name; owner; group
index e6ea139..baa42ae 100644 (file)
@@ -23,16 +23,14 @@ there is a limit on the number of open files per process,
 is necessary for programs which deal with many files.
 .PP
 Files are closed upon termination of a process, and
 is necessary for programs which deal with many files.
 .PP
 Files are closed upon termination of a process, and
-certain file descriptors may be closed by
-.IR exec (2)
-(see
-.IR ioctl (2)).
+certain high-numbered file descriptors are closed by
+.IR exec (2).
 .SH "SEE ALSO"
 .SH "SEE ALSO"
-creat(2), open(2), pipe(2), exec(2), ioctl(2)
+creat(2), open(2), pipe(2), exec(2)
 .SH DIAGNOSTICS
 Zero is returned if a file is closed;
 \-1 is returned for an unknown file descriptor.
 .SH DIAGNOSTICS
 Zero is returned if a file is closed;
 \-1 is returned for an unknown file descriptor.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (close = 6.)
 .br
 (file descriptor in r0)
 (close = 6.)
 .br
 (file descriptor in r0)
index dca31a9..3dc9dfe 100644 (file)
@@ -53,7 +53,7 @@ in which it is to be created is not writable; the file
 does exist and is unwritable;
 the file is a directory;
 there are already too many files open.
 does exist and is unwritable;
 the file is a directory;
 there are already too many files open.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (creat = 8.)
 .br
 .B sys creat; name; mode
 (creat = 8.)
 .br
 .B sys creat; name; mode
index 32502aa..c57c9f6 100644 (file)
@@ -45,7 +45,7 @@ creat(2), open(2), close(2), pipe(2)
 The value \-1 is returned if:
 the given file descriptor is invalid;
 there are already too many open files.
 The value \-1 is returned if:
 the given file descriptor is invalid;
 there are already too many open files.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (dup = 41.)
 .br
 (file descriptor in r0)
 (dup = 41.)
 .br
 (file descriptor in r0)
index 19acdb9..3613e92 100644 (file)
@@ -10,9 +10,9 @@ execl, execv, execle, execve, execlp, execvp, exec, exece, environ  \- execute a
 .br
 .B char *name, *argv[ ];
 .PP
 .br
 .B char *name, *argv[ ];
 .PP
-.B "execle(name, arg0, arg1, ..., argn, 0, envp)
+.B execle(name, arg0, arg1, ..., argn, 0, envp)
 .br
 .br
-.B "char *name, *arg0, *arg1, ..., *argn, *envp[ ];
+.B char *name, *arg0, *arg1, ..., *argn, *envp[ ];
 .PP
 .B execve(name, argv, envp);
 .br
 .PP
 .B execve(name, argv, envp);
 .br
@@ -25,7 +25,7 @@ in all its forms
 overlays the calling process with the named file, then
 transfers to the
 entry point of the core image of the file.
 overlays the calling process with the named file, then
 transfers to the
 entry point of the core image of the file.
-There can be no return from a successful exec; the calling
+There can be no return from a succussful exec; the calling
 core image is lost.
 .PP
 Files remain open across
 core image is lost.
 .PP
 Files remain open across
@@ -77,7 +77,7 @@ is the name of the
 file.
 .PP
 From C, two interfaces are available.
 file.
 .PP
 From C, two interfaces are available.
-.I Execl
+.I execl
 is useful when a known file with known arguments is
 being called;
 the arguments to
 is useful when a known file with known arguments is
 being called;
 the arguments to
@@ -159,8 +159,8 @@ routines use lower-level routines as follows
 to pass an environment explicitly:
 .RS
 .nf
 to pass an environment explicitly:
 .RS
 .nf
-execle(file, arg0, arg1, . . . , argn, 0, environ);
 execve(file, argv, environ);
 execve(file, argv, environ);
+execle(file, arg0, arg1, . . . , argn, 0, environ);
 .fi
 .RE
 .PP
 .fi
 .RE
 .PP
@@ -207,7 +207,7 @@ the values of
 and
 .I argv[\-1]
 will be modified before return.
 and
 .I argv[\-1]
 will be modified before return.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 .DT
 (exec = 11.)
 .br
 .DT
 (exec = 11.)
 .br
@@ -284,3 +284,26 @@ envp0:     int     env0
 .fi
 .PP
 This arrangement happens to conform well to C calling conventions.
 .fi
 .PP
 This arrangement happens to conform well to C calling conventions.
+.PP
+On a VAX-11, the stack begins at 0x80000000 and grows towards lower-
+numbered addresses.  After
+.IR exec ,
+the layout of data on the stack is as follows.
+.PP
+.nf
+.ta \w' arg0:  'u
+ ap \(->
+ fp \(->
+ sp \(->       .long nargs
+       .long arg0
+       ...
+       .long argn
+       .long 0
+       .long env0
+       ...
+       .long envn
+       .long 0
+ arg0: .byte "arg0\e0"
+       ...
+ envn: .byte "envn\e0"
+       .long 0
index 3c0c541..6dd30aa 100644 (file)
@@ -31,7 +31,7 @@ The function
 circumvents all cleanup.
 .SH "SEE ALSO"
 wait(2)
 circumvents all cleanup.
 .SH "SEE ALSO"
 wait(2)
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (exit = 1.)
 .br
 (status in r0)
 (exit = 1.)
 .br
 (status in r0)
index 7ccb6ae..4b62b2d 100644 (file)
@@ -33,7 +33,7 @@ there is inadequate swap space,
 the user is not super-user and has too many processes,
 or the system's process table is full.
 Only the super-user can take the last process-table slot.
 the user is not super-user and has too many processes,
 or the system's process table is full.
 Only the super-user can take the last process-table slot.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (fork = 2.)
 .br
 .B sys fork
 (fork = 2.)
 .br
 .B sys fork
index 41d0831..46becdc 100644 (file)
@@ -13,7 +13,7 @@ uniquely-named
 temporary files.
 .SH "SEE ALSO"
 mktemp(3)
 temporary files.
 .SH "SEE ALSO"
 mktemp(3)
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (getpid = 20.)
 .br
 .B sys getpid
 (getpid = 20.)
 .br
 .B sys getpid
index 4b22144..2d1bbb3 100644 (file)
@@ -26,7 +26,7 @@ returns the real group ID,
 the effective group ID.
 .SH "SEE ALSO"
 setuid(2)
 the effective group ID.
 .SH "SEE ALSO"
 setuid(2)
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (getuid = 24.)
 .br
 .B sys getuid
 (getuid = 24.)
 .br
 .B sys getuid
index 5270aab..551b93f 100644 (file)
@@ -1,7 +1,38 @@
 .TH INDIR 2 
 .SH NAME
 .TH INDIR 2 
 .SH NAME
-indir \- indirect system call
-.SH ASSEMBLER
+indir, syscall \- indirect system call
+.SH SYNOPSIS
+.BR "syscall(number, r0, r1, arg ...)" \  \  (PDP-11)
+.br
+.BR "syscall(number, arg, ...)" \  \  (VAX-11)
+.SH DESCRIPTION
+.I Syscall
+performs the system call whose assembly language
+interface has the specified
+.I number,
+register arguments
+.I r0
+and
+.I r1
+(on the PDP-11, regardless of whether the entry point really
+uses them) and further arguments
+.IR arg .
+.PP
+The r0 value of the system call is returned.
+.SH DIAGNOSTICS
+When the C-bit is set,
+.I syscall
+returns \-1 and sets the
+external variable 
+.I errno
+(see
+.IR intro (2)).
+.SH BUGS
+There is no way to simulate system calls
+such as
+.IR pipe (2),
+which return values in register r1.
+.SH "ASSEMBLER (PDP-11)"
 (indir = 0.)
 .br
 .B sys indir; call
 (indir = 0.)
 .br
 .B sys indir; call
@@ -13,7 +44,7 @@ Execution resumes after the
 .I indir
 call.
 .PP
 .I indir
 call.
 .PP
-The main purpose of
+On the PDP-11, the main purpose of
 .I indir
 is to allow a program to
 store arguments in system calls and execute them
 .I indir
 is to allow a program to
 store arguments in system calls and execute them
index b3c3440..9b28a5f 100644 (file)
@@ -71,7 +71,7 @@ or
 This error may in some cases occur
 on a call following the one to which it actually applies.
 .en 6 ENXIO "No such device or address
 This error may in some cases occur
 on a call following the one to which it actually applies.
 .en 6 ENXIO "No such device or address
-I/O on a special file refers to a subdevice that does not
+I/O on a special file refers to a subdevice which does not
 exist,
 or beyond the limits of the device.
 It may also occur when, for example, a tape drive
 exist,
 or beyond the limits of the device.
 It may also occur when, for example, a tape drive
@@ -89,7 +89,7 @@ does not start with a valid magic number, see
 Either a file descriptor refers to no
 open file,
 or a read (resp. write) request is made to
 Either a file descriptor refers to no
 open file,
 or a read (resp. write) request is made to
-a file that is open only for writing (resp. reading).
+a file which is open only for writing (resp. reading).
 .en 10 ECHILD "No children
 .I Wait
 and the process has no
 .en 10 ECHILD "No children
 .I Wait
 and the process has no
@@ -125,6 +125,7 @@ e.g. in
 An attempt to mount a device that was already mounted or
 an attempt was made to dismount a device
 on which there is an active file
 An attempt to mount a device that was already mounted or
 an attempt was made to dismount a device
 on which there is an active file
+directory.
 (open file, current directory, mounted-on file, active text segment).
 .en 17 EEXIST "File exists
 An existing file was mentioned in an inappropriate context,
 (open file, current directory, mounted-on file, active text segment).
 .en 17 EEXIST "File exists
 An existing file was mentioned in an inappropriate context,
@@ -172,7 +173,7 @@ is not a terminal or one of the other
 devices to which these calls apply.
 .en 26 ETXTBSY "Text file busy
 An attempt to execute a pure-procedure
 devices to which these calls apply.
 .en 26 ETXTBSY "Text file busy
 An attempt to execute a pure-procedure
-program that is currently open for writing
+program which is currently open for writing
 (or reading!).
 Also an attempt to open for writing a pure-procedure
 program that is being executed.
 (or reading!).
 Also an attempt to open for writing a pure-procedure
 program that is being executed.
@@ -211,7 +212,7 @@ The value of a function in the math package (3M)
 is unrepresentable within machine precision.
 .SH SEE ALSO
 intro(3)
 is unrepresentable within machine precision.
 .SH SEE ALSO
 intro(3)
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 .B as /usr/include/sys.s file ...
 .PP
 The PDP11 assembly language interface is given for each
 .B as /usr/include/sys.s file ...
 .PP
 The PDP11 assembly language interface is given for each
@@ -260,3 +261,17 @@ The return value is in register 2 (possibly 3 also, as in
 and is \-1 in case of error.
 The overflow bit in the program status word is also
 set when errors occur.
 and is \-1 in case of error.
 The overflow bit in the program status word is also
 set when errors occur.
+.PP
+Under
+.UX \s-2/32V\s0
+on a VAX-11, a system call follows exactly the same conventions as a
+C procedure.  Namely, register
+.B ap
+points to a long word containing the number of arguments, and the
+arguments follow in successive long words.  Values are returned in registers
+.B r0
+and
+.BR r1 .
+An error is indicated by setting the C (carry) bit in the processor status
+word; the error number is placed in
+.BR r0 .
index 5c20d1c..5350611 100644 (file)
@@ -73,7 +73,7 @@ should have an open-ended declaration like
 .B } *argp;
 .PP
 The important thing is that the size is fixed by `struct sgttyb'.
 .B } *argp;
 .PP
 The important thing is that the size is fixed by `struct sgttyb'.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (ioctl = 54.)
 .br
 .B sys ioctl; fildes; request; argp
 (ioctl = 54.)
 .br
 .B sys ioctl; fildes; request; argp
index 4546204..fcefa16 100644 (file)
@@ -30,7 +30,7 @@ and initialization processes,
 see
 .IR init (8).
 .PP
 see
 .IR init (8).
 .PP
-Processes may send signals to themselves.
+Proccesses may send signals to themselves.
 .SH "SEE ALSO"
 signal(2), kill(1)
 .SH DIAGNOSTICS
 .SH "SEE ALSO"
 signal(2), kill(1)
 .SH DIAGNOSTICS
@@ -39,7 +39,7 @@ Zero is returned if the process is killed;
 have the same effective user ID and the
 user is not super-user, or if the process
 does not exist.
 have the same effective user ID and the
 user is not super-user, or if the process
 does not exist.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (kill = 37.)
 .br
 (process number in r0)
 (kill = 37.)
 .br
 (process number in r0)
index 9b39a1f..1225830 100644 (file)
@@ -29,7 +29,7 @@ other than the super-user;
 when an attempt is made to link
 to a file on another file system;
 when a file has too many links.
 when an attempt is made to link
 to a file on another file system;
 when a file has too many links.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (link = 9.)
 .br
 .B sys link; name1; name2
 (link = 9.)
 .br
 .B sys link; name1; name2
index a161a6b..da25318 100644 (file)
@@ -50,7 +50,7 @@ or seek to a position before the beginning of file.
 .SH BUGS
 .I Lseek
 is a no-op on character special files.
 .SH BUGS
 .I Lseek
 is a no-op on character special files.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (lseek = 19.)
 .br
 (file descriptor in r0)
 (lseek = 19.)
 .br
 (file descriptor in r0)
index f968f23..76042e5 100644 (file)
@@ -36,7 +36,7 @@ mkdir(1), mknod(1), filsys(5)
 Zero is returned if the file has been made; \-1
 if the file already exists
 or if the user is not the super-user.
 Zero is returned if the file has been made; \-1
 if the file already exists
 or if the user is not the super-user.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (mknod = 14.)
 .br
 .B sys  mknod; name; mode; addr
 (mknod = 14.)
 .br
 .B sys  mknod; name; mode; addr
index 4affb4c..e968ee0 100644 (file)
@@ -72,7 +72,13 @@ if the special file is inaccessible or
 does not have a mounted file system,
 or if there are active files in the mounted 
 file system.
 does not have a mounted file system,
 or if there are active files in the mounted 
 file system.
-.SH ASSEMBLER
+.SH BUGS
+If a file containing holes
+(unallocated blocks)
+is read, even on a file system mounted read-only,
+the system will attempt to fill in the holes
+by writing on the device.
+.SH "ASSEMBLER (PDP-11)"
 (mount = 21.)
 .br
 .B sys  mount; special; name; rwflag
 (mount = 21.)
 .br
 .B sys  mount; special; name; rwflag
diff --git a/usr/man/man2/mpxcall.2 b/usr/man/man2/mpxcall.2
deleted file mode 100644 (file)
index b32f577..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-.TH MPXCALL 2
-.SH NAME
-mpxcall \- multiplexor and channel interface
-.SH SYNOPSIS
-.B mpxcall(arg1, arg2, arg3, cmd)
-.SH DESCRIPTION
-.I Mpxcall
-supplies a primitive interface to the kernel
-used by the routines listed below.
-Each routine that uses
-.I mpxcall
-passes an integer
-.I cmd
-as the fourth argument.
-These are defined in
-.I /usr/include/mx.h.
-.I Mpxcall
-always returns an integer which is to be interpreted
-in accordance with the definition of
-.I cmd.
-.SH "SEE ALSO"
-group(2), join(2), extract(2), connect(2), chan(2), attach(2), detach(2)
-.SH DIAGNOSTICS
-The value \-1 is returned on error.
index 04fb86c..29f088f 100644 (file)
@@ -31,7 +31,7 @@ then 0 (to maintain compatibility with previous versions
 of this call).
 .SH "SEE ALSO"
 nice(1)
 of this call).
 .SH "SEE ALSO"
 nice(1)
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (nice = 34.)
 .br
 (priority in r0)
 (nice = 34.)
 .br
 (priority in r0)
index 25571cf..816685f 100644 (file)
@@ -34,7 +34,7 @@ if the file does not exist,
 if one of the necessary directories
 does not exist or is unreadable, if the file is not
 readable (resp. writable), or if too many files are open.
 if one of the necessary directories
 does not exist or is unreadable, if the file is not
 readable (resp. writable), or if too many files are open.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (open = 5.)
 .br
 .B sys open; name; mode
 (open = 5.)
 .br
 .B sys open; name; mode
index 0ef5b9d..d9c4866 100644 (file)
@@ -13,7 +13,7 @@ or
 .IR alarm (2).
 .SH SEE ALSO
 kill(1), kill(2), alarm(2), signal(2), setjmp(3)
 .IR alarm (2).
 .SH SEE ALSO
 kill(1), kill(2), alarm(2), signal(2), setjmp(3)
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (pause = 29.)
 .br
 .B sys pause
 (pause = 29.)
 .br
 .B sys pause
diff --git a/usr/man/man2/phys.2 b/usr/man/man2/phys.2
deleted file mode 100644 (file)
index a95823d..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-.TH PHYS 2 PDP11
-.SH NAME
-phys \- allow a process to access physical addresses
-.SH SYNOPSIS
-.B phys(segreg, size, physadr)
-.SH DESCRIPTION
-The argument
-.I segreg
-specifies a process virtual (data-space) address
-range of 8K bytes starting
-at virtual address
-.IR segreg \(mu8K
-bytes.
-This address range is mapped into
-physical address
-.IR physadr \(mu64
-bytes.
-Only the first
-.IR size \(mu64
-bytes of this mapping is addressable.
-If
-.I size
-is zero,
-any previous mapping of this
-virtual address range is nullified.
-For example,
-the call
-.PP
-       phys(6, 1, 0177775);
-.PP
-will map virtual addresses 0160000-0160077 into
-physical addresses 017777500-017777577.
-In particular,
-virtual address 0160060 is the PDP-11 console
-located at physical address 017777560.
-.PP
-This call may only be executed by the super-user.
-.SH "SEE ALSO"
-PDP-11 segmentation hardware
-.SH DIAGNOSTICS
-The function value zero is returned if
-the physical mapping is in effect.
-The value \-1 is returned
-if not super-user,
-if
-.I segreg
-is not in the range 0-7,
-if
-.I size
-is not in the range 0-127,
-or if
-the specified
-.I segreg
-is already used for other than
-a previous call to
-.IR phys .
-.SH BUGS
-This system call is obviously very machine
-dependent and very dangerous.
-This system call is not considered
-a permanent part of the system.
-.SH ASSEMBLER
-(phys = 52.)
-.br
-.B sys phys; segreg; size; physadr
index 0499160..5de1c56 100644 (file)
@@ -19,8 +19,6 @@ before the writing process is suspended.
 A read using the descriptor
 .IR fildes [0]
 will pick up the data.
 A read using the descriptor
 .IR fildes [0]
 will pick up the data.
-Writes with a count of 4096 bytes or less are atomic;
-no other process can intersperse data.
 .PP
 It is assumed that after the
 pipe has been set up,
 .PP
 It is assumed that after the
 pipe has been set up,
@@ -54,7 +52,7 @@ A signal is generated if a write on a pipe with only one end is attempted.
 .SH BUGS
 Should more than 4096 bytes be necessary in any
 pipe among a loop of processes, deadlock will occur.
 .SH BUGS
 Should more than 4096 bytes be necessary in any
 pipe among a loop of processes, deadlock will occur.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (pipe = 42.)
 .br
 .B sys pipe
 (pipe = 42.)
 .br
 .B sys pipe
diff --git a/usr/man/man2/pkon.2 b/usr/man/man2/pkon.2
deleted file mode 100644 (file)
index b6c0757..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-.TH PKON 2
-.SH NAME
-pkon, pkoff \- establish packet protocol
-.SH SYNOPSIS
-.B pkon(fd, size)
-.PP
-.B pkoff(fd)
-.SH DESCRIPTION
-.I Pkon
-establishes packet protocol (see
-.IR pk (4))
-on the open character special file whose file
-descriptor is
-.I fd.
-.I Size
-is a desired packet size, a power of 2 in the range
-.RI 32\(<= size \(<=4096.
-The size is negotiated with a remote packet driver,
-and a possibly smaller actual packet size is returned.
-.PP
-An asynchronous line used for packet
-communication should be in raw mode;
-see
-.IR tty (4).
-.PP
-.I Pkoff
-turns off the packet driver on the channel whose
-file descriptor is
-.I fd.
-.SH SEE ALSO
-pk(4), pkopen(3), tty(4), signal(2)
-.SH DIAGNOSTICS
-.I Pkon
-returns \-1 if 
-.I fd
-does not describe an open file, or if
-packet communication cannot
-be established.
-.PP
-.I Pkoff
-returns \-1 for an unknown file descriptor.
-.PP
-Writing on a packet driver link that has been shut down
-by
-.I close
-or
-.I pkoff
-at the other end raises signal SIGPIPE
-in the writing process.
index 8410d38..e9a24a4 100644 (file)
@@ -49,7 +49,7 @@ Profiling may be turned off if an update in
 would cause a memory fault.
 .SH "SEE ALSO"
 monitor(3), prof(1)
 would cause a memory fault.
 .SH "SEE ALSO"
 monitor(3), prof(1)
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (profil = 44.)
 .br
 .B sys profil; buff; bufsiz; offset; scale
 (profil = 44.)
 .br
 .B sys profil; buff; bufsiz; offset; scale
index e0f5909..c6dd433 100644 (file)
@@ -128,7 +128,7 @@ however, as soon as possible after execution of at least one instruction,
 execution stops again.
 The signal number from the stop is
 SIGTRAP.
 execution stops again.
 The signal number from the stop is
 SIGTRAP.
-(On the PDP-11 the T-bit is used and just one instruction
+(On the PDP-11 and VAX-11 the T-bit is used and just one instruction
 is executed;
 on the Interdata the stop does not take place
 until a store instruction is executed.)
 is executed;
 on the Interdata the stop does not take place
 until a store instruction is executed.)
@@ -161,6 +161,8 @@ showing signal SIGTRAP.
 .PP
 On the Interdata 8/32,
 `word' means a 32-bit word and `even' means 0 mod 4.
 .PP
 On the Interdata 8/32,
 `word' means a 32-bit word and `even' means 0 mod 4.
+On a VAX-11, `word' also means a 32-bit integer, but the `even' restriction
+does not apply.
 .SH "SEE ALSO"
 wait(2), signal(2), adb(1)
 .SH DIAGNOSTICS
 .SH "SEE ALSO"
 wait(2), signal(2), adb(1)
 .SH DIAGNOSTICS
index 63d481b..ab3e2a6 100644 (file)
@@ -41,7 +41,7 @@ preposterous
 .I nbytes,
 file descriptor not that of
 an input file.
 .I nbytes,
 file descriptor not that of
 an input file.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (read = 3.)
 .br
 (file descriptor in r0)
 (read = 3.)
 .br
 (file descriptor in r0)
index 47d1b01..69e25d8 100644 (file)
@@ -16,7 +16,7 @@ getuid(2)
 .SH DIAGNOSTICS
 Zero is returned if the user (group) ID is set;
 \-1 is returned otherwise.
 .SH DIAGNOSTICS
 Zero is returned if the user (group) ID is set;
 \-1 is returned otherwise.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (setuid = 23.)
 .br
 (user ID in r0)
 (setuid = 23.)
 .br
 (user ID in r0)
index 50da35b..6c8ebd2 100644 (file)
@@ -4,13 +4,13 @@ signal \- catch or ignore signals
 .SH SYNOPSIS
 .B #include <signal.h>
 .PP
 .SH SYNOPSIS
 .B #include <signal.h>
 .PP
-.B (*signal(sig, func))()
+.B (*signal(sig, func))();
 .br
 .B (*func)();
 .SH DESCRIPTION
 A signal
 is generated by some abnormal event,
 .br
 .B (*func)();
 .SH DESCRIPTION
 A signal
 is generated by some abnormal event,
-initiated either by user at a typewriter (quit, interrupt),
+initiated either by user at a terminal (quit, interrupt),
 by a program error (bus error, etc.),
 or by request of another program (kill).
 Normally all signals
 by a program error (bus error, etc.),
 or by request of another program (kill).
 Normally all signals
@@ -36,7 +36,7 @@ SIGKILL       9       kill (cannot be caught or ignored)
 SIGBUS 10*     bus error
 SIGSEGV        11*     segmentation violation
 SIGSYS 12*     bad argument to system call
 SIGBUS 10*     bus error
 SIGSEGV        11*     segmentation violation
 SIGSYS 12*     bad argument to system call
-SIGPIPE        13      write on a pipe or link with no one to read it
+SIGPIPE        13      write on a pipe with no one to read it
 SIGALRM        14      alarm clock
 SIGTERM        15      software termination signal
        16      unassigned
 SIGALRM        14      alarm clock
 SIGTERM        15      software termination signal
        16      unassigned
@@ -78,7 +78,7 @@ during a
 .I read
 or
 .IR write (2)
 .I read
 or
 .IR write (2)
-on a slow device (like a typewriter; but not a file);
+on a slow device (like a terminal; but not a file);
 and during
 .I pause
 or
 and during
 .I pause
 or
@@ -118,7 +118,11 @@ reset, there is no chance to catch it.
 The type specification of the routine and its
 .I func
 argument are problematical.
 The type specification of the routine and its
 .I func
 argument are problematical.
-.SH ASSEMBLER
+.PP
+On the VAX-11, odd values for
+.I func
+are the same as SIG_IGN.
+.SH "ASSEMBLER (PDP-11)"
 (signal = 48.)
 .br
 .B sys  signal; sig; label
 (signal = 48.)
 .br
 .B sys  signal; sig; label
@@ -138,3 +142,35 @@ specifies an address in the process
 where an interrupt is simulated.
 An RTI or RTT instruction will return from the
 interrupt.
 where an interrupt is simulated.
 An RTI or RTT instruction will return from the
 interrupt.
+.SH "NOTES (UNIX/32V)"
+The following defines the mapping of hardware traps to signals:
+.PP
+.nf
+.ta \w'     Floating divide by zero   'u +\w'15*  'u
+Arithemetic traps:
+.in +5
+Integer overflow       SIGFPE
+Integer division by zero       SIGFPE
+Floating overflow      SIGFPE
+Floating underflow     SIGFPE
+Floating division by zero      SIGFPE
+Decimal division by zero       SIGFPE
+Decimal overflow       SIGFPE
+Subscript-range        SIGFPE
+.in -5
+Access control (i.e. protection
+  violation)
+  except length violation      SIGBUS
+Translation not valid, and
+  Length access control        SIGSEGV
+Reserved instruction   SIGILL
+Customer-reserved instr.       SIGEMT
+Reserved operand       SIGILL
+Reserved addressing    SIGILL
+Trace pending  SIGTRAP
+Bpt instruction        SIGTRAP
+Compatibility-mode     SIGEMT
+Chme   SIGSEGV
+Chms   SIGSEGV
+Chmu   SIGBUS
+.fi
index ab924a6..e297a1c 100644 (file)
@@ -65,9 +65,9 @@ When
 .I fildes
 is associated with a pipe,
 .I fstat
 .I fildes
 is associated with a pipe,
 .I fstat
-reports an ordinary file
-with restricted permissions.
-The size is the number of bytes queued in the pipe.
+reports an ordinary file with an i-node number,
+restricted permissions,
+and a not necessarily meaningful length.
 .PP
 .I st_atime
 is the file was last read.
 .PP
 .I st_atime
 is the file was last read.
index e1208ec..22c6662 100644 (file)
@@ -17,7 +17,7 @@ date(1), time(2), ctime(3)
 .SH DIAGNOSTICS
 Zero is returned if the time was set;
 \-1 if user is not the super-user.
 .SH DIAGNOSTICS
 Zero is returned if the time was set;
 \-1 if user is not the super-user.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (stime = 25.)
 .br
 (time in r0-r1)
 (stime = 25.)
 .br
 (time in r0-r1)
diff --git a/usr/man/man2/stty.2 b/usr/man/man2/stty.2
new file mode 100644 (file)
index 0000000..2dc8a23
--- /dev/null
@@ -0,0 +1,202 @@
+.TH STTY 2 
+.SH NAME
+stty, gtty \- set and retrieve terminal modes
+.SH SYNOPSIS
+.B #include <sgtty.h>
+.PP
+.B stty(fildes, arg)
+.br
+.B struct sgttyb *arg;
+.PP
+.B gtty(fildes, arg)
+.br
+.B struct sgttyb *arg;
+.SH DESCRIPTION
+.I Gtty
+stores in the structure pointed to by 
+.I arg
+status information about the terminal
+whose file descriptor is in r0 (in the first argument).
+.PP
+.I Stty
+delays until the terminal is quiescent,
+then sets its status to agree with the structure
+pointed to by
+.IR arg .
+.PP
+The input and output speeds are set from the first two bytes
+Both system calls use the structure
+defined in <sgtty.h>:
+.PP
+.nf
+struct sgttyb {
+       char    sg_ispeed;
+       char    sg_ospeed;
+       char    sg_erase;
+       char    sg_kill;
+       int     sg_flags;
+};
+.fi
+.PP
+The
+.I sg_ispeed 
+and 
+.I sg_ospeed
+fields describe the input and output speeds of the
+device according to the following table,
+which corresponds to the DH-11 interface.
+If DC-11, DL-11 or KL-11 interfaces are used,
+impossible speed changes are ignored.
+Symbolic values in the table are as defined in
+.IR <sgtty.h> .
+.PP
+.nf
+.ta \w'B9600   'u +5n
+B0     0       (hang up dataphone)
+B50    1       50 baud
+B75    2       75 baud
+B110   3       110 baud
+B134   4       134.5 baud
+B150   5       150 baud
+B200   6       200 baud
+B300   7       300 baud
+B600   8       600 baud
+B1200  9       1200 baud
+B1800  10      1800 baud
+B2400  11      2400 baud
+B4800  12      4800 baud
+B9600  13      9600 baud
+EXTA   14      External A
+EXTB   15      External B
+.fi
+.DT
+.PP
+In the current configuration,
+only 110, 150, 300 and 1200 baud are really supported on dial-up lines.
+Code conversion and line control required for
+IBM 2741's (134.5 baud)
+must be implemented by the user's
+program.
+The half-duplex line discipline
+required for the 202 dataset (1200 baud)
+is not supplied; full-duplex 212 datasets work fine.
+.PP
+The
+.I sg_erase
+and
+.I sg_kill
+fields of the argument structure
+specify the erase and kill characters respectively.
+(Defaults are # and @.)
+.PP
+The
+.I sg_flags
+field of the argument structure
+contains several bits which determine the
+system's treatment of the terminal:
+.PP
+.ta \w'ALLDELAY 'u +\w'0100000 'u
+.nf
+ALLDELAY       0177400 Delay algorithm selection
+BSDELAY        0100000 Select backspace delays:
+BS0    0
+BS1    0100000
+VTDELAY        0040000 Select form-feed and vertical-tab delays:
+FF0    0
+FF1    0040000
+CRDELAY        0030000 Select carriage-return delays:
+CR0    0
+CR1    0010000
+CR2    0020000
+CR3    0030000
+TBDELAY        0006000 Select tab delays:
+TAB0   0
+TAB1   0002000
+TAB2   0004000
+TAB3   0006000
+NLDELAY        0001400 Select new-line delays:
+NL0    0
+NL1    0000400
+NL2    0001000
+NL3    0001400
+EVENP  0000200 Even parity allowed on input (e. g. for M37s)
+ODDP   0000100 Odd parity allowed on input
+RAW    0000040 Raw mode: wake up on all characters
+CRMOD  0000020 Map CR into LF; echo LF or CR as CR-LF
+ECHO   0000010 Echo (full duplex)
+LCASE  0000004 Map upper case to lower on input (e. g. M33)
+CBREAK 0000002 Return each character as soon as typed
+HUPCL  0000001 Hang up (remove `data terminal ready') on last close
+.DT
+.fi
+.PP
+The delay bits specify how long
+transmission stops to allow for mechanical or other movement
+when certain characters are sent to the terminal.
+In all cases a value of 0 indicates no delay.
+.PP
+Backspace delays are currently ignored but will
+be used for Terminet 300's.
+.PP
+If a form-feed/vertical tab delay is specified,
+it lasts for about 2 seconds.
+.PP
+Carriage-return delay type 1 lasts about .08 seconds
+and is suitable for the Terminet 300.
+Delay type 2 lasts about .16 seconds and is suitable
+for the VT05 and the TI 700.
+Delay type 3 is unimplemented and is 0.
+.PP
+New-line delay type 1 is dependent on the current column
+and is tuned for Teletype model 37's.
+Type 2 is useful for the VT05 and is about .10 seconds.
+Type 3 is unimplemented and is 0.
+.PP
+Tab delay type 1 is dependent on the amount of movement
+and is tuned to the Teletype model
+37.
+Other types are unimplemented and are 0.
+.PP
+Characters with the wrong parity, as determined by bits 200 and
+100, are ignored.
+.PP
+In raw mode, every character is passed immediately
+to the program without waiting until a full line has been typed.
+No erase or kill processing is done;
+the end-of-file character (EOT), the interrupt character
+(DEL) and the quit character (FS) are not treated specially.
+.PP
+Mode 020 causes input carriage returns to be turned into
+new-lines;
+input of either CR or LF causes LF-CR both to
+be echoed
+(used for GE TermiNet 300's and other terminals without the newline function).
+.PP
+The hangup mode 01
+causes the line to be disconnected
+when the last process with the line open closes it or terminates.
+It is useful when a port is to be used for some special
+purpose;
+for example, if it is associated
+with an ACU used to place outgoing calls.
+.PP
+This system call is also used with certain special
+files other than terminals,
+but since none of them are part of the standard system
+the specifications will not be given.
+.SH "SEE ALSO"
+stty(1), tty(4)
+.SH DIAGNOSTICS
+Zero is returned if the call was successful;
+\-1 if the file descriptor does not refer to a terminal.
+.SH "ASSEMBLER (PDP-11)"
+(stty = 31.)
+.br
+(file descriptor in r0)
+.br
+.B sys stty; arg
+.PP
+(gtty = 32.)
+.br
+(file descriptor in r0)
+.B sys gtty; arg
index aa676d7..ff0075b 100644 (file)
@@ -21,7 +21,7 @@ sync(1), update(8)
 The writing, although scheduled, is not necessarily
 complete upon return from 
 .IR sync .
 The writing, although scheduled, is not necessarily
 complete upon return from 
 .IR sync .
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (sync = 36.)
 .br
 .B sys sync
 (sync = 36.)
 .br
 .B sys sync
index 7c9df4d..3c25698 100644 (file)
@@ -34,8 +34,8 @@ entry fills in a structure pointed to by its argument,
 as defined by
 .IR <sys/timeb.h> :
 .PP
 as defined by
 .IR <sys/timeb.h> :
 .PP
-.nf
 .ta .5i +\w'unsigned 'u
 .ta .5i +\w'unsigned 'u
+.nf
 .so /usr/include/sys/timeb.h
 .fi
 .PP
 .so /usr/include/sys/timeb.h
 .fi
 .PP
@@ -46,7 +46,7 @@ and a flag that, if nonzero, indicates that
 Daylight Saving time applies locally during the appropriate part of the year.
 .SH "SEE ALSO"
 date(1), stime(2), ctime(3)
 Daylight Saving time applies locally during the appropriate part of the year.
 .SH "SEE ALSO"
 date(1), stime(2), ctime(3)
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (ftime = 35.)
 .br
 .B sys ftime; bufptr
 (ftime = 35.)
 .br
 .B sys ftime; bufptr
index 4ded016..c8dd57c 100644 (file)
@@ -11,8 +11,7 @@ returns time-accounting information
 for the current process
 and for the terminated child processes
 of the current process.
 for the current process
 and for the terminated child processes
 of the current process.
-All times are in 1/HZ seconds,
-where HZ=60 in North America.
+All times are in 1/60 seconds.
 .PP
 After the call, the buffer will appear as follows:
 .PP
 .PP
 After the call, the buffer will appear as follows:
 .PP
@@ -30,7 +29,7 @@ of the children's process times and
 their children's times.
 .SH "SEE ALSO"
 time(1), time(2)
 their children's times.
 .SH "SEE ALSO"
 time(1), time(2)
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (times = 43.)
 .br
 .B sys times; buffer
 (times = 43.)
 .br
 .B sys times; buffer
index e27dc90..b995e36 100644 (file)
@@ -24,7 +24,7 @@ The value is initially 0 (no restrictions).
 The mask is inherited by child processes.
 .SH SEE ALSO
 creat(2), mknod(2), chmod(2)
 The mask is inherited by child processes.
 .SH SEE ALSO
 creat(2), mknod(2), chmod(2)
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (umask = 60.)
 .br
 .B sys umask; complmode
 (umask = 60.)
 .br
 .B sys umask; complmode
index 8368b05..d94d693 100644 (file)
@@ -28,7 +28,7 @@ that is currently in use.
 Write permission is not required on the file itself.
 It is also illegal to unlink a directory
 (except for the super-user).
 Write permission is not required on the file itself.
 It is also illegal to unlink a directory
 (except for the super-user).
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (unlink = 10.)
 .br
 .B sys  unlink; name
 (unlink = 10.)
 .br
 .B sys  unlink; name
index 0a0c3c1..1a47e79 100644 (file)
@@ -25,7 +25,7 @@ The caller must be the owner of the file or the super-user.
 The `inode-changed' time of the file is set to the current time.
 .SH SEE ALSO
 stat (2)
 The `inode-changed' time of the file is set to the current time.
 .SH SEE ALSO
 stat (2)
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (utime = 30.)
 .br
 .B sys utime; file; timep
 (utime = 30.)
 .br
 .B sys utime; file; timep
index 0b7abd2..eeeda74 100644 (file)
@@ -57,7 +57,7 @@ exit(2), fork(2), signal(2)
 .SH DIAGNOSTICS
 Returns
 \-1 if there are no children not previously waited for.
 .SH DIAGNOSTICS
 Returns
 \-1 if there are no children not previously waited for.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (wait = 7.)
 .br
 .B sys  wait
 (wait = 7.)
 .br
 .B sys  wait
index 6ba5336..9b6a62d 100644 (file)
@@ -34,7 +34,7 @@ creat(2), open(2), pipe(2)
 Returns
 \-1 on error: bad descriptor, buffer address, or
 count; physical I/O errors.
 Returns
 \-1 on error: bad descriptor, buffer address, or
 count; physical I/O errors.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 (write = 4.)
 .br
 (file descriptor in r0)
 (write = 4.)
 .br
 (file descriptor in r0)
index 1aa6c6f..f13b33c 100644 (file)
@@ -1,9 +1,9 @@
 .TH ABORT 3
 .SH NAME
 .TH ABORT 3
 .SH NAME
-abort \- generate IOT fault
+abort \- generate a fault
 .SH DESCRIPTION
 .I Abort
 .SH DESCRIPTION
 .I Abort
-executes the PDP11 IOT instruction.
+executes an instruction which is illegal in user mode.
 This causes a signal that normally terminates
 the process with a core dump, which may be used for debugging.
 .SH SEE ALSO
 This causes a signal that normally terminates
 the process with a core dump, which may be used for debugging.
 .SH SEE ALSO
index 69f332e..cdf763f 100644 (file)
@@ -11,4 +11,4 @@ the absolute value of its integer operand.
 floor(3) for
 .I fabs
 .SH BUGS
 floor(3) for
 .I fabs
 .SH BUGS
-You get what the hardware gives on the largest negative integer.
+You get what the hardware gives on the smallest integer.
index 90af9d5..ec06156 100644 (file)
@@ -1,7 +1,6 @@
 .TH ASSERT 3X
 .SH NAME
 .TH ASSERT 3X
 .SH NAME
-assert \-
-program verification
+assert \- program verification
 .SH SYNOPSIS
 .B #include <assert.h>
 .PP
 .SH SYNOPSIS
 .B #include <assert.h>
 .PP
index 4eb2760..5504dd2 100644 (file)
@@ -21,7 +21,7 @@ representation respectively.
 The first unrecognized character ends the string.
 .PP
 .I Atof
 The first unrecognized character ends the string.
 .PP
 .I Atof
-recognizes an optional string of tabs and spaces,
+recoginizes an optional string of tabs and spaces,
 then an optional sign, then
 a string of digits optionally containing a decimal
 point, then an optional `e' or `E' followed
 then an optional sign, then
 a string of digits optionally containing a decimal
 point, then an optional `e' or `E' followed
index 5f9f0ed..cf0da08 100644 (file)
@@ -79,7 +79,7 @@ If the required name does not appear in a table
 built into the routine,
 the difference from GMT is produced; e.g.
 in Afghanistan
 built into the routine,
 the difference from GMT is produced; e.g.
 in Afghanistan
-.I timezone(\-(60*4+30), 0)
+.I timezone(-(60*4+30), 0)
 is appropriate because it is 4:30 ahead of GMT
 and the string
 .B GMT+4:30
 is appropriate because it is 4:30 ahead of GMT
 and the string
 .B GMT+4:30
index 048ca84..01f16f0 100644 (file)
@@ -1,8 +1,6 @@
 .TH CTYPE 3 
 .SH NAME
 .TH CTYPE 3 
 .SH NAME
-isalpha, isupper, islower, isdigit, isalnum, isspace, ispunct, 
-isprint, iscntrl, isascii \-
-character classification
+isalpha, isupper, islower, isdigit, isalnum, isspace, ispunct, isprint, iscntrl, isascii \- character classification
 .SH SYNOPSIS
 .B #include <ctype.h>
 .PP
 .SH SYNOPSIS
 .B #include <ctype.h>
 .PP
index c6fc011..d931177 100644 (file)
@@ -21,7 +21,7 @@ above the uninitialized data region.
 When execution begins, the program break
 coincides with
 .I end,
 When execution begins, the program break
 coincides with
 .I end,
-but many functions reset the program break, among them
+but resetting the program break by
 the routines of
 .IR brk (2),
 .IR malloc (3), 
 the routines of
 .IR brk (2),
 .IR malloc (3), 
index 6168c4d..46aacdd 100644 (file)
@@ -1,3 +1,5 @@
+.if t .ds s \d*\u
+.if n .ds s *
 .TH FREXP 3
 .SH NAME
 frexp, ldexp, modf \- split into mantissa and exponent
 .TH FREXP 3
 .SH NAME
 frexp, ldexp, modf \- split into mantissa and exponent
@@ -27,13 +29,13 @@ and stores an integer
 such that
 .I value
 =
 such that
 .I value
 =
-.IR x *2** n
+\fIx\fP\|\(**\|2\u\fIn\fP\d
 indirectly through 
 .I eptr.
 .PP
 .I Ldexp
 returns the quantity
 indirectly through 
 .I eptr.
 .PP
 .I Ldexp
 returns the quantity
-.IR value *2** exp.
+\fIvalue\|\(**\|2\u\fIexp\fP\d.
 .PP
 .I Modf
 returns the positive fractional part of
 .PP
 .I Modf
 returns the positive fractional part of
diff --git a/usr/man/man3/gamma.3m b/usr/man/man3/gamma.3m
new file mode 100644 (file)
index 0000000..382e53d
--- /dev/null
@@ -0,0 +1,36 @@
+.TH GAMMA 3M 
+.SH NAME
+gamma \- log gamma function
+.SH SYNOPSIS
+.B #include <math.h>
+.PP
+.B double gamma(x)
+.br
+.B double x;
+.SH DESCRIPTION
+.I Gamma
+returns
+ln |\(*G(|\fIx\fR|)|.
+The sign of
+\(*G(|\fIx\fR|)
+is returned in the external integer
+.IR signgam .
+The following C program might be
+used to calculate
+\(*G:
+.PP
+       y = gamma(x);
+.br
+       if (y > 88.)
+.br
+               error( );
+.br
+       y = exp(y);
+.br
+       if(signgam)
+.br
+               y = \-y;
+.SH DIAGNOSTICS
+A huge value is returned for negative integer arguments.
+.SH BUGS
+There should be a positive indication of error.
diff --git a/usr/man/man3/getarg.3f b/usr/man/man3/getarg.3f
new file mode 100644 (file)
index 0000000..f5d2a4e
--- /dev/null
@@ -0,0 +1,35 @@
+.TH GETARG 3F
+.SH NAME
+getarg, iargc \- command arguments to Fortran
+.nf
+.ft B
+subroutine getarg( argno, string )
+integer argno
+character \(**(\(**) string
+.PP
+.B iargc()
+.fi
+.ft R
+.SH DESCRIPTION
+These procedures permit Fortran programs to access the command arguments.
+The integer function
+.B iargc
+returns the number of command arguments.
+The subroutine
+.B getarg
+stores the nth command argument in its second argument.
+The string is truncated or padded with blanks,
+in accord with the rules of Fortran character assignment.
+.PP
+The command
+       go arg1 argument2
+.br
+will return 2 as the value of
+.B iargc.
+If \fBs\fR is declared character\(**4,
+then
+      call getarg(2, s)
+.br
+will put "argu" in \fBs\fR.
+.SH "SEE ALSO"
+exec(2)
index 3191d1a..e48e8c3 100644 (file)
@@ -40,7 +40,7 @@ it may be used to save object text.
 .PP
 .I Getw
 returns the next
 .PP
 .I Getw
 returns the next
-word from the named input
+word (32-bit integer under UNIX/32V) from the named input
 .IR stream .
 It returns the constant
 .SM
 .IR stream .
 It returns the constant
 .SM
index d791817..d0da6d3 100644 (file)
@@ -1,7 +1,6 @@
 .TH GETPWENT 3 
 .SH NAME
 .TH GETPWENT 3 
 .SH NAME
-getpwent, getpwuid, getpwnam, setpwent, endpwent
-\- get password file entry
+getpwent, getpwuid, getpwnam, setpwent, endpwent \- get password file entry
 .SH SYNOPSIS
 .B #include <pwd.h>
 .PP
 .SH SYNOPSIS
 .B #include <pwd.h>
 .PP
index 76f5b81..6e6f60a 100644 (file)
@@ -73,7 +73,7 @@ or ERANGE.
 The values of EDOM and ERANGE are defined in
 the include file
 .I <math.h>.
 The values of EDOM and ERANGE are defined in
 the include file
 .I <math.h>.
-.SH ASSEMBLER
+.SH "ASSEMBLER (PDP-11)"
 In assembly language these functions may be accessed
 by simulating the C calling sequence.
 For example,
 In assembly language these functions may be accessed
 by simulating the C calling sequence.
 For example,
index 5b3c3de..ac373b6 100644 (file)
@@ -29,7 +29,7 @@ performs the reverse conversion from long integers
 to three-byte integers
 .RI ( cp ).
 .PP
 to three-byte integers
 .RI ( cp ).
 .PP
-These functions are useful for file-system maintenance;
-disk addresses are three bytes long.
+These functions are useful for file-system maintenance
+where the i-numbers are three bytes long.
 .SH SEE ALSO
 filsys(5)
 .SH SEE ALSO
 filsys(5)
diff --git a/usr/man/man3/mp.3x b/usr/man/man3/mp.3x
deleted file mode 100644 (file)
index c8c507a..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-.TH MP 3X
-.SH NAME
-itom, madd, msub, mult, mdiv, min, mout,
-pow, gcd, rpow \- multiple precision integer arithmetic
-.SH SYNOPSIS
-.nf
-.B "typedef struct { int len; short *val; } mint;"
-.PP
-.PP
-.B madd(a, b, c)
-.B msub(a, b, c)
-.B mult(a, b, c)
-.B mdiv(a, b, q, r)
-.B min(a)
-.B mout(a)
-.B pow(a, b, m, c)
-.B gcd(a, b, c)
-.B rpow(a, b, c)
-.B msqrt(a, b, r)
-.B mint *a, *b, *c, *m, "*q, *r;"
-.PP
-.B
-.B sdiv(a, n, q, r)
-.B mint *a, *q;
-.B short *r;
-.PP
-.B mint *itom(n)
-.SH DESCRIPTION
-These routines perform arithmetic on integers of
-arbitrary length.
-The integers are stored using the defined type
-.I mint.
-Pointers to
-a
-.I mint
-should be initialized using the function
-.IR itom ,
-which sets the initial value to
-.IR n .
-After that space is managed automatically by the routines.
-.PP
-.IR madd , " msub" , " mult" ,
-assign to their third arguments the sum, difference, and
-product, respectively, of their first two arguments.
-.I mdiv
-assigns the quotient and remainder, respectively,
-to its third and fourth arguments.
-.I sdiv
-is like
-.I mdiv
-except that the divisor is an ordinary integer.
-.I msqrt
-produces the square root and remainder of its first argument.
-.I rpow
-calculates
-.I a
-raised to the power
-.IR b ,
-while
-.I pow
-calculates this reduced modulo
-.IR m .
-.IR min " and" mout
-do decimal input and output.
-.PP
-The functions are obtained with the
-loader option
-.IR -lmp .
-.SH DIAGNOSTICS
-Illegal operations and running out of memory
-produce messages and core images.
diff --git a/usr/man/man3/pkopen.3 b/usr/man/man3/pkopen.3
deleted file mode 100644 (file)
index 841b4b2..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-.TH PKOPEN 3 deprecated
-.SH NAME
-pkopen, pkclose, pkread, pkwrite, pkfail \- packet driver simulator
-.SH SYNOPSIS
-.B char *pkopen(fd)
-.PP
-.B pkclose(ptr)
-.br
-.B char *ptr;
-.PP
-.B pkread(ptr, buffer, count)
-.br
-.B char *ptr, *buffer;
-.PP
-.B pkwrite(ptr, buffer, count)
-.br
-.B char *ptr, *buffer;
-.PP
-.B pkfail()
-.SH DESCRIPTION
-These routines are a user-level implementation of the 
-full-duplex
-end-to-end communication protocol described in
-.IR pk (4).
-If
-.I fd
-is a file descriptor open for reading and writing,
-.I pkopen
-carries out the initial synchronization and returns an identifying
-pointer.
-The pointer
-is used as the first parameter to
-.I pkread,
-.I pkwrite,
-and
-.I pkclose.
-.PP
-.I Pkread, pkwrite
-and
-.I pkclose
-behave analogously to
-.I read, write
-and
-.IR close (2).
-However, a write of zero bytes
-is meaningful and will produce a corresponding
-read of zero bytes.
-.SH SEE ALSO
-pk(4), pkon(2)
-.SH DIAGNOSTICS
-.I Pkfail
-is called upon persistent breakdown of communication.
-.I Pkfail
-must be supplied by the user.
-.PP
-.I Pkopen
-returns a null (0) pointer if packet protocol
-can not be established.
-.PP
-.I Pkread
-returns \-1 on end of file,
-0 in correspondence with a 0-length write.
-.SH BUGS
-This simulation of
-.IR pk (4)
-leaves something to be desired
-in needing special read and write routines, and in
-not being inheritable across calls of
-.IR exec (2).
-Its prime use is on systems that lack
-.I pk.
-.br
-These functions use
-.IR alarm (2);
-simultaneous use of
-.I alarm
-for other puposes may cause trouble.
index 3319f12..9b0916f 100644 (file)
@@ -1,4 +1,4 @@
-.TH PRINTF 3S 
+.TH PRINTF 3S
 .SH NAME
 printf, fprintf, sprintf \- formatted output conversion
 .SH SYNOPSIS
 .SH NAME
 printf, fprintf, sprintf \- formatted output conversion
 .SH SYNOPSIS
@@ -187,7 +187,8 @@ The unsigned integer
 .I arg
 is converted to decimal
 and printed (the result will be in the
 .I arg
 is converted to decimal
 and printed (the result will be in the
-range 0 to 65535).
+range 0 through MAXUINT, where MAXUINT equals 4294967295 on a VAX-11
+and 65536 on a PDP-11).
 .TP
 .B %
 Print a `%'; no argument is converted.
 .TP
 .B %
 Print a `%'; no argument is converted.
index 147360f..6279647 100644 (file)
@@ -1,4 +1,4 @@
-.TH RAND 3 
+.TH RAND 3 "UNIX/32V"
 .SH NAME
 rand, srand \- random number generator
 .SH SYNOPSIS
 .SH NAME
 rand, srand \- random number generator
 .SH SYNOPSIS
@@ -13,7 +13,7 @@ uses a multiplicative congruential
 random number generator
 with period 2\u\s732\s0\d
 to return successive pseudo-random
 random number generator
 with period 2\u\s732\s0\d
 to return successive pseudo-random
-numbers in the range from 0 to 2\u\s715\s10\d\-1.
+numbers in the range from 0 to 2\u\s731\s10\d\-1.
 .PP
 The generator is reinitialized by calling
 .I srand
 .PP
 The generator is reinitialized by calling
 .I srand
index 47c4e3f..45a0d69 100644 (file)
@@ -1,12 +1,12 @@
 .TH STRING 3 
 .SH NAME
 .TH STRING 3 
 .SH NAME
-strcat, strncat, strcmp, strncmp, strcpy, strncpy, strlen, index, rindex \- string operations
+strcat, strcatn, strcmp, strcmpn, strcpy, strcpyn, strlen, index, rindex \- string operations
 .SH SYNOPSIS
 .B char *strcat(s1, s2)
 .br
 .B char *s1, *s2;
 .PP
 .SH SYNOPSIS
 .B char *strcat(s1, s2)
 .br
 .B char *s1, *s2;
 .PP
-.B char *strncat(s1, s2, n)
+.B char *strcatn(s1, s2, n)
 .br
 .B char *s1, *s2;
 .PP
 .br
 .B char *s1, *s2;
 .PP
@@ -14,7 +14,7 @@ strcat, strncat, strcmp, strncmp, strcpy, strncpy, strlen, index, rindex \- stri
 .br
 .B char *s1, *s2;
 .PP
 .br
 .B char *s1, *s2;
 .PP
-.B strncmp(s1, s2, n)
+.B strcmpn(s1, s2, n)
 .br
 .B char *s1, *s2;
 .PP
 .br
 .B char *s1, *s2;
 .PP
@@ -22,7 +22,7 @@ strcat, strncat, strcmp, strncmp, strcpy, strncpy, strlen, index, rindex \- stri
 .br
 .B char *s1, *s2;
 .PP
 .br
 .B char *s1, *s2;
 .PP
-.B char *strncpy(s1, s2, n)
+.B char *strcpyn(s1, s2, n)
 .br
 .B char *s1, *s2;
 .PP
 .br
 .B char *s1, *s2;
 .PP
@@ -46,7 +46,7 @@ appends a copy of string
 .I s2
 to the end of string
 .IR s1 .
 .I s2
 to the end of string
 .IR s1 .
-.I Strncat
+.I Strcatn
 copies at most
 .I n
 characters.
 copies at most
 .I n
 characters.
@@ -60,7 +60,7 @@ according as
 is lexicographically greater than, equal to, or
 less than
 .IR s2 .
 is lexicographically greater than, equal to, or
 less than
 .IR s2 .
-.I Strncmp
+.I Strcmpn
 makes the same comparison but looks at at most
 .I n
 characters.
 makes the same comparison but looks at at most
 .I n
 characters.
@@ -71,7 +71,7 @@ copies string
 to
 .I s1,
 stopping after the null character has been moved.
 to
 .I s1,
 stopping after the null character has been moved.
-.I Strncpy
+.I Strcpyn
 copies exactly
 .I n
 characters,
 copies exactly
 .I n
 characters,
@@ -103,4 +103,4 @@ does not occur in  the string.
 .SH BUGS
 .I Strcmp 
 uses native character comparison, which is signed
 .SH BUGS
 .I Strcmp 
 uses native character comparison, which is signed
-on PDP11's, unsigned on other machines.
+on PDP11's and VAX-11's, unsigned on other machines.
index f56c3ff..be862e3 100644 (file)
@@ -1,6 +1,6 @@
 .TH SYSTEM 3
 .SH NAME
 .TH SYSTEM 3
 .SH NAME
-system \- issue a shell command 
+system \- issue a shell command
 .SH SYNOPSIS
 .B system(string)
 .br
 .SH SYNOPSIS
 .B system(string)
 .br
diff --git a/usr/man/man4/dc.4 b/usr/man/man4/dc.4
new file mode 100644 (file)
index 0000000..391566b
--- /dev/null
@@ -0,0 +1,21 @@
+.TH DC 4 
+.SH NAME
+dc \- DC-11 communications interface
+.SH DESCRIPTION
+The discussion of typewriter I/O given in
+.IR tty (4)
+applies to these devices.
+.PP
+The DC-11 typewriter interface operates at any of four speeds,
+independently settable for input and output.
+The speed is selected by the same encoding used by the
+.IR dh (4)
+device (enumerated in
+.IR stty (2));
+impossible speed changes are ignored.
+.SH FILES
+/dev/tty[01234567abcd]   113B Dataphones
+(not currently connected\- see
+.IR dh (4))
+.SH "SEE ALSO"
+tty(4), stty(2), dh(4)
diff --git a/usr/man/man4/dh.4 b/usr/man/man4/dh.4
new file mode 100644 (file)
index 0000000..3935cfa
--- /dev/null
@@ -0,0 +1,15 @@
+.TH DH 4 
+.SH NAME
+dh \- DH-11 communications multiplexer
+.SH DESCRIPTION
+Each line attached to the DH-11 communications multiplexer
+behaves as described in
+.IR tty (4).
+Input and output for each line may independently
+be set to run at any of 16 speeds;
+see stty(2)
+for the encoding.
+.SH FILES
+/dev/tty[f-u]
+.SH "SEE ALSO"
+tty(4), stty(2)
diff --git a/usr/man/man4/dp.4 b/usr/man/man4/dp.4
new file mode 100644 (file)
index 0000000..a9ff408
--- /dev/null
@@ -0,0 +1,29 @@
+.TH DP 4 
+.SH NAME
+dp \- DP-11 201 data-phone interface
+.SH DESCRIPTION
+The
+.I dp0
+file
+is a 201 data-phone interface.
+.I Read
+and
+.I write
+calls
+to dp0
+are limited to a maximum of 512 bytes.
+Each write call is sent as a single record.
+Seven bits from each byte
+are written along with an eighth odd parity
+bit.
+The sync must be user supplied.
+Each read call returns characters received from a
+single record.
+Seven bits are returned unaltered; the eighth bit
+is set if the byte was not received in odd parity.
+A 10 second time out is set and a zero-byte
+record is returned if nothing is received in that time.
+.SH FILES
+/dev/dp0
+.SH "SEE ALSO"
+dn(4), gerts(3)
diff --git a/usr/man/man4/du.4 b/usr/man/man4/du.4
deleted file mode 100644 (file)
index e3366b5..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-.TH DU 4 
-.SH NAME
-du, dp \- DU-11 201 data-phone interface
-.SH DESCRIPTION
-The
-.I dp0
-file
-is a 201 data-phone interface.
-.I Read
-and
-.I write
-calls
-to dp0
-are limited to a maximum of 512 bytes.
-Each write call is sent as a single record.
-Seven bits from each byte
-are written along with an eighth odd parity
-bit.
-The sync must be user supplied.
-Each read call returns characters received from a
-single record.
-Seven bits are returned unaltered; the eighth bit
-is set if the byte was not received in odd parity.
-A 10 second time out is set and a zero-byte
-record is returned if nothing is received in that time.
-.SH FILES
-/dev/dp0
-.SH "SEE ALSO"
-dn(4)
-.SH BUGS
-The name
-.I dp0
-is a historical dreg.
diff --git a/usr/man/man4/dz.4 b/usr/man/man4/dz.4
new file mode 100644 (file)
index 0000000..8e7f84a
--- /dev/null
@@ -0,0 +1,15 @@
+.TH DZ 4 
+.SH NAME
+dz \- DZ-11 communications multiplexer
+.SH DESCRIPTION
+Each line attached to the DZ-11 communications multiplexer
+behaves as described in
+.IR tty (4).
+Each line may
+be set to run at any of 16 speeds;
+see stty(2)
+for the encoding.
+.SH FILES
+/dev/tty*
+.SH "SEE ALSO"
+tty(4), stty(2)
index 04f00ad..9624aa3 100644 (file)
@@ -1,47 +1,58 @@
 .TH HP 4 
 .SH NAME
 .TH HP 4 
 .SH NAME
-hp \- RH-11/RP04, RP05, RP06 moving-head disk
+hp \- RH-11/RP04, RP05, RP06, RM03 moving-head disk
 .SH DESCRIPTION
 .SH DESCRIPTION
-The octal representation of the minor device number is encoded
-.IR idp ,
-where
-.I i
-is an interleave flag,
-.I d
-is a physical drive number,
-and
-.I p
-is a pseudodrive (subsection) within a physical unit.
-If
-.I i
-is 0,
-the origins and sizes of the pseudodisks on each drive,
-counted in cylinders of 418 512-byte blocks, are:
-.nf
+Files with minor device numbers 0 through 7 refer to various portions
+of drive 0;
+minor devices 8 through 15 refer to drive 1, etc.
 .PP
 .PP
+The origin and size of the pseudo-disks on each drive are
+as follows:
+.PP
+RP partitions
+.br
        disk    start   length
        disk    start   length
-       0       0       23
-       1       23      21
+.br
+       0       0       9614
+.br
+       1       9614    8778
+.br
        2       0       0
        2       0       0
+.br
        3       0       0
        3       0       0
-       4       44      386
-       5       430     385
-       6       44      367
-       7       44      771
-.fi
+.br
+       4       0       0
+.br
+       5       0       0
+.br
+       6       10450   330220
+.br
+       7       18392   322278
 .PP
 .PP
-If
-.I i
-is 1, the minor device consists of the specified 
-pseudodisk on drives numbered 0 through the designated
-drive number.
-Successively numbered blocks are distributed
-across the drives in rotation.
+RM partitions
+.br
+       disk    start   length
+.br
+       0       0       9600
+.br
+       1       9600    8800
+.br
+       2       0       0
+.br
+       3       0       0
+.br
+       4       0       0
+.br
+       5       0       0
+.br
+       6       9600    122080
+.br
+       7       18400   113280
 .PP
 .PP
-Systems distributed for these devices
-use disk 0 for the root, disk 1 for swapping, and
-disk 4 (RP04/5) or disk 7 (RP06) for a mounted
-user file system.
+It is unwise for all of these files to be present in one installation,
+since there is overlap in addresses and protection becomes
+a sticky matter.
+Ordinarily devices 0 and 6 (or 0 and 7) will be used.
 .PP
 The
 block
 .PP
 The
 block
@@ -50,9 +61,8 @@ access the disk via the system's normal
 buffering mechanism
 and may be read and written without regard to
 physical disk records.
 buffering mechanism
 and may be read and written without regard to
 physical disk records.
-.PP
-A `raw' interface
-provides for direct transmission between the disk
+There is also a `raw' interface
+which provides for direct transmission between the disk
 and the user's read or write buffer.
 A single read or write call results in exactly one I/O operation
 and therefore raw I/O is considerably more efficient when
 and the user's read or write buffer.
 A single read or write call results in exactly one I/O operation
 and therefore raw I/O is considerably more efficient when
@@ -61,27 +71,14 @@ The names of the raw files
 conventionally
 begin with
 an extra `r.'
 conventionally
 begin with
 an extra `r.'
+.PP
 In raw I/O the buffer must begin on a word boundary,
 In raw I/O the buffer must begin on a word boundary,
-and raw I/O to an interleaved device is likely to have
-disappointing results.
+and counts should be a multiple of 512 bytes
+(a disk block).
+Likewise
+.I seek
+calls should specify a multiple of 512 bytes.
 .SH FILES
 /dev/rp?, /dev/rrp?
 .SH SEE ALSO
 rp(4)
 .SH FILES
 /dev/rp?, /dev/rrp?
 .SH SEE ALSO
 rp(4)
-.SH BUGS
-In raw I/O
-.I read
-and
-.IR write (2)
-truncate file offsets to 512-byte block boundaries,
-and
-.I write
-scribbles on the tail of incomplete blocks.
-Thus,
-in programs that are likely to access raw devices,
-.I read, write
-and
-.IR lseek (2)
-should always deal in 512-byte multiples.
-.PP
-Raw device drivers don't work on interleaved devices.
index 62f7fd5..0f255ae 100644 (file)
@@ -1,20 +1,24 @@
-.TH HT 4 
+.TH HT 4 UNIX/32V
 .SH NAME
 .SH NAME
-ht \- RH-11/TU-16 magtape interface
+ht \- RH-11/TE-16 magtape interface
 .SH DESCRIPTION
 The files
 .SH DESCRIPTION
 The files
-.I mt0, mt1, ...
-refer to the DEC RH/TM/TU16 magtape.
-When opened for reading or writing,
-the tape is not rewound.
-When closed, it is rewound (unless the 0200 bit is on, see below).
-If the tape was open for writing, a double end-of-file is written.
-If the tape is not to be rewound the 
-tape is backspaced to just between the two
-tapemarks.
+.I "mt0, ..., mt15"
+refer to the DEC RH/TM/TE-16 magtape.
+The files
+.I "mt0, ..., mt7"
+are 800 bpi, and
+.I "mt8, ..., mt15"
+are 1600bpi.
+The files
+.I "mt0, ..., mt3"
+and
+.I "mt8, ..., mt11"
+are rewound when closed; the others are not.
+When a file open for writing is closed, a double end-of-file is written.
 .PP
 A standard tape consists of a
 .PP
 A standard tape consists of a
-series of 512 byte records terminated by a double
+series of 512 byte records terminated by an
 end-of-file.
 To the extent possible, the system makes
 it possible, if inefficient, to treat
 end-of-file.
 To the extent possible, the system makes
 it possible, if inefficient, to treat
@@ -25,22 +29,6 @@ Writing in very small units is inadvisable,
 however, because it tends to create monstrous record
 gaps.
 .PP
 however, because it tends to create monstrous record
 gaps.
 .PP
-The last octal digit of the minor device
-number selects the drive.
-The middle digit selects a controller.
-The initial digit is even to select 800 BPI,
-odd to select 1600 BPI.
-If the 0200 bit is on (initial digit 2 or 3), the tape is not rewound
-on close.
-Note that the
-minor device number has no necessary connection
-with the file name, and in fact
-.IR tp (1)
-turns the short name
-.I x
-into
-.RI `/dev/mt x '.
-.PP
 The
 .I mt
 files discussed above are useful
 The
 .I mt
 files discussed above are useful
@@ -50,7 +38,7 @@ When foreign tapes are to be dealt with, and especially
 when long records are to be read or written, the
 `raw' interface is appropriate.
 The associated files may be named
 when long records are to be read or written, the
 `raw' interface is appropriate.
 The associated files may be named
-.I "rmt0, ..., rmt7,"
+.I "rmt0, ..., rmt15,"
 but the same minor-device considerations
 as for the regular files still apply.
 .PP
 but the same minor-device considerations
 as for the regular files still apply.
 .PP
@@ -80,9 +68,10 @@ tp(1)
 The magtape system is supposed to be able
 to take 64 drives.
 Such addressing has never been tried.
 The magtape system is supposed to be able
 to take 64 drives.
 Such addressing has never been tried.
+These bugs will be fixed when
+we get more experience with this device.
 .PP
 .PP
-Taking a drive off line, or running off the end of tape,
-while writing have been known to hang the system.
+The driver is limited to four transports.
 .PP
 If any non-data error is encountered, it refuses to do anything
 more until closed.
 .PP
 If any non-data error is encountered, it refuses to do anything
 more until closed.
diff --git a/usr/man/man4/kl.4 b/usr/man/man4/kl.4
new file mode 100644 (file)
index 0000000..aaa95e7
--- /dev/null
@@ -0,0 +1,24 @@
+.TH KL 4 
+.SH NAME
+kl \- KL-11 or DL-11 asynchronous interface
+.SH DESCRIPTION
+The discussion of terminal I/O given in
+.IR tty (4)
+applies to these devices.
+.PP
+Since they run at a constant speed, attempts
+to change the speed via
+.IR stty (2)
+are ignored.
+.PP
+The on-line console terminal is interfaced using
+a KL-11 or DL-11.
+By appropriate switch settings during a reboot,
+UNIX will come up as a single-user system with I/O
+on the console terminal.
+.SH FILES
+/dev/console   console
+.SH "SEE ALSO"
+tty(4), init(8)
+.SH BUGS
+Modem control for the DL-11E is not implemented.
diff --git a/usr/man/man4/kmem.4 b/usr/man/man4/kmem.4
new file mode 100644 (file)
index 0000000..7ab48e0
--- /dev/null
@@ -0,0 +1 @@
+.so /usr/man/man4/mem.4
diff --git a/usr/man/man4/lp.4 b/usr/man/man4/lp.4
new file mode 100644 (file)
index 0000000..46b2f98
--- /dev/null
@@ -0,0 +1,92 @@
+.TH LP 4 
+.SH NAME
+lp \- line printer
+.SH DESCRIPTION
+.I Lp
+provides the interface to any of the standard
+DEC line printers.
+When it is opened or closed, a suitable number
+of page ejects is generated.
+Bytes written are printed.
+.PP
+An internal parameter within the driver determines
+whether or not the device is treated as having
+a 96- or 64-character set.
+In half-ASCII mode, lower case letters are turned
+into
+upper case
+and certain characters are escaped according to
+the following table:
+.PP
+.if t .ig
+.br
+.ns
+.TP 10
+{
+(\b-
+.br
+.ns
+.TP 10
+}
+)\b-
+.br
+.ns
+.TP 10
+\`
+\'\b-
+.br
+.ns
+.TP 10
+|
+!\b-
+.br
+.ns
+.TP 10
+~
+^\b-
+..
+.if n .ig
+.br
+.ns
+.TP 10
+{
+\o"(\-"
+.br
+.ns
+.TP 10
+}
+\o")\-"
+.br
+.ns
+.TP 10
+\`
+\o"\'\-"
+.br
+.ns
+.TP 10
+|
+\o"!\-"
+.br
+.ns
+.TP 10
+~
+\o"^\-"
+..
+.PP
+The driver correctly interprets
+carriage returns, backspaces, tabs, and form feeds.
+A sequence of newlines which extends over the end of
+a page is turned into a form feed.
+All lines are indented 8 characters.
+Lines longer than 80 characters are truncated.
+These numbers are parameters in the driver;
+another parameter allows indenting all printout
+if it is unpleasantly near the left margin.
+.SH FILES
+/dev/lp
+.SH "SEE ALSO"
+lpr(1)
+.SH BUGS
+Half-ASCII mode, the indent and the maximum line length should
+be settable by a call analogous to
+.IR stty (2).
index e3f6612..e7f125d 100644 (file)
@@ -1,35 +1,40 @@
 .TH MEM 4 
 .SH NAME
 .TH MEM 4 
 .SH NAME
-mem, kmem  \-  core memory
+mem, kmem  \-  main memory
 .SH DESCRIPTION
 .I Mem
 .SH DESCRIPTION
 .I Mem
-is a special file that is an image of the core memory
+is a special file that is an image of the main memory
 of the computer.
 of the computer.
-It may be used, for example, to examine,
-and even to patch the system.
-.I Kmem
-is the same as 
-.I mem
-except that kernel virtual memory
-rather than physical memory is accessed.
+It may be used, for example, to examine
+(and even to patch) the system.
 .PP
 .PP
-Byte addresses
-are interpreted as memory addresses.
-References to non-existent locations return errors.
+Byte addresses in
+.I mem
+are interpreted as physical memory addresses.
+References to non-existent locations cause errors to be returned.
 .PP
 Examining and patching device registers is likely
 to lead to unexpected results when read-only or write-only
 bits are present.
 .PP
 .PP
 Examining and patching device registers is likely
 to lead to unexpected results when read-only or write-only
 bits are present.
 .PP
+The file
+.I kmem
+is the same as 
+.I mem
+except that kernel virtual memory
+rather than physical memory is accessed.
+.PP
 On PDP11's, the I/O page
 begins at location 0160000 of
 .I kmem
 and per-process data for the current process
 begins at 0140000.
 On PDP11's, the I/O page
 begins at location 0160000 of
 .I kmem
 and per-process data for the current process
 begins at 0140000.
+On VAX11's the I/O space begins at physical address 20000000(16)
+and per-process data for the current process is at virtual 80020000(16).
 .SH FILES
 /dev/mem,
 /dev/kmem
 .SH BUGS
 .SH FILES
 /dev/mem,
 /dev/kmem
 .SH BUGS
-On PDP11's, memory files are accessed one byte
+On PDP11's and VAX11's, memory files are accessed one byte
 at a time, an inapproriate method for some
 device registers.
 at a time, an inapproriate method for some
 device registers.
diff --git a/usr/man/man4/pc.4 b/usr/man/man4/pc.4
new file mode 100644 (file)
index 0000000..ccac08e
--- /dev/null
@@ -0,0 +1,38 @@
+.TH PC 4 
+.SH NAME
+pc  \-  PC-11 paper tape reader/punch
+.SH DESCRIPTION
+.I Ppt
+refers to the PC-11 paper tape reader or punch,
+depending on whether it is read or written.
+.PP
+When
+.I ppt
+is opened for writing, a 100-character leader
+is punched.
+Thereafter each byte written is punched on
+the tape.  No editing of the characters
+is performed.
+When the file is closed, a 100-character trailer is punched.
+.PP
+When
+.I ppt
+is opened for reading, the process
+waits until tape is placed in the reader and the reader
+is on-line.
+Then requests to read cause the characters read
+to be passed back to the program, again without
+any editing.
+This means that several null leader characters
+will usually appear at the beginning of the file.
+Likewise several nulls are likely to appear at the end.
+End-of-file is generated when the tape runs out.
+.PP
+Seek calls for this file are meaningless.
+.SH FILES
+/dev/ppt
+.SH BUGS
+If both the reader and the punch are open simultaneously,
+the trailer is sometimes not punched.
+Sometimes the reader goes into a dead state in which it cannot be
+opened.
index 98a097b..4647f9e 100644 (file)
@@ -8,7 +8,13 @@ refer to sections of RP disk drive 0.
 The files
 .I "rp8 ... rp15"
 refer to drive 1 etc.
 The files
 .I "rp8 ... rp15"
 refer to drive 1 etc.
-This allows a large disk to be broken up
+This is done since the size of
+a full RP drive is 81200 blocks and
+internally the system is only capable
+of addressing 65536
+blocks.
+Also since the disk is so large,
+this allows it to be broken up
 into more manageable pieces.
 .PP
 The origin and size of the pseudo-disks on each drive are
 into more manageable pieces.
 .PP
 The origin and size of the pseudo-disks on each drive are
@@ -17,19 +23,49 @@ as follows:
 .br
        disk    start   length
 .br
 .br
        disk    start   length
 .br
-       0       0       81000
+       0       0       40600
 .br
 .br
-       1       0       5000
+       1       40600   40600
 .br
 .br
-       2       5000    2000
+       2       0       9200
 .br
 .br
-       3       7000    74000
+       3       72000   9200
 .br
 .br
-       4-7     unassigned
+       4       0       65535
+.br
+       5       15600   65535
+.br
+       6-7     unassigned
+.PP
+It is unwise for all of these files to be present in one installation,
+since there is overlap in addresses and protection becomes
+a sticky matter.
+Here is a suggestion for two useful configurations:
+If the root of the file system is on some other device
+and the RP used as a mounted device,
+then
+.I rp0
+and
+.I rp1,
+which divide the disk into two equal size portions, is a good idea.
+Other things being equal, it is advantageous to have two equal-sized portions
+since one can always be copied onto the other, which is occasionally useful.
 .PP
 .PP
-Thus rp0 covers the whole drive,
-while rp1, rp2, rp3 can serve usefully as a root, swap, and
-mounted user file system respectively.
+If the RP is the only disk and has to
+contain the root and the swap area,
+the root can be put on
+.I rp2
+and a mountable file system on
+.IR rp5 .
+Then the swap space can be put in the
+unused blocks 9200 to 15600 of
+.I rp0
+(or, equivalently,
+.IR rp4) .
+This arrangement puts the root file system, the swap area,
+and the i-list of the mounted file system relatively
+near each other and thus tends to
+minimize head movement.
 .PP
 The
 .I rp
 .PP
 The
 .I rp
@@ -52,23 +88,13 @@ section as the corresponding
 .I rp
 file.
 .PP
 .I rp
 file.
 .PP
-In raw I/O the buffer must begin on a word boundary.
+In raw I/O the buffer must begin on a word boundary,
+and counts should be a multiple of 512 bytes
+(a disk block).
+Likewise
+.I seek
+calls should specify a multiple of 512 bytes.
 .SH FILES
 /dev/rp?, /dev/rrp?
 .SH SEE ALSO
 hp(4)
 .SH FILES
 /dev/rp?, /dev/rrp?
 .SH SEE ALSO
 hp(4)
-.SH BUGS
-In raw I/O
-.I read
-and
-.IR write (2)
-truncate file offsets to 512-byte block boundaries,
-and
-.I write
-scribbles on the tail of incomplete blocks.
-Thus,
-in programs that are likely to access raw devices,
-.I read, write
-and
-.IR lseek (2)
-should always deal in 512-byte multiples.
index 4b0fef4..9306851 100644 (file)
@@ -5,14 +5,10 @@ tm \- TM-11/TU-10 magtape interface
 The files
 .I "mt0, ..., mt7"
 refer to the DEC TU10/TM11 magtape.
 The files
 .I "mt0, ..., mt7"
 refer to the DEC TU10/TM11 magtape.
-When closed it can be rewound or not, see below.
-If it was open for writing, two end-of-files are written.
-If the tape is not to be rewound
-it is positioned with the head between the two
-tapemarks.
-.PP
-If the 0200 bit is on in the minor device number the
-tape is not rewound when closed.
+When opened for reading or writing,
+the tape is rewound.
+When closed, it is rewound;
+if it was open for writing, an end-of-file is written first.
 .PP
 A standard tape consists of a
 series of 512 byte records terminated by an
 .PP
 A standard tape consists of a
 series of 512 byte records terminated by an
index 959e3a9..e06bb5a 100644 (file)
@@ -23,7 +23,9 @@ communications ports use the
 same general interface, no matter what
 hardware is involved.
 The remainder of this section discusses
 same general interface, no matter what
 hardware is involved.
 The remainder of this section discusses
-the common features of the interface.
+the common features of the interface
+and differences resulting from the particular device,
+KL-11 or DH-11, on which the interface is implemented.
 .PP
 When a terminal file is opened, it causes
 the process to wait until a connection is established.
 .PP
 When a terminal file is opened, it causes
 the process to wait until a connection is established.
@@ -96,7 +98,7 @@ all upper-case letters are mapped into
 the corresponding lower-case letter.
 The upper-case letter may be generated by preceding
 it by `\\'.
 the corresponding lower-case letter.
 The upper-case letter may be generated by preceding
 it by `\\'.
-In addition, the following escape sequences can be generated
+In addition, the following escape sequences are generated
 on output and accepted on input:
 .PP
 .nf
 on output and accepted on input:
 .PP
 .nf
@@ -111,8 +113,6 @@ for use
 Certain ASCII control characters have special meaning.
 These characters are not passed to a reading program
 except in raw mode where they lose their special character.
 Certain ASCII control characters have special meaning.
 These characters are not passed to a reading program
 except in raw mode where they lose their special character.
-Also, it is possible to change these characters from the default;
-see below.
 .TP
 EOT
 (Control-D) may be used to generate an end of file
 .TP
 EOT
 (Control-D) may be used to generate an end of file
@@ -153,10 +153,8 @@ but a core image file will be generated.
 DC3
 (Control-S) delays all printing on the terminal
 until something is typed in.
 DC3
 (Control-S) delays all printing on the terminal
 until something is typed in.
-.TP
-DC1
-(Control-Q) restarts  printing after DC3 without generating
-any input to a program.
+A second DC3 may be used to restart printing
+without causing any input.
 .PP
 When the carrier signal from the dataset drops (usually
 because the user has hung up his terminal)
 .PP
 When the carrier signal from the dataset drops (usually
 because the user has hung up his terminal)
@@ -192,7 +190,7 @@ that respond to it from hanging up.
 Several
 .IR ioctl (2)
 calls apply to terminals.
 Several
 .IR ioctl (2)
 calls apply to terminals.
-Most of them use the following structure,
+Some of the use the following structure,
 defined in
 .IR <sgtty.h> :
 .PP
 defined in
 .IR <sgtty.h> :
 .PP
@@ -296,7 +294,7 @@ CRMOD       0000020 Map CR into LF; echo LF or CR as CR-LF
 ECHO   0000010 Echo (full duplex)
 LCASE  0000004 Map upper case to lower on input
 CBREAK 0000002 Return each character as soon as typed
 ECHO   0000010 Echo (full duplex)
 LCASE  0000004 Map upper case to lower on input
 CBREAK 0000002 Return each character as soon as typed
-TANDEM 0000001 Automatic flow control
+HUPCL  0000001 Unused
 .DT
 .fi
 .PP
 .DT
 .fi
 .PP
@@ -346,9 +344,9 @@ Mode 020 causes input carriage returns to be turned into
 new-lines;
 input of either CR or LF causes LF-CR both to
 be echoed
 new-lines;
 input of either CR or LF causes LF-CR both to
 be echoed
-(for terminals with a new-line function).
+(used for GE TermiNet 300's and other terminals without the newline function).
 .PP
 .PP
-CBREAK is a sort of half-cooked (rare?) mode.
+CBREAK is a sort of half-cooked mode.
 Programs can read each character as soon as typed, instead
 of waiting for a full line,
 but quit and interrupt work, and output delays, case-translation,
 Programs can read each character as soon as typed, instead
 of waiting for a full line,
 but quit and interrupt work, and output delays, case-translation,
@@ -356,14 +354,6 @@ CRMOD, XTABS, ECHO, and parity work normally.
 On the other hand there is no erase or kill,
 and no special treatment of \e or EOT.
 .PP
 On the other hand there is no erase or kill,
 and no special treatment of \e or EOT.
 .PP
-TANDEM mode causes the system to produce
-a stop character (default DC3) whenever the input
-queue is in danger of overflowing, and a start character
-(default DC1)
-when the input queue has drained sufficiently.
-It is useful for flow control when the `terminal'
-is actually another machine that obeys the conventions.
-.PP
 Several
 .I ioctl
 calls have the form:
 Several
 .I ioctl
 calls have the form:
@@ -381,17 +371,15 @@ Fetch the parameters associated with the terminal, and store
 in the pointed-to structure.
 .TP
 TIOCSETP
 in the pointed-to structure.
 .TP
 TIOCSETP
-Set the parameters according to the pointed-to structure.
+Set the parameters according to the pointed-to strucutre.
 The interface delays until output is quiescent,
 then throws away any unread characters,
 before changing the modes.
 .TP
 TIOCSETN
 The interface delays until output is quiescent,
 then throws away any unread characters,
 before changing the modes.
 .TP
 TIOCSETN
-Set the parameters but do not delay or flush input.
-Switching out of RAW or CBREAK mode
-may cause some garbage input.
+Set the parameters but do not delay of flush input.
 .PP
 .PP
-With the following codes the
+With the collowing codes the
 .I arg
 is ignored.
 .TP
 .I arg
 is ignored.
 .TP
@@ -400,58 +388,21 @@ Set ``exclusive-use'' mode:
 no further opens are permitted until the file has been closed.
 .TP
 TIOCNXCL
 no further opens are permitted until the file has been closed.
 .TP
 TIOCNXCL
-Turn off ``exclusive-use'' mode.
+Turns off ``exclusive-use'' mode.
 .TP
 TIOCHPCL
 When the file is closed for the last time,
 hang up the terminal.
 This is useful when the line is associated
 with an ACU used to place outgoing calls.
 .TP
 TIOCHPCL
 When the file is closed for the last time,
 hang up the terminal.
 This is useful when the line is associated
 with an ACU used to place outgoing calls.
-.TP
-TIOCFLUSH
-All characters waiting in input or output queues are flushed.
 .PP
 .PP
-The following codes affect characters that are special
-to the terminal interface.
-The argument is a pointer to the following structure,
-defined in
-.IR <sgtty.h> :
-.PP
-.nf
-.ft 3
-struct tchars {
-       char    t_intrc;                /* interrupt */
-       char    t_quitc;                /* quit */
-       char    t_startc;       /* start output */
-       char    t_stopc;        /* stop output */
-       char    t_eofc;         /* end-of-file */
-       char    t_brkc;         /* input delimiter (like nl) */
-};
-.fi
-.ft R
-.PP
-The default values for these characters are
-DEL, FS, DC1, DC3, EOT, and \-1.
-A character value of \-1
-eliminates the effect of that character.
-The
-.I t_brkc
-character, by default \-1,
-acts like a new-line in that it terminates a `line,'
-is echoed, and is passed to the program.
-The `stop' and `start' characters may be the same,
-to produce a toggle effect.
-It is probably counterproductive to make
-other special characters (including erase an kill)
-identical.
-.PP
-The calls are:
-.TP
-TIOCSETC
-Change the various special characters to those given in the structure.
-.TP
-TIOCSETP
-Set the special characters to those given in the structure.
+Speed cannot be changed on terminals attached to a KL-11;
+the UNIX console, whose special use is described in
+.IR boot (8),
+is such a terminal.
+Other terminals, called 
+.I /dev/tty*,
+are attached to DZ-11's.
 .SH FILES
 /dev/tty
 .br
 .SH FILES
 /dev/tty
 .br
@@ -462,8 +413,5 @@ Set the special characters to those given in the structure.
 getty(8), stty (1), signal(2), ioctl(2)
 .SH BUGS
 Half-duplex terminals are not supported.
 getty(8), stty (1), signal(2), ioctl(2)
 .SH BUGS
 Half-duplex terminals are not supported.
-.PP
-The terminal handler has clearly entered the
-race for ever-greater complexity and generality.
-It's still not complex and general enough for
-TENEX fans.
+On raw-mode output, parity should be transmitted as specified
+in the characters written.
index adb2c35..2941750 100644 (file)
@@ -1,4 +1,4 @@
-.TH A.OUT 5 
+.TH A.OUT 5 "UNIX/32V"
 .SH NAME
 a.out \- assembler and link editor output
 .SH SYNOPSIS
 .SH NAME
 a.out \- assembler and link editor output
 .SH SYNOPSIS
@@ -13,7 +13,7 @@ Both programs make
 .I a.out
 executable if there were no
 errors and no unresolved external references.
 .I a.out
 executable if there were no
 errors and no unresolved external references.
-Layout information as given in the include file for the PDP11 is:
+Layout information as given in the include file for the VAX-11 is:
 .PP
 .nf
 .ta 8n +9n +11n
 .PP
 .nf
 .ta 8n +9n +11n
@@ -22,7 +22,7 @@ Layout information as given in the include file for the PDP11 is:
 .fi
 .PP
 The file has four sections:
 .fi
 .PP
 The file has four sections:
-a header, the program and data text,
+a header, the program text and data,
 relocation information, and a symbol table
 (in that order).
 The last two may be empty
 relocation information, and a symbol table
 (in that order).
 The last two may be empty
@@ -34,7 +34,7 @@ or if the symbols and relocation have been
 removed by
 .IR strip (1).
 .PP
 removed by
 .IR strip (1).
 .PP
-In the header the sizes of each section are given in bytes, but are even.
+In the header the sizes of each section are given in bytes.
 The size of the header is not included in any of the other sizes.
 .PP
 When an
 The size of the header is not included in any of the other sizes.
 .PP
 When an
@@ -51,40 +51,26 @@ segment is not to be write-protected and shared,
 so the data segment is immediately contiguous
 with the text segment.
 If the magic number is 0410,
 so the data segment is immediately contiguous
 with the text segment.
 If the magic number is 0410,
-the data segment begins at the first 0 mod 8K byte
+the data segment begins at the first 0 mod 512 byte
 boundary following the text segment,
 and the text segment is not writable by the program;
 if other processes are executing the same file,
 they will share the text segment.
 boundary following the text segment,
 and the text segment is not writable by the program;
 if other processes are executing the same file,
 they will share the text segment.
-If the magic number is 411,
-the text segment is again pure, write-protected, and shared,
-and moreover instruction and data space are separated;
-the text and data segment both begin at location 0.
-If the magic number is 0405, the text segment
-is overlaid on an existing (0411 or 0405) text segment
-and the existing data segment is preserved.
 .PP
 The stack will occupy the highest possible locations
 .PP
 The stack will occupy the highest possible locations
-in the core image: from 0177776(8) and growing downwards.
+in the core image: growing downwards from 80000000(16).
 The stack is automatically extended as required.
 The data segment is only extended as requested by
 The stack is automatically extended as required.
 The data segment is only extended as requested by
-.IR brk (2).
+.IR break (2).
 .PP
 .PP
-The start of the text segment in the file is 020(8);
-the start of the data segment is 020+S\s6\dt\u\s10 (the size of the text)
-the start of the relocation information is
-020+S\s6\dt\u\s10+S\s6\dd\u\s10;
-the start of the symbol table is
-020+2(S\s6\dt\u\s10+S\s6\dd\u\s10)
-if the
-relocation information is present,
-020+S\s6\dt\u\s10+S\s6\dd\u\s10
-if not.
+The start of the text segment in the file is 32(10);
+the start of the data segment is 32+a_text;
+the start of the text relocation is 32+a_text+a_data;
+the start of the data relocation is 32+a_text+a_data+a_trsize;
+the start of the symbol table is 32+a_text+a_data+a_trsize+a_drsize.
 .PP
 The layout of a symbol table entry and the principal flag values
 that distinguish symbol types are given in the include file.
 .PP
 The layout of a symbol table entry and the principal flag values
 that distinguish symbol types are given in the include file.
-Other flag values may occur if an assembly language program
-defines machine instructions.
 .PP
 If a symbol's type is undefined external,
 and the value field is non-zero,
 .PP
 If a symbol's type is undefined external,
 and the value field is non-zero,
@@ -95,65 +81,42 @@ the name of a common region
 whose size is indicated by the value of the
 symbol.
 .PP
 whose size is indicated by the value of the
 symbol.
 .PP
-The value of a word in the text or data portions which is not
-a reference to an undefined external symbol
-is exactly that value which will appear in core
+The value of a byte in the text or data which is not
+a portion of a reference to an undefined external symbol
+is exactly that value which will appear in memory
 when the file is executed.
 when the file is executed.
-If a word in the text or data portion
+If a byte in the text or data
 involves a reference to an undefined external symbol,
 involves a reference to an undefined external symbol,
-as indicated by the relocation information
-for that word,
-then the value of the word as stored in the file
+as indicated by the relocation information,
+then the value stored in the file
 is an offset from the associated external symbol.
 When the file is processed by the
 link editor and the external symbol becomes
 defined, the value of the symbol will
 is an offset from the associated external symbol.
 When the file is processed by the
 link editor and the external symbol becomes
 defined, the value of the symbol will
-be added into the word in the file.
+be added to the bytes in the file.
 .PP
 If relocation
 .PP
 If relocation
-information is present, it amounts to one word per
-word of program text or initialized data.
-There is no relocation information if the `relocation info stripped'
-flag in the header is on.
-.PP
-Bits 3-1 of a relocation word indicate the segment referred
-to by the text or data word associated with the relocation
-word:
-.TP
-000
-absolute number
-.br
-.ns
-.TP
-002
-reference to text segment
-.br
-.ns
-.TP
-004
-reference to initialized data
-.br
-.ns
-.TP
-006
-reference to uninitialized data (bss)
-.br
-.ns
-.TP
-010
-reference to undefined external symbol
-.PP
-Bit 0 of the relocation word indicates, if 1,
-that the
-reference is relative to the pc (e.g. `clr x');
-if 0,
-that
-the reference is to the actual symbol (e.g.,
-`clr *$x').
+information is present, it amounts to six bytes per
+relocatable dataum.
+There is no relocation information if a_trsize+a_drsize==0.
+The relocation information is structured as
+.nf
+.ta 4n,+17n
 .PP
 .PP
-The remainder of the relocation word (bits 15-4)
-contains a symbol number in the case of external
-references, and is unused otherwise.
-The first symbol is numbered 0, the second 1, etc.
+struct relocation_info {
+       long address;   /* relative to current segment */
+       short pcrel:1,  /* if so, segment offset has already */
+               /* been subtracted */
+         length:2,     /* 0=byte, 1=word, 2=long */
+         extern:1,     /* does not include value */
+               /* of symbol referenced */
+         offset:1,     /* already includes origin */
+               /* of this segment (?) */
+         symbolnum:11;
+               /* if extern then symbol table */
+               /* ordinal (0, 1, 2, ...) else */
+               /* segment number (same as symbol types) */
+};
+.fi
 .SH "SEE ALSO"
 as(1), ld(1), nm(1)
 .SH "SEE ALSO"
 as(1), ld(1), nm(1)
index deff5a6..e762f75 100644 (file)
@@ -1,9 +1,9 @@
 .TH CORE 5 
 .SH NAME
 .TH CORE 5 
 .SH NAME
-core \- format of core image file
+core \- format of memory image file
 .SH DESCRIPTION
 UNIX
 .SH DESCRIPTION
 UNIX
-writes out a core image of a terminated
+writes out a memory image of a terminated
 process when any of various errors occur.
 See
 .IR signal (2)
 process when any of various errors occur.
 See
 .IR signal (2)
@@ -11,24 +11,10 @@ for the list of reasons;
 the most common are memory violations, illegal
 instructions, bus errors, and user-generated
 quit signals.
 the most common are memory violations, illegal
 instructions, bus errors, and user-generated
 quit signals.
-The core image is called `core' and is written in the process's
+The memory image is called `core' and is written in the process's
 working directory (provided it can be; normal
 access controls apply).
 .PP
 working directory (provided it can be; normal
 access controls apply).
 .PP
-The first 1024 bytes of the core image
-are a copy of the system's per-user
-data for the process, including the registers
-as they were at the time of the fault;
-see the system listings for the format of this area.
-The
-remainder represents the actual contents of
-the user's core area when the core image
-was written.
-If the text segment
-is write-protected and shared,
-it is not dumped; otherwise the entire
-address space is dumped.
-.PP
 In general the debugger
 .IR adb (1)
 is sufficient to deal with core images.
 In general the debugger
 .IR adb (1)
 is sufficient to deal with core images.
index c80ed62..d87bd0e 100644 (file)
@@ -2,6 +2,8 @@
 .SH NAME
 dir \- format of directories
 .SH SYNOPSIS
 .SH NAME
 dir \- format of directories
 .SH SYNOPSIS
+.B #include <sys/types.h>
+.br
 .B #include <sys/dir.h>
 .SH DESCRIPTION
 A directory
 .B #include <sys/dir.h>
 .SH DESCRIPTION
 A directory
@@ -14,7 +16,7 @@ see,
 The structure of a directory entry as given in the
 include file is:
 .RS
 The structure of a directory entry as given in the
 include file is:
 .RS
-.ta 8n +6n
+.ta 8n +10n
 .PP
 .nf
 .so /usr/include/sys/dir.h
 .PP
 .nf
 .so /usr/include/sys/dir.h
index 9f1baa9..d642a19 100644 (file)
@@ -33,7 +33,7 @@ is:
 .I S_isize
 is the address of the first block after the i-list,
 which starts just after the super-block, in block 2.
 .I S_isize
 is the address of the first block after the i-list,
 which starts just after the super-block, in block 2.
-Thus is i-list is
+Thus the i-list is
 .IR s_isize \-2
 blocks long.
 .I S_fsize
 .IR s_isize \-2
 blocks long.
 .I S_fsize
index 6f8453b..0c22ebc 100644 (file)
@@ -26,15 +26,15 @@ Each entry has the following format:
 .IP ""
 struct {
        char    pathname[32];
 .IP ""
 struct {
        char    pathname[32];
-       int     mode;
+       unsigned short  mode;
        char    uid;
        char    gid;
        char    unused1;
        char    size[3];
        long    modtime;
        char    uid;
        char    gid;
        char    unused1;
        char    size[3];
        long    modtime;
-       int     tapeaddr;
+       unsigned short  tapeaddr;
        char    unused2[16];
        char    unused2[16];
-       int     checksum;
+       unsigned short  checksum;
 };
 .fi
 .PP
 };
 .fi
 .PP
diff --git a/usr/man/man5/wtmp.5 b/usr/man/man5/wtmp.5
new file mode 100644 (file)
index 0000000..d53e456
--- /dev/null
@@ -0,0 +1,32 @@
+.TH WTMP 5 
+.SH NAME
+wtmp \- user login history
+.SH DESCRIPTION
+This
+file records all logins and logouts.
+Its format is exactly like
+.IR utmp (5)
+except that
+a null user name indicates a logout on the associated
+typewriter.
+Furthermore, the typewriter name `~' indicates that the
+system was rebooted at the indicated time;
+the adjacent pair of entries with typewriter names
+`|' and `}' indicate the system-maintained time
+just before and just after a
+.I date
+command has changed the system's idea of the time.
+.PP
+.I Wtmp
+is maintained by
+.IR login (1)
+and
+.IR init (8).
+Neither of these programs creates the file,
+so if it is removed record-keeping is turned off.
+It is summarized by
+.IR ac (1).
+.SH FILES
+/usr/adm/wtmp
+.SH "SEE ALSO"
+utmp(5), login(1), init(8), ac(1), who(1)
diff --git a/usr/man/man6/banner.6 b/usr/man/man6/banner.6
deleted file mode 100644 (file)
index 2945ecb..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-.TH BANNER 6 
-.SH NAME
-banner \- make long posters
-.SH SYNOPSIS
-.B /usr/games/banner
-.SH DESCRIPTION
-.I Banner
-reads the standard input and
-prints it sideways in huge built-up letters
-on the standard output.
index 3badae5..9b30a77 100644 (file)
@@ -1,18 +1,13 @@
 .TH BCD 6 
 .SH NAME
 .TH BCD 6 
 .SH NAME
-bcd, ppt \- convert to antique media
+bcd \- convert to antique media
 .SH SYNOPSIS
 .B /usr/games/bcd
 text
 .SH SYNOPSIS
 .B /usr/games/bcd
 text
-.PP
-.B /usr/games/ppt
 .SH DESCRIPTION
 .I Bcd
 converts the literal
 .I text
 into a form familiar to old-timers.
 .SH DESCRIPTION
 .I Bcd
 converts the literal
 .I text
 into a form familiar to old-timers.
-.PP
-.I Ppt
-converts the standard input into yet another form.
 .SH "SEE ALSO"
 dd(1)
 .SH "SEE ALSO"
 dd(1)
diff --git a/usr/man/man6/bj.6 b/usr/man/man6/bj.6
deleted file mode 100644 (file)
index cb2e8f7..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-.TH BJ 6 
-.SH NAME
-bj \- the game of black jack
-.SH SYNOPSIS
-.B /usr/games/bj
-.SH DESCRIPTION
-.I Bj
-is a serious attempt at
-simulating the dealer
-in the game of black jack (or twenty-one)
-as might be found in Reno.
-The following rules apply:
-.HP 5
-The bet is $2 every hand.
-.IP
-A player `natural' (black jack) pays $3.
-A dealer natural loses $2.
-Both dealer and player naturals
-is a `push' (no money exchange).
-.IP
-If the dealer has an ace up,
-the player is allowed to make an `insurance'
-bet against the chance of a dealer natural.
-If this bet is not taken, play resumes as normal.
-If the bet is taken, it is a side bet
-where the player wins $2 if the dealer has
-a natural and loses $1 if the dealer does not.
-.IP
-If the player is dealt two cards
-of the same value, he is allowed to
-`double'.
-He is allowed to play two
-hands, each with one of these cards.
-(The bet is doubled also; $2 on each hand.)
-.IP
-If a dealt hand
-has a total of ten or eleven,
-the player may `double down'.
-He may double the bet ($2 to $4)
-and receive exactly one more card on that hand.
-.IP
-Under normal play,
-the player may `hit' (draw a card)
-as long as his total is not over twenty-one.
-If the player `busts' (goes over twenty-one),
-the dealer wins the bet.
-.IP
-When the player `stands' (decides not to hit),
-the dealer hits until he attains
-a total of seventeen or more.
-If the dealer busts, the player wins the bet.
-.IP
-If both player and dealer stand,
-the one with the largest total wins.
-A tie is a push.
-.PP
-The machine deals and keeps score.
-The following questions will be asked at
-appropriate times.
-Each question is
-answered by
-.B y
-followed by a new line for `yes',
-or just new line for `no'.
-.PP
-?              (means, `do you want a hit?')
-.br
-Insurance?
-.br
-Double down?
-.PP
-Every time the deck is shuffled,
-the dealer so states and the `action' (total bet)
-and `standing' (total won or lost)
-is printed.
-To exit, hit the interrupt key (DEL)
-and the action and standing will be printed.
diff --git a/usr/man/man6/checkers.6 b/usr/man/man6/checkers.6
deleted file mode 100644 (file)
index c2c59fe..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-.TH CHECKERS 6
-.SH NAME
-checkers \- game
-.SH SYNOPSIS
-.B /usr/games/checkers
-.SH DESCRIPTION
-.I Checkers
-uses standard notation for the board:
-.PP
-.ce
-BLACK
-.nf
-.TS
-center, box;
-r|r|r|r|r|r|r|r.
-////   1       ////    2       ////    3       ////    4
-////           ////            ////            ////
-_
-5      ////    6       ////    7       ////    8       ////
-       ////            ////            ////            ////
-_
-////   9       ////    10      ////    11      ////    12
-////           ////            ////            ////
-_
-13     ////    14      ////    15      ////    16      ////
-       ////            ////            ////            ////
-_
-////   17      ////    18      ////    19      ////    20
-////           ////            ////            ////
-_
-21     ////    22      ////    23      ////    24      ////
-       ////            ////            ////            ////
-_
-////   25      ////    26      ////    27      ////    28
-////           ////            ////            ////
-_
-29     ////    30      ////    31      ////    32      ////
-       ////            ////            ////            ////
-_
-.TE
-.ce
-WHITE
-.fi
-.PP
-Black plays first.
-The program normally plays white.
-To specify a move, name the square moved from
-and the square moved to.
-For multiple jumps name all the squares touched.
-.PP
-.PP
-Certain commands may be given instead of moves:
-.TP \w'reverse\ \ 'u
-reverse
-Reverse roles; the program takes over your pieces.
-.TP
-backup
-Undo the last move for each player.
-.TP
-list
-Print the record of the game.
-.TP
-move
-Let the program select a move for you.
-.TP
-print
-Print a map of the present position.
diff --git a/usr/man/man6/chess.6 b/usr/man/man6/chess.6
deleted file mode 100644 (file)
index 5fef18a..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-.TH CHESS 6 
-.SH NAME
-chess \- the game of chess
-.SH SYNOPSIS
-.B /usr/games/chess
-.SH DESCRIPTION
-.I Chess
-is a computer program that plays class D chess.
-Moves may be given either in standard (descriptive) notation
-or in algebraic notation.
-The symbol `+' is used to specify check;
-`o-o' and `o-o-o' specify castling.
-To play black, type `first';
-to print the board, type an empty line.
-.PP
-Each move is echoed in the appropriate notation followed by
-the program's reply.
-.SH FILES
-/usr/lib/book          opening `book'
-.SH DIAGNOSTICS
-The most cryptic diagnostic is `eh?' which
-means that the input was syntactically incorrect.
-.SH WARNING
-Over-use of this program
-will cause it to go away.
-.SH BUGS
-Pawns may be promoted only to queens.
diff --git a/usr/man/man6/cubic.6 b/usr/man/man6/cubic.6
deleted file mode 100644 (file)
index 1b8265d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-.so /usr/man/man6/ttt.6
diff --git a/usr/man/man6/hangman.6 b/usr/man/man6/hangman.6
new file mode 100644 (file)
index 0000000..5234512
--- /dev/null
@@ -0,0 +1,23 @@
+.TH HANGMAN 6 
+.SH NAME
+hangman \- guess the word
+.SH SYNOPSIS
+.B /usr/games/hangman
+[ arg ]
+.SH DESCRIPTION
+.I Hangman
+chooses a word at least seven letters
+long from a dictionary.
+The user is to guess letters one at a time.
+.PP
+The optional argument
+.I arg
+names an alternate dictionary.
+The special name `\-a' gets a particular very large
+dictionary.
+.SH FILES
+/usr/dict/words                the regular dictionary
+.br
+/usr/dict/web2         the alternate dictionary
+.SH BUGS
+Hyphenated compounds are run together.
index 3c3153f..e81ba64 100644 (file)
@@ -2,7 +2,7 @@
 .SH NAME
 maze \- generate a maze problem
 .SH SYNOPSIS
 .SH NAME
 maze \- generate a maze problem
 .SH SYNOPSIS
-.B /usr/games/maze/
+.B /usr/games/maze
 .SH DESCRIPTION
 .I Maze
 asks a few questions and then
 .SH DESCRIPTION
 .I Maze
 asks a few questions and then
diff --git a/usr/man/man6/moo.6 b/usr/man/man6/moo.6
deleted file mode 100644 (file)
index 7e06c0c..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-.TH MOO 6 
-.SH NAME
-moo \- guessing game
-.SH SYNOPSIS
-.B /usr/games/moo
-.SH DESCRIPTION
-.I Moo
-is a guessing game imported from England.
-The computer picks a number consisting
-of four distinct decimal digits.
-The player guesses four distinct digits
-being scored on each guess.
-A `cow' is a correct digit in an incorrect position.
-A `bull' is a correct digit in a correct position.
-The game continues until the player guesses the number
-(a score of four bulls).
diff --git a/usr/man/man6/reversi.6 b/usr/man/man6/reversi.6
deleted file mode 100644 (file)
index 2b15e1e..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-.TH REVERSI 6 
-.SH NAME
-reversi \- a game of dramatic reversals
-.SH SYNOPSIS
-.B /usr/games/reversi
-[ [
-.B \-r
-]
-.I file
-]
-.SH DESCRIPTION
-.I Reversi
-(also known as `friends',
-`Chinese friends' and `Othello')
-is played on an 8\(mu8 board
-using two-sided tokens.
-Each player takes his turn by placing
-a token with his side up in an empty square.
-During the first four turns, players
-may only place tokens in the four central squares
-of the board.
-Subsequently, with each turn, a player
-.I must
-capture one or more
-of his opponent's tokens.
-He does this by placing
-one of his tokens such that
-it and another of his tokens embrace
-a solid line of his opponent's
-horizontally, vertically or diagonally.
-Captured tokens are flipped over
-and thus can be re-captured.
-If a player cannot outflank
-his opponent he forfeits
-his turn.
-The play continues until the
-board is filled or until no more
-outflanking is possible.
-.PP
-In this game,
-your tokens are asterisks
-and the machine's are at-signs.
-You move by typing in the row and column
-at which you want to place your token
-as two digits (1-8),
-optionally separated by blanks or tabs.
-You can also type
-.TP
-.B  c
-to continue the game after hitting break
-(this is only necessary if you interrupt the machine
-while it is deliberating).
-.TP
-.BR g " \fIn"
-to start
-.I reversi
-playing against itself
-for the next
-.IR n ""
-moves
-(or until the break key is hit).
-.TP
-.B  n
-to stop printing the board after each move.
-.TP
-.B  o
-to start it up again.
-.TP
-.B  p
-to print the board regardless.
-.TP
-.B  q
-to quit (without dishonor).
-.TP
-.B  s
-to print the score.
-.PP
-.I Reversi
-also recognizes several commands which are valid only
-at the start of the game, before any moves have been made.
-They are
-.TP
-.B  f
-to let the machine go first.
-.TP
-.BR h " \fIn"
-to ask for a handicap
-of from one to four corner squares.
-If you're
-good, you can give the machine
-a handicap by typing a negative number.
-.TP
-.BR l " \fIn"
-to set the amount of lookahead
-used by the machine in searching for moves.
-Zero means none at all. Four is the default.
-Greater than six means you may fall asleep
-waiting for the machine to move.
-.TP
-.BR t " \fIn"
-to tell
-.I reversi
-that you will only need
-.IR n ""
-seconds
-to consider each move. If you fail to respond in the
-alloted time, you forfeit your turn.
-.PP
-If
-.I reversi
-is given a file name as an argument,
-it will checkpoint the game,
-move by move, by dumping the board onto
-.IR file .
-The
-.B \-r
-option will cause
-.I reversi
-to restart the game from
-.I file
-and continue logging.
diff --git a/usr/man/man6/ttt.6 b/usr/man/man6/ttt.6
deleted file mode 100644 (file)
index ee0adbc..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-.TH TTT 6 
-.SH NAME
-ttt, cubic \- tic-tac-toe
-.SH SYNOPSIS
-.B /usr/games/ttt
-.PP
-.B /usr/games/cubic
-.SH DESCRIPTION
-.I Ttt
-is the X and O game popular in the first grade.
-This is a learning program that never makes the same
-mistake twice.
-.PP
-Although it learns, it learns slowly.
-It must lose nearly 80 games to
-completely know the game.
-.PP
-.I Cubic
-plays three-dimensional tic-tac-toe on a 4\(mu4\(mu4
-board.
-Moves are specified as a sequence of three
-coordinate numbers in the range 1-4.
-.SH FILES
-/usr/games/ttt.k       learning file
diff --git a/usr/man/man6/words.6 b/usr/man/man6/words.6
deleted file mode 100644 (file)
index 5e71af1..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-.TH WORDS 6 
-.SH NAME
-hangman, words \- word games
-.SH SYNOPSIS
-.B /usr/games/hangman
-[ dict ]
-.PP
-.B /usr/games/words
-.SH DESCRIPTION
-.I Hangman
-chooses a word at least seven letters
-long from a word list.
-The user is to guess letters one at a time.
-.PP
-The optional argument
-names an alternate word list.
-The special name `\-a' gets a particular very large
-word list.
-.PP
-.I Words
-prints all the uncapitalized words
-in the word list that can be made from
-letters in
-.I string.
-.SH FILES
-/usr/dict/words                the regular word list
-.br
-/crp/dict/web2         the the \-a word list
-.SH DIAGNOSTICS
-After each round,
-.I hangman
-reports the average number of guesses per round
-and the number of rounds.
-.SH BUGS
-Hyphenated compounds are run together.
-.PP
-UNIX software is distributed without
-the \-a word list.
index 2dbe08e..f012a24 100644 (file)
@@ -27,6 +27,22 @@ It contains:
 |160  p |161  q |162  r |163  s |164  t |165  u |166  v |167  w |
 |170  x |171  y |172  z |173  { |174  | |175  } |176  ~ |177 del|
 
 |160  p |161  q |162  r |163  s |164  t |165  u |166  v |167  w |
 |170  x |171  y |172  z |173  { |174  | |175  } |176  ~ |177 del|
 
+| 00 nul| 01 soh| 02 stx| 03 etx| 04 eot| 05 enq| 06 ack| 07 bel|
+| 08 bs | 09 ht | 0a nl | 0b vt | 0c np | 0d cr | 0e so | 0f si |
+| 10 dle| 11 dc1| 12 dc2| 13 dc3| 14 dc4| 15 nak| 16 syn| 17 etb|
+| 18 can| 19 em | 1a sub| 1b esc| 1c fs | 1d gs | 1e rs | 1f us |
+| 20 sp | 21  ! | 22  " | 23  # | 24  $ | 25  % | 26  & | 27  \' |
+| 28  ( | 29  ) | 2a  * | 2b  + | 2c  , | 2d  \- | 2e  . | 2f  / |
+| 30  0 | 31  1 | 32  2 | 33  3 | 34  4 | 35  5 | 36  6 | 37  7 |
+| 38  8 | 39  9 | 3a  : | 3b  ; | 3c  < | 3d  = | 3e  > | 3f  ? |
+| 40  @ | 41  A | 42  B | 43  C | 44  D | 45  E | 46  F | 47  G |
+| 48  H | 49  I | 4a  J | 4b  K | 4c  L | 4d  M | 4e  N | 4f  O |
+| 50  P | 51  Q | 52  R | 53  S | 54  T | 55  U | 56  V | 57  W |
+| 58  X | 59  Y | 5a  Z | 5b  [ | 5c  \\ | 5d  ] | 5e  ^ | 5f  _ |
+| 60  \` | 61  a | 62  b | 63  c | 64  d | 65  e | 66  f | 67  g |
+| 68  h | 69  i | 6a  j | 6b  k | 6c  l | 6d  m | 6e  n | 6f  o |
+| 70  p | 71  q | 72  r | 73  s | 74  t | 75  u | 76  v | 77  w |
+| 78  x | 79  y | 7a  z | 7b  { | 7c  | | 7d  } | 7e  ~ | 7f del|
 .fi
 .cs R
 .SH FILES
 .fi
 .cs R
 .SH FILES
index ec04d9f..6c405d8 100644 (file)
@@ -1,3 +1,6 @@
+.TH EQNCHAR 7 
+.SH NAME
+eqnchar \- special character definitions for eqn
 .EQ
 tdefine ciplus % "\o'\(pl\(ci'" %
 ndefine ciplus % O\b+ %
 .EQ
 tdefine ciplus % "\o'\(pl\(ci'" %
 ndefine ciplus % O\b+ %
@@ -88,9 +91,6 @@ define supset % \(sp %
 define !subset % \(ib %
 define !supset % \(ip %
 .EN
 define !subset % \(ib %
 define !supset % \(ip %
 .EN
-.TH EQNCHAR 7 
-.SH NAME
-eqnchar \- special character definitions for eqn
 .SH SYNOPSIS
 .B eqn /usr/pub/eqnchar
 [ files ]
 .SH SYNOPSIS
 .B eqn /usr/pub/eqnchar
 [ files ]
diff --git a/usr/man/man7/greek.7 b/usr/man/man7/greek.7
new file mode 100644 (file)
index 0000000..0720069
--- /dev/null
@@ -0,0 +1,41 @@
+.TH GREEK 7 
+.SH NAME
+greek \- graphics for extended TTY-37 type-box
+.SH SYNOPSIS
+.B "cat /usr/pub/greek"
+[ \(bv
+.BR "greek \-T" terminal
+]
+.SH DESCRIPTION
+.I Greek
+gives the mapping
+from ascii
+to the `shift out' graphics in effect between SO and SI 
+on model 37 Teletypes
+with a 128-character type-box.
+These are the default greek characters produced by
+.I nroff.
+The filters of 
+.IR greek (1)
+attempt to print them on various other terminals.
+The file contains:
+.PP
+.nf
+.if n .ta 9 +3 +6 +9 +3 +6 +9 +3 +6
+.if t .ta 1i +.3i +.75i +1i +.3i +.75i +1i  +.3i
+alpha  \(*a    A       beta    \(*b    B       gamma   \(*g    \\
+GAMMA  \(*G    G       delta   \(*d    D       DELTA   \(*D    W
+epsilon        \(*e    S       zeta    \(*z    Q       eta     \(*y    N
+THETA  \(*H    T       theta   \(*h    O       lambda  \(*l    L
+LAMBDA \(*L    E       mu      \(*m    M       nu      \(*n    @
+xi     \(*c    X       pi      \(*p    J       PI      \(*P    P
+rho    \(*r    K       sigma   \(*s    Y       SIGMA   \(*S    R
+tau    \(*t    I       phi     \(*f    U       PHI     \(*F    F
+psi    \(*q    V       PSI     \(*Q    H       omega   \(*w    C
+OMEGA  \(*W    Z       nabla   \(gr    [       not     \(no    _
+partial        \(pd    ]       integral        \(is    ^
+.fi
+.SH "SEE ALSO"
+greek(1)
+.br
+troff(1)
index 3abc524..4d983d2 100644 (file)
@@ -1,4 +1,4 @@
-.TH HIER 7
+.TH HIER 7 UNIX/32V
 .SH NAME
 hier \- file system hierarchy
 .SH DESCRIPTION
 .SH NAME
 hier \- file system hierarchy
 .SH DESCRIPTION
@@ -35,11 +35,10 @@ raw disks,
 utility programs, cf /usr/bin/ (1)
 .RS
 .IP as
 utility programs, cf /usr/bin/ (1)
 .RS
 .IP as
-assembler first pass,
-cf /usr/lib/as2
+assembler
 .IP cc
 C compiler executive,
 .IP cc
 C compiler executive,
-cf /usr/lib/c[012]
+cf /lib/ccom, /lib/cpp, /lib/c2
 .IP ...
 .RE
 .IP /lib/
 .IP ...
 .RE
 .IP /lib/
@@ -47,22 +46,13 @@ object libraries and other stuff, cf /usr/lib/
 .RS
 .IP libc.a
 system calls, standard I/O, etc. (2,3,3S)
 .RS
 .IP libc.a
 system calls, standard I/O, etc. (2,3,3S)
-.IP libm.a
-math routines (3M)
-.IP libplot.a
-plotting routines,
-.IR plot (3)
-.IP libF77.a
-Fortran runtime support
-.IP libI77.a
-Fortran I/O
 .IP ...
 .IP ...
-.IP as2
-second pass of
-.IR as (1)
-.IP c[012]
-passes of
-.IR cc (1)
+.IP ccom
+C compiler proper
+.IP cpp
+C preprocessor
+.IP c2
+C code improver
 .IP ...
 .RE
 .IP /etc/
 .IP ...
 .RE
 .IP /etc/
@@ -159,8 +149,6 @@ history file for
 .RE
 .IP games/
 .RS
 .RE
 .IP games/
 .RS
-.IP bj
-blackjack
 .IP hangman
 .IP quiz.k/
 what
 .IP hangman
 .IP quiz.k/
 what
@@ -201,6 +189,15 @@ internal system buffers
 .IP lib/
 object libraries and stuff, to keep /lib/ small
 .RS
 .IP lib/
 object libraries and stuff, to keep /lib/ small
 .RS
+.IP libm.a
+math routines (3M)
+.IP libplot.a
+plotting routines,
+.IR plot (3)
+.IP libF77.a
+Fortran runtime support
+.IP libI77.a
+Fortran I/O
 .IP lint[12]
 subprocesses for
 .IR lint (1)
 .IP lint[12]
 subprocesses for
 .IR lint (1)
@@ -232,9 +229,9 @@ macros for
 fonts for
 .IR troff (1)
 .RS
 fonts for
 .IR troff (1)
 .RS
-.IP R
+.IP ftR
 Times Roman
 Times Roman
-.IP B
+.IP ftB
 Times Bold
 .IP ...
 .RE
 Times Bold
 .IP ...
 .RE
@@ -248,9 +245,6 @@ remote system names and numbers
 the real copy program
 .IP ...
 .RE
 the real copy program
 .IP ...
 .RE
-.IP suftab
-table of suffixes for hyphenation, used by
-.IR troff (1)
 .IP units
 conversion tables for
 .IR units (1)
 .IP units
 conversion tables for
 .IR units (1)
@@ -311,16 +305,6 @@ transient control file, while
 .I lpr
 is working
 .RE
 .I lpr
 is working
 .RE
-.IP uucp/
-work files and staging area for 
-.IR uucp (1)
-.RS
-.IP LOGFILE
-summary log
-.IP LOG.*
-log file for one transaction
-.RE
-.RE
 .IP mail/
 mailboxes for
 .IR mail (1)
 .IP mail/
 mailboxes for
 .IR mail (1)
@@ -335,6 +319,19 @@ lock file while
 .I uid
 is receiving mail
 .RE
 .I uid
 is receiving mail
 .RE
+.IP secretmail/
+like
+.IR mail /
+.IP uucp/
+work files and staging area for 
+.IR uucp (1)
+.RS
+.IP LOGFILE
+summary log
+.IP LOG.*
+log file for one transaction
+.RE
+.RE
 .TP
 .I wd
 initial working directory of a user,
 .TP
 .I wd
 initial working directory of a user,
@@ -356,56 +353,10 @@ papers, mostly in volume 2 of this manual, typically in
 .IR ms (7)
 format
 .RS
 .IR ms (7)
 format
 .RS
-.IP as/
-assembler manual
 .IP c
 C manual
 .IP ...
 .RE
 .IP c
 C manual
 .IP ...
 .RE
-.IP sys/
-system source
-.RS
-.IP dev/
-device drivers
-.RS
-.IP bio.c
-common code
-.IP cat.c
-.IR cat (4)
-.IP dh.c
-DH11,
-.IR tty (4)
-.IP tty
-.IR tty (4)
-.IP ...
-.RE
-.IP conf/
-hardware-dependent code
-.RS
-.IP mch.s
-assembly language portion
-.IP conf
-configuration generator
-.IP ...
-.RE
-.IP h/
-header (include) files
-.RS
-.IP acct.h
-.IR acct (5)
-.IP stat.h
-.IR stat (2)
-.IP ...
-.RE
-.IP sys/
-source for system proper
-.RS
-.IP main.c
-.IP pipe.c
-.IP sysent.c
-system entry points
-.IP ...
-.RE
 .RE
 .RE
 .IP /usr/\tsrc/
 .RE
 .RE
 .IP /usr/\tsrc/
@@ -417,12 +368,6 @@ source of commands
 .RS
 .IP as/
 assembler
 .RS
 .IP as/
 assembler
-.RS
-.IP makefile
-recipe for rebuilding the assembler
-.IP as1?.s
-source of pass1
-.RE
 .IP ar.c
 source for
 .IR ar (1)
 .IP ar.c
 source for
 .IR ar (1)
@@ -433,12 +378,6 @@ source for
 and
 .IR troff (1)
 .RS
 and
 .IR troff (1)
 .RS
-.IP nmake
-makefile for
-.I nroff
-.IP tmake
-makefile for
-.I troff
 .IP font/
 source for font tables, /usr/lib/font/
 .RS
 .IP font/
 source for font tables, /usr/lib/font/
 .RS
@@ -461,13 +400,6 @@ source for functions in /lib/libc.a
 .RS
 .IP crt/
 C runtime support
 .RS
 .IP crt/
 C runtime support
-.RS
-.IP ldiv.s
-division into a long
-.IP lmul.s
-multiplication to produce long
-.IP ...
-.RE
 .IP csu/
 startup and wrapup routines needed with every C program
 .RS
 .IP csu/
 startup and wrapup routines needed with every C program
 .RS
@@ -495,7 +427,6 @@ standard I/O functions (3S)
 other functions in (3)
 .RS
 .IP abs.c
 other functions in (3)
 .RS
 .IP abs.c
-.IP atof.c
 .IP ...
 .RE
 .IP compall
 .IP ...
 .RE
 .IP compall
@@ -506,6 +437,27 @@ shell procedure to make /lib/libc.a
 .IP libI77/
 source for /lib/libI77
 .IP libF77/
 .IP libI77/
 source for /lib/libI77
 .IP libF77/
+.IP sys/
+system source
+.RS
+.IP h/
+header (include) files
+.RS
+.IP acct.h
+.IR acct (5)
+.IP stat.h
+.IR stat (2)
+.IP ...
+.RE
+.IP sys/
+source for system proper
+.RS
+.IP main.c
+.IP pipe.c
+.IP sysent.c
+system entry points
+.IP ...
+.RE
 .IP ...
 .IP games/
 source for /usr/games
 .IP ...
 .IP games/
 source for /usr/games
index 16fb12f..a53b886 100644 (file)
@@ -1,6 +1,6 @@
 .TH TERM 7 
 .SH NAME
 .TH TERM 7 
 .SH NAME
-terminals\- conventional names
+terminals \- conventional names
 .SH DESCRIPTION
 These names
 are used by certain commands and are maintained 
 .SH DESCRIPTION
 These names
 are used by certain commands and are maintained 
diff --git a/usr/man/man8/boot.8 b/usr/man/man8/boot.8
deleted file mode 100644 (file)
index d04d772..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-.TH BOOT 8
-.SH NAME
-boot \- startup procedures
-.SH DESCRIPTION
-A PDP11/45 and PDP11/70 UNIX system is started by
-a two-stage process.
-The first is a primary bootstrap
-which is able to read in relatively small stand-alone programs;
-the second (called
-.IR boot )
-is used to read in the system itself.
-.PP
-The primary bootstrap must reside
-in the otherwise unused block zero of the boot device.
-It can be read in and started by the standard ROM
-programs,
-or if necessary by keying in a small startup routine.
-This program is capable of loading type 407 executable
-files (not shared, not separate I&D).
-The user types on the system console
-the name of the program wished, in this case
-.IR boot ,
-followed by a carriage return;
-the named program is retrieved from the file system
-that starts at block 0 of drive 0 of the boot device.
-No prompt is given,
-no diagnostic results if the file cannot be found, and no
-provision is made for correcting typographical errors.
-.PP
-The second step, called
-.I boot,
-actually brings in the system.
-When read into location 0 and executed,
-.I boot
-sets up memory management, relocates itself into
-high memory, and types a `:' on the console.
-Then it
-reads from the console
-a device specification (see below) followed immediately by
-a pathname.
-.I Boot
-finds the corresponding file on the given device,
-loads that file into memory location zero,
-sets up memory management as required,
-and calls the program by executing a `trap' instruction.
-Normal
-line editing characters can be used.
-.PP
-Conventionally, the name of the secondary boot program
-is `/boot' and the name of the current version of the system
-is `/unix'.
-Then, the recipe is:
-.TP
-1)
-Load block 0 of the boot device by fiddling with the
-console keys as appropriate for your hardware.
-If you have no appropriate ROM, some programs suitable
-for manual use are given below.
-.TP
-2)
-Type
-.IR boot .
-.TP
-3)
-When the prompt is given, type
-.br
-       hp(0,0)unix
-.br
-or
-.br
-       rp(0,0)unix
-.br
-depending on whether you are loading from an RP04/5/6 or an RP03
-respectively.
-The first 0 indicates the physical unit number;
-the second indicates
-the block number of the beginning of the logical file
-system to be searched.
-(See below).
-.PP
-When the system is running, it types a `#' prompt.
-After doing any file system checks and setting the date
-.RI ( date (8))
-a multi-user system is brought up by typing an EOT
-(control-d)
-in response to the `#' prompt.
-.PP
-.B Device specifications.
-A device specification has the following form:
-.IP " "
-device(unit,offset)
-.LP
-where
-.I device
-is the type of the device to be searched,
-.I unit
-is the unit number of the device,
-and 
-.I offset
-is the block offset of the file system on the device.
-.I Device
-is one of the following
-.br
-.nf
-       rp      RP03
-       hp      RP04/5/6
-       rk      RK05
-.fi
-For example, the specification
-.IP " "
-hp(1,7000)
-.LP
-indicates an RP03 disk, unit 1, and the file system found
-starting at block 7000 (cylinder 35).
-.PP
-.SM
-.B ROM
-.B programs.
-The following programs to call the primary bootstrap
-may be installed in read-only memories
-or manually keyed into main 
-memory.
-Each program is position-independent
-but should be placed well above location 0
-so it will not be overwritten.
-Each reads a block from the
-beginning of a device into core location
-zero.
-The octal words constituting the program are
-listed on the left.
-.PP
-.ne 5
-.nf
-.if n .ta 3 11 15 23 38
-.if t .ta .3i 1i 1.4i 2i 3.5i
-RK (drive 0):
-       012700          mov     $rkda,r0
-       177412
-       005040          clr     \-(r0)  / rkda cleared by start
-       010040          mov     r0,\-(r0)
-       012740          mov     $5,\-(r0)
-       000005
-       105710  1:      tstb    (r0)
-       002376          bge     1b
-       005007          clr     pc
-.PP
-.ne 11
-RP (drive 0)
-       012700          mov     $rpmr,r0
-       176726
-       005040          clr     \-(r0)
-       005040          clr     \-(r0)
-       005040          clr     \-(r0)
-       010040          mov     r0,\-(r0)
-       012740          mov     $5,\-(r0)
-       000005
-       105710  1:      tstb    (r0)
-       002376          bge     1b
-       005007          clr     pc
-.DT
-.SH FILES
-/unix \- system code
-.br
-/usr/mdec/rpuboot, /usr/mdec/hpuboot \- copies of primary bootstrap
-.br
-/boot \- second stage bootstrap
-.SH "SEE ALSO"
-init(8)
diff --git a/usr/man/man8/bproc.8 b/usr/man/man8/bproc.8
new file mode 100644 (file)
index 0000000..c164f77
--- /dev/null
@@ -0,0 +1,165 @@
+.TH  BPROC 8 "UNIX/32V"
+.tr |
+.SH NAME
+boot procedures \- UNIX/32V startup
+.SH DESCRIPTION
+.I "How to start UNIX/32V.||"
+UNIX/32V is started by placing it in memory
+at location zero and transferring to its entry address.
+Since the system is not reenterable,
+it is necessary to read it in from disk or tape.
+The LSI-11 console computer is used to do this.
+.PP
+The LSI-11 must first be in the right frame of mind.  When it is,
+it will type three greater-than signs `>>>' as a prompt.
+If you do not see this prompt, type control-P and ``HALT\er''
+to gain the attention of the LSI-11.
+If the last printout on the console is a six-digit octal number and
+an at-sign `@', then the LSI-11 has crashed and is in ODT mode.
+Type ``173000G'' to boot the LSI-11.  If this fails, open the VAX-11
+cabinet and flick the HALT/ENABLE switch on the LSI-11 first to HALT,
+then to ENABLE.
+.PP
+To boot from disk, first put the LSI-11 in the right frame of mind and then
+mumble the following incantation through the console
+(parentheses indicate comments which should not be mumbled):
+.PP
+.nf
+   \fI>>>\|\fRHALT
+   \fI>>>\|\fRLINK             (save the following sequence on the floppy)
+                       (the prompt should change to <<<)
+   \fI<<<\|\fRHALT
+   \fI<<<\|\fRUNJAM
+   \fI<<<\|\fRINIT
+   \fI<<<\|\fRD 30000 00009FDE
+   \fI<<<\|\fRD + D0512001
+   \fI<<<\|\fRD + D004A101
+   \fI<<<\|\fRD + 0400C113
+   \fI<<<\|\fRD + 10008F32
+   \fI<<<\|\fRD + D40424C1
+   \fI<<<\|\fRD + 8FD00CA1
+   \fI<<<\|\fRD + 80000000
+   \fI<<<\|\fRD + 320800C1
+   \fI<<<\|\fRD + A1FE008F
+   \fI<<<\|\fRD + 28C1D410
+   \fI<<<\|\fRD + 14C1D404
+   \fI<<<\|\fRD + C139D004
+   \fI<<<\|\fRD + 00000400
+   \fI<<<\|\fRSTART 30000
+   \fI<<<\|\fRSTART 2
+   (to exit from linking mode type `control-c')
+   \fI<<<\|\fR`control-c'
+   \fI>>>\|\fRPERFORM    (the magic word)
+.fi
+.PP
+This causes the LSI-11 to read block 0, unit 0, MBA 0 into memory at
+location 0 and start the VAX-11 at location 0 when the read has finished.
+In a standard file system, block 0 contains the program
+.IR uboot .
+.I uboot
+executes the file
+.I /fboot
+which it finds in the file system which resides at the beginning of
+unit 0, MBA 0.
+.I fboot
+prints a prompt, reads a file name (usually `unix') from the console,
+finds that file, reads it into memory at location 0, and transfers to it.
+.PP
+The second and subsequent times that the system is booted, you need only
+utter the magic word PERFORM; the LSI-11 will do all the chanting.
+This takes all the fun out of booting, but it is faster.
+.PP
+The above program is an assembled version of this code.
+.PP
+.nf
+.if n .ta 3 14 21 41 49
+.if t .ta .3i 1i 1.6i 3.5i
+RP06 disk (MBA 0, drive 0)
+       00009fde        moval   *$0x20010000,r1 # MBA 0
+       \0\0512001
+       d0              movl    $1,4(r1)        # initialize MBA
+       \0\004a101
+       d0              movl    $0x13,0x400(r1) # volume valid
+       0400c113
+       10008f32        cvtwl   $0x1000,0x424(r1)       # 16-bit format
+       \0\00424c1
+       d4              clrl    12(r1)  # map reg. 0, offset 0
+       \0\0\0\00ca1
+       8fd0            movl    $0x80000000,0x800(r1)   # valid, page 0/0
+       80000000
+       \0\00800c1
+       32              cvtwl   $-512,16(r1)    # byte count
+       a1fe008f
+       \0\0\0\0\0\010
+       28c1d4          clrl    0x428(r1)       # cylinder
+       \0\0\0\0\0\004
+       14c1d4          clrl    0x414(r1)       # sector, track
+       \0\0\0\0\0\004
+       c139d0          movl    $0x39,0x400(r1) # read 1 block
+       \0\0\0\00400
+       \0\000          halt
+.fi
+.PP
+To boot from magnetic tape:  The
+.IR tp (1)
+command places the bootstrap program
+.I mboot
+on block 0 of the tape.  When read into memory at location 0 and executed,
+.I mboot
+prompts with an equal sign `=', reads a file name from the console,
+then loads and executes that file from the
+.I tp
+tape.  Unfortunately DEC does not provide a console command to read
+a block from tape to memory.  Here is a position-independent program
+which does:
+.PP
+.nf
+TM03 magtape (MBA 1, drive 0) from load point:
+.if n .ta 3 14 21 41 49
+.if t .ta .3i 1i 1.6i 3.5i
+       20009fde        moval   *$0x20012000,r1 # MBA 1
+       \0\0512001
+       d0              movl    $1,4(r1)        # initialize
+       \0\004a101
+       32              cvtwl   $0x13c0,0x424(r1)       # drive characteristics
+       c113c08f
+       \0\0\0\00424
+       a1d4            clrl    12(r1)  # map reg. 0, offset 0
+       \0\0\0\0\0\00c
+       008fd0          movl    $0x80000000,0x800(r1)   # valid, page 0/0
+       c1800000
+       \0\0\0\00800
+       8f32            cvtwl   $-512,16(r1)    # byte count
+       10a1fe00
+       00c139d0        movl    $0x39,0x400(r1) # read 1 block
+       \0\0\0\0\0\004
+       \0\0\0\000      halt
+Then give the console command ``START 0\er''.
+.fi
+.PP
+.IR mboot\  and\  fboot
+do not perform character erase and line kill editing.  Instead,
+they start over with the prompt for file name whenever the requested
+file cannot be found.
+.PP
+Be sure that
+.I mboot
+exists whenever a
+.I tp
+tape is made.  Remember to put
+.IR uboot\  and\  /fboot
+in file systems when running
+.IR mkfs .
+.SH FILES
+.ta \w'/usr/mdec/mboot   'u
+/unix  UNIX/32V code
+.br
+/usr/mdec/uboot        disk bootstrap
+.br
+/fboot file system bootstrap
+.br
+/usr/mdec/mboot        
+.IR tp ""
+magtape bootstrap
+.SH "SEE ALSO"
+tp(1), init(8)
index 8919446..ddc7489 100644 (file)
@@ -1,4 +1,5 @@
-.TH CRASH 8 
+.TH CRASH 8 "UNIX/32V"
+.tr |
 .SH NAME
 crash \- what to do when the system crashes
 .SH DESCRIPTION
 .SH NAME
 crash \- what to do when the system crashes
 .SH DESCRIPTION
@@ -6,33 +7,51 @@ This section gives at least a few clues about how to proceed if the
 system crashes.
 It can't pretend to be complete.
 .PP
 system crashes.
 It can't pretend to be complete.
 .PP
-.I Bringing it back up.
+.I "What to do first.||"
+(Someday the LSI-11 will do this automatically.)
+Write the date and time on the console log.
+Use the console commands to examine the registers, program status long word,
+and the top several locations on the stack.
+A suggested command sequence is
+.DS
+.nf
+       E PSL<return>
+       E R0/NE:F<return>
+       E SP<return>
+       E/V @ /NE:20<return>
+.fi
+.DE
+.PP
+.I "How to bring it back up.||"
 If the reason for the crash is not evident
 (see below for guidance on `evident')
 you may want to try to dump the system if you feel up to
 debugging.
 If the reason for the crash is not evident
 (see below for guidance on `evident')
 you may want to try to dump the system if you feel up to
 debugging.
-At the moment a dump can be taken only on magtape.
-With a tape mounted and ready,
-stop the machine, load address 44, and start.
-This should write a copy of all of core
-on the tape with an EOF mark.
+At the moment a dump can be taken only on magnetic tape.
+With a tape mounted and ready and the cpu halted, insure that the cpu
+is in kernel mode,
+deposit 80000200 into the pc, and continue.
+The sequence of console commands is
+.DS
+.nf
+       D PSL 0
+       D PC 80000200<return>
+       C<return>
+.fi
+.DE
+This should write a copy of all of memory
+on the tape, followed by two EOF marks.
 Caution:
 Caution:
-Any error is taken to mean the end of core has been reached.
+Any error is taken to mean the end of memory has been reached.
 This means that you must be sure the ring is in,
 the tape is ready, and the tape is clean and new.
 If the dump fails, you can try again,
 but some of the registers will be lost.
 See below for what to do with the tape.
 .PP
 This means that you must be sure the ring is in,
 the tape is ready, and the tape is clean and new.
 If the dump fails, you can try again,
 but some of the registers will be lost.
 See below for what to do with the tape.
 .PP
-In restarting after a crash,
-always bring up the system single-user.
-This is accomplished by following the directions in
-.IR boot (8)
-as modified for your particular installation;
-a single-user system is indicated by having a particular value
-in the switches (173030 unless you've changed
-.I init)
-as the system starts executing.
+To restart after a crash, follow the directions in
+.IR bproc (8).
+The system will come up in single-user mode.
 When it is running,
 perform a
 .I dcheck
 When it is running,
 perform a
 .I dcheck
@@ -42,12 +61,9 @@ on all file systems which could have been in use at the time
 of the crash.
 If any serious file system problems are found, they should be repaired.
 When you are satisfied with the health of your disks,
 of the crash.
 If any serious file system problems are found, they should be repaired.
 When you are satisfied with the health of your disks,
-check and set the date if necessary,
-then come up multi-user.
-This is most easily accomplished by changing the
-single-user value in the switches to something else,
-then logging out
-by typing an EOT.
+log out by typing an EOT (<control-D>).
+The command sequence in /etc/rc will be executed and the system will
+be in multi-user mode.
 .PP
 To even boot \s8UNIX\s10 at all,
 three files (and the directories leading to them)
 .PP
 To even boot \s8UNIX\s10 at all,
 three files (and the directories leading to them)
@@ -57,11 +73,11 @@ the initialization program
 .I /etc/init
 must be present and executable.
 If it is not,
 .I /etc/init
 must be present and executable.
 If it is not,
-the CPU will loop in user mode at location 6.
+then the cpu will loop at location 0x13.
 For
 .I init
 to work correctly,
 For
 .I init
 to work correctly,
-.I /dev/tty8
+.I /dev/console
 and
 .I /bin/sh
 must be present.
 and
 .I /bin/sh
 must be present.
@@ -85,7 +101,7 @@ it is probably prudent to go to a
 backup system to avoid working on a
 mounted file system.
 .PP
 backup system to avoid working on a
 mounted file system.
 .PP
-.I Repairing disks.
+.I "Repairing disks.||"
 The first rule to keep in mind is that an addled disk
 should be treated gently;
 it shouldn't be mounted unless necessary,
 The first rule to keep in mind is that an addled disk
 should be treated gently;
 it shouldn't be mounted unless necessary,
@@ -101,13 +117,16 @@ There can be
 problems with the free list:
 duplicates in the free list, or free blocks also in files.
 These can be cured easily with an
 problems with the free list:
 duplicates in the free list, or free blocks also in files.
 These can be cured easily with an
-.I icheck \-s.
+.I "icheck \-s."
 If the same block appears in more than one file
 or if a file contains bad blocks,
 the files should be deleted, and the free list reconstructed.
 The best way to delete such a file is to use
 .IR  clri (1),
 If the same block appears in more than one file
 or if a file contains bad blocks,
 the files should be deleted, and the free list reconstructed.
 The best way to delete such a file is to use
 .IR  clri (1),
-then remove its directory entries.
+then remove its directory entries with
+.IR rm (1).
+(Do not use
+.IR mv (1).)
 If any of the affected files is really precious,
 you can try to copy it to another device
 first.
 If any of the affected files is really precious,
 you can try to copy it to another device
 first.
@@ -138,18 +157,19 @@ stops with files that have been deleted while still open.
 A
 .I clri
 will free the inode, and an
 A
 .I clri
 will free the inode, and an
-.I icheck -s
+.I "icheck -s"
 will
 recover any missing blocks.
 .PP
 will
 recover any missing blocks.
 .PP
-.I Why did it crash?
+.I "Why did it crash?||"
 UNIX types a message
 on the console typewriter when it voluntarily crashes.
 Here is the current list of such messages,
 with enough information to provide
 a hope at least of the remedy.
 The message has the form `panic: ...',
 UNIX types a message
 on the console typewriter when it voluntarily crashes.
 Here is the current list of such messages,
 with enough information to provide
 a hope at least of the remedy.
 The message has the form `panic: ...',
-possibly accompanied by other information.
+`TRAP FROM KERNEL MODE', or `ILLEGAL I/E VECTOR'
+(possibly accompanied by other information).
 Left unstated in all cases
 is the possibility that hardware or software
 error produced the message in some unexpected way.
 Left unstated in all cases
 is the possibility that hardware or software
 error produced the message in some unexpected way.
@@ -191,7 +211,7 @@ Like `no fs', but produced elsewhere.
 .HP 5
 no inodes
 .br
 .HP 5
 no inodes
 .br
-The in-core inode table is full.
+The in-memory inode table is full.
 Try increasing NINODE in param.h.
 Shouldn't be a panic, just a user error.
 .HP 5
 Try increasing NINODE in param.h.
 Shouldn't be a panic, just a user error.
 .HP 5
@@ -223,121 +243,130 @@ A pure procedure program is being executed,
 and the table for such things is full.
 This shouldn't be a panic.
 .HP 5
 and the table for such things is full.
 This shouldn't be a panic.
 .HP 5
-trap
+TRAP FROM KERNEL MODE
 .br
 An unexpected trap has occurred within the system.
 .br
 An unexpected trap has occurred within the system.
-This is accompanied by three numbers:
-a `ka6', which is the contents of the segmentation
-register for the area in which the system's stack is kept;
-`aps', which is the location where the hardware stored
-the program status word during the trap;
-and a `trap type' which encodes
-which trap occurred.
+The trap type can be determined by examining the top word of the
+stack (the trap type) with the console commands.
 The trap types are:
 .TP 10
 0
 The trap types are:
 .TP 10
 0
-bus error
+reserved addressing mode
 .br
 .ns
 .TP 10
 1
 .br
 .ns
 .TP 10
 1
-illegal instruction
+privileged instruction
 .br
 .ns
 .TP 10
 2
 .br
 .ns
 .TP 10
 2
-BPT/trace
+BPT
 .br
 .ns
 .TP 10
 3
 .br
 .ns
 .TP 10
 3
-IOT
+XFC
 .br
 .ns
 .TP 10
 4
 .br
 .ns
 .TP 10
 4
-power fail
+reserved operand
 .br
 .ns
 .TP 10
 5
 .br
 .ns
 .TP 10
 5
-EMT
+CHMK (system call)
 .br
 .ns
 .TP 10
 6
 .br
 .ns
 .TP 10
 6
-recursive system call (TRAP instruction)
+arithemtic trap
 .br
 .ns
 .TP 10
 7
 .br
 .ns
 .TP 10
 7
-11/70 cache parity, or programmed interrupt
+reschedule trap (software level 3)
+.br
+.ns
+.TP 10
+8
+segmentation fault
+.br
+.ns
+.TP 10
+9
+protection fault
 .br
 .ns
 .TP 10
 10
 .br
 .ns
 .TP 10
 10
-floating point trap
+trace pending (TP bit)
+.HP 5
+ILLEGAL I/E VECTOR, HALTED AT xx
 .br
 .br
+an illegal interrupt or exception has occurred.  The possible addresses are
 .ns
 .TP 10
 .ns
 .TP 10
-11
-segmentation violation
+4
+machine check (hardware error).
+.br
+.ns
+.TP 10
+8
+kernel stack not valid
+.br
+.ns
+.TP 10
+C
+power failure
 .PP
 In some of these cases it is
 possible for octal 20 to be added into the trap type;
 this indicates that the processor was in user mode when the trap occurred.
 If you wish to examine the stack after such a trap,
 .PP
 In some of these cases it is
 possible for octal 20 to be added into the trap type;
 this indicates that the processor was in user mode when the trap occurred.
 If you wish to examine the stack after such a trap,
-either dump the system, or use the console switches to examine core;
+either dump the system, or use the console to examine memory;
 the required address mapping is described below.
 .PP
 the required address mapping is described below.
 .PP
-.I Interpreting dumps.
+.I "Interpreting dumps.||"
 All file system problems
 should be taken care of before attempting to look at dumps.
 The dump should be read into the file
 All file system problems
 should be taken care of before attempting to look at dumps.
 The dump should be read into the file
-.I /usr/sys/core;
+.IR /usr/sys/core ;
 .IR  cp (1)
 will do.
 At this point, you should execute
 .IR  cp (1)
 will do.
 At this point, you should execute
-.I ps \-alxk
+.I "ps \-alxk"
 and
 .I who
 to print the process table and the users who were on
 at the time of the crash.
 and
 .I who
 to print the process table and the users who were on
 at the time of the crash.
-You should dump (
-.IR  od (1))
-the first 30 bytes of
-.I /usr/sys/core.
-Starting at location 4,
-the registers R0, R1, R2, R3, R4, R5, SP
-and KDSA6 (KISA6 for 11/40s) are stored.
-If the dump had to be restarted,
-R0 will not be correct.
-Next, take the value of KA6 (location 022(8) in the dump)
-multiplied by 0100(8) and dump 01000(8) bytes starting from there.
-This is the per-process data associated with the process running
-at the time of the crash.
-Relabel
-the addresses 140000 to 141776.
-R5 is C's frame or display pointer.
-Stored at (R5) is the old R5 pointing to the previous
-stack frame.
-At (R5)+2
-is the saved PC of the calling procedure.
-Trace
-this calling chain until
-you obtain an R5 value of 141756, which
-is where the user's R5 is stored.
-If the chain is broken,
-you have to look for a plausible
-R5, PC pair and continue from there.
-Each PC should be looked up in the system's name list
-using
+Use
+.IR adb (1)
+to examine
+.IR /usr/sys/core .
+The location
+.I dumpstack\-80000000
+is the bottom of a stack onto which were pushed the stack pointer
+.BR sp ,
+.B PCBB
+(containing the physical address of a
+.IR u_area ),
+.BR MAPEN ,
+.BR IPL ,
+and registers
+.BR r13 \- r0
+(in that order).
+.BR r13 (fp)
+is the system frame pointer and the stack is used in standard
+.B calls
+format.  Use
 .IR  adb (1)
 .IR  adb (1)
-and its `:' command,
 to get a reverse calling order.
 In most cases this procedure will give
 an idea of what is wrong.
 A more complete discussion
 of system debugging is impossible here.
 to get a reverse calling order.
 In most cases this procedure will give
 an idea of what is wrong.
 A more complete discussion
 of system debugging is impossible here.
-.SH SEE ALSO
-clri(1), icheck(1), dcheck(1), boot(8)
+.SH "SEE ALSO"
+clri(1), icheck(1), dcheck(1), bproc(8)
+.SH BUGS
diff --git a/usr/man/man8/fget.demon.8 b/usr/man/man8/fget.demon.8
new file mode 100644 (file)
index 0000000..d0249e7
--- /dev/null
@@ -0,0 +1,95 @@
+.TH FGET.DEMON 8 
+.SH NAME
+fget.demon, fget.odemon \- fget daemons
+.SH SYNOPSIS
+.B /etc/fget.demon
+time
+.br
+.B /etc/fget.odemon
+time
+.SH DESCRIPTION
+.I Fget.demon
+and
+.I fget.odemon
+are daemons for the 210 dataphone or spider.
+They are designed to retrieve files
+that have been requested by
+.IR fget (1)
+from the Honeywell 6070 computer.
+The argument
+.I time
+is the number of seconds for
+.I fget.demon
+to wait for files to appear from GRTS.
+The default is 6 minutes.
+.I Fget.demon
+is automatically initiated by
+.I fget,
+and by
+.I cron (1).
+.PP
+On systems with both a spider and a dataphone connection to
+the Honeywell 6070 computer,
+.I fget.demon
+uses spider, and
+.I fget.odemon
+uses the dataphone,
+and is called automatically as a backup
+when the spider connection is down.
+On other systems, there is only one fget daemon,
+.I fget.demon,
+which use the dataphone.
+.PP
+The daemons
+use the spooling directory
+.I /usr/dpd.
+The file
+.I glock
+in that directory
+is used
+to prevent two daemons from becoming active.
+After the program has successfully set the lock,
+it forks and the main path exits, thus
+spawning the daemon.
+GRTS is interrogated for any output for the daemon's station-id.
+If none,
+.I fget.demon
+will wait up to
+.I time
+seconds,
+interrogating GRTS every minute or so to see if any output has arrived.
+All problems and successful transactions are recorded
+in the 
+.I errors
+file in the spooling directory.
+.PP
+To restart
+.I fget.demon
+(in the case of hardware or software malfunction),
+it is necessary to first kill the old
+.I fget.demon
+(if still alive),
+and remove the lock file
+before initiating
+.I fget.demon.
+This is done automatically when the system is brought up,
+by
+.I /etc/rc
+(see
+.IR init (1))
+in case there are any jobs waiting to come over.
+.SH FILES
+.ta \w'/dev/tiu/d2  '
+/usr/dpd/*
+spool area
+.br
+/dev/du*
+dataphone device
+.br
+/dev/dn*
+acu device
+.br
+/dev/tiu/d2
+spider device
+.SH "SEE ALSO"
+fget(1), dpd(1)
index 67955ef..8988fe1 100644 (file)
@@ -1,19 +1,15 @@
 .TH GETTY 8 
 .SH NAME
 .TH GETTY 8 
 .SH NAME
-getty  \- set typewriter mode
+getty  \- set terminal mode
 .SH SYNOPSIS
 .B /etc/getty
 [ char ]
 .SH DESCRIPTION
 .I Getty
 .SH SYNOPSIS
 .B /etc/getty
 [ char ]
 .SH DESCRIPTION
 .I Getty
-is invoked
-by
+is invoked by
 .IR  init (8)
 .IR  init (8)
-immediately after a typewriter is opened
-following a dial-up.
-It reads the user's login name and calls
-.IR login (1)
-with the name as argument.
+immediately after a terminal is opened,
+following the making of a connection.
 While reading the name
 .I getty
 attempts to adapt the system to the speed and type of terminal
 While reading the name
 .I getty
 attempts to adapt the system to the speed and type of terminal
@@ -22,64 +18,43 @@ being used.
 .I Init
 calls
 .I getty
 .I Init
 calls
 .I getty
-with a single character argument taken from
-the
-.IR ttys (5)
+with an argument specified by the
+.I ttys
 file entry for the terminal line.
 file entry for the terminal line.
-This argument determines a sequence of line speeds through which
+Arguments other than `0' can be used to make
 .I getty
 .I getty
-cycles, and also the `login:' greeting message,
-which can contain character sequences to put various kinds of
-terminals in useful states.
+treat the line specially.
+Normally, it
+sets the speed of the interface to 300 baud,
+specifies that raw mode is to be used (break on every character),
+that echo is to be suppressed, and either parity
+allowed.
+It types the `login:' message,
+which includes the characters which put the Terminet 300
+terminal into full-duplex and
+return the GSI terminal to non-graphic mode.
+Then the user's name is read, a character at a time.
+If a null character is received, it is assumed to be the result
+of the user pushing the `break' (`interrupt') key.
+The speed is then
+changed to 1200 baud and the `login:' is typed again;
+a second `break' changes the speed to 150 baud and the `login:'
+is typed again.  Successive `break' characters cycle through the
+speeds 300, 1200, and 150 baud.
 .PP
 The user's name is terminated by a new-line or
 carriage-return character.
 .PP
 The user's name is terminated by a new-line or
 carriage-return character.
-In the second case CRMOD mode is set
-(see
-.IR  ioctl (2)).
+The latter results in the system being set to
+treat carriage returns appropriately (see
+.IR  stty (2)).
 .PP
 .PP
-The name is scanned to see if
+The user's name is scanned to see if
 it contains any lower-case alphabetic characters; if not,
 and if the name is nonempty, the
 system is told to map any future upper-case characters
 into the corresponding lower-case characters.
 .PP
 it contains any lower-case alphabetic characters; if not,
 and if the name is nonempty, the
 system is told to map any future upper-case characters
 into the corresponding lower-case characters.
 .PP
-If the terminal's `break' key is depressed,
-.I getty
-cycles to the next speed appropriate to the type of line
-and prints the greeting message again.
-.PP
 Finally, login is called with the user's name as argument.
 Finally, login is called with the user's name as argument.
-.PP
-The following arguments from the
-.I ttys
-file are understood.
-.TP
-0
-Cycles through 300-1200-150-110 baud.
-Useful as a default for dialup lines accessed by a variety
-of terminals.
-.TP
-\-
-Intended for an on-line Teletype model 33, for example
-an operator's console.
-.TP
-1
-Optimized for a 150-baud Teletype model 37.
-.TP
-2
-Intended for an on-line 9600-baud terminal, for example
-the Textronix 4104.
-.TP
-3
-Starts at 1200 baud, cycles to 300 and back.
-Useful with 212 datasets where most terminals
-run at 1200 speed.
-.TP
-5
-Same as `3' but starts at 300.
-.TP
-4
-Useful for on-line console DECwriter (LA36).
 .SH "SEE ALSO"
 .SH "SEE ALSO"
-init(8), login(1), ioctl(2), ttys(5)
+init(8), login(1), stty(2), ttys(5)
+.SH BUGS
index 3caae5e..002be18 100644 (file)
@@ -1,39 +1,35 @@
 .TH INIT 8 
 .SH NAME
 .TH INIT 8 
 .SH NAME
-init, rc  \-  process control initialization
+init  \-  process control initialization
 .SH SYNOPSIS
 .B /etc/init
 .SH SYNOPSIS
 .B /etc/init
-.br
-.B /etc/rc
 .SH DESCRIPTION
 .I Init
 .SH DESCRIPTION
 .I Init
-is invoked as the last step of the boot procedure (see
-.IR boot (8)).
+is invoked inside UNIX as the last step in the boot procedure.
 Generally its role is to create a process for each
 Generally its role is to create a process for each
-typewriter on which a user may log in.
+terminal port on which a user may log in.
 .PP
 .PP
-When
 .I init
 .I init
-first is executed
-the console typewriter
-.I /dev/console.
-is opened for reading
-and writing and the shell is invoked immediately.
-This feature is used to bring up a single-user system.
-If the shell terminates,
-.I init
-comes up multi-user and the process described below is started.
+first opens the console terminal
+.I /dev/console
+for reading
+and writing, and then invokes a Shell.
+This feature brings up the system in single-user mode.
+The
+.I getty
+and
+.I login
+routines mentioned below and described elsewhere are not used yet.
 .PP
 .PP
-When
-.I init
-comes up multiuser,
-it
-invokes a shell, with input taken from the
+When the single-user shell terminates
+(usually caused by typing an EOT on the console),
+.I  init
+invokes another Shell, with input taken from the
 file
 .I /etc/rc.
 This command file
 file
 .I /etc/rc.
 This command file
-performs housekeeping
-like removing temporary files,
+performs housekeeping operations
+such as removing temporary files,
 mounting file systems, and starting
 daemons.
 .PP
 mounting file systems, and starting
 daemons.
 .PP
@@ -43,28 +39,28 @@ reads the file
 .I /etc/ttys
 and
 forks several times to create a process
 .I /etc/ttys
 and
 forks several times to create a process
-for each typewriter specified in the file.
-Each of these processes opens the appropriate typewriter
+for each terminal specified in the file.
+Each of these processes opens the appropriate terminal
 for reading and writing.  These channels thus
 for reading and writing.  These channels thus
-receive file descriptors 0, 1 and 2, the standard input,
-output and error files.
-Opening the typewriter will usually involve a delay,
+receive file descriptors 0 and 1, the standard input and
+output.
+Opening the terminal will usually involve a delay,
 since the
 .IR open ""
 is not completed until someone
 is dialed up and carrier established on the channel.
 Then
 .I /etc/getty
 since the
 .IR open ""
 is not completed until someone
 is dialed up and carrier established on the channel.
 Then
 .I /etc/getty
-is called with argument as specified by the last character of
+is called with argument as specified by the second character of
 the
 .I ttys
 file line.
 .I Getty
 reads the user's name and invokes
 the
 .I ttys
 file line.
 .I Getty
 reads the user's name and invokes
-.IR login (1)
-to log in the user and execute the shell.
+.I login
+to log in the user and execute the Shell.
 .PP
 .PP
-Ultimately the shell will terminate
+Ultimately the Shell will terminate
 because of an end-of-file either
 typed explicitly or generated as a result of hanging up.
 The main path of
 because of an end-of-file either
 typed explicitly or generated as a result of hanging up.
 The main path of
@@ -79,19 +75,33 @@ makes an entry in
 .IR /usr/adm/wtmp ,
 which maintains a history
 of logins and logouts.
 .IR /usr/adm/wtmp ,
 which maintains a history
 of logins and logouts.
-Then the appropriate typewriter is reopened and
+Then the appropriate terminal is reopened and
 .I getty
 is
 reinvoked.
 .PP
 .I Init
 catches the
 .I getty
 is
 reinvoked.
 .PP
 .I Init
 catches the
-hangup signal SIGHUP and interprets it to mean that
-the
-system should be brought from multi user to single
-user.
-Use `kill -1 1' to send the hangup signal.
+.I hangup
+signal (signal SIGHUP) and interprets it to mean that
+the file
+.I /etc/ttys
+should be read again.
+The Shell process on each line which used to be active
+in
+.I ttys
+but is no longer there is terminated;
+a new process is created for each added line;
+lines unchanged in the file are undisturbed.
+Thus it is possible to drop or add phone lines without
+rebooting the system by changing the
+.I ttys
+file and sending a
+.I hangup
+signal to the
+.I init
+process: use `kill \-1 1.'
 .SH FILES
 .SH FILES
-/dev/tty?, /etc/utmp, /usr/adm/wtmp, /etc/ttys, /etc/rc
+/dev/console, /dev/tty?, /etc/utmp, /usr/adm/wtmp, /etc/ttys, /etc/rc
 .SH "SEE ALSO"
 login(1), kill(1), sh(1), ttys(5), getty(8)
 .SH "SEE ALSO"
 login(1), kill(1), sh(1), ttys(5), getty(8)
index aa6ba76..153fba8 100644 (file)
@@ -8,7 +8,7 @@ lpd \- line printer daemon
 is the daemon for the line printer.
 .I Lpd
 uses the directory
 is the daemon for the line printer.
 .I Lpd
 uses the directory
-.IR /usr/spool/lpd .
+.I /usr/lpd.
 The file
 .I lock
 in that directory is used
 The file
 .I lock
 in that directory is used
@@ -47,16 +47,17 @@ the file is unlinked.
 is followed by a user ID; after the job is sent,
 a message is
 mailed to the user via the
 is followed by a user ID; after the job is sent,
 a message is
 mailed to the user via the
-.IR mail (1)
+.I mail(1)
 command
 to verify the sending of the job.
 .PP
 Any error encountered will cause the daemon to
 command
 to verify the sending of the job.
 .PP
 Any error encountered will cause the daemon to
-wait and start over.
+wait 1 minute
+and start over.
 This means that an improperly constructed
 This means that an improperly constructed
-.B df
+.I df
 file may cause the same job to be submitted
 file may cause the same job to be submitted
-repeatedly.
+every 20 minutes.
 .PP
 .I Lpd
 is automatically initiated by the line printer command,
 .PP
 .I Lpd
 is automatically initiated by the line printer command,
@@ -78,7 +79,7 @@ by
 in case there were any jobs left in the spooling directory
 when the system last went down.
 .SH FILES
 in case there were any jobs left in the spooling directory
 when the system last went down.
 .SH FILES
-/usr/spool/lpd/*
+/usr/lpd/*
 spool area for line printer daemon
 .br
 /etc/passwd
 spool area for line printer daemon
 .br
 /etc/passwd
@@ -86,5 +87,5 @@ to get the user's name
 .br
 /dev/lp
 line printer device
 .br
 /dev/lp
 line printer device
-.SH "SEE ALSO"
+.sh "SEE ALSO"
 lpr(1)
 lpr(1)
diff --git a/usr/man/man8/sticky.8 b/usr/man/man8/sticky.8
new file mode 100644 (file)
index 0000000..108547a
--- /dev/null
@@ -0,0 +1,51 @@
+.TH STICKY 8
+.SH NAME
+sticky \- executable files with persistent text
+.SH DESCRIPTION
+While the `sticky bit', mode 01000 (see
+.IR chmod (2)),
+is set on a sharable executable file,
+the text of that file will not be removed from the system swap area.
+Thus the file does not have to be fetched from the file system
+upon each execution.
+As long as a copy remains in the swap area, the
+original text cannot be overwritten in the file system,
+nor can the file be deleted.
+(Directory entries can be removed so long as one link remains.)
+.PP
+Sharable files are made by the
+.B \-n
+and
+.B \-i
+options of
+.IR ld (1).
+.PP
+To replace a sticky file that has been used do:
+(1) Clear the sticky bit with
+.IR chmod (1).
+(2) Execute the old program to flush the swapped copy.
+This can be done safely even if others are using it.
+(3) Overwrite the sticky file.
+If the file is being executed by any process,
+writing will be prevented; see the next paragraph
+for a dodge.
+(4) Set the sticky bit again.
+Only the super-user can set the sticky bit.
+.PP
+To replace a sharable executable file while any user is
+executing it do:
+(1) Rename the directory entry for that file with
+.IR mv (1).
+(2) Install the new program with
+.I cp,
+.IR mv (1),
+or otherwise.
+(3) With
+.I chown
+and
+.IR chmod (2),
+set the mode of the new file to agree with that of the original
+as necessary.
+(4) Delete the old file when convenient.
+.SH BUGS
+Are self-evident.
diff --git a/usr/man/man8/sysgen.8 b/usr/man/man8/sysgen.8
new file mode 100644 (file)
index 0000000..40f1eba
--- /dev/null
@@ -0,0 +1,188 @@
+.TH  SYSGEN 8 "UNIX/32V"
+.SH NAME
+sysgen \- UNIX/32V system generation from the distribution tape
+.SH DESCRIPTION
+This section explains how to generate an initial UNIX/32V system
+from the distribution tape.  It assumes that you have some familiarity
+with the hardware: how to mount and unmount disk packs and magnetic tapes,
+and how to use the console.
+.SH PREREQUISITES
+.nf
+1      VAX-11/780 system with at least 256K bytes of memory
+1      RP06 disk spindle (unit 0) with controller on MBA 0
+1      TE16 magnetic tape drive (unit 0) with TM03 formatter on MBA 1
+1      error-free disk pack for use on the RP06 spindle
+1      UNIX/32V distribution tape
+90     minutes of time
+.fi
+.SH OVERVIEW
+The distribution tape is recorded at 800 bpi and contains three files.
+The first file is in
+.IR tp (5)
+format and contains stand-alone utility programs for handling disks,
+tapes, and the console.  The first file usually contains about 250
+blocks of 512 characters each.
+The second file on the distribution tape is a
+.IR dd (1)
+copy of an initial root file system (see
+.IR filsys (5)).
+On the tape the file system is 250 blocks of 10240 characters.
+The third and last file on the tape contains source code, and also
+object code and miscellaneous data, from the
+.I /usr
+file system.  The last file is in
+.IR tar (1)
+format, blocked 10240 characters per tape record, and contains several
+thousand records.
+The system generation process has three phases, corresponding to the
+three files on the distribution tape.  The first phase formats and
+verifies the disk pack.  The second phase creates the initial root
+file system on the disk.  The third phase establishes the
+.I /usr
+directory.
+.SH PROCEDURE
+.PP
+Read and understand this entire description before attempting anything else.
+Quotation marks ``'' surround literal character strings which you should type
+on the console.  The notation ``\er'' stands for the RETURN key.
+.PP
+Turn on the VAX-11/780 to LOCAL.  The POWER and ATTN lights should go on;
+if not, fix your hardware before proceeding.
+.PP
+Mount an error-free disk pack on the RP06 spindle, unit 0, MBA 0.
+Start the drive and set read-write (not write protect).  The START,
+CONTROL A, and DOOR LOCKED lights should be on.  If the READY light on the
+drive does not come on within 30 seconds, then fix your hardware before
+proceeding.
+.PP
+Mount the UNIX/32V distribution tape on the tape drive, unit 0, MBA 1.  All
+status lights (PWR, BOT, WRL, SELECT, LOAD, ONLINE) should be on.
+If the WRL light is not on, then remove the write ring from the reel and
+start again.  If the other lights are not on, then fix your hardware
+before proceeding.
+.PP
+Enter the commands HALT, UNJAM, INITIALIZE on the console.  These may
+usually be abbreviated to ``H\er'', ``U\er'', and ``I\er'', respectively.
+.PP
+Deposit in memory at a high address the absolute tape boot program found in
+.IR bproc (8).
+Execute the code you deposited, using the ``START'' console command.
+One 512-byte bock (the
+.I tp
+boot program) will be read from the tape into VAX-11 memory beginning at
+location 0.
+.PP
+Give the console command ``START 0\er''.  This starts the
+.I tp
+boot program, which relocates itself high in memory, rewinds the tape,
+and then types an equal sign `=' on the console as a prompt.
+.PP
+Type ``rp6fmt\er''.  The
+.I tp
+boot will load the RP06 disk formatting program into memory and transfer
+control to it.
+.PP
+Enter the MBA number and unit number (in this case, both ``0\er'') in
+response to the prompts.  The
+.I rp6fmt
+program will then format the disk; this should take approximately 20 minutes.
+Error messages may appear on the console if bad spots are found on the disk.
+There should not be any (you mounted an error-free pack, remember).
+If there are any error messages, sit tight and hope for the best.
+.PP
+When the
+.I rp6fmt
+program finishes, it will ask to format another pack.  Type ``\-1\er''
+to exit.  The equal sign prompt `=' of the
+.I tp
+boot should appear again.  Type ``rpread\er''.  This program verifies
+that the entire disk can be read.  Enter the unit number and starting
+block number (both ``0\er'') in response to the prompts.  Enter ``\er''
+when asked for the number of blocks; this will read the whole pack.
+Reading the disk takes 10 minutes.  Messages indicating bad spots
+may appear on the console.  The bad spots should match those found
+by the
+.I rp6fmt
+program.  All ECC errors should be correctible.  If there are any errors
+which are not correctible, you should probably start the whole boot
+procedure over with a better pack.
+.PP
+After the
+.I rpread
+program finishes, it will prompt for another read.
+Type ``\-1\er'' to exit; another `=' prompt from the
+.I tp
+boot will appear.  Type ``tdcopy\er''.  In general,
+.I tdcopy
+copies tape-to-disk.  It is used here to copy an initial root file system
+from the tape onto the disk beginning at cylinder 0, track 0, sector 0.
+Respond to the prompts from
+.I tdcopy
+with ``1\er'' (tape MBA #), ``0\er'' (tape unit #), ``1\er'' (tape
+file offset), ``0\er'' (tape block offset), ``0\er'' (disk MBA #),
+``0\er'' (disk unit), ``0\er'' (disk block offset), and ``250\er''
+(number of input blocks).  The copy takes 5 minutes.
+.PP
+You are now ready to boot UNIX (yea!).
+The `=' prompt from
+.I tp
+boot should appear again.  Type ``rpboot\er''.  The
+.I rpboot
+program should then prompt with ``file:''.  Type ``unix\er''.
+This loads the operating system from disk and executes it.
+The system will report the physical memory in your configuration
+and the memory not used by the operating system.  Then it will
+type ``#''.  This is the super-user prompt for single-user operation
+of the UNIX system.
+.PP
+Set the date and time using the
+.IR date (1)
+command.
+.PP
+Check the integrity of the root file system with
+.nf
+       icheck /dev/rrp0a
+       dcheck /dev/rrp0a
+.fi
+.PP
+Create the
+.I /usr
+file system with
+.nf
+       /etc/mkfs /dev/rp0g 300000
+       /etc/mount /dev/rp0g /usr
+.fi
+This takes 5 minutes.
+.PP
+Extract the remaining files from the distribution tape with
+.ta 0.5i 3.5i
+.nf
+       cd /usr
+       cp /dev/rmt4 /dev/null  ;: bypasses tp file
+       cp /dev/rmt4 /dev/null  ;: bypasses root
+       tar xbf 20 /dev/rmt0
+.fi
+This takes 20 minutes.
+.PP
+Check the integrity of the /usr file system with
+.nf
+       cd /
+       /etc/umount /dev/rp0g
+       icheck /dev/rrp0g
+.fi
+.PP
+Establish the desired entries in the password file
+.IR /etc/passwd ,
+using the text editor
+.IR ed (1).
+.PP
+Set the terminal lines configuration in
+.I /etc/ttys
+using the text editor
+.IR ed (1).
+.PP
+Edit the reconfiguration file
+.I /etc/rc
+as desired.
+.PP
+Type EOT (control-D) to start multi-user operation.
diff --git a/usr/man/nohup.out b/usr/man/nohup.out
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/man/tabs b/usr/man/tabs
new file mode 100644 (file)
index 0000000..99eb37c
--- /dev/null
@@ -0,0 +1,21 @@
+.ps 14
+.sp |1i
+     Contents
+.sp |2i
+     Index
+.sp |3i
+     UNIX/32V 1
+.sp |4i
+     UNIX/32V 2
+.sp |5i
+     UNIX/32V 3
+.sp |6i
+     UNIX/32V 4
+.sp |7i
+     UNIX/32V 5
+.sp |8i
+     UNIX/32V 6
+.sp |9i
+     UNIX/32V 7
+.sp |10i
+     UNIX/32V 8
diff --git a/usr/man/tocrc b/usr/man/tocrc
new file mode 100755 (executable)
index 0000000..ea674cd
--- /dev/null
@@ -0,0 +1,78 @@
+tmp=/tmp/toc$$
+trap "rm $tmp ; exit" 2 3 15
+if [ $# -eq 2 ]
+then
+       : create toc input file for one section only
+
+       > man0/tocx$1
+       for file in man$1/*.$1*
+       do
+               test -s $file \
+       &&      < $file grep '^\.TH' | grep local >/dev/null \
+       ||      < $file sed -n '1p' | grep '^\.so' >/dev/null \
+       ||      < $file grep '\\-' |
+               sed -n '1p' |
+               sed \
+                       -e 's/.s-1//g' \
+                       -e 's/.s0//g' \
+                       -e 's/.s+1//g' \
+                       -e 's/  *.-  */: /' \
+                       -e "s/^/`basename $file | sed 's/\.\([^\.]*\)\$/(\1)/'` /" \
+                       -e 's/$/./' \
+               >> man0/tocx$1
+       done
+else case $1 in
+       all )
+               :   tocx files for all sections and everything else
+
+               for x in 1 2 3 4 5 6 7 8
+                       do
+                       $0 $x $x
+                       done
+               $0 t
+               ;;
+       t )
+               :   permuted index and toc files
+
+               if [ ! -f man0/tocx1 ]
+               then
+                       echo "tocx? files missing; must run tocrc all first"
+                       exit
+               fi
+               sed \
+                       -e 's/(1c)/(1C)/' \
+                       -e 's/(1m)/(1M)/' \
+                       -e 's/(1g)/(1G)/' \
+                       -e 's/(3c)/(3C)/' \
+                       -e 's/(3m)/(3M)/' \
+                       -e 's/(3s)/(3S)/' \
+                       -e '/"\."/d' \
+                       man0/tocx? \
+               > cattoc
+
+               ptx -r -t -b break -f -w 108 -i ignore cattoc man0/ptxx
+               cd man0; troff -g ptx.in >t.ptx ; cd ..
+
+               for x in 1 2 3 4 5 6 7 8
+               do
+                       < man0/tocx$x grep '^intro' >$tmp
+                               sed \
+                               -e '2,${' \
+                               -e '/^intro/d' \
+                               -e '}' \
+                               -e 's/ .*://' \
+                               -e 's/.$//' \
+                               -e 's/(.*) /" "/' \
+                               -e 's/.*/.xx "&"/' \
+                               -e '/""/d' \
+                               $tmp man0/tocx$x \
+                       >man0/toc$x
+               done
+               cd man0; troff -g toc.in >t.toc ; cd ..
+               ;;
+       * )
+               $0 $1 $1
+               ;;
+       esac
+fi
+exit
diff --git a/usr/mdec/hpuboot.s b/usr/mdec/hpuboot.s
deleted file mode 100644 (file)
index 46609bf..0000000
+++ /dev/null
@@ -1,259 +0,0 @@
-/ disk boot program to load and transfer
-/ to a unix entry
-
-/ entry is made by jsr pc,*$0
-/ so return can be rts pc
-
-core = 28.
-.. = [core*2048.]-512.
-
-/ establish sp and check if running below
-/ intended origin, if so, copy
-/ program up to 'core' K words.
-start:
-       mov     $..,sp
-       mov     sp,r1
-       cmp     pc,r1
-       bhis    2f
-       clr     r0
-       cmp     (r0),$407
-       bne     1f
-       mov     $20,r0
-1:
-       mov     (r0)+,(r1)+
-       cmp     r1,$end
-       blo     1b
-       jmp     (sp)
-
-/ clear core to make things clean
-2:
-       clr     (r0)+
-       cmp     r0,sp
-       blo     2b
-
-/ at origin, read pathname,
-/ initialize rp
-       mov     $drive,*$hpcs2
-       mov     $preset+go,*$hpcs1
-       mov     $fmt22,*$hpof
-
-/ spread out in array 'names', one
-/ component every 14 bytes.
-       mov     $names,r1
-1:
-       mov     r1,r2
-2:
-       jsr     pc,getc
-       cmp     r0,$'\n
-       beq     1f
-       cmp     r0,$'/
-       beq     3f
-       movb    r0,(r2)+
-       br      2b
-3:
-       cmp     r1,r2
-       beq     2b
-       add     $14.,r1
-       br      1b
-
-/ now start reading the inodes
-/ starting at the root and
-/ going through directories
-1:
-       mov     $names,r1
-       mov     $2,r0
-1:
-       clr     bno
-       jsr     pc,iget
-       tst     (r1)
-       beq     1f
-2:
-       jsr     pc,rmblk
-               br start
-       mov     $buf,r2
-3:
-       mov     r1,r3
-       mov     r2,r4
-       add     $16.,r2
-       tst     (r4)+
-       beq     5f
-4:
-       cmpb    (r3)+,(r4)+
-       bne     5f
-       cmp     r4,r2
-       blo     4b
-       mov     -16.(r2),r0
-       add     $14.,r1
-       br      1b
-5:
-       cmp     r2,$buf+512.
-       blo     3b
-       br      2b
-
-/ read file into core until
-/ a mapping error, (no disk address)
-1:
-       clr     r1
-1:
-       jsr     pc,rmblk
-               br 1f
-       mov     $buf,r2
-2:
-       mov     (r2)+,(r1)+
-       cmp     r2,$buf+512.
-       blo     2b
-       br      1b
-/ relocate core around
-/ assembler header
-1:
-       clr     r0
-       cmp     (r0),$407
-       bne     2f
-1:
-       mov     20(r0),(r0)+
-       cmp     r0,sp
-       blo     1b
-/ enter program and
-/ restart if return
-2:
-       jsr     pc,*$0
-       br      start
-
-/ get the inode specified in r0
-iget:
-       add     $15.,r0
-       mov     r0,r5
-       ash     $-3.,r0
-       bic     $!17777,r0
-       mov     r0,dno
-       clr     r0
-       jsr     pc,rblk
-       bic     $!7,r5
-       ash     $6,r5
-       add     $buf,r5
-       mov     $inod,r4
-1:
-       mov     (r5)+,(r4)+
-       cmp     r4,$inod+64.
-       blo     1b
-       rts     pc
-
-/ read a mapped block
-/ offset in file is in bno.
-/ skip if success, no skip if fail
-/ the algorithm only handles a single
-/ indirect block. that means that
-/ files longer than 10+128 blocks cannot
-/ be loaded.
-rmblk:
-       add     $2,(sp)
-       mov     bno,r0
-       cmp     r0,$10.
-       blt     1f
-       mov     $10.,r0
-1:
-       mov     r0,-(sp)
-       asl     r0
-       add     (sp)+,r0
-       add     $addr+1,r0
-       movb    (r0)+,dno
-       movb    (r0)+,dno+1
-       movb    -3(r0),r0
-       bne     1f
-       tst     dno
-       beq     2f
-1:
-       jsr     pc,rblk
-       mov     bno,r0
-       inc     bno
-       sub     $10.,r0
-       blt     1f
-       ash     $2,r0
-       mov     buf+2(r0),dno
-       mov     buf(r0),r0
-       bne     rblk
-       tst     dno
-       bne     rblk
-2:
-       sub     $2,(sp)
-1:
-       rts     pc
-
-drive  = 0
-cyl    = 0.
-read   = 70
-preset = 20
-go     = 1
-fmt22  = 10000
-
-hpcs1  = 176700
-hpda   = hpcs1+6
-hpcs2  = hpcs1+10
-hpds   = hpcs1+12
-hpof   = hpcs1+32
-hpca   = hpcs1+34
-
-/ rp0456 disk driver.
-/ low order address in dno,
-/ high order in r0.
-rblk:
-       mov     r1,-(sp)
-       mov     dno,r1
-       div     $22.*19.,r0
-       add     $cyl,r0
-       mov     r0,*$hpca
-       clr     r0
-       div     $22.,r0
-       swab    r0
-       bis     r1,r0
-       mov     $hpda,r1
-       mov     r0,(r1)
-       mov     $buf,-(r1)
-       mov     $-256.,-(r1)
-       mov     $read+go,-(r1)
-1:
-       tstb    (r1)
-       bge     1b
-       mov     (sp)+,r1
-       rts     pc
-
-tks = 177560
-tkb = 177562
-/ read and echo a teletype character
-getc:
-       mov     $tks,r0
-       inc     (r0)
-1:
-       tstb    (r0)
-       bge     1b
-       mov     tkb,r0
-       bic     $!177,r0
-       cmp     r0,$'A
-       blo     1f
-       cmp     r0,$'Z
-       bhi     1f
-       add     $'a-'A,r0
-1:
-
-tps = 177564
-tpb = 177566
-/ print a teletype character
-putc:
-       tstb    *$tps
-       bge     putc
-       mov     r0,*$tpb
-       cmp     r0,$'\r
-       bne     1f
-       mov     $'\n,r0
-       br      putc
-1:
-       rts     pc
-
-end:
-inod = ..-1024.
-addr = inod+12.
-buf = inod+64.
-bno = buf+512.
-dno = bno+2
-names = dno+2
-reset = 5
diff --git a/usr/mdec/makefile b/usr/mdec/makefile
deleted file mode 100644 (file)
index fe78a87..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-hpuboot:
-       as -o hpuboot hpuboot.s
-       strip rpuboot
-
-rpuboot:
-       as -o rpuboot rpuboot.s
-       strip hpuboot
diff --git a/usr/mdec/rpuboot.s b/usr/mdec/rpuboot.s
deleted file mode 100644 (file)
index e9ab92a..0000000
+++ /dev/null
@@ -1,251 +0,0 @@
-/ disk boot program to load and transfer
-/ to a unix entry
-
-/ entry is made by jsr pc,*$0
-/ so return can be rts pc
-
-core = 28.
-.. = [core*2048.]-512.
-
-/ establish sp and check if running below
-/ intended origin, if so, copy
-/ program up to 'core' K words.
-start:
-       mov     $..,sp
-       mov     sp,r1
-       cmp     pc,r1
-       bhis    2f
-       clr     r0
-       cmp     (r0),$407
-       bne     1f
-       mov     $20,r0
-1:
-       mov     (r0)+,(r1)+
-       cmp     r1,$end
-       blo     1b
-       jmp     (sp)
-
-/ clear core to make things clean
-2:
-       clr     (r0)+
-       cmp     r0,sp
-       blo     2b
-
-/ at origin, read pathname,
-/ initialize rp
-
-       clr     *$rpcs          / selects drive zero
-/ spread out in array 'names', one
-/ component every 14 bytes.
-       mov     $names,r1
-1:
-       mov     r1,r2
-2:
-       jsr     pc,getc
-       cmp     r0,$'\n
-       beq     1f
-       cmp     r0,$'/
-       beq     3f
-       movb    r0,(r2)+
-       br      2b
-3:
-       cmp     r1,r2
-       beq     2b
-       add     $14.,r1
-       br      1b
-
-/ now start reading the inodes
-/ starting at the root and
-/ going through directories
-1:
-       mov     $names,r1
-       mov     $2,r0
-1:
-       clr     bno
-       jsr     pc,iget
-       tst     (r1)
-       beq     1f
-2:
-       jsr     pc,rmblk
-               br start
-       mov     $buf,r2
-3:
-       mov     r1,r3
-       mov     r2,r4
-       add     $16.,r2
-       tst     (r4)+
-       beq     5f
-4:
-       cmpb    (r3)+,(r4)+
-       bne     5f
-       cmp     r4,r2
-       blo     4b
-       mov     -16.(r2),r0
-       add     $14.,r1
-       br      1b
-5:
-       cmp     r2,$buf+512.
-       blo     3b
-       br      2b
-
-/ read file into core until
-/ a mapping error, (no disk address)
-1:
-       clr     r1
-1:
-       jsr     pc,rmblk
-               br 1f
-       mov     $buf,r2
-2:
-       mov     (r2)+,(r1)+
-       cmp     r2,$buf+512.
-       blo     2b
-       br      1b
-/ relocate core around
-/ assembler header
-1:
-       clr     r0
-       cmp     (r0),$407
-       bne     2f
-1:
-       mov     20(r0),(r0)+
-       cmp     r0,sp
-       blo     1b
-/ enter program and
-/ restart if return
-2:
-       jsr     pc,*$0
-       br      start
-
-/ get the inode specified in r0
-iget:
-       add     $15.,r0
-       mov     r0,r5
-       ash     $-3.,r0
-       bic     $!17777,r0
-       mov     r0,dno
-       clr     r0
-       jsr     pc,rblk
-       bic     $!7,r5
-       ash     $6,r5
-       add     $buf,r5
-       mov     $inod,r4
-1:
-       mov     (r5)+,(r4)+
-       cmp     r4,$inod+64.
-       blo     1b
-       rts     pc
-
-/ read a mapped block
-/ offset in file is in bno.
-/ skip if success, no skip if fail
-/ the algorithm only handles a single
-/ indirect block. that means that
-/ files longer than 10+128 blocks cannot
-/ be loaded.
-rmblk:
-       add     $2,(sp)
-       mov     bno,r0
-       cmp     r0,$10.
-       blt     1f
-       mov     $10.,r0
-1:
-       mov     r0,-(sp)
-       asl     r0
-       add     (sp)+,r0
-       add     $addr+1,r0
-       movb    (r0)+,dno
-       movb    (r0)+,dno+1
-       movb    -3(r0),r0
-       bne     1f
-       tst     dno
-       beq     2f
-1:
-       jsr     pc,rblk
-       mov     bno,r0
-       inc     bno
-       sub     $10.,r0
-       blt     1f
-       ash     $2,r0
-       mov     buf+2(r0),dno
-       mov     buf(r0),r0
-       bne     rblk
-       tst     dno
-       bne     rblk
-2:
-       sub     $2,(sp)
-1:
-       rts     pc
-
-cyl    = 0.
-read   = 4
-go     = 1
-
-rpcs   = 176710
-rpda   = 176724
-rpca   = 176722
-rpba   = 176720
-/ rp03 disk driver.
-/ low order address in dno,
-/ high order in r0.
-rblk:
-       mov     r1,-(sp)
-       mov     dno,r1
-       div     $20.*10.,r0
-/      add     $cyl,r0
-       mov     r0,*$rpca
-       clr     r0
-       div     $10.,r0
-       swab    r0
-       bis     r1,r0
-       mov     r0,*$rpda
-       mov     $rpba,r1
-       mov     $buf,(r1)
-       mov     $-256.,-(r1)
-       mov     $read+go,-(r1)
-1:
-       tstb    (r1)
-       bge     1b
-       mov     (sp)+,r1
-       rts     pc
-
-tks = 177560
-tkb = 177562
-/ read and echo a teletype character
-getc:
-       mov     $tks,r0
-       inc     (r0)
-1:
-       tstb    (r0)
-       bge     1b
-       mov     tkb,r0
-       bic     $!177,r0
-       cmp     r0,$'A
-       blo     1f
-       cmp     r0,$'Z
-       bhi     1f
-       add     $'a-'A,r0
-1:
-
-tps = 177564
-tpb = 177566
-/ print a teletype character
-putc:
-       tstb    *$tps
-       bge     putc
-       mov     r0,*$tpb
-       cmp     r0,$'\r
-       bne     1f
-       mov     $'\n,r0
-       br      putc
-1:
-       rts     pc
-
-end:
-inod = ..-1024.
-addr = inod+12.
-buf = inod+64.
-bno = buf+512.
-dno = bno+2
-names = dno+2
-reset = 5
diff --git a/usr/news/dummy b/usr/news/dummy
new file mode 100644 (file)
index 0000000..e69de29
index d3283fe..0df53fd 100644 (file)
 |150  h |151  i |152  j |153  k |154  l |155  m |156  n |157  o |
 |160  p |161  q |162  r |163  s |164  t |165  u |166  v |167  w |
 |170  x |171  y |172  z |173  { |174  | |175  } |176  ~ |177 del|
 |150  h |151  i |152  j |153  k |154  l |155  m |156  n |157  o |
 |160  p |161  q |162  r |163  s |164  t |165  u |166  v |167  w |
 |170  x |171  y |172  z |173  { |174  | |175  } |176  ~ |177 del|
+
+
+| 00 nul| 01 soh| 02 stx| 03 etx| 04 eot| 05 enq| 06 ack| 07 bel|
+| 08 bs | 09 ht | 0a nl | 0b vt | 0c np | 0d cr | 0e so | 0f si |
+| 10 dle| 11 dc1| 12 dc2| 13 dc3| 14 dc4| 15 nak| 16 syn| 17 etb|
+| 18 can| 19 em | 1a sub| 1b esc| 1c fs | 1d gs | 1e rs | 1f us |
+| 20 sp | 21  ! | 22  " | 23  # | 24  $ | 25  % | 26  & | 27  ' |
+| 28  ( | 29  ) | 2a  * | 2b  + | 2c  , | 2d  - | 2e  . | 2f  / |
+| 30  0 | 31  1 | 32  2 | 33  3 | 34  4 | 35  5 | 36  6 | 37  7 |
+| 38  8 | 39  9 | 3a  : | 3b  ; | 3c  < | 3d  = | 3e  > | 3f  ? |
+| 40  @ | 41  A | 42  B | 43  C | 44  D | 45  E | 46  F | 47  G |
+| 48  H | 49  I | 4a  J | 4b  K | 4c  L | 4d  M | 4e  N | 4f  O |
+| 50  P | 51  Q | 52  R | 53  S | 54  T | 55  U | 56  V | 57  W |
+| 58  X | 59  Y | 5a  Z | 5b  [ | 5c  \ | 5d  ] | 5e  ^ | 5f  _ |
+| 60  ` | 61  a | 62  b | 63  c | 64  d | 65  e | 66  f | 67  g |
+| 68  h | 69  i | 6a  j | 6b  k | 6c  l | 6d  m | 6e  n | 6f  o |
+| 70  p | 71  q | 72  r | 73  s | 74  t | 75  u | 76  v | 77  w |
+| 78  x | 79  y | 7a  z | 7b  { | 7c  | | 7d  } | 7e  ~ | 7f del|
diff --git a/usr/pub/kbd b/usr/pub/kbd
new file mode 100644 (file)
index 0000000..780da70
--- /dev/null
@@ -0,0 +1,22 @@
+
+<[1234567890-_]^\ >qwertyuiop@ asdfghjkl;: zxcvbnm,./\r
+
+\ e<[1234567890-_]^\ >          @          ;:        ,./\ f
+
+
+<{!"#$%&'() =_}~| >QWERTYUIOP` ASDFGHJKL+* ZXCVBNM,.?
+
+\ e<{ !"#$%&'() =_} ~ |  >QWERTYUIOP`  ASDFGHJKL+* ZXCVBNM,.?\ f
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/usr/pub/marg8 b/usr/pub/marg8
new file mode 100644 (file)
index 0000000..a4eef67
--- /dev/null
@@ -0,0 +1 @@
+        \e1
diff --git a/usr/pub/tabclr b/usr/pub/tabclr
new file mode 100644 (file)
index 0000000..1926d4f
--- /dev/null
@@ -0,0 +1 @@
+\e2
diff --git a/usr/pub/tabs b/usr/pub/tabs
new file mode 100644 (file)
index 0000000..254c937
--- /dev/null
@@ -0,0 +1,4 @@
+
+\e1        \e1        \e1        \e1        \e1        \e1        \e1        \e1        \e1        \e1        \e1
+012345670123456701234567012345670123456701234567012345670123456701234567012345670
+x      x       x       x       x       x       x       x       x       x       x       x
diff --git a/usr/pub/ttt b/usr/pub/ttt
new file mode 100644 (file)
index 0000000..f8aa2a9
--- /dev/null
@@ -0,0 +1,2 @@
+       .text
+       .byte   033,062
diff --git a/usr/spool/at/lasttimedone b/usr/spool/at/lasttimedone
deleted file mode 100644 (file)
index 7105d93..0000000
+++ /dev/null
@@ -1 +0,0 @@
-1455
diff --git a/usr/spool/at/past/dummy b/usr/spool/at/past/dummy
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/spool/dpd/empty b/usr/spool/dpd/empty
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/usr/spool/lpd/dummy b/usr/spool/lpd/dummy
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/spool/mail/dmr b/usr/spool/mail/dmr
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/usr/spool/mail/dummy b/usr/spool/mail/dummy
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/spool/mail/root b/usr/spool/mail/root
deleted file mode 100644 (file)
index a4bd552..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-From bin Thu Jan 11 19:28:15 1979
-Secret mail has arrived.
-
diff --git a/usr/spool/uucp/users/dummy b/usr/spool/uucp/users/dummy
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/src/cmd/Admin/Mk b/usr/src/cmd/Admin/Mk
new file mode 100755 (executable)
index 0000000..fde80a9
--- /dev/null
@@ -0,0 +1,96 @@
+trap "" 1
+DESTDIR=${DESTDIR-/usr/vaxv7}
+CC=cc
+
+: make sure directory hierarchy exists
+(      cd $DESTDIR
+       for i in bin etc lib sys usr
+       do      if [ ! -d $i ]
+               then rm -f $i; mkdir $i
+               fi
+       done
+       cd $DESTDIR/usr
+       for i in bin dict games lib
+       do      if [ ! -d $i ]
+               then rm -f $i; mkdir $i
+               fi
+       done
+       cd $DESTDIR/usr/lib
+       for i in lex refer struct term uucp
+       do      if [ ! -d $i ]
+               then rm -f $i; mkdir $i
+               fi
+       done
+)
+cd ..
+
+for i in $*
+do     echo "  ======== $i"
+
+       CFLAGS='-O -d2'
+       case $i in
+       dump.c|dumpdir.c|egrep.y|fgrep.c|ncheck.c|restor.c|sa.c|sort.c) CFLAGS=-O ;;
+       as|awk|eqn|f77|lex|lint|llx|pcc|plot|refer|sed|struct|tbl|uucp|yacc) CFLAGS=-O ;;
+       esac
+
+       case $i in
+
+       clean)  rm -f *.o core y.tab.c lex.yy.c  ;: Clean unwanted files.
+               ;;
+
+       *.y)    B=`basename $i .y`
+               eval D=`grep " $B\$" Admin/destinations`
+                  yacc $B.y  \
+               && $CC $CFLAGS -o $B y.tab.c -lln \
+               && install -s $B $DESTDIR$D/$B
+               rm -f y.tab.[co] $B
+               ;;
+
+       *.l)    B=`basename $i .l`
+               eval D=`grep " $B\$" Admin/destinations`
+                  lex $B.l  \
+               && $CC $CFLAGS -o $B lex.yy.c -lln \
+               && install -s $B $DESTDIR$D/$B
+               rm -f lex.yy.[co] $B
+               ;;
+
+       *.c)    B=`basename $i .c`
+               eval D=`grep " $B\$" Admin/destinations`
+                  $CC $CFLAGS -o $B $B.c \
+               && install -s $B $DESTDIR$D/$B
+               rm -f $B.o $B
+               ;;
+
+       *.s)    B=`basename $i .s`
+               eval D=`grep " $B\$" Admin/destinations`
+                  as -o $B.o $B.s \
+               && $CC -o $B $B.o \
+               && install -s $B $DESTDIR$D/$B
+               rm -f $B.o $B
+               ;;
+
+       *.sh)   B=`basename $i .sh`
+               eval D=`grep " $B\$" Admin/destinations`
+               install -c $B.sh $DESTDIR$D/$B
+               ;;
+
+       Admin)  echo Do nothing.
+               ;;
+
+       ALIASES) echo Establish alias names.
+               test -f $DESTDIR/test && ln $DESTDIR/test $DESTDIR/[
+               test -f $DESTDIR/ed   && ln $DESTDIR/ed   $DESTDIR/e
+               ;;
+
+       *)      if [ ! -d $i ]
+               then    echo "Don't know what to do with $i."
+               else
+                       cd $i
+                          make CC=$CC CFLAGS="$CFLAGS" DESTDIR=$DESTDIR \
+                       && make install DESTDIR=$DESTDIR \
+                       && make clean
+                       cd ..
+               fi
+
+       esac
+done
diff --git a/usr/src/cmd/Admin/destinations b/usr/src/cmd/Admin/destinations
new file mode 100644 (file)
index 0000000..79be257
--- /dev/null
@@ -0,0 +1,215 @@
+/usr/bin       ;: [
+/usr/bin       ;: ac
+/etc           ;: accton
+/bin           ;: adb
+/usr/bin       ;: admin
+/bin           ;: ar
+/usr/bin       ;: ar11
+/usr/bin       ;: arcv
+/usr/bin       ;: args
+/usr/games     ;: arithmetic
+/bin           ;: as
+/usr/bin       ;: at
+/usr/lib       ;: atrun
+/usr/bin       ;: awk
+/usr/bin       ;: basename
+/usr/bin       ;: bc
+/usr/games     ;: bcd
+/usr/bin       ;: bdiff
+/usr/games     ;: black
+/usr/bin       ;: bs
+/usr/bin       ;: cal
+/usr/bin       ;: calendar
+/usr/bin       ;: call
+/bin           ;: cat
+/usr/bin       ;: cb
+/bin           ;: cc
+/usr/bin       ;: checkeq
+/usr/bin       ;: chgrp
+/bin           ;: chmod
+/bin           ;: chown
+/bin           ;: clri
+/bin           ;: cmp
+/usr/bin       ;: col
+/usr/bin       ;: comb
+/usr/bin       ;: comm
+/usr/bin       ;: con
+/bin           ;: cp
+/usr/bin       ;: cpall
+/usr/bin       ;: cpio
+/bin           ;: cr
+/etc           ;: cron
+/usr/bin       ;: crypt
+/usr/bin       ;: cu
+/bin           ;: date
+/usr/bin       ;: dc
+/bin           ;: dcheck
+/bin           ;: dd
+/usr/bin       ;: delta
+/usr/bin       ;: deroff
+/bin           ;: df
+/bin           ;: diff
+/usr/bin       ;: diff3
+/usr/lib       ;: diffh
+/etc           ;: dmesg
+/usr/bin       ;: dpr
+/usr/bin       ;: draw
+/bin           ;: du
+/bin           ;: dump
+/bin           ;: dumpdir
+/bin           ;: echo
+/bin           ;: ed
+/bin   ;: edtv
+/usr/bin       ;: egrep
+/usr/bin       ;: eqn
+/usr/bin       ;: expr
+/usr/bin       ;: f77
+/bin           ;: false
+/usr/bin       ;: fcf
+/usr/bin       ;: fcfn
+/usr/bin       ;: fgrep
+/usr/bin       ;: file
+/usr/bin       ;: find
+/usr/games     ;: fish
+/usr/bin       ;: fsend
+/usr/bin       ;: ftp
+/usr/bin       ;: gcat
+/usr/bin       ;: get
+/etc           ;: getty
+/usr/bin       ;: graph
+/bin           ;: grep
+/usr/bin       ;: group
+/usr/bin       ;: hcatsim
+/usr/bin       ;: help
+/usr/bin       ;: hyphen
+/bin           ;: icheck
+/usr/bin       ;: ind
+/usr/bin       ;: indent
+/etc           ;: init
+/usr/bin       ;: install
+/usr/bin       ;: iostat
+/usr/bin       ;: join
+/bin           ;: kill
+/bin           ;: ld
+/usr/bin       ;: lex
+/usr/bin       ;: line
+/usr/bin       ;: lint
+/bin           ;: ln
+/bin           ;: login
+/usr/bin       ;: look
+/usr/bin       ;: lookbib
+/usr/bin       ;: lorder
+/usr/bin       ;: lpr
+/bin           ;: ls
+/usr/bin       ;: m3
+/usr/bin       ;: m4
+/bin           ;: mail
+/usr/bin       ;: make
+/usr/lib       ;: makekey
+/usr/bin/      ;: man
+/usr/bin       ;: mesg
+/usr/bin       ;: mips
+/bin           ;: mkdir
+/etc           ;: mkfs
+/etc           ;: mknod
+/usr/bin       ;: monsum
+/usr/bin       ;: morse
+/etc           ;: mount
+/usr/bin       ;: mtm
+/bin           ;: mv
+/usr/bin       ;: mvall
+/bin           ;: ncheck
+/usr/bin       ;: neqn
+/usr/bin       ;: newgrp
+/usr/bin       ;: news
+/bin           ;: nice
+/bin           ;: nm
+/bin           ;: nohup
+/usr/bin       ;: nroff
+/usr/bin       ;: number
+/bin           ;: od
+/usr/bin       ;: opr
+/bin           ;: passwd
+/usr/bin       ;: paste
+/usr/bin       ;: pcs
+/usr/bin       ;: pg
+/bin           ;: pr
+/usr/bin       ;: prof
+/usr/bin       ;: prompt
+/usr/bin       ;: prt
+/bin           ;: ps.sl
+/bin           ;: ps
+/usr/bin       ;: pstat
+/usr/bin       ;: ptx
+/bin           ;: pwd
+/usr/games     ;: quiz
+/usr/bin       ;: quot
+/etc           ;: quote
+/usr/bin       ;: random
+/usr/bin       ;: reloc
+/bin           ;: restor
+/usr/bin       ;: rev
+/usr/bin       ;: rew
+/bin           ;: rm
+/usr/bin       ;: rmchg
+/bin           ;: rmdir
+/usr/bin       ;: sa
+/usr/bin       ;: scv
+/usr/bin       ;: sed
+/bin           ;: sh
+/bin           ;: size
+/usr/bin       ;: sleep
+/usr/bin       ;: sort
+/usr/bin       ;: sp
+/usr/bin       ;: spell
+/usr/bin       ;: spline
+/usr/bin       ;: split
+/usr/bin       ;: strip
+/bin           ;: stty
+/bin           ;: su
+/usr/bin       ;: sum
+/bin           ;: sync
+/usr/bin       ;: t300
+/usr/bin       ;: t300s
+/usr/bin       ;: t450
+/usr/bin       ;: tabs
+/usr/bin       ;: tabs4
+/usr/bin       ;: tabs8
+/usr/bin       ;: tail
+/bin           ;: tar
+/usr/bin       ;: tbl
+/usr/bin       ;: tc
+/usr/bin       ;: tee
+/usr/bin       ;: tek
+/usr/bin       ;: tekstare
+/usr/bin       ;: test
+/bin           ;: time
+/usr/bin       ;: tk
+/usr/bin       ;: touch
+/bin           ;: tp
+/usr/bin       ;: tr
+/usr/games     ;: trek
+/usr/bin       ;: trim
+/usr/bin       ;: troff
+/bin           ;: true
+/usr/bin       ;: tsort
+/usr/bin       ;: tty
+/etc           ;: umount
+/usr/bin       ;: und
+/usr/bin       ;: uniq
+/usr/bin       ;: units
+/etc           ;: update
+/usr/bin       ;: uucp
+/usr/bin       ;: uux
+/usr/bin       ;: val
+/usr/bin       ;: vis
+/usr/bin       ;: vplot
+/usr/bin       ;: vpr
+/etc           ;: wall
+/usr/bin       ;: wc
+/usr/bin       ;: what
+/bin           ;: who
+/bin           ;: write
+/usr/games     ;: wump
+/usr/bin       ;: yacc
+/usr/bin       ;: yes
diff --git a/usr/src/cmd/adb/:rofix b/usr/src/cmd/adb/:rofix
new file mode 100644 (file)
index 0000000..cd5fa24
--- /dev/null
@@ -0,0 +1,3 @@
+g/^[   ]*\.data/s//.text/
+w
+q
diff --git a/usr/src/cmd/adb/Makefile b/usr/src/cmd/adb/Makefile
new file mode 100644 (file)
index 0000000..c677c47
--- /dev/null
@@ -0,0 +1,42 @@
+CFLAGS=-O -d2
+adb:   access.o command.o expr.o
+adb:   format.o input.o opset.o optab.o main.o
+adb:   message.o output.o
+adb:   pcs.o
+adb:   print.o
+adb:   runpcs.o
+adb:   setup.o sym.o
+adb:;  $(CC) -o adb *.o 
+
+defs.h:                mac.h mode.h
+mode.h:                machine.h
+
+access.o:      defs.h access.c
+command.o:     defs.h command.c
+expr.o:                defs.h expr.c
+format.o:      defs.h format.c
+input.o:       defs.h input.c
+main.o:                defs.h main.c
+message.o:     mac.h mode.h message.c
+       $(CC) -S message.c
+       ed <:rofix message.s
+       as -o message.o message.s
+       rm message.s
+opset.o:       defs.h opset.c
+optab.o:       defs.h optab.c
+       $(CC) -S optab.c
+       ed <:rofix optab.s
+       as -o optab.o optab.s
+       rm optab.s
+output.o:      defs.h output.c
+pcs.o:         defs.h pcs.c
+print.o:       defs.h print.c
+runpcs.o:      defs.h runpcs.c
+setup.o:       defs.h setup.c
+sym.o:         defs.h sym.c
+
+install :
+       install -s adb $(DESTDIR)/bin
+
+clean :
+       rm -f *.o 
index a591679..e6b14e9 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include "defs.h"
  */
 
 #include "defs.h"
+SCCSID(@(#)access.c    2.2);
 
 
 MSG            ODDADR;
 
 
 MSG            ODDADR;
@@ -25,43 +26,68 @@ INT         pid;
 /* file handling and access routines */
 
 put(adr,space,value)
 /* file handling and access routines */
 
 put(adr,space,value)
+#ifndef EDDT
 L_INT  adr;
 {
        access(WT,adr,space,value);
 }
 L_INT  adr;
 {
        access(WT,adr,space,value);
 }
+#else
+       L_INT *adr; {*adr=value;}
+#endif
 
 POS    get(adr, space)
 
 POS    get(adr, space)
+#ifndef EDDT
 L_INT          adr;
 {
        return(access(RD,adr,space,0));
 }
 L_INT          adr;
 {
        return(access(RD,adr,space,0));
 }
+#else
+       L_INT *adr; {return(*adr);}
+#endif
 
 POS    chkget(n, space)
 L_INT          n;
 {
 
 POS    chkget(n, space)
 L_INT          n;
 {
+#ifndef vax
        REG INT         w;
        REG INT         w;
+#else
+       REG L_INT       w;
+#endif
 
        w = get(n, space);
        chkerr();
        return(w);
 }
 
 
        w = get(n, space);
        chkerr();
        return(w);
 }
 
+POS bchkget(n, space) 
+L_INT  n;
+{
+       return(chkget(n, space) & LOBYTE);
+}
+
+#ifndef EDDT
 access(mode,adr,space,value)
 L_INT  adr;
 {
 access(mode,adr,space,value)
 L_INT  adr;
 {
-       INT             w, w1, pmode, rd, file;
+       INT     pmode,rd,file;
+       ADDR    w;
        rd = mode==RD;
 
        IF space == NSP THEN return(0); FI
 
        IF pid          /* tracing on? */
        rd = mode==RD;
 
        IF space == NSP THEN return(0); FI
 
        IF pid          /* tracing on? */
-       THEN IF (adr&01) ANDF !rd THEN error(ODDADR); FI
+       THEN
+#ifndef vax
+               IF adr&01 ANDF !rd THEN error(ODDADR); FI
+#endif
             pmode = (space&DSP?(rd?RDUSER:WDUSER):(rd?RIUSER:WIUSER));
             pmode = (space&DSP?(rd?RDUSER:WDUSER):(rd?RIUSER:WIUSER));
-            w = ptrace(pmode, pid, shorten(adr&~01), value);
+            w = ptrace(pmode, pid, adr, value);
+#ifndef vax
             IF adr&01
             THEN w1 = ptrace(pmode, pid, shorten(adr+1), value);
                  w = (w>>8)&LOBYTE | (w1<<8);
             FI
             IF adr&01
             THEN w1 = ptrace(pmode, pid, shorten(adr+1), value);
                  w = (w>>8)&LOBYTE | (w1<<8);
             FI
+#endif
             IF errno
             THEN errflg = (space&DSP ? BADDAT : BADTXT);
             FI
             IF errno
             THEN errflg = (space&DSP ? BADDAT : BADTXT);
             FI
@@ -76,12 +102,13 @@ L_INT      adr;
        FI
        file=(space&DSP?datmap.ufd:txtmap.ufd);
        IF longseek(file,adr)==0 ORF
        FI
        file=(space&DSP?datmap.ufd:txtmap.ufd);
        IF longseek(file,adr)==0 ORF
-          (rd ? read(file,&w,2) : write(file,&value,2)) < 1
+          (rd ? read(file,&w,sizeof(w)) : write(file,&value,sizeof(w))) < 1
        THEN    errflg=(space&DSP?BADDAT:BADTXT);
        FI
        return(w);
 
 }
        THEN    errflg=(space&DSP?BADDAT:BADTXT);
        FI
        return(w);
 
 }
+#endif
 
 chkmap(adr,space)
        REG L_INT       *adr;
 
 chkmap(adr,space)
        REG L_INT       *adr;
@@ -100,7 +127,7 @@ chkmap(adr,space)
 }
 
 within(adr,lbd,ubd)
 }
 
 within(adr,lbd,ubd)
-L_INT  adr, lbd, ubd;
+POS    adr, lbd, ubd;
 {
        return(adr>=lbd && adr<ubd);
 }
 {
        return(adr>=lbd && adr<ubd);
 }
index e4a7885..9fef4dd 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include "defs.h"
  */
 
 #include "defs.h"
+SCCSID(@(#)command.c   2.4);
 
 
 MSG            BADEQ;
 
 
 MSG            BADEQ;
@@ -23,14 +24,14 @@ INT         mkfault;
 STRING         errflg;
 
 CHAR           lastc;
 STRING         errflg;
 
 CHAR           lastc;
-CHAR           eqformat[128] "o";
-CHAR           stformat[128] "o\"= \"^i";
-POS            *endhdr;
+CHAR           eqformat[128] = "z";
+CHAR           stformat[128] = "X\"= \"^i";
+struct user u;
 
 L_INT          dot;
 L_INT          ditto;
 INT            dotinc;
 
 L_INT          dot;
 L_INT          ditto;
 INT            dotinc;
-INT            lastcom '=';
+INT            lastcom '=';
 L_INT          var[];
 L_INT          locval;
 L_INT          locmsk;
 L_INT          var[];
 L_INT          locval;
 L_INT          locmsk;
@@ -86,7 +87,7 @@ CHAR          defcom;
                goto trystar;
 
            case '=':
                goto trystar;
 
            case '=':
-               itype=NSP; ptype=ASYM;
+               itype=NSP; ptype=0;
                goto trypr;
 
            case '?':
                goto trypr;
 
            case '?':
@@ -129,13 +130,11 @@ CHAR              defcom;
                        case 'l':
                            /*search for exp*/
                            IF eqcom THEN error(BADEQ); FI
                        case 'l':
                            /*search for exp*/
                            IF eqcom THEN error(BADEQ); FI
-                           dotinc=2; savdot=dot;
+                           dotinc=(longpr?4:2); savdot=dot;
                            expr(1); locval=expv;
                            IF expr(0) THEN locmsk=expv; ELSE locmsk = -1L; FI
                            expr(1); locval=expv;
                            IF expr(0) THEN locmsk=expv; ELSE locmsk = -1L; FI
-                           LOOP w=leng(get(dot,itype));
-                                IF longpr
-                                THEN w=itol(w,get(inkdot(2),itype));
-                                FI
+                               IF !longpr THEN locmsk &= 0xFFFF; locval &= 0xFFFF; FI
+                           LOOP w=get(dot,itype);
                                 IF errflg ORF mkfault ORF (w&locmsk)==locval THEN break; FI
                                 dot=inkdot(dotinc);
                            POOL
                                 IF errflg ORF mkfault ORF (w&locmsk)==locval THEN break; FI
                                 dot=inkdot(dotinc);
                            POOL
@@ -154,8 +153,8 @@ CHAR                defcom;
                                 errflg=0; dot=savdot;
                                 IF longpr
                                 THEN put(dot,itype,expv);
                                 errflg=0; dot=savdot;
                                 IF longpr
                                 THEN put(dot,itype,expv);
+                                ELSE put(dot,itype,itol(get(dot+2,itype),expv));
                                 FI
                                 FI
-                                put((longpr?inkdot(2):dot),itype,shorten(expv));
                                 savdot=dot;
                                 printf("=%8t"); exform(1,wformat,itype,ptype);
                                 newline();
                                 savdot=dot;
                                 printf("=%8t"); exform(1,wformat,itype,ptype);
                                 newline();
@@ -177,8 +176,8 @@ CHAR                defcom;
            case '>':
                lastcom=0; savc=rdc();
                IF regptr=getreg(savc)
            case '>':
                lastcom=0; savc=rdc();
                IF regptr=getreg(savc)
-               THEN endhdr[regptr]=shorten(dot);
-                    ptrace(WUREGS,pid,2*(512+regptr),endhdr[regptr]);
+               THEN * (ADDR *) (((ADDR)&u)+regptr)=dot;
+                    ptrace(WUREGS,pid,2*(512+regptr),* (ADDR *) (((ADDR)&u)+regptr));
                ELIF (modifier=varchk(savc)) != -1
                THEN    var[modifier]=dot;
                ELSE    error(BADVAR);
                ELIF (modifier=varchk(savc)) != -1
                THEN    var[modifier]=dot;
                ELSE    error(BADVAR);
@@ -187,7 +186,7 @@ CHAR                defcom;
 
            case '!':
                lastcom=0;
 
            case '!':
                lastcom=0;
-               unox(); break;
+               shell(); break;
 
            case '$':
                lastcom=0;
 
            case '$':
                lastcom=0;
index 427be15..4af7431 100644 (file)
@@ -9,30 +9,34 @@
 
 /*     Layout of a.out file (fsym):
  *
 
 /*     Layout of a.out file (fsym):
  *
- *     header of 8 words       magic number 405, 407, 410, 411
+ *     header of 8 longwords
+ *                             magic number 410
  *                             text size       )
  *                             text size       )
- *                             data size       ) in bytes but even
+ *                             data size       ) padded with 0 to multiple of 4 bytes
  *                             bss size        )
  *                             symbol table size
  *                             bss size        )
  *                             symbol table size
- *                             entry point
- *                             {unused}
- *                             flag set if no relocation
+ *                             entry address
+ *                             size of text relocation info
+ *                             size of data relocation info
  *
  *
  *     header:         0
  *
  *
  *     header:         0
- *     text:           16
- *     data:           16+textsize
- *     relocation:     16+textsize+datasize
- *     symbol table:   16+2*(textsize+datasize) or 16+textsize+datasize
+ *     text:           32
+ *     data:           32+textsize
+ *     text reloc:     32+textsize+datasize
+ *     data reloc:     32+textsize+datasize+textreloc
+ *     symbol table:   32+textsize+datasize+textreloc+datareloc
  *
  */
 
  *
  */
 
+#ifdef EDDT
+#define printf printadb
+#endif
 
 #include <sys/param.h>
 #include <sys/dir.h>
 
 #include <sys/param.h>
 #include <sys/dir.h>
-#include <sys/reg.h>
+#include <sys/psl.h>
 #include <sys/user.h>
 #include <sys/user.h>
-#include <sgtty.h>
 #include "mac.h"
 #include "mode.h"
 
 #include "mac.h"
 #include "mode.h"
 
 #define        DSP     2
 #define STAR   4
 #define STARCOM 0200
 #define        DSP     2
 #define STAR   4
 #define STARCOM 0200
-#define DSYM   7
-#define ISYM   2
-#define ASYM   1
+#define DSYM   4
+#define ISYM   4
+#define ASYM   2
 #define NSYM   0
 #define ESYM   (-1)
 #define NSYM   0
 #define ESYM   (-1)
+#define XSYM   (-2)
 #define BKPTSET        1
 #define BKPTEXEC 2
 #define        SYMSIZ  100
 #define MAXSIG 20
 
 #define BKPTSET        1
 #define BKPTEXEC 2
 #define        SYMSIZ  100
 #define MAXSIG 20
 
-#define USERPS 2*(512-1)
-#define USERPC 2*(512-2)
+#define USERPS PSL
+#define USERPC PC
 #define BPT    03
 #define BPT    03
+#define TBIT   020
 #define FD     0200
 #define        SETTRC  0
 #define        RDUSER  2
 #define FD     0200
 #define        SETTRC  0
 #define        RDUSER  2
 #define        RUREGS  3
 #define        WUREGS  6
 #define        CONTIN  7
 #define        RUREGS  3
 #define        WUREGS  6
 #define        CONTIN  7
-#define        SINGLE  9
 #define        EXIT    8
 #define        EXIT    8
+#define SINGLE 9
 
 #define FROFF  (&(0->fpsr))
 #define FRLEN  25
 #define FRMAX  6
 
 
 #define FROFF  (&(0->fpsr))
 #define FRLEN  25
 #define FRMAX  6
 
-#define        ps      -1
-#define        pc      -2
-#define        sp      -6
-#define        r5      -9
-#define        r4      -10
-#define        r3      -11
-#define        r2      -12
-#define        r1      -5
-#define        r0      -3
+/* the quantities involving ctob() are located in the kernel stack.
+/* the others are in the pcb.
+*/
+#define KSP 0
+#define ESP 4
+#define SSP 8
+#define USP (ctob(4)-5*4)
+#define R0 (ctob(4)-19*4)
+#define R1 (ctob(4)-18*4)
+#define R2 (ctob(4)-17*4)
+#define R3 (ctob(4)-16*4)
+#define R4 (ctob(4)-15*4)
+#define R5 (ctob(4)-14*4)
+#define R6 (ctob(4)-13*4)
+#define R7 (ctob(4)-12*4)
+#define R8 (ctob(4)-11*4)
+#define R9 (ctob(4)-10*4)
+#define R10 (ctob(4)-9*4)
+#define R11 (ctob(4)-8*4)
+#define AP (ctob(4)-7*4)
+#define FP (ctob(4)-6*4)
+#define PC (ctob(4)-2*4)
+#define PSL (ctob(4)-1*4)
+#define P0BR 80
+#define P0LR 84
+#define P1BR 88
+#define P1LR 92
 
 #define MAXOFF 255
 #define MAXPOS 80
 #define MAXLIN 128
 #define EOF    0
 #define EOR    '\n'
 
 #define MAXOFF 255
 #define MAXPOS 80
 #define MAXLIN 128
 #define EOF    0
 #define EOR    '\n'
+#define SP     ' '
 #define TB     '\t'
 #define QUOTE  0200
 #define STRIP  0177
 #define TB     '\t'
 #define QUOTE  0200
 #define STRIP  0177
@@ -110,9 +135,15 @@ union {
        L_INT   L;
 } itolws;
 
        L_INT   L;
 } itolws;
 
+#ifndef vax
 #define leng(a)                ((long)((unsigned)(a)))
 #define shorten(a)     ((int)(a))
 #define itol(a,b)      (itolws.I[0]=(a), itolws.I[1]=(b), itolws.L)
 #define leng(a)                ((long)((unsigned)(a)))
 #define shorten(a)     ((int)(a))
 #define itol(a,b)      (itolws.I[0]=(a), itolws.I[1]=(b), itolws.L)
+#else
+#define leng(a)                itol(0,a)
+#define shorten(a)     ((short)(a))
+#define itol(a,b)      (itolws.I[0]=(b), itolws.I[1]=(a), itolws.L)
+#endif
 
 
 
 
 
 
@@ -126,8 +157,3 @@ STRING              exform();
 L_INT          round();
 BKPTR          scanbkpt();
 VOID           fault();
 L_INT          round();
 BKPTR          scanbkpt();
 VOID           fault();
-
-typedef struct sgttyb TTY;
-TTY    adbtty, usrtty;
-#include <setjmp.h>
-jmp_buf erradb;
diff --git a/usr/src/cmd/adb/dummy.c b/usr/src/cmd/adb/dummy.c
deleted file mode 100644 (file)
index 5c0eabd..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-/*
- *
- *     UNIX debugger - small version
- *
- */
-
-subpcs(modif)
-{
-       prints("sub processes not supported\n");
-}
-
-delbp()
-{;}
-
-endpcs()
-{;}
diff --git a/usr/src/cmd/adb/err b/usr/src/cmd/adb/err
new file mode 100644 (file)
index 0000000..aa06398
--- /dev/null
@@ -0,0 +1,52 @@
+cc -O -d2 -c access.c
+cc -O -d2 -c command.c
+cc -O -d2 -c expr.c
+cc -O -d2 -c format.c
+"format.c", line 115: warning: struct/union or struct/union pointer required
+"format.c", line 116: warning: struct/union or struct/union pointer required
+"format.c", line 214: warning: struct/union or struct/union pointer required
+"format.c", line 219: warning: struct/union or struct/union pointer required
+cc -O -d2 -c input.c
+cc -O -d2 -c opset.c
+"opset.c", line 118: warning: struct/union or struct/union pointer required
+"opset.c", line 119: warning: struct/union or struct/union pointer required
+"opset.c", line 125: warning: struct/union or struct/union pointer required
+"opset.c", line 126: warning: struct/union or struct/union pointer required
+"opset.c", line 127: warning: struct/union or struct/union pointer required
+"opset.c", line 128: warning: struct/union or struct/union pointer required
+cc -S optab.c
+ed <:rofix optab.s
+51223
+50414
+as -o optab.o optab.s
+rm optab.s
+cc -O -d2 -c main.c
+"main.c", line 120: warning: illegal combination of pointer and integer
+"main.c", line 134: warning: illegal combination of pointer and integer
+cc -S message.c
+ed <:rofix message.s
+8661
+8658
+as -o message.o message.s
+rm message.s
+cc -O -d2 -c output.c
+/usr/include/stdio.h: 22: EOF redefined
+"output.c", line 108: warning: illegal pointer combination
+"output.c", line 108: warning: illegal pointer combination
+"output.c", line 120: warning: illegal pointer combination
+"output.c", line 163: warning: illegal combination of pointer and integer
+"output.c", line 236: warning: illegal combination of pointer and integer
+"output.c", line 317: warning: illegal pointer combination
+"output.c", line 319: warning: illegal pointer combination
+cc -O -d2 -c pcs.c
+"pcs.c", line 63: warning: illegal combination of pointer and integer
+"pcs.c", line 64: warning: illegal combination of pointer and integer
+cc -O -d2 -c print.c
+print.c: 102: MAXSIG redefined
+cc -O -d2 -c runpcs.c
+cc -O -d2 -c setup.c
+"setup.c", line 88: warning: illegal combination of pointer and integer
+"setup.c", line 90: warning: illegal combination of pointer and integer
+"setup.c", line 91: warning: illegal combination of pointer and integer
+cc -O -d2 -c sym.c
+cc -o adb *.o 
index e73b325..89eb085 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include "defs.h"
  */
 
 #include "defs.h"
+SCCSID(@(#)expr.c      2.5);
 
 
 MSG            BADSYM;
 
 
 MSG            BADSYM;
@@ -17,22 +18,22 @@ MSG         NOADR;
 MSG            BADLOC;
 
 SYMTAB         symbol;
 MSG            BADLOC;
 
 SYMTAB         symbol;
-INT            lastframe;
-INT            savlastf;
-L_INT          savframe;
-INT            savpc;
-INT            callpc;
+ADDR           lastframe;
+ADDR           savlastf;
+ADDR           savframe;
+ADDR           savpc;
+ADDR           callpc;
 
 
 
 CHAR           *lp;
 
 
 
 CHAR           *lp;
-INT            octal;
+INT            radix;
 STRING         errflg;
 L_INT          localval;
 CHAR           isymbol[8];
 
 STRING         errflg;
 L_INT          localval;
 CHAR           isymbol[8];
 
-CHAR           lastc;
-POS            *endhdr;
+CHAR           lastc,peekc;
+char u[ctob(4)];       /* struct user u; */
 
 L_INT          dot;
 L_INT          ditto;
 
 L_INT          dot;
 L_INT          ditto;
@@ -53,7 +54,7 @@ expr(a)
        WHILE rc
        DO  lhs = expv;
 
        WHILE rc
        DO  lhs = expv;
 
-           switch (readchar()) {
+           switch ((int)readchar()) {
 
                    case '+':
                        term(a|1); expv += lhs; break;
 
                    case '+':
                        term(a|1); expv += lhs; break;
@@ -90,7 +91,7 @@ expr(a)
 term(a)
 {      /* item | monadic item | (expr) | */
 
 term(a)
 {      /* item | monadic item | (expr) | */
 
-       switch (readchar()) {
+       switch ((int)readchar()) {
 
                    case '*':
                        term(a|1); expv=chkget(expv,DSP); return(1);
 
                    case '*':
                        term(a|1); expv=chkget(expv,DSP); return(1);
@@ -119,11 +120,10 @@ term(a)
 
 item(a)
 {      /* name [ . local ] | number | . | ^ | <var | <register | 'x | | */
 
 item(a)
 {      /* name [ . local ] | number | . | ^ | <var | <register | 'x | | */
-       INT             base, d, frpt, regptr;
+       INT             base, d, regptr;
        CHAR            savc;
        BOOL            hex;
        L_INT           frame;
        CHAR            savc;
        BOOL            hex;
        L_INT           frame;
-       UNION{REAL r; L_INT i;} real;
        SYMPTR          symp;
 
        hex=FALSE;
        SYMPTR          symp;
 
        hex=FALSE;
@@ -132,15 +132,17 @@ item(a)
        IF symchar(0)
        THEN    readsym();
                IF lastc=='.'
        IF symchar(0)
        THEN    readsym();
                IF lastc=='.'
-               THEN    frame=endhdr[r5]&EVEN; lastframe=0; callpc=endhdr[pc];
+               THEN    frame= *(ADDR *)(((ADDR)&u[0])+FP); lastframe=0;
+                       callpc= *(ADDR *)(((ADDR)&u[0])+PC);
                        WHILE errflg==0
                        DO  savpc=callpc;
                        WHILE errflg==0
                        DO  savpc=callpc;
-                           findroutine(frame);
+                               findsym(callpc,ISYM);
                            IF  eqsym(symbol.symc,isymbol,'~')
                            THEN break;
                            FI
                            IF  eqsym(symbol.symc,isymbol,'~')
                            THEN break;
                            FI
+                               callpc=get(frame+16, DSP);
                            lastframe=frame;
                            lastframe=frame;
-                           frame=get(frame,DSP)&EVEN;
+                           frame=get(frame+12,DSP)&EVEN;
                            IF frame==0
                            THEN error(NOCFN);
                            FI
                            IF frame==0
                            THEN error(NOCFN);
                            FI
@@ -156,33 +158,12 @@ item(a)
                lp--;
 
 
                lp--;
 
 
-       ELIF digit(lastc) ORF (hex=TRUE, lastc=='#' ANDF hexdigit(readchar()))
-       THEN    expv = 0;
-               base = (lastc == '0' ORF octal ? 8 : (hex ? 16 : 10));
-               WHILE (hex ? hexdigit(lastc) : digit(lastc))
-               DO  expv *= base;
-                   IF (d=convdig(lastc))>=base THEN error(BADSYN); FI
-                   expv += d; readchar();
-                   IF expv==0 ANDF (lastc=='x' ORF lastc=='X')
-                   THEN hex=TRUE; base=16; readchar();
-                   FI
-               OD
-               IF lastc=='.' ANDF (base==10 ORF expv==0) ANDF !hex
-               THEN    real.r=expv; frpt=0; base=10;
-                       WHILE digit(readchar())
-                       DO      real.r *= base; frpt++;
-                               real.r += lastc-'0';
-                       OD
-                       WHILE frpt--
-                       DO      real.r /= base; OD
-                       expv = real.i;
-               FI
-               lp--;
-
+       ELIF getnum(readchar)
+       THEN ;
        ELIF lastc=='.'
        THEN    readchar();
                IF symchar(0)
        ELIF lastc=='.'
        THEN    readchar();
                IF symchar(0)
-               THEN    lastframe=savlastf; callpc=savpc; findroutine(savframe);
+               THEN    lastframe=savlastf; callpc=savpc;
                        chkloc(savframe);
                ELSE    expv=dot;
                FI
                        chkloc(savframe);
                ELSE    expv=dot;
                FI
@@ -200,7 +181,7 @@ item(a)
        ELIF lastc=='<'
        THEN    savc=rdc();
                IF regptr=getreg(savc)
        ELIF lastc=='<'
        THEN    savc=rdc();
                IF regptr=getreg(savc)
-               THEN    expv=endhdr[regptr];
+               THEN    expv= * (ADDR *)(((ADDR)&u[0])+regptr);
                ELIF (base=varchk(savc)) != -1
                THEN    expv=var[base];
                ELSE    error(BADVAR);
                ELIF (base=varchk(savc)) != -1
                THEN    expv=var[base];
                ELSE    error(BADVAR);
@@ -210,7 +191,7 @@ item(a)
        THEN    d=4; expv=0;
                WHILE quotchar()
                DO  IF d--
        THEN    d=4; expv=0;
                WHILE quotchar()
                DO  IF d--
-                   THEN IF d==1 THEN expv =<<16; FI
+                   THEN IF d==1 THEN expv <<=16; FI
                         expv |= ((d&1)?lastc:lastc<<8);
                    ELSE error(BADSYN);
                    FI
                         expv |= ((d&1)?lastc:lastc<<8);
                    ELSE error(BADSYN);
                    FI
@@ -224,6 +205,44 @@ item(a)
 }
 
 /* service routines for expression reading */
 }
 
 /* service routines for expression reading */
+getnum(rdf) int (*rdf)();
+{
+       INT base,d,frpt;
+       BOOL hex;
+       UNION{REAL r; L_INT i;} real;
+       IF digit(lastc) ORF (hex=TRUE, lastc=='#' ANDF hexdigit((*rdf)()))
+       THEN    expv = 0;
+               base = (hex ? 16 : radix);
+               WHILE (base>10 ? hexdigit(lastc) : digit(lastc))
+               DO  expv = (base==16 ? expv<<4 : expv*base);
+                   IF (d=convdig(lastc))>=base THEN error(BADSYN); FI
+                   expv += d; (*rdf)();
+                   IF expv==0
+                   THEN IF (lastc=='x' ORF lastc=='X')
+                                THEN hex=TRUE; base=16; (*rdf)();
+                                ELIF (lastc=='t' ORF lastc=='T')
+                            THEN hex=FALSE; base=10; (*rdf)();
+                        ELIF (lastc=='o' ORF lastc=='O')
+                        THEN hex=FALSE; base=8; (*rdf)();
+                                FI
+                   FI
+               OD
+               IF lastc=='.' ANDF (base==10 ORF expv==0) ANDF !hex
+               THEN    real.r=expv; frpt=0; base=10;
+                       WHILE digit((*rdf)())
+                       DO      real.r *= base; frpt++;
+                               real.r += lastc-'0';
+                       OD
+                       WHILE frpt--
+                       DO      real.r /= base; OD
+                       expv = real.i;
+               FI
+               peekc=lastc;
+/*             lp--; */
+               return(1);
+       ELSE return(0);
+       FI
+}
 
 readsym()
 {
 
 readsym()
 {
@@ -244,8 +263,12 @@ STRING     symstr;
        SYMPTR          symp;
        symset();
        WHILE (symp=symget())
        SYMPTR          symp;
        symset();
        WHILE (symp=symget())
+#ifndef EDDT
        DO IF (symp->symf&SYMCHK)==symp->symf
           ANDF eqsym(symp->symc, symstr,'_')
        DO IF (symp->symf&SYMCHK)==symp->symf
           ANDF eqsym(symp->symc, symstr,'_')
+#else
+       DO      IF eqsym(symp->symc, symstr, '_')
+#endif
            THEN return(symp);
            FI
        OD
            THEN return(symp);
            FI
        OD
diff --git a/usr/src/cmd/adb/findfn.c b/usr/src/cmd/adb/findfn.c
deleted file mode 100644 (file)
index 6c5e8d9..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#
-/*
- *
- *     UNIX debugger
- *
- */
-
-#include "defs.h"
-
-
-MSG            NOCFN;
-
-INT            callpc;
-BOOL           localok;
-SYMTAB         symbol;
-
-STRING         errflg;
-
-
-findroutine(cframe)
-       L_INT           cframe;
-{
-       REG INT         narg, inst;
-       INT             lastpc, back2;
-       BOOL            v;
-
-       v=FALSE; localok=FALSE; lastpc=callpc;
-       callpc=get(cframe+2, DSP); back2=get(leng(callpc-2), ISP);
-       IF (inst=get(leng(callpc-4), ISP)) == 04737     /* jsr pc,*$... */
-       THEN    narg = 1;
-       ELIF (inst&~077)==04700                 /* jsr pc,... */
-       THEN    narg=0; v=(inst!=04767);
-       ELIF (back2&~077)==04700
-       THEN    narg=0; v=TRUE;
-       ELSE    errflg=NOCFN;
-               return(0);
-       FI
-       IF findsym( (v ? lastpc : ((inst==04767?callpc:0) + back2) ),ISYM) == -1
-           ANDF !v
-       THEN    symbol.symc[0] = '?';
-               symbol.symc[1] = 0;
-               symbol.symv = 0;
-       ELSE    localok=TRUE;
-       FI
-       inst = get(leng(callpc), ISP);
-       IF inst == 05726                /* tst (sp)+ */
-       THEN    return(narg+1);
-       FI
-       IF inst == 022626               /* cmp (sp)+,(sp)+ */
-       THEN    return(narg+2);
-       FI
-       IF inst == 062706               /* add $n,sp */
-       THEN    return(narg+get(leng(callpc+2), ISP)/2);
-       FI
-       return(narg);
-}
-
index 6707255..6b4f9fc 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include "defs.h"
  */
 
 #include "defs.h"
+SCCSID (@(#)format.c   2.4);
 
 
 MSG            BADMOD;
 
 
 MSG            BADMOD;
@@ -16,16 +17,23 @@ SYMTAB              symbol;
 
 INT            mkfault;
 CHAR           *lp;
 
 INT            mkfault;
 CHAR           *lp;
-INT            maxoff;
-INT            sigint;
-INT            sigqit;
+L_INT          maxoff;
+ADDR           sigint;
+ADDR           sigqit;
 STRING         errflg;
 STRING         errflg;
-CHAR           lastc;
+CHAR           lastc,peekc;
 L_INT          dot;
 INT            dotinc;
 L_INT          dot;
 INT            dotinc;
+L_INT          expv;
 L_INT          var[];
 
 
 L_INT          var[];
 
 
+STRING         fphack;
+rdfp()
+{
+       return(lastc= *fphack++);
+}
+
 scanform(icount,ifp,itype,ptype)
 L_INT          icount;
 STRING         ifp;
 scanform(icount,ifp,itype,ptype)
 L_INT          icount;
 STRING         ifp;
@@ -34,28 +42,28 @@ STRING              ifp;
        CHAR            modifier;
        INT             fcount, init=1;
        L_INT           savdot;
        CHAR            modifier;
        INT             fcount, init=1;
        L_INT           savdot;
+       BOOL exact;
 
        WHILE icount
        DO  fp=ifp;
 
        WHILE icount
        DO  fp=ifp;
-           IF init==0 ANDF findsym(shorten(dot),ptype)==0 ANDF maxoff
+           savdot=dot; init=0;
+
+           IF init==0 ANDF (exact=(findsym(dot,ptype)==0)) ANDF maxoff
            THEN printf("\n%.8s:%16t",symbol.symc);
            FI
            THEN printf("\n%.8s:%16t",symbol.symc);
            FI
-           savdot=dot; init=0;
 
            /*now loop over format*/
            WHILE *fp ANDF errflg==0
 
            /*now loop over format*/
            WHILE *fp ANDF errflg==0
-           DO  IF digit(modifier = *fp)
-               THEN fcount=0;
-                    WHILE digit(modifier = *fp++)
-                    DO fcount *= 10;
-                       fcount += modifier-'0';
-                    OD
-                    fp--;
+           DO  IF (fphack=fp, getnum(rdfp))
+               THEN fcount=expv; fp= --fphack; peekc=0;
                ELSE fcount=1;
                FI
 
                IF *fp==0 THEN break; FI
                ELSE fcount=1;
                FI
 
                IF *fp==0 THEN break; FI
-               fp=exform(fcount,fp,itype,ptype);
+               IF exact ANDF dot==savdot ANDF itype==ISP ANDF symbol.symc[0]=='_' ANDF *fp=='i'
+               THEN exform(1,"x",itype,ptype); fp++; printc(EOR); /* entry mask */
+               ELSE fp=exform(fcount,fp,itype,ptype);
+               FI
            OD
            dotinc=dot-savdot;
            dot=savdot;
            OD
            dotinc=dot-savdot;
            dot=savdot;
@@ -73,7 +81,8 @@ STRING                ifp;
        OD
 }
 
        OD
 }
 
-STRING exform(fcount,ifp,itype,ptype)
+STRING
+exform(fcount,ifp,itype,ptype)
 INT            fcount;
 STRING         ifp;
 {
 INT            fcount;
 STRING         ifp;
 {
@@ -93,12 +102,12 @@ STRING             ifp;
 
        WHILE fcount>0
        DO      fp = ifp; c = *fp;
 
        WHILE fcount>0
        DO      fp = ifp; c = *fp;
-               longpr=(c>='A')&(c<='Z')|(c=='f');
+               longpr=(c>='A')&(c<='Z')|(c=='f')|(c=='4');
                IF itype==NSP ORF *fp=='a'
                THEN wx=dot; w=dot;
                ELSE w=get(dot,itype);
                     IF longpr
                IF itype==NSP ORF *fp=='a'
                THEN wx=dot; w=dot;
                ELSE w=get(dot,itype);
                     IF longpr
-                    THEN wx=itol(w,get(inkdot(2),itype));
+                    THEN wx=itol(get(inkdot(2),itype),w);
                     ELSE wx=w;
                     FI
                FI
                     ELSE wx=w;
                     FI
                FI
@@ -147,6 +156,17 @@ STRING             ifp;
                    case 'b': case 'B':
                        printf("%-8o", w&LOBYTE); dotinc=1; break;
 
                    case 'b': case 'B':
                        printf("%-8o", w&LOBYTE); dotinc=1; break;
 
+                       case '1':
+                       printf("%-8r", w&LOBYTE); dotinc=1; break;
+
+                       case '2':
+                   case 'w':
+                       printf("%-8r", w); break;
+
+                       case '4':
+                   case 'W':
+                       printf("%-16R", wx); break;
+
                    case 's': case 'S':
                        savdot=dot; dotinc=1;
                        WHILE (c=get(dot,itype)&LOBYTE) ANDF errflg==0
                    case 's': case 'S':
                        savdot=dot; dotinc=1;
                        WHILE (c=get(dot,itype)&LOBYTE) ANDF errflg==0
@@ -175,11 +195,9 @@ STRING             ifp;
                        printf("%-16Q", wx); break;
 
                    case 'o':
                        printf("%-16Q", wx); break;
 
                    case 'o':
-                   case 'w':
                        printf("%-8o", w); break;
 
                    case 'O':
                        printf("%-8o", w); break;
 
                    case 'O':
-                   case 'W':
                        printf("%-16O", wx); break;
 
                    case 'i':
                        printf("%-16O", wx); break;
 
                    case 'i':
@@ -232,10 +250,11 @@ STRING            ifp;
        return(fp);
 }
 
        return(fp);
 }
 
-unox()
+shell()
 {
 {
+#ifndef EDDT
        INT             rc, status, unixpid;
        INT             rc, status, unixpid;
-       STRING          argp lp;
+       STRING          argp lp;
 
        WHILE lastc!=EOR DO rdc(); OD
        IF (unixpid=fork())==0
 
        WHILE lastc!=EOR DO rdc(); OD
        IF (unixpid=fork())==0
@@ -249,6 +268,7 @@ unox()
                signal(SIGINT,sigint);
                prints("!"); lp--;
        FI
                signal(SIGINT,sigint);
                prints("!"); lp--;
        FI
+#endif
 }
 
 
 }
 
 
index ce52a3e..1c2531b 100644 (file)
@@ -6,12 +6,13 @@
  */
 
 #include "defs.h"
  */
 
 #include "defs.h"
+SCCSID(@(#)input.c     2.2);
 
 INT            mkfault;
 CHAR           line[LINSIZ];
 INT            infile;
 CHAR           *lp;
 
 INT            mkfault;
 CHAR           line[LINSIZ];
 INT            infile;
 CHAR           *lp;
-CHAR           lastc EOR;
+CHAR           peekc,lastc = EOR;
 INT            eof;
 
 /* input routines */
 INT            eof;
 
 /* input routines */
@@ -35,12 +36,18 @@ readchar()
        THEN    lastc=EOF;
        ELSE    IF lp==0
                THEN    lp=line;
        THEN    lastc=EOF;
        ELSE    IF lp==0
                THEN    lp=line;
+#ifdef EDDT
+                       getcon(lp); eof=0; while (*lp++!=EOR);
+#else
                        REP eof = read(infile,lp,1)==0;
                            IF mkfault THEN error(0); FI
                        PER eof==0 ANDF *lp++!=EOR DONE
                        REP eof = read(infile,lp,1)==0;
                            IF mkfault THEN error(0); FI
                        PER eof==0 ANDF *lp++!=EOR DONE
+#endif
                        *lp=0; lp=line;
                FI
                        *lp=0; lp=line;
                FI
-               IF lastc = *lp THEN lp++; FI
+               IF lastc = peekc THEN peekc=0;
+               ELIF lastc = *lp THEN lp++;
+               FI
        FI
        return(lastc);
 }
        FI
        return(lastc);
 }
@@ -78,4 +85,22 @@ STRING               deformat;
        IF fptr!=deformat THEN *fptr++ = '\0'; FI
 }
 
        IF fptr!=deformat THEN *fptr++ = '\0'; FI
 }
 
-
+#ifdef EDDT
+getcon(cs) register char *cs; {
+register char *p=cs;
+for(;;) {
+       putchar(*p++=getcnsl());
+       if (p[-1]=='\r') {putchar(p[-1]='\n'); *p++='\0'; return;}
+       if (p[-1]=='\\') {p[-1]=getcnsl(); continue;}
+       if (p[-1]=='#') {p -= 2; continue;}
+       if (p[-1]=='@') {putchar('\r'); putchar('\n'); p=cs; continue;}
+}}
+getcnsl() {
+# define RXCS  32  /*  receiver control/staus */
+# define RXDB  33  /*  receiver data */
+# define RXCS_DONE  0x80  /*  receiver done */
+while ((mfpr(RXCS) & RXCS_DONE)==0);
+return (mfpr(RXDB) & 0177);
+}
+#endif
index a5510d6..9c0e0af 100644 (file)
@@ -45,3 +45,5 @@
 #define TB     '\t'
 #define NL     '\n'
 #define EOF    0
 #define TB     '\t'
 #define NL     '\n'
 #define EOF    0
+
+#define SCCSID(arg) static char Sccsid[] = "arg"
index 12b2a3a..c92368e 100644 (file)
@@ -1,27 +1,31 @@
 #
 /*
 #
 /*
- *     UNIX/INTERDATA debugger
+ *     UNIX/vax debugger
  */
 
 /* unix parameters */
 #define DBNAME "adb\n"
  */
 
 /* unix parameters */
 #define DBNAME "adb\n"
-#define LPRMODE "%Q"
-#define OFFMODE "+%o"
-#define TXTRNDSIZ 8192L
+#define LPRMODE "%R"
+#define OFFMODE "+%R"
+#define TXTRNDSIZ 512L
 
 
-TYPE   unsigned TXTHDR[8];
-TYPE   unsigned SYMV;
+TYPE   long TXTHDR[8];
+TYPE   long SYMV;
+
+#ifndef vax
+struct {short hiword; short loword;}; /* stupid fp-11 */
+#endif
 
 /* symbol table in a.out file */
 struct symtab {
        char    symc[8];
 
 /* symbol table in a.out file */
 struct symtab {
        char    symc[8];
-       int     symf;
+#ifndef EDDT
+       char    symf;
+       char    sympad[3];
+#endif
        SYMV    symv;
 };
 #define SYMTABSIZ (sizeof (struct symtab))
 
        SYMV    symv;
 };
 #define SYMTABSIZ (sizeof (struct symtab))
 
-#define SYMCHK 047
-#define SYMTYPE(symflg) (( symflg>=041 || (symflg>=02 && symflg<=04))\
-                               ?  ((symflg&07)>=3 ? DSYM : (symflg&07))\
-                               : NSYM\
-                       )
+#define SYMCHK 057
+#define SYMTYPE(symflg) (symflg&41 ? DSYM : NSYM)
index 6d7c7fa..f53df41 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include "defs.h"
  */
 
 #include "defs.h"
+SCCSID(@(#)main.c      2.2);
 
 
 MSG            NOEOR;
 
 
 MSG            NOEOR;
@@ -14,10 +15,10 @@ INT         mkfault;
 INT            executing;
 INT            infile;
 CHAR           *lp;
 INT            executing;
 INT            infile;
 CHAR           *lp;
-INT            maxoff;
-INT            maxpos;
-INT            sigint;
-INT            sigqit;
+L_INT          maxoff;
+L_INT          maxpos;
+ADDR           sigint;
+ADDR           sigqit;
 INT            wtflag;
 L_INT          maxfile;
 L_INT          maxstor;
 INT            wtflag;
 L_INT          maxfile;
 L_INT          maxstor;
@@ -26,7 +27,7 @@ L_INT         datsiz;
 L_INT          datbas;
 L_INT          stksiz;
 STRING         errflg;
 L_INT          datbas;
 L_INT          stksiz;
 STRING         errflg;
-INT            exitflg;
+L_INT          exitflg;
 INT            magic;
 L_INT          entrypt;
 
 INT            magic;
 L_INT          entrypt;
 
@@ -41,11 +42,13 @@ CHAR                printbuf[];
 CHAR           *printptr;
 
 
 CHAR           *printptr;
 
 
-L_INT  round(a,b)
-L_INT          a, b;
+L_INT
+round(a,b)
+REG L_INT a, b;
 {
 {
-       L_INT           w;
-       w = ((a+b-1)/b)*b;
+       REG L_INT w;
+       w = (a/b)*b;
+       IF a!=w THEN w += b; FI
        return(w);
 }
 
        return(w);
 }
 
@@ -63,27 +66,34 @@ error(n)
 {
        errflg=n;
        iclose(); oclose();
 {
        errflg=n;
        iclose(); oclose();
-       longjmp(erradb,1);
+#ifndef EDDT
+       reset();
+#endif
 }
 
 fault(a)
 {
        signal(a,fault);
 }
 
 fault(a)
 {
        signal(a,fault);
+#ifndef EDDT
        lseek(infile,0L,2);
        lseek(infile,0L,2);
+#endif
        mkfault++;
 }
 
 /* set up files and initial address mappings */
 INT argcount;
 
        mkfault++;
 }
 
 /* set up files and initial address mappings */
 INT argcount;
 
+#ifndef EDDT
 main(argc, argv)
 main(argc, argv)
+#else
+eddt(argc, argv)
+#endif
 REG STRING     *argv;
 REG INT                argc;
 {
 REG STRING     *argv;
 REG INT                argc;
 {
-       maxfile=1L<<24; maxstor=1L<<16;
+       maxfile=1L<<24; maxstor=1L<<31;
+       mkioptab();
 
 
-       gtty(0,&adbtty);
-       gtty(0,&usrtty);
        WHILE argc>1
        DO      IF eqstr("-w",argv[1])
                THEN    wtflag=2; argc--; argv++;
        WHILE argc>1
        DO      IF eqstr("-w",argv[1])
                THEN    wtflag=2; argc--; argv++;
@@ -105,13 +115,18 @@ REG INT           argc;
        var[VARS] = stksiz;
        var[VART] = txtsiz;
 
        var[VARS] = stksiz;
        var[VART] = txtsiz;
 
+#ifndef EDDT
        IF (sigint=signal(SIGINT,01))!=01
        THEN    sigint=fault; signal(SIGINT,fault);
        FI
        sigqit=signal(SIGQUIT,1);
        IF (sigint=signal(SIGINT,01))!=01
        THEN    sigint=fault; signal(SIGINT,fault);
        FI
        sigqit=signal(SIGQUIT,1);
-       setjmp(erradb);
+       setexit();
+#endif
        IF executing THEN delbp(); FI
        executing=FALSE;
        IF executing THEN delbp(); FI
        executing=FALSE;
+#ifdef EDDT
+       prints(DBNAME);
+#endif
 
        LOOP    flushbuf();
                IF errflg
 
        LOOP    flushbuf();
                IF errflg
@@ -125,7 +140,11 @@ REG INT            argc;
                lp=0; rdc(); lp--;
                IF eof
                THEN    IF infile
                lp=0; rdc(); lp--;
                IF eof
                THEN    IF infile
-                       THEN    iclose(); eof=0; longjmp(erradb,1);
+#ifndef EDDT
+                       THEN    iclose(); eof=0; reset();
+#else
+                       THEN    iclose(); eof=0;
+#endif
                        ELSE    done();
                        FI
                ELSE    exitflg=0;
                        ELSE    done();
                        FI
                ELSE    exitflg=0;
@@ -135,9 +154,10 @@ REG INT            argc;
        POOL
 }
 
        POOL
 }
 
+#ifndef EDDT
 done()
 {
        endpcs();
        exit(exitflg);
 }
 done()
 {
        endpcs();
        exit(exitflg);
 }
-
+#endif
diff --git a/usr/src/cmd/adb/makefile b/usr/src/cmd/adb/makefile
deleted file mode 100644 (file)
index 9256b7f..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-CFLAGS = -i -O
-
-all:   adb
-
-cmp:   adb
-       cmp adb /bin/adb
-       rm adb *.o
-
-cp:    adb
-       cp adb /bin/adb
-       rm adb *.o
-
-adb:   access.o command.o expr.o findfn.o
-adb:   format.o input.o opset.o main.o
-adb:   message.o output.o pcs.o print.o
-adb:   runpcs.o setup.o sym.o
-adb:;  cc -o adb -i *.o
-
-
-access.o:      defs.h
-command.o:     defs.h
-expr.o:                defs.h
-findrtn.o:     defs.h
-format.o:      defs.h
-input.o:       defs.h
-main.o:                defs.h
-message.o:     mac.h mode.h
-output.o:      defs.h
-pcs.o:         defs.h
-print.o:       defs.h
-runpcs.o:      defs.h
-setup.o:       defs.h
-sym.o:         defs.h
index 0a7b9f1..577eb77 100644 (file)
@@ -8,9 +8,10 @@
 
 
 #include       "mac.h"
 
 
 #include       "mac.h"
+SCCSID(@(#)message.c   2.2);
 #include       "mode.h"
 
 #include       "mode.h"
 
-MSG            version = "\nVERSION sys117     DATE 1978 Dec 27 16:37:44\n";
+MSG            VERSION =  "\nVERSION vax2.1    DATE 780917\n";
 
 MSG            BADMOD  =  "bad modifier";
 MSG            BADCOM  =  "bad command";
 
 MSG            BADMOD  =  "bad modifier";
 MSG            BADCOM  =  "bad command";
index 61c1c82..65036ce 100644 (file)
@@ -6,7 +6,12 @@
 #define MAXCOM 64
 #define MAXARG 32
 #define LINSIZ 256
 #define MAXCOM 64
 #define MAXARG 32
 #define LINSIZ 256
+TYPE   long    ADDR;
+#ifndef vax
 TYPE   int             INT;
 TYPE   int             INT;
+#else
+TYPE   short   INT;
+#endif
 TYPE   int             VOID;
 TYPE   long int        L_INT;
 TYPE   float           REAL;
 TYPE   int             VOID;
 TYPE   long int        L_INT;
 TYPE   float           REAL;
@@ -44,8 +49,8 @@ struct symslave {
 };
 
 struct bkpt {
 };
 
 struct bkpt {
-       INT     loc;
-       INT     ins;
+       ADDR    loc;
+       ADDR    ins;
        INT     count;
        INT     initcnt;
        INT     flag;
        INT     count;
        INT     initcnt;
        INT     flag;
index e74b181..3a26878 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include "defs.h"
  */
 
 #include "defs.h"
+SCCSID(@(#)opset.c     2.3);
 
 STRING         errflg;
 L_INT          dot;
 
 STRING         errflg;
 L_INT          dot;
@@ -15,363 +16,132 @@ L_INT             var[];
 
 /* instruction printing */
 
 
 /* instruction printing */
 
-#define        DOUBLE  0
-#define DOUBLW 1
-#define        SINGLE  2
-#define SINGLW 3
-#define        REVERS  4
-#define        BRANCH  5
-#define        NOADDR  6
-#define        DFAULT  7
-#define        TRAP    8
-#define        SYS     9
-#define        SOB     10
-#define JMP    11
-#define JSR    12
+/*
+ * Argument access types
+ */
+#define ACCA   (8<<3)  /* address only */
+#define ACCR   (1<<3)  /* read */
+#define ACCW   (2<<3)  /* write */
+#define ACCM   (3<<3)  /* modify */
+#define ACCB   (4<<3)  /* branch displacement */
+#define ACCI   (5<<3)  /* XFC code */
+
+/*
+ * Argument data types
+ */
+#define TYPB   0       /* byte */
+#define TYPW   1       /* word */
+#define TYPL   2       /* long */
+#define TYPQ   3       /* quad */
+#define TYPF   4       /* floating */
+#define TYPD   5       /* double floating */
 
 
 TYPE   struct optab    *OPTAB;
 struct optab {
 
 
 TYPE   struct optab    *OPTAB;
 struct optab {
-       int     mask;
-       int     val;
-       int     itype;
-       char    *iname;
-} optab[] {
-       0107777, 0010000, DOUBLE, "mov",
-       0107777, 0020000, DOUBLE, "cmp",
-       0107777, 0030000, DOUBLE, "bit",
-       0107777, 0040000, DOUBLE, "bic",
-       0107777, 0050000, DOUBLE, "bis",
-       0007777, 0060000, DOUBLE, "add",
-       0007777, 0160000, DOUBLE, "su",
-       0100077, 0005000, SINGLE, "clr",
-       0100077, 0005100, SINGLE, "com",
-       0100077, 0005200, SINGLE, "inc",
-       0100077, 0005300, SINGLE, "dec",
-       0100077, 0005400, SINGLE, "neg",
-       0100077, 0005500, SINGLE, "adc",
-       0100077, 0005600, SINGLE, "sbc",
-       0100077, 0005700, SINGLE, "tst",
-       0100077, 0006000, SINGLE, "ror",
-       0100077, 0006100, SINGLE, "rol",
-       0100077, 0006200, SINGLE, "asr",
-       0100077, 0006300, SINGLE, "asl",
-       0000077, 0000100, JMP,    "jmp",
-       0000077, 0000300, SINGLE, "swab",
-       0000077, 0170100, SINGLW, "ldfps",
-       0000077, 0170200, SINGLW, "stfps",
-       0000077, 0170300, SINGLW, "stst",
-       0000077, 0170400, SINGLW, "clrf",
-       0000077, 0170500, SINGLW, "tstf",
-       0000077, 0170600, SINGLW, "absf",
-       0000077, 0170700, SINGLW, "negf",
-       0000077, 0006700, SINGLW, "sxt",
-       0000077, 0006600, SINGLW, "mtpi",
-       0000077, 0106600, SINGLW, "mtpd",
-       0000077, 0006500, SINGLW, "mfpi",
-       0000077, 0106500, SINGLW, "mfpd",
-       0000777, 0070000, REVERS, "mul",
-       0000777, 0071000, REVERS, "div",
-       0000777, 0072000, REVERS, "ash",
-       0000777, 0073000, REVERS, "ashc",
-       LOBYTE,  0000400, BRANCH, "br",
-       LOBYTE,  0001000, BRANCH, "bne",
-       LOBYTE,  0001400, BRANCH, "beq",
-       LOBYTE,  0002000, BRANCH, "bge",
-       LOBYTE,  0002400, BRANCH, "blt",
-       LOBYTE,  0003000, BRANCH, "bgt",
-       LOBYTE,  0003400, BRANCH, "ble",
-       LOBYTE,  0100000, BRANCH, "bpl",
-       LOBYTE,  0100400, BRANCH, "bmi",
-       LOBYTE,  0101000, BRANCH, "bhi",
-       LOBYTE,  0101400, BRANCH, "blos",
-       LOBYTE,  0102000, BRANCH, "bvc",
-       LOBYTE,  0102400, BRANCH, "bvs",
-       LOBYTE,  0103000, BRANCH, "bcc",
-       LOBYTE,  0103400, BRANCH, "bcs",
-       0000000, 0000000, NOADDR, "halt",
-       0000000, 0000001, NOADDR, "wait",
-       0000000, 0000002, NOADDR, "rti",
-       0000000, 0000003, NOADDR, "bpt",
-       0000000, 0000004, NOADDR, "iot",
-       0000000, 0000005, NOADDR, "reset",
-       LOBYTE,  0171000, REVERS, "mulf",
-       LOBYTE,  0171400, REVERS, "modf",
-       LOBYTE,  0172000, REVERS, "addf",
-       LOBYTE,  0172400, REVERS, "movf",
-       LOBYTE,  0173000, REVERS, "subf",
-       LOBYTE,  0173400, REVERS, "cmpf",
-       LOBYTE,  0174000, DOUBLW, "movf",
-       LOBYTE,  0174400, REVERS, "divf",
-       LOBYTE,  0175000, DOUBLW, "movei",
-       LOBYTE,  0175400, DOUBLW, "movfi",
-       LOBYTE,  0176000, DOUBLW, "movfo",
-       LOBYTE,  0176400, REVERS, "movie",
-       LOBYTE,  0177000, REVERS, "movif",
-       LOBYTE,  0177400, REVERS, "movof",
-       0000000, 0170000, NOADDR, "cfcc",
-       0000000, 0170001, NOADDR, "setf",
-       0000000, 0170002, NOADDR, "seti",
-       0000000, 0170011, NOADDR, "setd",
-       0000000, 0170012, NOADDR, "setl",
-       0000777, 0004000, JSR,    "jsr",
-       0000777, 0074000, DOUBLE, "xor",
-       0000007, 0000200, SINGLE, "rts",
-       0000017, 0000240, DFAULT, "cflg",
-       0000017, 0000260, DFAULT, "sflg",
-       LOBYTE,  0104000, TRAP,   "emt",
-       LOBYTE,  0104400, SYS,    "sys",
-       0000077, 0006400, TRAP,   "mark",
-       0000777, 0077000, SOB,    "sob",
-       0000007, 0000230, TRAP,   "spl",
-       0177777, 0000000, DFAULT, "",
-};
-
+       char *iname;
+       char val;
+       char nargs;
+       char argtype[6];
+} optab[];
 #define SYSTAB struct systab
 SYSTAB {
        int     argc;
        char    *sname;
 #define SYSTAB struct systab
 SYSTAB {
        int     argc;
        char    *sname;
-} systab[] {
-       1, "indir",
-       0, "exit",
-       0, "fork",
-       2, "read",
-       2, "write",
-       2, "open",
-       0, "close",
-       0, "wait",
-       2, "creat",
-       2, "link",
-       1, "unlink",
-       2, "exec",
-       1, "chdir",
-       0, "time",
-       3, "mknod",
-       2, "chmod",
-       2, "chown",
-       1, "break",
-       2, "stat",
-       2, "seek",
-       0, "getpid",
-       3, "mount",
-       1, "umount",
-       0, "setuid",
-       0, "getuid",
-       0, "stime",
-       3, "ptrace",
-       0, "alarm",
-       1, "fstat",
-       0, "pause",
-       1, "30",
-       1, "stty",
-       1, "gtty",
-       0, "access",
-       0, "nice",
-       0, "sleep",
-       0, "sync",
-       1, "kill",
-       0, "csw",
-       0, "setpgrp",
-       0, "tell",
-       0, "dup",
-       0, "pipe",
-       1, "times",
-       4, "profil",
-       0, "tiu",
-       0, "setgid",
-       0, "getgid",
-       2, "signal",
-       0, "49",
-       0, "50",
-       0, "51",
-       0, "52",
-       0, "53",
-       0, "54",
-       0, "55",
-       0, "56",
-       0, "57",
-       0, "58",
-       0, "59",
-       0, "60",
-       0, "61",
-       0, "62",
-       0, "63",
-};
-
-STRING regname[] { "r0", "r1", "r2", "r3", "r4", "r5", "sp", "pc"};
-
+} systab[];
+STRING regname[];
+STRING fltimm[];
 POS    type, space, incp;
 
 POS    type, space, incp;
 
-printins(f,idsp,ins)
-REG INT                ins;
-{
-       INT             byte;
-       REG OPTAB       p;
-
-       type=DSYM; space=idsp; incp=2;
-       FOR p=optab;; p++
-       DO      IF (ins & ~p->mask) == p->val
-               THEN    break;
-               FI
-       OD
-       prints(p->iname); byte=ins&0100000; ins &= p->mask;
-       switch (p->itype) {
-
-           case JMP:
-               type=ISYM;
-
-           case SINGLE:
-               IF byte THEN printc('b'); FI
-           case SINGLW:
-               paddr("%8t",ins);
-               break;
-
-           case REVERS:
-               doubl(ins&077,(ins>>6)&07);
-               break;
-
-           case JSR:
-               type=ISYM;
-
-           case DOUBLE:
-               IF byte THEN printc('b'); FI
-           case DOUBLW:
-               doubl(ins>>6,ins);
+int ioptab[256]; /* index by opcode to optab */
 
 
-           case NOADDR:
-               break;
-
-           case SOB:
-               paddr("%8t",(ins>>6)&07);
-               branch(",",-(ins&077));
-               break;
-
-           case BRANCH:
-               branch("%8t",ins);
-               break;
-
-           case SYS:
-               BEGIN
-                  INT          indir;
-                  REG INT      w;
-                  printf("%8t%s", systab[ins &= 077].sname);
-                  IF ins==0 ANDF f==0 ANDF idsp!=NSP   /* indir */
-                  THEN w=dot; dot=chkget(inkdot(2),idsp);
-                       prints(" {");
-                       indir=get(dot,DSP);
-                       IF errflg
-                       THEN errflg=0; printc('?');
-                       ELSE printins(1,DSP,indir);
-                       FI
-                       printc('}');
-                       dot=w; incp=4;
-                  ELSE w = systab[ins].argc;
-                       WHILE w-- ANDF idsp!=NSP
-                       DO prints("; ");
-                          psymoff(leng(get(inkdot(incp),idsp)), NSYM, "");
-                          incp += 2;
-                       OD
-                  FI
-               END
-               break;
-
-           case TRAP:
-           case DFAULT:
-           default:
-               printf("%8t%o", ins);
-       }
-       dotinc=incp;
+mkioptab() {/* set up ioptab */
+REG OPTAB p=optab; while (p->iname) {ioptab[p->val&LOBYTE]=p-optab; p++;}
 }
 
 }
 
-doubl(a,b)
-{
-       paddr("%8t",a); paddr(",",b);
-}
+extern char *fmtr;
+extern char *fmtR;
 
 
-branch(s,ins)
-STRING         s;
+printins(f,idsp,ins)
+#ifndef vax
 REG INT                ins;
 REG INT                ins;
+#else
+REG L_INT      ins;
+#endif
 {
 {
-       printf(s);
-       IF ins&0200 THEN ins |= 0177400; FI
-       ins = shorten(dot) + (ins<<1) + 2;
-       psymoff(leng(ins),ISYM,"");
-}
-
-paddr(s, a)
-STRING         s;
-REG INT                a;
-{
-       REG INT         r;
-
-       var[2]=var[1];
-       r = a&07; a &= 070;
-
-       printf(s);
-       IF r==7 ANDF a&020
-       THEN IF a&010 THEN printc('*'); FI
-            IF a&040
-            THEN IF space==NSP
-                 THEN printc('?');
-                 ELSE  var[1]=chkget(inkdot(incp),space) + shorten(inkdot(incp+2));
-                      psymoff(var[1],(a&010?DSYM:type),"");
-                 FI
-            ELSE printc('$');
-                 IF space==NSP
-                 THEN printc('?');
-                 ELSE var[1]=chkget(inkdot(incp), space);
-                       psymoff(var[1], (a&010?type:NSYM), "");
-                 FI
-            FI
-            incp += 2;
-            return;
-       FI
-       r = regname[r];
-       switch (a) {
-           /* r */
-           case 000:
-               prints(r);
-               return;
-
-           /* (r) */
-           case 010:
-               printf("(%s)", r);
-               return;
-
-           /* *(r)+ */
-           case 030:
-               printc('*');
-
-           /* (r)+ */
-           case 020:
-               printf("(%s)+", r);
-               return;
-
-           /* *-(r) */
-           case 050:
-               printc('*');
-
-           /* -(r) */
-           case 040:
-               printf("-(%s)", r);
-               return;
-
-           /* *x(r) */
-           case 070:
-               printc('*');
-
-           /* x(r) */
-           case 060:
-               IF space==NSP
-               THEN printc('?');
-               ELSE    var[1]=chkget(inkdot(incp), space);
-                       psymoff(var[1], (a==070?type:NSYM), "");
-               FI
-               incp += 2;
-               printf("(%s)", r);
-               return;
+       short i,b,mode; char **r; long d; char *fmat;
+       REG char *      ap;
+       REG OPTAB       ip;
+#ifndef vax
+       struct {char b2,b3,b0,b1;};
+#else
+       struct {char b0,b1,b2,b3;};
+#endif
+
+       type=DSYM; space=idsp;
+       ins &= LOBYTE;
+       ip=optab+ioptab[ins]; printf("%s%8t",ip->iname); incp=1;
+       ap=ip->argtype;
+       for (i=0; i<ip->nargs; i++,ap++) {
+               var[i]=0x80000000;
+               if (i!=0) printc(',');
+         top:
+               if (*ap&ACCB) b= 0xAF + ((*ap&7)<<5);  /* branch displacement */
+               else {b=bchkget(inkdot(incp),idsp); ++incp;}
+               if (b&0300) {/* not short literal */
+                       r= &regname[b&0xF]; mode= b >>= 4;
+                 mid:
+                       switch ((int)mode) {
+                               case 4: /* [r] */ printf("[%s]",*r); goto top;
+                               case 5: /* r */ printf("%s",*r); break;
+                               case 7: /* -(r) */ printc('-');
+                         base:
+                               case 6: /* (r) */ printf("(%s)",*r); break;
+                               case 9: /* *(r)+ */ printc('*');
+                               case 8: /* (r)+ */
+                                 if (r==(regname+0xF)) {/* PC: immediate or absolute */
+                                       printc('$'); if (b==9) goto abs;
+                                       mode=((*ap&7)<<1)+0xA; goto mid;
+                                 }
+                                 printf("(%s)+",*r); break;
+                               case 0xB: printc('*');
+                               case 0xA: d=bchkget(inkdot(incp),idsp); ++incp;
+                                 if (d&0x80) d -= 0x100; fmat=fmtr;
+                         disp:
+                                 var[i]=d;
+                                 if (r==(regname+0xF) && b>=0xA) var[i] += dot+incp;
+                                 psymoff(var[i],type,"");
+                                 if (r!=regname+0xF) goto base;
+                                 break;
+                               case 0xD: printc('*');
+                               case 0xC: d=0;
+                                       d.b0 = bchkget(inkdot(incp),idsp); ++incp;
+                                       d.b1 = bchkget(inkdot(incp),idsp); ++incp;
+                                       if (d&0x8000) d -= 0x10000; fmat=fmtr;
+                                       goto disp;
+                               case 0xF: printc('*');
+                               case 0xE:
+                         abs:
+                                       d.b0 = bchkget(inkdot(incp),idsp); ++incp;
+                                       d.b1 = bchkget(inkdot(incp),idsp); ++incp;
+                                       d.b2 = bchkget(inkdot(incp),idsp); ++incp;
+                                       d.b3 = bchkget(inkdot(incp),idsp); ++incp;
+                                       fmat=fmtR; goto disp;
+                       }
+               } else {/* short literal */
+                       var[i]=b;
+                       if ((*ap&7)==TYPF || (*ap&7)==TYPD) printf("$%s",fltimm[b]);
+                       else printf("$%r",b);
+               }
        }
        }
+       if (ins==0xCF || ins==0xAF || ins==0x8F) {/* CASEx instr */
+               for (i=0; i<=var[2]; ++i) {
+                       printc(EOR); printf("    %R:  ",i+var[1]);
+                       d=get(inkdot(incp+i+i),idsp)&0xFFFF;
+                       if (d&0x8000) d -= 0x10000;
+                       psymoff(inkdot(incp)+d,type,"");
+               }
+               incp += var[2]+var[2]+2;
+       }
+       dotinc=incp;
 }
 }
-
-
-
diff --git a/usr/src/cmd/adb/optab.c b/usr/src/cmd/adb/optab.c
new file mode 100644 (file)
index 0000000..60b663e
--- /dev/null
@@ -0,0 +1,120 @@
+#include "defs.h"
+SCCSID(@(#)optab.c     2.2);
+/*
+ * Argument access types
+ */
+#define ACCA   (8<<3)  /* address only */
+#define ACCR   (1<<3)  /* read */
+#define ACCW   (2<<3)  /* write */
+#define ACCM   (3<<3)  /* modify */
+#define ACCB   (4<<3)  /* branch displacement */
+#define ACCI   (5<<3)  /* XFC code */
+
+/*
+ * Argument data types
+ */
+#define TYPB   0       /* byte */
+#define TYPW   1       /* word */
+#define TYPL   2       /* long */
+#define TYPQ   3       /* quad */
+#define TYPF   4       /* floating */
+#define TYPD   5       /* double floating */
+
+
+TYPE   struct optab    *OPTAB;
+struct optab {
+       char *iname;
+       char val;
+       char nargs;
+       char argtype[6];
+} optab[] = {
+#define OP(a,b,c,d,e,f,g,h,i) {a,b,c,d,e,f,g,h,i}
+#include "../as/instrs"
+0};
+
+#define SYSTAB struct systab
+SYSTAB {
+       int     argc;
+       char    *sname;
+} systab[] = {
+       1, "indir",
+       0, "exit",
+       0, "fork",
+       2, "read",
+       2, "write",
+       2, "open",
+       0, "close",
+       0, "wait",
+       2, "creat",
+       2, "link",
+       1, "unlink",
+       2, "exec",
+       1, "chdir",
+       0, "time",
+       3, "mknod",
+       2, "chmod",
+       2, "chown",
+       1, "break",
+       2, "stat",
+       2, "seek",
+       0, "getpid",
+       3, "mount",
+       1, "umount",
+       0, "setuid",
+       0, "getuid",
+       0, "stime",
+       3, "ptrace",
+       0, "alarm",
+       1, "fstat",
+       0, "pause",
+       1, "30",
+       1, "stty",
+       1, "gtty",
+       0, "access",
+       0, "nice",
+       0, "sleep",
+       0, "sync",
+       1, "kill",
+       0, "csw",
+       0, "setpgrp",
+       0, "tell",
+       0, "dup",
+       0, "pipe",
+       1, "times",
+       4, "profil",
+       0, "tiu",
+       0, "setgid",
+       0, "getgid",
+       2, "signal",
+       0, "49",
+       0, "50",
+       0, "51",
+       0, "52",
+       0, "53",
+       0, "54",
+       0, "55",
+       0, "56",
+       0, "57",
+       0, "58",
+       0, "59",
+       0, "60",
+       0, "61",
+       0, "62",
+       0, "63",
+};
+
+STRING regname[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
+                                       "r8", "r9", "r10","r11","ap", "fp", "sp", "pc"};
+STRING fltimm[] = {
+"0.5", "0.5625", "0.625", "0.6875", "0.75", "0.8125", "0.875", "0.9375",
+"1.0", "1.125", "1.25", "1.375", "1.5", "1.625", "1.75", "1.875",
+"2.0", "2.25", "2.5", "2.75", "3.0", "3.25", "3.5", "3.75",
+"4.0", "4.5", "5.0", "5.5", "6.0", "6.5", "7.0", "7.5",
+"8.0", "9.0", "10.0", "11.0", "12.0", "13.0", "14.0", "15.0",
+"16.0", "18.0", "20.0", "22.0", "24.0", "26.0", "28.0", "30.0",
+"32.0", "36.0", "40.0", "44.0", "48.0", "52.0", "56.0", "60.0",
+"64.0", "72.0", "80.0", "88.0", "96.0", "104.0", "112.0", "120.0"
+};
+
+char *fmtr = {"%r"};
+char *fmtR = {"%R"};
index 24e4893..ca45e38 100644 (file)
@@ -6,15 +6,19 @@
  */
 
 #include "defs.h"
  */
 
 #include "defs.h"
+SCCSID(@(#)output.c    2.3);
+#include <stdio.h>
 
 
 INT            mkfault;
 INT            infile;
 
 
 INT            mkfault;
 INT            infile;
-INT            outfile 1;
-INT            maxpos;
+INT            outfile = 1;
+L_INT          maxpos;
+L_INT          maxoff;
+INT            radix = 16;
 
 CHAR           printbuf[MAXLIN];
 
 CHAR           printbuf[MAXLIN];
-CHAR           *printptr printbuf;
+CHAR           *printptr printbuf;
 CHAR           *digitptr;
 
 
 CHAR           *digitptr;
 
 
@@ -32,9 +36,9 @@ eqstr(s1, s2)
 }
 
 length(s)
 }
 
 length(s)
-       STRING          s;
+       REG STRING              s;
 {
 {
-       INT             n 0;
+       INT             n 0;
        WHILE *s++ DO n++; OD
        return(n);
 }
        WHILE *s++ DO n++; OD
        return(n);
 }
@@ -63,7 +67,11 @@ printc(c)
                FI
             OD
             *q++=EOR;
                FI
             OD
             *q++=EOR;
+#ifdef EDDT
+               printptr=printbuf; do putchar(*printptr++); while (printptr<q);
+#else
             write(outfile,printbuf,q-printbuf);
             write(outfile,printbuf,q-printbuf);
+#endif
             printptr=printbuf;
        ELIF c==TB
        THEN *printptr++=SP;
             printptr=printbuf;
        ELIF c==TB
        THEN *printptr++=SP;
@@ -97,7 +105,7 @@ printf(fmat,a1)
        L_INT           lx;
        CHAR            digits[64];
 
        L_INT           lx;
        CHAR            digits[64];
 
-       fptr = fmat; vptr = &a1;
+       fptr = fmat; dptr = vptr = &a1;
 
        WHILE c = *fptr++
        DO  IF c!='%'
 
        WHILE c = *fptr++
        DO  IF c!='%'
@@ -106,7 +114,11 @@ printf(fmat,a1)
                 width=convert(&fptr);
                 IF *fptr=='.' THEN fptr++; prec=convert(&fptr); ELSE prec = -1; FI
                 digitptr=digits;
                 width=convert(&fptr);
                 IF *fptr=='.' THEN fptr++; prec=convert(&fptr); ELSE prec = -1; FI
                 digitptr=digits;
+#ifndef vax
                 dptr=rptr=vptr; lx = *dptr; x = *vptr++;
                 dptr=rptr=vptr; lx = *dptr; x = *vptr++;
+#else
+                rptr=dptr; x = shorten(lx = *dptr++);
+#endif
                 s=0;
                 switch (c = *fptr++) {
 
                 s=0;
                 switch (c = *fptr++) {
 
@@ -114,11 +126,23 @@ printf(fmat,a1)
                    case 'u':
                        printnum(x,c,10); break;
                    case 'o':
                    case 'u':
                        printnum(x,c,10); break;
                    case 'o':
+#ifndef vax
                        printoct(0,x,0); break;
                        printoct(0,x,0); break;
+#else
+                       printoct(itol(0,x),0); break;
+#endif
                    case 'q':
                        lx=x; printoct(lx,-1); break;
                    case 'x':
                    case 'q':
                        lx=x; printoct(lx,-1); break;
                    case 'x':
+#ifndef vax
                        printdbl(0,x,c,16); break;
                        printdbl(0,x,c,16); break;
+#else
+                       printdbl(itol(0,x),c,16); break;
+#endif
+                       case 'r':
+                       printdbl(lx=x,c,radix); break;
+                       case 'R':
+                       printdbl(lx,c,radix); vptr++; break;
                    case 'Y':
                        printdate(lx); vptr++; break;
                    case 'D':
                    case 'Y':
                        printdate(lx); vptr++; break;
                    case 'D':
@@ -133,9 +157,18 @@ printf(fmat,a1)
                    case 'c':
                        printc(x); break;
                    case 's':
                    case 'c':
                        printc(x); break;
                    case 's':
+#ifndef vax
                        s=x; break;
                        s=x; break;
+#else
+                       s=lx; break;
+#endif
+#ifndef EDDT
                    case 'f':
                    case 'F':
                    case 'f':
                    case 'F':
+#ifdef vax
+                       dptr++;
+                       sprintf(s=digits,"%+.16e",*rptr,*(rptr+4)); prec= -1; break;
+#else
                        vptr += 7;
                        s=ecvt(*rptr, prec, &decpt, &n);
                        *digitptr++=(n?'-':'+');
                        vptr += 7;
                        s=ecvt(*rptr, prec, &decpt, &n);
                        *digitptr++=(n?'-':'+');
@@ -149,6 +182,8 @@ printf(fmat,a1)
                        THEN *digitptr++ = 'e'; printnum(decpt,'d',10);
                        FI
                        s=0; prec = -1; break;
                        THEN *digitptr++ = 'e'; printnum(decpt,'d',10);
                        FI
                        s=0; prec = -1; break;
+#endif
+#endif
                    case 'm':
                        vptr--; break;
                    case 'M':
                    case 'm':
                        vptr--; break;
                    case 'M':
@@ -157,14 +192,22 @@ printf(fmat,a1)
                    case 't':
                        IF c=='T'
                        THEN width=x;
                    case 't':
                        IF c=='T'
                        THEN width=x;
+#ifndef vax
                        ELSE vptr--;
                        ELSE vptr--;
+#else
+                       ELSE dptr--;
+#endif
                        FI
                        IF width
                        THEN width -= charpos()%width;
                        FI
                        break;
                    default:
                        FI
                        IF width
                        THEN width -= charpos()%width;
                        FI
                        break;
                    default:
+#ifndef vax
                        printc(c); vptr--;
                        printc(c); vptr--;
+#else
+                       printc(c); dptr--;
+#endif
                }
 
                IF s==0
                }
 
                IF s==0
@@ -189,7 +232,11 @@ printdate(tvec)
 {
        REG INT         i;
        REG STRING      timeptr;
 {
        REG INT         i;
        REG STRING      timeptr;
+#ifndef EDDT
        timeptr = ctime(&tvec);
        timeptr = ctime(&tvec);
+#else
+       timeptr="????????????????????????";
+#endif
        FOR i=20; i<24; i++ DO *digitptr++ = *(timeptr+i); OD
        FOR i=3; i<19; i++ DO *digitptr++ = *(timeptr+i); OD
 } /*printdate*/
        FOR i=20; i<24; i++ DO *digitptr++ = *(timeptr+i); OD
        FOR i=3; i<19; i++ DO *digitptr++ = *(timeptr+i); OD
 } /*printdate*/
@@ -249,7 +296,7 @@ printoct(o,s)
             FI
        FI
        FOR i=0;i<=11;i++
             FI
        FI
        FOR i=0;i<=11;i++
-       DO digs[i] = po&7; po =>> 3; OD
+       DO digs[i] = po&7; po >>= 3; OD
        digs[10] &= 03; digs[11]=0;
        FOR i=11;i>=0;i--
        DO IF digs[i] THEN break; FI OD
        digs[10] &= 03; digs[11]=0;
        FOR i=11;i>=0;i--
        DO IF digs[i] THEN break; FI OD
@@ -257,27 +304,47 @@ printoct(o,s)
        DO *digitptr++=digs[i]+'0'; OD
 }
 
        DO *digitptr++=digs[i]+'0'; OD
 }
 
+#ifndef vax
 printdbl(lx,ly,fmat,base)
 INT lx, ly; char fmat; int base;
 printdbl(lx,ly,fmat,base)
 INT lx, ly; char fmat; int base;
+#else
+printdbl(lxy,fmat,base)
+L_INT lxy; char fmat; int base;
+#endif
 {      int digs[20]; int *dptr; char k;
 {      int digs[20]; int *dptr; char k;
+#ifndef MULD2
+       register char *cp1;
+       cp1=digs; if ((lxy&0xFFFF0000L)==0xFFFF0000L) {*cp1++='-'; lxy= -lxy;}
+       sprintf(cp1,base==16 ? "%X" : "%D",lxy);
+       cp1=digs; while (*digitptr++= *cp1++); --digitptr;
+#else
        L_REAL f ,g; long q;
        L_REAL f ,g; long q;
+#ifdef vax
+       INT lx,ly;
+       ly=lxy; lx=(lxy>>16)&0xFFFF;
+#endif
        dptr=digs;
        dptr=digs;
-       IF fmat!='D'
-       THEN    f=leng(lx); f *= itol(1,0); f += leng(ly);
-               IF fmat=='x' THEN *digitptr++='#'; FI
-       ELSE    f=itol(lx,ly);
+       IF fmat=='D' ORF fmat=='r'
+       THEN    f=itol(lx,ly);
                IF f<0 THEN *digitptr++='-'; f = -f; FI
                IF f<0 THEN *digitptr++='-'; f = -f; FI
+       ELSE
+               IF lx==-1
+               THEN *digitptr++='-'; f=leng(-ly);
+               ELSE f=leng(lx); f *= itol(1,0); f += leng(ly);
+               FI
+               IF fmat=='x' THEN *digitptr++='#'; FI
        FI
        WHILE f
        DO  q=f/base; g=q;
            *dptr++ = f-g*base;
            f=q;
        OD
        FI
        WHILE f
        DO  q=f/base; g=q;
            *dptr++ = f-g*base;
            f=q;
        OD
-       IF dptr==digs THEN *dptr++=0; FI
+       IF dptr==digs ORF dptr[-1]>9 THEN *dptr++=0; FI
        WHILE dptr!=digs
        DO  k = *--dptr;
            *digitptr++ = (k+(k<=9 ? '0' : 'a'-10));
        OD
        WHILE dptr!=digs
        DO  k = *--dptr;
            *digitptr++ = (k+(k<=9 ? '0' : 'a'-10));
        OD
+#endif
 }
 
 iclose()
 }
 
 iclose()
@@ -296,7 +363,11 @@ oclose()
 
 endline()
 {
 
 endline()
 {
+#ifndef vax
        IF charpos()>=maxpos
        IF charpos()>=maxpos
+#else
+       IF maxpos<=charpos()
+#endif
        THEN printf("\n");
        FI
 }
        THEN printf("\n");
        FI
 }
index 983a4b4..275443c 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include "defs.h"
  */
 
 #include "defs.h"
+SCCSID(@(#)pcs.c       2.3);
 
 
 MSG            NOBKPT;
 
 
 MSG            NOBKPT;
@@ -19,8 +20,7 @@ BKPTR         bkpthead;
 
 CHAR           *lp;
 CHAR           lastc;
 
 CHAR           *lp;
 CHAR           lastc;
-POS            corhdr[512];
-POS            *endhdr;
+struct user u;
 
 INT            signo;
 L_INT          dot;
 
 INT            signo;
 L_INT          dot;
@@ -35,24 +35,23 @@ L_INT               loopcnt;
 subpcs(modif)
 {
        REG INT         check;
 subpcs(modif)
 {
        REG INT         check;
-       INT             execsig;
-       INT             runmode;
+       INT             execsig,runmode;
        REG BKPTR       bkptr;
        STRING          comptr;
        execsig=0; loopcnt=cntval;
 
        REG BKPTR       bkptr;
        STRING          comptr;
        execsig=0; loopcnt=cntval;
 
-       switch(modif) {
+       switch (modif) {
 
            /* delete breakpoint */
            case 'd': case 'D':
 
            /* delete breakpoint */
            case 'd': case 'D':
-               IF (bkptr=scanbkpt(shorten(dot)))
+               IF (bkptr=scanbkpt(dot))
                THEN bkptr->flag=0; return;
                ELSE error(NOBKPT);
                FI
 
            /* set breakpoint */
            case 'b': case 'B':
                THEN bkptr->flag=0; return;
                ELSE error(NOBKPT);
                FI
 
            /* set breakpoint */
            case 'b': case 'B':
-               IF (bkptr=scanbkpt(shorten(dot)))
+               IF (bkptr=scanbkpt(dot))
                THEN bkptr->flag=0;
                FI
                FOR bkptr=bkpthead; bkptr; bkptr=bkptr->nxtbkpt
                THEN bkptr->flag=0;
                FI
                FOR bkptr=bkpthead; bkptr; bkptr=bkptr->nxtbkpt
@@ -89,15 +88,14 @@ subpcs(modif)
            /* run program */
            case 'r': case 'R':
                endpcs();
            /* run program */
            case 'r': case 'R':
                endpcs();
-               setup();
-               runmode=CONTIN;
+               setup(); runmode=CONTIN;
                break;
 
            /* single step */
            case 's': case 'S':
                break;
 
            /* single step */
            case 's': case 'S':
-               runmode=SINGLE;
                IF pid
                IF pid
-               THEN execsig=getsig(signo);
+               THEN
+                       runmode=SINGLE; execsig=getsig(signo);
                ELSE setup(); loopcnt--;
                FI
                break;
                ELSE setup(); loopcnt--;
                FI
                break;
@@ -105,14 +103,13 @@ subpcs(modif)
            /* continue with optional signal */
            case 'c': case 'C': case 0:
                IF pid==0 THEN error(NOPCS); FI
            /* continue with optional signal */
            case 'c': case 'C': case 0:
                IF pid==0 THEN error(NOPCS); FI
-               runmode=CONTIN;
-               execsig=getsig(signo);
+               runmode=CONTIN; execsig=getsig(signo);
                break;
 
            default: error(BADMOD);
        }
 
                break;
 
            default: error(BADMOD);
        }
 
-       IF loopcnt>0 ANDF runpcs(runmode, execsig)
+       IF loopcnt>0 ANDF runpcs(runmode,execsig)
        THEN printf("breakpoint%16t");
        ELSE printf("stopped at%16t");
        FI
        THEN printf("breakpoint%16t");
        ELSE printf("stopped at%16t");
        FI
index e82d4bf..22be525 100644 (file)
@@ -6,6 +6,9 @@
  */
 
 #include "defs.h"
  */
 
 #include "defs.h"
+SCCSID(@(#)print.c     2.9);
+#include "a.out.h"
+struct user u;
 
 
 MSG            LONGFIL;
 
 
 MSG            LONGFIL;
@@ -18,15 +21,15 @@ MAP         txtmap;
 MAP            datmap;
 
 SYMTAB         symbol;
 MAP            datmap;
 
 SYMTAB         symbol;
-INT            lastframe;
-INT            callpc;
+ADDR           lastframe;
+ADDR           callpc;
 
 INT            infile;
 INT            outfile;
 CHAR           *lp;
 
 INT            infile;
 INT            outfile;
 CHAR           *lp;
-INT            maxoff;
-INT            maxpos;
-INT            octal;
+L_INT          maxoff;
+L_INT          maxpos;
+INT            radix;
 
 /* symbol management */
 L_INT          localval;
 
 /* symbol management */
 L_INT          localval;
@@ -34,23 +37,34 @@ L_INT               localval;
 /* breakpoints */
 BKPTR          bkpthead;
 
 /* breakpoints */
 BKPTR          bkpthead;
 
-REGLIST reglist [] {
-               "ps", ps,
-               "pc", pc,
-               "sp", sp,
-               "r5", r5,
-               "r4", r4,
-               "r3", r3,
-               "r2", r2,
-               "r1", r1,
-               "r0", r0,
+REGLIST reglist [] = {
+               "p1lr", P1LR,
+               "p1br",P1BR,
+               "p0lr", P0LR,
+               "p0br",P0BR,
+               "ksp",KSP,
+               "esp",ESP,
+               "ssp",SSP,
+               "psl", PSL,
+               "pc", PC,
+               "usp",USP,
+               "fp", FP,
+               "ap", AP,
+               "r11", R11,
+               "r10", R10,
+               "r9", R9,
+               "r8", R8,
+               "r7", R7,
+               "r6", R6,
+               "r5", R5,
+               "r4", R4,
+               "r3", R3,
+               "r2", R2,
+               "r1", R1,
+               "r0", R0,
 };
 
 };
 
-INT            frnames[] { 0, 3, 4, 5, 1, 2 };
-
 char           lastc;
 char           lastc;
-POS            corhdr[];
-POS            *endhdr;
 
 INT            fcor;
 STRING         errflg;
 
 INT            fcor;
 STRING         errflg;
@@ -67,7 +81,7 @@ INT           adrflg;
 L_INT          cntval;
 INT            cntflg;
 
 L_INT          cntval;
 INT            cntflg;
 
-STRING         signals[] {
+STRING         signals[] {
                "",
                "hangup",
                "interrupt",
                "",
                "hangup",
                "interrupt",
@@ -85,6 +99,7 @@ STRING                signals[] {
                "alarm call",
                "terminated",
 };
                "alarm call",
                "terminated",
 };
+#define MAXSIG 15
 
 
 
 
 
 
@@ -97,9 +112,9 @@ printtrace(modif)
        POS             dynam;
        REG BKPTR       bkptr;
        CHAR            hi, lo;
        POS             dynam;
        REG BKPTR       bkptr;
        CHAR            hi, lo;
-       INT             word;
+       ADDR            word;
        STRING          comptr;
        STRING          comptr;
-       L_INT           argp, frame, link;
+       ADDR            argp, frame, link;
        SYMPTR          symp;
 
        IF cntflg==0 THEN cntval = -1; FI
        SYMPTR          symp;
 
        IF cntflg==0 THEN cntval = -1; FI
@@ -129,7 +144,9 @@ printtrace(modif)
                        ELSE    outfile=open(file,1);
                                IF outfile<0
                                THEN    outfile=creat(file,0644);
                        ELSE    outfile=open(file,1);
                                IF outfile<0
                                THEN    outfile=creat(file,0644);
+#ifndef EDDT
                                ELSE    lseek(outfile,0L,2);
                                ELSE    lseek(outfile,0L,2);
+#endif
                                FI
                        FI
 
                                FI
                        FI
 
@@ -138,11 +155,12 @@ printtrace(modif)
                }
                break;
 
                }
                break;
 
-           case 'o':
-               octal = TRUE; break;
-
            case 'd':
            case 'd':
-               octal = FALSE; break;
+               if (adrflg) {
+                       if (adrval<2 || adrval>16) {printf("must have 2 <= radix <= 16"); break;}
+                       printf("radix=%d base ten",radix=adrval);
+               }
+               break;
 
            case 'q': case 'Q': case '%':
                done();
 
            case 'q': case 'Q': case '%':
                done();
@@ -181,54 +199,64 @@ printtrace(modif)
                printregs();
                return;
 
                printregs();
                return;
 
-           case 'f': case 'F':
-               printfregs(modif=='F');
-               return;
-
            case 'c': case 'C':
            case 'c': case 'C':
-               frame=(adrflg?adrval:endhdr[r5])&EVEN; lastframe=0;
-               callpc=(adrflg?get(frame+2,DSP):endhdr[pc]);
+               IF adrflg
+               THEN frame=adrval;
+                       word=get(adrval+6,DSP)&0xFFFF;
+                       IF word&0x2000
+                       THEN /* 'calls', can figure out argp */
+                               argp=adrval+20+((word>>14)&3); word &= 0xFFF;
+                               WHILE word DO IF word&1 THEN argp+=4; FI word>>=1; OD
+                       ELSE /* 'callg', can't tell where argp is */ argp=frame;
+                       FI
+                       callpc=get(frame+16,DSP);
+               ELSE argp= *(ADDR *)(((ADDR)&u)+AP);
+                       frame= *(ADDR *)(((ADDR)&u)+FP);
+                       callpc= *(ADDR *)(((ADDR)&u)+PC);
+               FI
+               lastframe=0;
                WHILE cntval--
                DO      chkerr();
                WHILE cntval--
                DO      chkerr();
-                       narg = findroutine(frame);
-                       printf("%.8s(", symbol.symc);
-                       argp = frame+4;
-                       IF --narg >= 0
-                       THEN    printf("%o", get(argp, DSP));
-                       FI
-                       WHILE --narg >= 0
-                       DO      argp += 2;
-                               printf(",%o", get(argp, DSP));
-                       OD
+                       printf("%.8s(", findsym(callpc,ISYM)==-1 ? "?":symbol.symc);
+                       narg = get(argp,DSP); IF narg&~0xFF THEN narg=0; FI
+                       LOOP IF narg==0 THEN break; FI
+                               printf("%R", get(argp += 4, DSP));
+                               IF --narg!=0 THEN printc(','); FI
+                       POOL
                        prints(")\n");
 
                        IF modif=='C'
                        prints(")\n");
 
                        IF modif=='C'
-                       THEN WHILE localsym(frame)
+                       THEN WHILE localsym(frame,argp)
                             DO word=get(localval,DSP);
                                printf("%8t%.8s:%10t", symbol.symc);
                             DO word=get(localval,DSP);
                                printf("%8t%.8s:%10t", symbol.symc);
-                               IF errflg THEN prints("?\n"); errflg=0; ELSE printf("%o\n",word); FI
+                               IF errflg THEN prints("?\n"); errflg=0; ELSE printf("%R\n",word); FI
                             OD
                        FI
 
                             OD
                        FI
 
+                       callpc=get(frame+16, DSP);
+                       argp=get(frame+8, DSP);
                        lastframe=frame;
                        lastframe=frame;
-                       frame=get(frame, DSP)&EVEN;
-                       IF frame==0 THEN break; FI
+                       frame=get(frame+12, DSP)&EVEN;
+                       IF frame==0 ORF (!adrflg ANDF (frame&0xF0000000)!=0x70000000)
+                       THEN break;
+                       FI
                OD
                break;
 
                OD
                break;
 
+#ifndef EDDT
            /*print externals*/
            case 'e': case 'E':
                symset();
            /*print externals*/
            case 'e': case 'E':
                symset();
-               WHILE (symp=symget())
+               WHILE symp=symget()
                DO chkerr();
                DO chkerr();
-                  IF (symp->symf)==043 ORF (symp->symf)==044
-                  THEN printf("%.8s:%12t%o\n", symp->symc, get(leng(symp->symv),DSP));
+                  IF symp->symf==(N_DATA|N_EXT) ORF symp->symf==(N_BSS|N_EXT)
+                  THEN printf("%.8s:%12t%R\n", symp->symc, get(symp->symv,DSP));
                   FI
                OD
                break;
 
            case 'a': case 'A':
                   FI
                OD
                break;
 
            case 'a': case 'A':
-               frame=(adrflg ? adrval : endhdr[r4]);
+               frame=(adrflg ? adrval : *(ADDR *)(((ADDR)&u)+FP));
 
                WHILE cntval--
                DO chkerr();
 
                WHILE cntval--
                DO chkerr();
@@ -265,6 +293,7 @@ printtrace(modif)
                errflg=0;
                flushbuf();
                break;
                errflg=0;
                flushbuf();
                break;
+#endif
 
            /*set default c frame*/
            /*print breakpoints*/
 
            /*set default c frame*/
            /*print breakpoints*/
@@ -291,38 +320,23 @@ STRING    s; MAP *amap;
        int file;
        file=amap->ufd;
        printf("%s%12t`%s'\n",s,(file<0 ? "-" : (file==fcor ? corfil : symfil)));
        int file;
        file=amap->ufd;
        printf("%s%12t`%s'\n",s,(file<0 ? "-" : (file==fcor ? corfil : symfil)));
-       printf("b1 = %-16Q",amap->b1);
-       printf("e1 = %-16Q",amap->e1);
-       printf("f1 = %-16Q",amap->f1);
-       printf("\nb2 = %-16Q",amap->b2);
-       printf("e2 = %-16Q",amap->e2);
-       printf("f2 = %-16Q",amap->f2);
+       printf("b1 = %-16R",amap->b1);
+       printf("e1 = %-16R",amap->e1);
+       printf("f1 = %-16R",amap->f1);
+       printf("\nb2 = %-16R",amap->b2);
+       printf("e2 = %-16R",amap->e2);
+       printf("f2 = %-16R",amap->f2);
        printc(EOR);
 }
 
        printc(EOR);
 }
 
-printfregs(longpr)
-{
-       REG i;
-       L_REAL f;
-
-       printf("fpsr    %o\n", corhdr[0].fpsr);
-       FOR i=0; i<FRMAX; i++
-       DO      IF corhdr[0].fpsr&FD ORF longpr /* long mode */
-               THEN    f = corhdr[0].Lfr[frnames[i]];
-               ELSE    f = corhdr[0].Sfr[frnames[i]];
-               FI
-               printf("fr%-8d%-32.18f\n", i, f);
-       OD
-}
-
 printregs()
 {
        REG REGPTR      p;
 printregs()
 {
        REG REGPTR      p;
-       INT             v;
+       L_INT           v;
 
 
-       FOR p=reglist; p < &reglist[9]; p++
-       DO      printf("%s%8t%o%8t", p->rname, v=endhdr[p->roffs]);
-               valpr(v,(p->roffs==pc?ISYM:DSYM));
+       FOR p=reglist; p < &reglist[24]; p++
+       DO      printf("%s%6t%R %16t", p->rname, v= *(ADDR *)(((ADDR)&u)+p->roffs));
+               valpr(v,(p->roffs==PC?ISYM:DSYM));
                printc(EOR);
        OD
        printpc();
                printc(EOR);
        OD
        printpc();
@@ -332,27 +346,38 @@ getreg(regnam)
 {
        REG REGPTR      p;
        REG STRING      regptr;
 {
        REG REGPTR      p;
        REG STRING      regptr;
+       CHAR    *olp;
        CHAR            regnxt;
        CHAR            regnxt;
-       regnxt=readchar();
-       FOR p=reglist; p<&reglist[9]; p++
+
+       olp=lp;
+       FOR p=reglist; p < &reglist[24]; p++
        DO      regptr=p->rname;
        DO      regptr=p->rname;
-               IF (regnam == *regptr++) ANDF (regnxt == *regptr)
-               THEN    return(p->roffs);
+               IF (regnam == *regptr++)
+               THEN
+                       WHILE *regptr
+                       DO IF (regnxt=readchar()) != *regptr++
+                               THEN --regptr; break;
+                               FI
+                       OD
+                       IF *regptr
+                       THEN lp=olp;
+                       ELSE return(p->roffs);
+                       FI
                FI
        OD
                FI
        OD
-       lp--;
+       lp=olp;
        return(0);
 }
 
 printpc()
 {
        return(0);
 }
 
 printpc()
 {
-       dot=endhdr[pc];
+       dot= *(ADDR *)(((ADDR)&u)+PC);
        psymoff(dot,ISYM,":%16t"); printins(0,ISP,chkget(dot,ISP));
        printc(EOR);
 }
 
 sigprint()
 {
        psymoff(dot,ISYM,":%16t"); printins(0,ISP,chkget(dot,ISP));
        printc(EOR);
 }
 
 sigprint()
 {
-       prints(signals[signo]);
+       IF (signo>=0) ANDF (signo<=MAXSIG) THEN prints(signals[signo]); FI
 }
 
 }
 
index 821554f..2219879 100644 (file)
@@ -6,6 +6,8 @@
  */
 
 #include "defs.h"
  */
 
 #include "defs.h"
+SCCSID(@(#)runpcs.c    2.7);
+struct user u;
 
 
 MSG            NOFORK;
 
 
 MSG            NOFORK;
@@ -13,8 +15,8 @@ MSG           ENDPCS;
 MSG            BADWAIT;
 
 CHAR           *lp;
 MSG            BADWAIT;
 
 CHAR           *lp;
-INT            sigint;
-INT            sigqit;
+ADDR           sigint;
+ADDR           sigqit;
 
 /* breakpoints */
 BKPTR          bkpthead;
 
 /* breakpoints */
 BKPTR          bkpthead;
@@ -22,8 +24,6 @@ BKPTR         bkpthead;
 REGLIST                reglist[];
 
 CHAR           lastc;
 REGLIST                reglist[];
 
 CHAR           lastc;
-POS            corhdr[];
-POS            *endhdr;
 
 INT            fcor;
 INT            fsym;
 
 INT            fcor;
 INT            fsym;
@@ -34,7 +34,7 @@ INT           signo;
 L_INT          dot;
 STRING         symfil;
 INT            wtflag;
 L_INT          dot;
 STRING         symfil;
 INT            wtflag;
-INT            pid;
+L_INT          pid;
 L_INT          expv;
 INT            adrflg;
 L_INT          loopcnt;
 L_INT          expv;
 INT            adrflg;
 L_INT          loopcnt;
@@ -46,47 +46,59 @@ L_INT               loopcnt;
 /* service routines for sub process control */
 
 getsig(sig)
 /* service routines for sub process control */
 
 getsig(sig)
-{      return(expr(0) ? shorten(expv) : sig);
+{      return(expr(0) ? expv : sig);
 }
 
 }
 
-INT            userpc=1;
+ADDR userpc = 1;
 
 
-runpcs(runmode, execsig)
+runpcs(runmode,execsig)
 {
        INT             rc;
        REG BKPTR       bkpt;
 {
        INT             rc;
        REG BKPTR       bkpt;
-       IF adrflg
-       THEN userpc=shorten(dot);
-       FI
-       setbp();
+       IF adrflg THEN userpc=dot; FI
        printf("%s: running\n", symfil);
 
        printf("%s: running\n", symfil);
 
-       WHILE (loopcnt--)>0
+       WHILE --loopcnt>=0
        DO
 #ifdef DEBUG
        DO
 #ifdef DEBUG
-               printf("\ncontinue %d %d\n",userpc,execsig);
+               printf("\ncontinue %x %d\n",userpc,execsig);
 #endif
 #endif
-               stty(0,&usrtty);
+               IF runmode==SINGLE
+               THEN delbp(); /* hardware handles single-stepping */
+               ELSE /* continuing from a breakpoint is hard */
+                       IF bkpt=scanbkpt(userpc)
+                       THEN execbkpt(bkpt,execsig); execsig=0;
+                       FI
+                       setbp();
+               FI
                ptrace(runmode,pid,userpc,execsig);
                ptrace(runmode,pid,userpc,execsig);
-               bpwait(); chkerr(); readregs();
-
-               /*look for bkpt*/
-               IF signo==0 ANDF (bkpt=scanbkpt(endhdr[pc]-2))
-               THEN /*stopped at bkpt*/
-                    userpc=endhdr[pc]=bkpt->loc;
-                    IF bkpt->flag==BKPTEXEC
-                       ORF ((bkpt->flag=BKPTEXEC, command(bkpt->comm,':')) ANDF --bkpt->count)
-                    THEN execbkpt(bkpt); execsig=0; loopcnt++;
-                         userpc=1;
-                    ELSE bkpt->count=bkpt->initcnt;
-                         rc=1;
-                    FI
-               ELSE rc=0; execsig=signo; userpc=1;
+               bpwait(); chkerr(); execsig=0; delbp(); readregs();
+
+               IF (signo==0) ANDF (bkpt=scanbkpt(userpc))
+               THEN /* stopped by BPT instruction */
+#ifdef DEBUG
+                       printf("\n BPT code; '%s'%o'%o'%d",
+                               bkpt->comm,bkpt->comm[0],EOR,bkpt->flag);
+#endif
+                       dot=bkpt->loc;
+                       IF bkpt->flag==BKPTEXEC
+                       ORF ((bkpt->flag=BKPTEXEC)
+                               ANDF bkpt->comm[0]!=EOR
+                               ANDF command(bkpt->comm,':')
+                               ANDF --bkpt->count)
+                       THEN execbkpt(bkpt,execsig); execsig=0; loopcnt++;
+                       ELSE bkpt->count=bkpt->initcnt; rc=1;
+                       FI
+               ELSE execsig=signo; rc=0;
                FI
        OD
        return(rc);
 }
 
                FI
        OD
        return(rc);
 }
 
+#define BPOUT 0
+#define BPIN 1
+INT bpstate = BPOUT;
+
 endpcs()
 {
        REG BKPTR       bkptr;
 endpcs()
 {
        REG BKPTR       bkptr;
@@ -98,6 +110,7 @@ endpcs()
                FI
             OD
        FI
                FI
             OD
        FI
+       bpstate=BPOUT;
 }
 
 setup()
 }
 
 setup()
@@ -116,21 +129,19 @@ setup()
                  endpcs(); error(0);
             FI
        FI
                  endpcs(); error(0);
             FI
        FI
+       bpstate=BPOUT;
 }
 
 }
 
-execbkpt(bkptr)
+execbkpt(bkptr,execsig)
 BKPTR  bkptr;
 BKPTR  bkptr;
-{      INT             bkptloc;
+{
 #ifdef DEBUG
        printf("exbkpt: %d\n",bkptr->count);
 #endif
 #ifdef DEBUG
        printf("exbkpt: %d\n",bkptr->count);
 #endif
-       bkptloc = bkptr->loc;
-       ptrace(WIUSER,pid,bkptloc,bkptr->ins);
-       stty(0,&usrtty);
-       ptrace(SINGLE,pid,bkptloc,0);
-       bpwait(); chkerr();
-       ptrace(WIUSER,pid,bkptloc,BPT);
+       delbp();
+       ptrace(SINGLE,pid,bkptr->loc,execsig);
        bkptr->flag=BKPTSET;
        bkptr->flag=BKPTSET;
+       bpwait(); chkerr(); readregs();
 }
 
 
 }
 
 
@@ -139,6 +150,7 @@ doexec()
        STRING          argl[MAXARG];
        CHAR            args[LINSIZ];
        STRING          p, *ap, filnam;
        STRING          argl[MAXARG];
        CHAR            args[LINSIZ];
        STRING          p, *ap, filnam;
+       extern STRING environ;
        ap=argl; p=args;
        *ap++=symfil;
        REP     IF rdc()==EOR THEN break; FI
        ap=argl; p=args;
        *ap++=symfil;
        REP     IF rdc()==EOR THEN break; FI
@@ -159,10 +171,11 @@ doexec()
                FI
        PER lastc!=EOR DONE
        *ap++=0;
                FI
        PER lastc!=EOR DONE
        *ap++=0;
-       execv(symfil, argl);
+       exect(symfil, argl, environ);
 }
 
 BKPTR  scanbkpt(adr)
 }
 
 BKPTR  scanbkpt(adr)
+ADDR adr;
 {
        REG BKPTR       bkptr;
        FOR bkptr=bkpthead; bkptr; bkptr=bkptr->nxtbkpt
 {
        REG BKPTR       bkptr;
        FOR bkptr=bkpthead; bkptr; bkptr=bkptr->nxtbkpt
@@ -175,44 +188,51 @@ BKPTR     scanbkpt(adr)
 
 delbp()
 {
 
 delbp()
 {
-       REG INT         a;
+       REG ADDR        a;
        REG BKPTR       bkptr;
        REG BKPTR       bkptr;
-       FOR bkptr=bkpthead; bkptr; bkptr=bkptr->nxtbkpt
-       DO IF bkptr->flag
-          THEN a=bkptr->loc;
-               ptrace(WIUSER,pid,a,bkptr->ins);
-          FI
-       OD
+       IF bpstate!=BPOUT
+       THEN
+               FOR bkptr=bkpthead; bkptr; bkptr=bkptr->nxtbkpt
+               DO      IF bkptr->flag
+                       THEN a=bkptr->loc;
+                               ptrace(WIUSER,pid,a,
+                                       (bkptr->ins&0xFF)|(ptrace(RIUSER,pid,a,0)&~0xFF));
+                       FI
+               OD
+               bpstate=BPOUT;
+       FI
 }
 
 setbp()
 {
 }
 
 setbp()
 {
-       REG INT         a;
+       REG ADDR                a;
        REG BKPTR       bkptr;
 
        REG BKPTR       bkptr;
 
-       FOR bkptr=bkpthead; bkptr; bkptr=bkptr->nxtbkpt
-       DO IF bkptr->flag
-          THEN a = bkptr->loc;
-               bkptr->ins = ptrace(RIUSER, pid, a, 0);
-               ptrace(WIUSER, pid, a, BPT);
-               IF errno
-               THEN prints("cannot set breakpoint: ");
-                    psymoff(leng(bkptr->loc),ISYM,"\n");
-               FI
-          FI
-       OD
+       IF bpstate!=BPIN
+       THEN
+               FOR bkptr=bkpthead; bkptr; bkptr=bkptr->nxtbkpt
+               DO IF bkptr->flag
+                  THEN a = bkptr->loc;
+                       bkptr->ins = ptrace(RIUSER, pid, a, 0);
+                       ptrace(WIUSER, pid, a, BPT | (bkptr->ins&~0xFF));
+                       IF errno
+                       THEN prints("cannot set breakpoint: ");
+                            psymoff(bkptr->loc,ISYM,"\n");
+                       FI
+                  FI
+               OD
+               bpstate=BPIN;
+       FI
 }
 
 bpwait()
 {
 }
 
 bpwait()
 {
-       REG INT w;
-       INT stat;
+       REG ADDR w;
+       ADDR stat;
 
        signal(SIGINT, 1);
        WHILE (w = wait(&stat))!=pid ANDF w != -1 DONE
        signal(SIGINT,sigint);
 
        signal(SIGINT, 1);
        WHILE (w = wait(&stat))!=pid ANDF w != -1 DONE
        signal(SIGINT,sigint);
-       gtty(0,&usrtty);
-       stty(0,&adbtty);
        IF w == -1
        THEN pid=0;
             errflg=BADWAIT;
        IF w == -1
        THEN pid=0;
             errflg=BADWAIT;
@@ -240,14 +260,11 @@ readregs()
 {
        /*get REG values from pcs*/
        REG i;
 {
        /*get REG values from pcs*/
        REG i;
-       FOR i=0; i<9; i++
-       DO endhdr[reglist[i].roffs] =
-                   ptrace(RUREGS, pid, 2*(512+reglist[i].roffs), 0);
+       FOR i=24; --i>=0; 
+       DO *(ADDR *)(((ADDR)&u)+reglist[i].roffs) =
+                   ptrace(RUREGS, pid, reglist[i].roffs, 0);
        OD
        OD
-
-       /* REALing poINT                */
-       FOR i=FROFF; i<FRLEN+FROFF; i++
-       DO corhdr[i] = ptrace(RUREGS,pid,i,0); OD
+       userpc= *(ADDR *)(((ADDR)&u)+PC);
 }
 
 
 }
 
 
index 8ed84a8..d2f50e1 100644 (file)
@@ -6,6 +6,8 @@
  */
 
 #include "defs.h"
  */
 
 #include "defs.h"
+#include "a.out.h"
+SCCSID(@(#)setup.c     2.5);
 
 
 MSG            BADNAM;
 
 
 MSG            BADNAM;
@@ -31,16 +33,28 @@ L_INT               entrypt;
 
 INT            argcount;
 INT            signo;
 
 INT            argcount;
 INT            signo;
-POS            corhdr[512];
-POS            *endhdr &corhdr[512];
+struct user u;
 
 
-STRING         symfil  "a.out";
-STRING         corfil  "core";
+STRING         symfil  "a.out";
+STRING         corfil  "core";
 
 #define TXTHDRSIZ      (sizeof(txthdr))
 
 
 #define TXTHDRSIZ      (sizeof(txthdr))
 
+#ifndef EDDT
+readl(f,p,n) int f,n; long * p;{
+#ifndef vax
+       int t=0;
+       do {t += read(f,&(p->loword),2); t += read(f,&(p->hiword),2); p++;} while (--n);
+       return(t);
+#else
+       return(read(f,p,n*sizeof(long)));
+#endif
+}
+#endif
+
 setsym()
 {
 setsym()
 {
+#ifndef EDDT
        INT             relflg;
        INT             symval, symflg;
        SYMSLAVE        *symptr;
        INT             relflg;
        INT             symval, symflg;
        SYMSLAVE        *symptr;
@@ -49,7 +63,7 @@ setsym()
 
        fsym=getfile(symfil,1);
        txtmap.ufd=fsym;
 
        fsym=getfile(symfil,1);
        txtmap.ufd=fsym;
-       IF read(fsym, txthdr, TXTHDRSIZ)==TXTHDRSIZ
+       IF readl(fsym, txthdr, TXTHDRSIZ/sizeof(txthdr[0]))==TXTHDRSIZ
        THEN    magic=txthdr[0];
                IF magic!=0411 ANDF magic!=0410 ANDF magic!=0407 ANDF magic!=0405
                THEN    magic=0;
        THEN    magic=txthdr[0];
                IF magic!=0411 ANDF magic!=0410 ANDF magic!=0407 ANDF magic!=0405
                THEN    magic=0;
@@ -64,8 +78,10 @@ setsym()
                        txtmap.e2=txtmap.b2+(magic==0407?symbas:datsiz);
                        txtmap.f2 = TXTHDRSIZ+(magic==0407?0:txtmap.e1);
                        entrypt=txthdr[5];
                        txtmap.e2=txtmap.b2+(magic==0407?symbas:datsiz);
                        txtmap.f2 = TXTHDRSIZ+(magic==0407?0:txtmap.e1);
                        entrypt=txthdr[5];
-                       relflg=txthdr[7];
-                       IF relflg!=1 THEN symbas =<< 1; FI
+       /*              relflg=txthdr[7];
+       /*              IF relflg!=1 THEN symbas =<< 1; FI
+       */
+                       symbas += txthdr[6]+txthdr[7];
                        symbas += TXTHDRSIZ;
 
                        /* set up symvec */
                        symbas += TXTHDRSIZ;
 
                        /* set up symvec */
@@ -75,9 +91,14 @@ setsym()
                                symptr=symvec=sbrk(sizeof (SYMSLAVE));
                        ELSE    symset();
                                WHILE (symp=symget()) ANDF errflg==0
                                symptr=symvec=sbrk(sizeof (SYMSLAVE));
                        ELSE    symset();
                                WHILE (symp=symget()) ANDF errflg==0
-                               DO  symval=symp->symv; symflg=symp->symf;
-                                   symptr->valslave=symval;
+                               DO 
+                                   symflg=symp->symf;
+                                   symptr->valslave=symp->symv;
                                    symptr->typslave=SYMTYPE(symflg);
                                    symptr->typslave=SYMTYPE(symflg);
+                                   IF (symflg & STABTYPES) != 0
+                                   THEN
+                                       symptr->typslave=XSYM;
+                                   FI
                                    symptr++;
                                OD
                        FI
                                    symptr++;
                                OD
                        FI
@@ -85,29 +106,37 @@ setsym()
                FI
        FI
        IF magic==0 THEN txtmap.e1=maxfile; FI
                FI
        FI
        IF magic==0 THEN txtmap.e1=maxfile; FI
+#endif
 }
 
 setcor()
 {
 }
 
 setcor()
 {
+#ifndef EDDT
        fcor=getfile(corfil,2);
        datmap.ufd=fcor;
        fcor=getfile(corfil,2);
        datmap.ufd=fcor;
-       IF read(fcor, corhdr, ctob(USIZE))==ctob(USIZE)
-       THEN    txtsiz = corhdr->u_tsize << 6;
-               datsiz = corhdr->u_dsize << 6;
-               stksiz = corhdr->u_ssize << 6;
+       IF read(fcor, &u, ctob(4))==ctob(4)
+          ANDF (u.u_pcb.pcb_ksp & 0xF0000000L)==0x80000000L
+          ANDF (u.u_pcb.pcb_usp & 0xF0000000L)==0x70000000L
+       THEN    signo = u.u_arg[0]&017;
+               txtsiz = ctob(u.u_tsize);
+               datsiz = ctob(u.u_dsize);
+               stksiz = ctob(u.u_ssize);
                datmap.b1 = datbas = (magic==0410?round(txtsiz,TXTRNDSIZ):0);
                datmap.e1=(magic==0407?txtsiz:datmap.b1)+datsiz;
                datmap.f1 = ctob(USIZE);
                datmap.b2 = maxstor-stksiz;
                datmap.e2 = maxstor;
                datmap.f2 = ctob(USIZE)+(magic==0410?datsiz:datmap.e1);
                datmap.b1 = datbas = (magic==0410?round(txtsiz,TXTRNDSIZ):0);
                datmap.e1=(magic==0407?txtsiz:datmap.b1)+datsiz;
                datmap.f1 = ctob(USIZE);
                datmap.b2 = maxstor-stksiz;
                datmap.e2 = maxstor;
                datmap.f2 = ctob(USIZE)+(magic==0410?datsiz:datmap.e1);
-               IF magic ANDF magic!=corhdr[0].u_exdata.ux_mag
+               signo = *(ADDR *)(((ADDR)&u)+ctob(4)-4*4);
+               IF magic ANDF magic!=u.u_exdata.ux_mag
                THEN    printf("%s\n",BADMAG);
                FI
        ELSE    datmap.e1 = maxfile;
        FI
                THEN    printf("%s\n",BADMAG);
                FI
        ELSE    datmap.e1 = maxfile;
        FI
+#endif
 }
 
 }
 
+#ifndef EDDT
 create(f)
 STRING f;
 {      int fd;
 create(f)
 STRING f;
 {      int fd;
@@ -136,3 +165,4 @@ STRING      filnam;
        FI
        return(fsym);
 }
        FI
        return(fsym);
 }
+#endif
index 0ebb0f9..32ed95d 100644 (file)
@@ -6,23 +6,25 @@
  */
 
 #include "defs.h"
  */
 
 #include "defs.h"
+SCCSID(@(#)sym.c       2.4);
+#include "a.out.h"
 
 
 MSG            BADFIL;
 
 SYMTAB         symbol;
 BOOL           localok;
 
 
 MSG            BADFIL;
 
 SYMTAB         symbol;
 BOOL           localok;
-INT            lastframe;
+ADDR           lastframe;
 SYMSLAVE               *symvec;
 SYMSLAVE               *symvec;
-POS            maxoff;
-L_INT          maxstor;
+ADDR           maxoff;
+ADDR           maxstor;
 
 /* symbol management */
 L_INT          symbas;
 L_INT          symcnt;
 L_INT          symnum;
 
 /* symbol management */
 L_INT          symbas;
 L_INT          symcnt;
 L_INT          symnum;
-L_INT          localval;
-char           symrqd -1;
+ADDR           localval;
+char           symrqd -1;
 SYMTAB         symbuf[SYMSIZ];
 SYMPTR         symnxt;
 SYMPTR         symend;
 SYMTAB         symbuf[SYMSIZ];
 SYMPTR         symnxt;
 SYMPTR         symend;
@@ -38,7 +40,9 @@ POS           findsym();
 longseek(f, a)
 L_INT a;
 {
 longseek(f, a)
 L_INT a;
 {
+#ifndef EDDT
        return(lseek(f,a,0) != -1);
        return(lseek(f,a,0) != -1);
+#endif
 }
 
 valpr(v,idsp)
 }
 
 valpr(v,idsp)
@@ -53,32 +57,31 @@ valpr(v,idsp)
        FI
 }
 
        FI
 }
 
-localsym(cframe)
-L_INT cframe;
+localsym(cframe,cargp)
+ADDR cframe,cargp;
 {
 {
+#ifndef EDDT
        INT symflg;
        INT symflg;
-       WHILE nextsym() ANDF localok
-               ANDF symbol.symc[0]!='~'
-               ANDF (symflg=symbol.symf)!=037
-       DO IF symflg>=2 ANDF symflg<=4
+       WHILE nextsym()
+               ANDF symbol.symc[0]!='_'
+               ANDF (symflg=symbol.symf)!=N_FN
+       DO IF symflg>=N_TEXT ANDF symflg<=(N_BSS|N_EXT)
           THEN localval=symbol.symv;
                return(TRUE);
           THEN localval=symbol.symv;
                return(TRUE);
-          ELIF symflg==1
-          THEN localval=leng(shorten(cframe)+symbol.symv);
-               return(TRUE);
-          ELIF symflg==20 ANDF lastframe
-          THEN localval=leng(lastframe+2*symbol.symv-10);
+          ELIF symflg==N_ABS
+          THEN localval=(symbol.symv<0 ? cframe:cargp)+symbol.symv;
                return(TRUE);
           FI
        OD
                return(TRUE);
           FI
        OD
+#endif
        return(FALSE);
 }
 psymoff(v,type,s)
 L_INT v; int type; char *s;
 {
        POS             w;
        return(FALSE);
 }
 psymoff(v,type,s)
 L_INT v; int type; char *s;
 {
        POS             w;
-       w = findsym(shorten(v),type);
-       IF w >= maxoff
+       IF (v!=0) THEN w = findsym(v,type); FI
+       IF v==0 ORF w >= maxoff ORF (shorten(v)<maxoff ANDF w!=0)
        THEN printf(LPRMODE,v);
        ELSE printf("%.8s", symbol.symc);
             IF w THEN printf(OFFMODE,w); FI
        THEN printf(LPRMODE,v);
        ELSE printf("%.8s", symbol.symc);
             IF w THEN printf(OFFMODE,w); FI
@@ -86,19 +89,26 @@ L_INT v; int type; char *s;
        printf(s);
 }
 
        printf(s);
 }
 
-POS    findsym(svalue,type)
-POS    svalue;
+POS
+findsym(svalue,type)
+L_INT  svalue;
 INT    type;
 {
        L_INT           diff, value, symval, offset;
        INT             symtyp;
 INT    type;
 {
        L_INT           diff, value, symval, offset;
        INT             symtyp;
+#ifndef EDDT
        REG SYMSLAVE    *symptr;
        SYMSLAVE        *symsav;
        REG SYMSLAVE    *symptr;
        SYMSLAVE        *symsav;
-       value=svalue; diff = 0377777L; symsav=0;
+#else
+       REG SYMPTR      *symptr;
+       SYMPTR  *symsav;
+#endif
+       value=svalue; diff = 0x7fffffffL; symsav=0;
        IF type!=NSYM ANDF (symptr=symvec)
        IF type!=NSYM ANDF (symptr=symvec)
+#ifndef EDDT
        THEN    WHILE diff ANDF (symtyp=symptr->typslave)!=ESYM
        THEN    WHILE diff ANDF (symtyp=symptr->typslave)!=ESYM
-               DO  IF symtyp==type
-                   THEN symval=leng(symptr->valslave);
+               DO  IF (type==0 ORF symtyp==type) ANDF symtyp != XSYM
+                   THEN symval=symptr->valslave;
                         IF value-symval<diff
                            ANDF value>=symval
                         THEN diff = value-symval;
                         IF value-symval<diff
                            ANDF value>=symval
                         THEN diff = value-symval;
@@ -114,15 +124,35 @@ INT       type;
                        read(fsym,&symbol,SYMTABSIZ);
                FI
        FI
                        read(fsym,&symbol,SYMTABSIZ);
                FI
        FI
-       return(shorten(diff));
+#else
+       THEN    WHILE diff ANDF symptr<symend
+               DO  IF value-symptr->symv<diff
+                           ANDF value>=symptr->symv
+                       THEN diff = value-symptr->symv;
+                           symsav=symptr;
+                   FI
+                   symptr++;
+               OD
+               IF symsav THEN cpsym(symsav,&symbol); FI
+       FI
+#endif
+       return(diff);
+}
+
+#ifdef EDDT
+cpsym(fm,to) register char *fm,*to;{
+register int i=12; do *to++= *fm++; while (--i);
 }
 }
+#endif
 
 nextsym()
 {
        IF (--symcnt)<0
        THEN    return(FALSE);
 
 nextsym()
 {
        IF (--symcnt)<0
        THEN    return(FALSE);
+#ifndef EDDT
        ELSE    return(longseek(fsym, symbas+(symnum-symcnt)*SYMTABSIZ)!=0 ANDF
                        read(fsym,&symbol,SYMTABSIZ)==SYMTABSIZ);
        ELSE    return(longseek(fsym, symbas+(symnum-symcnt)*SYMTABSIZ)!=0 ANDF
                        read(fsym,&symbol,SYMTABSIZ)==SYMTABSIZ);
+#endif
        FI
 }
 
        FI
 }
 
@@ -132,16 +162,21 @@ nextsym()
 symset()
 {
        symcnt = symnum;
 symset()
 {
        symcnt = symnum;
+#ifndef EDDT
        symnxt = symbuf;
        IF symrqd
        THEN    longseek(fsym, symbas);
                symread(); symrqd=FALSE;
        ELSE    longseek(fsym, symbas+sizeof symbuf);
        FI
        symnxt = symbuf;
        IF symrqd
        THEN    longseek(fsym, symbas);
                symread(); symrqd=FALSE;
        ELSE    longseek(fsym, symbas+sizeof symbuf);
        FI
+#else
+       symnxt=symvec;
+#endif
 }
 
 SYMPTR symget()
 {
 }
 
 SYMPTR symget()
 {
+#ifndef EDDT
        REG INT rc;
        IF symnxt >= symend
        THEN    rc=symread(); symrqd=TRUE;
        REG INT rc;
        IF symnxt >= symend
        THEN    rc=symread(); symrqd=TRUE;
@@ -149,16 +184,32 @@ SYMPTR    symget()
        FI
        IF --symcnt>0 ANDF rc==0 THEN errflg=BADFIL; FI
        return( (symcnt>=0 && rc) ? symnxt++ : 0);
        FI
        IF --symcnt>0 ANDF rc==0 THEN errflg=BADFIL; FI
        return( (symcnt>=0 && rc) ? symnxt++ : 0);
+#else
+       IF --symcnt>=0 THEN return(symnxt++); ELSE return(0); FI
+#endif
 }
 
 }
 
+#ifndef EDDT
 symread()
 {
        INT             symlen;
 symread()
 {
        INT             symlen;
-
-       IF (symlen=read(fsym,symbuf,sizeof symbuf))>=SYMTABSIZ
+#ifndef vax
+       short t;        SYMTAB *p;
+#endif
+
+       symlen=read(fsym,symbuf,sizeof symbuf);
+#ifndef vax
+       p=symbuf;
+       while ((char *)p<(char*)symbuf+symlen) {
+               t=p->symv.hiword; p->symv.hiword=p->symv.loword; p->symv.loword=t;
+               p++;
+       }
+#endif
+       IF symlen>=SYMTABSIZ
        THEN    symnxt = symbuf;
                symend = &symbuf[symlen/SYMTABSIZ];
                return(TRUE);
        ELSE    return(FALSE);
        FI
 }
        THEN    symnxt = symbuf;
                symend = &symbuf[symlen/SYMTABSIZ];
                return(TRUE);
        ELSE    return(FALSE);
        FI
 }
+#endif
diff --git a/usr/src/cmd/ar11.c b/usr/src/cmd/ar11.c
new file mode 100644 (file)
index 0000000..edde067
--- /dev/null
@@ -0,0 +1,664 @@
+
+/* ar11 - archiver for PDP-11 formatted archives */
+
+#include <signal.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#define ARMAG -155  /* 017545 */
+struct ar_hdr {
+       char ar_name[14];
+       short ar_date1;
+       short ar_date2;
+       char ar_uid;
+       char ar_gid;
+       short ar_mode;
+       short ar_size1;
+       short ar_size2;
+};
+int ar_date;
+int ar_size;
+#include <signal.h>
+struct stat    stbuf;
+struct ar_hdr  arbuf;
+union ints
+{
+       struct
+       {
+               short h1;
+               short h2;
+       };
+       int w1;
+} x;
+
+#define        SKIP    1
+#define        IODD    2
+#define        OODD    4
+#define        HEAD    8
+
+char   *man    { "mrxtdp" };
+char   *opt    { "uvnbai" };
+
+int    signum[] = {SIGHUP, SIGINT, SIGQUIT, 0};
+int    sigdone();
+int    rcmd();
+int    dcmd();
+int    xcmd();
+int    tcmd();
+int    pcmd();
+int    mcmd();
+int    (*comfun)();
+char   flg[26];
+char   **namv;
+int    namc;
+char   *arnam;
+char   *ponam;
+char   *tfnam;
+char   *tf1nam;
+char   *tf2nam;
+char   *file;
+char   name[16];
+int    af;
+int    tf;
+int    tf1;
+int    tf2;
+int    bastate;
+char   buf[512];
+
+char   *trim();
+char   *mktemp();
+char   *ctime();
+
+main(argc, argv)
+char *argv[];
+{
+       register i;
+       register char *cp;
+
+       for(i=0; signum[i]; i++)
+               if(signal(signum[i], SIG_IGN) != SIG_IGN)
+                       signal(signum[i], sigdone);
+       if(argc < 3)
+               usage();
+       cp = argv[1];
+       for(cp = argv[1]; *cp; cp++)
+       switch(*cp) {
+       case 'c':
+       case 'v':
+       case 'u':
+       case 'n':
+       case 'a':
+       case 'b':
+       case 'i':
+               flg[*cp - 'a']++;
+               continue;
+
+       case 'r':
+               setcom(rcmd);
+               continue;
+
+       case 'd':
+               setcom(dcmd);
+               continue;
+
+       case 'x':
+               setcom(xcmd);
+               continue;
+
+       case 't':
+               setcom(tcmd);
+               continue;
+
+       case 'p':
+               setcom(pcmd);
+               continue;
+
+       case 'm':
+               setcom(mcmd);
+               continue;
+
+       default:
+               fprintf(stderr, "ar11: bad option `%c'\n", *cp);
+               done(1);
+       }
+       if(flg['i'-'a'])
+               flg['b'-'a']++;
+       if(flg['a'-'a'] || flg['b'-'a']) {
+               bastate = 1;
+               ponam = trim(argv[2]);
+               argv++;
+               argc--;
+               if(argc < 3)
+                       usage();
+       }
+       arnam = argv[2];
+       namv = argv+3;
+       namc = argc-3;
+       if(comfun == 0) {
+               if(flg['u'-'a'] == 0) {
+                       fprintf(stderr, "ar11: one of [%s] must be specified\n", man);
+                       done(1);
+               }
+               setcom(rcmd);
+       }
+       (*comfun)();
+       done(notfound());
+}
+
+setcom(fun)
+int (*fun)();
+{
+
+       if(comfun != 0) {
+               fprintf(stderr, "ar11: only one of [%s] allowed\n", man);
+               done(1);
+       }
+       comfun = fun;
+}
+
+rcmd()
+{
+       register f;
+
+       init();
+       if(getaf() && flg['c'-'a']==0) {
+               fprintf(stderr, "ar11: %s does not exist\n", arnam);
+               done(1);
+       }
+       while(!getdir()) {
+               bamatch();
+               if(namc == 0 || match()) {
+                       f = stats();
+                       if(f < 0) {
+                               if(namc)
+                                       fprintf(stderr, "ar11: cannot open %s\n", file);
+                               goto cp;
+                       }
+                       if(flg['u'-'a'])
+                               if(stbuf.st_mtime <= ar_date) {
+                                       close(f);
+                                       goto cp;
+                               }
+                       mesg('r');
+                       copyfil(af, -1, IODD+SKIP);
+                       movefil(f);
+                       continue;
+               }
+       cp:
+               mesg('c');
+               copyfil(af, tf, IODD+OODD+HEAD);
+       }
+       cleanup();
+}
+
+dcmd()
+{
+
+       init();
+       if(getaf())
+               noar();
+       while(!getdir()) {
+               if(match()) {
+                       mesg('d');
+                       copyfil(af, -1, IODD+SKIP);
+                       continue;
+               }
+               mesg('c');
+               copyfil(af, tf, IODD+OODD+HEAD);
+       }
+       install();
+}
+
+xcmd()
+{
+       register f;
+
+       if(getaf())
+               noar();
+       while(!getdir()) {
+               if(namc == 0 || match()) {
+                       f = creat(file, arbuf.ar_mode & 0777);
+                       if(f < 0) {
+                               fprintf(stderr, "ar11: %s cannot create\n", file);
+                               goto sk;
+                       }
+                       mesg('x');
+                       copyfil(af, f, IODD);
+                       close(f);
+                       continue;
+               }
+       sk:
+               mesg('c');
+               copyfil(af, -1, IODD+SKIP);
+       }
+}
+
+pcmd()
+{
+
+       if(getaf())
+               noar();
+       while(!getdir()) {
+               if(namc == 0 || match()) {
+                       if(flg['v'-'a']) {
+                               printf("\n<%s>\n\n", file);
+                               fflush(stdout);
+                       }
+                       copyfil(af, 1, IODD);
+                       continue;
+               }
+               copyfil(af, -1, IODD+SKIP);
+       }
+}
+
+mcmd()
+{
+
+       init();
+       if(getaf())
+               noar();
+       tf2nam = mktemp("/tmp/v2XXXXX");
+       close(creat(tf2nam, 0600));
+       tf2 = open(tf2nam, 2);
+       if(tf2 < 0) {
+               fprintf(stderr, "ar11: cannot create third temp\n");
+               done(1);
+       }
+       while(!getdir()) {
+               bamatch();
+               if(match()) {
+                       mesg('m');
+                       copyfil(af, tf2, IODD+OODD+HEAD);
+                       continue;
+               }
+               mesg('c');
+               copyfil(af, tf, IODD+OODD+HEAD);
+       }
+       install();
+}
+
+tcmd()
+{
+
+       if(getaf())
+               noar();
+       while(!getdir()) {
+               if(namc == 0 || match()) {
+                       if(flg['v'-'a'])
+                               longt();
+                       printf("%s\n", trim(file));
+               }
+               copyfil(af, -1, IODD+SKIP);
+       }
+}
+
+init()
+{
+       static short mbuf = ARMAG;
+
+       tfnam = mktemp("/tmp/vXXXXX");
+       close(creat(tfnam, 0600));
+       tf = open(tfnam, 2);
+       if(tf < 0) {
+               fprintf(stderr, "ar11: cannot create temp file\n");
+               done(1);
+       }
+       if (write(tf, (char *)&mbuf, sizeof(short)) != sizeof(short))
+               wrerr();
+}
+
+getaf()
+{
+       short mbuf;
+
+       af = open(arnam, 0);
+       if(af < 0)
+               return(1);
+       if (read(af, (char *)&mbuf, sizeof(short)) != sizeof(short) || mbuf!=ARMAG) {
+               fprintf(stderr, "ar11: %s not in PDP-11 archive format\n", arnam);
+               done(1);
+       }
+       return(0);
+}
+
+usage()
+{
+       printf("usage: ar11 [%s][%s] archive files ...\n", opt, man);
+       done(1);
+}
+
+noar()
+{
+
+       fprintf(stderr, "ar11: %s does not exist\n", arnam);
+       done(1);
+}
+
+sigdone()
+{
+       done(100);
+}
+
+done(c)
+{
+
+       if(tfnam)
+               unlink(tfnam);
+       if(tf1nam)
+               unlink(tf1nam);
+       if(tf2nam)
+               unlink(tf2nam);
+       exit(c);
+}
+
+notfound()
+{
+       register i, n;
+
+       n = 0;
+       for(i=0; i<namc; i++)
+               if(namv[i]) {
+                       fprintf(stderr, "ar11: %s not found\n", namv[i]);
+                       n++;
+               }
+       return(n);
+}
+
+cleanup()
+{
+       register i, f;
+
+       for(i=0; i<namc; i++) {
+               file = namv[i];
+               if(file == 0)
+                       continue;
+               namv[i] = 0;
+               mesg('a');
+               f = stats();
+               if(f < 0) {
+                       fprintf(stderr, "ar11: %s cannot open\n", file);
+                       continue;
+               }
+               movefil(f);
+       }
+       install();
+}
+
+install()
+{
+       register i;
+
+       for(i=0; signum[i]; i++)
+               signal(signum[i], (int (*)())1);
+       close(af);
+       af = creat(arnam, 0666);
+       if(af < 0) {
+               fprintf(stderr, "ar11: cannot create %s\n", arnam);
+               done(1);
+       }
+       lseek(tf, 0l, 0);
+       while((i = read(tf, buf, 512)) > 0)
+               if (write(af, buf, i) != i)
+                       wrerr();
+       if(tf2nam) {
+               lseek(tf2, 0l, 0);
+               while((i = read(tf2, buf, 512)) > 0)
+                       if (write(af, buf, i) != i)
+                               wrerr();
+       }
+       if(tf1nam) {
+               lseek(tf1, 0l, 0);
+               while((i = read(tf1, buf, 512)) > 0)
+                       if (write(af, buf, i) != i)
+                               wrerr();
+       }
+}
+
+/*
+ * insert the file 'file'
+ * into the temporary file
+ */
+movefil(f)
+{
+       register char *cp;
+       register i;
+
+       cp = trim(file);
+       for(i=0; i<14; i++)
+               if(arbuf.ar_name[i] = *cp)
+                       cp++;
+       x.w1 = stbuf.st_size;
+       arbuf.ar_size1 = x.h2;
+       arbuf.ar_size2 = x.h1;
+       x.w1 = stbuf.st_mtime;
+       arbuf.ar_date1 = x.h2;
+       arbuf.ar_date2 = x.h1;
+       arbuf.ar_uid = stbuf.st_uid;
+       arbuf.ar_gid = stbuf.st_gid;
+       arbuf.ar_mode = stbuf.st_mode;
+       copyfil(f, tf, OODD+HEAD);
+       close(f);
+}
+
+stats()
+{
+       register f;
+
+       f = open(file, 0);
+       if(f < 0)
+               return(f);
+       if(fstat(f, &stbuf) < 0) {
+               close(f);
+               return(-1);
+       }
+       return(f);
+}
+
+/*
+ * copy next file
+ * size given in arbuf
+ */
+copyfil(fi, fo, flag)
+{
+       register i, o;
+       int pe;
+
+       if(flag & HEAD)
+               if (write(fo, (char *)&arbuf, sizeof arbuf) != sizeof arbuf)
+                       wrerr();
+       pe = 0;
+       while(ar_size > 0) {
+               i = o = 512;
+               if(ar_size < i) {
+                       i = o = ar_size;
+                       if(i&1) {
+                               if(flag & IODD)
+                                       i++;
+                               if(flag & OODD)
+                                       o++;
+                       }
+               }
+               if(read(fi, buf, i) != i)
+                       pe++;
+               if((flag & SKIP) == 0)
+                       if (write(fo, buf, o) != o)
+                               wrerr();
+               ar_size =- 512;
+       }
+       if(pe)
+               phserr();
+}
+
+getdir()
+{
+       register i;
+
+       i = read(af, (char *)&arbuf, sizeof arbuf);
+       if(i != sizeof arbuf) {
+               if(tf1nam) {
+                       i = tf;
+                       tf = tf1;
+                       tf1 = i;
+               }
+               return(1);
+       }
+       for(i=0; i<14; i++)
+{
+               name[i] = arbuf.ar_name[i];
+}
+       file = name;
+       ar_date = swap(&arbuf.ar_date1);
+       ar_size = swap(&arbuf.ar_size1);
+       return(0);
+}
+
+match()
+{
+       register i;
+
+       for(i=0; i<namc; i++) {
+               if(namv[i] == 0)
+                       continue;
+               if(strcmp(trim(namv[i]), file) == 0) {
+                       file = namv[i];
+                       namv[i] = 0;
+                       return(1);
+               }
+       }
+       return(0);
+}
+
+bamatch()
+{
+       register f;
+
+       switch(bastate) {
+
+       case 1:
+               if(strcmp(file, ponam) != 0)
+                       return;
+               bastate = 2;
+               if(flg['a'-'a'])
+                       return;
+
+       case 2:
+               bastate = 0;
+               tf1nam = mktemp("/tmp/v1XXXXX");
+               close(creat(tf1nam, 0600));
+               f = open(tf1nam, 2);
+               if(f < 0) {
+                       fprintf(stderr, "ar11: cannot create second temp\n");
+                       return;
+               }
+               tf1 = tf;
+               tf = f;
+       }
+}
+
+phserr()
+{
+
+       fprintf(stderr, "ar11: phase error on %s\n", file);
+}
+
+mesg(c)
+{
+
+       if(flg['v'-'a'])
+               if(c != 'c' || flg['v'-'a'] > 1)
+                       printf("%c - %s\n", c, file);
+}
+
+char *
+trim(s)
+char *s;
+{
+       register char *p1, *p2;
+
+       for(p1 = s; *p1; p1++)
+               ;
+       while(p1 > s) {
+               if(*--p1 != '/')
+                       break;
+               *p1 = 0;
+       }
+       p2 = s;
+       for(p1 = s; *p1; p1++)
+               if(*p1 == '/')
+                       p2 = p1+1;
+       return(p2);
+}
+
+#define        IFMT    060000
+#define        ISARG   01000
+#define        LARGE   010000
+#define        SUID    04000
+#define        SGID    02000
+#define        ROWN    0400
+#define        WOWN    0200
+#define        XOWN    0100
+#define        RGRP    040
+#define        WGRP    020
+#define        XGRP    010
+#define        ROTH    04
+#define        WOTH    02
+#define        XOTH    01
+#define        STXT    01000
+
+longt()
+{
+       register char *cp;
+
+       pmode();
+       printf("%3d/%1d", arbuf.ar_uid, arbuf.ar_gid);
+       printf("%7D", ar_size);
+       cp = ctime(&ar_date);
+       printf(" %-12.12s %-4.4s ", cp+4, cp+20);
+}
+
+int    m1[] { 1, ROWN, 'r', '-' };
+int    m2[] { 1, WOWN, 'w', '-' };
+int    m3[] { 2, SUID, 's', XOWN, 'x', '-' };
+int    m4[] { 1, RGRP, 'r', '-' };
+int    m5[] { 1, WGRP, 'w', '-' };
+int    m6[] { 2, SGID, 's', XGRP, 'x', '-' };
+int    m7[] { 1, ROTH, 'r', '-' };
+int    m8[] { 1, WOTH, 'w', '-' };
+int    m9[] { 2, STXT, 't', XOTH, 'x', '-' };
+
+int    *m[] { m1, m2, m3, m4, m5, m6, m7, m8, m9};
+
+pmode()
+{
+       register int **mp;
+
+       for (mp = &m[0]; mp < &m[9];)
+               select(*mp++);
+}
+
+select(pairp)
+int *pairp;
+{
+       register int n, *ap;
+
+       ap = pairp;
+       n = *ap++;
+       while (--n>=0 && (arbuf.ar_mode&*ap++)==0)
+               ap++;
+       putchar(*ap);
+}
+
+wrerr()
+{
+       perror("ar write error");
+       done(1);
+}
+
+swap(word)
+short *word;
+{
+       x.h1 = word->h2;
+       x.h2 = word->h1;
+       
+       return(x.w1);
+}
diff --git a/usr/src/cmd/args.c b/usr/src/cmd/args.c
new file mode 100644 (file)
index 0000000..a519ef9
--- /dev/null
@@ -0,0 +1,25 @@
+main(argc, argv)
+int argc;
+char *argv[];
+{
+       register int i;
+       register char *cp;
+
+       argc--;
+       for(i=1; i<=argc; i++) {
+               printf("%d:     ",i);
+               for(cp=argv[i]; *cp ; ++cp) {
+                       if (*cp&0200) putchar('@');
+                       *cp &= 0177;
+                       if (*cp=='@') putchar('@');
+                       putchar(*cp);
+               }
+               printf("\n");
+       }
+       exit(0);
+}
+
+putchar(c)
+{
+       write(1,&c,1);
+}
diff --git a/usr/src/cmd/arithmetic.c b/usr/src/cmd/arithmetic.c
new file mode 100644 (file)
index 0000000..f369918
--- /dev/null
@@ -0,0 +1,215 @@
+#include <stdio.h>
+#include <signal.h>
+#define        MAX     100
+
+char   types[10];
+int    right[MAX];
+int    left[MAX];
+int    rights;
+int    wrongs;
+long   stvec;
+long   etvec;
+long   dtvec;
+
+main(argc,argv)
+char   *argv[];
+{
+       int range, k, dif, l;
+       char line[100];
+       int ans,pans,i,j,t;
+       char    dir,sense;
+       extern  delete();
+
+       signal(SIGINT, delete);
+
+       range = 11;
+       dif = 0;
+       while(argc > 1) {
+               switch(*argv[1]) {
+               case '+':
+               case '-':
+               case 'x':
+               case '/':
+                       while(types[dif] = argv[1][dif])
+                               dif++;
+                       break;
+
+               default:
+                       range = getnum(argv[1]) + 1;
+               }
+               argv++;
+               argc--;
+       }
+       if(range > MAX) {
+               printf("Range is too large.\n");
+               exit();
+       }
+
+       if(dif == 0) {
+               types[0] = '+';
+               types[1] = '-';
+               dif = 2;
+       }
+
+       for(i = 0; i < range; i++) {
+               left[i] = right[i] = i;
+       }
+       time(&stvec);
+       k = stvec;
+       srand(k);
+       k = 0;
+       l = 0;
+       goto start;
+
+loop:
+       if(++k%20 == 0)
+               score();
+
+start:
+       i = skrand(range);
+       j = skrand(range);
+       if(dif > 1)
+               l = random(dif);
+
+       switch(types[l]) {
+               case '+':
+               default:
+                       ans = left[i] + right[j];
+                       printf("%d + %d =   ", left[i], right[j]);
+                       break;
+
+               case '-':
+                       t = left[i] + right[j];
+                       ans = left[i];
+                       printf("%d - %d =   ", t, right[j]);
+                       break;
+
+               case 'x':
+                       ans = left[i] * right[j];
+                       printf("%d x %d =   ", left[i], right[j]);
+                       break;
+
+               case '/':
+                       while(right[j] == 0)
+                               j = random(range);
+                       t = left[i] * right[j] + random(right[j]);
+                       ans = left[i];
+                       printf("%d / %d =   ", t, right[j]);
+                       break;
+       }
+
+
+loop1:
+       getline(line);
+       dtvec += etvec - stvec;
+       if(line[0]=='\n') goto loop1;
+       pans = getnum(line);
+       if(pans == ans) {
+               printf("Right!\n");
+               rights++;
+               goto loop;
+       }
+       else {
+               printf("What?\n");
+               wrongs++;
+               if(range >= MAX)        goto loop1;
+               left[range] = left[i];
+               right[range++] = right[j];
+               goto loop1;
+       }
+}
+
+getline(s)
+char *s;
+{
+       register char   *rs;
+
+       rs = s;
+
+       while((*rs = getchar()) == ' ');
+       while(*rs != '\n')
+               if(*rs == 0)
+                       exit();
+               else if(rs >= &s[99]) {
+                       while((*rs = getchar()) != '\n')
+                               if(*rs == '\0') exit();
+               }
+               else
+                       *++rs = getchar();
+       while(*--rs == ' ')
+               *rs = '\n';
+}
+
+getnum(s)
+char *s;
+{
+       int     a;
+       char    c;
+
+       a = 0;
+       while((c = *s++) >= '0' && c <= '9') {
+               a = a*10 + c - '0';
+       }
+       return(a);
+}
+
+int arand;
+
+srand(n)
+{
+       arand = n&077774 | 01;
+}
+
+rand()         /*uniform on 0 to 2**13-1*/
+{
+
+       arand *= 3125;
+       arand &= 077777;
+       return(arand/4);
+}
+
+random(range)
+{
+       return(hmul(rand(), 8*range));
+}
+
+skrand(range){
+int temp;
+       temp = rand() + rand();
+       if(temp >017777) temp = 040000 - temp;
+       return(hmul(temp,8*range));
+       }
+
+/* 'hmul' returns the upper 16 bits of the product, where the operands
+   are assumed to be 16-bit integers. It replaces an old PDP-11 
+   assembler language subroutine. -- dks.
+*/
+hmul(a,b) { return(a*b >> 16); }
+score()
+{
+       time(&etvec);
+
+       printf("\n\nRights %d; Wrongs %d; Score %d%%\n", rights, wrongs,
+               (rights * 100)/(rights + wrongs));
+
+       if(rights == 0) return;
+       printf("Total time %ld seconds; %.1f seconds per problem\n\n\n",
+               etvec - stvec,
+               (etvec - stvec) / (rights + 0.));
+
+       sleep(3);
+       time(&dtvec);
+       stvec += dtvec - etvec;
+       return(0);
+}
+
+delete()
+{
+       if(rights + wrongs == 0.) {
+               printf("\n");
+               exit();
+       }
+       score();
+       exit();
+}
+
diff --git a/usr/src/cmd/as/:rofix b/usr/src/cmd/as/:rofix
new file mode 100755 (executable)
index 0000000..38e6a92
--- /dev/null
@@ -0,0 +1,5 @@
+ed $1 <<!
+g/^[   ]*\.data/s//.text/
+w
+q
+!
diff --git a/usr/src/cmd/as/:yyfix b/usr/src/cmd/as/:yyfix
new file mode 100755 (executable)
index 0000000..ba93187
--- /dev/null
@@ -0,0 +1,12 @@
+for i in $*
+do ed y.tab.c <<!
+/^\(.*\)$i[    ]*\[]/s//extern \1 $i[];\\
+\1 $i []/
+.ka
+/}/kb
+'a,'b W rodata.c
+'a,'bd
+w
+q
+!
+done
diff --git a/usr/src/cmd/as/Makefile b/usr/src/cmd/as/Makefile
new file mode 100644 (file)
index 0000000..79fbf2c
--- /dev/null
@@ -0,0 +1,37 @@
+DESTDIR = 
+CFLAGS=-O
+AS=/bin/as
+as :   as0.o as1.o as2.o as3.o rodata.o
+       $(CC) -o as as?.o rodata.o
+
+as0.o :        as.h as0.c
+as1.o :        as.h as1.c
+as2.o :        as.h as2.c
+
+as3.o :        as.h as.yh as3.c instrs
+       $(CC) $(CFLAGS) -S as3.c
+       :rofix as3.s
+       $(AS) -o as3.o as3.s
+
+mon.o :        /usr/lib/mon.c
+       $(CC) -c -p -DMASTER='"/usr/lib/as.monsum"' -DINCREMENT='"/tmp/asXXXXX"' /usr/lib/mon.c
+
+as.yh rodata.o :       as0.c
+
+as0.c :        as0.y
+       yacc -d as0.y
+       mv y.tab.h as.yh
+       rm -f rodata.c
+       :yyfix yyexca yyact yypact yypgo yyr1 yyr2 yychk yydef
+       mv y.tab.c as0.c 
+       $(CC) $(CFLAGS) -S rodata.c
+       :rofix rodata.s
+       $(AS) -o rodata.o rodata.s
+
+
+clean :
+       rm -f *.o as0.c as?.s as.yh rodata.[cso] 
+
+install :
+       install -s as $(DESTDIR)/bin
+
diff --git a/usr/src/cmd/as/as.h b/usr/src/cmd/as/as.h
new file mode 100644 (file)
index 0000000..6a177c8
--- /dev/null
@@ -0,0 +1,168 @@
+#
+/* %Z%%M% %R%.%L% %D% %T% */
+#define readonly
+#define        NINST   300
+#define        NSYM    3000
+#define        NHASH   (NSYM+1)
+#define        NLOC    4               /* number of location ctrs */
+#define        NCPS    8
+
+/*
+ * Symbol types
+ */
+#define        XUNDEF  0x0
+#define        XABS    0x2
+#define        XTEXT   0x4
+#define        XDATA   0x6
+#define        XBSS    0x8
+#define        XDATAO  0xA
+#define        XBSSO   0xC
+#define        XTEXTO  0xE
+#define        XABSO   0x10
+#define        XUNDEFO 0x12
+
+#define        XTXRN   0xA
+#define        XXTRN   0x1
+#define        XTYPE   0x1E
+
+#define        XFORW   0x20    /* Was forward-referenced when undefined */
+
+#define        ERR     (-1)
+#define        NBPW    32
+
+#define        AMASK   017
+
+/*
+ * Actual argument syntax types
+ */
+#define AREG   1       /* %r */
+#define ABASE  2       /* (%r) */
+#define ADECR  3       /* -(%r) */
+#define AINCR  4       /* (%r)+ */
+#define ADISP  5       /* expr(%r) */
+#define AEXP   6       /* expr */
+#define AIMM   7       /* $ expr */
+#define ASTAR  8       /* * */
+#define AINDX  16      /* [%r] */
+
+/*
+ * Argument access types
+ */
+#define ACCA   (8<<3)  /* address only */
+#define ACCR   (1<<3)  /* read */
+#define ACCW   (2<<3)  /* write */
+#define ACCM   (3<<3)  /* modify */
+#define ACCB   (4<<3)  /* branch displacement */
+#define ACCI   (5<<3)  /* XFC code */
+
+/*
+ * Argument data types
+ */
+#define TYPB   0       /* byte */
+#define TYPW   1       /* word */
+#define TYPL   2       /* long */
+#define TYPQ   3       /* quad */
+#define TYPF   4       /* floating */
+#define TYPD   5       /* double floating */
+
+#define TYPMASK 7
+
+/* reference types for loader */
+#define PCREL 1
+#define LEN1 2
+#define LEN2 4
+#define LEN4 6
+#define LEN8 8
+
+#define        TMPC    7
+#define        HW      01
+#define        FW      03
+#define        DW      07
+
+#define        PAGRND  0x1FFL
+
+#define        round(x,y)      (((x)+(y)) & ~(y))
+
+#define        STABTYPS        0340
+
+struct symtab {
+       char    name[NCPS];
+       char    type;
+       char    tag;
+       short   index;
+       long    value;
+       char    ptype;
+       char    other;
+       short   desc;
+};
+
+struct instab {
+       char    name[NCPS];
+       char    opcode; /* must have same offset as symtab.type */
+       char    tag;    /* yacc-coded nargs (INST0, ...) or token # (IALIGN, ...) */
+       char    nargs;
+       char    argtyp[6];
+};
+
+struct arg {
+       char    atype;
+       char    areg1;
+       char    areg2;
+       struct  exp *xp;
+};
+
+struct exp {
+       char    xtype;
+       char    xloc;
+       long    xvalue;
+       long    yvalue;         /* 2nd half of double floating */
+       struct  symtab *xname;
+};
+
+struct hdr {
+       long    magic;
+       long    tsize;
+       long    dsize;
+       long    bsize;
+       long    ssize;
+       long    entry;
+       long    trsize;
+       long    drsize;
+};
+
+struct symtab  *symtab;
+struct symtab  *hshtab[NHASH];
+struct arg     arglist[6];
+struct exp     explist[20];
+extern int     lineno;
+extern int     hshused;
+extern int     usrname;
+extern int lclname;
+extern struct  symtab *nextsym;
+extern struct  exp     usedot[NLOC+NLOC];
+extern FILE    *usefile[NLOC+NLOC];
+extern FILE    *rusefile[NLOC+NLOC];
+extern char    *tmpn2;
+extern char    *tmpn3;
+extern struct  exp     *dotp;
+extern int     loctr;
+extern long    tsize;
+extern long    dsize;
+extern long    datbase;
+extern int     bitoff;
+extern long    bitfield;
+extern char    yytext[NCPS+2];
+extern FILE    *txtfil;
+extern FILE    *tmpfil;
+extern FILE    *relfil;
+extern int     passno;
+extern int     argcnt;
+extern int     anyerrs;
+extern int     *brptr;
+struct instab  *itab[NINST];
+struct instab  instab[];
+int    curlen;
+int    gindex;
+int    orgwarn;
+struct symtab  **lookup();
+struct exp     *combine();
diff --git a/usr/src/cmd/as/as0.y b/usr/src/cmd/as/as0.y
new file mode 100644 (file)
index 0000000..3eafbd8
--- /dev/null
@@ -0,0 +1,803 @@
+%token COLON
+%token PLUS MINUS
+%token MUL DIV
+%token IOR XOR AND
+%token TILDE LSH RSH
+%token LITOP REGOP
+%token CM NL LB RB LP RP MP SEMI
+%token INT NAME REG
+%token NOCHAR SP ALPH DIG SQ SH
+%token INST0 INSTn IJXXX
+%token ISPACE IBYTE IWORD IINT ILONG
+%token IDATA IGLOBAL ISET ITEXT ICOMM ILCOMM IALIGN
+%token IFLOAT IDOUBLE IORG
+%token ISTAB
+%token ILSYM
+%token FLTNUM
+%token NOTYET
+
+%nonassoc COLON
+%left PLUS MINUS
+%left IOR XOR AND
+%left MUL DIV LSH RSH TILDE
+
+%{
+#include <stdio.h>
+#include "as.h"
+#include "as.yh"
+static char AS0[]="@(#)as0.y 1.16 79/03/21 22:27:23"; /* SCCS id */
+struct arg *ap = { arglist};
+struct exp     *xp = { explist};
+int    i, ii;
+long   li;
+struct exp     usedot[];
+struct exp     *dotp = &usedot[0];
+int    anyerrs;
+int argcnt;
+int    passno  = 1;
+FILE   *tmpfil;
+FILE   *relfil;
+FILE   *txtfil;
+int    hshused;
+long   tsize;
+long   dsize;
+long   bitfield;
+int    bitoff;
+int    usrname;
+int lclname;
+struct symtab *lastnam;
+char   yytext[NCPS+2];
+char   sname[8];
+struct symtab  *stpt;
+%}
+
+%%
+
+%{
+       struct exp *pval;
+%}
+
+wholefile: file = {
+               curlen = NBPW/4;
+               flushfield(NBPW/4);
+       }
+
+file:  /* empty */ = {
+               goto reset;
+       }
+       | file linstruction NL = {
+               lineno++;
+               goto reset;
+       }
+       | file linstruction SEMI = {
+               goto reset;
+       }
+       | file error NL = {
+               lineno++;
+               yyerrok;
+       reset:
+               ap = arglist; argcnt=0;
+               xp = explist;
+               usrname = 0;
+       }
+       ;
+
+labels:                /* empty */
+       | labels NAME COLON = {
+               flushfield(NBPW/4);
+               if (($2->type&XTYPE)!=XUNDEF) {
+                       if(($2->type&XTYPE)!=dotp->xtype || $2->value!=dotp->xvalue
+                        || passno==1 && $2->index != dotp->xloc)
+                               if ($2->name[0] != 'L' || $2->name[1] != 'L')
+                                       yyerror("%.8s redefined", $2->name);
+               }
+               $2->type &= ~(XTYPE|XFORW);
+               $2->type |= dotp->xtype;
+               $2->value = dotp->xvalue;
+               if (passno==1)
+                       $2->index = dotp-usedot;
+       }
+       ;
+
+linstruction:  labels instruction
+               ;
+
+instruction:
+       ISET NAME CM expr = {
+               $2->type &= (XXTRN|XFORW);
+               $2->type |= $4->xtype&(XTYPE|XFORW);
+               $2->value = $4->xvalue;
+               if (passno==1)
+                       $2->index = $4->xloc;
+               if (($4->xtype&XTYPE)==XUNDEF)
+                       yyerror("Illegal set");
+       }
+       | setlcl NAME CM expr = {
+               if ($4->xtype!=XABS) yyerror("Illegal lsym");
+               $2->value=$4->xvalue; $2->type=XABS;
+       }
+       | IGLOBAL NAME = {
+               $2->type |= XXTRN;
+       }
+       | IDATA = {
+               i = -IDATA;
+               goto chloc;
+       }
+       | IDATA expr = {
+               i = IDATA;
+               goto chloc;
+       }
+       | ITEXT = {
+               i = -ITEXT;
+               goto chloc;
+       }
+       | ITEXT expr = {
+               i = ITEXT;
+       chloc:
+               if (i < 0) {
+                       ii = 0;
+                       i = -i;
+               } else {
+                       if ($2->xtype != XABS || (ii=$2->xvalue) >= NLOC) {
+                               yyerror("illegal location counter");
+                               ii = 0;
+                       }
+               }
+               if (i == IDATA)
+                       ii += NLOC;
+               flushfield(NBPW/4);
+               dotp = &usedot[ii];
+               if (passno==2) {
+                       if (usefile[ii] == NULL) {
+                               tmpn2[TMPC] = 'a'+ii;
+                               if ((usefile[ii]=fopen(tmpn2, "w"))==NULL) {
+                                       yyerror("cannot create temp");
+                                       delexit();
+                               }
+                               tmpn3[TMPC] = 'a'+ii;
+                               if ((rusefile[ii]=fopen(tmpn3, "w"))==NULL) {
+                                       yyerror("cannot create temp");
+                                       delexit();
+                               }
+                       }
+                       txtfil = usefile[ii];
+                       relfil = rusefile[ii];
+               }
+       }
+       | IBYTE setchar explist = {
+               flushfield(NBPW/4);
+               if (bitoff)
+                       dotp->xvalue++;
+       }
+       | ILONG setlong explist = {
+               flushfield(NBPW);
+       }
+       | IINT setlong explist = {
+               flushfield(NBPW);
+       }
+       | IWORD setword explist = {
+               flushfield(NBPW/2);
+       }
+       | ISPACE expr = {
+               if ($2->xtype != XABS)
+                       yyerror("space size not absolute");
+               li = $2->xvalue;
+       ospace:
+               flushfield(NBPW/4);
+               while (--li>=0) outb(0);
+       }
+       | IORG expr = {
+               if ($2->xtype==XABS)
+                       orgwarn++;
+               else if ($2->xtype!=dotp->xtype)
+                       yyerror("Illegal 'org'");
+               li = $2->xvalue - dotp->xvalue;
+               if (li < 0)
+                       yyerror("Backwards 'org'");
+               goto ospace;
+       }
+       | ISTAB expr CM expr CM expr CM expr CM expr CM expr CM expr CM expr CM
+               expr CM expr CM expr CM expr = {
+               if (passno == 1) 
+                       if ($18->xvalue & STABTYPS) {
+                               struct symtab *p;
+                               stpt = symalloc();
+                               stpt->name[0] = $2->xvalue;
+                               stpt->name[1] = $4->xvalue;
+                               stpt->name[2] = $6->xvalue;
+                               stpt->name[3] = $8->xvalue;
+                               stpt->name[4] = $10->xvalue;
+                               stpt->name[5] = $12->xvalue;
+                               stpt->name[6] = $14->xvalue;
+                               stpt->name[7] = $16->xvalue;
+                               stpt->ptype = $18->xvalue;
+                               stpt->other = $20->xvalue;
+                               stpt->desc = $22->xvalue;
+                               p = $24->xname;
+                               if(p == NULL) {
+                                       stpt->value = $24->xvalue;
+                               }
+                               else {
+                                       stpt->value = $24->xname;
+                                       stpt->index = p->index;
+                                       stpt->type = p->type | 0200;
+/*
+printf("FORWARD REF FOR .STAB...\n");
+printf("value (xname) = %x value(value(xname) = %x\n", stpt->value, stpt->value->value);
+printf("name: %.8s\n\n", (stpt->value)->name);
+*/
+                               }
+                       }
+                       else yyerror("Invalid type in .stab");
+       }
+       | comm NAME CM expr = {
+               if ($4->xtype != XABS)
+                       yyerror("comm size not absolute");
+               if (passno==1 && ($2->type&XTYPE)!=XUNDEF)
+                       yyerror("Redefinition of %.8s", $2->name);
+               if (passno==1) {
+                       $2->value = $4->xvalue;
+                       if ($1==ICOMM)
+                               $2->type |= XXTRN;
+                       else {
+                               $2->type &= ~XTYPE;
+                               $2->type |= XBSS;
+                       }
+               }
+       }
+       | IALIGN expr = {
+               jalign($2);
+       }
+       | INST0 = {
+               insout($1, 0, 0);
+       }
+       | INSTn args = {
+               insout($1, arglist, argcnt);
+       }
+       | IJXXX args = {
+               insout($1, arglist, -argcnt);
+       }
+       | floating flist
+       |  /* empty */
+       ;
+
+comm:  ICOMM = {
+               $$ = ICOMM;
+       }
+       | ILCOMM = {
+               $$ = ILCOMM;
+       }
+       ;
+explist: /* empty */
+       | explist CM outexpr
+       | outexpr
+       ;
+
+outexpr: expr = {
+               i = curlen;
+               pval = $1;
+               flushfield(curlen);
+               goto outx;
+       }
+       | expr COLON expr = {
+               if ($1->xtype != XABS)
+                       yyerror("Width expression not absolute");
+               i = $1->xvalue;
+               pval = $3;
+               if (bitoff+i > curlen)
+                       flushfield(curlen);
+               if (i > curlen)
+                       yyerror("Expression crosses field boundary");
+       outx:
+                if ((pval->xtype&XTYPE)!=XABS) {
+                       if (bitoff) yyerror("Illegal relocation in field");
+                       i=LEN1+!PCREL;
+                       if (curlen==NBPW) i=LEN4+!PCREL; if (curlen==NBPW/2) i=LEN2+!PCREL;
+                       outrel(&pval->xvalue,i,pval->xtype,pval->xname);
+               } else {
+                       li = pval->xvalue & ((1L<<i)-1);
+                       bitfield |= li << bitoff; bitoff += i;
+               }
+               ap = arglist;
+               xp = explist;
+       }
+
+floating: IFLOAT = {
+               curlen = 4;
+       }
+       | IDOUBLE = {
+               curlen = 8;
+       }
+
+flist: /* empty */
+       | flist CM fltout
+       | fltout
+       ;
+
+fltout:        FLTNUM = {
+               dotp->xvalue += curlen;
+               if (passno==2)
+                       putflt($1, curlen);
+       }
+       ;
+
+setlcl: ILSYM = {
+               lclname=1;
+       }
+
+setchar: = {
+               curlen = NBPW/4;
+       }
+
+setlong: = {
+               curlen = NBPW;
+       }
+
+setword: = {
+               curlen = NBPW/2;
+       }
+
+args:  arg = {if(++argcnt>6) yyerror("More than 6 arguments"); ++ap;}
+       | args CM arg = {if(++argcnt>6) yyerror("More than 6 arguments"); ++ap;}
+       ;
+arg:   reg = {
+               ap->atype = AREG;
+               ap->areg1 = $1;
+       }
+       | argb1 LB reg RB = {
+               ap->atype |= AINDX;
+               ap->areg2 = $3;
+       }
+       | argb1
+       ;
+argb1: MP reg RP = {
+               ap->atype = ADECR;
+               ap->areg1 = $2;
+       }
+       | MUL argb2 = {
+               if (ap->atype == ABASE) {/* concession for *(%r) meaning *0(%r) */
+                       ap->atype = ADISP; xp->xtype = XABS; xp->xvalue = 0; xp->xloc = 0;
+                       ap->xp = xp++;
+               }
+               ap->atype |= ASTAR;
+       }
+       | argb2
+       ;
+argb2: expr = {
+               ap->atype = AEXP;
+               ap->xp = $1;
+               ap->areg1 = 0;
+       }
+       |       LP reg RP = {
+               ap->atype = ABASE;
+               ap->areg1 = $2;
+       }
+       | expr LP reg RP = {
+               ap->atype = ADISP;
+               ap->xp = $1;
+               ap->areg1 = $3;
+       }
+       | LP reg RP PLUS = {
+               ap->atype = AINCR;
+               ap->areg1 = $2;
+       }
+       | LITOP expr = {
+               ap->atype = AIMM;
+               ap->areg1 = 0;
+               ap->xp = $2;
+       }
+       ;
+
+reg:
+       REG
+       | REGOP expr = {
+               if (passno==2 && (($2->xtype&XTYPE)!=XABS || $2->xvalue<0 || $2->xvalue>=16))
+                       yyerror("Illegal register");
+               $$ = $2->xvalue;
+       };
+
+expr:  NAME = {
+               $$ = xp++;
+               $$->xtype = $1->type;
+               if (($1->type&XTYPE)==XUNDEF) {
+                       $$->xname = $1;
+                       $$->xvalue = 0;
+                       if (passno==1)
+                               $1->type |= XFORW;
+               } else {
+                       $$->xvalue = $1->value;
+                       $$->xname = NULL;
+               }
+       }
+       | INT = {
+               $$ = xp++;
+               $$->yvalue = 0;
+               $$->xtype = XABS;
+               $$->xvalue = * (long *)$1;
+               $$->xloc = 0;
+               $$->xname = NULL;
+       }
+       | FLTNUM = {
+               $$ = xp++;
+               $$->yvalue = * (((long *)$1)+1);
+               $$->xtype = XABS;
+               $$->xvalue = * (long *)$1;
+               $$->xloc = 0;
+               $$->xname = NULL;
+       }
+       | LP expr RP = {
+               $$ = $2;
+       }
+       | expr PLUS expr = {
+               goto comb;
+       }
+       | expr MINUS expr = {
+               goto comb;
+       }
+       | expr TILDE expr = {
+               goto comb;
+       }
+       | expr IOR expr = {
+               goto comb;
+       }
+       | expr XOR expr = {
+               goto comb;
+       }
+       | expr AND expr = {
+               goto comb;
+       }
+       | expr LSH expr = {
+               goto comb;
+       }
+       | expr RSH expr = {
+               goto comb;
+       }
+       | expr MUL expr = {
+               goto comb;
+       }
+       | expr DIV expr = {
+       comb:
+               $$ = combine($2, $1, $3);
+       }
+       | nothing MINUS expr = {
+               goto comb;
+       }
+       | nothing TILDE expr = {
+               goto comb;
+       }
+       | REG = {
+       sugar:
+               $$ = xp++;
+               $$->xtype = XABS;
+               $$->xvalue = $1 & 0xFF;
+               $$->xloc = 0;
+       }
+       | INST0 = {goto sugar;}
+       | INSTn = {goto sugar;}
+       ;
+
+nothing: = {
+               $$ = xp++;
+               $$->xtype = XABS;
+               $$->xvalue = 0;
+       }
+
+%%
+
+yyerror(s, a)
+char *s;
+{
+       if (anyerrs==0)
+               fprintf(stderr, "Assembler:\n");
+       anyerrs++;
+       fprintf(stderr, "line %d: ", lineno);
+       fprintf(stderr, s, a);
+       fprintf(stderr, "\n");
+       yyerrok;
+}
+
+/*
+ * Tables for combination of operands.
+ */
+
+/* table for + */
+readonly char pltab[6][6] = {
+/*     UND     ABS     TXT     DAT     BSS     EXT */
+/*UND*/        XUNDEF, XUNDEF, XUNDEF, XUNDEF, XUNDEF, XUNDEF,
+/*ABS*/        XUNDEF, XABS,   XTEXT,  XDATA,  XBSS,   XXTRN,
+/*TXT*/        XUNDEF, XTEXT,  ERR,    ERR,    ERR,    ERR,
+/*DAT*/        XUNDEF, XDATA,  ERR,    ERR,    ERR,    ERR,
+/*BSS*/        XUNDEF, XBSS,   ERR,    ERR,    ERR,    ERR,
+/*EXT*/        XUNDEF, XXTRN,  ERR,    ERR,    ERR,    ERR,
+};
+
+/* table for - */
+readonly char mintab[6][6] = {
+/*     UND     ABS     TXT     DAT     BSS     EXT */
+/*UND*/        XUNDEF, XUNDEF, XUNDEF, XUNDEF, XUNDEF, XUNDEF,
+/*ABS*/        XUNDEF, XABS,   ERR,    ERR,    ERR,    ERR,
+/*TXT*/        XUNDEF, XTEXT,  XABS,   ERR,    ERR,    ERR,
+/*DAT*/        XUNDEF, XDATA,  ERR,    XABS,   ERR,    ERR,
+/*BSS*/        XUNDEF, XBSS,   ERR,    ERR,    XABS,   ERR,
+/*EXT*/        XUNDEF, XXTRN,  ERR,    ERR,    ERR,    ERR,
+};
+
+/* table for other operators */
+readonly char othtab[6][6] = {
+/*     UND     ABS     TXT     DAT     BSS     EXT */
+/*UND*/        XUNDEF, XUNDEF, XUNDEF, XUNDEF, XUNDEF, XUNDEF,
+/*ABS*/        XUNDEF, XABS,   ERR,    ERR,    ERR,    ERR,
+/*TXT*/        XUNDEF, ERR,    ERR,    ERR,    ERR,    ERR,
+/*DAT*/        XUNDEF, ERR,    ERR,    ERR,    ERR,    ERR,
+/*BSS*/        XUNDEF, ERR,    ERR,    ERR,    ERR,    ERR,
+/*EXT*/        XUNDEF, ERR,    ERR,    ERR,    ERR,    ERR,
+};
+
+struct exp *
+combine(op, r1, r2)
+register struct exp *r1, *r2;
+{
+       register t1, t2, type, loc;
+
+       lastnam=0; /* kluge for jxxx instructions */
+       t1 = r1->xtype&XTYPE;
+       t2 = r2->xtype&XTYPE;
+       if (r1->xtype==XXTRN+XUNDEF)
+               t1 = XTXRN;
+       if (r2->xtype==XXTRN+XUNDEF)
+               t2 = XTXRN;
+       if (passno==1)
+               if (r1->xloc!=r2->xloc && t1==t2)
+                       t1 = t2 = XTXRN;        /* error on != loc ctrs */
+       t1 >>= 1;
+       t2 >>= 1;
+       switch (op) {
+
+       case PLUS:
+               r1->xvalue += r2->xvalue;
+               type = pltab[t1][t2];
+               break;
+
+       case MINUS:
+               r1->xvalue -= r2->xvalue;
+               type = mintab[t1][t2];
+               break;
+
+       case IOR:
+               r1->xvalue |= r2->xvalue;
+               goto comm;
+
+       case XOR:
+               r1->xvalue ^= r2->xvalue;
+               goto comm;
+
+       case AND:
+               r1->xvalue &= r2->xvalue;
+               goto comm;
+
+       case LSH:
+               r1->xvalue <<= r2->xvalue;
+               goto comm;
+
+       case RSH:
+               r1->xvalue >>= r2->xvalue;
+               goto comm;
+
+       case TILDE:
+               r1->xvalue |= ~ r2->xvalue;
+               goto comm;
+
+       case MUL:
+               r1->xvalue *= r2->xvalue;
+               goto comm;
+
+       case DIV:
+               if (r2->xvalue == 0)
+                       yyerror("Divide check");
+               else
+                       r1->xvalue /= r2->xvalue;
+               goto comm;
+
+       comm:
+               type = othtab[t1][t2];
+               break;
+
+       default:
+               yyerror("Internal error: unknown operator");
+       }
+       if (t2==(XTXRN>>1))
+               r1->xname = r2->xname;
+       r1->xtype = type | (r1->xtype|r2->xtype)&(XFORW|XXTRN);
+       if (type==ERR)
+               yyerror("Relocation error");
+       return(r1);
+}
+
+readonly short type[] = {
+       EOF,
+       SP,     0,      0,      0,      0,      0,      0,      0,
+       0,      SP,     NL,     0,      0,      SP,     0,      0,
+       0,      0,      0,      0,      0,      0,      0,      0,
+       0,      0,      0,      0,      0,      0,      0,      0,
+       SP,     0,      0,      SH,     LITOP,  REG,    AND,    SQ,
+       LP,     RP,     MUL,    PLUS,   CM,     MINUS,  ALPH,   DIV,
+       DIG,    DIG,    DIG,    DIG,    DIG,    DIG,    DIG,    DIG,
+       DIG,    DIG,    COLON,  SEMI,   LSH,    0,      RSH,    0,
+       0,      ALPH,   ALPH,   ALPH,   ALPH,   ALPH,   ALPH,   ALPH,
+       ALPH,   ALPH,   ALPH,   ALPH,   ALPH,   ALPH,   ALPH,   ALPH,
+       ALPH,   ALPH,   ALPH,   ALPH,   ALPH,   ALPH,   ALPH,   ALPH,
+       ALPH,   ALPH,   ALPH,   LB,     0,      RB,     XOR,    ALPH,
+       0,      ALPH,   ALPH,   ALPH,   ALPH,   ALPH,   ALPH,   ALPH,
+       ALPH,   ALPH,   ALPH,   ALPH,   ALPH,   ALPH,   ALPH,   ALPH,
+       ALPH,   ALPH,   ALPH,   ALPH,   ALPH,   ALPH,   ALPH,   ALPH,
+       ALPH,   ALPH,   ALPH,   0,      IOR,    0,      TILDE,  0,
+};
+
+yylex()
+{
+       register short val;
+       register base;
+       register char *cp;
+       struct symtab *op;
+       static long intval;
+       static double fltval;
+       char fltchr[64];
+
+       if (passno!=1) {
+               val = get2(tmpfil);
+               if (val==NAME)
+                       fread(&yylval, sizeof(yylval), 1, tmpfil);
+               else if (val==INT) {
+                       fread(&intval, sizeof(intval), 1, tmpfil);
+                       yylval = &intval;
+               } else if (val==FLTNUM) {
+                       fread(&fltval, sizeof(fltval), 1, tmpfil);
+                       yylval = &fltval;
+               } else
+                       yylval = get2(tmpfil);
+               return(val);
+       }
+loop:
+       switch(yylval = (type+1)[val = getchar()]) {
+
+       case SH:
+               while ((val = getchar()) != '\n' && val>0)
+                       ;
+               val = NL;
+               goto ret;
+
+       case SP:
+               goto loop;
+
+       case REG:
+               val = getchar();
+               if (val>='0' && val<='9') {
+                       yylval = val-'0';
+                       if (val=='1') {
+                               if ((val = getchar())>='0' && val<='5')
+                                       yylval = 10+val-'0';
+                               else
+                                       ungetc(val, stdin);
+                       }
+                       while ((val = getchar()) == '+' || val=='-' ) {
+                               if (val=='+')
+                                       yylval++;
+                               else
+                                       yylval--;
+                       }
+                       ungetc(val, stdin);
+                       val = REG;
+               } else {
+                       ungetc(val, stdin);
+                       val = REGOP;
+               }
+               goto ret;
+
+       case EOF:
+               val = 0;
+               goto ret;
+
+       case ALPH:
+               cp = yytext;
+               do {
+                       if (cp <= &yytext[NCPS])
+                               *cp++ = val;
+               } while ((type+1)[val=getchar()]==ALPH || (type+1)[val]==DIG);
+               *cp = '\0';
+               while (val=='\t' || val==' ')
+                       val = getchar();
+               ungetc(val, stdin);
+               base = 1;
+               if (val==':') {
+                       base = usrname;
+                       usrname = 1;
+               }
+               if ((op = *lookup(1))->tag) {
+                       yylval = op->type;
+                       val = op->tag+256;
+                       goto ret;
+               } else {
+                       lastnam = yylval = op;
+                       usrname = base;
+                       val = NAME;
+                       goto ret;
+               }
+
+       case DIG:
+               intval = val-'0';
+               if (val=='0') {
+                       val = getchar();
+                       if (val=='x' || val=='X') {
+                               base = 16;
+                       } else if (val=='d' || val=='D' || val=='f' || val=='F') {
+                               char *p = fltchr;
+                               double atof();
+                               while (p < &fltchr[63] && ((val=getchar())=='.'
+                                || val=='e' || val=='d' || val=='E' || val=='D'
+                                || val=='-' || val=='+' || (type+1)[val]==DIG))
+                                       *p++ = val;
+                               ungetc(val, stdin);
+                               *p++ = '\0';
+                               fltval = atof(fltchr);
+                               val = FLTNUM;
+                               goto ret;
+                       } else {
+                               ungetc(val, stdin);
+                               base = 8;
+                       }
+               } else
+                       base = 10;
+               while ((type+1)[val=getchar()]==DIG
+                   || (base==16 && (val>='a' && val<='f'||val>='A' && val<='F'))) {
+                       if (base==8)
+                               intval <<= 3;
+                       else if (base==10)
+                               intval *= 10;
+                       else
+                               intval <<= 4;
+                       if (val>='a' && val<='f')
+                               val -= 'a' - 10 - '0';
+                       else if (val>='A' && val<='F')
+                               val -= 'A' - 10 - '0';
+                       intval += val-'0';
+               }
+               ungetc(val, stdin);
+               val = INT;
+               goto ret;
+
+       case MINUS:
+               if ((val = getchar())=='(') yylval=val=MP;
+               else {ungetc(val,stdin); val=MINUS;}
+               goto ret;
+
+       case SQ:
+               if ((yylval = getchar()) == '\n')
+                       lineno++;
+               intval = yylval;
+               val = INT;
+               goto ret;
+
+       case 0:
+               yyerror("Illegal character");
+               val = NOCHAR;
+               goto ret;
+
+       default:
+               val = yylval;
+               goto ret;
+       }
+ret:
+       put2(val, tmpfil);
+       if (val==NAME)
+               fwrite(&yylval, sizeof(yylval), 1, tmpfil);
+       else if (val==INT) {
+               fwrite(&intval, sizeof(intval), 1, tmpfil);
+               yylval = &intval;
+       } else if (val==FLTNUM) {
+               fwrite(&fltval, sizeof(fltval), 1, tmpfil);
+               yylval = &fltval;
+       } else
+               put2(yylval, tmpfil);
+       return(val);
+}
+
diff --git a/usr/src/cmd/as/as1.c b/usr/src/cmd/as/as1.c
new file mode 100644 (file)
index 0000000..14b9fbb
--- /dev/null
@@ -0,0 +1,491 @@
+#
+char AS1[] = "@(#)as1.c 1.21 79/03/21 22:27:27";       /* sccs ident */
+#include <stdio.h>
+#include <signal.h>
+#include <a.out.h>
+#include "as.h"
+#include "as.yh"
+
+int    curlen;
+int    lineno  = 1;
+long   datbase;
+struct symtab *nextsym,*rovjxxx;
+char *endcore;
+struct hdr hdr = {
+       0410, 0, 0, 0, 0, 0, 0, 0,
+};
+
+#ifndef vax
+       struct {short hiword; short loword;}; /* stupid fp-11 */
+#endif
+
+writel(p,n,f) long *p; FILE *f; {
+#ifdef vax
+       fwrite(p,sizeof(*p),n,f);
+#else
+       while (n--) {
+               fwrite(&(*p).loword,2,1,f);
+               fwrite(&(*p).hiword,2,1,f);
+               p++;
+       }
+#endif
+}
+
+symwrite(p,n,f) struct symtab *p; FILE *f; {
+#ifdef vax
+       while (n--) {
+               fwrite(&(p->name[0]), sizeof(symtab[0].name), 1, f);
+               fwrite(p->ptype ? &(p->ptype) : &(p->type),
+                       sizeof(symtab[0].type), 1, f);
+               fwrite(&(p->other), sizeof(symtab[0].other), 1, f);
+               fwrite(&(p->desc), sizeof(symtab[0].desc), 1, f);
+               fwrite(&(p->value), sizeof(symtab[0].value), 1, f);
+               p++;
+       }
+#else
+       while (n--) {
+               fwrite(p,sizeof(symtab[0])-sizeof(p->value),1,f);
+               writel(&(p->value),1,f); p++;
+       }
+#endif
+}
+
+char   *tmpn1;
+char   *tmpn2;
+char   *tmpn3;
+struct exp     usedot[NLOC+NLOC];
+FILE   *usefile[NLOC+NLOC];
+FILE   *rusefile[NLOC+NLOC];
+extern char _sibuf[BUFSIZ],_sobuf[BUFSIZ];
+extern short njxxx;
+extern int d124;
+
+main(argc, argv)
+char **argv;
+{
+       int symcmp();
+       register struct instab *ip;
+       register struct symtab *sp;
+       int c;
+       long v;
+       register struct symtab **hp;
+       char *outfile = "a.out";
+       int infound = 0;
+       int delexit();
+
+       while (argc > 1) {
+               if (argv[1][0]=='-' && argv[1][1]=='o') {
+                       if (argc <3) {
+                               yyerror("-o what?");
+                               exit(1);
+                       }
+                       outfile = argv[2];
+                       argc -= 2;
+                       argv += 2;
+                       continue;
+               }
+               if (argv[1][0]=='-' && argv[1][1]=='d') {
+                       d124=argv[1][2]-'0';
+                       if (d124!=1 && d124!=2 && d124!=4) {
+                               yyerror("-d[124] only"); exit(1);
+                       }
+                       argc--; argv++; continue;
+               }
+               if (infound) {
+                       yyerror(">1 argument.");
+                       exit(1);
+               }
+               infound++;
+               if (freopen(argv[1], "r", stdin) == NULL) {
+                       yyerror("as: Can't open %s\n", argv[1]);
+                       exit(2);
+               }
+               setbuf(stdin,_sibuf);
+               argc--;
+               argv++;
+       }
+       nextsym=symtab=endcore=sbrk(0); rovjxxx= nextsym-1;
+       c = -1;
+       for (ip=instab; ip->name[0]!=0; ip++) {
+               register char *p1, *p2;
+               for (p1=ip->name,p2=yytext; p2<yytext+NCPS;)
+                       *p2++ = *p1++;
+               *p2++ = 0;
+               usrname = 0;
+               hp = lookup(0);
+               if (*hp==NULL) {
+                       *hp = ip;
+                       if (ip->tag!=(INSTn-256) && ip->tag!=(INST0-256) && ip->tag!=0)
+                               continue; /* was pseudo-op */
+/*                     c++;
+/*                     if (c>=NINST) {
+/*                             yyerror("Instruction table overflow");
+/*                             continue;
+/*                     }
+*/
+                       itab[ip->opcode&0xFF] = ip; /* given opcode, find instruction */
+               }
+       }
+       for (c=0; c<NLOC; c++) {
+               usedot[c].xtype = XTEXT;
+               usedot[c+NLOC].xtype = XDATA;
+       }
+       if (signal(SIGINT, SIG_IGN) != SIG_IGN)
+               signal(SIGINT, delexit);
+       tmpn1 = mktemp("/tmp/asXXXXX");
+       tmpfil = fopen(tmpn1, "w");
+       if (tmpfil==NULL) {
+               yyerror("Bad temp1file");
+               delexit();
+       }
+       setbuf(tmpfil,_sobuf);
+       yyparse();
+       if (anyerrs)
+               delexit();
+       jxxxfix();
+       stabfix();
+       fclose(tmpfil);
+       tmpfil = fopen(tmpn1, "r");
+       if (tmpfil==NULL) {
+               yyerror("Bad tmp1file (r)");
+               delexit();
+       }
+       setbuf(tmpfil,_sibuf);
+       /* round and assign text segment origins */
+       tsize = 0;
+       for (c=0; c<NLOC; c++) {
+               v = round(usedot[c].xvalue, FW);
+               usedot[c].xvalue = tsize;
+               tsize += v;
+       }
+       /* round and assign data segment origins */
+       datbase = round(tsize, PAGRND);
+       for (c=0; c<NLOC; c++) {
+               v = round(usedot[NLOC+c].xvalue, FW);
+               usedot[NLOC+c].xvalue = datbase+dsize;
+               dsize += v;
+       }
+       hdr.bsize = dsize;
+       /* assign final values to symbols */
+       for (sp=symtab; sp<nextsym; sp++) {
+               if ((sp->name[0]&0xFF)>=0xFE) continue; /* ignore jxxx entries */
+               if ((sp->type&XTYPE)==XUNDEF)
+                       sp->type = XXTRN+XUNDEF;
+               else if ((sp->type&XTYPE)==XDATA)
+                       sp->value += usedot[sp->index].xvalue;
+               else if ((sp->type&XTYPE)==XTEXT)
+                       sp->value += usedot[sp->index].xvalue;
+               else if ((sp->type&XTYPE)==XBSS) {
+                       long bs;
+                       bs = sp->value;
+                       sp->value = hdr.bsize + datbase;
+                       hdr.bsize += bs;
+               }
+       }
+       hdr.bsize -= dsize;
+       tmpn2 = mktemp("/tmp/aaatXXXXX");
+       txtfil = fopen(outfile, "w");
+       if (txtfil==NULL) {
+               yyerror("Cannot create %s", outfile);
+               delexit();
+       }
+       setbuf(txtfil,_sobuf);
+       usefile[0] = txtfil;
+       tmpn3 = mktemp("/tmp/abatXXXXX");
+       relfil = fopen(tmpn3, "w");
+       if (relfil==NULL) {
+               yyerror("temp file can't be opened");
+               delexit();
+       }
+       rusefile[0] = relfil;
+       hdr.tsize = tsize;
+       hdr.dsize = dsize;
+       hdr.ssize = 
+               (sizeof(symtab[0])-
+               (sizeof(symtab[0].tag)+sizeof(symtab[0].index)+
+                       sizeof(symtab[0].ptype)))*
+               (nextsym-symtab-njxxx);
+       /* hdr.trsize, hdr.drsize set by outrel */
+       writel(&hdr,8,txtfil);
+       tsize = 0;
+       dsize = 0;
+       lineno = 1;
+       dotp = &usedot[0];
+       passno = 2;
+/*
+       for (sp=symtab; sp<nextsym; sp++)
+               sp->index = 20000;
+*/
+       setindices();
+       yyparse();
+       /* round csects to FW */
+       for (c=0; c<NLOC; c++) {
+               if (usefile[c]) {
+                       txtfil=usefile[c]; dotp= &usedot[c];
+                       while (usedot[c].xvalue&FW) outb(0);
+                       if (c>0)
+                               fclose(usefile[c]);
+                       fclose(rusefile[c]);
+               }
+               if (usefile[NLOC+c]) {
+                       txtfil = usefile[NLOC+c]; dotp= &usedot[c+NLOC];
+                       relfil = rusefile[NLOC+c];
+                       while (usedot[c+NLOC].xvalue&FW) outb(0);
+                       fclose(txtfil);
+                       fclose(relfil);
+               }
+       }
+       txtfil = usefile[0];
+       /* append csect text onto text for csect 0 */
+       for (c=1; c<NLOC+NLOC; c++) {
+               register ch;
+               if (usefile[c]) {
+                       tmpn2[TMPC] = c+'a';
+                       relfil = fopen(tmpn2, "r");
+                       if (relfil==NULL) {
+                               yyerror("cannot reopen temp");
+                               continue;
+                       }
+                       while ((ch = getc(relfil))>=0)
+                               putc(ch, txtfil);
+                       fclose(relfil);
+               }
+       }
+       /* append relocation info onto text */
+       for (c=0; c<NLOC+NLOC; c++) {
+               register ch;
+               if (rusefile[c]) {
+                       tmpn3[TMPC] = c+'a';
+                       relfil = fopen(tmpn3, "r");
+                       if (relfil==NULL) {
+                               yyerror("cannot reopen temp");
+                               continue;
+                       }
+                       while ((ch = getc(relfil))>=0)
+                               putc(ch, txtfil);
+                       fclose(relfil);
+               }
+       }
+       remjxxx();
+/*
+       qsort(symtab, nextsym-symtab, sizeof(symtab[0]), symcmp);
+*/
+       for (sp=symtab; sp<nextsym; sp++) {
+               sp->type &= ~XFORW;
+               sp->index = 0;
+       }
+       symwrite(symtab, nextsym-symtab, txtfil);
+       fseek(txtfil,0L,0); /* a little half-passedness here to get rsize correct */
+       writel(&hdr,8,txtfil);
+       delete();
+       if (anyerrs==0 && orgwarn)
+               yyerror("Caution: absolute origins.\n");
+       exit(anyerrs!=0);
+}
+
+
+delexit()
+{
+       delete();
+       exit(1);
+}
+
+delete()
+{
+       register c;
+
+       if (tmpn1)
+               unlink(tmpn1);
+       for (c=0; c<NLOC+NLOC; c++) {
+               if (tmpn2) {
+                       tmpn2[TMPC] = c+'a';
+                       unlink(tmpn2);
+               }
+               if (tmpn3) {
+                       tmpn3[TMPC] = c+'a';
+                       unlink(tmpn3);
+               }
+       }
+}
+
+struct symtab *
+symalloc() {
+if((char *)++nextsym>=endcore) {
+       register int *p;
+       if(-1==sbrk(200*sizeof(*symtab)))
+               {yyerror("Memory overflow"); delexit();}
+       p=endcore += 200*sizeof(*symtab); while (p>(char *)nextsym) *--p=0;
+}
+/*if(++nextsym-symtab>NSYM) yyerror("Symbol table overflow");
+*/
+return(nextsym-1);
+}
+
+struct symtab **
+lookup(instflg)
+{
+       register int ihash; int un;
+       register struct symtab **hp;
+       register char *p1, *p2;
+       static struct symtab *local;
+
+       if (lclname!=0) {
+               lclname=0;
+               *(hp= &local) = symalloc();
+               p1=yytext; p2=(*hp)->name;
+               while (*p2++ = *p1++);
+               return(hp);
+       }
+       un = usrname;
+       usrname = 1;
+       ihash = 0;
+       p1 = yytext;
+       while (*p1) {
+               ihash += ihash + *p1++;
+       }
+       ihash &= 077777;
+       while (p1<yytext+NCPS)
+               *p1++ = 0;
+       hp = &hshtab[ihash%NHASH];
+       while (*hp) {
+               if (hp>=symtab && (*hp)->ptype) {
+                       printf("IGNORING LOOKUP %s %x %x %x\n",
+                       (*hp)->name, (*hp)->ptype, (*hp)->type, (*hp)->type & STABTYPS);
+                       goto no;
+                       }
+               p2 = (*hp)->name;
+               for (p1=yytext; p1<yytext+NCPS;)
+                       if (*p1++ != *p2++)
+                               goto no;
+/*             if (un == ((*hp)->tag==0)) */
+                       return(hp);
+       no:
+               if (++hp >= &hshtab[NHASH])
+                       hp = hshtab;
+       }
+       if(++hshused >= NHASH) {
+               yyerror("Symbol table overflow");
+               delexit();
+       }
+       if (instflg) {
+               *hp = symalloc();
+               for (p1=yytext,p2=(*hp)->name; p1<yytext+NCPS;)
+                       *p2++ = *p1++;
+       }
+       return(hp);
+}
+
+outb(val) {dotp->xvalue++; if (passno==2) fwrite(&val,1,1,txtfil);}
+
+int reflen[] = {0,0,1,1,2,2,4,4,8,8};
+
+outrel(pval,reftype,reltype,xsym)
+long *pval; register int reftype,reltype; struct symtab *xsym; {
+/* reftype: PCREL or not, plus length LEN1, LEN2, LEN4, LEN8
+/* reltype: csect ("segment") number (XTEXT, XDATA, ...) associated with 'val'
+/* xsym: symbol table pointer
+*/
+long ts; char tc;
+long tl;
+short t;
+if (passno!=2) {
+       dotp->xvalue += reflen[reftype]; return;
+}
+if (bitoff&07) yyerror("Padding error");
+reltype &= ~XFORW;
+if (reltype==XUNDEF) yyerror("Undefined reference");
+if (reltype!=XABS || reftype&PCREL) {
+       /* write the address portion of a relocation datum */
+       if (dotp>= &usedot[NLOC]) {
+               hdr.drsize += sizeof(dotp->xvalue) + 3 + sizeof tc;
+               tl=dotp->xvalue-datbase; writel(&tl,1,relfil);
+       } else {
+               hdr.trsize += sizeof(dotp->xvalue) + 3 + sizeof tc;
+               writel(&dotp->xvalue,1,relfil);
+       }
+       /* write the properties portion of a relocation datum */
+       if (reltype==XXTRN+XUNDEF) {
+               setindex(xsym);
+               ts=(xsym->index);
+               tc = (XXTRN<<3)|(reftype-LEN1);
+       } else if ((reltype&XTYPE)==XUNDEFO) {
+               setindex(xsym);
+               ts=(xsym->index);
+               tc = ((XXTRN+2)<<3)|(reftype-LEN1);
+       } else  {
+               ts=(reltype);
+               tc = (reftype-LEN1);
+       }
+       fwrite((char *)&ts, 3, 1, relfil);
+       fwrite(&tc, sizeof(tc), 1, relfil);
+}
+/* write the raw ("unrelocated") value to the text file */
+t=reflen[reftype]; dotp->xvalue += t;
+if (reftype&PCREL) *pval -= dotp->xvalue;
+#ifdef vax
+       fwrite(pval,1,t,txtfil);
+#else
+       if (t>2) {
+               fwrite(&((*pval).loword),1,2,txtfil);
+               fwrite(&((*pval).hiword),1,t-2,txtfil);
+       } else fwrite(&((*pval).loword),1,t,txtfil);
+#endif
+}
+
+setindex(xsym)
+register struct symtab *xsym;
+{
+       return;
+/*     
+       if (xsym->index == 20000)
+               xsym->index = gindex++;
+       if (gindex >= 1023)
+               yyerror("Too many external symbols");
+*/
+}
+
+flushfield(n)
+{
+       if (bitoff==0) return;
+       n=((bitoff+n-1)/n)*n;
+       while (n>0) {outb((int)bitfield); bitfield >>= 8; n -= 8;}
+       bitoff=0; bitfield=0;
+}
+
+putflt(fp, s)
+double *fp;
+{fwrite(fp,1,s,txtfil);}
+
+symcmp(p, q)
+register struct symtab *p, *q;
+{
+       if (p->index < q->index)
+               return(-1);
+       if (p->index > q->index)
+               return(1);
+       if (p->value < q->value)
+               return(-1);
+       if (p->value > q->value)
+               return(1);
+       return(0);
+}
+
+stabfix() {
+       register struct symtab *sp;
+       register struct symtab *p;
+       
+       for(sp=symtab; sp<nextsym; sp++) {
+               if(sp->ptype && (sp->type & 0200)) {
+                       p = sp->value;
+                       sp->value = p->value;
+                       sp->index = p->index;
+                       sp->type = p->type;
+/*
+printf("STABFIX: %s (old %s) to %d offsets %d %d\n", sp->name, p->name, sp->value, sp, p);
+*/
+/*
+                       sp->ptype = (sp->ptype & STABTYPS) | (p->type & N_EXT);
+*/
+               }
+       }
+}
diff --git a/usr/src/cmd/as/as11.s b/usr/src/cmd/as/as11.s
deleted file mode 100644 (file)
index a5e5ae9..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/
-/
-
-/ PDP-11 assembler pass 0
-
-       jmp     start
-go:
-       jsr     pc,assem
-       movb    pof,r0
-       sys     write; outbuf; 512.
-       jes     wrterr
-       movb    pof,r0
-       sys     close
-       movb    fbfil,r0
-       sys     close
-       tstb    errflg
-       bne     aexit
-       jsr     r5,fcreat; a.tmp3
-       mov     r0,r1
-       mov     symend,0f
-       sub     $usymtab,0f
-       sys     indir; 9f
-       jes     wrterr
-       .data
-9:     sys     write; usymtab; 0:..
-       .text
-       mov     r1,r0
-       sys     close
-       sys     exec; fpass2; 1f
-       mov     $fpass2,r0
-       jsr     r5,filerr; "?\n
-
-aexit:
-       sys     unlink; a.tmp1
-       sys     unlink; a.tmp2
-       sys     unlink; a.tmp3
-       mov     $3,r0
-       sys     exit
-.data
-1:
-       fpass2
-       globfl
-       outfl
-outfp:
-       outfile
-       a.tmp1
-       a.tmp2
-       a.tmp3
-       0
-fpass2:
-       </lib/as2\0>
-globfl:
-unglob=.+1
-       <-\0\0>
-outfl:
-       <-o\0>
-outfile:
-       <a.out\0>
-3:
-       <-g\0>
-       .even
-       .text
-
-filerr:
-       mov     r4,-(sp)
-       mov     r0,r4
-       mov     r4,0f
-       clr     r0
-1:
-       tstb    (r4)+
-       beq     1f
-       inc     r0
-       br      1b
-1:
-       mov     r0,1f
-       mov     $1,r0
-       sys     indir; 9f
-       .data
-9:     sys     write; 0:0; 1:0
-       .text
-       mov     r5,0f
-       mov     $1,0f+2
-       tstb    1(r5)
-       beq     1f
-       mov     $2,0f+2
-1:
-       mov     $1,r0
-       sys     indir; 9f
-       .data
-9:     sys     write; 0:0; 1
-       .text
-       tst     (r5)+
-       mov     (sp)+,r4
-       rts     r5
-
-fcreat:
-       mov     r4,-(sp)
-       mov     (r5)+,r4
-       mov     r4,0f
-1:
-       sys     indir; 9f
-       .data
-9:     sys     stat; 0:..; outbuf
-       .text
-       bec     2f
-       mov     r4,0f
-       sys     indir; 9f
-       .data
-9:     sys     creat; 0:..; 444
-       .text
-       bes     2f
-       mov     (sp)+,r4
-       rts     r5
-2:
-       incb    9.(r4)
-       cmpb    9.(r4),$'z
-       blos    1b
-       mov     r4,r0
-       jsr     r5,filerr; "?\n
-       mov     $3,r0
-       sys     exit
-
-.=.+2
-wrterr:
-       mov     $1,r0
-       sys     write; 9f; 9f-8f
-       inc     errflg
-       jbr     aexit
-9:     <as: Write error on temp file.\n>; 8:
diff --git a/usr/src/cmd/as/as12.s b/usr/src/cmd/as/as12.s
deleted file mode 100644 (file)
index ab555a4..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/
-/
-
-/ a2 -- pdp-11 assembler pass 1
-
-error:
-       incb    errflg
-       mov     r0,-(sp)
-       mov     r1,-(sp)
-       mov     (r5)+,r0
-       tst     *curarg
-       beq     1f
-       mov     r0,-(sp)
-       mov     *curarg,r0
-       clr     *curarg
-       jsr     r5,filerr; '\n
-       mov     (sp)+,r0
-1:
-       mov     r2,-(sp)
-       mov     r3,-(sp)
-       mov     line,r3
-       movb    r0,1f
-       mov     $1f+6,r0
-       mov     $4,r1
-2:
-       clr     r2
-       dvd     $10.,r2
-       add     $'0,r3
-       movb    r3,-(r0)
-       mov     r2,r3
-       sob     r1,2b
-       mov     $1,r0
-       sys     write; 1f; 7
-       mov     (sp)+,r3
-       mov     (sp)+,r2
-       mov     (sp)+,r1
-       mov     (sp)+,r0
-       rts     r5
-
-       .data
-1:     <f xxxx\n>
-       .even
-       .text
-
-betwen:
-       cmp     r0,(r5)+
-       blt     1f
-       cmp     (r5)+,r0
-       blt     2f
-1:
-       tst     (r5)+
-2:
-       rts     r5
-
-putw:
-       tst     ifflg
-       beq     1f
-       cmp     r4,$'\n
-       bne     2f
-1:
-       mov     r4,*obufp
-       add     $2,obufp
-       cmp     obufp,$outbuf+512.
-       blo     2f
-       mov     $outbuf,obufp
-       movb    pof,r0
-       sys     write; outbuf; 512.
-       jes     wrterr
-2:
-       rts     pc
-
diff --git a/usr/src/cmd/as/as13.s b/usr/src/cmd/as/as13.s
deleted file mode 100644 (file)
index 9e49eba..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/
-/
-
-/ a3 -- pdp-11 assembler pass 1
-
-assem:
-       jsr     pc,readop
-       jsr     pc,checkeos
-               br ealoop
-       tst     ifflg
-       beq     3f
-       cmp     r4,$200
-       blos    assem
-       cmpb    (r4),$21        /if
-       bne     2f
-       inc     ifflg
-2:
-       cmpb    (r4),$22   /endif
-       bne     assem
-       dec     ifflg
-       br      assem
-3:
-       mov     r4,-(sp)
-       jsr     pc,readop
-       cmp     r4,$'=
-       beq     4f
-       cmp     r4,$':
-       beq     1f
-       mov     r4,savop
-       mov     (sp)+,r4
-       jsr     pc,opline
-       br      ealoop
-1:
-       mov     (sp)+,r4
-       cmp     r4,$200
-       bhis    1f
-       cmp     r4,$1           / digit
-       beq     3f
-       jsr     r5,error; 'x
-       br      assem
-1:
-       bitb    $37,(r4)
-       beq     1f
-       jsr     r5,error; 'm
-1:
-       bisb    dot-2,(r4)
-       mov     dot,2(r4)
-       br      assem
-3:
-       mov     numval,r0
-       jsr     pc,fbcheck
-       movb    dotrel,curfbr(r0)
-       asl     r0
-       movb    dotrel,nxtfb
-       mov     dot,nxtfb+2
-       movb    r0,nxtfb+1
-       mov     dot,curfb(r0)
-       movb    fbfil,r0
-       sys     write; nxtfb; 4
-       jes     wrterr
-       br      assem
-4:
-       jsr     pc,readop
-       jsr     pc,expres
-       mov     (sp)+,r1
-       cmp     r1,$200
-       bhis    1f
-       jsr     r5,error; 'x
-       br      ealoop
-1:
-       cmp     r1,$dotrel
-       bne     2f
-       bic     $40,r3
-       cmp     r3,dotrel
-       bne     1f
-2:
-       bicb    $37,(r1)
-       bic     $!37,r3
-       bne     2f
-       clr     r2
-2:
-       bisb    r3,(r1)
-       mov     r2,2(r1)
-       br      ealoop
-1:
-       jsr     r5,error; '.
-       movb    $2,dotrel
-ealoop:
-       cmp     r4,$';
-       beq     assem1
-       cmp     r4,$'\n
-       bne     1f
-       inc     line
-       br      assem1
-1:
-       cmp     r4,$'\e
-       bne     2f
-       tst     ifflg
-       beq     1f
-       jsr     r5,error; 'x
-1:
-       rts     pc
-2:
-       jsr     r5,error; 'x
-2:
-       jsr     pc,checkeos
-               br assem1
-       jsr     pc,readop
-       br      2b
-assem1:
-       jmp     assem
-
-fbcheck:
-       cmp     r0,$9.
-       bhi     1f
-       rts     pc
-1:
-       jsr     r5,error; 'f
-       clr     r0
-       rts     pc
-
-checkeos:
-       cmp     r4,$'\n
-       beq     1f
-       cmp     r4,$';
-       beq     1f
-       cmp     r4,$'\e
-       beq     1f
-       add     $2,(sp)
-1:
-       rts     pc
-
diff --git a/usr/src/cmd/as/as14.s b/usr/src/cmd/as/as14.s
deleted file mode 100644 (file)
index f8a5018..0000000
+++ /dev/null
@@ -1,244 +0,0 @@
-/
-/
-
-/ a4 -- pdp-11 assembler pass1
-
-rname:
-       mov     r1,-(sp)
-       mov     r2,-(sp)
-       mov     r3,-(sp)
-       mov     $8,r5
-       mov     $symbol+8.,r2
-       clr     -(r2)
-       clr     -(r2)
-       clr     -(r2)
-       clr     -(r2)
-       clr     -(sp)
-       clr     -(sp)
-       cmp     r0,$'~          /  symbol not for hash table
-       bne     1f
-       inc     2(sp)
-       clrb    ch
-1:
-       jsr     pc,rch
-       movb    chartab(r0),r3
-       ble     1f
-       add     r3,(sp)
-       swab    (sp)
-       dec     r5
-       blt     1b
-       movb    r3,(r2)+
-       br      1b
-1:
-       movb    r0,ch
-       mov     (sp)+,r1
-       clr     r0
-       tst     (sp)+
-       beq     1f
-       mov     symend,r4
-       br      4f
-1:
-       div     $hshsiz,r0
-       ashc    $1,r0
-       add     $hshtab,r1
-       clr     timesaround
-1:
-       sub     r0,r1
-       cmp     r1,$hshtab
-       bhi     2f
-       add     $2*hshsiz,r1
-       tst     timesaround
-       beq     3f
-       mov     $1,r0
-       sys     write; 9f; 8f-9f
-       jmp     aexit
-       .data
-timesaround:
-       .=.+2
-9:     <as: symbol table overflow\n>; 8: .even
-       .text
-3:
-       inc     timesaround
-2:
-       mov     $symbol,r2
-       mov     -(r1),r4
-       beq     3f
-       cmp     (r2)+,(r4)+
-       bne     1b
-       cmp     (r2)+,(r4)+
-       bne     1b
-       cmp     (r2)+,(r4)+
-       bne     1b
-       cmp     (r2)+,(r4)+
-       bne     1b
-       br      1f
-3:
-       mov     symend,r4
-       mov     r4,(r1)
-4:
-       mov     $symbol,r2
-       mov     r4,-(sp)
-       add     $20,r4
-       cmp     r4,0f
-       blos    4f
-       add     $512.,0f
-       sys     indir; 9f
-       .data
-9:     sys     break; 0:end
-       .text
-4:
-       mov     (sp)+,r4
-       mov     (r2)+,(r4)+
-       mov     (r2)+,(r4)+
-       mov     (r2)+,(r4)+
-       mov     (r2)+,(r4)+
-       clr     (r4)+
-       clr     (r4)+
-       mov     r4,symend
-       sub     $4,r4
-1:
-       mov     r4,-(sp)
-       mov     r4,r3
-       sub     $8,r3
-       cmp     r3,$usymtab
-       blo     1f
-       sub     $usymtab,r3
-       clr     r2
-       div     $3,r2
-       mov     r2,r4
-       add     $4000,r4                / user symbol
-       br      2f
-1:
-       sub     $symtab,r3
-       clr     r2
-       div     $3,r2
-       mov     r2,r4
-       add     $1000,r4                / builtin symbol
-2:
-       jsr     pc,putw
-       mov     (sp)+,r4
-       mov     (sp)+,r3
-       mov     (sp)+,r2
-       mov     (sp)+,r1
-       tst     (sp)+
-       rts     pc
-
-number:
-       mov     r2,-(sp)
-       mov     r3,-(sp)
-       mov     r5,-(sp)
-       clr     r1
-       clr     r5
-1:
-       jsr     pc,rch
-       jsr     r5,betwen; '0; '9
-               br 1f
-       sub     $'0,r0
-       mpy     $10.,r5
-       add     r0,r5
-       als     $3,r1
-       add     r0,r1
-       br      1b
-1:
-       cmp     r0,$'b
-       beq     1f
-       cmp     r0,$'f
-       beq     1f
-       cmp     r0,$'.
-       bne     2f
-       mov     r5,r1
-       clr     r0
-2:
-       movb    r0,ch
-       mov     r1,r0
-       mov     (sp)+,r5
-       mov     (sp)+,r3
-       mov     (sp)+,r2
-       rts     pc
-1:
-       mov     r0,r3
-       mov     r5,r0
-       jsr     pc,fbcheck
-       add     $141,r0
-       cmp     r3,$'b
-       beq     1f
-       add     $10.,r0
-1:
-       mov     r0,r4
-       mov     (sp)+,r5
-       mov     (sp)+,r3
-       mov     (sp)+,r2
-       add     $2,(sp)
-       rts     pc
-
-rch:
-       movb    ch,r0
-       beq     1f
-       clrb    ch
-       rts     pc
-1:
-       dec     inbfcnt
-       blt     2f
-       movb    *inbfp,r0
-       inc     inbfp
-       bic     $!177,r0
-       beq     1b
-       rts     pc
-2:
-       movb    fin,r0
-       beq     3f
-       sys     read; inbuf;512.
-       bcs     2f
-       tst     r0
-       beq     2f
-       mov     r0,inbfcnt
-       mov     $inbuf,inbfp
-       br      1b
-2:
-       movb    fin,r0
-       clrb    fin
-       sys     close
-3:
-       decb    nargs
-       bgt     2f
-       mov     $'\e,r0
-       rts     pc
-2:
-       tst     ifflg
-       beq     2f
-       jsr     r5,error; 'i
-       jmp     aexit
-2:
-       mov     curarg,r0
-       tst     (r0)+
-       mov     (r0),0f
-       mov     r0,curarg
-       incb    fileflg
-       sys     indir; 9f
-       .data
-9:     sys     open; 0:0; 0
-       .text
-       bec     2f
-       mov     0b,r0
-       jsr     r5,filerr; <?\n>
-       jmp     aexit
-2:
-       movb    r0,fin
-       mov     $1,line
-       mov     r4,-(sp)
-       mov     r1,-(sp)
-       mov     $5,r4
-       jsr     pc,putw
-       mov     *curarg,r1
-2:
-       movb    (r1)+,r4
-       beq     2f
-       jsr     pc,putw
-       br      2b
-2:
-       mov     $-1,r4
-       jsr     pc,putw
-       mov     (sp)+,r1
-       mov     (sp)+,r4
-       br      1b
-
diff --git a/usr/src/cmd/as/as15.s b/usr/src/cmd/as/as15.s
deleted file mode 100644 (file)
index a6981b3..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/
-/
-
-/ a5 -- pdp-11 assembler pass 1
-
-readop:
-       mov     savop,r4
-       beq     1f
-       clr     savop
-       rts     pc
-1:
-       jsr     pc,8f
-       jsr     pc,putw
-       rts     pc
-
-8:
-       jsr     pc,rch
-_readop:
-       mov     r0,r4
-       movb    chartab(r0),r1
-       bgt     rdname
-       jmp     *1f-2(r1)
-
-       fixor
-       escp
-       8b
-       retread
-       dquote
-       garb
-       squote
-       rdname
-       skip
-       rdnum
-       retread
-       string
-1:
-
-escp:
-       jsr     pc,rch
-       mov     $esctab,r1
-1:
-       cmpb    r0,(r1)+
-       beq     1f
-       tstb    (r1)+
-       bne     1b
-       rts     pc
-1:
-       movb    (r1),r4
-       rts     pc
-
-esctab:
-       .byte '/, '/
-       .byte '\<, 035
-       .byte '>, 036
-       .byte '%, 037
-       .byte 0, 0
-
-fixor:
-       mov     $037,r4
-retread:
-       rts     pc
-
-rdname:
-       movb    r0,ch
-       cmp     r1,$'0
-       blo     1f
-       cmp     r1,$'9
-       blos    rdnum
-1:
-       jmp     rname
-
-rdnum:
-       jsr     pc,number
-               br 1f
-       rts     pc
-
-squote:
-       jsr     pc,rsch
-       br      1f
-dquote:
-       jsr     pc,rsch
-       mov     r0,-(sp)
-       jsr     pc,rsch
-       swab    r0
-       bis     (sp)+,r0
-1:
-       mov     r0,numval
-       mov     $1,r4
-       jsr     pc,putw
-       mov     numval,r4
-       jsr     pc,putw
-       mov     $1,r4
-       tst     (sp)+
-       rts     pc
-
-skip:
-       jsr     pc,rch
-       mov     r0,r4
-       cmp     r0,$'\e
-       beq     1f
-       cmp     r0,$'\n
-       bne     skip
-1:
-       rts     pc
-
-garb:
-       jsr     r5,error; 'g
-       br      8b
-
-string:
-       mov     $'<,r4
-       jsr     pc,putw
-       clr     numval
-1:
-       jsr     pc,rsch
-       tst     r1
-       bne     1f
-       mov     r0,r4
-       bis     $400,r4
-       jsr     pc,putw
-       inc      numval
-       br      1b
-1:
-       mov     $-1,r4
-       jsr     pc,putw
-       mov     $'<,r4
-       tst     (sp)+
-       rts     pc
-
-rsch:
-       jsr     pc,rch
-       cmp     r0,$'\e
-       beq     4f
-       cmp     r0,$'\n
-       beq     4f
-       clr     r1
-       cmp     r0,$'\\
-       bne     3f
-       jsr     pc,rch
-       mov     $schar,r2
-1:
-       cmpb    (r2)+,r0
-       beq     2f
-       tstb    (r2)+
-       bpl     1b
-       rts     pc
-2:
-       movb    (r2)+,r0
-       clr     r1
-       rts     pc
-3:
-       cmp     r0,$'>
-       bne     1f
-       inc     r1
-1:
-       rts     pc
-4:
-       jsr     r5,error; '<
-       jmp     aexit
-
-schar:
-       .byte 'n, 012
-       .byte 's, 040
-       .byte 't, 011
-       .byte 'e, 004
-       .byte '0, 000
-       .byte 'r, 015
-       .byte 'a, 006
-       .byte 'p, 033
-       .byte 0,  -1
-
diff --git a/usr/src/cmd/as/as16.s b/usr/src/cmd/as/as16.s
deleted file mode 100644 (file)
index 799c9fe..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-/
-/
-
-/ a6 -- pdp-11 assembler pass 1
-
-opline:
-       mov     r4,r0
-       jsr     r5,betwen; 0; 200
-               br      1f
-       cmp     r0,$'<
-       bne     xpr
-       jmp     opl17
-xpr:
-       jsr     pc,expres
-       add     $2,dot
-       rts     pc
-1:
-       movb    (r4),r0
-       cmp     r0,$24
-       beq     xpr
-       jsr     r5,betwen; 5; 36
-               br xpr
-       mov     r0,-(sp)
-       jsr     pc,readop
-       mov     (sp)+,r0
-       asl     r0
-       jmp     *1f-12(r0)
-
-1:
-       opl13   / map fop freg,fdst to double
-       opl6
-       opl7
-       opl10
-       opl11
-       opl13   / map fld/fst to double
-       opl13
-       opl13   / map fop fsrc,freg to double
-       opl15
-       opl16
-       opl17
-       opl20
-       opl21
-       opl22
-       opl23
-       xpr
-       opl25
-       opl26
-       opl27
-       opl13  / map mul s,r to double
-       opl31
-       opl32
-       xpr
-       xpr
-       opl35
-       opl36
-
-/ jbr
-opl35:
-       mov     $4,-(sp)
-       br      1f
-
-/ jeq, etc
-opl36:
-       mov     $6,-(sp)
-1:
-       jsr     pc,expres
-       cmp     r3,dotrel
-       bne     1f
-       sub     dot,r2
-       bge     1f
-       cmp     r2,$-376
-       blt     1f
-       mov     $2,(sp)
-1:
-       add     (sp)+,dot
-       rts     pc
-
-/double
-opl13:
-opl7:
-       jsr     pc,addres
-op2:
-       cmp     r4,$',
-       beq     1f
-       jsr     pc,errora
-       rts     pc
-1:
-       jsr     pc,readop
-opl15:   / single operand
-       jsr     pc,addres
-       add     $2,dot
-       rts     pc
-
-opl31: / sob
-       jsr     pc,expres
-       cmp     r4,$',
-       beq     1f
-       jsr     pc,errora
-1:
-       jsr     pc,readop
-
-/branch
-opl6:
-opl10:
-opl11:
-       jsr     pc,expres
-       add     $2,dot
-       rts     pc
-
-/ .byte
-opl16:
-       jsr     pc,expres
-       inc     dot
-       cmp     r4,$',
-       bne     1f
-       jsr     pc,readop
-       br      opl16
-1:
-       rts     pc
-
-/ < (.ascii)
-opl17:
-       add     numval,dot
-       jsr     pc,readop
-       rts     pc
-
-/.even
-opl20:
-       inc     dot
-       bic     $1,dot
-       rts     pc
-
-/.if
-opl21:
-       jsr     pc,expres
-       tst     r3
-       bne     1f
-       jsr     r5,error; 'U
-1:
-       tst     r2
-       bne     opl22
-       inc     ifflg
-opl22: /endif
-       rts     pc
-
-/.globl
-opl23:
-       cmp     r4,$200
-       blo     1f
-       bisb    $40,(r4)
-       jsr     pc,readop
-       cmp     r4,$',
-       bne     1f
-       jsr     pc,readop
-       br      opl23
-1:
-       rts     pc
-
-opl25:
-opl26:
-opl27:
-       mov     dotrel,r1
-       asl     r1
-       mov     dot,savdot-4(r1)
-       mov     savdot-[2*25](r0),dot
-       asr     r0
-       sub     $25-2,r0
-       mov     r0,dotrel
-       rts     pc
-
-/ .common
-opl32:
-       cmp     r4,$200
-       blo     1f
-       bis     $40,(r4)
-       jsr     pc,readop
-       cmp     r4,$',
-       bne     1f
-       jsr     pc,readop
-       jsr     pc,expres
-       rts     pc
-1:
-       jsr     r5,error; 'x
-       rts     pc
-
-addres:
-       cmp     r4,$'(
-       beq     alp
-       cmp     r4,$'-
-       beq     amin
-       cmp     r4,$'$
-       beq     adoll
-       cmp     r4,$'*
-       beq     astar
-getx:
-       jsr     pc,expres
-       cmp     r4,$'(
-       bne     2f
-       jsr     pc,readop
-       jsr     pc,expres
-       jsr     pc,checkreg
-       jsr     pc,checkrp
-       add     $2,dot
-       clr     r0
-       rts     pc
-2:
-       cmp     r3,$24          / register type
-       bne     1f
-       jsr     pc,checkreg
-       clr     r0
-       rts     pc
-1:
-       add     $2,dot
-       clr     r0
-       rts     pc
-
-alp:
-       jsr     pc,readop
-       jsr     pc,expres
-       jsr     pc,checkrp
-       jsr     pc,checkreg
-       cmp     r4,$'+
-       bne     1f
-       jsr     pc,readop
-       clr     r0
-       rts     pc
-1:
-       mov     $2,r0
-       rts     pc
-
-amin:
-       jsr     pc,readop
-       cmp     r4,$'(
-       beq     1f
-       mov     r4,savop
-       mov     $'-,r4
-       br      getx
-1:
-       jsr     pc,readop
-       jsr     pc,expres
-       jsr     pc,checkrp
-       jsr     pc,checkreg
-       clr     r0
-       rts     pc
-
-adoll:
-       jsr     pc,readop
-       jsr     pc,expres
-       add     $2,dot
-       clr     r0
-       rts     pc
-
-astar:
-       jsr     pc,readop
-       cmp     r4,$'*
-       bne     1f
-       jsr     r5,error; '*
-1:
-       jsr     pc,addres
-       add     r0,dot
-       rts     pc
-
-errora:
-       jsr     r5,error; 'a
-       rts     pc
-
-checkreg:
-       cmp     r2,$7
-       bhi     1f
-       cmp     r3,$1
-       beq     2f
-       cmp     r3,$4
-       bhi     2f
-1:
-       jsr     pc,errora
-2:
-       rts     pc
-
-errore:
-       jsr     r5,error; 'e
-       rts     pc
-
-checkrp:
-       cmp     r4,$')
-       beq     1f
-       jsr     r5,error; ')
-       rts     pc
-1:
-       jsr     pc,readop
-       rts     pc
-
diff --git a/usr/src/cmd/as/as17.s b/usr/src/cmd/as/as17.s
deleted file mode 100644 (file)
index 30a17c2..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-/
-/
-
-/  a7 -- pdp-11 assembler pass 1
-
-expres:
-       mov     r5,-(sp)
-       mov     $'+,-(sp)
-       clr     opfound
-       clr     r2
-       mov     $1,r3
-       br      1f
-advanc:
-       jsr     pc,readop
-1:
-       mov     r4,r0
-       jsr     r5,betwen; 0; 177
-               br .+4
-       br      7f
-       movb    (r4),r0
-       mov     2(r4),r1
-       br      oprand
-7:
-       cmp     r4,$141
-       blo     1f
-       cmp     r4,$141+10.
-       bhis    2f
-       movb    curfbr-141(r4),r0
-       asl     r4
-       mov     curfb-[2*141](r4),r2
-       cmp     r2,$-1
-       bne     oprand
-       jsr     r5,error; 'f
-       br      oprand
-2:
-       clr     r3
-       clr     r2
-       br      oprand
-1:
-       mov     $esw1,r1
-1:
-       cmp     (r1)+,r4
-       beq     1f
-       tst     (r1)+
-       bne     1b
-       tst     opfound
-       bne     2f
-       jsr     pc,errore
-2:
-       tst     (sp)+
-       mov     (sp)+,r5
-       rts     pc
-1:
-       jmp     *(r1)
-
-esw1:
-       '+;     binop
-       '-;     binop
-       '*;     binop
-       '/;     binop
-       '&;     binop
-       037;    binop
-       035;    binop
-       036;    binop
-       '%;     binop
-       '[;     brack
-       '^;     binop
-       1;      exnum
-       '!;     binop
-       0;      0
-
-binop:
-       cmpb    (sp),$'+
-       beq     1f
-       jsr     pc,errore
-1:
-       movb    r4,(sp)
-       br      advanc
-
-exnum:
-       mov     numval,r1
-       mov     $1,r0
-       br      oprand
-
-brack:
-       mov     r2,-(sp)
-       mov     r3,-(sp)
-       jsr     pc,readop
-       jsr     pc,expres
-       cmp     r4,$']
-       beq     1f
-       jsr     r5,error; ']
-1:
-       mov     r3,r0
-       mov     r2,r1
-       mov     (sp)+,r3
-       mov     (sp)+,r2
-
-oprand:
-       inc     opfound
-       mov     $exsw2,r5
-1:
-       cmp     (sp),(r5)+
-       beq     1f
-       tst     (r5)+
-       bne     1b
-       br      eoprnd
-1:
-       jmp     *(r5)
-
-exsw2:
-       '+; exadd
-       '-; exsub
-       '*; exmul
-       '/; exdiv
-       037; exor
-       '&; exand
-       035;exlsh
-       036;exrsh
-       '%; exmod
-       '!; exnot
-       '^; excmbin
-       0;  0
-
-excmbin:
-       mov     r0,r3                   / give left flag of right
-       br      eoprnd
-
-exrsh:
-       neg     r1
-       beq     exlsh
-       inc     r1
-       clc
-       ror     r2
-exlsh:
-       jsr     r5,combin; 0
-       als     r1,r2
-       br      eoprnd
-
-exmod:
-       jsr     r5,combin; 0
-       mov     r1,-(sp)
-       mov     r2,r1
-       clr     r0
-       dvd     (sp)+,r0
-       mov     r1,r2
-       br      eoprnd
-
-exadd:
-       jsr     r5,combin; 0
-       add     r1,r2
-       br      eoprnd
-
-exsub:
-       jsr     r5,combin; 1
-       sub     r1,r2
-       br      eoprnd
-
-exand:
-       jsr     r5,combin; 0
-       com     r1
-       bic     r1,r2
-       br      eoprnd
-
-exor:
-       jsr     r5,combin; 0
-       bis     r1,r2
-       br      eoprnd
-
-exmul:
-       jsr     r5,combin; 0
-       mpy     r2,r1
-       mov     r1,r2
-       br      eoprnd
-
-exdiv:
-       jsr     r5,combin; 0
-       mov     r1,-(sp)
-       mov     r2,r1
-       clr     r0
-       dvd     (sp)+,r0
-       mov     r0,r2
-       br      eoprnd
-
-exnot:
-       jsr     r5,combin; 0
-       com     r1
-       add     r1,r2
-       br      eoprnd
-
-eoprnd:
-       mov     $'+,(sp)
-       jmp     advanc
-
-combin:
-       mov     r0,-(sp)
-       bis     r3,(sp)
-       bic     $!40,(sp)
-       bic     $!37,r0
-       bic     $!37,r3
-       cmp     r0,r3
-       ble     1f
-       mov     r0,-(sp)
-       mov     r3,r0
-       mov     (sp)+,r3
-1:
-       tst     r0
-       beq     1f
-       tst     (r5)+
-       beq     2f
-       cmp     r0,r3
-       bne     2f
-       mov     $1,r3
-       br      2f
-1:
-       tst     (r5)+
-       clr     r3
-2:
-       bis     (sp)+,r3
-       rts     r5
-
diff --git a/usr/src/cmd/as/as18.s b/usr/src/cmd/as/as18.s
deleted file mode 100644 (file)
index 6b6eb81..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/
-/
-
-/ a8 -- pdp-11 assembler pass 1
-
-chartab:
-       .byte -14,-14,-14,-14,-02,-14,-14,-14
-       .byte -14,-22, -2,-14,-14,-22,-14,-14
-       .byte -14,-14,-14,-14,-14,-14,-14,-14
-       .byte -14,-14,-14,-14,-14,-14,-14,-14
-       .byte -22,-20,-16,-14,-20,-20,-20,-12
-       .byte -20,-20,-20,-20,-20,-20,056,-06
-       .byte 060,061,062,063,064,065,066,067
-       .byte 070,071,-20,-02,-00,-20,-14,-14
-       .byte -14,101,102,103,104,105,106,107
-       .byte 110,111,112,113,114,115,116,117
-       .byte 120,121,122,123,124,125,126,127
-       .byte 130,131,132,-20,-24,-20,-20,137
-       .byte -14,141,142,143,144,145,146,147
-       .byte 150,151,152,153,154,155,156,157
-       .byte 160,161,162,163,164,165,166,167
-       .byte 170,171,172,-14,-26,-14,176,-14
-
-.data
-
-namedone:.byte 0
-a.tmp1:        </tmp/atm1a\0>
-a.tmp2:        </tmp/atm2a\0>
-a.tmp3:        </tmp/atm3a\0>
-       .even
-curfb:
-       -1;-1;-1;-1;-1;-1;-1;-1;-1;-1
-obufp: outbuf
-symend:        usymtab
-
-.bss
-curfbr:        .=.+10.
-savdot:        .=.+6
-bufcnt:        .=.+2
-hshsiz = 3001.
-hshtab:        .=2*hshsiz+.
-pof:   .=.+1
-wordf: .=.+1
-fin:   .=.+1
-fbfil: .=.+1
-fileflg:.=.+1
-errflg:        .=.+1
-ch:    .=.+1
-.even
-symbol:        .=.+8.
-obufc: .=.+2
-outbuf:        .=.+512.
-line:  .=.+2
-inbfcnt:.=.+2
-ifflg: .=.+2
-inbfp: .=.+2
-nargs: .=.+2
-curarg:        .=.+2
-opfound:.=.+2
-savop: .=.+2
-numval:        .=.+2
-nxtfb: .=.+4
-usymtab:.=.+36.
-end:
-.text
diff --git a/usr/src/cmd/as/as19.s b/usr/src/cmd/as/as19.s
deleted file mode 100644 (file)
index 6c7be87..0000000
+++ /dev/null
@@ -1,329 +0,0 @@
-/
-/
-
-/ a9 -- pdp-11 assembler pass 1
-
-eae = 0
-
-/ key to types
-
-/      0       undefined
-/      1       absolute
-/      2       text
-/      3       data
-/      4       bss
-/      5       flop freg,dst (movfo, = stcfd)
-/      6       branch
-/      7       jsr
-/      10      rts
-/      11      sys
-/      12      movf (=ldf,stf)
-/      13      double operand (mov)
-/      14      flop fsrc,freg (addf)
-/      15      single operand (clr)
-/      16      .byte
-/      17      string (.ascii, "<")
-/      20      .even
-/      21      .if
-/      22      .endif
-/      23      .globl
-/      24      register
-/      25      .text
-/      26      .data
-/      27      .bss
-/      30      mul,div, etc
-/      31      sob
-/      32      .comm
-/      33      estimated text
-/      34      estimated data
-/      35      jbr
-/      36      jeq, jne, etc
-
-       .data
-symtab:
-/ special variables
-
-<.\0\0\0\0\0\0\0>; dotrel:02; dot:000000
-<..\0\0\0\0\0\0>;      01; dotdot:000000
-
-/ register
-
-<r0\0\0\0\0\0\0>;      24;000000
-<r1\0\0\0\0\0\0>;      24;000001
-<r2\0\0\0\0\0\0>;      24;000002
-<r3\0\0\0\0\0\0>;      24;000003
-<r4\0\0\0\0\0\0>;      24;000004
-<r5\0\0\0\0\0\0>;      24;000005
-<sp\0\0\0\0\0\0>;      24;000006
-<pc\0\0\0\0\0\0>;      24;000007
-
-.if eae
-
-/eae & switches
-
-<csw\0\0\0\0\0>;       01;177570
-<div\0\0\0\0\0>;       01;177300
-<ac\0\0\0\0\0\0>;      01;177302
-<mq\0\0\0\0\0\0>;      01;177304
-<mul\0\0\0\0\0>;       01;177306
-<sc\0\0\0\0\0\0>;      01;177310
-<sr\0\0\0\0\0\0>;      01;177311
-<nor\0\0\0\0\0>;       01;177312
-<lsh\0\0\0\0\0>;       01;177314
-<ash\0\0\0\0\0>;       01;177316
-
-.endif
-
-/ double operand
-
-<mov\0\0\0\0\0>;       13;0010000
-<movb\0\0\0\0>;                13;0110000
-<cmp\0\0\0\0\0>;       13;0020000
-<cmpb\0\0\0\0>;                13;0120000
-<bit\0\0\0\0\0>;       13;0030000
-<bitb\0\0\0\0>;                13;0130000
-<bic\0\0\0\0\0>;       13;0040000
-<bicb\0\0\0\0>;                13;0140000
-<bis\0\0\0\0\0>;       13;0050000
-<bisb\0\0\0\0>;                13;0150000
-<add\0\0\0\0\0>;       13;0060000
-<sub\0\0\0\0\0>;       13;0160000
-
-/ branch
-
-<br\0\0\0\0\0\0>;      06;0000400
-<bne\0\0\0\0\0>;       06;0001000
-<beq\0\0\0\0\0>;       06;0001400
-<bge\0\0\0\0\0>;       06;0002000
-<blt\0\0\0\0\0>;       06;0002400
-<bgt\0\0\0\0\0>;       06;0003000
-<ble\0\0\0\0\0>;       06;0003400
-<bpl\0\0\0\0\0>;       06;0100000
-<bmi\0\0\0\0\0>;       06;0100400
-<bhi\0\0\0\0\0>;       06;0101000
-<blos\0\0\0\0>;                06;0101400
-<bvc\0\0\0\0\0>;       06;0102000
-<bvs\0\0\0\0\0>;       06;0102400
-<bhis\0\0\0\0>;                06;0103000
-<bec\0\0\0\0\0>;       06;0103000
-<bcc\0\0\0\0\0>;       06;0103000
-<blo\0\0\0\0\0>;       06;0103400
-<bcs\0\0\0\0\0>;       06;0103400
-<bes\0\0\0\0\0>;       06;0103400
-
-/ jump/branch type
-
-<jbr\0\0\0\0\0>;       35;0000400
-<jne\0\0\0\0\0>;       36;0001000
-<jeq\0\0\0\0\0>;       36;0001400
-<jge\0\0\0\0\0>;       36;0002000
-<jlt\0\0\0\0\0>;       36;0002400
-<jgt\0\0\0\0\0>;       36;0003000
-<jle\0\0\0\0\0>;       36;0003400
-<jpl\0\0\0\0\0>;       36;0100000
-<jmi\0\0\0\0\0>;       36;0100400
-<jhi\0\0\0\0\0>;       36;0101000
-<jlos\0\0\0\0>;                36;0101400
-<jvc\0\0\0\0\0>;       36;0102000
-<jvs\0\0\0\0\0>;       36;0102400
-<jhis\0\0\0\0>;                36;0103000
-<jec\0\0\0\0\0>;       36;0103000
-<jcc\0\0\0\0\0>;       36;0103000
-<jlo\0\0\0\0\0>;       36;0103400
-<jcs\0\0\0\0\0>;       36;0103400
-<jes\0\0\0\0\0>;       36;0103400
-
-/ single operand
-
-<clr\0\0\0\0\0>;       15;0005000
-<clrb\0\0\0\0>;                15;0105000
-<com\0\0\0\0\0>;       15;0005100
-<comb\0\0\0\0>;                15;0105100
-<inc\0\0\0\0\0>;       15;0005200
-<incb\0\0\0\0>;                15;0105200
-<dec\0\0\0\0\0>;       15;0005300
-<decb\0\0\0\0>;                15;0105300
-<neg\0\0\0\0\0>;       15;0005400
-<negb\0\0\0\0>;                15;0105400
-<adc\0\0\0\0\0>;       15;0005500
-<adcb\0\0\0\0>;                15;0105500
-<sbc\0\0\0\0\0>;       15;0005600
-<sbcb\0\0\0\0>;                15;0105600
-<tst\0\0\0\0\0>;       15;0005700
-<tstb\0\0\0\0>;                15;0105700
-<ror\0\0\0\0\0>;       15;0006000
-<rorb\0\0\0\0>;                15;0106000
-<rol\0\0\0\0\0>;       15;0006100
-<rolb\0\0\0\0>;                15;0106100
-<asr\0\0\0\0\0>;       15;0006200
-<asrb\0\0\0\0>;                15;0106200
-<asl\0\0\0\0\0>;       15;0006300
-<aslb\0\0\0\0>;                15;0106300
-<jmp\0\0\0\0\0>;       15;0000100
-<swab\0\0\0\0>;                15;0000300
-
-/ jsr
-
-<jsr\0\0\0\0\0>;       07;0004000
-
-/ rts
-
-<rts\0\0\0\0\0>;       010;000200
-
-/ simple operand
-
-<sys\0\0\0\0\0>;       011;104400
-
-/ flag-setting
-
-<clc\0\0\0\0\0>;       01;0000241
-<clv\0\0\0\0\0>;       01;0000242
-<clz\0\0\0\0\0>;       01;0000244
-<cln\0\0\0\0\0>;       01;0000250
-<sec\0\0\0\0\0>;       01;0000261
-<sev\0\0\0\0\0>;       01;0000262
-<sez\0\0\0\0\0>;       01;0000264
-<sen\0\0\0\0\0>;       01;0000270
-
-/ floating point ops
-
-<cfcc\0\0\0\0>;                01;170000
-<setf\0\0\0\0>;                01;170001
-<setd\0\0\0\0>;                01;170011
-<seti\0\0\0\0>;                01;170002
-<setl\0\0\0\0>;                01;170012
-<clrf\0\0\0\0>;                15;170400
-<negf\0\0\0\0>;                15;170700
-<absf\0\0\0\0>;                15;170600
-<tstf\0\0\0\0>;                15;170500
-<movf\0\0\0\0>;                12;172400
-<movif\0\0\0>;         14;177000
-<movfi\0\0\0>;         05;175400
-<movof\0\0\0>;         14;177400
-<movfo\0\0\0>;         05;176000
-<addf\0\0\0\0>;                14;172000
-<subf\0\0\0\0>;                14;173000
-<mulf\0\0\0\0>;                14;171000
-<divf\0\0\0\0>;                14;174400
-<cmpf\0\0\0\0>;                14;173400
-<modf\0\0\0\0>;                14;171400
-<movie\0\0\0>;         14;176400
-<movei\0\0\0>;         05;175000
-<ldfps\0\0\0>;         15;170100
-<stfps\0\0\0>;         15;170200
-<fr0\0\0\0\0\0>;       24;000000
-<fr1\0\0\0\0\0>;       24;000001
-<fr2\0\0\0\0\0>;       24;000002
-<fr3\0\0\0\0\0>;       24;000003
-<fr4\0\0\0\0\0>;       24;000004
-<fr5\0\0\0\0\0>;       24;000005
-
-/ 11/45 operations
-
-<als\0\0\0\0\0>;       30;072000
-<alsc\0\0\0\0>;                30;073000
-<mpy\0\0\0\0\0>;       30;070000
-.if eae-1
-<mul\0\0\0\0\0>;       30;070000
-<div\0\0\0\0\0>;       30;071000
-<ash\0\0\0\0\0>;       30;072000
-<ashc\0\0\0\0>;                30;073000
-.endif
-<dvd\0\0\0\0\0>;       30;071000
-<xor\0\0\0\0\0>;       07;074000
-<sxt\0\0\0\0\0>;       15;006700
-<mark\0\0\0\0>;                11;006400
-<sob\0\0\0\0\0>;       31;077000
-
-/ specials
-
-<.byte\0\0\0>;         16;000000
-<.even\0\0\0>;         20;000000
-<.if\0\0\0\0\0>;       21;000000
-<.endif\0\0>;          22;000000
-<.globl\0\0>;          23;000000
-<.text\0\0\0>;         25;000000
-<.data\0\0\0>;         26;000000
-<.bss\0\0\0\0>;                27;000000
-<.comm\0\0\0>;         32;000000
-
-ebsymtab:
-
-
-start:
-       sys     signal; 2; 1
-       ror     r0
-       bcs     1f
-       sys     signal; 2; aexit
-1:
-       mov     (sp)+,r0
-       tst     (sp)+
-1:
-       mov     (sp),r1
-       cmpb    (r1),$'-
-       bne     1f
-       tst     (sp)+
-       dec     r0
-       cmpb    1(r1),$'u
-       bne     2f
-       movb    $'g,unglob
-       br      1b
-2:
-       tstb    1(r1)
-       bne     2f
-       movb    $'g,unglob
-       br      1b
-2:
-       cmpb    1(r1),$'o
-       bne     1f
-       mov     (sp),outfp
-       tst     (sp)+
-       dec     r0
-       br      1b
-1:
-       movb    r0,nargs
-       tst     -(sp)
-       mov     sp,curarg
-       jsr     r5,fcreat; a.tmp1
-       movb    r0,pof
-       jsr     r5,fcreat; a.tmp2
-       movb    r0,fbfil
-       jsr     pc,setup
-       jmp     go
-
-setup:
-       mov     $symtab,r1
-1:
-       clr     r3
-       mov     $8,r2
-       mov     r1,-(sp)
-2:
-       movb    (r1)+,r4
-       beq     2f
-       add     r4,r3
-       swab    r3
-       sob     r2,2b
-2:
-       clr     r2
-       div     $hshsiz,r2
-       ashc    $1,r2
-       add     $hshtab,r3
-4:
-       sub     r2,r3
-       cmp     r3,$hshtab
-       bhi     3f
-       add     $2*hshsiz,r3
-3:
-       tst     -(r3)
-       bne     4b
-       mov     (sp)+,r1
-       mov     r1,(r3)
-       add     $12.,r1
-       cmp     r1,$ebsymtab
-       blo     1b
-       rts     pc
-
-/overlay buffer
-inbuf  = setup
-.      =inbuf+512.
-
diff --git a/usr/src/cmd/as/as2.c b/usr/src/cmd/as/as2.c
new file mode 100644 (file)
index 0000000..9a24f1f
--- /dev/null
@@ -0,0 +1,352 @@
+#
+char AS2[] = "@(#)as2.c 1.29 79/03/21 22:27:31";       /* sccs ident */
+#include       <stdio.h>
+#include       "as.h"
+#define JBR 0x11
+#define BRW 0x31
+extern struct symtab *nextsym;
+struct tshdr {/* overlays symtab struct */
+       char tsflag; /* 0xFF==active, 0xFE==inactive */
+       char tsbump; /* 0->short, 1->long */
+       short tsfear; /* possible bump value */
+       short tsline; /* source line number, for debugging and error messages */
+       short dest;  /* symtab ordinal of destination label */
+       char type;
+       char tag;
+       short index; /* usetab ordinal of csect */
+       long value;  /* estimated PC of following instruction */
+       char    ptype;
+       char    other;
+       short   desc;
+};
+
+jxxxbump(ts1,displ) register struct tshdr *ts1; {
+register struct symtab *sp2;
+/* printf("\njxxxbump %d  %.8s",displ,symtab[ts1->dest].name);  */
+ts1->tsflag=0xFE; ts1->tsbump=1; /* no longer in doubt, alas */
+for (sp2=symtab; sp2<nextsym; sp2++)
+       if ((sp2->type&XTYPE)==ts1->type && sp2->index==ts1->index &&
+                       sp2->value>=ts1->value && sp2!=ts1) sp2->value += ts1->tsfear;
+usedot[ts1->index].xvalue += ts1->tsfear;
+}
+
+jxxxfix() {/* pass 1.5, resolve jxxx instructions and .align in .text */
+register struct tshdr *sp1; register struct symtab *sp2,*sp3;
+#define TUNNEL 4
+register struct tshdr *tunnel;
+register int displ,nchange;
+for (;;) {/* lazy topological sort */
+       nchange=0;
+       tunnel=0;
+       for (sp1=symtab; sp1<nextsym; sp1++) {
+               if (sp1->dest== -1) continue; /* .align in .text */
+               displ=sp1->tsflag&0xFF;
+               if (sp1->tsfear==1 || displ==0xFE && sp1->tsbump) tunnel=sp1;
+               if (displ<0xFF) continue;
+               sp2= &symtab[sp1->dest];
+               if (sp1->index!=sp2->index) {
+                       yyerror("Intersegment jxxx, line %d",sp1->tsline); continue;
+               }
+               displ=sp2->value - sp1->value;
+               if (displ<-128 || displ>127) {
+                       if (1<sp1->tsfear && tunnel && tunnel->dest==sp1->dest
+                         && tunnel->index==sp1->index
+                         && tunnel->value - sp1->value>=-125) {/* entrance is 3 back */
+                               sp1->tsfear=TUNNEL; sp1->dest=((struct symtab *)tunnel)-symtab;
+                               sp1->tsflag=0xFE; continue;
+                       } else {jxxxbump(sp1,displ); tunnel=sp1; ++nchange; continue;}
+               }
+                       /* immediate lose */
+               if (displ>=0) {/* forward search for intervening jxxx */
+                       for (sp3=sp1+1; sp3<nextsym; sp3++) {
+                               if ((((struct tshdr *)sp3)->tsflag&0xFF)<0xFF
+                                       || sp3->index!=sp1->index) continue;
+                               if (sp3->value > sp2->value) break; /* beyond destination */
+                               displ += sp3->tsfear; /* assume worst case */
+                       }
+                       if (displ<=127) sp1->tsflag=0xFE; /* win! */
+               } else {/* backward search for intervening jxxx */
+                       for (sp3=sp1-1; sp3>=symtab; sp3--) {
+                               if ((((struct tshdr *)sp3)->tsflag&0xFF)<0xFF
+                                       || sp3->index!=sp1->index) continue;
+                               if (sp3->value <= sp2->value) break; /* beyond destination */
+                               displ -= sp3->tsfear; /* assume worst case */
+                       }
+                       if (displ>=-128) sp1->tsflag=0xFE; /* win! */
+               }
+       }
+       if (nchange==0) break;
+}
+for (sp1=symtab; sp1<nextsym; sp1++) /* handle .align in .text */
+       if (sp1->dest== -1 && (displ = sp1->value & (unsigned)(sp1->tsfear)))
+               jxxxbump(sp1,sp1->tsfear -= displ-1);
+}
+
+short njxxx;
+struct symtab *lastnam;
+struct tshdr *rovjxxx /* = {symtab-1}*/ ;
+
+remjxxx() {/* remove jxxx entries from symbol table */
+register struct symtab *sp1,*sp2;
+for (sp1=symtab; sp1<nextsym; sp1++) {
+       if ((((struct tshdr *)sp1)->tsflag&0xFF)<0xFE) continue;
+       sp2=sp1; /* found first */
+       for (;;) {
+               register char *cp1,*cp2;
+               while ((((struct tshdr *)sp1)->tsflag&0xFF)>=0xFE) sp1++;
+               if (sp1>=nextsym) {nextsym=sp2; return;}
+               *sp2 = *sp1;
+               sp2++; sp1++;
+       }
+} njxxx=0;
+}
+
+ijxout(op,ap,nact) struct arg *ap; {/* handle jxxx instructions */
+register struct arg *aplast;
+aplast=ap+nact-1;
+if (passno!=2) {/* record the jxxx in a special symbol table entry */
+       register struct tshdr *ts2;
+       putins(op,ap,nact); /* assume minimal length */
+       ts2=(struct tshdr *)(symalloc()); ts2->tsflag=0xFF;
+       ts2->tsfear=3; if (op==JBR) ts2->tsfear=1;
+       ts2->tsline=lineno;
+       if (lastnam==0) yyerror("jxxx destination not a label");
+       ts2->dest=lastnam-symtab; ts2->type=dotp->xtype;
+       ts2->index=dotp-usedot; ts2->value=dotp->xvalue; njxxx++;
+} else {/* pass2, resolve */
+       register long displ; register struct exp *xp; register struct tshdr *sp;
+       /* forward search for special symbol table entry */
+       while (((++rovjxxx)->tsflag&0xFF)<0xFE);
+       xp=aplast->xp;
+       if (rovjxxx->tsfear==TUNNEL) {
+               sp= &symtab[rovjxxx->dest]; xp->xvalue=sp->value;
+               if (1==sp->tsfear) xp->xvalue -= 2; /* brw */
+       }
+       if (rovjxxx->tsbump==0) putins(op,ap,nact);
+       else {
+               if (op!=JBR) {
+                       displ=xp->xvalue; xp->xvalue=rovjxxx->value+rovjxxx->tsfear;
+                       putins(op^1,ap,nact); xp->xvalue=displ;
+               }
+               putins(BRW,aplast,1);
+       }
+}}
+
+jalign(xp) register struct exp *xp; {
+       if (xp->xtype != XABS || 0>xp->xvalue || xp->xvalue>16) {
+               yyerror("Illegal `align' argument"); return;
+       }
+       flushfield(NBPW/4);
+       if (dotp<(usedot+NLOC)) {/* .align in .text */
+               if (passno!=2) {/* record in symbol table entry */
+                       register struct tshdr *ts2;
+                       ts2=(struct tshdr *)(symalloc()); ts2->tsflag=0xFF;
+                       ts2->tsfear=(1<<xp->xvalue)-1; ts2->tsline=lineno;
+                       ts2->dest= -1; ts2->type=dotp->xtype;
+                       ts2->index=dotp-usedot; ts2->value=dotp->xvalue;
+                       njxxx++; return;
+               } else while (((++rovjxxx)->tsflag&0xFF)<0xFE);
+       }
+       while (dotp->xvalue & ((1<<xp->xvalue)-1)) outb(0);
+}
+
+insout(op, ap, nact)
+struct arg *ap;
+{
+       int jxxflg;
+
+       op &= 0xFF; if (0>(jxxflg=nact)) nact= -nact;
+       if (passno!=2) {
+               register struct arg *ap2; register struct instab *ip; int i,nexp;
+               ip=itab[op]; nexp=ip->nargs;
+               if (nact<nexp) yyerror("Too few arguments");
+               if (nact>nexp) {yyerror("Too many arguments"); nact=nexp;}
+               for (ap2=ap+nact, i=nact; --i>=0;) argcompat(--ap2,ip->argtyp[i],i);
+       }
+       if (jxxflg<0) ijxout(op,ap,nact);
+       else putins(op, ap, nact);
+}
+
+argcompat(act, exp, i)
+struct arg *act;
+int exp,i;
+{
+       register at,atm;
+
+       at = act->atype; atm=at&AMASK;
+
+       if ((exp&ACCA) && (atm==AREG)) {
+               yyerror("arg %d, addressing a register",i); return;}
+       if ((exp&ACCW) && (atm==AIMM) && !(at&ASTAR)) {
+               yyerror("arg %d, modifying a constant",i); return;}
+       if (at&AINDX) {
+               if (act->areg2==017) {
+                       yyerror("arg %d, PC used as index",i); return;}
+               if (atm==AREG) {
+                       yyerror("arg %d, indexing the register file",i); return;}
+               if (atm==AIMM) {
+                       yyerror("arg %d, indexing a constant",i); return;}
+               if (((atm==ADECR) || (atm==AINCR)) && (act->areg1==act->areg2)) {
+                       yyerror("arg %d, indexing with modified register",i); return;}
+       }
+}
+
+int d124 = {4};
+int len124[] = {0,LEN1,LEN2,0,LEN4};
+char mod124[] = {0,0x00,0x20,0,0x40};
+
+putins(op, ap, n)
+register struct arg *ap;
+{
+/* op had better be positive */
+       register struct exp *xp;
+       register int a; int i,xtrab;
+
+       if (passno!=2) {
+               dotp->xvalue += n+1;    /* 1 for the opcode, at least 1 per arg */
+               for (i=0; i<n; i++,ap++) {/* some args take more than 1 byte */
+                       a=ap->atype;
+                       if (a&AINDX) dotp->xvalue++;
+                       switch (a&~(AINDX|ASTAR)) {
+                               case AEXP: {
+                                       a=itab[op]->argtyp[i];
+                                       if (a==ACCB+TYPB) break;
+                                       if (a==ACCB+TYPW) {dotp->xvalue++; break;}
+                                       dotp->xvalue += d124; break;
+                               }
+                               case ADISP: {
+                                       xp=ap->xp;
+                                       if ((xp->xtype&XTYPE)!=XABS || xp->xtype&XFORW)
+                                               {dotp->xvalue += d124; break;}
+                                       if (xp->xvalue==0 && !(a&ASTAR)) break;
+                                       dotp->xvalue++;
+                                       if ((xp->xvalue<-128) || (xp->xvalue>127)) dotp->xvalue++;
+                                       if ((xp->xvalue<-32768) || (xp->xvalue>32767))
+                                               dotp->xvalue += 2;
+                                       break;
+                               }
+                               case AIMM: {
+                                       if (ap->atype&ASTAR) a=TYPL;
+                                       else {
+                                               xp=ap->xp;
+                                               if ((xp->xtype&XTYPE)==XABS && !(xp->xtype&XFORW)
+                                                       && xp->xvalue>=0 && xp->xvalue<=63) break;
+                                               a=itab[op]->argtyp[i];
+                                               if (a&ACCA) a=TYPL; else a &= TYPMASK;
+                                       }
+                                       switch (a) {
+                                               case TYPD: case TYPF:
+                                                       if (xp->yvalue==0 &&
+                                                          (xp->xvalue & 0x000043f0)==xp->xvalue) break;
+                                                       if (a==TYPF) dotp->xvalue -= 4;
+                                               case TYPQ: dotp->xvalue += 4;
+                                               case TYPL: dotp->xvalue += 2;
+                                               case TYPW: dotp->xvalue++;
+                                               case TYPB: dotp->xvalue++;
+                                       }
+                               }
+                       }
+               }
+               return;
+       }
+       /* pass2 here */
+       outb(op); /* the opcode */
+       for (i=0; i<n; i++,ap++) {/* now for the arguments */
+               a=ap->atype; xp=ap->xp; xtrab=0;
+               if (a&AINDX) {outb(0x40 | ap->areg2); a &= ~AINDX;}
+               if (a&ASTAR) {ap->areg1 |= 0x10; a &= ~ASTAR;}
+               switch (a) {
+                       case AREG:  ap->areg1 |= 0x50; break; /* %r */
+                       case ABASE: ap->areg1 |= 0x60; break; /* (%r) */
+                       case ADECR: ap->areg1 |= 0x70; break; /* -(%r) */
+                       case AINCR: ap->areg1 |= 0x80; break; /* (%r)+ */
+                       case AEXP: {/* expr */
+                               a=itab[op]->argtyp[i];
+                               if (a==ACCB+TYPB) {
+                                       ap->areg1=a=xp->xvalue - dotp->xvalue -1;
+                                       if (a<-128 || a>127) yyerror("Branch too far"); break;
+                               }
+                               if (a==ACCB+TYPW) {
+                                       ap->areg1=a=xp->xvalue -= dotp->xvalue +2; xp->xtype=XABS;
+                                       if (a<-32768 || a>32767) yyerror("Branch too far");
+                                       xp->xvalue = a>>8; xtrab=LEN1; break;
+                               }
+                               /* reduces to expr(pc) mode */
+                               ap->areg1 |= (0xAF+mod124[d124]); xtrab=len124[d124]+PCREL; break;
+                       }
+                       case ADISP: {/* expr(%r) */
+                               ap->areg1 |= 0xA0;
+                               if ((xp->xtype&XTYPE)!=XABS || xp->xtype&XFORW)
+                                       {ap->areg1 += mod124[d124]; xtrab=len124[d124]; break;}
+                               if (xp->xvalue==0 && !(ap->areg1&0x10)) {ap->areg1 ^= 0xC0; break;}
+                               xtrab=LEN1;
+                               if ((xp->xvalue<-128) || (xp->xvalue>127))
+                                       {ap->areg1 += 0x20; xtrab=LEN2;}
+                               if ((xp->xvalue<-32768) || (xp->xvalue>32767))
+                                       {ap->areg1 += 0x20; xtrab=LEN4;}
+                               break;
+                       }
+                       case AIMM: { /* $expr */
+                               if (ap->atype&ASTAR) a=TYPL;
+                               else {
+                                       if ((xp->xtype&XTYPE)==XABS && !(xp->xtype&XFORW) &&
+                                               xp->xvalue>=0 && xp->xvalue<=63) {ap->areg1=xp->xvalue; break;}
+                                       a=itab[op]->argtyp[i];
+                                       if (a&ACCA) a=TYPL; else a &= TYPMASK;
+                               }
+                               ap->areg1 |= 0x8F;
+                               switch (a) {
+                                       case TYPD: case TYPF:
+                                               if (xp->yvalue==0 &&
+                                                  (xp->xvalue & 0x000043f0)==xp->xvalue) {
+                                                       ap->areg1 = xp->xvalue>>4; break;
+                                               }
+                                               if (a==TYPF) {xtrab = LEN4; break;}
+                                       case TYPQ: xtrab = LEN8; break;
+                                       case TYPL: xtrab = LEN4; break;
+                                       case TYPW: xtrab = LEN2; break;
+                                       case TYPB: xtrab = LEN1; break;
+                               }
+                       }
+               }
+               outb(ap->areg1);/* first byte to describe arg */
+               if (xtrab) outrel(&xp->xvalue,xtrab,xp->xtype,xp->xname);
+       }
+}
+
+get2(f)
+register FILE *f;
+{
+       short r;
+       register char *p;
+       r = 0;
+       p = (char *)&r;
+       *p++ = getc(f);
+       *p = getc(f);
+       return(r);
+}
+
+put2(v, f)
+register FILE *f;
+short v;
+{
+       register char *p;
+       short lv;
+
+       p = (char *)&lv;
+       lv = v;
+       putc(*p++, f);
+       putc(*p, f);
+}
+
+setindices() {
+       register int i;
+       register struct symtab *sp;
+       
+       i = 0;
+       for (sp=symtab; sp<nextsym; sp++) {
+               if ((((struct tshdr *)sp)->tsflag&0xFF)<0xFE) {
+                       sp->index = i++;
+               }
+       }
+}
diff --git a/usr/src/cmd/as/as21.s b/usr/src/cmd/as/as21.s
deleted file mode 100644 (file)
index d4a2263..0000000
+++ /dev/null
@@ -1,281 +0,0 @@
-/
-/
-
-/ a21 -- pdp-11 assembler pass 2 
-
-main:
-       sys     signal; 2; 1
-       ror     r0
-       bcs     1f
-       sys     signal; 2; saexit
-1:
-       jmp     start
-
-/ set up sizes and origins
-
-go:
-
-/ read in symbol table
-
-       mov     $usymtab,r1
-1:
-       jsr     pc,getw
-       bvs     1f
-       add     $14,symsiz              / count symbols
-       jsr     pc,getw
-       jsr     pc,getw
-       jsr     pc,getw
-       jsr     pc,getw
-       mov     r4,r0
-       bic     $!37,r0
-       cmp     r0,$2                   /text
-       blo     2f
-       cmp     r0,$3                   /data
-       bhi     2f
-       add     $31,r4                  /mark "estimated"
-       mov     r4,(r1)+
-       jsr     pc,getw
-       mov     r4,(r1)+
-       br      3f
-2:
-       clr     (r1)+
-       clr     (r1)+
-       jsr     pc,getw
-3:
-       jsr     pc,setbrk
-       br      1b
-1:
-
-/ read in f-b definitions
-
-       mov     r1,fbbufp
-       movb    fbfil,fin
-       clr     ibufc
-1:
-       jsr     pc,getw
-       bvs     1f
-       add     $31,r4                  / "estimated"
-       mov     r4,(r1)+
-       jsr     pc,getw
-       mov     r4,(r1)+
-       jsr     pc,setbrk
-       br      1b
-1:
-       mov     r1,endtable
-       mov     $100000,(r1)+
-
-/ set up input text file; initialize f-b table
-
-       jsr     pc,setup
-/ do pass 1
-
-       jsr     pc,assem
-
-/ prepare for pass 2
-       cmp     outmod,$777
-       beq     1f
-       jmp     aexit
-1:
-       clr     dot
-       mov     $2,dotrel
-       mov     $..,dotdot
-       clr     brtabp
-       movb    fin,r0
-       sys     close
-       jsr     r5,ofile; a.tmp1
-       movb    r0,fin
-       clr     ibufc
-       jsr     pc,setup
-       inc     passno
-       inc     bsssiz
-       bic     $1,bsssiz
-       mov     txtsiz,r1
-       inc     r1
-       bic     $1,r1
-       mov     r1,txtsiz
-       mov     datsiz,r2
-       inc     r2
-       bic     $1,r2
-       mov     r2,datsiz
-       mov     r1,r3
-       mov     r3,datbase      / txtsiz
-       mov     r3,savdot+2
-       add     r2,r3
-       mov     r3,bssbase      / txtsiz+datsiz
-       mov     r3,savdot+4
-       clr     r0
-       asl     r3
-       adc     r0
-       add     $20,r3
-       adc     r0
-       mov     r3,symseek+2    / 2*txtsiz+2*datsiz+20
-       mov     r0,symseek
-       sub     r2,r3
-       sbc     r0
-       mov     r3,drelseek+2   / 2*txtsiz+datsiz
-       mov     r0,drelseek
-       sub     r1,r3
-       sbc     r0
-       mov     r3,trelseek+2   / txtsiz+datsiz+20
-       mov     r0,trelseek
-       sub     r2,r3
-       sbc     r0
-       mov     r0,datseek
-       mov     r3,datseek+2    / txtsiz+20
-       mov     $usymtab,r1
-1:
-       jsr     pc,doreloc
-       add     $4,r1
-       cmp     r1,endtable
-       blo     1b
-       clr     r0
-       clr     r1
-       jsr     r5,oset; txtp
-       mov     trelseek,r0
-       mov     trelseek+2,r1
-       jsr     r5,oset; relp
-       mov     $8.,r2
-       mov     $txtmagic,r1
-1:
-       mov     (r1)+,r0
-       jsr     r5,putw; txtp
-       dec     r2
-       bne     1b
-       jsr     pc,assem
-
-/polish off text and relocation
-
-       jsr     r5,flush; txtp
-       jsr     r5,flush; relp
-
-/ append full symbol table
-
-       mov     symf,r0
-       mov     r0,fin
-       sys     lseek; 0; 0; 0
-       clr     ibufc
-       mov     symseek,r0
-       mov     symseek+2,r1
-       jsr     r5,oset; txtp
-       mov     $usymtab,r1
-1:
-       jsr     pc,getw
-       bvs     1f
-       mov     r4,r0
-       jsr     r5,putw; txtp
-       jsr     pc,getw
-       mov     r4,r0
-       jsr     r5,putw; txtp
-       jsr     pc,getw
-       mov     r4,r0
-       jsr     r5,putw; txtp
-       jsr     pc,getw
-       mov     r4,r0
-       jsr     r5,putw; txtp
-       mov     (r1)+,r0
-       jsr     r5,putw; txtp
-       mov     (r1)+,r0
-       jsr     r5,putw; txtp
-       jsr     pc,getw
-       jsr     pc,getw
-       br      1b
-1:
-       jsr     r5,flush; txtp
-       jmp     aexit
-
-       .data
-saexit:
-       mov     pc,errflg
-
-aexit:
-       mov     a.tmp1,0f
-       sys     unlink; 0:..
-       mov     a.tmp2,0f
-       sys     unlink; 0:..
-       mov     a.tmp3,0f
-       sys     unlink; 0:..
-       tst     errflg
-       bne     2f
-       sys     umask; 0
-       bic     r0,outmod
-       sys     chmod; a.outp2:a.out; outmod: 777
-       clr     r0
-       br      1f
-2:
-       mov     $2,r0
-1:
-       sys     exit
-       .text
-
-filerr:
-       mov     *(r5),r5
-1:
-       movb    (r5)+,ch
-       beq     1f
-       mov     $1,r0
-       sys     write; ch; 1
-       br      1b
-1:
-       mov     $1,r0
-       sys     write; qnl; 2
-       jmp     saexit
-
-doreloc:
-       movb    (r1),r0
-       bne     1f
-       bisb    defund,(r1)
-1:
-       bic     $!37,r0
-       cmp     r0,$5
-       bhis    1f
-       cmp     r0,$3
-       blo     1f
-       beq     2f
-       add     bssbase,2(r1)
-       rts     pc
-2:
-       add     datbase,2(r1)
-1:
-       rts     pc
-
-setbrk:
-       mov     r1,-(sp)
-       add     $20,r1
-       cmp     r1,0f
-       blo     1f
-       add     $512.,0f
-       sys     indir; 9f
-       .data
-9:     sys     break; 0: end
-       .text
-1:
-       mov     (sp)+,r1
-       rts     pc
-
-setup:
-       mov     $curfb,r4
-1:
-       clr     (r4)+
-       cmp     r4,$curfb+40.
-       blo     1b
-       mov     txtfil,fin
-       clr     ibufc
-       clr     r4
-1:
-       jsr     pc,fbadv
-       tstb    (r4)+
-       cmp     r4,$10.
-       blt     1b
-       rts     pc
-
-ofile:
-       mov     *(r5),0f
-       sys     indir; 9f
-       .data
-9:     sys     open; 0:..; 0
-       .text
-       bes     1f
-       tst     (r5)+
-       rts     r5
-1:
-       jmp     filerr
diff --git a/usr/src/cmd/as/as22.s b/usr/src/cmd/as/as22.s
deleted file mode 100644 (file)
index 1fbdb3b..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-/
-/
-
-/ a2 -- pdp-11 assembler pass 2
-
-outw:
-       cmp     dot-2,$4
-       beq     9f
-       bit     $1,dot
-       bne     1f
-       add     $2,dot
-       tstb    passno
-       beq     8f
-       clr     -(sp)
-       rol     r3
-       adc     (sp)
-       asr     r3              / get relative pc bit
-       cmp     r3,$40
-       bne     2f
-/ external references
-       mov     $666,outmod             / make nonexecutable
-       mov     xsymbol,r3
-       sub     $usymtab,r3
-       asl     r3
-       bis     $4,r3           / external relocation
-       br      3f
-2:
-       bic     $40,r3          / clear any ext bits
-       cmp     r3,$5
-       blo     4f
-       cmp     r3,$33          / est. text, data
-       beq     6f
-       cmp     r3,$34
-       bne     7f
-6:
-       jsr     r5,error; 'r
-7:
-       mov     $1,r3           / make absolute
-4:
-       cmp     r3,$2
-       blo     5f
-       cmp     r3,$4
-       bhi     5f
-       tst     (sp)
-       bne     4f
-       add     dotdot,r2
-       br      4f
-5:
-       tst     (sp)
-       beq     4f
-       sub     dotdot,r2
-4:
-       dec     r3
-       bpl     3f
-       clr     r3
-3:
-       asl     r3
-       bis     (sp)+,r3
-       mov     r2,r0
-       jsr     r5,putw; txtp
-       mov     tseekp,r0
-       add     $2,2(r0)
-       adc     (r0)
-       mov     r3,r0
-       jsr     r5,putw; relp
-       mov     rseekp,r0
-       add     $2,2(r0)
-       adc     (r0)
-8:
-       rts     pc
-1:
-       jsr     r5,error; 'o
-       clr     r3
-       jsr     pc,outb
-       rts     pc
-
-9:
-       jsr     r5,error; 'x
-       rts     pc
-
-outb:
-       cmp     dot-2,$4                / test bss mode
-       beq     9b
-       cmp     r3,$1
-       blos    1f
-       jsr     r5,error; 'r
-1:
-       tstb    passno
-       beq     2f
-       mov     r2,r0
-       bit     $1,dot
-       bne     1f
-       jsr     r5,putw; txtp
-       clr     r0
-       jsr     r5,putw; relp
-       mov     tseekp,r0
-       add     $2,2(r0)
-       adc     (r0)
-       mov     rseekp,r0
-       add     $2,2(r0)
-       adc     (r0)
-       br      2f
-1:
-       mov     txtp,r0
-       movb    r2,-1(r0)
-2:
-       inc     dot
-       rts     pc
-
-error:
-       mov     pc,errflg
-       mov     $666,outmod             / make nonexecutable
-       mov     r3,-(sp)
-       mov     r2,-(sp)
-       mov     r1,-(sp)
-       mov     r0,-(sp)
-       mov     $argb,r1
-1:
-       movb    (r1),ch
-       beq     1f
-       clrb    (r1)+
-       mov     $1,r0
-       sys     write; ch; 1
-       br      1b
-1:
-       mov     (r5)+,r0
-       movb    r0,0f
-       mov     line,r3
-       mov     $0f+6,r0
-       mov     $4,r1
-2:
-       clr     r2
-       dvd     $10.,r2
-       add     $'0,r3
-       movb    r3,-(r0)
-       mov     r2,r3
-       sob     r1,2b
-       mov     $1,r0
-       sys     write; 0f; 7
-       mov     (sp)+,r0
-       mov     (sp)+,r1
-       mov     (sp)+,r2
-       mov     (sp)+,r3
-       rts     r5
-
-       .data
-0:     <f xxxx\n>
-       .even
-       .text
-
-betwen:
-       cmp     r0,(r5)+
-       blt     1f
-       cmp     (r5)+,r0
-       blt     2f
-1:
-       tst     (r5)+
-2:
-       rts     r5
-
diff --git a/usr/src/cmd/as/as23.s b/usr/src/cmd/as/as23.s
deleted file mode 100644 (file)
index 26f16c8..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-/
-/
-
-/ a3 -- pdp-11 assembler pass 2
-
-assem:
-       jsr     pc,readop
-       cmp     r4,$5
-       beq     2f
-       cmp     r4,$'<
-       beq     2f
-       jsr     pc,checkeos
-               br eal1
-       mov     r4,-(sp)
-       cmp     (sp),$1
-       bne     1f
-       mov     $2,(sp)
-       jsr     pc,getw
-       mov     r4,numval
-1:
-       jsr     pc,readop
-       cmp     r4,$'=
-       beq     4f
-       cmp     r4,$':
-       beq     1f
-       mov     r4,savop
-       mov     (sp)+,r4
-2:
-       jsr     pc,opline
-dotmax:
-       tstb    passno
-       bne     eal1
-       movb    dotrel,r0
-       asl     r0
-       cmp     dot,txtsiz-4(r0)
-       blos    ealoop
-       mov     dot,txtsiz-4(r0)
-eal1:
-       jmp     ealoop
-1:
-       mov     (sp)+,r4
-       cmp     r4,$200
-       bhis    1f
-       cmp     r4,$2
-       beq     3f
-       jsr     r5,error; 'x
-       br      assem
-1:
-       tstb    passno
-       bne     2f
-       movb    (r4),r0
-       bic     $!37,r0
-       beq     5f
-       cmp     r0,$33
-       blt     6f
-       cmp     r0,$34
-       ble     5f
-6:
-       jsr     r5,error; 'm
-5:
-       bic     $37,(r4)
-       bis     dotrel,(r4)
-       mov     2(r4),brdelt
-       sub     dot,brdelt
-       mov     dot,2(r4)
-       br      assem
-2:
-       cmp     dot,2(r4)
-       beq     assem
-       jsr     r5,error; 'p
-       br      assem
-3:
-       mov     numval,r4
-       jsr     pc,fbadv
-       asl     r4
-       mov     curfb(r4),r0
-       movb    dotrel,(r0)
-       mov     2(r0),brdelt
-       sub     dot,brdelt
-       mov     dot,2(r0)
-       br      assem
-4:
-       jsr     pc,readop
-       jsr     pc,expres
-       mov     (sp)+,r1
-       cmp     r1,$symtab      /test for dot
-       bne     1f
-       bic     $40,r3
-       cmp     r3,dotrel       / can't change relocation
-       bne     2f
-       cmp     r3,$4           / bss
-       bne     3f
-       mov     r2,dot
-       br      dotmax
-3:
-       sub     dot,r2
-       bmi     2f
-       mov     r2,-(sp)
-3:
-       dec     (sp)
-       bmi     3f
-       clr     r2
-       mov     $1,r3
-       jsr     pc,outb
-       br      3b
-3:
-       tst     (sp)+
-       br      dotmax
-2:
-       jsr     r5,error; '.
-       br      ealoop
-1:
-       cmp     r3,$40
-       bne     1f
-       jsr     r5,error; 'r
-1:
-       bic     $37,(r1)
-       bic     $!37,r3
-       bne     1f
-       clr     r2
-1:
-       bisb    r3,(r1)
-       mov     r2,2(r1)
-
-ealoop:
-       cmp     r4,$'\n
-       beq     1f
-       cmp     r4,$'\e
-       bne     9f
-       rts     pc
-1:
-       inc     line
-9:
-       jmp     assem
-
-checkeos:
-       cmp     r4,$'\n
-       beq     1f
-       cmp     r4,$';
-       beq     1f
-       cmp     r4,$'\e
-       beq     1f
-       add     $2,(sp)
-1:
-       rts     pc
-
-fbadv:
-       asl     r4
-       mov     nxtfb(r4),r1
-       mov     r1,curfb(r4)
-       bne     1f
-       mov     fbbufp,r1
-       br      2f
-1:
-       add     $4,r1
-2:
-       cmpb    1(r1),r4
-       beq     1f
-       tst     (r1)
-       bpl     1b
-1:
-       mov     r1,nxtfb(r4)
-       asr     r4
-       rts     pc
-
diff --git a/usr/src/cmd/as/as24.s b/usr/src/cmd/as/as24.s
deleted file mode 100644 (file)
index b192663..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/
-/
-
-/ a4 -- pdp-11 assembler pass 2
-
-oset:
-       mov     r2,-(sp)
-       mov     r3,-(sp)
-       mov     (r5)+,r3
-       mov     r1,r2
-       bic     $!777,r1
-       add     r3,r1
-       add     $8,r1
-       mov     r1,(r3)+        / next slot
-       mov     r3,r1
-       add     $1006,r1
-       mov     r1,(r3)+        / buf max
-       mov     r0,(r3)+
-       mov     r2,(r3)+        / seek addr
-       mov     (sp)+,r3
-       mov     (sp)+,r2
-       rts     r5
-
-putw:
-       mov     r1,-(sp)
-       mov     r2,-(sp)
-       mov     (r5)+,r2
-       mov     (r2)+,r1        / slot
-       cmp     r1,(r2)         / buf max
-       bhis    1f
-       mov     r0,(r1)+
-       mov     r1,-(r2)
-       br      2f
-1:
-       tst     (r2)+
-       mov     r0,-(sp)
-       jsr     r5,flush1
-       mov     (sp)+,r0
-       mov     r0,*(r2)+
-       add     $2,-(r2)
-2:
-       mov     (sp)+,r2
-       mov     (sp)+,r1
-       rts     r5
-
-flush:
-       mov     (r5)+,r2
-       cmp     (r2)+,(r2)+
-flush1:
-       mov     (r2)+,0f
-       mov     (r2)+,r1
-       mov     r1,0f+2         / seek address
-       mov     fout,r0
-       sys     indir; 9f
-       .data
-9:     sys     lseek; 0:..; ..; 0
-       .text
-       bic     $!777,r1
-       add     r2,r1           / write address
-       mov     r1,0f
-       mov     r2,r0
-       bis     $777,-(r2)
-       add     $1,(r2)         / new seek addr
-       adc     -(r2)
-       cmp     -(r2),-(r2)
-       sub     (r2),r1
-       neg     r1
-       mov     r1,0f+2         / count
-       mov     r0,(r2)         / new next slot
-       mov     fout,r0
-       sys     indir; 9f
-       jes     wrterr
-       .data
-9:     sys     write; 0:..; ..
-       .text
-       rts     r5
-
-wrterr:
-       mov     $1,r0
-       sys     write; 9f; 8f-9f
-       jmp     saexit
-9:     <as: write error on output\n>; 8:
-
-readop:
-       mov     savop,r4
-       beq     1f
-       clr     savop
-       rts     pc
-1:
-       jsr     pc,getw1
-       cmp     r4,$200
-       blo     1f
-       cmp     r4,$4000
-       blo     2f
-       add     $usymtab-4000,r4
-       rts     pc
-2:
-       add     $symtab-1000,r4
-1:
-       rts     pc
-
-getw:
-       mov     savop,r4
-       beq     getw1
-       clr     savop
-       rts     pc
-getw1:
-       dec     ibufc
-       bgt     1f
-       movb    fin,r0
-       sys     read; inbuf; 512.
-       bes     3f
-       asr     r0
-       mov     r0,ibufc
-       bne     2f
-3:
-       mov     $4,r4
-       sev
-       rts     pc
-2:
-       mov     $inbuf,ibufp
-1:
-       mov     *ibufp,r4
-       add     $2,ibufp
-       rts     pc
diff --git a/usr/src/cmd/as/as25.s b/usr/src/cmd/as/as25.s
deleted file mode 100644 (file)
index f8aaf11..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-/
-/
-
-/ as25 is empty
diff --git a/usr/src/cmd/as/as26.s b/usr/src/cmd/as/as26.s
deleted file mode 100644 (file)
index b818624..0000000
+++ /dev/null
@@ -1,562 +0,0 @@
-/
-/
-
-/ a6 -- pdp-11 assembler pass 2
-
-opline:
-       mov     r4,r0
-       jsr     r5,betwen; 0; 177
-               br 2f
-       cmp     r4,$5
-       beq     opeof
-       cmp     r4,$'<
-       bne     xpr
-       jmp     opl17
-xxpr:
-       tst     (sp)+
-xpr:
-       jsr     pc,expres
-       jsr     pc,outw
-       rts     pc
-2:
-       movb    (r4),r0
-       cmp     r0,$24          /reg
-       beq     xpr
-       cmp     r0,$33          /est text
-       beq     xpr
-       cmp     r0,$34          / est data
-       beq     xpr
-       jsr     r5,betwen; 5; 36
-               br xpr
-       mov     2(r4),-(sp)
-       mov     r0,-(sp)
-       jsr     pc,readop
-       mov     (sp)+,r0
-       asl     r0
-       mov     $adrbuf,r5
-       clr     swapf
-       mov     $-1,rlimit
-       jmp     *1f-10.(r0)
-
-1:
-       opl5
-       opl6
-       opl7
-       opl10
-       opl11
-       opl12
-       opl13
-       opl14
-       opl15
-       opl16
-       opl17
-       opl20
-       opl21
-       opl22
-       opl23
-       xxpr
-       opl25
-       opl26
-       opl27
-       opl30
-       opl31
-       opl32
-       xxpr
-       xxpr
-       opl35
-       opl36
-
-opeof:
-       mov     $1,line
-       mov     $20,-(sp)
-       mov     $argb,r1
-1:
-       jsr     pc,getw
-       tst     r4
-       bmi     1f
-       movb    r4,(r1)+
-       dec     (sp)
-       bgt     1b
-       tstb    -(r1)
-       br      1b
-1:
-       movb    $'\n,(r1)+
-       clrb    (r1)+
-       tst     (sp)+
-       rts     pc
-
-opl30: / mpy, dvd etc
-       inc     swapf
-       mov     $1000,rlimit
-       br      opl13
-
-opl14:         / flop freg,fsrc
-       inc     swapf
-
-opl5:          / flop src,freg
-       mov     $400,rlimit
-
-/double
-opl13:
-       jsr     pc,addres
-op2a:
-       mov     r2,-(sp)
-       jsr     pc,readop
-op2b:
-       jsr     pc,addres
-       tst     swapf
-       beq     1f
-       mov     (sp),r0
-       mov     r2,(sp)
-       mov     r0,r2
-1:
-       swab    (sp)
-       asr     (sp)
-       asr     (sp)
-       cmp     (sp),rlimit
-       blo     1f
-       jsr     r5,error; 'x
-1:
-       bis     (sp)+,r2
-       bis     (sp)+,r2
-       clr     r3
-       jsr     pc,outw
-       mov     $adrbuf,r1
-1:
-       cmp     r1,r5
-       bhis    1f
-       mov     (r1)+,r2
-       mov     (r1)+,r3
-       mov     (r1)+,xsymbol
-       jsr     pc,outw
-       br      1b
-1:
-       rts     pc
-
-opl15:         / single operand
-       clr     -(sp)
-       br      op2b
-
-opl12:         / movf
-       mov     $400,rlimit
-       jsr     pc,addres
-       cmp     r2,$4           / see if source is fregister
-       blo     1f
-       inc     swapf
-       br      op2a
-1:
-       mov     $174000,(sp)
-       br      op2a
-
-/ jbr
-opl35:
-/ jeq, jne, etc
-opl36:
-       jsr     pc,expres
-       tstb    passno
-       bne     1f
-       mov     r2,r0
-       jsr     pc,setbr
-       tst     r2
-       beq     2f
-       cmp     (sp),$br
-       beq     2f
-       add     $2,r2
-2:
-       add     r2,dot          / if doesn't fit
-       add     $2,dot
-       tst     (sp)+
-       rts     pc
-1:
-       jsr     pc,getbr
-       bcc     dobranch
-       mov     (sp)+,r0
-       mov     r2,-(sp)
-       mov     r3,-(sp)
-       cmp     r0,$br
-       beq     2f
-       mov     $402,r2
-       xor     r0,r2           / flip cond, add ".+6"
-       mov     $1,r3
-       jsr     pc,outw
-2:
-       mov     $1,r3
-       mov     $jmp+37,r2
-       jsr     pc,outw
-       mov     (sp)+,r3
-       mov     (sp)+,r2
-       jsr     pc,outw
-       rts     pc
-
-/sob
-opl31: / sob
-       jsr     pc,expres
-       jsr     pc,checkreg
-       swab    r2
-       asr     r2
-       asr     r2
-       bis     r2,(sp)
-       jsr     pc,readop
-       jsr     pc,expres
-       tstb    passno
-       beq     3f
-       sub     dot,r2
-       neg     r2
-       mov     r2,r0
-       jsr     r5,betwen; -2; 175
-               br 2f
-       add     $4,r2
-       br      1f
-
-/branch
-opl6:
-       jsr     pc,expres
-       tstb    passno
-       beq     3f
-dobranch:
-       sub     dot,r2
-       mov     r2,r0
-       jsr     r5,betwen; -254.; 256.
-               br 2f
-1:
-       bit     $1,r2
-       bne     2f
-       cmp     r3,dot-2        / same relocation as .
-       bne     2f
-       asr     r2
-       dec     r2
-       bic     $177400,r2
-3:
-       bis     (sp)+,r2
-       clr     r3
-       jsr     pc,outw
-       rts     pc
-2:
-       jsr     r5,error; 'b
-       clr     r2
-       br      3b
-
-/jsr
-opl7:
-       jsr     pc,expres
-       jsr     pc,checkreg
-       jmp     op2a
-
-/ rts
-opl10:
-       jsr     pc,expres
-       jsr     pc,checkreg
-       br      1f
-
-/ sys, emt etc
-opl11:
-       jsr     pc,expres
-       cmp     r2,$256.
-       bhis    0f
-       cmp     r3,$1
-       ble     1f
-0:
-       jsr     pc,errora
-1:
-       bis     (sp)+,r2
-       jsr     pc,outw
-       rts     pc
-
-/ .byte
-opl16:
-       jsr     pc,expres
-       jsr     pc,outb
-       cmp     r4,$',
-       bne     1f
-       jsr     pc,readop
-       br      opl16
-1:
-       tst     (sp)+
-       rts     pc
-
-/ < (.ascii)
-opl17:
-       jsr     pc,getw
-       mov     $1,r3
-       mov     r4,r2
-       bmi     2f
-       bic     $!377,r2
-       jsr     pc,outb
-       br      opl17
-2:
-       jsr     pc,getw
-       rts     pc
-
-/.even
-opl20:
-       bit     $1,dot
-       beq     1f
-       cmp     dot-2,$4
-       beq     2f              / bss mode
-       clr     r2
-       clr     r3
-       jsr     pc,outb
-       br      1f
-2:
-       inc     dot
-1:
-       tst     (sp)+
-       rts     pc
-opl21: /if
-       jsr     pc,expres
-opl22:
-oplret:
-       tst     (sp)+
-       rts     pc
-
-
-/.globl
-opl23:
-       cmp     r4,$200
-       blo     1f
-       bisb    $40,(r4)
-       jsr     pc,readop
-       cmp     r4,$',
-       bne     1f
-       jsr     pc,readop
-       br      opl23
-1:
-       tst     (sp)+
-       rts     pc
-
-/ .text, .data, .bss
-opl25:
-opl26:
-opl27:
-       inc     dot
-       bic     $1,dot
-       mov     r0,-(sp)
-       mov     dot-2,r1
-       asl     r1
-       mov     dot,savdot-4(r1)
-       tstb    passno
-       beq     1f
-       jsr     r5,flush; txtp
-       jsr     r5,flush; relp
-       mov     (sp),r2
-       asl     r2
-       add     $txtseek-[4*25],r2
-       mov     r2,tseekp
-       mov     (r2),r0
-       mov     2(r2),r1
-       jsr     r5,oset; txtp
-       add     $trelseek-txtseek,r2
-       mov     (r2),r0
-       mov     2(r2),r1
-       mov     r2,rseekp
-       jsr     r5,oset; relp
-1:
-       mov     (sp)+,r0
-       mov     savdot-[2*25](r0),dot
-       asr     r0
-       sub     $25-2,r0
-       mov     r0,dot-2        / new . relocation
-       tst     (sp)+
-       rts     pc
-
-opl32:
-       cmp     r4,$200
-       blo     1f
-       mov     r4,-(sp)
-       jsr     pc,readop
-       jsr     pc,readop
-       jsr     pc,expres
-       mov     (sp)+,r0
-       bit     $37,(r0)
-       bne     1f
-       bis     $40,(r0)
-       mov     r2,2(r0)
-1:
-       tst     (sp)+
-       rts     pc
-
-addres:
-       clr     -(sp)
-4:
-       cmp     r4,$'(
-       beq     alp
-       cmp     r4,$'-
-       beq     amin
-       cmp     r4,$'$
-       beq     adoll
-       cmp     r4,$'*
-       bne     getx
-       jmp     astar
-getx:
-       jsr     pc,expres
-       cmp     r4,$'(
-       bne     2f
-       jsr     pc,readop
-       mov     r2,(r5)+
-       mov     r3,(r5)+
-       mov     xsymbol,(r5)+
-       jsr     pc,expres
-       jsr     pc,checkreg
-       jsr     pc,checkrp
-       bis     $60,r2
-       bis     (sp)+,r2
-       rts     pc
-
-2:
-       cmp     r3,$24
-       bne     1f
-       jsr     pc,checkreg
-       bis     (sp)+,r2
-       rts     pc
-1:
-       mov     r3,-(sp)
-       bic     $40,r3
-       mov     (sp)+,r3
-       bis     $100000,r3
-       sub     dot,r2
-       sub     $4,r2
-       cmp     r5,$adrbuf
-       beq     1f
-       sub     $2,r2
-1:
-       mov     r2,(r5)+                / index
-       mov     r3,(r5)+                / index reloc.
-       mov     xsymbol,(r5)+           / index global
-       mov     $67,r2                  / address mode
-       bis     (sp)+,r2
-       rts     pc
-
-alp:
-       jsr     pc,readop
-       jsr     pc,expres
-       jsr     pc,checkrp
-       jsr     pc,checkreg
-       cmp     r4,$'+
-       beq     1f
-       tst     (sp)+
-       beq     2f
-       bis     $70,r2
-       clr     (r5)+
-       clr     (r5)+
-       mov     xsymbol,(r5)+
-       rts     pc
-2:
-       bis     $10,r2
-       rts     pc
-1:
-       jsr     pc,readop
-       bis     $20,r2
-       bis     (sp)+,r2
-       rts     pc
-
-amin:
-       jsr     pc,readop
-       cmp     r4,$'(
-       beq     1f
-       mov     r4,savop
-       mov     $'-,r4
-       br      getx
-1:
-       jsr     pc,readop
-       jsr     pc,expres
-       jsr     pc,checkrp
-       jsr     pc,checkreg
-       bis     (sp)+,r2
-       bis     $40,r2
-       rts     pc
-
-adoll:
-       jsr     pc,readop
-       jsr     pc,expres
-       mov     r2,(r5)+
-       mov     r3,(r5)+
-       mov     xsymbol,(r5)+
-       mov     (sp)+,r2
-       bis     $27,r2
-       rts     pc
-
-astar:
-       tst     (sp)
-       beq     1f
-       jsr     r5,error; '*
-1:
-       mov     $10,(sp)
-       jsr     pc,readop
-       jmp     4b
-
-errora:
-       jsr     r5,error; 'a
-       rts     pc
-
-checkreg:
-       cmp     r2,$7
-       bhi     1f
-       cmp     r1,$1
-       blos    2f
-       cmp     r3,$5
-       blo     1f
-2:
-       rts     pc
-1:
-       jsr     pc,errora
-       clr     r2
-       clr     r3
-       rts     pc
-
-errore:
-       jsr     r5,error; 'e
-       rts     pc
-
-checkrp:
-       cmp     r4,$')
-       beq     1f
-       jsr     r5,error; ')
-       rts     pc
-1:
-       jsr     pc,readop
-       rts     pc
-
-setbr:
-       mov     brtabp,r1
-       cmp     r1,$brlen
-       blt     1f
-       mov     $2,r2
-       rts     pc
-1:
-       inc     brtabp
-       clr     -(sp)
-       sub     dot,r0
-       ble     1f
-       sub     brdelt,r0
-1:
-       jsr     r5,betwen; -254.; 256.
-               br 1f
-       br      2f
-1:
-       mov     r1,-(sp)
-       bic     $!7,(sp)
-       mov     $1,r0
-       ash     (sp)+,r0
-       ash     $-3,r1
-       bisb    r0,brtab(r1)
-       mov     $2,(sp)
-2:
-       mov     (sp)+,r2
-       rts     pc
-
-getbr:
-       mov     brtabp,r1
-       cmp     r1,$brlen
-       blt     1f
-       sec
-       rts     pc
-1:
-       mov     r1,-(sp)
-       bic     $!7,(sp)
-       neg     (sp)
-       inc     brtabp
-       ash     $-3,r1
-       movb    brtab(r1),r1
-       ash     (sp)+,r1
-       ror     r1              / 0-bit into c-bit
-       rts     pc
diff --git a/usr/src/cmd/as/as27.s b/usr/src/cmd/as/as27.s
deleted file mode 100644 (file)
index cfcfaa8..0000000
+++ /dev/null
@@ -1,294 +0,0 @@
-/
-/
-
-/  a7 -- pdp-11 assembler
-
-expres:
-       clr     xsymbol
-expres1:
-       mov     r5,-(sp)
-       mov     $'+,-(sp)
-       clr     r2
-       mov     $1,r3
-       br      1f
-advanc:
-       jsr     pc,readop
-1:
-       mov     r4,r0
-       jsr     r5,betwen; 0; 177
-               br .+4
-       br      7f
-       movb    (r4),r0
-       tst     r0
-       bne     1f
-       tstb    passno
-       beq     1f
-       jsr     r5,error; 'u
-1:
-       cmp     r0,$40
-       bne     1f
-       mov     r4,xsymbol
-       clr     r1
-       br      oprand
-1:
-       mov     2(r4),r1
-       br      oprand
-7:
-       cmp     r4,$141
-       blo     1f
-       asl     r4
-       mov     curfb-[2*141](r4),r0
-       mov     2(r0),r1
-       movb    (r0),r0
-       br      oprand
-1:
-       mov     $esw1,r1
-1:
-       cmp     (r1)+,r4
-       beq     1f
-       tst     (r1)+
-       bne     1b
-       tst     (sp)+
-       mov     (sp)+,r5
-       rts     pc
-1:
-       jmp     *(r1)
-
-esw1:
-       '+;     binop
-       '-;     binop
-       '*;     binop
-       '/;     binop
-       '&;     binop
-       037;    binop
-       035;    binop
-       036;    binop
-       '%;     binop
-       '[;     brack
-       '^;     binop
-       1;      exnum
-       2;      exnum1
-       '!;     binop
-       200;    0
-
-binop:
-       cmpb    (sp),$'+
-       beq     1f
-       jsr     pc,errore
-1:
-       movb    r4,(sp)
-       br      advanc
-
-exnum1:
-       mov     numval,r1
-       br      1f
-
-exnum:
-       jsr     pc,getw
-       mov     r4,r1
-1:
-       mov     $1,r0
-       br      oprand
-
-brack:
-       mov     r2,-(sp)
-       mov     r3,-(sp)
-       jsr     pc,readop
-       jsr     pc,expres1
-       cmp     r4,$']
-       beq     1f
-       jsr     r5,error; ']
-1:
-       mov     r3,r0
-       mov     r2,r1
-       mov     (sp)+,r3
-       mov     (sp)+,r2
-
-oprand:
-       mov     $exsw2,r5
-1:
-       cmp     (sp),(r5)+
-       beq     1f
-       tst     (r5)+
-       bne     1b
-       br      eoprnd
-1:
-       jmp     *(r5)
-
-exsw2:
-       '+; exadd
-       '-; exsub
-       '*; exmul
-       '/; exdiv
-       037; exor
-       '&; exand
-       035;exlsh
-       036;exrsh
-       '%; exmod
-       '^; excmbin
-       '!; exnot
-       200;  0
-
-excmbin:
-       mov     r0,r3
-       br      eoprnd
-
-exrsh:
-       neg     r1
-       beq     exlsh
-       inc     r1
-       clc
-       ror     r2
-exlsh:
-       jsr     r5,combin; relte2
-       als     r1,r2
-       br      eoprnd
-
-exmod:
-       jsr     r5,combin; relte2
-       mov     r3,r0
-       mov     r2,r3
-       clr     r2
-       dvd     r1,r2
-       mov     r3,r2
-       mov     r0,r3
-       br      eoprnd
-
-exadd:
-       jsr     r5,combin; reltp2
-       add     r1,r2
-       br      eoprnd
-
-exsub:
-       jsr     r5,combin; reltm2
-       sub     r1,r2
-       br      eoprnd
-
-exand:
-       jsr     r5,combin; relte2
-       com     r1
-       bic     r1,r2
-       br      eoprnd
-
-exor:
-       jsr     r5,combin; relte2
-       bis     r1,r2
-       br      eoprnd
-
-exmul:
-       jsr     r5,combin; relte2
-       mpy     r2,r1
-       mov     r1,r2
-       br      eoprnd
-
-exdiv:
-       jsr     r5,combin; relte2
-       mov     r3,r0
-       mov     r2,r3
-       clr     r2
-       dvd     r1,r2
-       mov     r0,r3
-       br      eoprnd
-
-exnot:
-       jsr     r5,combin; relte2
-       com     r1
-       add     r1,r2
-       br      eoprnd
-
-eoprnd:
-       mov     $'+,(sp)
-       jmp     advanc
-
-combin:
-       tstb    passno
-       bne     combin1
-       mov     r0,-(sp)
-       bis     r3,(sp)
-       bic     $!40,(sp)
-       bic     $!37,r0
-       bic     $!37,r3
-       cmp     r0,r3
-       ble     1f
-       mov     r0,-(sp)
-       mov     r3,r0
-       mov     (sp)+,r3
-1:
-       tst     r0
-       beq     1f
-       cmp     (r5)+,$reltm2
-       bne     2f
-       cmp     r0,r3
-       bne     2f
-       mov     $1,r3
-       br      2f
-1:
-       tst     (r5)+
-       clr     r3
-2:
-       bis     (sp)+,r3
-       rts     r5
-combin1:
-       mov     r1,-(sp)
-       clr     maxtyp
-       jsr     pc,maprel
-       mov     r0,r1
-       mpy     $6,r1
-       mov     r3,r0
-       jsr     pc,maprel
-       add     (r5)+,r0
-       add     r1,r0
-       movb    (r0),r3
-       bpl     1f
-       cmp     r3,$-1
-       beq     2f
-       jsr     r5,error; 'r
-2:
-       mov     maxtyp,r3
-1:
-       mov     (sp)+,r1
-       rts     r5
-
-maprel:
-       cmp     r0,$40
-       bne     1f
-       mov     $5,r0
-       rts     pc
-1:
-       bic     $!37,r0
-       cmp     r0,maxtyp
-       blos    1f
-       mov     r0,maxtyp
-1:
-       cmp     r0,$5
-       blo     1f
-       mov     $1,r0
-1:
-       rts     pc
-
-X = -2
-M = -1
-reltp2:
-       .byte 0, 0, 0, 0, 0, 0
-       .byte 0, M, 2, 3, 4,40
-       .byte 0, 2, X, X, X, X
-       .byte 0, 3, X, X, X, X
-       .byte 0, 4, X, X, X, X
-       .byte 0,40, X, X, X, X
-
-reltm2:
-       .byte 0, 0, 0, 0, 0, 0
-       .byte 0, M, 2, 3, 4,40
-       .byte 0, X, 1, X, X, X
-       .byte 0, X, X, 1, X, X
-       .byte 0, X, X, X, 1, X
-       .byte 0, X, X, X, X, X
-
-relte2:
-       .byte 0, 0, 0, 0, 0, 0
-       .byte 0, M, X, X, X, X
-       .byte 0, X, X, X, X, X
-       .byte 0, X, X, X, X, X
-       .byte 0, X, X, X, X, X
-       .byte 0, X, X, X, X, X
-
diff --git a/usr/src/cmd/as/as28.s b/usr/src/cmd/as/as28.s
deleted file mode 100644 (file)
index a5e03cc..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/
-/
-
-/ as8 -- PDP-11 assembler pass 2
-
-qnl:   <?\n>
-a.out: <a.out\0>
-.even
-.data
-a.outp:        a.out
-
-a.tmp1:        0
-a.tmp2:        0
-a.tmp3:        0
-
-tseekp:        txtseek
-rseekp:        trelseek
-
-txtmagic:
-       br      .+20
-txtsiz:        .=.+2
-datsiz:        .=.+2
-bsssiz:        .=.+2
-symsiz:        .=.+2
-stksiz:        .=.+2
-exorig:        .=.+2
-       .=.+2
-
-txtseek:0; 20
-datseek:.=.+4
-       .=.+4
-trelseek:.=.+4
-drelseek:.=.+4
-       .=.+4
-symseek:.=.+4
-
-.bss
-
-brlen  = 1024.
-brtab: .=.+[brlen\/8.]
-brtabp:        .=.+2
-brdelt:        .=.+2
-fbbufp:        .=.+2
-defund:        .=.+2
-savdot:        .=.+6
-datbase:.=.+2
-bssbase:.=.+2
-fbfil: .=.+2
-fin:   .=.+2
-ibufc: .=.+2
-txtfil:        .=.+2
-symf:  .=.+2
-adrbuf:        .=.+12.
-xsymbol:.=.+2
-fout:  .=.+2
-ch:    .=.+2
-errflg:        .=.+2
-wordf: .=.+2
-argb:  .=.+22.
-line:  .=.+2
-savop: .=.+2
-curfb: .=.+20.
-nxtfb: .=.+20.
-numval:        .=.+2
-maxtyp:        .=.+2
-relfil:        .=.+2
-ibufp: .=.+2
-txtp:  .=.+8+512.
-relp:  .=.+8+512.
-swapf: .=.+2
-rlimit:        .=.+2
-passno:        .=.+2
-endtable:.=.+2
-usymtab:.=.+20.
-end:
-
-.text
diff --git a/usr/src/cmd/as/as29.s b/usr/src/cmd/as/as29.s
deleted file mode 100644 (file)
index c17cae2..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-/
-/
-
-/ as9 -- PDP-11 assembler pass 2
-
-eae = 0
-
-       .data
-symtab:
-
-/ special variables
-
-dotrel: 02; dot:000000 /.
- 01; dotdot:000000 /..
-
-/ register
-
-24;000000 /r0
-24;000001 /r1
-24;000002 /r2
-24;000003 /r3
-24;000004 /r4
-24;000005 /r5
-24;000006 /sp
-24;000007 /pc
-
-
-.if eae
-/eae & switches
-
-01;177570 /csw
-01;177300 /div
-01;177302 /ac
-01;177304 /mq
-01;177306 /mul
-01;177310 /sc
-01;177311 /sr
-01;177312 /nor
-01;177314 /lsh
-01;177316 /ash
-
-.endif
-
-/ double operand
-
-13;0010000 /mov
-13;0110000 /movb
-13;0020000 /cmp
-13;0120000 /cmpb
-13;0030000 /bit
-13;0130000 /bitb
-13;0040000 /bic
-13;0140000 /bicb
-13;0050000 /bis
-13;0150000 /bisb
-13;0060000 /add
-13;0160000 /sub
-
-/ branch
-
-06;0000400 /br
-06;0001000 /bne
-06;0001400 /beq
-06;0002000 /bge
-06;0002400 /blt
-06;0003000 /bgt
-06;0003400 /ble
-06;0100000 /bpl
-06;0100400 /bmi
-06;0101000 /bhi
-06;0101400 /blos
-06;0102000 /bvc
-06;0102400 /bvs
-06;0103000 /bhis
-06;0103000 /bec
-06;0103000 /bcc
-06;0103400 /blo
-06;0103400 /bcs
-06;0103400 /bes
-
-/ jump/ branch type
-
-35;0000400 /jbr
-36;0001000 /jne
-36;0001400 /jeq
-36;0002000 /jge
-36;0002400 /jlt
-36;0003000 /jgt
-36;0003400 /jle
-36;0100000 /jpl
-36;0100400 /jmi
-36;0101000 /jhi
-36;0101400 /jlos
-36;0102000 /jvc
-36;0102400 /jvs
-36;0103000 /jhis
-36;0103000 /jec
-36;0103000 /jcc
-36;0103400 /jlo
-36;0103400 /jcs
-36;0103400 /jes
-
-/ single operand
-
-15;0005000 /clr
-15;0105000 /clrb
-15;0005100 /com
-15;0105100 /comb
-15;0005200 /inc
-15;0105200 /incb
-15;0005300 /dec
-15;0105300 /decb
-15;0005400 /neg
-15;0105400 /negb
-15;0005500 /adc
-15;0105500 /adcb
-15;0005600 /sbc
-15;0105600 /sbcb
-15;0005700 /tst
-15;0105700 /tstb
-15;0006000 /ror
-15;0106000 /rorb
-15;0006100 /rol
-15;0106100 /rolb
-15;0006200 /asr
-15;0106200 /asrb
-15;0006300 /asl
-15;0106300 /aslb
-15;0000100 /jmp
-15;0000300 /swab
-
-/ jsr
-
-07;0004000 /jsr
-
-/ rts
-
-10;000200 /rts
-
-/ simple operand
-
-11;104400 /sys
-
-/ flag-setting
-
-01;0000241 /clc
-01;0000242 /clv
-01;0000244 /clz
-01;0000250 /cln
-01;0000261 /sec
-01;0000262 /sev
-01;0000264 /sez
-01;0000270 /sen
-
-/ floating point ops
-
-01;170000 / cfcc
-01;170001 / setf
-01;170011 / setd
-01;170002 / seti
-01;170012 / setl
-15;170400 / clrf
-15;170700 / negf
-15;170600 / absf
-15;170500 / tstf
-12;172400 / movf
-14;177000 / movif
-05;175400 / movfi
-14;177400 / movof
-05;176000 / movfo
-14;172000 / addf
-14;173000 / subf
-14;171000 / mulf
-14;174400 / divf
-14;173400 / cmpf
-14;171400 / modf
-14;176400 / movie
-05;175000 / movei
-15;170100 / ldfps
-15;170200 / stfps
-24;000000 / fr0
-24;000001 / fr1
-24;000002 / fr2
-24;000003 / fr3
-24;000004 / fr4
-24;000005 / fr5
-
-/ 11/45 operations
-
-30;072000 /als (ash)
-30;073000 /alsc (ashc)
-30;070000 /mpy
-.if eae-1
-30;070000/ mul
-30;071000 / div
-30;072000 / ash
-30;073000 /ashc
-.endif
-30;071000 /dvd
-07;074000 /xor
-15;006700 /sxt
-11;006400 /mark
-31;077000 /sob
-
-/ specials
-
-16;000000 /.byte
-20;000000 /.even
-21;000000 /.if
-22;000000 /.endif
-23;000000 /.globl
-25;000000 /.text
-26;000000 /.data
-27;000000 /.bss
-32;000000 /.comm
-
-start:
-       mov     (sp)+,r0
-       tst     (sp)+
-1:
-       mov     (sp)+,r1
-       cmpb    (r1),$'-
-       bne     1f
-       dec     r0
-       cmpb    1(r1),$'g
-       bne     2f
-       mov     $40,defund      / globalize externals
-       br      1b
-2:
-       cmpb    1(r1),$'o
-       bne     1b
-       dec     r0
-       mov     (sp)+,r1
-       mov     r1,a.outp
-       mov     r1,a.outp1
-       mov     r1,a.outp2
-       br      1b
-1:
-       cmp     r0,$4
-       bge     1f
-       jmp     aexit
-1:
-       mov     r1,a.tmp1
-       mov     (sp)+,a.tmp2
-       mov     (sp)+,a.tmp3
-       jsr     r5,ofile; a.tmp1
-       movb    r0,txtfil
-       jsr     r5,ofile; a.tmp2
-       movb    r0,fbfil
-       jsr     r5,ofile; a.tmp3
-       movb    r0,symf
-       movb    r0,fin
-       sys     creat; a.outp1:a.out; 666
-       bec     1f
-       jsr     r5,filerr; a.outp
-1:
-       movb    r0,fout
-       jmp     go
-
-/ overlaid buffer
-inbuf  = start
-.      = inbuf+512.
diff --git a/usr/src/cmd/as/as3.c b/usr/src/cmd/as/as3.c
new file mode 100644 (file)
index 0000000..1216117
--- /dev/null
@@ -0,0 +1,74 @@
+#
+char AS3[] = "@(#)as3.c 1.10 79/03/21 22:27:36";       /* sccs ident */
+#include <stdio.h>
+#include "as.h"
+#include "as.yh"
+
+#define OP(a,b,c,d,e,f,g,h,i) {a,b,(c==0 ? INST0-256:INSTn-256),c,d,e,f,g,h,i}
+
+readonly struct instab instab[] = {
+{".space", 0, ISPACE-256},
+{".byte", 0, IBYTE-256},
+{".word", 0, IWORD-256},
+{".long", 0, ILONG-256},
+{".int", 0, IINT-256},
+{".data", 0, IDATA-256},
+{".globl", 0, IGLOBAL-256},
+{".set", 0, ISET-256},
+{".text", 0, ITEXT-256},
+{".comm", 0, ICOMM-256},
+{".lcomm", 0, ILCOMM-256},
+{".lsym", 0, ILSYM-256},
+{".align", 0, IALIGN-256},
+{".float", 0, IFLOAT-256},
+{".double", 0, IDOUBLE-256},
+{".org", 0, IORG-256},
+{".stab", 0, ISTAB-256},
+{"r0",0,REG-256},
+{"r1",1,REG-256},
+{"r2",2,REG-256},
+{"r3",3,REG-256},
+{"r4",4,REG-256},
+{"r5",5,REG-256},
+{"r6",6,REG-256},
+{"r7",7,REG-256},
+{"r8",8,REG-256},
+{"r9",9,REG-256},
+{"r10",10,REG-256},
+{"r11",11,REG-256},
+{"r12",12,REG-256},
+{"r13",13,REG-256},
+{"r14",14,REG-256},
+{"r15",15,REG-256},
+{"ap",12,REG-256},
+{"fp",13,REG-256},
+{"sp",14,REG-256},
+{"pc",15,REG-256},
+{"jcc",0x1e,IJXXX-256},
+{"jcs",0x1f,IJXXX-256},
+{"jeql",0x13,IJXXX-256},
+{"jeqlu",0x13,IJXXX-256},
+{"jgeq",0x18,IJXXX-256},
+{"jgequ",0x1e,IJXXX-256},
+{"jgtr",0x14,IJXXX-256},
+{"jgtru",0x1a,IJXXX-256},
+{"jleq",0x15,IJXXX-256},
+{"jlequ",0x1b,IJXXX-256},
+{"jlss",0x19,IJXXX-256},
+{"jlssu",0x1f,IJXXX-256},
+{"jneq",0x12,IJXXX-256},
+{"jnequ",0x12,IJXXX-256},
+{"jvc",0x1c,IJXXX-256},
+{"jvs",0x1d,IJXXX-256},
+{"jbr",0x11,IJXXX-256},
+{"jbc",0xe1,IJXXX-256},
+{"jbs",0xe0,IJXXX-256},
+{"jbcc",0xe5,IJXXX-256},
+{"jbsc",0xe4,IJXXX-256},
+{"jbcs",0xe3,IJXXX-256},
+{"jbss",0xe2,IJXXX-256},
+{"jlbc",0xe9,IJXXX-256},
+{"jlbs",0xe8,IJXXX-256},
+#include "instrs"
+0
+};
diff --git a/usr/src/cmd/as/err b/usr/src/cmd/as/err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/src/cmd/as/instrs b/usr/src/cmd/as/instrs
new file mode 100644 (file)
index 0000000..5ff6a23
--- /dev/null
@@ -0,0 +1,257 @@
+OP("acbb",0x9d,4,ACCR+TYPB,ACCR+TYPB,ACCM+TYPB,ACCB+TYPW,0,0),
+OP("acbd",0x6f,4,ACCR+TYPD,ACCR+TYPD,ACCM+TYPD,ACCB+TYPW,0,0),
+OP("acbf",0x4f,4,ACCR+TYPF,ACCR+TYPF,ACCM+TYPF,ACCB+TYPW,0,0),
+OP("acbl",0xf1,4,ACCR+TYPL,ACCR+TYPL,ACCM+TYPL,ACCB+TYPW,0,0),
+OP("acbw",0x3d,4,ACCR+TYPW,ACCR+TYPW,ACCM+TYPW,ACCB+TYPW,0,0),
+OP("adawi",0x58,2,ACCR+TYPW,ACCM+TYPW,0,0,0,0),
+OP("addb2",0x80,2,ACCR+TYPB,ACCM+TYPB,0,0,0,0),
+OP("addb3",0x81,3,ACCR+TYPB,ACCR+TYPB,ACCW+TYPB,0,0,0),
+OP("addd2",0x60,2,ACCR+TYPD,ACCM+TYPD,0,0,0,0),
+OP("addd3",0x61,3,ACCR+TYPD,ACCR+TYPD,ACCW+TYPD,0,0,0),
+OP("addf2",0x40,2,ACCR+TYPF,ACCM+TYPF,0,0,0,0),
+OP("addf3",0x41,3,ACCR+TYPF,ACCR+TYPF,ACCW+TYPF,0,0,0),
+OP("addl2",0xc0,2,ACCR+TYPL,ACCM+TYPL,0,0,0,0),
+OP("addl3",0xc1,3,ACCR+TYPL,ACCR+TYPL,ACCW+TYPL,0,0,0),
+OP("addp4",0x20,4,ACCR+TYPW,ACCA+TYPB,ACCR+TYPW,ACCA+TYPB,0,0),
+OP("addp6",0x21,6,ACCR+TYPW,ACCA+TYPB,ACCR+TYPW,ACCA+TYPB,ACCR+TYPW,ACCA+TYPB),
+OP("addw2",0xa0,2,ACCR+TYPW,ACCM+TYPW,0,0,0,0),
+OP("addw3",0xa1,3,ACCR+TYPW,ACCR+TYPW,ACCW+TYPW,0,0,0),
+OP("adwc",0xd8,2,ACCR+TYPL,ACCM+TYPL,0,0,0,0),
+OP("aobleq",0xf3,3,ACCR+TYPL,ACCM+TYPL,ACCB+TYPB,0,0,0),
+OP("aoblss",0xf2,3,ACCR+TYPL,ACCM+TYPL,ACCB+TYPB,0,0,0),
+OP("ashl",0x78,3,ACCR+TYPB,ACCR+TYPL,ACCW+TYPL,0,0,0),
+OP("ashp",0xf8,6,ACCR+TYPB,ACCR+TYPW,ACCA+TYPB,ACCR+TYPB,ACCR+TYPW,ACCA+TYPB),
+OP("ashq",0x79,3,ACCR+TYPB,ACCR+TYPQ,ACCW+TYPQ,0,0,0),
+OP("bbc",0xe1,3,ACCR+TYPL,ACCR+TYPB,ACCB+TYPB,0,0,0),
+OP("bbcc",0xe5,3,ACCR+TYPL,ACCR+TYPB,ACCB+TYPB,0,0,0),
+OP("bbcci",0xe7,3,ACCR+TYPL,ACCR+TYPB,ACCB+TYPB,0,0,0),
+OP("bbcs",0xe3,3,ACCR+TYPL,ACCR+TYPB,ACCB+TYPB,0,0,0),
+OP("bbs",0xe0,3,ACCR+TYPL,ACCR+TYPB,ACCB+TYPB,0,0,0),
+OP("bbsc",0xe4,3,ACCR+TYPL,ACCR+TYPB,ACCB+TYPB,0,0,0),
+OP("bbss",0xe2,3,ACCR+TYPL,ACCR+TYPB,ACCB+TYPB,0,0,0),
+OP("bbssi",0xe6,3,ACCR+TYPL,ACCR+TYPB,ACCB+TYPB,0,0,0),
+OP("bcc",0x1e,1,ACCB+TYPB,0,0,0,0,0),
+OP("bcs",0x1f,1,ACCB+TYPB,0,0,0,0,0),
+OP("beql",0x13,1,ACCB+TYPB,0,0,0,0,0),
+OP("beqlu",0x13,1,ACCB+TYPB,0,0,0,0,0),
+OP("bgeq",0x18,1,ACCB+TYPB,0,0,0,0,0),
+OP("bgequ",0x1e,1,ACCB+TYPB,0,0,0,0,0),
+OP("bgtr",0x14,1,ACCB+TYPB,0,0,0,0,0),
+OP("bgtru",0x1a,1,ACCB+TYPB,0,0,0,0,0),
+OP("bicb2",0x8a,2,ACCR+TYPB,ACCM+TYPB,0,0,0,0),
+OP("bicb3",0x8b,3,ACCR+TYPB,ACCR+TYPB,ACCW+TYPB,0,0,0),
+OP("bicl2",0xca,2,ACCR+TYPL,ACCM+TYPL,0,0,0,0),
+OP("bicl3",0xcb,3,ACCR+TYPL,ACCR+TYPL,ACCW+TYPL,0,0,0),
+OP("bicpsw",0xb9,1,ACCR+TYPW,0,0,0,0,0),
+OP("bicw2",0xaa,2,ACCR+TYPW,ACCM+TYPW,0,0,0,0),
+OP("bicw3",0xab,3,ACCR+TYPW,ACCR+TYPW,ACCW+TYPW,0,0,0),
+OP("bisb2",0x88,2,ACCR+TYPB,ACCM+TYPB,0,0,0,0),
+OP("bisb3",0x89,3,ACCR+TYPB,ACCR+TYPB,ACCW+TYPB,0,0,0),
+OP("bisl2",0xc8,2,ACCR+TYPL,ACCM+TYPL,0,0,0,0),
+OP("bisl3",0xc9,3,ACCR+TYPL,ACCR+TYPL,ACCW+TYPL,0,0,0),
+OP("bispsw",0xb8,1,ACCR+TYPW,0,0,0,0,0),
+OP("bisw2",0xa8,2,ACCR+TYPW,ACCM+TYPW,0,0,0,0),
+OP("bisw3",0xa9,3,ACCR+TYPW,ACCR+TYPW,ACCW+TYPW,0,0,0),
+OP("bitb",0x93,2,ACCR+TYPB,ACCR+TYPB,0,0,0,0),
+OP("bitl",0xd3,2,ACCR+TYPL,ACCR+TYPL,0,0,0,0),
+OP("bitw",0xb3,2,ACCR+TYPW,ACCR+TYPW,0,0,0,0),
+OP("blbs",0xe8,2,ACCR+TYPL,ACCB+TYPB,0,0,0,0),
+OP("blbc",0xe9,2,ACCR+TYPL,ACCB+TYPB,0,0,0,0),
+OP("bleq",0x15,1,ACCB+TYPB,0,0,0,0,0),
+OP("blequ",0x1b,1,ACCB+TYPB,0,0,0,0,0),
+OP("blss",0x19,1,ACCB+TYPB,0,0,0,0,0),
+OP("blssu",0x1f,1,ACCB+TYPB,0,0,0,0,0),
+OP("bneq",0x12,1,ACCB+TYPB,0,0,0,0,0),
+OP("bnequ",0x12,1,ACCB+TYPB,0,0,0,0,0),
+OP("bpt",0x03,0,0,0,0,0,0,0),
+OP("brb",0x11,1,ACCB+TYPB,0,0,0,0,0),
+OP("brw",0x31,1,ACCB+TYPW,0,0,0,0,0),
+OP("bsbb",0x10,1,ACCB+TYPB,0,0,0,0,0),
+OP("bsbw",0x30,1,ACCB+TYPW,0,0,0,0,0),
+OP("bvc",0x1c,1,ACCB+TYPB,0,0,0,0,0),
+OP("bvs",0x1d,1,ACCB+TYPB,0,0,0,0,0),
+OP("callg",0xfa,2,ACCA+TYPB,ACCA+TYPB,0,0,0,0),
+OP("calls",0xfb,2,ACCR+TYPL,ACCA+TYPB,0,0,0,0),
+OP("caseb",0x8f,3,ACCR+TYPB,ACCR+TYPB,ACCR+TYPB,0,0,0),
+OP("casel",0xcf,3,ACCR+TYPL,ACCR+TYPL,ACCR+TYPL,0,0,0),
+OP("casew",0xaf,3,ACCR+TYPW,ACCR+TYPW,ACCR+TYPW,0,0,0),
+OP("chme",0xbd,1,ACCR+TYPW,0,0,0,0,0),
+OP("chmk",0xbc,1,ACCR+TYPW,0,0,0,0,0),
+OP("chms",0xbe,1,ACCR+TYPW,0,0,0,0,0),
+OP("chmu",0xbf,1,ACCR+TYPW,0,0,0,0,0),
+OP("clrb",0x94,1,ACCW+TYPB,0,0,0,0,0),
+OP("clrd",0x7c,1,ACCW+TYPD,0,0,0,0,0),
+OP("clrf",0xd4,1,ACCW+TYPF,0,0,0,0,0),
+OP("clrl",0xd4,1,ACCW+TYPL,0,0,0,0,0),
+OP("clrq",0x7c,1,ACCW+TYPQ,0,0,0,0,0),
+OP("clrw",0xb4,1,ACCW+TYPW,0,0,0,0,0),
+OP("cmpb",0x91,2,ACCR+TYPB,ACCR+TYPB,0,0,0,0),
+OP("cmpc3",0x29,3,ACCR+TYPW,ACCA+TYPB,ACCA+TYPB,0,0,0),
+OP("cmpc5",0x2d,5,ACCR+TYPW,ACCA+TYPB,ACCR+TYPB,ACCR+TYPW,ACCA+TYPB,0),
+OP("cmpd",0x71,2,ACCR+TYPD,ACCR+TYPD,0,0,0,0),
+OP("cmpf",0x51,2,ACCR+TYPF,ACCR+TYPF,0,0,0,0),
+OP("cmpl",0xd1,2,ACCR+TYPL,ACCR+TYPL,0,0,0,0),
+OP("cmpp3",0x35,3,ACCR+TYPW,ACCA+TYPB,ACCA+TYPB,0,0,0),
+OP("cmpp4",0x37,4,ACCR+TYPW,ACCA+TYPB,ACCR+TYPW,ACCA+TYPB,0,0),
+OP("cmpv",0xec,4,ACCR+TYPL,ACCR+TYPB,ACCR+TYPB,ACCR+TYPL,0,0),
+OP("cmpw",0xb1,2,ACCR+TYPW,ACCR+TYPW,0,0,0,0),
+OP("cmpzv",0xed,4,ACCR+TYPL,ACCR+TYPB,ACCR+TYPB,ACCR+TYPL,0,0),
+OP("crc",0x0b,4,ACCA+TYPB,ACCR+TYPL,ACCR+TYPW,ACCA+TYPB,0,0),
+OP("cvtbd",0x6c,2,ACCR+TYPB,ACCW+TYPD,0,0,0,0),
+OP("cvtbf",0x4c,2,ACCR+TYPB,ACCW+TYPB,0,0,0,0),
+OP("cvtbl",0x98,2,ACCR+TYPB,ACCW+TYPL,0,0,0,0),
+OP("cvtbw",0x99,2,ACCR+TYPB,ACCW+TYPW,0,0,0,0),
+OP("cvtdb",0x68,2,ACCR+TYPD,ACCW+TYPB,0,0,0,0),
+OP("cvtdf",0x76,2,ACCR+TYPD,ACCW+TYPF,0,0,0,0),
+OP("cvtdl",0x6a,2,ACCR+TYPD,ACCW+TYPL,0,0,0,0),
+OP("cvtdw",0x69,2,ACCR+TYPD,ACCW+TYPW,0,0,0,0),
+OP("cvtfb",0x48,2,ACCR+TYPF,ACCW+TYPB,0,0,0,0),
+OP("cvtfd",0x56,2,ACCR+TYPF,ACCW+TYPD,0,0,0,0),
+OP("cvtfl",0x4a,2,ACCR+TYPF,ACCW+TYPL,0,0,0,0),
+OP("cvtfw",0x49,2,ACCR+TYPF,ACCW+TYPW,0,0,0,0),
+OP("cvtlb",0xf6,2,ACCR+TYPL,ACCW+TYPB,0,0,0,0),
+OP("cvtld",0x6e,2,ACCR+TYPL,ACCW+TYPD,0,0,0,0),
+OP("cvtlf",0x4e,2,ACCR+TYPL,ACCW+TYPF,0,0,0,0),
+OP("cvtlp",0xf9,3,ACCR+TYPL,ACCR+TYPW,ACCA+TYPB,0,0,0),
+OP("cvtlw",0xf7,2,ACCR+TYPL,ACCW+TYPW,0,0,0,0),
+OP("cvtpl",0x36,3,ACCR+TYPW,ACCA+TYPB,ACCW+TYPL,0,0,0),
+OP("cvttp",0x26,5,ACCR+TYPW,ACCA+TYPB,ACCA+TYPB,ACCR+TYPW,ACCA+TYPB,0),
+OP("cvtpt",0x24,5,ACCR+TYPW,ACCA+TYPB,ACCA+TYPB,ACCR+TYPW,ACCA+TYPB,0),
+OP("cvtps",0x08,4,ACCR+TYPW,ACCA+TYPB,ACCR+TYPW,ACCA+TYPB,0,0),
+OP("cvtrdl",0x6b,2,ACCR+TYPD,ACCW+TYPL,0,0,0,0),
+OP("cvtrfl",0x4b,2,ACCR+TYPF,ACCW+TYPL,0,0,0,0),
+OP("cvtsp",0x09,4,ACCR+TYPW,ACCA+TYPB,ACCR+TYPW,ACCA+TYPB,0,0),
+OP("cvtwb",0x33,2,ACCR+TYPW,ACCW+TYPB,0,0,0,0),
+OP("cvtwd",0x6d,2,ACCR+TYPW,ACCW+TYPD,0,0,0,0),
+OP("cvtwf",0x4d,2,ACCR+TYPW,ACCW+TYPF,0,0,0,0),
+OP("cvtwl",0x32,2,ACCR+TYPW,ACCW+TYPL,0,0,0,0),
+OP("decb",0x97,1,ACCM+TYPB,0,0,0,0,0),
+OP("decl",0xd7,1,ACCM+TYPL,0,0,0,0,0),
+OP("decw",0xb7,1,ACCM+TYPW,0,0,0,0,0),
+OP("divb2",0x86,2,ACCR+TYPB,ACCM+TYPB,0,0,0,0),
+OP("divb3",0x87,3,ACCR+TYPB,ACCR+TYPB,ACCW+TYPB,0,0,0),
+OP("divd2",0x66,2,ACCR+TYPD,ACCM+TYPD,0,0,0,0),
+OP("divd3",0x67,3,ACCR+TYPD,ACCR+TYPD,ACCR+TYPD,0,0,0),
+OP("divf2",0x46,2,ACCR+TYPF,ACCM+TYPF,0,0,0,0),
+OP("divf3",0x47,3,ACCR+TYPF,ACCR+TYPF,ACCW+TYPF,0,0,0),
+OP("divl2",0xc6,2,ACCR+TYPL,ACCM+TYPL,0,0,0,0),
+OP("divl3",0xc7,3,ACCR+TYPL,ACCR+TYPL,ACCW+TYPL,0,0,0),
+OP("divp",0x27,6,ACCR+TYPW,ACCA+TYPB,ACCR+TYPW,ACCA+TYPB,ACCR+TYPW,ACCA+TYPB),
+OP("divw2",0xa6,2,ACCR+TYPW,ACCM+TYPW,0,0,0,0),
+OP("divw3",0xa7,3,ACCR+TYPW,ACCR+TYPW,ACCW+TYPW,0,0,0),
+OP("editpc",0x38,4,ACCR+TYPW,ACCA+TYPB,ACCA+TYPB,ACCA+TYPB,0,0),
+OP("ediv",0x7b,4,ACCR+TYPL,ACCR+TYPQ,ACCW+TYPL,ACCW+TYPL,0,0),
+OP("emodd",0x74,5,ACCR+TYPD,ACCR+TYPB,ACCR+TYPD,ACCW+TYPL,ACCW+TYPD,0),
+OP("emodf",0x54,5,ACCR+TYPF,ACCR+TYPB,ACCR+TYPF,ACCW+TYPL,ACCW+TYPF,0),
+OP("emul",0x7a,4,ACCR+TYPL,ACCR+TYPL,ACCR+TYPL,ACCW+TYPQ,0,0),
+OP("extv",0xee,4,ACCR+TYPL,ACCR+TYPB,ACCR+TYPB,ACCW+TYPL,0,0),
+OP("extzv",0xef,4,ACCR+TYPL,ACCR+TYPB,ACCR+TYPB,ACCW+TYPL,0,0),
+OP("ffc",0xeb,4,ACCR+TYPL,ACCR+TYPB,ACCR+TYPB,ACCW+TYPL,0,0),
+OP("ffs",0xea,4,ACCR+TYPL,ACCR+TYPB,ACCR+TYPB,ACCW+TYPL,0,0),
+OP("halt",0x00,0,0,0,0,0,0,0),
+OP("incb",0x96,1,ACCM+TYPB,0,0,0,0,0),
+OP("incl",0xd6,1,ACCM+TYPL,0,0,0,0,0),
+OP("incw",0xb6,1,ACCM+TYPW,0,0,0,0,0),
+OP("index",0x0a,6,ACCR+TYPL,ACCR+TYPL,ACCR+TYPL,ACCR+TYPL,ACCR+TYPL,ACCW+TYPL),
+OP("insque",0x0e,2,ACCA+TYPB,ACCA+TYPB,0,0,0,0),
+OP("insv",0xf0,4,ACCR+TYPL,ACCR+TYPL,ACCR+TYPB,ACCW+TYPB,0,0),
+OP("jmp",0x17,1,ACCA+TYPB,0,0,0,0,0),
+OP("jsb",0x16,1,ACCA+TYPB,0,0,0,0,0),
+OP("ldpctx",0x06,0,0,0,0,0,0,0),
+OP("locc",0x3a,3,ACCR+TYPB,ACCR+TYPW,ACCA+TYPB,0,0,0),
+OP("matchc",0x39,4,ACCR+TYPW,ACCA+TYPB,ACCR+TYPW,ACCA+TYPB,0,0),
+OP("mcomb",0x92,2,ACCR+TYPB,ACCW+TYPB,0,0,0,0),
+OP("mcoml",0xd2,2,ACCR+TYPL,ACCW+TYPL,0,0,0,0),
+OP("mcomw",0xb2,2,ACCR+TYPW,ACCW+TYPW,0,0,0,0),
+OP("mfpr",0xdb,2,ACCR+TYPL,ACCW+TYPL,0,0,0,0),
+OP("mnegb",0x8e,2,ACCR+TYPB,ACCW+TYPB,0,0,0,0),
+OP("mnegd",0x72,2,ACCR+TYPD,ACCW+TYPD,0,0,0,0),
+OP("mnegf",0x52,2,ACCR+TYPF,ACCW+TYPF,0,0,0,0),
+OP("mnegl",0xce,2,ACCR+TYPL,ACCW+TYPL,0,0,0,0),
+OP("mnegw",0xae,2,ACCR+TYPW,ACCW+TYPL,0,0,0,0),
+OP("movab",0x9e,2,ACCA+TYPB,ACCW+TYPL,0,0,0,0),
+OP("movad",0x7e,2,ACCA+TYPD,ACCW+TYPL,0,0,0,0),
+OP("movaf",0xde,2,ACCA+TYPF,ACCW+TYPL,0,0,0,0),
+OP("moval",0xde,2,ACCA+TYPL,ACCW+TYPL,0,0,0,0),
+OP("movaq",0x7e,2,ACCA+TYPQ,ACCW+TYPL,0,0,0,0),
+OP("movaw",0x3e,2,ACCA+TYPW,ACCW+TYPL,0,0,0,0),
+OP("movb",0x90,2,ACCR+TYPB,ACCW+TYPB,0,0,0,0),
+OP("movc3",0x28,3,ACCR+TYPW,ACCA+TYPB,ACCA+TYPB,0,0,0),
+OP("movc5",0x2c,5,ACCR+TYPW,ACCA+TYPB,ACCR+TYPB,ACCR+TYPW,ACCA+TYPB,0),
+OP("movd",0x70,2,ACCR+TYPD,ACCW+TYPD,0,0,0,0),
+OP("movf",0x50,2,ACCR+TYPF,ACCW+TYPF,0,0,0,0),
+OP("movl",0xd0,2,ACCR+TYPL,ACCW+TYPL,0,0,0,0),
+OP("movp",0x34,3,ACCR+TYPW,ACCA+TYPB,ACCA+TYPB,0,0,0),
+OP("movpsl",0xdc,1,ACCW+TYPL,0,0,0,0,0),
+OP("movq",0x7d,2,ACCR+TYPQ,ACCW+TYPQ,0,0,0,0),
+OP("movtc",0x2e,6,ACCR+TYPW,ACCA+TYPB,ACCR+TYPB,ACCA+TYPB,ACCR+TYPW,ACCA+TYPB),
+OP("movtuc",0x2f,6,ACCR+TYPW,ACCA+TYPB,ACCR+TYPB,ACCA+TYPB,ACCR+TYPW,ACCA+TYPB),
+OP("movw",0xb0,2,ACCR+TYPW,ACCW+TYPW,0,0,0,0),
+OP("movzbl",0x9a,2,ACCR+TYPB,ACCW+TYPL,0,0,0,0),
+OP("movzbw",0x9b,2,ACCR+TYPB,ACCW+TYPW,0,0,0,0),
+OP("movzwl",0x3c,2,ACCR+TYPW,ACCW+TYPL,0,0,0,0),
+OP("mtpr",0xda,2,ACCR+TYPL,ACCR+TYPL,0,0,0,0),
+OP("mulb2",0x84,2,ACCR+TYPB,ACCM+TYPB,0,0,0,0),
+OP("mulb3",0x85,3,ACCR+TYPB,ACCR+TYPB,ACCW+TYPB,0,0,0),
+OP("muld2",0x64,2,ACCR+TYPD,ACCM+TYPD,0,0,0,0),
+OP("muld3",0x65,3,ACCR+TYPD,ACCR+TYPD,ACCW+TYPD,0,0,0),
+OP("mulf2",0x44,2,ACCR+TYPF,ACCM+TYPF,0,0,0,0),
+OP("mulf3",0x45,3,ACCR+TYPF,ACCR+TYPF,ACCW+TYPF,0,0,0),
+OP("mull2",0xc4,2,ACCR+TYPL,ACCM+TYPL,0,0,0,0),
+OP("mull3",0xc5,3,ACCR+TYPL,ACCR+TYPL,ACCW+TYPL,0,0,0),
+OP("mulp",0x25,6,ACCR+TYPW,ACCA+TYPB,ACCR+TYPW,ACCA+TYPB,ACCR+TYPW,ACCA+TYPB),
+OP("mulw2",0xa4,2,ACCR+TYPW,ACCM+TYPW,0,0,0,0),
+OP("mulw3",0xa5,3,ACCR+TYPW,ACCR+TYPW,ACCW+TYPW,0,0,0),
+OP("nop",0x01,0,0,0,0,0,0,0),
+OP("polyd",0x75,3,ACCR+TYPD,ACCR+TYPW,ACCA+TYPB,0,0,0),
+OP("polyf",0x55,3,ACCR+TYPF,ACCR+TYPW,ACCA+TYPB,0,0,0),
+OP("popr",0xba,1,ACCR+TYPW,0,0,0,0,0),
+OP("prober",0x0c,3,ACCR+TYPB,ACCR+TYPW,ACCA+TYPB,0,0,0),
+OP("probew",0x0d,3,ACCR+TYPB,ACCR+TYPW,ACCA+TYPB,0,0,0),
+OP("pushab",0x9f,1,ACCA+TYPB,0,0,0,0,0),
+OP("pushad",0x7f,1,ACCA+TYPD,0,0,0,0,0),
+OP("pushaf",0xdf,1,ACCA+TYPF,0,0,0,0,0),
+OP("pushal",0xdf,1,ACCA+TYPL,0,0,0,0,0),
+OP("pushaq",0x7f,1,ACCA+TYPQ,0,0,0,0,0),
+OP("pushaw",0x3f,1,ACCA+TYPW,0,0,0,0,0),
+OP("pushl",0xdd,1,ACCR+TYPL,0,0,0,0,0),
+OP("pushr",0xbb,1,ACCR+TYPW,0,0,0,0,0),
+OP("rei",0x02,0,0,0,0,0,0,0),
+OP("remque",0x0f,2,ACCA+TYPB,ACCW+TYPL,0,0,0,0),
+OP("ret",0x04,0,0,0,0,0,0,0),
+OP("rotl",0x9c,3,ACCR+TYPB,ACCR+TYPL,ACCW+TYPL,0,0,0),
+OP("rsb",0x05,0,0,0,0,0,0,0),
+OP("sbwc",0xd9,2,ACCR+TYPL,ACCM+TYPL,0,0,0,0),
+OP("scanc",0x2a,4,ACCR+TYPW,ACCA+TYPB,ACCA+TYPB,ACCR+TYPB,0,0),
+OP("skpc",0x3b,3,ACCR+TYPB,ACCR+TYPW,ACCA+TYPB,0,0,0),
+OP("sobgeq",0xf4,2,ACCM+TYPL,ACCB+TYPB,0,0,0,0),
+OP("sobgtr",0xf5,2,ACCM+TYPL,ACCB+TYPB,0,0,0,0),
+OP("spanc",0x2b,4,ACCR+TYPW,ACCA+TYPB,ACCA+TYPB,ACCR+TYPB,0,0),
+OP("subb2",0x82,2,ACCR+TYPB,ACCM+TYPB,0,0,0,0),
+OP("subb3",0x83,3,ACCR+TYPB,ACCR+TYPB,ACCW+TYPB,0,0,0),
+OP("subd2",0x62,2,ACCR+TYPD,ACCM+TYPD,0,0,0,0),
+OP("subd3",0x63,3,ACCR+TYPD,ACCR+TYPD,ACCW+TYPD,0,0,0),
+OP("subf2",0x42,2,ACCR+TYPF,ACCM+TYPF,0,0,0,0),
+OP("subf3",0x43,3,ACCR+TYPF,ACCR+TYPF,ACCW+TYPF,0,0,0),
+OP("subl2",0xc2,2,ACCR+TYPL,ACCM+TYPL,0,0,0,0),
+OP("subl3",0xc3,3,ACCR+TYPL,ACCR+TYPL,ACCW+TYPL,0,0,0),
+OP("subp4",0x22,4,ACCR+TYPW,ACCA+TYPB,ACCR+TYPW,ACCA+TYPB,0,0),
+OP("subp6",0x23,6,ACCR+TYPW,ACCA+TYPB,ACCR+TYPW,ACCA+TYPB,ACCR+TYPW,ACCA+TYPB),
+OP("subw2",0xa2,2,ACCR+TYPW,ACCM+TYPW,0,0,0,0),
+OP("subw3",0xa3,3,ACCR+TYPW,ACCR+TYPW,ACCW+TYPW,0,0,0),
+OP("svpctx",0x07,0,0,0,0,0,0,0),
+OP("tstb",0x95,1,ACCR+TYPB,0,0,0,0,0),
+OP("tstd",0x73,1,ACCR+TYPD,0,0,0,0,0),
+OP("tstf",0x53,1,ACCR+TYPF,0,0,0,0,0),
+OP("tstl",0xd5,1,ACCR+TYPL,0,0,0,0,0),
+OP("tstw",0xb5,1,ACCR+TYPW,0,0,0,0,0),
+OP("xfc",0xfc,1,ACCI+TYPB,0,0,0,0,0),
+OP("xorb2",0x8c,2,ACCR+TYPB,ACCM+TYPB,0,0,0,0),
+OP("xorb3",0x8d,3,ACCR+TYPB,ACCR+TYPB,ACCW+TYPB,0,0,0),
+OP("xorl2",0xcc,2,ACCR+TYPL,ACCM+TYPL,0,0,0,0),
+OP("xorl3",0xcd,3,ACCR+TYPL,ACCR+TYPL,ACCW+TYPL,0,0,0),
+OP("xorw2",0xac,2,ACCR+TYPW,ACCM+TYPW,0,0,0,0),
+OP("xorw3",0xad,3,ACCR+TYPW,ACCR+TYPW,ACCW+TYPW,0,0,0),
+OP("escd",0xfd,0,0,0,0,0,0,0),
+OP("esce",0xfe,0,0,0,0,0,0,0),
+OP("escf",0xff,0,0,0,0,0,0,0),
diff --git a/usr/src/cmd/as/makefile b/usr/src/cmd/as/makefile
deleted file mode 100644 (file)
index 899a596..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-all:   as as2
-
-cmp:   as as2
-       cmp as /bin/as
-       cmp as2 /lib/as2
-       rm as as2 a.out
-
-cp:    as as2
-       cp as /bin/as
-       cp as2 /lib/as2
-       rm as as2 a.out
-
-as:
-       as /usr/include/sys.s as1?.s
-       ld -n -s a.out -o as
-
-as2:
-       as /usr/include/sys.s as2?.s
-       ld -n -s a.out -o as2
index e997fad..8b01bef 100644 (file)
@@ -20,7 +20,6 @@ char **argv;
 {
        int tt, day, year, uniq;
        struct direct dirent;
 {
        int tt, day, year, uniq;
        struct direct dirent;
-       char file[DIRSIZ+1];
        FILE *dirf;
 
        chdir(DIR);
        FILE *dirf;
 
        chdir(DIR);
@@ -32,9 +31,7 @@ char **argv;
        while (fread((char *)&dirent, sizeof(dirent), 1, dirf) == 1) {
                if (dirent.d_ino==0)
                        continue;
        while (fread((char *)&dirent, sizeof(dirent), 1, dirf) == 1) {
                if (dirent.d_ino==0)
                        continue;
-               strncpy(file, dirent.d_name, DIRSIZ);
-               file[DIRSIZ] = '\0';
-               if (sscanf(file, "%2d.%3d.%4d.%2d", &year, &day, &tt, &uniq) != 4)
+               if (sscanf(dirent.d_name, "%2d.%3d.%4d.%2d", &year, &day, &tt, &uniq) != 4)
                        continue;
                if (nowyear < year)
                        continue;
                        continue;
                if (nowyear < year)
                        continue;
@@ -42,7 +39,7 @@ char **argv;
                        continue;
                if (nowyear==year && nowdate==day && nowtime < tt)
                        continue;
                        continue;
                if (nowyear==year && nowdate==day && nowtime < tt)
                        continue;
-               run(file);
+               run(dirent.d_name);
        }
        fclose(dirf);
        updatetime(nowtime);
        }
        fclose(dirf);
        updatetime(nowtime);
diff --git a/usr/src/cmd/awk/Makefile b/usr/src/cmd/awk/Makefile
new file mode 100644 (file)
index 0000000..f6e23a3
--- /dev/null
@@ -0,0 +1,38 @@
+CFLAGS=-O
+YFLAGS=-d
+
+FILES=awk.lx.o b.o main.o token.o tran.o lib.o run.o parse.o proctab.o dump.o 
+SOURCE=awk.def awk.g.y awk.lx.l b.c dump.c lib.c main.c parse.c proctab.c \
+       proc.c\
+       run.c token.c tran.c
+
+awk:   $(FILES) awk.g.o
+       cc $(CFLAGS) awk.g.o  $(FILES)  -lm -o awk
+
+y.tab.h:       awk.g.o
+
+awk.h: y.tab.h
+       -cmp -s y.tab.h awk.h || cp y.tab.h awk.h
+       rm y.tab.h
+
+$(FILES):      awk.h awk.def
+
+token.c:       awk.h
+       ed - <tokenscript
+
+find:
+       egrep -n "$(PAT)" *.[ylhc] awk.def
+
+lint:
+       lint -spu b.c main.c token.c tran.c run.c lib.c parse.c -lm |\
+               egrep -v '^(error|free|malloc)'
+
+proctab.c:     proc
+       proc > proctab.c
+proc:  awk.h proc.o token.o
+       cc -o proc proc.c token.o
+
+install:
+       install -s awk $(DESTDIR)/usr/bin
+clean:
+       rm -f *.o proc proctab.c
index e1d7d5a..7de49fc 100644 (file)
@@ -107,7 +107,7 @@ extern obj  true, false;
 extern int     pairstack[], paircnt;
 
 #define cantexec(n)    (n->ntype == NVALUE)
 extern int     pairstack[], paircnt;
 
 #define cantexec(n)    (n->ntype == NVALUE)
-#define notlegal(n)    (n <= FIRSTTOKEN || n >= LASTTOKEN || proctab[n-FIRSTTOKEN]== nullproc)
+#define notlegal(n)    (proctab[n-FIRSTTOKEN]== nullproc)
 #define isexpr(n)      (n->ntype == NEXPR)
 #define isjump(n)      (n.otype == OJUMP)
 #define isexit(n)      (n.otype == OJUMP && n.osub == JEXIT)
 #define isexpr(n)      (n->ntype == NEXPR)
 #define isjump(n)      (n.otype == OJUMP)
 #define isexit(n)      (n.otype == OJUMP && n.osub == JEXIT)
diff --git a/usr/src/cmd/awk/awk.h b/usr/src/cmd/awk/awk.h
new file mode 100644 (file)
index 0000000..5f2df5f
--- /dev/null
@@ -0,0 +1,76 @@
+# define FIRSTTOKEN 257
+# define FINAL 258
+# define FATAL 259
+# define LT 260
+# define LE 261
+# define GT 262
+# define GE 263
+# define EQ 264
+# define NE 265
+# define MATCH 266
+# define NOTMATCH 267
+# define APPEND 268
+# define ADD 269
+# define MINUS 270
+# define MULT 271
+# define DIVIDE 272
+# define MOD 273
+# define UMINUS 274
+# define ASSIGN 275
+# define ADDEQ 276
+# define SUBEQ 277
+# define MULTEQ 278
+# define DIVEQ 279
+# define MODEQ 280
+# define JUMP 281
+# define XBEGIN 282
+# define XEND 283
+# define NL 284
+# define PRINT 285
+# define PRINTF 286
+# define SPRINTF 287
+# define SPLIT 288
+# define IF 289
+# define ELSE 290
+# define WHILE 291
+# define FOR 292
+# define IN 293
+# define NEXT 294
+# define EXIT 295
+# define BREAK 296
+# define CONTINUE 297
+# define PROGRAM 298
+# define PASTAT 299
+# define PASTAT2 300
+# define ASGNOP 301
+# define BOR 302
+# define AND 303
+# define NOT 304
+# define NUMBER 305
+# define VAR 306
+# define ARRAY 307
+# define FNCN 308
+# define SUBSTR 309
+# define LSUBSTR 310
+# define INDEX 311
+# define RELOP 312
+# define MATCHOP 313
+# define OR 314
+# define STRING 315
+# define DOT 316
+# define CCL 317
+# define NCCL 318
+# define CHAR 319
+# define CAT 320
+# define STAR 321
+# define PLUS 322
+# define QUEST 323
+# define POSTINCR 324
+# define PREINCR 325
+# define POSTDECR 326
+# define PREDECR 327
+# define INCR 328
+# define DECR 329
+# define FIELD 330
+# define INDIRECT 331
+# define LASTTOKEN 332
index 8a74cb6..7e0799b 100644 (file)
@@ -7,15 +7,14 @@
 extern int     yylval;
 extern int     mustfld;
 
 extern int     yylval;
 extern int     mustfld;
 
-int    lineno  1;
+int    lineno  1;
 #ifdef DEBUG
 #      define  RETURN(x)       {if (dbg) ptoken(x); return(x); }
 #else
 #      define  RETURN(x)       return(x)
 #endif
 #ifdef DEBUG
 #      define  RETURN(x)       {if (dbg) ptoken(x); return(x); }
 #else
 #      define  RETURN(x)       return(x)
 #endif
-#define        CADD    cbuf[clen++]=yytext[0]; if(clen>=CBUFLEN-1) {yyerror("string too long", cbuf); BEGIN A;}
-#define        CBUFLEN 150
-char   cbuf[CBUFLEN];
+#define        CADD    cbuf[clen++]=yytext[0];
+char   cbuf[80];
 int    clen, cflag;
 %}
 
 int    clen, cflag;
 %}
 
@@ -128,20 +127,20 @@ WS        [ \t]
 <reg>\n                { yyerror("newline in regular expression"); lineno++; BEGIN A; }
 <reg>.         { yylval = yytext[0]; RETURN(CHAR); }
 
 <reg>\n                { yyerror("newline in regular expression"); lineno++; BEGIN A; }
 <reg>.         { yylval = yytext[0]; RETURN(CHAR); }
 
-<str>\"                { BEGIN A; cbuf[clen]=0; yylval = setsymtab(cbuf, tostring(cbuf), 0.0, CON|STR, symtab); RETURN(STRING); }
+<str>\"                { BEGIN A; cbuf[clen]=0; yylval = setsymtab("", tostring(cbuf), 0.0, CON|STR, symtab); RETURN(STRING); }
 <str>\n                { yyerror("newline in string"); lineno++; BEGIN A; }
 <str>"\\\""    { cbuf[clen++]='"'; }
 <str,chc>"\\"n { cbuf[clen++]='\n'; }
 <str,chc>"\\"t { cbuf[clen++]='\t'; }
 <str,chc>"\\\\"        { cbuf[clen++]='\\'; }
 <str>\n                { yyerror("newline in string"); lineno++; BEGIN A; }
 <str>"\\\""    { cbuf[clen++]='"'; }
 <str,chc>"\\"n { cbuf[clen++]='\n'; }
 <str,chc>"\\"t { cbuf[clen++]='\t'; }
 <str,chc>"\\\\"        { cbuf[clen++]='\\'; }
-<str>.         { CADD; }
+<str>.         CADD;
 
 <chc>"\\""]"   { cbuf[clen++]=']'; }
 <chc>"]"       { BEGIN reg; cbuf[clen]=0; yylval = tostring(cbuf);
                if (cflag==0) { RETURN(CCL); }
                else { RETURN(NCCL); } }
 <chc>\n                { yyerror("newline in character class"); lineno++; BEGIN A; }
 
 <chc>"\\""]"   { cbuf[clen++]=']'; }
 <chc>"]"       { BEGIN reg; cbuf[clen]=0; yylval = tostring(cbuf);
                if (cflag==0) { RETURN(CCL); }
                else { RETURN(NCCL); } }
 <chc>\n                { yyerror("newline in character class"); lineno++; BEGIN A; }
-<chc>.         { CADD; }
+<chc>.         CADD;
 
 %%
 
 
 %%
 
index f520604..a3c6040 100644 (file)
@@ -313,9 +313,10 @@ struct fa *cgotofn()
        for (i=0; i<=line; i++) index[i] = iposns[i] = setvec[i] = 0;
        for (i=0; i<NCHARS; i++)  isyms[i] = symbol[i] = 0;
        setcnt = 0;
        for (i=0; i<=line; i++) index[i] = iposns[i] = setvec[i] = 0;
        for (i=0; i<NCHARS; i++)  isyms[i] = symbol[i] = 0;
        setcnt = 0;
+       state[0] = add(0);
        /* compute initial positions and symbols of state 0 */
        ssmax = 0;
        /* compute initial positions and symbols of state 0 */
        ssmax = 0;
-       ptr = state[0] = foll[0];
+       ptr = foll[0];
        spinit = *ptr;
        for (i=0; i<spinit; i++) {
                curpos = *(++ptr);
        spinit = *ptr;
        for (i=0; i<spinit; i++) {
                curpos = *(++ptr);
diff --git a/usr/src/cmd/awk/dump.c b/usr/src/cmd/awk/dump.c
new file mode 100644 (file)
index 0000000..5319cee
--- /dev/null
@@ -0,0 +1,135 @@
+#include "awk.def"
+#include "stdio.h"
+#include "awk.h"
+#define printit(n) printf(printname[n-FIRSTTOKEN]);
+extern char *printname[];
+extern cell fldtab[];
+
+dump(a,b) node *a, *b;
+{
+#ifdef DEBUG
+       node *x;
+       if(a==nullstat) return;
+       for(x=a;x!=NULL;x=x->nnext)
+       {
+       if(x==b) printf(" *** ");
+               if(x->ntype==NVALUE)
+               {       switch(x->subtype)
+                       {
+                       default: runerror();
+                       case CCON: case CVAR:
+                               printf("%s",x->nobj->nval);
+                               continue;
+                       case CFLD:
+                               if(x->nobj->nval==0) printf("$%d",x->nobj - fldtab);
+                               else printf("$0");
+                               continue;
+                       }
+               }
+               else if(x->ntype==PASTAT2)
+               {       pa2dump(x,b);
+                       continue;
+               }
+               switch(x->nobj)
+               {
+               default: runerror();
+               case LE: case LT: case EQ:
+               case NE: case GT: case GE:
+               case MATCH: case NOTMATCH:
+               case ADD: case MINUS: case MULT:
+               case DIVIDE: case MOD: case ASGNOP:
+               case BOR: case AND: case CAT:
+                       dump(x->narg[0], b);
+                       printit(x->nobj);
+                       if(x->nobj!=MATCH && x->nobj!=NOTMATCH)
+                               dump(x->narg[1]);
+                       else    printf("regex");
+                       break;
+               case UMINUS: case FNCN: case INCR:
+               case DECR: case INDIRECT:
+                       printit(x->nobj);
+                       dump(x->narg[0], b);
+                       break;
+               case PRINT: case PRINTF: case SPRINTF:
+               case SPLIT:
+                       printit(x->nobj);
+                       dump(x->narg[0], b);
+                       if(x->nobj==SPLIT || x->nobj==SPRINTF) break;
+                       if(x->narg[1]==0) break;
+                       printit((int)x->narg[1]);
+                       dump(x->narg[2], b);
+                       break;
+               case IF: case WHILE:
+                       printit(x->nobj);
+                       dump(x->narg[0], b);
+                       printf(") ");
+                       dump(x->narg[1], b);
+                       if(x->narg[2]==NULL) break;
+                       printit(ELSE);
+                       dump(x->narg[2], b);
+                       break;
+               case FOR:
+                       printit(x->nobj);
+                       dump(x->narg[0], b);
+                       putchar(';');
+                       dump(x->narg[1], b);
+                       putchar(';');
+                       dump(x->narg[2], b);
+                       printf(") ");
+                       dump(x->narg[3], b);
+                       break;
+               case NEXT: case EXIT: case BREAK: case CONTINUE:
+                       printit(x->nobj);
+                       break;
+               case PROGRAM:
+                       if(x->narg[0]!=NULL)
+                       {       printf("BEGIN {");
+                               dump(x->narg[0], b);
+                               printf("}\n");
+                       }
+                       dump(x->narg[1], b);
+                       if(x->narg[2]!=NULL)
+                       {       printf("END {");
+                               dump(x->narg[2], b);
+                               printf("}\n");
+                       }
+                       break;
+               case PASTAT:
+                       dump(x->narg[0], b);
+                       printf("{");
+                       dump(x->narg[1], b);
+                       printf("}\n");
+                       break;
+               case ARRAY:
+                       printf(x->nval);
+                       printf("[");
+                       dump(x->narg[1], b);
+                       printf("]");
+                       break;
+               case SUBSTR:
+                       printit(x->nobj);
+                       dump(x->narg[0], b);
+                       putchar(',');
+                       dump(x->narg[1], b);
+                       if(x->narg[2]!=NULL)
+                       {       putchar(',');
+                               dump(x->narg[2], b);
+                       }
+                       putchar(')');
+                       break;
+               }
+               if(x->ntype == NSTAT) putchar('\n');
+       }
+#endif
+}
+pa2dump(a, b) node *a, *b;
+{
+#ifdef DEBUG
+       dump(a->narg[0], b);
+       printf(", ");
+       dump(a->narg[1], b);
+       printf(" {");
+       dump(a->narg[2], b);
+       printf("}\n");
+#endif
+}
index bdc9abb..b7f4f3a 100644 (file)
@@ -209,66 +209,16 @@ PUTS(s) char *s; {
        dprintf("%s\n", s, NULL, NULL);
 }
 
        dprintf("%s\n", s, NULL, NULL);
 }
 
-#define        MAXEXPON        38      /* maximum exponenet for fp number */
-
-isnumber(s)
-register char *s;
+/*
+isnumber(s) char *s;
 {
 {
-       register d1, d2;
-       int point;
-       char *es;
-
-       d1 = d2 = point = 0;
-       while (*s == ' ' || *s == '\t' || *s == '\n')
-               s++;
-       if (*s == '\0')
-               return(0);      /* empty stuff isn't number */
-       if (*s == '+' || *s == '-')
-               s++;
-       if (!isdigit(*s) && *s != '.')
-               return(0);
-       if (isdigit(*s)) {
-               d1++;
-               do {
-                       s++;
-               } while (isdigit(*s));
-       }
-       if (*s == '.') {
-               point++;
-               s++;
+       for(;*s!=0; s++)
+       {       if(isdigit(*s) || *s=='-' || *s=='.'
+                       || *s=='+' || *s=='e' || *s=='E')
+                       continue;
+               else    return(0);
        }
        }
-       if (d1 == 0 && point == 0)
-               return(0);
-       if (isdigit(*s)) {
-               d2++;
-               do {
-                       s++;
-               } while (isdigit(*s));
-       }
-       if (!(d1 || point && d2))
-               return(0);
-       if (*s == 'e' || *s == 'E') {
-               s++;
-               if (*s == '+' || *s == '-')
-                       s++;
-               if (!isdigit(*s))
-                       return(0);
-               es = s;
-               do {
-                       s++;
-               } while (isdigit(*s));
-               if (s - es > 2)
-                       return(0);
-               else if (s - es == 2 && 10 * (*es-'0') + *(es+1)-'0' >= MAXEXPON)
-                       return(0);
-       }
-       while (*s == ' ' || *s == '\t' || *s == '\n')
-               s++;
-       if (*s == '\0')
-               return(1);
-       else
-               return(0);
+       return(1);
 }
 }
-/*
+ */
 isnumber(s) char *s; {return(0);}
 isnumber(s) char *s; {return(0);}
-*/
diff --git a/usr/src/cmd/awk/makefile b/usr/src/cmd/awk/makefile
deleted file mode 100644 (file)
index 631cdff..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-CFLAGS=-O
-YFLAGS=-d
-
-all:   awk
-
-cp:    awk
-       cp awk /bin/awk
-       rm *.o awk.h proc awk proctab.c y.tab.h
-
-cmp:   awk
-       cmp awk /bin/awk
-       rm *.o awk.h proc awk proctab.c y.tab.h
-
-FILES=awk.lx.o b.o main.o token.o tran.o lib.o run.o parse.o proctab.o 
-SOURCE=awk.def awk.g.y awk.lx.l b.c lib.c main.c parse.c proctab.c \
-       proc.c\
-       run.c token.c tran.c
-
-awk:   $(FILES) awk.g.o
-       cc -i -s $(CFLAGS) awk.g.o $(FILES) -lm -o awk
-
-y.tab.h:       awk.g.o
-
-awk.h: y.tab.h
-       -cmp -s y.tab.h awk.h || cp y.tab.h awk.h
-
-$(FILES):      awk.h awk.def
-
-token.c:       awk.h
-       ed - <tokenscript
-       rm temp
-
-src:   $(SOURCE) test.a tokenscript makefile
-       cp $? /usr/src/cmd/awk
-       touch src
-
-profile:       awk.g.o $(FILES)
-       cc -p -i awk.g.o $(FILES) -lm
-
-find:
-       egrep -n "$(PAT)" *.[ylhc] awk.def
-
-list:
-       -pr $(SOURCE) makefile
-
-lint:
-       lint -spu b.c main.c token.c tran.c run.c lib.c parse.c -lm |\
-               egrep -v '^(error|free|malloc)'
-
-proctab.c:     proc
-       proc > proctab.c
-proc:  awk.h proc.o token.o
-       cc -o proc proc.c token.o
index 869e9e9..a64aee9 100644 (file)
@@ -4,7 +4,7 @@ struct xx
 {      int token;
        char *name;
        char *pname;
 {      int token;
        char *name;
        char *pname;
-} proc[] {
+} proc[] {
        { PROGRAM, "program", NULL},
        { BOR, "boolop", " || "},
        { AND, "boolop", " && "},
        { PROGRAM, "program", NULL},
        { BOR, "boolop", " || "},
        { AND, "boolop", " && "},
@@ -18,7 +18,7 @@ struct xx
        { ARRAY, "array", NULL},
        { INDIRECT, "indirect", "$("},
        { SUBSTR, "substr", "substr"},
        { ARRAY, "array", NULL},
        { INDIRECT, "indirect", "$("},
        { SUBSTR, "substr", "substr"},
-       { INDEX, "sindex", "sindex"},
+       { INDEX, "index", "index"},
        { SPRINTF, "asprintf", "sprintf "},
        { ADD, "arith", " + "},
        { MINUS, "arith", " - "},
        { SPRINTF, "asprintf", "sprintf "},
        { ADD, "arith", " + "},
        { MINUS, "arith", " - "},
@@ -68,12 +68,12 @@ main()
                        printf("extern obj %s();\n",p->name);
        for(p=proc;p->token!=0;p++)
                table[p->token-FIRSTTOKEN]=p->name;
                        printf("extern obj %s();\n",p->name);
        for(p=proc;p->token!=0;p++)
                table[p->token-FIRSTTOKEN]=p->name;
-       printf("obj (*proctab[%d])() {\n", SIZE);
+       printf("obj (*proctab[%d])() {\n", SIZE);
        for(i=0;i<SIZE;i++)
                if(table[i]==0) printf("/*%s*/\tnullproc,\n",tokname(i+FIRSTTOKEN));
                else printf("/*%s*/\t%s,\n",tokname(i+FIRSTTOKEN),table[i]);
        printf("};\n");
        for(i=0;i<SIZE;i++)
                if(table[i]==0) printf("/*%s*/\tnullproc,\n",tokname(i+FIRSTTOKEN));
                else printf("/*%s*/\t%s,\n",tokname(i+FIRSTTOKEN),table[i]);
        printf("};\n");
-       printf("char *printname[%d] {\n", SIZE);
+       printf("char *printname[%d] {\n", SIZE);
        for(p=proc; p->token!=0; p++)
                names[p->token-FIRSTTOKEN] = p->pname;
        for(i=0; i<SIZE; i++)
        for(p=proc; p->token!=0; p++)
                names[p->token-FIRSTTOKEN] = p->pname;
        for(i=0; i<SIZE; i++)
index 4fc6d43..7bf7f05 100644 (file)
@@ -31,7 +31,7 @@ obj execute(u) node *u;
 {
        register obj (*proc)();
        obj x;
 {
        register obj (*proc)();
        obj x;
-       node *a;
+       register node *a;
        extern char *printname[];
 
        if (u==(node *)NULL)
        extern char *printname[];
 
        if (u==(node *)NULL)
@@ -43,7 +43,8 @@ obj execute(u) node *u;
                        proc=dopa2;
                else {
                        if (notlegal(a->nobj))
                        proc=dopa2;
                else {
                        if (notlegal(a->nobj))
-                               error(FATAL, "illegal statement %o", a);
+                               error(FATAL, "illegal procedure %o %s", proctab[a->nobj-FIRSTTOKEN],
+                                       printname[a->nobj-FIRSTTOKEN]);
                        proc = proctab[a->nobj-FIRSTTOKEN];
                }
                x = (*proc)(a->narg,a->nobj);
                        proc = proctab[a->nobj-FIRSTTOKEN];
                }
                x = (*proc)(a->narg,a->nobj);
@@ -179,11 +180,11 @@ obj relop(a,n) node **a;
 
        x = execute(a[0]);
        y = execute(a[1]);
 
        x = execute(a[0]);
        y = execute(a[1]);
-       if (x.optr->tval&NUM && y.optr->tval&NUM) {
-               j = x.optr->fval - y.optr->fval;
+       if ((x.optr->tval&NUM)==0 && (y.optr->tval&NUM)==0)
+               i = strcmp(x.optr->sval, y.optr->sval);
+       else {
+               j = getfval(x.optr) - getfval(y.optr);
                i = j<0? -1: (j>0? 1: 0);
                i = j<0? -1: (j>0? 1: 0);
-       } else {
-               i = strcmp(getsval(x.optr), getsval(y.optr));
        }
        tempfree(x);
        tempfree(y);
        }
        tempfree(x);
        tempfree(y);
@@ -283,7 +284,7 @@ obj substr(a, nnn) node **a;
        return(x);
 }
 
        return(x);
 }
 
-obj sindex(a, nnn) node **a;
+obj index(a, nnn) node **a;
 {
        obj x, y;
        char *s1, *s2, *p1, *p2, *q;
 {
        obj x, y;
        char *s1, *s2, *p1, *p2, *q;
@@ -300,7 +301,7 @@ obj sindex(a, nnn) node **a;
                for (q=p1, p2=s2; *p2 != '\0' && *q == *p2; q++, p2++)
                        ;
                if (*p2 == '\0') {
                for (q=p1, p2=s2; *p2 != '\0' && *q == *p2; q++, p2++)
                        ;
                if (*p2 == '\0') {
-                       setfval(x.optr, (awkfloat) (p1 - s1 + 1));      /* origin 1 */
+                       setfval(x.optr, (float) (p1 - s1 + 1)); /* origin 1 */
                        return(x);
                }
        }
                        return(x);
                }
        }
@@ -357,7 +358,6 @@ char *format(s,a) char *s; node *a;
                }
                if (flag == 0) {
                        sprintf(p, "%s", fmt);
                }
                if (flag == 0) {
                        sprintf(p, "%s", fmt);
-                       p += strlen(p);
                        continue;
                }
                if (a == NULL)
                        continue;
                }
                if (a == NULL)
@@ -651,11 +651,7 @@ obj whilestat(a,n) node **a;
                if (!istrue(x)) return(x);
                tempfree(x);
                x = execute(a[1]);
                if (!istrue(x)) return(x);
                tempfree(x);
                x = execute(a[1]);
-               if (isbreak(x)) {
-                       x = true;
-                       return(x);
-               }
-               if (isnext(x) || isexit(x))
+               if (isbreak(x) || isnext(x) || isexit(x))
                        return(x);
                tempfree(x);
        }
                        return(x);
                tempfree(x);
        }
@@ -697,7 +693,6 @@ obj instat(a, n) node **a;
        tp = (cell **) arrayp->sval;
        for (i = 0; i < MAXSYM; i++) {  /* this routine knows too much */
                for (cp = tp[i]; cp != NULL; cp = cp->nextval) {
        tp = (cell **) arrayp->sval;
        for (i = 0; i < MAXSYM; i++) {  /* this routine knows too much */
                for (cp = tp[i]; cp != NULL; cp = cp->nextval) {
-                       xfree(vp->sval);
                        vp->sval = tostring(cp->nval);
                        vp->tval = STR;
                        x = execute(a[2]);
                        vp->sval = tostring(cp->nval);
                        vp->tval = STR;
                        x = execute(a[2]);
@@ -830,3 +825,13 @@ doit:
        fprintf(files[i].fp, "%s", s);
        tempfree(x);
 }
        fprintf(files[i].fp, "%s", s);
        tempfree(x);
 }
+
+#ifdef gcos
+
+FILE *popen(s1, s2)    /* fake */
+char *s1, *s2;
+{
+       error(FATAL, "can't open pipe %s on gcos\n", s1);
+}
+
+#endif
index b5f7f06..769e8df 100644 (file)
@@ -76,7 +76,7 @@ cell **tab;
        register cell *p;
        cell *lookup();
 
        register cell *p;
        cell *lookup();
 
-       if (n != NULL && (p = lookup(n, tab)) != NULL) {
+       if (n != NULL && *n != '\0' && (p = lookup(n, tab)) != NULL) {
                xfree(s);
                dprintf("setsymtab found %o: %s", p, p->nval, NULL);
                dprintf(" %s %g %o\n", p->sval, p->fval, p->tval);
                xfree(s);
                dprintf("setsymtab found %o: %s", p, p->nval, NULL);
                dprintf(" %s %g %o\n", p->sval, p->fval, p->tval);
@@ -162,17 +162,13 @@ register cell *vp;
        dprintf("getfval: %o", vp, NULL, NULL);
        checkval(vp);
        if ((vp->tval & NUM) == 0) {
        dprintf("getfval: %o", vp, NULL, NULL);
        checkval(vp);
        if ((vp->tval & NUM) == 0) {
-               /* the problem is to make non-numeric things */
-               /* have unlikely numeric variables, so that */
-               /* $1 == $2 comparisons sort of make sense when */
-               /* one or the other is numeric */
-               if (isnumber(vp->sval)) {
-                       vp->fval = atof(vp->sval);
-                       if (!(vp->tval & CON))  /* don't change type of a constant */
-                               vp->tval |= NUM;
+               vp->fval = atof(vp->sval);
+               vp->tval |= NUM;
+               if (*vp->sval == '\0') {        /* "" is not equal to "0" */
+                       vp->tval &= ~STR;
+                       if (!(vp->tval&FLD))
+                               xfree(vp->sval);
                }
                }
-               else
-                       vp->fval = 0.0; /* not a very good idea */
        }
        dprintf("  %g\n", vp->fval, NULL, NULL);
        return(vp->fval);
        }
        dprintf("  %g\n", vp->fval, NULL, NULL);
        return(vp->fval);
diff --git a/usr/src/cmd/bas/bas.s b/usr/src/cmd/bas/bas.s
deleted file mode 100644 (file)
index 19c65d0..0000000
+++ /dev/null
@@ -1,2128 +0,0 @@
-/
-/
-
-/ bas0 -- basic
-
-scope = 1
-.globl main
-.globl sin, cos, log, exp, atan, pow, sqrt
-.globl rand, srand
-.globl fptrap
-.globl fopen, getc
-
-indir =        0  /for  indirect sys calls. (not in as)
-one = 40200
-
-main:
-       mov     $1,prfile /initial print file
-       sys     signal; 4; fptrap
-       setd
-       sys     time
-       mov     r1,r0
-       mov     r0,randx
-       jsr     pc,srand
-       sys     signal; 1; _done
-       sys     signal; 2; intrup
-       tst     r0
-       jeq     1f
-       sys     signal; 2; 1
-1:
-       mov     sp,gsp
-       clr     seeka
-       mov     $'a,r1
-1:
-       movb    r1,tmpf+8
-       sys     stat; tmpf; line
-       bes     1f
-       inc     r1
-       cmp     r1,$'z
-       blos    1b
-       br      2f
-1:
-       sys     creat; tmpf; 600
-       bes     2f
-       mov     r0,tfo
-       sys     open; tmpf; 0
-       bec     1f
-2:
-       mov     $3f,r0
-       jsr     pc,print
-       sys     exit
-3:
-       <Tmp file?\n\0>; .even
-1:
-       mov     r0,tfi
-
-       mov     gsp,sp
-       cmp     (sp),$2  /is there a file argument
-       blt     noarg
-       mov     4(sp),r0
-       mov     $argname,r1
-1:
-       movb    (r0)+,(r1)+
-       bne     1b
-aftered: / after edit
-       mov     $argname,r0
-       jsr     r5,fopen; iobuf
-       bes     1f
-noarg:
-       jsr     pc,isymtab
-       br      loop
-1:
-       mov     $1f,r0
-       jsr     pc,print
-       br      loop
-1:
-       <Cannot open file\n\0>; .even
-
-intrup:
-       sys     signal; 2; intrup
-       mov     $'\n,r0
-       jsr     r5,xputc
-       jsr     r5,error
-               <ready\n\0>; .even
-
-loop:
-       mov     gsp,sp
-       clr     lineno
-       jsr     pc,rdline
-       mov     $line,r3
-1:
-       movb    (r3),r0
-       jsr     pc,digit
-               br 1f
-       jsr     r5,atoi
-       cmp     r0,$' /
-       beq     3f
-       cmp     r0,$'    /tab
-       bne     1f
-3:
-       mov     $lintab,r3
-       mov     r1,r0
-       bgt     2f
-       jsr     pc,serror
-2:
-       cmp     r0,(r3)
-       beq     2f
-       tst     (r3)
-       beq     2f
-       add     $6,r3
-       br      2b
-2:
-       cmp     r3,$elintab-12.
-       blo     2f
-       jsr     r5,error
-               <too many lines\n\0>; .even
-2:
-       mov     r0,(r3)+
-       mov     seeka,(r3)+
-       mov     tfo,r0
-       mov     seeka,seekx
-       sys     indir; sysseek
-       mov     $line,r0
-       jsr     pc,size
-       inc     r0
-       add     r0,seeka
-       mov     r0,wlen
-       mov     tfo,r0
-       mov     $line,wbuf
-       sys     indir;syswrit
-       br      loop
-1:
-       mov     $line,r3
-       jsr     pc,singstat
-       br      loop
-
-nextc:
-       movb    (r3)+,r0
-       rts     r5
-
-size:
-       clr     -(sp)
-1:
-       inc     (sp)
-       cmpb    (r0),$'\n
-       beq     1f
-       cmpb    (r0),$0
-       beq     1f
-       inc     r0
-       br      1b
-1:
-       mov     (sp)+,r0
-       rts     pc
-
-rdline:  / read input (file or tty) to carr. ret.
-       mov     $line,r1
-1:
-       jsr     r5,getc; iobuf
-       bes     2f
-       tst     r0
-       beq     2f
-       cmp     r1,$line+99.
-       bhis    2f                      / bad check, but a check
-       movb    r0,(r1)+
-       cmpb    r0,$'\n
-       bne     1b
-       clrb    (r1)
-       rts     pc
-2:
-       mov     fi,r0
-       beq     1f
-       sys     close
-       clr     fi
-       br      1b
-1:
-       jmp     _done
-
-error:
-       tst     fi
-       beq     1f
-       sys     close
-       clr     fi
-1:
-       tst     lineno
-       beq     1f
-       jsr     pc,nextlin
-               br 1f
-       mov     $line,r0
-       jsr     pc,print
-1:
-       mov     r5,r0
-       jsr     pc,print
-       jmp     loop
-
-serror:
-       dec     r3
-       tst     fi
-       beq     1f
-       sys     close
-       clr     fi
-1:
-       mov     $line,r1
-1:
-       cmp     r1,r3
-       bne     2f
-       mov     $'_,r0
-       jsr     r5,xputc
-       mov     $10,r0
-       jsr     r5,xputc
-2:
-       movb    (r1),r0
-       jsr     r5,xputc
-       cmpb    (r1)+,$'\n
-       bne     1b
-       jmp     loop
-
-print:
-       mov     r0,wbuf
-       jsr     pc,size
-       mov     r0,wlen
-       mov     prfile,r0
-       sys     indir; syswrit
-       rts     pc
-
-digit:
-       cmp     r0,$'0
-       blo     1f
-       cmp     r0,$'9
-       bhi     1f
-       add     $2,(sp)
-1:
-       rts     pc
-
-alpha:
-       cmp     r0,$'a
-       blo     1f
-       cmp     r0,$'z
-       bhi     1f
-       add     $2,(sp)
-1:
-       cmp     r0,$'A
-       blo     1f
-       cmp     r0,$'Z
-       bhi     1f
-       add     $2,(sp)
-1:
-       rts     pc
-
-name:
-       mov     $nameb,r1
-       clr     (r1)
-       clr     2(r1)
-1:
-       cmp     r1,$nameb+4
-       bhis    2f
-       movb    r0,(r1)+
-2:
-       movb    (r3)+,r0
-       jsr     pc,alpha
-               br 2f
-       br      1b
-2:
-       jsr     pc,digit
-               br 2f
-       br      1b
-2:
-       mov     $resnam,r1
-1:
-       cmp     nameb,(r1)
-       bne     2f
-       cmp     nameb+2,2(r1)
-       bne     2f
-       sub     $resnam,r1
-       asr     r1
-       add     $2,(sp)
-       rts     pc
-2:
-       add     $4,r1
-       cmp     r1,$eresnam
-       blo     1b
-       mov     $symtab,r1
-1:
-       tst     (r1)
-       beq     1f
-       cmp     nameb,(r1)
-       bne     2f
-       cmp     nameb+2,2(r1)
-       bne     2f
-       rts     pc
-2:
-       add     $14.,r1
-       br      1b
-1:
-       cmp     r1,$esymtab-28.
-       blo     1f
-       jsr     r5,error
-               <out of symbol space\n\0>; .even
-1:
-       mov     nameb,(r1)
-       mov     nameb+2,2(r1)
-       clr     4(r1)
-       clr     14.(r1)
-       rts     pc
-
-skip:
-       cmp     r0,$' /
-       beq     1f
-       cmp     r0,$'     / tab
-       bne     2f
-1:
-       movb    (r3)+,r0
-       br      skip
-2:
-       rts     pc
-
-xputc:
-.if scope  / for plotting
-       tstb    drflg
-       beq     1f
-       jsr     pc,drput
-       rts     r5
-1:
-.endif
-       mov     r0,ch
-       mov     $1,r0
-       sys     write; ch; 1
-       rts     r5
-
-nextlin:
-       clr     -(sp)
-       mov     $lintab,r1
-1:
-       tst     (r1)
-       beq     1f
-       cmp     lineno,(r1)
-       bhi     2f
-       mov     (sp),r0
-       beq     3f
-       cmp     (r0),(r1)
-       blos    2f
-3:
-       mov     r1,(sp)
-2:
-       add     $6,r1
-       br      1b
-1:
-       mov     (sp)+,r1
-       beq     1f
-       mov     (r1)+,lineno
-       mov     (r1)+,seekx
-       mov     tfi,r0
-       sys     indir; sysseek
-       mov     tfi,r0
-       sys     read; line; 100.
-       add     $2,(sp)
-1:
-       rts     pc
-
-getloc:
-       mov     $lintab,r1
-1:
-       tst     (r1)
-       beq     1f
-       cmp     r0,(r1)
-       beq     2f
-       add     $6,r1
-       br      1b
-1:
-       jsr     r5,error
-               <label not found\n\0>; .even
-2:
-       rts     pc
-
-isymtab:
-       mov     $symtab,r0
-       mov     $symtnam,r1
-       clrf    fr0
-       movf    $one,fr1
-1:
-       mov     (r1)+,(r0)+
-       mov     (r1)+,(r0)+
-       mov     $1,(r0)+
-       subf    r1,r0
-       movf    r0,(r0)+
-       cmp     r1,$esymtnam
-       blo     1b
-       clr     (r0)+
-       rts     pc
-
-/
-/
-
-/ bas1 -- compile
-/
-/    convention:       jsr pc,subrout /test
-/                              br failside
-/                      succeed ...
-
-compile:
-       clr     forp
-       mov     $iflev,ifp /added for if..else..fi
-       mov     $space,r4
-       tst     lineno
-       beq     1f
-       rts     pc
-1:
-       jsr     pc,nextlin
-               br 1f
-       mov     lineno,r0
-       jsr     pc,getloc
-       mov     r4,4(r1)
-       jsr     pc,statement
-               br .+2
-       inc     lineno
-       cmp     r4,$espace+20  / out of code space?
-       blo     1b
-       jsr     r5,error
-               <out of code space\n\0>; .even
-1:
-       tst     forp
-       jne     forer
-       cmp     ifp,$iflev
-       jne     fier   /hanging if..fi
-       mov     $loop,(r4)+
-       rts     pc
-
-singstat:
-       clr     forp
-       mov     $iflev,ifp
-       mov     $exline,r4
-       jsr     pc,statement
-               br 1f
-       cmp     -2(r4),$_asgn
-       beq     1f
-       mov     $_print,(r4)+
-       mov     $_nline,(r4)+
-1:
-       tst     forp
-       jne     forer
-       cmp     r4,$eexline
-       blo     1f
-       jsr     r5,error
-               <out of code space\n\0>; .even
-1:
-       mov     $loop,(r4)+
-       mov     r4,exprloc
-       mov     $exline,r4
-       jmp     execute
-
-statement:
-       mov     $line,r3
-       movb    (r3)+,r0
-       jsr     pc,digit
-               br stat1
-       dec     r3
-       jsr     r5,atoi
-       cmp     r0,$' /
-       beq     1f
-       cmp     r0,$'    /tab
-       beq     1f
-       mov     $line,r3
-       movb    (r3)+,r0
-       br      stat1
-1:
-       mov     $_line,(r4)+
-       mov     r1,(r4)+
-
-stat1:
-       jsr     pc,skip
-       cmp     r0,$'\n
-       bne     .+4
-       rts     pc
-       mov     r3,-(sp)
-       jsr     pc,alpha
-               br 1f
-       jsr     pc,name
-               br 1f
-       tst     (sp)+
-       jsr     pc,skip
-       dec     r3
-       jmp     *2f(r1)
-2:
-       stlist
-       stdone
-       stdone
-       strun
-       stprint
-       stprompt   / prompt is like print except for cr
-       stif
-       stgoto
-       streturn
-       stfor
-       stnext
-       stoctl
-       stsave
-       stdump
-       stfi
-       stelse
-       stedit
-       stcomment
-.if scope    / for plotting on tektronix
-       stdisp
-       stdraw
-       steras
-.endif
-
-1:
-       mov     (sp)+,r3
-       dec     r3
-       jsr     pc,expr
-       cmp     r0,$'\n
-       jne     joe
-       add     $2,(sp)
-       rts     pc
-
-stsave:
-       mov     $_save,func
-       br      1f
-
-stlist:
-       mov     $_list,func
-1:
-       cmp     r0,$'\n
-       bne     1f
-       clrf    r0
-       jsr     pc,const
-       movif   $77777,r0
-       jsr     pc,const
-       br      2f
-1:
-       jsr     pc,expr
-       cmp     r0,$'\n
-       bne     1f
-       mov     $_dup,(r4)+
-       br      2f
-1:
-       dec     r3
-       jsr     pc,expr
-       cmp     r0,$'\n
-       jne     joe
-2:
-       mov     func,(r4)+
-       rts     pc
-
-stdone:
-       cmp     r0,$'\n
-       jne     joe
-       mov     $_done,(r4)+
-       rts     pc
-
-strun:
-       cmp     r0,$'\n
-       jne     joe
-       mov     $_run,(r4)+
-       rts     pc
-
-
-stprompt:
-       clr     -(sp)
-       br      stpr2
-
-stdump:
-       cmp     r0,$'\n
-       jne     joe
-       mov     $_dump,(r4)+
-       rts     pc
-
-stprint:
-       mov     pc,-(sp)
-stpr2:
-       movb    (r3)+,r0
-       jsr     pc,skip
-1:
-       cmp     r0,$'\n
-       beq     2f
-       cmp     r0,$'"
-       beq     1f
-       dec     r3
-       jsr     pc,expr
-       mov     $_print,(r4)+
-       br      1b
-1:
-       mov     $_ascii,(r4)+
-1:
-       movb    (r3)+,(r4)
-       cmpb    (r4),$'"
-       beq     1f
-       cmpb    (r4)+,$'\n
-       bne     1b
-       jbr     joe
-1:
-       add     $2,r4
-       bic     $1,r4
-       br      stpr2
-2:
-       tst     (sp)+
-       beq     1f
-       mov     $_nline,(r4)+
-1:
-       rts     pc
-
-stif:
-       jsr     pc,expr
-       mov     $_if,(r4)+
-       mov     r4,*ifp
-       add     $2,ifp
-       tst     (r4)+
-       jsr     pc,skip
-       cmp     r0,$'\n   / if ... fi
-       beq     1f
-       jsr     pc,stat1
-               br  .+2
-stfi:
-       sub     $2,ifp
-       cmp     ifp,$iflev
-       jlo     fier
-       mov     *ifp,r1  /for jump around if
-       mov     r4,(r1)
-1:
-       rts     pc
-
-fier:
-       jsr     r5,error; <if...else...fi imbalance\n\0>; .even
-
-stelse:
-       mov     $_tra,(r4)+  /jump around else side
-       mov     r4+,-(sp) / save hole
-       tst     (r4)+
-       sub     $2,ifp
-       cmp     ifp,$iflev
-       jlo     fier
-       mov     *ifp,r1
-       mov     r4,(r1)  /fill in jump to else
-       mov     (sp)+,*ifp /save hole for fi
-       add     $2,ifp
-       rts     pc
-
-stedit:  / enter the regular editor <ed>
-       sys fork
-       br      newpr
-       mov     $lintab,r0  / zero out line table during edit
-1:
-       cmp     r0,$elintab  /done
-       beq     1f
-       mov     $0,(r0)+
-       br      1b
-1:
-       sys     unlink; tmpf
-       sys     wait
-       jmp     aftered / start over
-newpr:
-       sys     exec; ed; edarg
-       sys     exit
-ed:    </bin/ed\0> ; .even
-ednm:  <-\n>
- .even
-edarg: ednm; argname; 0
-
-stcomment:  /comment line
-       cmp     r0,$'\n
-       beq     1f
-       movb    (r3)+,r0
-       br      stcomment
-1:
-       rts     pc
-stgoto:
-       jsr     pc,expr
-       mov     $_goto,(r4)+
-       rts     pc
-
-streturn:
-       cmp     r0,$'\n
-       beq     1f
-       jsr     pc,expr
-       cmp     r0,$'\n
-       bne     joe
-       br      2f
-1:
-       clrf    r0
-       jsr     pc,const
-2:
-       mov     $_return,(r4)+
-       rts     pc
-
-joe:
-       jsr     pc,serror
-
-stfor:
-       mov     r4,-(sp)
-       jsr     pc,e2
-       mov     r4,-(sp)
-       cmp     r0,$'=
-       bne     joe
-       tst     val
-       bne     joe
-       jsr     pc,expr
-       mov     forp,(r4)+      / overlay w _asgn
-       mov     r4,forp
-       cmp     (r4)+,(r4)+     / _tra ..
-       mov     (sp)+,r0
-       mov     (sp)+,r1
-1:
-       mov     (r1)+,(r4)+
-       cmp     r1,r0
-       blo     1b
-       mov     $_fori,(r4)+
-       mov     forp,r1
-       mov     $_tra,(r1)+
-       mov     r4,(r1)+
-       dec     r3
-       jsr     pc,expr
-       mov     $_lesseq,(r4)+
-       mov     $_if,(r4)+
-       mov     forp,(r4)+
-       mov     r4,forp
-       cmp     r0,$'\n
-       beq     1f
-       jsr     pc,stat1
-               br .+2
-       br      stnext
-1:
-       rts     pc
-
-forer:
-       jsr     r5,error; <for/next imbalance\n\0>; .even
-
-stnext:
-       mov     forp,r1
-       beq     forer
-       mov     -(r1),r0
-       mov     -(r0),forp
-       mov     $_ptra,(r4)+
-       mov     $_asgn,(r0)+
-       cmp     (r0)+,(r0)+
-       mov     r0,(r4)+
-       mov     r4,(r1)+
-       rts     pc
-
-stoctl:
-       jsr     pc,expr
-       mov     $_octal,(r4)+
-       rts     pc
-
-.if scope  / for plotting
-stdisp:
-       mov     $_sdisp,(r4)+
-       jsr     pc,stprint
-       mov     $_fdisp,(r4)+
-       rts     pc
-stdraw:
-       jsr     pc,expr
-       dec     r3
-       jsr     pc,expr
-       cmp     r0,$'\n
-       bne     1f
-       movf    $one,r0
-       jsr     pc,const
-       br      2f
-1:
-       dec     r3
-       jsr     pc,expr
-2:
-       mov     $_draw,(r4)+
-       rts     pc
-
-steras:
-       mov     $_erase,(r4)+
-       rts     pc
-.endif
-
-/
-/
-
-/ bas2 -- expression evaluation
-
-expr:
-       jsr     pc,e1
-       jsr     pc,rval
-       rts     pc
-
-/ assignment right to left
-e1:
-       jsr     pc,e2
-       cmp     r0,$'=
-       beq     1f
-       jsr     pc,rval
-       rts     pc
-1:
-       tst     val
-       beq     1f
-       jsr     pc,serror
-1:
-       jsr     pc,e1
-       jsr     r5,op; _asgn
-       rts     pc
-
-/ and or left to right
-e2:
-       jsr     pc,e3
-1:
-       cmp     r0,$'&
-       beq     2f
-       cmp     r0,$'|
-       beq     3f
-       rts     pc
-2:
-       jsr     pc,rval
-       jsr     pc,e3
-       jsr     r5,op; _and
-       br      1b
-3:
-       jsr     pc,rval
-       jsr     pc,e3
-       jsr     r5,op; _or
-       br      1b
-
-/ relation extended relation
-e3:
-       jsr     pc,e4
-       jsr     pc,e3a
-               rts pc
-       clr     -(sp)
-1:
-       mov     r0,-(sp)
-       jsr     pc,e4
-       jsr     pc,rval
-       mov     (sp)+,(r4)+
-       jsr     pc,e3a
-               br 1f
-       mov     $_extr,(r4)+
-       inc     (sp)
-       br      1b
-1:
-       dec     (sp)
-       blt     1f
-       mov     $_and,(r4)+
-       br      1b
-1:
-       tst     (sp)+
-       rts     pc
-
-/ relational operator
-e3a:
-       cmp     r0,$'>
-       beq     1f
-       cmp     r0,$'<
-       beq     2f
-       cmp     r0,$'=
-       beq     3f
-       rts     pc
-1:
-       mov     $_great,r0
-       cmpb    (r3),$'=
-       bne     1f
-       inc     r3
-       mov     $_greateq,r0
-       br      1f
-2:
-       cmpb    (r3),$'>
-       bne     2f
-       inc     r3
-       mov     $_noteq,r0
-       br      1f
-2:
-       mov     $_less,r0
-       cmpb    (r3),$'=
-       bne     1f
-       inc     r3
-       mov     $_lesseq,r0
-       br      1f
-3:
-       cmpb    (r3),$'=
-       beq     2f
-       rts     pc
-2:
-       inc     r3
-       mov     $_equal,r0
-1:
-       jsr     pc,rval
-       add     $2,(sp)
-       rts     pc
-
-/ add subtract
-e4:
-       jsr     pc,e5
-1:
-       cmp     r0,$'+
-       beq     2f
-       cmp     r0,$'-
-       beq     3f
-       rts     pc
-2:
-       jsr     pc,rval
-       jsr     pc,e5
-       jsr     r5,op; _add
-       br      1b
-3:
-       jsr     pc,rval
-       jsr     pc,e5
-       jsr     r5,op; _sub
-       br      1b
-
-/ multiply divide
-e5:
-       jsr     pc,e6
-1:
-       cmp     r0,$'*
-       beq     2f
-       cmp     r0,$'/
-       beq     3f
-       rts     pc
-2:
-       jsr     pc,rval
-       jsr     pc,e6
-       jsr     r5,op; _mult
-       br      1b
-3:
-       jsr     pc,rval
-       jsr     pc,e6
-       jsr     r5,op; _divid
-       br      1b
-
-/ exponential
-e6:
-       jsr     pc,e6a
-1:
-       cmp     r0,$'^
-       beq     2f
-       rts     pc
-2:
-       jsr     pc,rval
-       jsr     pc,e6a
-       jsr     r5,op; _expon
-       br      1b
-
-e6a:
-       movb    (r3)+,r0
-       jsr     pc,skip
-       cmp     r0,$'_
-       bne     1f
-       jsr     pc,e6a
-       jsr     r5,op; _neg
-       rts     pc
-1:
-       dec     r3
-       jsr     pc,e7
-       rts     pc
-/ end of unary -
-
-/ primary
-e7:
-       movb    (r3)+,r0
-       jsr     pc,skip
-       mov     $1,val
-       cmp     r0,$'(
-       bne     1f
-       jsr     pc,e1
-       cmp     r0,$')
-       bne     2f
-       movb    (r3)+,r0
-       br      e7a
-2:
-       jsr     pc,serror
-1:
-       cmp     r0,$'.
-       beq     2f
-       jsr     pc,digit
-               br 1f
-2:
-       dec     r3
-       jsr     r5,atof; nextc
-       jsr     pc,const
-       br      e7a
-1:
-       jsr     pc,alpha
-               br jim
-       jsr     pc,name
-               br 2f
-       jsr     r5,error; <reserved name\n\0>; .even
-2:
-/ try to fix illegal symbol bug:
-       cmp     r4,$eexline
-       bhis    jim
-
-       mov     $_lval,(r4)+
-       mov     r1,(r4)+
-       clr     val
-       br      e7a
-jim:
-       jsr     pc,serror
-
-e7a:
-       jsr     pc,skip
-       cmp     r0,$'(
-       bne     1f
-       jsr     pc,rval
-       jsr     r5,rlist; _funct
-       cmp     r0,$')
-       bne     jim
-       movb    (r3)+,r0
-       br      e7a
-1:
-       cmp     r0,$'[
-       bne     1f
-       tst     val
-       beq     2f
-       jsr     pc,serror
-2:
-       jsr     r5,rlist; _subscr
-       clr     val
-       cmp     r0,$']
-       bne     jim
-       movb    (r3)+,r0
-       br      e7a
-1:
-       rts     pc
-
-op:
-       jsr     pc,rval
-       mov     (r5)+,(r4)+
-       rts     r5
-
-rval:
-       tst     val
-       bne     1f
-       mov     $_rval,(r4)+
-       inc     val
-1:
-       rts     pc
-
-const:
-       mov     r0,-(sp)
-       movf    r1,-(sp)
-       tstf    r0
-       cfcc
-       bne     1f
-       mov     $_con0,(r4)+
-       br      2f
-1:
-       cmpf    $one,r0
-       cfcc
-       bne     1f
-       mov     $_con1,(r4)+
-       br      2f
-1:
-       movfi   r0,r0
-       movif   r0,r1
-       cmpf    r0,r1
-       cfcc
-       bne     1f
-       mov     $_intcon,(r4)+
-       mov     r0,(r4)+
-       br      2f
-1:
-       mov     $_const,(r4)+
-       movf    r0,(r4)+
-2:
-       movf    (sp)+,r1
-       mov     (sp)+,r0
-       rts     pc
-
-rlist:
-       clr     -(sp)
-       cmpb    (r3),$')
-       bne     1f
-       movb    (r3)+,r0
-       br      2f
-1:
-       inc     (sp)
-       jsr     pc,expr
-       cmp     r0,$',
-       beq     1b
-2:
-       mov     (r5)+,(r4)+
-       mov     (sp)+,(r4)+
-       rts     r5
-
-/
-/
-/ bas3 -- execution
-
-execute:
-       mov     $estack,r3
-       mov     r3,sstack
-       jmp     *(r4)+
-
-_if:
-       tstf    (r3)+
-       cfcc
-       beq     _tra
-       tst     (r4)+
-       jmp     *(r4)+
-
-_ptra:
-       mov     sstack,r3
-
-_tra:
-       mov     (r4)+,r4
-       jmp     *(r4)+
-
-_funct:
-       mov     r4,-(r3)
-       mov     sstack,-(r3)
-       mov     r3,sstack
-       inc     sublev
-       clr     r0
-       jsr     pc,arg
-       tstf    r0
-       cfcc
-       bge     1f
-       jmp     builtin
-
-_goto:
-       movf    (r3),r0
-1:
-       movfi   r0,-(sp)
-       jsr     pc,compile
-       mov     (sp)+,r0
-       jsr     pc,getloc
-       mov     4(r1),r4
-       jmp     *(r4)+
-
-_run:
-       jsr     pc,isymtab
-       mov     randx,r0
-       jsr     pc,srand
-       jsr     pc,compile
-       mov     $space,r4
-       jmp     *(r4)+
-
-_save:    / _save is a _list to the file named on the bas command
-       sys     creat; argname; 666
-       bes     1f
-       mov     r0,prfile
-       br      2f
-1:
-       mov     1f,r0
-       mov     $1,prfile
-       jsr     pc,print
-       br      _done
-1:     <Cannot create b.out\n\0>; .even
-
-_list:
-       mov     $1,prfile
-2:
-       movf    (r3)+,r0
-       movfi   r0,-(sp)
-/ probably vistigal??  mov     r3,0f
-       movf    (r3),r0
-       movfi   r0,lineno
-1:
-       jsr     pc,nextlin
-               br 1f
-       cmp     lineno,(sp)
-       bhi     1f
-       mov     $line,r0
-       jsr     pc,print
-       inc     lineno
-       br      1b
-1:
-       cmp     $1,prfile
-       beq     1f
-       mov     prfile,r0
-       sys     close
-       mov     $1,prfile
-1:
-       tst     (sp)+
-       jmp     *(r4)+
-
-_done:
-       sys     unlink; tmpf
-       sys     exit
-
-.if scope  / for plotting
-_sdisp:
-       mov     $2,r0
-       jsr     pc,drput
-       jsr     pc,drxy
-       mov     $1,r0
-       jsr     pc,drput
-       mov     $3,r0
-       jsr     pc,drput
-       incb    drflg
-       jmp     *(r4)+
-
-_fdisp:
-       clr     r0
-       jsr     pc,drput
-       clrb    drflg
-       jmp     *(r4)+
-
-_draw:
-       movf    (r3)+,r2
-       movf    (r3)+,r1
-       movf    (r3)+,r0
-       jsr     r5,draw
-       jmp     *(r4)+
-
-_erase:
-       mov     $1,r0
-       jsr     pc,drput
-       mov     $1,r0
-       jsr     pc,drput
-       jmp     *(r4)+
-.endif
-
-_print:
-       movf    (r3)+,r0
-       jsr     r5,ftoa; xputc
-       jmp     *(r4)+
-
-_octal:
-       movf    (r3)+,r0
-       jsr     r5,ftoo; xputc
-       jmp     *(r4)+
-
-_nline:
-       mov     $'\n,r0
-       jsr     r5,xputc
-       jmp     *(r4)+
-
-_ascii:
-       movb    (r4)+,r0
-       cmp     r0,$'"
-       beq     1f
-       jsr     r5,xputc
-       br      _ascii
-1:
-       inc     r4
-       bic     $1,r4
-       jmp     *(r4)+
-
-_line:
-       mov     sstack,r3
-       cmp     r3,$stack+20.
-       bhi     1f
-       jsr     r5,error
-               <out of space\n\0>; .even
-1:
-       mov     (r4)+,lineno
-       jmp     *(r4)+
-
-_or:
-       tstf    (r3)+
-       cfcc
-       bne     stone
-       tstf    (r3)
-       cfcc
-       bne     stone
-       br      stzero
-
-_and:
-       tstf    (r3)+
-       cfcc
-       beq     stzero
-       tstf    (r3)
-       cfcc
-       beq     stzero
-       br      stone
-
-_great:
-       jsr     pc,bool
-       bgt     stone
-       br      stzero
-
-_greateq:
-       jsr     pc,bool
-       bge     stone
-       br      stzero
-
-_less:
-       jsr     pc,bool
-       blt     stone
-       br      stzero
-
-_lesseq:
-       jsr     pc,bool
-       ble     stone
-       br      stzero
-
-_noteq:
-       jsr     pc,bool
-       bne     stone
-       br      stzero
-
-_equal:
-       jsr     pc,bool
-       beq     stone
-
-stzero:
-       clrf    r0
-       br      advanc
-
-stone:
-       movf    $one,r0
-       br      advanc
-
-_extr:
-       movf    r1,r0           / dup for _and in extended rel
-       br      subadv
-
-_asgn:
-       movf    (r3)+,r0
-       mov     (r3)+,r0
-       add     $4,r0
-       bis     $1,(r0)+
-       movf    r0,(r0)
-       br      subadv
-
-_add:
-       movf    (r3)+,r0
-       addf    (r3),r0
-       br      advanc
-
-_sub:
-       movf    (r3)+,r0
-       negf    r0
-       addf    (r3),r0
-       br      advanc
-
-_mult:
-       movf    (r3)+,r0
-       mulf    (r3),r0
-       br      advanc
-
-_divid:
-       movf    (r3)+,r1
-       movf    (r3),r0
-       divf    r1,r0
-       br      advanc
-
-_expon:
-       movf    (r3)+,fr1
-       movf    (r3),fr0
-       jsr     pc,pow
-       bec     advanc
-       jsr     r5,error
-               <Bad exponentiation\n\0>; .even
-
-_neg:  / unary -
-       negf    r0
-       jbr     advanc
-/ end of _neg
-
-_intcon:
-       movif   (r4)+,r0
-       jbr     subadv
-
-_con0:
-       clrf    r0
-       jbr     subadv
-
-_con1:
-       movf    $one,r0
-       jbr     subadv
-
-_const:
-       movf    (r4)+,r0
-
-subadv:
-       movf    r0,-(r3)
-       jmp     *(r4)+
-
-advanc:
-       movf    r0,(r3)
-       jmp     *(r4)+
-
-_rval:
-       jsr     pc,getlv
-       br      subadv
-
-_fori:
-       jsr     pc,getlv
-       addf    $one,r0
-       movf    r0,(r0)
-       br      subadv
-
-_lval:
-       mov     (r4)+,-(r3)
-       jmp     *(r4)+
-
-_dup:
-       movf    (r3),r0
-       br      subadv
-
-_return:
-       dec     sublev
-       bge     1f
-       jsr     r5,error
-               <bad return\n\0>; .even
-1:
-       movf    (r3),r0
-       mov     sstack,r3
-       mov     (r3)+,sstack
-       mov     (r3)+,r4
-       mov     (r4)+,r0
-1:
-       dec     r0
-       blt     advanc
-       add     $8,r3
-       br      1b
-
-_subscr:
-       mov     (r4),r1
-       mpy     $8.,r1
-       add     r1,r3
-       mov     r3,-(sp)
-       mov     (r3),r0
-       mov     (r4)+,-(sp)
-1:
-       dec     (sp)
-       blt     1f
-       movf    -(r3),r0
-       movfi   r0,r2
-       com     r2
-       blt     2f
-       jsr     r5,error
-               <subscript out of range\n\0>; .even
-2:
-       mov     r0,r1
-       mov     4(r0),r0
-       bic     $1,r0
-2:
-       beq     2f
-       cmp     r2,(r0)+
-       bne     3f
-       tst     -(r0)
-       br      1b
-3:
-       mov     (r0),r0
-       br      2b
-2:
-       mov     $symtab,r0
-2:
-       tst     (r0)
-       beq     2f
-       add     $14.,r0
-       br      2b
-2:
-       cmp     r0,$esymtab-28.
-       blo     2f
-       jsr     r5,error
-               <out of symbol space\n\0>; .even
-2:
-       cmp     (r1)+,(r1)+
-       mov     r0,-(sp)
-       clr     14.(r0)
-       mov     r2,(r0)+
-       mov     (r1),r2
-       bic     $1,r2
-       mov     r2,(r0)+
-       clr     (r0)+
-       mov     (sp)+,r0
-       bic     $!1,(r1)
-       bis     r0,(r1)
-       br      1b
-1:
-       tst     (sp)+
-       mov     (sp)+,r3
-       mov     r0,(r3)
-       jmp     *(r4)+
-
-bool:
-       movf    (r3)+,r1        / r1 used in extended rel
-       cmpf    (r3),r1
-       cfcc
-       rts     pc
-
-getlv:
-       mov     (r3)+,r0
-       add     $4,r0
-       bit     $1,(r0)+
-       bne     1f
-       jsr     r5,error;<used before set\n\0>; .even
-1:
-       movf    (r0),r0
-       rts     pc
-
-/
-/
-
-/ bas4 -- builtin functions
-
-builtin:
-       dec     sublev
-       mov     (r3)+,sstack
-       mov     (r3)+,r4
-       movfi   r0,r0
-       com     r0
-       asl     r0
-       cmp     r0,$2f-1f
-       bhis    2f
-       jmp     *1f(r0)
-1:
-       fnarg
-       fnexp
-       fnlog
-       fnsin
-       fncos
-       fnatan
-       fnrand
-       fnexpr
-       fnint
-       fnabs
-       fnsqr
-       fnlast
-2:
-       mov     $-1,r0
-       jsr     pc,getloc               / label not found diagnostic
-
-fnarg:
-       cmp     (r4)+,$1
-       jne     narg
-       movf    (r3),r0
-       movfi   r0,r0
-       jsr     pc,arg
-       br      fnadvanc
-
-fnexp:
-       jsr     r5,fnfn; exp
-       br      fnadvanc
-
-fnlog:
-       jsr     r5,fnfn; log
-       bec     fnadvanc
-       jsr     r5,error
-               <Bad log\n\0>; .even
-
-fnsin:
-       jsr     r5,fnfn; sin
-       bec     fnadvanc
-       jsr     r5,error
-               <Bad sine\n\0>; .even
-
-fncos:
-       jsr     r5,fnfn; cos
-       bec     fnadvanc
-       jsr     r5,error
-               <Bad cosine\n\0>; .even
-
-fnatan:
-       jsr     r5,fnfn; atan
-       bec     fnadvanc
-       jsr     r5,error
-               <Bad arctangent\n\0>; .even
-
-fnrand:
-       tst     (r4)+
-       bne     narg
-       jsr     pc,rand
-       movif   r0,r0
-       divf    $44000,r0
-       jmp     advanc
-
-fnexpr:
-       tst     (r4)+
-       bne     narg
-       mov     r3,-(sp)
-       mov     r4,-(sp)
-       jsr     pc,rdline
-       mov     exprloc,r4
-       mov     $line,r3
-       jsr     pc,expr
-       mov     $_tra,(r4)+
-       mov     (sp)+,(r4)+
-       mov     (sp)+,r3
-       mov     exprloc,r4
-       add     $8,r3
-       jmp     *(r4)+
-
-fnint:
-       cmp     (r4)+,$1
-       bne     narg
-       movf    (r3),r0
-       modf    $one,r0
-       movf    r1,r0
-       br      fnadvanc
-
-fnabs:
-       cmp     (r4)+,$1
-       bne     narg
-       movf    (r3),r0
-       cfcc
-       bge     fnadvanc
-       negf    r0
-       br      fnadvanc
-
-fnlast:
-       tst     (r4)+
-       bne     narg
-       movf    lastpr,fr0
-       jbr     advanc
-
-fnsqr:
-       jsr     r5,fnfn; sqrt
-       bec     fnadvanc
-       jsr     r5,error
-       <Bad square root arg\n\0>; .even
-fnadvanc:
-       add     $8,r3
-       jmp     advanc
-
-narg:
-       jsr     r5,error
-               <arg count\n\0>; .even
-
-arg:
-       tst     sublev
-       beq     1f
-       mov     sstack,r1
-       sub     *2(r1),r0
-       bhi     1f
-2:
-       inc     r0
-       bgt     2f
-       add     $8,r1
-       br      2b
-2:
-       movf    4(r1),r0
-       rts     pc
-1:
-       jsr     r5,error
-               <bad arg\n\0>; .even
-
-fnfn:
-       cmp     (r4)+,$1
-       bne     narg
-       movf    (r3),r0
-       jsr     pc,*(r5)+
-       rts     r5
-
-.if scope / for plotting
-draw:
-       tstf    r2
-       cfcc
-       bne     1f
-       movf    r0,drx
-       movf    r1,dry
-       rts     r5
-1:
-       movf    r0,-(sp)
-       movf    r1,-(sp)
-       mov     $3,r0
-       jsr     pc,drput
-       jsr     pc,drxy
-       movf    (sp)+,r0
-       movf    r0,dry
-       movf    (sp)+,r0
-       movf    r0,drx
-       jsr     pc,drxy
-       rts     r5
-
-drxy:
-       movf    drx,r0
-       jsr     pc,drco
-       movf    dry,r0
-
-drco:
-       tstf    r0
-       cfcc
-       bge     1f
-       clrf    r0
-1:
-       cmpf    $40200,r0               / 1.0
-       cfcc
-       bgt     1f
-       movf    $40177,r0               / 1.0-eps
-1:
-       subf    $40000,r0               / .5
-       mulf    $43200,r0               / 4096
-       movfi   r0,r0
-       mov     r0,-(sp)
-       jsr     pc,drput
-       mov     (sp)+,r0
-       swab    r0
-
-drput:
-       movb    r0,ch
-       mov     drfo,r0
-       bne     1f
-       sys     open; vt; 1
-       bec     2f
-       4
-2:
-       mov     r0,drfo
-1:
-       sys     write; ch; 1
-       rts     pc
-
-.endif
-/ bas4 -- old library routines
-atoi:
-       clr     r1
-       jsr     r5,nextc
-       clr     -(sp)
-       cmp     r0,$'-
-       bne     2f
-       inc     (sp)
-1:
-       jsr     r5,nextc
-2:
-       sub     $'0,r0
-       cmp     r0,$9
-       bhi     1f
-       mpy     $10.,r1
-       bcs     3f / >32k
-       add     r0,r1
-       bcs     3f / >32k
-       br      1b
-1:
-       add     $'0,r0
-       tst     (sp)+
-       beq     1f
-       neg     r1
-1:
-       rts     r5
-3:
-       tst     (sp)+
-       mov     $'.,r0  / faking overflow
-       br      1b
-
-ldfps = 170100^tst
-stfps = 170200^tst
-atof:
-       stfps   -(sp)
-       ldfps   $200
-       movf    fr1,-(sp)
-       mov     r1,-(sp)
-       mov     r2,-(sp)
-       clr     -(sp)
-       clrf    fr0
-       clr     r2
-       jsr     r5,*(r5)
-       cmpb    r0,$'-
-       bne     2f
-       inc     (sp)
-1:
-       jsr     r5,*(r5)
-2:
-       sub     $'0,r0
-       cmp     r0,$9.
-       bhi     2f
-       jsr     pc,dig
-               br      1b
-       inc     r2
-       br      1b
-2:
-       cmpb    r0,$'.-'0
-       bne     2f
-1:
-       jsr     r5,*(r5)
-       sub     $'0,r0
-       cmp     r0,$9.
-       bhi     2f
-       jsr     pc,dig
-               dec r2
-       br      1b
-2:
-       cmpb    r0,$'e-'0
-       bne     1f
-       jsr     r5,atoi
-       sub     $'0,r0
-       add     r1,r2
-1:
-       movf    $one,fr1
-       mov     r2,-(sp)
-       beq     2f
-       bgt     1f
-       neg     r2
-1:
-       cmp     r2,$38.
-       blos    1f
-       clrf    fr0
-       tst     (sp)+
-       bmi     out
-       movf    $huge,fr0
-       br      out
-1:
-       mulf    $ten,fr1
-       sob     r2,1b
-2:
-       tst     (sp)+
-       bge     1f
-       divf    fr1,fr0
-       br      2f
-1:
-       mulf    fr1,fr0
-       cfcc
-       bvc     2f
-       movf    $huge,fr0
-2:
-out:
-       tst     (sp)+
-       beq     1f
-       negf    fr0
-1:
-       add     $'0,r0
-       mov     (sp)+,r2
-       mov     (sp)+,r1
-       movf    (sp)+,fr1
-       ldfps   (sp)+
-       tst     (r5)+
-       rts     r5
-
-dig:
-       cmpf    $big,fr0
-       cfcc
-       blt     1f
-       mulf    $ten,fr0
-       movif   r0,fr1
-       addf    fr1,fr0
-       rts     pc
-1:
-       add     $2,(sp)
-       rts     pc
-
-one    = 40200
-ten    = 41040
-big    = 56200
-huge   = 77777
-
-.globl _ndigits
-.globl ecvt
-.globl fcvt
-
-ftoa:
-       movf    fr0,lastpr
-       jsr     pc,ecvt
-       mov     r0,bufptr
-       tstb    r1
-       beq     1f
-       mov     $'-,r0
-       jsr     r5,*(r5)
-1:
-       cmp     r3,$-2
-       blt     econ
-       cmp     r2,$-5
-       ble     econ
-       cmp     r2,$6
-       bgt     econ
-       jsr     pc,cout
-       tst     (r5)+
-       rts     r5
-
-econ:
-       mov     r2,-(sp)
-       mov     $1,r2
-       jsr     pc,cout
-       mov     $'e,r0
-       jsr     r5,*(r5)
-       mov     (sp)+,r0
-       dec     r0
-       jmp     itoa
-
-cout:
-       mov     bufptr,r1
-       add     _ndigits,r1
-       mov     r2,-(sp)
-       add     bufptr,r2
-1:
-       cmp     r1,r2
-       blos    1f
-       cmpb    -(r1),$'0
-       beq     1b
-       inc     r1
-1:
-       mov     (sp)+,r2
-       bge     2f
-       mov     $'.,r0
-       jsr     r5,*(r5)
-1:
-       mov     $'0,r0
-       jsr     r5,*(r5)
-       inc     r2
-       blt     1b
-       dec     r2
-2:
-       mov     r2,-(sp)
-       mov     bufptr,r2
-1:
-       cmp     r2,r1
-       bhis    1f
-       tst     (sp)
-       bne     2f
-       mov     $'.,r0
-       jsr     r5,*(r5)
-2:
-       dec     (sp)
-       movb    (r2)+,r0
-       jsr     r5,*(r5)
-       br      1b
-1:
-       tst     (sp)+
-       rts     pc
-
-.bss
-bufptr:        .=.+2
-.text
-
-ftoo:
-       stfps   -(sp)
-       ldfps   $200
-       mov     r1,-(sp)
-       mov     r2,-(sp)
-       mov     $buf,r1
-       movf    fr0,(r1)+
-       mov     $buf,r2
-       br      2f
-1:
-       cmp     r2,r1
-       bhis    1f
-       mov     $';,r0
-       jsr     r5,*(r5)
-2:
-       mov     (r2)+,r0
-       jsr     pc,oct
-       br      1b
-1:
-       mov     $'\n,r0
-       jsr     pc,*(r5)+
-       ldfps   (sp)+
-       rts     r5
-
-oct:
-       mov     r0,x+2
-       setl
-       movif   x,fr0
-       mulf    $small,fr0
-       seti
-       mov     $6.,-(sp)
-1:
-       modf    $eight,fr0
-       movfi   fr1,r0
-       add     $'0,r0
-       jsr     r5,*(r5)
-       dec     (sp)
-       bne     1b
-       tst     (sp)+
-       rts     pc
-
-eight  = 41000
-small  = 33600
-.bss
-buf:   .=.+8
-x:     .=.+4
-.text
-
-itoa:
-       mov     r1,-(sp)
-       mov     r0,r1
-       bge     1f
-       neg     r1
-       mov     $'-,r0
-       jsr     r5,*(r5)
-1:
-       jsr     pc,1f
-       mov     (sp)+,r1
-       tst     (r5)+
-       rts     r5
-
-1:
-       clr     r0
-       dvd     $10.,r0
-       mov     r1,-(sp)
-       mov     r0,r1
-       beq     1f
-       jsr     pc,1b
-1:
-       mov     (sp)+,r0
-       add     $'0,r0
-       jsr     r5,*(r5)
-       rts     pc
-/ bas -- BASIC
-/ new command "dump" which dumps symbol table values by name
-/              R. Haight
-/
-_dump:
-       mov     r4,-(sp)
-       mov     $12.*14.+symtab-14.,r4
-1:
-       add     $14.,r4
-       tst     (r4)
-       beq     1f
-       bit     $1,4(r4)
-       beq     1b
-       jsr     pc,dmp1
-       mov     $'=,r0
-       jsr     r5,xputc
-       movf    6(r4),r0
-       jsr     r5,ftoa; xputc
-       mov     $'\n,r0
-       jsr     r5,xputc
-       br      1b
-1:
-       mov     (sp)+,r4
-       jmp     *(r4)+
-
-dmp1:
-       tst     (r4)
-       blt     1f
-       mov     (r4),nameb
-       mov     2(r4),nameb+2
-       mov     $nameb,r0
-       jsr     pc,print
-       rts     pc
-1:
-       mov     r4,-(sp)
-       mov     $symtab-14.,r4
-1:
-       add     $14.,r4
-       tst     (r4)
-       beq     1f
-       mov     4(r4),r0
-       bic     $1,r0
-2:
-       beq     1b
-       cmp     r0,(sp)
-       beq     2f
-       mov     2(r0),r0
-       br      2b
-2:
-       jsr     pc,dmp1
-       mov     $'[,r0
-       jsr     r5,xputc
-       mov     *(sp),r0
-       com     r0
-       movif   r0,r0
-       jsr     r5,ftoa; xputc
-       mov     $'],r0
-       jsr     r5,xputc
-1:
-       mov     (sp)+,r4
-       rts     pc
-/
-/
-
-/ basx -- data
-
-one = 40200
-
-.data
-
-_ndigits:10.
-tmpf:  </tmp/btma\0>
-argname: <b.out\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0>
-vt:    </dev/vt0\0>
-.even
-pname: <\0\0\0\0\0\0>
-       .even
-
-resnam:
-       <list>
-       <done>
-       <q\0\0\0>
-       <run\0>
-       <prin>
-       <prom>   / prompt is like print without \n (cr)
-       <if\0\0>
-       <goto>
-       <retu>
-       <for\0>
-       <next>
-       <octa>
-       <save>
-       <dump>
-       <fi\0\0>
-       <else>
-       <edit>
-       <comm>  / comment
-.if scope / for plotting
-       <disp>
-       <draw>
-       <eras>
-.endif
-eresnam:
-
-symtnam:
-       <arg\0>
-       <exp\0>
-       <log\0>
-       <sin\0>
-       <cos\0>
-       <atn\0>
-       <rnd\0>
-       <expr>
-       <int\0>
-       <abs\0>
-       <sqr\0>
-       <last>
-esymtnam:
-
-/ indirect sys calls:
-sysseek:       sys     lseek; 0; seekx: 0; 0
-syswrit:       sys     write; wbuf: 0; wlen: 0
-sysread:       sys     read; rbuf: 0; rlen: 0
-sysopen:       sys     open; ofile: 0 ; omode: 0
-syscreat:      sys     creat; cfile: 0; cmode: 0
-.bss
-drx:   .=.+8
-dry:   .=.+8
-drfo:  .=.+2
-ch:    .=.+2
-drflg: .=.+2
-randx: .=.+2
-gsp:   .=.+2
-forp:  .=.+2
-exprloc:.=.+2
-sstack:        .=.+2
-sublev:        .=.+2
-val:   .=.+2
-splimit:       .=.+2  / statement size limit
-iflev: .=.+20.  / nested if compile stack: 10 deep
-ifp:   .=.+2    / current pointer to iflev
-line:  .=.+100.
-prfile:        .=.+2   / output from _list or _save
-tfi:   .=.+2  / input file
-lastpr:        .=.+8   / last printed number
-func:  .=.+2   / alternate functions, eg: _list or _save
-seeka: .=.+2   / seek offset 1
-lineno:        .=.+2
-nameb: .=.+4
-tfo:   .=.+2
-symtab:        .=.+2800.; esymtab: / symbol=7wds; symtab for 200
-space: .=.+8000.; espace: / code space
-exline:        .=.+1000.; eexline: / line execute space
-lintab:        .=.+1800.; elintab: / 3wds per statement = 300 stmts
-stack: .=.+800.; estack:
-
-iobuf: fi: .=.+518.  / should be acquired??
diff --git a/usr/src/cmd/bas/makefile b/usr/src/cmd/bas/makefile
deleted file mode 100644 (file)
index 4fc8b3e..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-bas cp cmp:
-       @echo Sorry, the bas source will not compile
-       @echo the object because it calls for old-style
-       @echo library routines.
-       @echo It\'s here just in case you want to play.
index e4dc51a..1e50fc5 100644 (file)
@@ -290,7 +290,7 @@ constant:
 
 CRS    :
                ={ $$ = cp; *cp++ = crs++; *cp++ = '\0';
 
 CRS    :
                ={ $$ = cp; *cp++ = crs++; *cp++ = '\0';
-                       if(crs == '[')crs=+3;
+                       if(crs == '[')crs+=3;
                        if(crs == 'a')crs='{';
                        if(crs >= 0241){yyerror("program too big");
                                getout();
                        if(crs == 'a')crs='{';
                        if(crs >= 0241){yyerror("program too big");
                                getout();
@@ -463,7 +463,7 @@ loop:
 int b_space [ b_sp_max ];
 int * b_sp_nxt = { b_space };
 
 int b_space [ b_sp_max ];
 int * b_sp_nxt = { b_space };
 
-int    bdebug = 0;
+int bdebug = 0;
 bundle(a){
        int i, *p, *q;
 
 bundle(a){
        int i, *p, *q;
 
diff --git a/usr/src/cmd/bcd.c b/usr/src/cmd/bcd.c
new file mode 100644 (file)
index 0000000..55f8f43
--- /dev/null
@@ -0,0 +1,133 @@
+int chtab[] = {
+00000, /*   */
+03004, /* ! */
+02404, /* " */
+02040, /* sharp */
+02042, /* $ */
+02104, /* % */
+00001, /* & */
+03002, /* ' */
+02201, /* ( */
+02202, /* ) */
+02102, /* * */
+00005, /* + */
+02044, /* , */
+00002, /* - */
+02041, /* . */
+00014, /* / */
+00004, /* 0 */
+00010, /* 1 */
+00020, /* 2 */
+00040, /* 3 */
+00100, /* 4 */
+00200, /* 5 */
+00400, /* 6 */
+01000, /* 7 */
+02000, /* 8 */
+04000, /* 9 */
+02200, /* : */
+02402, /* ; */
+02401, /* < */
+02204, /* = */
+02400, /* > */
+03000, /* ? */
+02100, /* at */
+ 011,
+ 021,
+ 041,
+0101,
+0201,
+0401,
+01001,
+02001,
+04001,
+012,
+022,
+042,
+0102,
+0202,
+0402,
+01002,
+02002,
+02002,
+024,
+044,
+0104,
+0204,
+0404,
+01004,
+02004,
+04004,
+02020, /* [ */
+03001, /* \ */
+02101, /* ] */
+00006, /* ^ */
+02024 /* _ */
+};
+       char s[128];
+       char *sp = {&s[0]};
+main(argc, argv)
+char *argv[];
+{
+       char *spp;
+       int i;
+       int j;
+       int c;
+       int l;
+
+       if (argc<2) {
+               puts("% ");
+               while ((c=getchar())!='\0'&c!='\n')
+                       *sp++ = c;
+               *sp = 0;
+               sp = &s[0];
+       } else
+               sp = *++argv;
+       puts("\n\n\n\n");
+       puts(" ________________________________");
+       puts("________________\n");
+       spp = sp;
+       while(*spp++);
+       spp--;
+       l = spp - sp;
+       putchar('/');
+       puts(sp);
+       i = 49 - l;
+       while(--i>0) putchar(' ');
+       puts("|\n");
+       j = 0;
+       spp = sp;
+       while (j++<12) {
+               putchar('|');
+               i = 0;
+               spp = sp;
+               while (i<48) {
+                       if(i>l) c = 0;
+                       else c = *spp++ - 040;
+                       i++;
+                       if (c>='a'-040) c = c - 040;
+                       if (c<0 | c>137) c = 0;
+                       if ((chtab[c]>>(j-1))&1) 
+                               puts("[\b\ 1\ 1\ 1\ 1\ 1]");
+                       else
+                               putchar(j>3?'0'+j-3:' ');
+               }
+               puts("|\n");
+       }
+       putchar('|');
+       puts("____________");
+       puts("____________________________________");
+       puts("|\n");
+       puts("\n\n\n\n");
+}
+
+puts(ss) char *ss; {
+       int i;
+       char t;
+       i = 0;
+       while(t = *ss++) {
+               if(t >= 'a' && t <= 'z')
+                       t += 'A'-'a';
+               putchar(t);
+       }
+}
diff --git a/usr/src/cmd/c/c0.h b/usr/src/cmd/c/c0.h
deleted file mode 100644 (file)
index 4aced95..0000000
+++ /dev/null
@@ -1,458 +0,0 @@
-#
-/*
-*      C compiler-- first pass header
-*/
-
-#include <stdio.h>
-
-/*
- * parameters
- */
-
-#define        LTYPE   long    /* change to int if no long consts */
-#define        MAXINT  077777  /* Largest positive short integer */
-#define        MAXUINT 0177777 /* largest unsigned integer */
-#define        NCPS    8       /* # chars per symbol */
-#define        HSHSIZ  400     /* # entries in hash table for names */
-#define        CMSIZ   40      /* size of expression stack */
-#define        SSIZE   20      /* size of other expression stack */
-#define        SWSIZ   230     /* size of switch table */
-#define        NMEMS   128     /* Number of members in a structure */
-#define        NBPW    16      /* bits per word, object machine */
-#define        NBPC    8       /* bits per character, object machine */
-#define        NCPW    2       /* chars per word, object machine */
-#define        LNCPW   2       /* chars per word, compiler's machine */
-#define        STAUTO  (-6)    /* offset of first auto variable */
-#define        STARG   4       /* offset of first argument */
-
-
-/*
- * # bytes in primitive types
- */
-#define        SZCHAR  1
-#define        SZINT   2
-#define        SZPTR   2
-#define        SZFLOAT 4
-#define        SZLONG  4
-#define        SZDOUB  8
-
-/*
- * format of a structure description
- */
-struct str {
-       int     ssize;                  /* structure size */
-       struct hshtab   **memlist;      /* member list */
-};
-
-/*
- * For fields, strp points here instead.
- */
-struct field {
-       int     flen;           /* field width in bits */
-       int     bitoffs;        /* shift count */
-};
-
-/*
- * Structure of tree nodes for operators
- */
-struct tnode {
-       int     op;             /* operator */
-       int     type;           /* data type */
-       int     *subsp;         /* subscript list (for arrays) */
-       struct  str *strp;      /* structure description for structs */
-       struct  tnode *tr1;     /* left operand */
-       struct  tnode *tr2;     /* right operand */
-};
-
-/*
- * Tree node for constants
- */
-struct cnode {
-       int     op;
-       int     type;
-       int     *subsp;
-       struct  str *strp;
-       int     value;
-};
-
-/*
- * Tree node for long constants
- */
-struct lnode {
-       int     op;
-       int     type;
-       int     *subsp;
-       struct  str *strp;
-       LTYPE   lvalue;
-};
-
-/*
- * tree node for floating
- * constants
- */
-struct fnode {
-       int     op;
-       int     type;
-       int     *subsp;
-       struct  str *strp;
-       char    *cstr;
-};
-
-/*
- * Structure of namelist
- */
-/*
- * Pushed-down entry for block structure
- */
-struct phshtab {
-       char    hclass;
-       char    hflag;
-       int     htype;
-       int     *hsubsp;
-       struct  str *hstrp;
-       int     hoffset;
-       struct  phshtab *hpdown;
-       char    hblklev;
-};
-
-/*
- * Top-level namelist
- */
-struct hshtab {
-       char    hclass;         /* storage class */
-       char    hflag;          /* various flags */
-       int     htype;          /* type */
-       int     *hsubsp;        /* subscript list */
-       struct  str *hstrp;     /* structure description */
-       int     hoffset;        /* post-allocation location */
-       struct  phshtab *hpdown;        /* Pushed-down name in outer block */
-       char    hblklev;        /* Block level of definition */
-       char    name[NCPS];     /* ASCII name */
-};
-
-/*
- * Place used to keep dimensions
- * during declarations
- */
-struct tdim {
-       int     rank;
-       int     dimens[5];
-};
-
-/*
- * Table for recording switches.
- */
-struct swtab {
-       int     swlab;
-       int     swval;
-};
-
-char   cvtab[4][4];
-char   filename[64];
-int    opdope[];
-char   ctab[];
-char   symbuf[NCPS+2];
-int    hshused;
-struct hshtab  hshtab[HSHSIZ];
-struct tnode **cp;
-int    isn;
-struct swtab   swtab[SWSIZ];
-struct swtab   *swp;
-int    contlab;
-int    brklab;
-int    retlab;
-int    deflab;
-unsigned autolen;              /* make these int if necessary */
-unsigned maxauto;              /* ... will only cause trouble rarely */
-int    peeksym;
-int    peekc;
-int    eof;
-int    line;
-char   *funcbase;
-char   *curbase;
-char   *coremax;
-char   *maxdecl;
-struct hshtab  *defsym;
-struct hshtab  *funcsym;
-int    proflg;
-struct hshtab  *csym;
-int    cval;
-LTYPE  lcval;
-int    nchstr;
-int    nerror;
-struct hshtab  **paraml;
-struct hshtab  **parame;
-int    strflg;
-int    mosflg;
-int    initflg;
-int    inhdr;
-char   sbuf[BUFSIZ];
-FILE   *sbufp;
-int    regvar;
-int    bitoffs;
-struct tnode   funcblk;
-char   cvntab[];
-char   numbuf[64];
-struct hshtab **memlist;
-int    nmems;
-struct hshtab  structhole;
-int    blklev;
-int    mossym;
-
-/*
-  operators
-*/
-#define        EOFC    0
-#define        NULLOP  218
-#define        SEMI    1
-#define        LBRACE  2
-#define        RBRACE  3
-#define        LBRACK  4
-#define        RBRACK  5
-#define        LPARN   6
-#define        RPARN   7
-#define        COLON   8
-#define        COMMA   9
-#define        FSEL    10
-#define        CAST    11
-#define        ETYPE   12
-
-#define        KEYW    19
-#define        NAME    20
-#define        CON     21
-#define        STRING  22
-#define        FCON    23
-#define        SFCON   24
-#define        LCON    25
-#define        SLCON   26
-
-#define        SIZEOF  91
-#define        INCBEF  30
-#define        DECBEF  31
-#define        INCAFT  32
-#define        DECAFT  33
-#define        EXCLA   34
-#define        AMPER   35
-#define        STAR    36
-#define        NEG     37
-#define        COMPL   38
-
-#define        DOT     39
-#define        PLUS    40
-#define        MINUS   41
-#define        TIMES   42
-#define        DIVIDE  43
-#define        MOD     44
-#define        RSHIFT  45
-#define        LSHIFT  46
-#define        AND     47
-#define        OR      48
-#define        EXOR    49
-#define        ARROW   50
-#define        ITOF    51
-#define        FTOI    52
-#define        LOGAND  53
-#define        LOGOR   54
-#define        FTOL    56
-#define        LTOF    57
-#define        ITOL    58
-#define        LTOI    59
-#define        ITOP    13
-#define        PTOI    14
-#define        LTOP    15
-
-#define        EQUAL   60
-#define        NEQUAL  61
-#define        LESSEQ  62
-#define        LESS    63
-#define        GREATEQ 64
-#define        GREAT   65
-#define        LESSEQP 66
-#define        LESSP   67
-#define        GREATQP 68
-#define        GREATP  69
-
-#define        ASPLUS  70
-#define        ASMINUS 71
-#define        ASTIMES 72
-#define        ASDIV   73
-#define        ASMOD   74
-#define        ASRSH   75
-#define        ASLSH   76
-#define        ASSAND  77
-#define        ASOR    78
-#define        ASXOR   79
-#define        ASSIGN  80
-
-#define        QUEST   90
-#define        MAX     93
-#define        MAXP    94
-#define        MIN     95
-#define        MINP    96
-#define        SEQNC   97
-#define        CALL    100
-#define        MCALL   101
-#define        JUMP    102
-#define        CBRANCH 103
-#define        INIT    104
-#define        SETREG  105
-#define        RFORCE  110
-#define        BRANCH  111
-#define        LABEL   112
-#define        NLABEL  113
-#define        RLABEL  114
-#define        STRASG  115
-#define        ITOC    109
-#define        SEOF    200     /* stack EOF marker in expr compilation */
-
-/*
-  types
-*/
-#define        INT     0
-#define        CHAR    1
-#define        FLOAT   2
-#define        DOUBLE  3
-#define        STRUCT  4
-#define        LONG    6
-#define        UNSIGN  7
-#define        UNION   8               /* adjusted later to struct */
-
-#define        ALIGN   01
-#define        TYPE    07
-#define        BIGTYPE 060000
-#define        TYLEN   2
-#define        XTYPE   (03<<3)
-#define        PTR     010
-#define        FUNC    020
-#define        ARRAY   030
-
-/*
-  storage classes
-*/
-#define        KEYWC   1
-#define        DEFXTRN 20
-#define        TYPEDEF 9
-#define        MOS     10
-#define        AUTO    11
-#define        EXTERN  12
-#define        STATIC  13
-#define        REG     14
-#define        STRTAG  15
-#define ARG    16
-#define        ARG1    17
-#define        AREG    18
-#define        MOU     21
-#define        ENUMTAG 22
-#define        ENUMCON 24
-
-/*
-  keywords
-*/
-#define        GOTO    20
-#define        RETURN  21
-#define        IF      22
-#define        WHILE   23
-#define        ELSE    24
-#define        SWITCH  25
-#define        CASE    26
-#define        BREAK   27
-#define        CONTIN  28
-#define        DO      29
-#define        DEFAULT 30
-#define        FOR     31
-#define        ENUM    32
-
-/*
-  characters
-*/
-#define        BSLASH  117
-#define        SHARP   118
-#define        INSERT  119
-#define        PERIOD  120
-#define        SQUOTE  121
-#define        DQUOTE  122
-#define        LETTER  123
-#define        DIGIT   124
-#define        NEWLN   125
-#define        SPACE   126
-#define        UNKN    127
-
-/*
- * Special operators in intermediate code
- */
-#define        BDATA   200
-#define        WDATA   201
-#define        PROG    202
-#define        DATA    203
-#define        BSS     204
-#define        CSPACE  205
-#define        SSPACE  206
-#define        SYMDEF  207
-#define        SAVE    208
-#define        RETRN   209
-#define        EVEN    210
-#define        PROFIL  212
-#define        SWIT    213
-#define        EXPR    214
-#define        SNAME   215
-#define        RNAME   216
-#define        ANAME   217
-#define        SETSTK  219
-#define        SINIT   220
-
-/*
-  Flag bits
-*/
-
-#define        BINARY  01
-#define        LVALUE  02
-#define        RELAT   04
-#define        ASSGOP  010
-#define        LWORD   020
-#define        RWORD   040
-#define        COMMUTE 0100
-#define        RASSOC  0200
-#define        LEAF    0400
-
-/*
- * Conversion codes
- */
-#define        ITF     1
-#define        ITL     2
-#define        LTF     3
-#define        ITP     4
-#define        PTI     5
-#define        FTI     6
-#define        LTI     7
-#define        FTL     8
-#define        LTP     9
-#define        ITC     10
-#define        XX      15
-
-/*
- * symbol table flags
- */
-
-#define        FMOS    01
-#define        FKEYW   04
-#define        FFIELD  020
-#define        FINIT   040
-#define        FLABL   0100
-
-/*
- * functions
- */
-char   *sbrk();
-struct tnode *tree();
-char   *copnum();
-struct tnode *convert();
-struct tnode *chkfun();
-struct tnode *disarray();
-struct tnode *block();
-struct cnode *cblock();
-struct fnode *fblock();
-char   *gblock();
-struct tnode *pexpr();
-struct str *strdec();
-struct hshtab *xprtype();
-struct tnode *nblock();
diff --git a/usr/src/cmd/c/c00.c b/usr/src/cmd/c/c00.c
deleted file mode 100644 (file)
index a5747e1..0000000
+++ /dev/null
@@ -1,884 +0,0 @@
-#
-/* C compiler
- *
- *
- *
- * Called from cc:
- *   c0 source temp1 temp2 [ profileflag ]
- * temp1 gets most of the intermediate code;
- * strings are put on temp2, which c1 reads after temp1.
- */
-
-#include "c0.h"
-
-int    isn     1;
-int    peeksym -1;
-int    line    1;
-struct tnode   funcblk { NAME, 0, NULL, NULL, NULL, NULL };
-
-struct kwtab {
-       char    *kwname;
-       int     kwval;
-} kwtab[]
-{
-       "int",          INT,
-       "char",         CHAR,
-       "float",        FLOAT,
-       "double",       DOUBLE,
-       "struct",       STRUCT,
-       "long",         LONG,
-       "unsigned",     UNSIGN,
-       "union",        UNION,
-       "short",        INT,
-       "auto",         AUTO,
-       "extern",       EXTERN,
-       "static",       STATIC,
-       "register",     REG,
-       "goto",         GOTO,
-       "return",       RETURN,
-       "if",           IF,
-       "while",        WHILE,
-       "else",         ELSE,
-       "switch",       SWITCH,
-       "case",         CASE,
-       "break",        BREAK,
-       "continue",     CONTIN,
-       "do",           DO,
-       "default",      DEFAULT,
-       "for",          FOR,
-       "sizeof",       SIZEOF,
-       "typedef",      TYPEDEF,
-       "enum",         ENUM,
-       0,              0,
-};
-
-main(argc, argv)
-char *argv[];
-{
-       register char *sp;
-       register i;
-       register struct kwtab *ip;
-
-       if(argc<4) {
-               error("Arg count");
-               exit(1);
-       }
-       if (freopen(argv[1], "r", stdin)==NULL) {
-               error("Can't find %s", argv[1]);
-               exit(1);
-       }
-       if (freopen(argv[2], "w", stdout)==NULL || (sbufp=fopen(argv[3],"w"))==NULL) {
-               error("Can't create temp");
-               exit(1);
-       }
-       setbuf(sbufp, sbuf);
-       if (argc>4)
-               proflg++;
-       /*
-        * The hash table locations of the keywords
-        * are marked; if an identifier hashes to one of
-        * these locations, it is looked up in in the keyword
-        * table first.
-        */
-       for (ip=kwtab; (sp = ip->kwname); ip++) {
-               i = 0;
-               while (*sp)
-                       i =+ *sp++;
-               hshtab[i%HSHSIZ].hflag = FKEYW;
-       }
-       coremax = funcbase = curbase = sbrk(0);
-       while(!eof)
-               extdef();
-       outcode("B", EOFC);
-       strflg++;
-       outcode("B", EOFC);
-       exit(nerror!=0);
-}
-
-/*
- * Look up the identifier in symbuf in the symbol table.
- * If it hashes to the same spot as a keyword, try the keyword table
- * first.  An initial "." is ignored in the hash.
- * Return is a ptr to the symbol table entry.
- */
-lookup()
-{
-       int ihash;
-       register struct hshtab *rp;
-       register char *sp, *np;
-
-       ihash = 0;
-       sp = symbuf;
-       while (sp<symbuf+NCPS)
-               ihash =+ *sp++&0177;
-       rp = &hshtab[ihash%HSHSIZ];
-       if (rp->hflag&FKEYW)
-               if (findkw())
-                       return(KEYW);
-       while (*(np = rp->name)) {
-               for (sp=symbuf; sp<symbuf+NCPS;)
-                       if (*np++ != *sp++)
-                               goto no;
-               if (mossym != (rp->hflag&FMOS))
-                       goto no;
-               csym = rp;
-               return(NAME);
-       no:
-               if (++rp >= &hshtab[HSHSIZ])
-                       rp = hshtab;
-       }
-       if(++hshused >= HSHSIZ) {
-               error("Symbol table overflow");
-               exit(1);
-       }
-       rp->hclass = 0;
-       rp->htype = 0;
-       rp->hoffset = 0;
-       rp->subsp = NULL;
-       rp->strp = NULL;
-       rp->hpdown = NULL;
-       rp->hblklev = blklev;
-       rp->hflag =| mossym;
-       sp = symbuf;
-       for (np=rp->name; sp<symbuf+NCPS;)
-               *np++ = *sp++;
-       csym = rp;
-       return(NAME);
-}
-
-/*
- * Search the keyword table.
- * Ignore initial "." to avoid member-of-structure
- * problems.
- */
-findkw()
-{
-       register struct kwtab *kp;
-       register char *p1, *p2;
-       char *wp;
-       int firstc;
-
-       wp = symbuf;
-       firstc = *wp;
-       for (kp=kwtab; (p2 = kp->kwname); kp++) {
-               p1 = wp;
-               while (*p1 == *p2++)
-                       if (*p1++ == '\0') {
-                               cval = kp->kwval;
-                               return(1);
-                       }
-       }
-       *wp = firstc;
-       return(0);
-}
-
-
-/*
- * Return the next symbol from the input.
- * peeksym is a pushed-back symbol, peekc is a pushed-back
- * character (after peeksym).
- * mosflg means that the next symbol, if an identifier,
- * is a member of structure or a structure tag, and it
- * gets a "." prepended to it to distinguish
- * it from other identifiers.
- */
-symbol() {
-       register c;
-       register char *sp;
-       register tline;
-
-       if (peeksym>=0) {
-               c = peeksym;
-               peeksym = -1;
-               if (c==NAME)
-                       mosflg = 0;
-               return(c);
-       }
-       if (peekc) {
-               c = peekc;
-               peekc = 0;
-       } else
-               if (eof)
-                       return(EOFC);
-               else
-                       c = getchar();
-loop:
-       if (c==EOF) {
-               eof++;
-               return(EOFC);
-       }
-       switch(ctab[c]) {
-
-       case SHARP:
-               if ((c=symbol())!=CON) {
-                       error("Illegal #");
-                       return(c);
-               }
-               tline = cval;
-               while (ctab[peekc]==SPACE)
-                       peekc = getchar();
-               if (peekc=='"') {
-                       sp = filename;
-                       while ((c = mapch('"')) >= 0)
-                               *sp++ = c;
-                       *sp++ = 0;
-                       peekc = getchar();
-               }
-               if (peekc != '\n') {
-                       error("Illegal #");
-                       while (getchar()!='\n' && eof==0)
-                               ;
-               }
-               peekc = 0;
-               line = tline;
-               return(symbol());
-
-       case INSERT:            /* ignore newlines */
-               inhdr = 1;
-               c = getchar();
-               goto loop;
-
-       case NEWLN:
-               if (!inhdr)
-                       line++;
-               inhdr = 0;
-
-       case SPACE:
-               c = getchar();
-               goto loop;
-
-       case PLUS:
-               return(subseq(c,PLUS,INCBEF));
-
-       case MINUS:
-               return(subseq(c,subseq('>',MINUS,ARROW),DECBEF));
-
-       case ASSIGN:
-               c = spnextchar();
-               peekc = 0;
-               if (c=='=')
-                       return(EQUAL);
-               if (c==' ')
-                       return(ASSIGN);
-               if (c=='<' || c=='>') {
-                       if (spnextchar() != c) {
-                               peeksym = ctab[c];
-                               return(ASSIGN);
-                       }
-                       peekc = 0;
-                       return(c=='<'? ASLSH: ASRSH);
-               }
-               if (ctab[c]>=PLUS && ctab[c]<=EXOR) {
-                       if (spnextchar() != ' '
-                        && (c=='-' || c=='&' || c=='*')) {
-                               error("Warning: %c= operator assumed", c);
-                               nerror--;
-                       }
-                       c = ctab[c];
-                       return(c+ASPLUS-PLUS);
-               }
-               peekc = c;
-               return(ASSIGN);
-
-       case LESS:
-               if (subseq(c,0,1)) return(LSHIFT);
-               return(subseq('=',LESS,LESSEQ));
-
-       case GREAT:
-               if (subseq(c,0,1)) return(RSHIFT);
-               return(subseq('=',GREAT,GREATEQ));
-
-       case EXCLA:
-               return(subseq('=',EXCLA,NEQUAL));
-
-       case BSLASH:
-               if (subseq('/', 0, 1))
-                       return(MAX);
-               goto unkn;
-
-       case DIVIDE:
-               if (subseq('\\', 0, 1))
-                       return(MIN);
-               if (subseq('*',1,0))
-                       return(DIVIDE);
-               while ((c = spnextchar()) != EOFC) {
-                       peekc = 0;
-                       if (c=='*') {
-                               if (spnextchar() == '/') {
-                                       peekc = 0;
-                                       c = getchar();
-                                       goto loop;
-                               }
-                       }
-               }
-               eof++;
-               error("Nonterminated comment");
-               return(0);
-
-       case PERIOD:
-       case DIGIT:
-               peekc = c;
-               return(getnum());
-
-       case DQUOTE:
-               cval = isn++;
-               return(STRING);
-
-       case SQUOTE:
-               return(getcc());
-
-       case LETTER:
-               sp = symbuf;
-               while(ctab[c]==LETTER || ctab[c]==DIGIT) {
-                       if (sp<symbuf+NCPS)
-                               *sp++ = c;
-                       c = getchar();
-               }
-               while(sp<symbuf+NCPS)
-                       *sp++ = '\0';
-               mossym = 0;
-               if (mosflg) {
-                       mossym = FMOS;
-                       mosflg = 0;
-               }
-               peekc = c;
-               if ((c=lookup())==KEYW && cval==SIZEOF)
-                       c = SIZEOF;
-               return(c);
-
-       case AND:
-               return(subseq('&', AND, LOGAND));
-
-       case OR:
-               return(subseq('|', OR, LOGOR));
-
-       case UNKN:
-       unkn:
-               error("Unknown character");
-               c = getchar();
-               goto loop;
-
-       }
-       return(ctab[c]);
-}
-
-/*
- * Read a number.  Return kind.
- */
-getnum()
-{
-       register char *np;
-       register c, base;
-       int expseen, sym, ndigit;
-       char *nsyn;
-       int maxdigit;
-
-       nsyn = "Number syntax";
-       lcval = 0;
-       base = 10;
-       maxdigit = 0;
-       np = numbuf;
-       ndigit = 0;
-       sym = CON;
-       expseen = 0;
-       if ((c=spnextchar()) == '0')
-               base = 8;
-       for (;; c = getchar()) {
-               *np++ = c;
-               if (ctab[c]==DIGIT || (base==16) && ('a'<=c&&c<='f'||'A'<=c&&c<='F')) {
-                       if (base==8)
-                               lcval =<< 3;
-                       else if (base==10)
-                               lcval = ((lcval<<2) + lcval)<<1;
-                       else
-                               lcval =<< 4;
-                       if (ctab[c]==DIGIT)
-                               c =- '0';
-                       else if (c>='a')
-                               c =- 'a'-10;
-                       else
-                               c =- 'A'-10;
-                       lcval =+ c;
-                       ndigit++;
-                       if (c>maxdigit)
-                               maxdigit = c;
-                       continue;
-               }
-               if (c=='.') {
-                       if (base==16 || sym==FCON)
-                               error(nsyn);
-                       sym = FCON;
-                       base = 10;
-                       continue;
-               }
-               if (ndigit==0) {
-                       sym = DOT;
-                       break;
-               }
-               if ((c=='e'||c=='E') && expseen==0) {
-                       expseen++;
-                       sym = FCON;
-                       if (base==16 || maxdigit>=10)
-                               error(nsyn);
-                       base = 10;
-                       *np++ = c = getchar();
-                       if (c!='+' && c!='-' && ctab[c]!=DIGIT)
-                               break;
-               } else if (c=='x' || c=='X') {
-                       if (base!=8 || lcval!=0 || sym!=CON)
-                               error(nsyn);
-                       base = 16;
-               } else if ((c=='l' || c=='L') && sym==CON) {
-                       c = getchar();
-                       sym = LCON;
-                       break;
-               } else
-                       break;
-       }
-       peekc = c;
-       if (maxdigit >= base)
-               error(nsyn);
-       if (sym==FCON) {
-               np[-1] = 0;
-               cval = np-numbuf;
-               return(FCON);
-       }
-       if (sym==CON && (lcval<0 || lcval>MAXINT&&base==10 || (lcval>>1)>MAXINT)) {
-               sym = LCON;
-       }
-       cval = lcval;
-       return(sym);
-}
-
-/*
- * If the next input character is c, return b and advance.
- * Otherwise push back the character and return a.
- */
-subseq(c,a,b)
-{
-       if (spnextchar() != c)
-               return(a);
-       peekc = 0;
-       return(b);
-}
-
-/*
- * Write out a string, either in-line
- * or in the string temp file labelled by
- * lab.
- */
-putstr(lab, amax)
-{
-       register int c, max;
-
-       nchstr = 0;
-       max = amax;
-       if (lab) {
-               strflg++;
-               outcode("BNB", LABEL, lab, BDATA);
-               max = 10000;
-       } else
-               outcode("B", BDATA);
-       while ((c = mapch('"')) >= 0) {
-               if (nchstr < max) {
-                       nchstr++;
-                       if (nchstr%15 == 0)
-                               outcode("0B", BDATA);
-                       outcode("1N", c & 0377);
-               }
-       }
-       if (nchstr < max) {
-               nchstr++;
-               outcode("10");
-       }
-       outcode("0");
-       strflg = 0;
-}
-
-/*
- * read a single-quoted character constant.
- * The routine is sensitive to the layout of
- * characters in a word.
- */
-getcc()
-{
-       register int c, cc;
-       register char *ccp;
-       char realc;
-
-       cval = 0;
-       ccp = &cval;
-       cc = 0;
-       while((c=mapch('\'')) >= 0)
-               if(cc++ < LNCPW)
-                       *ccp++ = c;
-       if (cc>LNCPW)
-               error("Long character constant");
-       if (cc==1) {
-               realc = cval;
-               cval = realc;
-       }
-       return(CON);
-}
-
-/*
- * Read a character in a string or character constant,
- * detecting the end of the string.
- * It implements the escape sequences.
- */
-mapch(ac)
-{
-       register int a, c, n;
-       static mpeek;
-
-       c = ac;
-       if (a = mpeek)
-               mpeek = 0;
-       else
-               a = getchar();
-loop:
-       if (a==c)
-               return(-1);
-       switch(a) {
-
-       case '\n':
-       case '\0':
-               error("Nonterminated string");
-               peekc = a;
-               return(-1);
-
-       case '\\':
-               switch (a=getchar()) {
-
-               case 't':
-                       return('\t');
-
-               case 'n':
-                       return('\n');
-
-               case 'b':
-                       return('\b');
-
-               case 'f':
-                       return('\014');
-
-               case 'v':
-                       return('\013');
-
-               case '0': case '1': case '2': case '3':
-               case '4': case '5': case '6': case '7':
-                       n = 0;
-                       c = 0;
-                       while (++c<=3 && '0'<=a && a<='7') {
-                               n =<< 3;
-                               n =+ a-'0';
-                               a = getchar();
-                       }
-                       mpeek = a;
-                       return(n);
-
-               case 'r':
-                       return('\r');
-
-               case '\n':
-                       if (!inhdr)
-                               line++;
-                       inhdr = 0;
-                       a = getchar();
-                       goto loop;
-               }
-       }
-       return(a);
-}
-
-/*
- * Read an expression and return a pointer to its tree.
- * It's the classical bottom-up, priority-driven scheme.
- * The initflg prevents the parse from going past
- * "," or ":" because those delimiters are special
- * in initializer (and some other) expressions.
- */
-struct tnode *
-tree()
-{
-       int *op, opst[SSIZE], *pp, prst[SSIZE];
-       register int andflg, o;
-       register struct hshtab *cs;
-       int p, ps, os;
-       struct tnode *cmst[CMSIZ];
-       struct lnode *lcp;
-
-       curbase = funcbase;
-       op = opst;
-       pp = prst;
-       cp = cmst;
-       *op = SEOF;
-       *pp = 06;
-       andflg = 0;
-
-advanc:
-       switch (o=symbol()) {
-
-       case NAME:
-               cs = csym;
-               if (cs->hclass==TYPEDEF)
-                       goto atype;
-               if (cs->hclass==ENUMCON) {
-                       *cp++ = cblock(cs->hoffset);
-                       goto tand;
-               }
-               if (cs->hclass==0 && cs->htype==0)
-                       if(nextchar()=='(') {
-                               /* set function */
-                               cs->hclass = EXTERN;
-                               cs->htype = FUNC;
-                       } else {
-                               cs->hclass = STATIC;
-                               error("%.8s undefined; func. %.8s", cs->name, funcsym->name);
-                               if (initflg) {
-                                       cs->hclass = EXTERN;
-                                       error("(Warning only)");
-                                       nerror =- 2;
-                               }
-                       }
-               *cp++ = nblock(cs);
-               goto tand;
-
-       case FCON:
-               *cp++ = fblock(DOUBLE, copnum(cval));
-               goto tand;
-
-       case LCON:
-               cs = gblock(sizeof(*lcp));
-               cs->op = LCON;
-               cs->type = LONG;
-               cs->lvalue = lcval;
-               *cp++ = cs;
-               goto tand;
-
-       case CON:
-               *cp++ = cblock(cval);
-               goto tand;
-
-       /* fake a static char array */
-       case STRING:
-               putstr(cval, 0);
-               cs = gblock(sizeof(*cs));
-               cs->hclass = STATIC;
-               cs->hoffset = cval;
-               *cp++ = block(NAME, ARRAY+CHAR, &nchstr, NULL, cs);
-
-       tand:
-               if(cp>=cmst+CMSIZ) {
-                       error("Expression overflow");
-                       exit(1);
-               }
-               if (andflg)
-                       goto syntax;
-               andflg = 1;
-               goto advanc;
-
-       case KEYW:
-       atype:
-               if (*op != LPARN || andflg)
-                       goto syntax;
-               peeksym = o;
-               *cp++ = xprtype(gblock(sizeof(*xprtype())));
-               if ((o=symbol()) != RPARN)
-                       goto syntax;
-               o = CAST;
-               --op;
-               --pp;
-               if (*op == SIZEOF) {
-                       andflg = 1;
-                       *pp = 100;
-                       goto advanc;
-               }
-               goto oponst;
-
-       case INCBEF:
-       case DECBEF:
-               if (andflg)
-                       o =+ 2;
-               goto oponst;
-
-       case COMPL:
-       case EXCLA:
-       case SIZEOF:
-               if (andflg)
-                       goto syntax;
-               goto oponst;
-
-       case MINUS:
-               if (!andflg)
-                       o = NEG;
-               andflg = 0;
-               goto oponst;
-
-       case AND:
-       case TIMES:
-               if (andflg)
-                       andflg = 0;
-               else if (o==AND)
-                       o = AMPER;
-               else
-                       o = STAR;
-               goto oponst;
-
-       case LPARN:
-               if (andflg) {
-                       o = symbol();
-                       if (o==RPARN)
-                               o = MCALL;
-                       else {
-                               peeksym = o;
-                               o = CALL;
-                               andflg = 0;
-                       }
-               }
-               goto oponst;
-
-       case RBRACK:
-       case RPARN:
-               if (!andflg)
-                       goto syntax;
-               goto oponst;
-
-       case DOT:
-       case ARROW:
-               mosflg++;
-               break;
-
-       case ASSIGN:
-               if (andflg==0 && PLUS<=*op && *op<=EXOR) {
-                       o = *op-- + ASPLUS - PLUS;
-                       pp--;
-                       goto oponst;
-               }
-               break;
-
-       }
-       /* binaries */
-       if (andflg==0)
-               goto syntax;
-       andflg = 0;
-
-oponst:
-       p = (opdope[o]>>9) & 077;
-opon1:
-       ps = *pp;
-       if (p>ps || p==ps && (opdope[o]&RASSOC)!=0) {
-               switch (o) {
-
-               case INCAFT:
-               case DECAFT:
-                       p = 37;
-                       break;
-               case LPARN:
-               case LBRACK:
-               case CALL:
-                       p = 04;
-               }
-               if (initflg) {
-                       if ((o==COMMA && *op!=LPARN && *op!=CALL)
-                        || (o==COLON && *op!=QUEST)) {
-                               p = 00;
-                               goto opon1;
-                       }
-               }
-               if (op >= &opst[SSIZE-1]) {
-                       error("expression overflow");
-                       exit(1);
-               }
-               *++op = o;
-               *++pp = p;
-               goto advanc;
-       }
-       --pp;
-       switch (os = *op--) {
-
-       case SEOF:
-               peeksym = o;
-               build(0);               /* flush conversions */
-               return(*--cp);
-
-       case COMMA:
-               if (*op != CALL)
-                       os = SEQNC;
-               break;
-
-       case CALL:
-               if (o!=RPARN)
-                       goto syntax;
-               build(os);
-               goto advanc;
-
-       case MCALL:
-               *cp++ = NULL;   /* empty arglist */
-               os = CALL;
-               break;
-
-       case INCBEF:
-       case INCAFT:
-       case DECBEF:
-       case DECAFT:
-               *cp++ = cblock(1);
-               break;
-
-       case LPARN:
-               if (o!=RPARN)
-                       goto syntax;
-               goto advanc;
-
-       case LBRACK:
-               if (o!=RBRACK)
-                       goto syntax;
-               build(LBRACK);
-               goto advanc;
-       }
-       build(os);
-       goto opon1;
-
-syntax:
-       error("Expression syntax");
-       errflush(o);
-       return(0);
-}
-
-struct hshtab *
-xprtype(atyb)
-struct hshtab *atyb;
-{
-       register struct hshtab *tyb;
-       struct hshtab typer;
-       int sc;
-       register char *md, *fb;
-       struct tnode *scp;
-
-       tyb = atyb;
-       fb = funcbase;
-       md = maxdecl;
-       scp = cp;
-       funcbase = curbase;
-       sc = DEFXTRN;           /* will cause error if class mentioned */
-       getkeywords(&sc, &typer);
-       tyb->hclass = 0;
-       tyb->hblklev = 0;
-       decl1(&sc, &typer, 0, tyb);
-       funcbase = fb;
-       maxdecl = md;
-       cp = scp;
-       tyb->op = ETYPE;
-       return(tyb);
-}
-
-char *
-copnum(len)
-{
-       register char *s1, *s2, *s3;
-
-       s1 = s2 = gblock((len+LNCPW-1) & ~(LNCPW-1));
-       s3 = numbuf;
-       while (*s2++ = *s3++);
-       return(s1);
-}
diff --git a/usr/src/cmd/c/c01.c b/usr/src/cmd/c/c01.c
deleted file mode 100644 (file)
index 2a9d96d..0000000
+++ /dev/null
@@ -1,644 +0,0 @@
-#
-/*
- * C compiler
- *
- *
- */
-
-#include "c0.h"
-
-/*
- * Called from tree, this routine takes the top 1, 2, or 3
- * operands on the expression stack, makes a new node with
- * the operator op, and puts it on the stack.
- * Essentially all the work is in inserting
- * appropriate conversions.
- */
-build(op)
-{
-       register int t1;
-       int t2, t;
-       register struct tnode *p1, *p2;
-       struct tnode *p3;
-       int dope, leftc, cvn, pcvn;
-
-       /*
-        * a[i] => *(a+i)
-        */
-       if (op==LBRACK) {
-               build(PLUS);
-               op = STAR;
-       }
-       dope = opdope[op];
-       if ((dope&BINARY)!=0) {
-               p2 = chkfun(disarray(*--cp));
-               t2 = p2->type;
-       }
-       p1 = *--cp;
-       /*
-        * sizeof gets turned into a number here.
-        */
-       if (op==SIZEOF) {
-               t1 = cblock(length(p1));
-               t1->type = UNSIGN;
-               *cp++ = t1;
-               return;
-       }
-       if (op!=AMPER) {
-               p1 = disarray(p1);
-               if (op!=CALL)
-                       p1 = chkfun(p1);
-       }
-       t1 = p1->type;
-       pcvn = 0;
-       t = INT;
-       switch (op) {
-
-       case CAST:
-               if ((t1&XTYPE)==FUNC || (t1&XTYPE)==ARRAY)
-                       error("Disallowed conversion");
-               if (t1==UNSIGN && t2==CHAR) {
-                       t2 = INT;
-                       p2 = block(AND,INT,NULL,NULL,p2,cblock(0377));
-               }
-               break;
-
-       /* end of expression */
-       case 0:
-               *cp++ = p1;
-               return;
-
-       /* no-conversion operators */
-       case QUEST:
-               if (p2->op!=COLON)
-                       error("Illegal conditional");
-               else
-                       if (fold(QUEST, p1, p2))
-                               return;
-
-       case SEQNC:
-               t = t2;
-
-       case COMMA:
-       case LOGAND:
-       case LOGOR:
-               *cp++ = block(op, t, NULL, NULL, p1, p2);
-               return;
-
-       case EXCLA:
-               t1 = INT;
-               break;
-
-       case CALL:
-               if ((t1&XTYPE) != FUNC)
-                       error("Call of non-function");
-               *cp++ = block(CALL,decref(t1),p1->subsp,p1->strp,p1,p2);
-               return;
-
-       case STAR:
-               if ((t1&XTYPE) == FUNC)
-                       error("Illegal indirection");
-               *cp++ = block(STAR, decref(t1), p1->subsp, p1->strp, p1);
-               return;
-
-       case AMPER:
-               if (p1->op==NAME || p1->op==STAR) {
-                       *cp++ = block(op,incref(t1),p1->subsp,p1->strp,p1);
-                       return;
-               }
-               error("Illegal lvalue");
-               break;
-
-       /*
-        * a.b goes to (&a)->b
-        */
-       case DOT:
-               if (p1->op==CALL && t1==STRUCT) {
-                       t1 = incref(t1);
-                       setype(p1, t1, p1);
-               } else {
-                       *cp++ = p1;
-                       build(AMPER);
-                       p1 = *--cp;
-               }
-
-       /*
-        * In a->b, a is given the type ptr-to-structure element;
-        * then the offset is added in without conversion;
-        * then * is tacked on to access the member.
-        */
-       case ARROW:
-               if (p2->op!=NAME || p2->tr1->hclass!=MOS) {
-                       error("Illegal structure ref");
-                       *cp++ = p1;
-                       return;
-               }
-               if (t2==INT && p2->tr1->hflag&FFIELD)
-                       t2 = UNSIGN;
-               t = incref(t2);
-               chkw(p1, -1);
-               setype(p1, t, p2);
-               *cp++ = block(PLUS,t,p2->subsp,p2->strp,p1,cblock(p2->tr1->hoffset));
-               build(STAR);
-               if (p2->tr1->hflag&FFIELD)
-                       *cp++ = block(FSEL,UNSIGN,NULL,NULL,*--cp,p2->tr1->hstrp);
-               return;
-       }
-       if ((dope&LVALUE)!=0)
-               chklval(p1);
-       if ((dope&LWORD)!=0)
-               chkw(p1, LONG);
-       if ((dope&RWORD)!=0)
-               chkw(p2, LONG);
-       if ((dope&BINARY)==0) {
-               if (op==ITOF)
-                       t1 = DOUBLE;
-               else if (op==FTOI)
-                       t1 = INT;
-               if (!fold(op, p1, 0))
-                       *cp++ = block(op,t1,p1->subsp,p1->strp,p1);
-               return;
-       }
-       cvn = 0;
-       if (t1==STRUCT || t2==STRUCT) {
-               if (t1!=t2 || p1->strp != p2->strp)
-                       error("Incompatible structures");
-               cvn = 0;
-       } else
-               cvn = cvtab[lintyp(t1)][lintyp(t2)];
-       leftc = (cvn>>4)&017;
-       cvn =& 017;
-       t = leftc? t2:t1;
-       if ((t==INT||t==CHAR) && (t1==UNSIGN||t2==UNSIGN))
-               t = UNSIGN;
-       if (dope&ASSGOP || op==CAST) {
-               t = t1;
-               if (op==ASSIGN || op==CAST) {
-                       if (cvn==ITP||cvn==PTI)
-                               cvn = leftc = 0;
-                       else if (cvn==LTP) {
-                               if (leftc==0)
-                                       cvn = LTI;
-                               else {
-                                       cvn = ITL;
-                                       leftc = 0;
-                               }
-                       }
-               }
-               if (leftc)
-                       cvn = leftc;
-               leftc = 0;
-       } else if (op==COLON || op==MAX || op==MIN) {
-               if (t1>=PTR && t1==t2)
-                       cvn = 0;
-               if (op!=COLON && (t1>=PTR || t2>=PTR))
-                       op =+ MAXP-MAX;
-       } else if (dope&RELAT) {
-               if (op>=LESSEQ && (t1>=PTR||t2>=PTR||(t1==UNSIGN||t2==UNSIGN)
-                && (t==INT||t==CHAR||t==UNSIGN)))
-                       op =+ LESSEQP-LESSEQ;
-               if (cvn==ITP || cvn==PTI)
-                       cvn = 0;
-       }
-       if (cvn==PTI) {
-               cvn = 0;
-               if (op==MINUS) {
-                       t = INT;
-                       pcvn++;
-               } else {
-                       if (t1!=t2 || t1!=(PTR+CHAR))
-                               cvn = XX;
-               }
-       }
-       if (cvn) {
-               t1 = plength(p1);
-               t2 = plength(p2);
-               if (cvn==XX || (cvn==PTI&&t1!=t2))
-                       error("Illegal conversion");
-               else if (leftc)
-                       p1 = convert(p1, t, cvn, t2);
-               else
-                       p2 = convert(p2, t, cvn, t1);
-       }
-       if (dope&RELAT)
-               t = INT;
-       if (t==FLOAT)
-               t = DOUBLE;
-       if (t==CHAR)
-               t = INT;
-       if (op==CAST) {
-               if (t!=DOUBLE && (t!=INT || p2->type!=CHAR)) {
-                       p2->type = t;
-                       p2->subsp = p1->subsp;
-                       p2->strp = p1->strp;
-               }
-               if (t==INT && p1->type==CHAR)
-                       p2 = block(ITOC, INT, NULL, NULL, p2);
-               *cp++ = p2;
-               return;
-       }
-       if (fold(op, p1, p2)==0) {
-               p3 = leftc?p2:p1;
-               *cp++ = block(op, t, p3->subsp, p3->strp, p1, p2);
-       }
-       if (pcvn && t1!=(PTR+CHAR)) {
-               p1 = *--cp;
-               *cp++ = convert(p1, 0, PTI, plength(p1->tr1));
-       }
-}
-
-/*
- * Generate the appropriate conversion operator.
- */
-struct tnode *
-convert(p, t, cvn, len)
-struct tnode *p;
-{
-       register int op;
-
-       op = cvntab[cvn];
-       if (opdope[op]&BINARY) {
-               if (len==0)
-                       error("Illegal conversion");
-               return(block(op, t, NULL, NULL, p, cblock(len)));
-       }
-       return(block(op, t, NULL, NULL, p));
-}
-
-/*
- * Traverse an expression tree, adjust things
- * so the types of things in it are consistent
- * with the view that its top node has
- * type at.
- * Used with structure references.
- */
-setype(ap, at, anewp)
-struct tnode *ap, *anewp;
-{
-       register struct tnode *p, *newp;
-       register t;
-
-       p = ap;
-       t = at;
-       newp = anewp;
-       for (;; p = p->tr1) {
-               p->subsp = newp->subsp;
-               p->strp = newp->strp;
-               p->type = t;
-               if (p->op==AMPER)
-                       t = decref(t);
-               else if (p->op==STAR)
-                       t = incref(t);
-               else if (p->op!=PLUS)
-                       break;
-       }
-}
-
-/*
- * A mention of a function name is turned into
- * a pointer to that function.
- */
-struct tnode *
-chkfun(ap)
-struct tnode *ap;
-{
-       register struct tnode *p;
-       register int t;
-
-       p = ap;
-       if (((t = p->type)&XTYPE)==FUNC && p->op!=ETYPE)
-               return(block(AMPER,incref(t),p->subsp,p->strp,p));
-       return(p);
-}
-
-/*
- * A mention of an array is turned into
- * a pointer to the base of the array.
- */
-struct tnode *
-disarray(ap)
-struct tnode *ap;
-{
-       register int t;
-       register struct tnode *p;
-
-       p = ap;
-       /* check array & not MOS and not typer */
-       if (((t = p->type)&XTYPE)!=ARRAY || p->op==NAME&&p->tr1->hclass==MOS
-        || p->op==ETYPE)
-               return(p);
-       p->subsp++;
-       *cp++ = p;
-       setype(p, decref(t), p);
-       build(AMPER);
-       return(*--cp);
-}
-
-/*
- * make sure that p is a ptr to a node
- * with type int or char or 'okt.'
- * okt might be nonexistent or 'long'
- * (e.g. for <<).
- */
-chkw(p, okt)
-struct tnode *p;
-{
-       register int t;
-
-       if ((t=p->type)!=INT && t<PTR && t!=CHAR && t!=UNSIGN && t!=okt)
-               error("Illegal type of operand");
-       return;
-}
-
-/*
- *'linearize' a type for looking up in the
- * conversion table
- */
-lintyp(t)
-{
-       switch(t) {
-
-       case INT:
-       case CHAR:
-       case UNSIGN:
-               return(0);
-
-       case FLOAT:
-       case DOUBLE:
-               return(1);
-
-       case LONG:
-               return(2);
-
-       default:
-               return(3);
-       }
-}
-
-/*
- * Report an error.
- */
-error(s, p1, p2, p3, p4, p5, p6)
-{
-       nerror++;
-       if (filename[0])
-               fprintf(stderr, "%s:", filename);
-       fprintf(stderr, "%d: ", line);
-       fprintf(stderr, s, p1, p2, p3, p4, p5, p6);
-       fprintf(stderr, "\n");
-}
-
-/*
- * Generate a node in an expression tree,
- * setting the operator, type, dimen/struct table ptrs,
- * and the operands.
- */
-struct tnode *
-block(op, t, subs, str, p1,p2)
-int *subs;
-struct str *str;
-struct tnode *p1, *p2;
-{
-       register struct tnode *p;
-
-       p = gblock(sizeof(*p));
-       p->op = op;
-       p->type = t;
-       p->subsp = subs;
-       p->strp = str;
-       p->tr1 = p1;
-       if (opdope[op]&BINARY)
-               p->tr2 = p2;
-       else
-               p->tr2 = NULL;
-       return(p);
-}
-
-struct tnode *
-nblock(ads)
-struct hshtab *ads;
-{
-       register struct hshtab *ds;
-
-       ds = ads;
-       return(block(NAME, ds->htype, ds->hsubsp, ds->hstrp, ds));
-}
-
-/*
- * Generate a block for a constant
- */
-struct cnode *
-cblock(v)
-{
-       register struct cnode *p;
-
-       p = gblock(sizeof(*p));
-       p->op = CON;
-       p->type = INT;
-       p->subsp = NULL;
-       p->strp = NULL;
-       p->value = v;
-       return(p);
-}
-
-/*
- * A block for a float or long constant
- */
-struct fnode *
-fblock(t, string)
-char *string;
-{
-       register struct fnode *p;
-
-       p = gblock(sizeof(*p));
-       p->op = FCON;
-       p->type = t;
-       p->subsp = NULL;
-       p->strp = NULL;
-       p->cstr = string;
-       return(p);
-}
-
-/*
- * Assign a block for use in the
- * expression tree.
- */
-char *
-gblock(n)
-{
-       register int *p;
-
-       p = curbase;
-       if ((curbase =+ n) >= coremax) {
-               if (sbrk(1024) == -1) {
-                       error("Out of space");
-                       exit(1);
-               }
-               coremax =+ 1024;
-       }
-       return(p);
-}
-
-/*
- * Check that a tree can be used as an lvalue.
- */
-chklval(ap)
-struct tnode *ap;
-{
-       register struct tnode *p;
-
-       p = ap;
-       if (p->op==FSEL)
-               p = p->tr1;
-       if (p->op!=NAME && p->op!=STAR)
-               error("Lvalue required");
-}
-
-/*
- * reduce some forms of `constant op constant'
- * to a constant.  More of this is done in the next pass
- * but this is used to allow constant expressions
- * to be used in switches and array bounds.
- */
-fold(op, ap1, ap2)
-struct tnode *ap1, *ap2;
-{
-       register struct tnode *p1;
-       register int v1, v2;
-       int unsignf;
-
-       p1 = ap1;
-       if (p1->op!=CON)
-               return(0);
-       unsignf = p1->type==UNSIGN;
-       if (op==QUEST) {
-               if (ap2->tr1->op==CON && ap2->tr2->op==CON) {
-                       p1->value = p1->value? ap2->tr1->value: ap2->tr2->value;
-                       *cp++ = p1;
-                       return(1);
-               }
-               return(0);
-       }
-       if (ap2) {
-               if (ap2->op!=CON)
-                       return(0);
-               v2 = ap2->value;
-               unsignf |= ap2->type==UNSIGN;
-       }
-       v1 = p1->value;
-       switch (op) {
-
-       case PLUS:
-               v1 =+ v2;
-               break;
-
-       case MINUS:
-               v1 =- v2;
-               break;
-
-       case TIMES:
-               v1 =* v2;
-               break;
-
-       case DIVIDE:
-               if (v2==0)
-                       goto divchk;
-               if (unsignf) {
-                       v1 = (unsigned)v1 / v2;
-                       break;
-               }
-               v1 =/ v2;
-               break;
-
-       case MOD:
-               if (v2==0)
-                       goto divchk;
-               if (unsignf) {
-                       v1 = (unsigned)v1 % v2;
-                       break;
-               }
-               v1 =% v2;
-               break;
-
-       case AND:
-               v1 =& v2;
-               break;
-
-       case OR:
-               v1 =| v2;
-               break;
-
-       case EXOR:
-               v1 =^ v2;
-               break;
-
-       case NEG:
-               v1 = - v1;
-               break;
-
-       case COMPL:
-               v1 = ~ v1;
-               break;
-
-       case LSHIFT:
-               v1 =<< v2;
-               break;
-
-       case RSHIFT:
-               if (unsignf) {
-                       v1 = (unsigned)v1 >> v2;
-                       break;
-               }
-               v1 =>> v2;
-               break;
-
-       case EQUAL:
-               v1 = v1==v2;
-               break;
-
-       case NEQUAL:
-               v1 = v1!=v2;
-               break;
-
-       case LESS:
-               v1 = v1<v2;
-               break;
-
-       case GREAT:
-               v1 = v1>v2;
-               break;
-
-       case LESSEQ:
-               v1 = v1<=v2;
-               break;
-
-       case GREATEQ:
-               v1 = v1>=v2;
-               break;
-
-       divchk:
-               error("Divide check");
-       default:
-               return(0);
-       }
-       p1->value = v1;
-       *cp++ = p1;
-       return(1);
-}
-
-/*
- * Compile an expression expected to have constant value,
- * for example an array bound or a case value.
- */
-conexp()
-{
-       register struct tnode *t;
-
-       initflg++;
-       if (t = tree())
-               if (t->op != CON)
-                       error("Constant required");
-       initflg--;
-       curbase = funcbase;
-       return(t->value);
-}
diff --git a/usr/src/cmd/c/c02.c b/usr/src/cmd/c/c02.c
deleted file mode 100644 (file)
index 8decd43..0000000
+++ /dev/null
@@ -1,792 +0,0 @@
-#
-/* C compiler
- *
- *
- */
-
-#include "c0.h"
-
-/*
- * Process a single external definition
- */
-extdef()
-{
-       register o;
-       int sclass, scflag, *cb;
-       struct hshtab typer;
-       register struct hshtab *ds;
-
-       if(((o=symbol())==EOFC) || o==SEMI)
-               return;
-       peeksym = o;
-       sclass = 0;
-       blklev = 0;
-       if (getkeywords(&sclass, &typer)==0) {
-               sclass = EXTERN;
-               if (peeksym!=NAME)
-                       goto syntax;
-       }
-       scflag = 0;
-       if (sclass==DEFXTRN) {
-               scflag++;
-               sclass = EXTERN;
-       }
-       if (sclass!=EXTERN && sclass!=STATIC && sclass!=TYPEDEF)
-               error("Illegal storage class");
-       do {
-               defsym = 0;
-               paraml = 0;
-               parame = 0;
-               if (sclass==TYPEDEF) {
-                       decl1(TYPEDEF, &typer, 0, NULL);
-                       continue;
-               }
-               decl1(EXTERN, &typer, 0, NULL);
-               if ((ds=defsym)==0)
-                       return;
-               funcsym = ds;
-               if ((ds->type&XTYPE)==FUNC) {
-                       if ((peeksym=symbol())==LBRACE || peeksym==KEYW
-                        || (peeksym==NAME && csym->hclass==TYPEDEF)) {
-                               funcblk.type = decref(ds->type);
-                               funcblk.strp = ds->strp;
-                               setinit(ds);
-                               outcode("BS", SYMDEF, sclass==EXTERN?ds->name:"");
-                               cfunc();
-                               return;
-                       }
-                       if (paraml)
-                               error("Inappropriate parameters");
-               } else if ((o=symbol())==COMMA || o==SEMI) {
-                       peeksym = o;
-                       o = (length(ds)+ALIGN) & ~ALIGN;
-                       if (sclass==STATIC) {
-                               setinit(ds);
-                               outcode("BSBBSBN", SYMDEF, "", BSS, NLABEL, ds->name, SSPACE, o);
-                       } else if (scflag)
-                               outcode("BSN", CSPACE, ds->name, o);
-               } else {
-                       if (o!=ASSIGN)
-                               peeksym = o;
-                       setinit(ds);
-                       if (sclass==EXTERN)
-                               outcode("BS", SYMDEF, ds->name);
-                       outcode("BBS", DATA, NLABEL, ds->name);
-                       cb = funcbase;
-                       if (cinit(ds, 1, sclass) & ALIGN)
-                               outcode("B", EVEN);
-                       if (maxdecl > cb)
-                               cb = maxdecl;
-                       funcbase = cb;
-               }
-       } while ((o=symbol())==COMMA);
-       if (o==SEMI)
-               return;
-syntax:
-       if (o==RBRACE) {
-               error("Too many }'s");
-               peeksym = 0;
-               return;
-       }
-       error("External definition syntax");
-       errflush(o);
-       statement();
-}
-
-/*
- * Process a function definition.
- */
-cfunc()
-{
-       register int *cb;
-       register sloc;
-
-       sloc = isn;
-       isn =+ 2;
-       outcode("BBS", PROG, RLABEL, funcsym->name);
-       if (proflg)
-               outcode("BN", PROFIL, isn++);
-       cb = curbase;
-       regvar = 5;
-       autolen = STAUTO;
-       maxauto = STAUTO;
-       blklev = 1;
-       declist(ARG);
-       outcode("B", SAVE);
-       funchead();
-       branch(sloc);
-       label(sloc+1);
-       retlab = isn++;
-       blklev = 0;
-       if ((peeksym = symbol()) != LBRACE)
-               error("Compound statement required");
-       statement();
-       outcode("BNB", LABEL, retlab, RETRN);
-       label(sloc);
-       outcode("BN", SETSTK, -maxauto);
-       branch(sloc+1);
-       if (cb < maxdecl)
-               cb = maxdecl;
-       curbase = funcbase = cb;
-}
-
-/*
- * Process the initializers for an external definition.
- */
-cinit(anp, flex, sclass)
-struct hshtab *anp;
-{
-       register struct phshtab *np;
-       register nel, ninit;
-       int width, isarray, o, brace, realtype, *cb;
-       struct tnode *s;
-
-       cb = funcbase;
-       np = gblock(sizeof(*np));
-       funcbase = curbase;
-       cpysymb(np, anp);
-       realtype = np->type;
-       isarray = 0;
-       if ((realtype&XTYPE) == ARRAY)
-               isarray++;
-       else
-               flex = 0;
-       width = length(np);
-       nel = 1;
-       /*
-        * If it's an array, find the number of elements.
-        * temporarily modify to look like kind of thing it's
-        * an array of.
-        */
-       if (sclass==AUTO)
-               if (isarray || realtype==STRUCT)
-                       error("No auto. aggregate initialization");
-       if (isarray) {
-               np->type = decref(realtype);
-               np->subsp++;
-               if (width==0 && flex==0)
-                       error("0-length row: %.8s", anp->name);
-               o = length(np);
-               /* nel = ldiv(0, width, o); */
-               nel = (unsigned)width/o;
-               width = o;
-       }
-       brace = 0;
-       if ((peeksym=symbol())==LBRACE && (isarray || np->type!=STRUCT)) {
-               peeksym = -1;
-               brace++;
-       }
-       ninit = 0;
-       do {
-               if ((o=symbol())==RBRACE)
-                       break;
-               peeksym = o;
-               if (o==STRING && realtype==ARRAY+CHAR) {
-                       if (sclass==AUTO)
-                               error("No strings in automatic");
-                       peeksym = -1;
-                       putstr(0, flex?10000:nel);
-                       ninit =+ nchstr;
-                       o = symbol();
-                       break;
-               } else if (np->type==STRUCT) {
-                       strinit(np, sclass);
-               } else if ((np->type&ARRAY)==ARRAY || peeksym==LBRACE)
-                       cinit(np, 0, sclass);
-               else {
-                       initflg++;
-                       s = tree();
-                       initflg = 0;
-                       if (np->hflag&FFIELD)
-                               error("No field initialization");
-                       *cp++ = nblock(np);
-                       *cp++ = s;
-                       build(ASSIGN);
-                       if (sclass==AUTO||sclass==REG)
-                               rcexpr(*--cp);
-                       else if (sclass==ENUMCON) {
-                               if (s->op!=CON)
-                                       error("Illegal enum constant for %.8s", anp->name);
-                               anp->hoffset = s->value;
-                       } else
-                               rcexpr(block(INIT,np->type,NULL,NULL,(*--cp)->tr2));
-               }
-               ninit++;
-               if ((ninit&077)==0 && sclass==EXTERN)
-                       outcode("BS", SYMDEF, "");
-       } while ((o=symbol())==COMMA && (ninit<nel || brace || flex));
-       if (brace==0 || o!=RBRACE)
-               peeksym = o;
-       /*
-        * If there are too few initializers, allocate
-        * more storage.
-        * If there are too many initializers, extend
-        * the declared size for benefit of "sizeof"
-        */
-       if (ninit<nel && sclass!=AUTO)
-               outcode("BN", SSPACE, (nel-ninit)*width);
-       else if (ninit>nel) {
-               if (flex && nel==0) {
-                       np->subsp[-1] = ninit;
-               } else
-                       error("Too many initializers: %.8s", anp->name);
-               nel = ninit;
-       }
-       curbase = funcbase = cb;
-       return(nel*width);
-}
-
-/*
- * Initialize a structure
- */
-strinit(np, sclass)
-struct tnode *np;
-{
-       register struct hshtab **mlp;
-       static zerloc;
-       register int o, brace;
-
-       if ((mlp = np->strp->memlist)==NULL) {
-               mlp = &zerloc;
-               error("Undefined structure initialization");
-       }
-       brace = 0;
-       if ((o = symbol()) == LBRACE)
-               brace++;
-       else
-               peeksym = o;
-       do {
-               if ((o=symbol()) == RBRACE)
-                       break;
-               peeksym = o;
-               if (*mlp==0) {
-                       error("Too many structure initializers");
-                       cinit(&funcblk, 0, sclass);
-               } else
-                       cinit(*mlp++, 0, sclass);
-               if (*mlp ==  &structhole) {
-                       outcode("B", EVEN);
-                       mlp++;
-               }
-       } while ((o=symbol())==COMMA && (*mlp || brace));
-       if (sclass!=AUTO && sclass!=REG) {
-               if (*mlp)
-                       outcode("BN", SSPACE, np->strp->ssize - (*mlp)->hoffset);
-               outcode("B", EVEN);
-       }
-       if (o!=RBRACE || brace==0)
-               peeksym = o;
-}
-
-/*
- * Mark already initialized
- */
-setinit(anp)
-struct hshtab *anp;
-{
-       register struct hshtab *np;
-
-       np = anp;
-       if (np->hflag&FINIT)
-               error("%s multiply defined", np->name);
-       np->hflag =| FINIT;
-}
-
-/*
- * Process one statement in a function.
- */
-statement()
-{
-       register o, o1, o2;
-       int o3;
-       struct tnode *np;
-       int sauto, sreg;
-
-stmt:
-       switch(o=symbol()) {
-
-       case EOFC:
-               error("Unexpected EOF");
-       case SEMI:
-               return;
-
-       case LBRACE:
-               sauto = autolen;
-               sreg = regvar;
-               blockhead();
-               while (!eof) {
-                       if ((o=symbol())==RBRACE) {
-                               autolen = sauto;
-                               if (sreg!=regvar)
-                                       outcode("BN", SETREG, sreg);
-                               regvar = sreg;
-                               blkend();
-                               return;
-                       }
-                       peeksym = o;
-                       statement();
-               }
-               error("Missing '}'");
-               return;
-
-       case KEYW:
-               switch(cval) {
-
-               case GOTO:
-                       if (o1 = simplegoto())
-                               branch(o1);
-                       else 
-                               dogoto();
-                       goto semi;
-
-               case RETURN:
-                       doret();
-                       goto semi;
-
-               case IF:
-                       np = pexpr();
-                       o2 = 0;
-                       if ((o1=symbol())==KEYW) switch (cval) {
-                       case GOTO:
-                               if (o2=simplegoto())
-                                       goto simpif;
-                               cbranch(np, o2=isn++, 0);
-                               dogoto();
-                               label(o2);
-                               goto hardif;
-
-                       case RETURN:
-                               if (nextchar()==';') {
-                                       o2 = retlab;
-                                       goto simpif;
-                               }
-                               cbranch(np, o1=isn++, 0);
-                               doret();
-                               label(o1);
-                               o2++;
-                               goto hardif;
-
-                       case BREAK:
-                               o2 = brklab;
-                               goto simpif;
-
-                       case CONTIN:
-                               o2 = contlab;
-                       simpif:
-                               chconbrk(o2);
-                               cbranch(np, o2, 1);
-                       hardif:
-                               if ((o=symbol())!=SEMI)
-                                       goto syntax;
-                               if ((o1=symbol())==KEYW && cval==ELSE) 
-                                       goto stmt;
-                               peeksym = o1;
-                               return;
-                       }
-                       peeksym = o1;
-                       cbranch(np, o1=isn++, 0);
-                       statement();
-                       if ((o=symbol())==KEYW && cval==ELSE) {
-                               o2 = isn++;
-                               branch(o2);
-                               label(o1);
-                               statement();
-                               label(o2);
-                               return;
-                       }
-                       peeksym = o;
-                       label(o1);
-                       return;
-
-               case WHILE:
-                       o1 = contlab;
-                       o2 = brklab;
-                       label(contlab = isn++);
-                       cbranch(pexpr(), brklab=isn++, 0);
-                       statement();
-                       branch(contlab);
-                       label(brklab);
-                       contlab = o1;
-                       brklab = o2;
-                       return;
-
-               case BREAK:
-                       chconbrk(brklab);
-                       branch(brklab);
-                       goto semi;
-
-               case CONTIN:
-                       chconbrk(contlab);
-                       branch(contlab);
-                       goto semi;
-
-               case DO:
-                       o1 = contlab;
-                       o2 = brklab;
-                       contlab = isn++;
-                       brklab = isn++;
-                       label(o3 = isn++);
-                       statement();
-                       label(contlab);
-                       contlab = o1;
-                       if ((o=symbol())==KEYW && cval==WHILE) {
-                               cbranch(tree(), o3, 1);
-                               label(brklab);
-                               brklab = o2;
-                               goto semi;
-                       }
-                       goto syntax;
-
-               case CASE:
-                       o1 = conexp();
-                       if ((o=symbol())!=COLON)
-                               goto syntax;
-                       if (swp==0) {
-                               error("Case not in switch");
-                               goto stmt;
-                       }
-                       if(swp>=swtab+SWSIZ) {
-                               error("Switch table overflow");
-                       } else {
-                               swp->swlab = isn;
-                               (swp++)->swval = o1;
-                               label(isn++);
-                       }
-                       goto stmt;
-
-               case SWITCH:
-                       o1 = brklab;
-                       brklab = isn++;
-                       np = pexpr();
-                       chkw(np, -1);
-                       rcexpr(block(RFORCE,0,NULL,NULL,np));
-                       pswitch();
-                       brklab = o1;
-                       return;
-
-               case DEFAULT:
-                       if (swp==0)
-                               error("Default not in switch");
-                       if (deflab)
-                               error("More than 1 'default'");
-                       if ((o=symbol())!=COLON)
-                               goto syntax;
-                       label(deflab = isn++);
-                       goto stmt;
-
-               case FOR:
-                       o1 = contlab;
-                       o2 = brklab;
-                       contlab = isn++;
-                       brklab = isn++;
-                       if (o=forstmt())
-                               goto syntax;
-                       label(brklab);
-                       contlab = o1;
-                       brklab = o2;
-                       return;
-
-               case ELSE:
-                       error("Inappropriate 'else'");
-                       statement();
-                       return;
-               }
-               error("Unknown keyword");
-               goto syntax;
-
-       case NAME:
-               if (nextchar()==':') {
-                       peekc = 0;
-                       o1 = csym;
-                       if (o1->hclass>0) {
-                               if (o1->hblklev==0) {
-                                       pushdecl(o1);
-                                       o1->hoffset = 0;
-                               } else {
-                                       defsym = o1;
-                                       redec();
-                                       goto stmt;
-                               }
-                       }
-                       o1->hclass = STATIC;
-                       o1->htype = ARRAY;
-                       o1->hflag =| FLABL;
-                       if (o1->hoffset==0)
-                               o1->hoffset = isn++;
-                       label(o1->hoffset);
-                       goto stmt;
-               }
-       }
-       peeksym = o;
-       rcexpr(tree());
-
-semi:
-       if ((o=symbol())==SEMI)
-               return;
-syntax:
-       error("Statement syntax");
-       errflush(o);
-}
-
-/*
- * Process a for statement.
- */
-forstmt()
-{
-       register int l, o, sline;
-       int sline1, *ss;
-       struct tnode *st;
-
-       if ((o=symbol()) != LPARN)
-               return(o);
-       if ((o=symbol()) != SEMI) {             /* init part */
-               peeksym = o;
-               rcexpr(tree());
-               if ((o=symbol()) != SEMI)
-                       return(o);
-       }
-       label(contlab);
-       if ((o=symbol()) != SEMI) {             /* test part */
-               peeksym = o;
-               cbranch(tree(), brklab, 0);
-               if ((o=symbol()) != SEMI)
-                       return(o);
-       }
-       if ((peeksym=symbol()) == RPARN) {      /* incr part */
-               peeksym = -1;
-               statement();
-               branch(contlab);
-               return(0);
-       }
-       l = contlab;
-       contlab = isn++;
-       st = tree();
-       sline = line;
-       if ((o=symbol()) != RPARN)
-               return(o);
-       ss = funcbase;
-       funcbase = curbase;
-       statement();
-       sline1 = line;
-       line = sline;
-       label(contlab);
-       rcexpr(st);
-       line = sline1;
-       if (ss < maxdecl)
-               ss = maxdecl;
-       curbase = funcbase = ss;
-       branch(l);
-       return(0);
-}
-
-/*
- * A parenthesized expression,
- * as after "if".
- */
-struct tnode *
-pexpr()
-{
-       register o, t;
-
-       if ((o=symbol())!=LPARN)
-               goto syntax;
-       t = tree();
-       if ((o=symbol())!=RPARN)
-               goto syntax;
-       return(t);
-syntax:
-       error("Statement syntax");
-       errflush(o);
-       return(0);
-}
-
-/*
- * The switch statement, which involves collecting the
- * constants and labels for the cases.
- */
-pswitch()
-{
-       register struct swtab *cswp, *sswp;
-       int dl, swlab;
-
-       cswp = sswp = swp;
-       if (swp==0)
-               cswp = swp = swtab;
-       branch(swlab=isn++);
-       dl = deflab;
-       deflab = 0;
-       statement();
-       branch(brklab);
-       label(swlab);
-       if (deflab==0)
-               deflab = brklab;
-       outcode("BNN", SWIT, deflab, line);
-       for (; cswp < swp; cswp++)
-               outcode("NN", cswp->swlab, cswp->swval);
-       outcode("0");
-       label(brklab);
-       deflab = dl;
-       swp = sswp;
-}
-
-/*
- * funchead is called at the start of each function
- * to process the arguments, which have been linked in a list.
- * This list is necessary because in
- * f(a, b) float b; int a; ...
- * the names are seen before the types.
- */
-/*
- * Structure resembling a block for a register variable.
- */
-struct hshtab  hreg    { REG, 0, 0, NULL, NULL, 0 };
-struct tnode   areg    { NAME, 0, NULL, NULL, &hreg};
-funchead()
-{
-       register pl;
-       register struct hshtab *cs;
-       struct tnode *bstack[2];
-
-       pl = STARG;
-       while(paraml) {
-               parame->hoffset = 0;
-               cs = paraml;
-               paraml = paraml->hoffset;
-               if (cs->htype==FLOAT)
-                       cs->htype = DOUBLE;
-               cs->hoffset = pl;
-               if ((cs->htype&XTYPE) == ARRAY) {
-                       cs->htype =- (ARRAY-PTR);       /* set ptr */
-                       cs->subsp++;            /* pop dims */
-               }
-               pl =+ rlength(cs);
-               if (cs->hclass==AREG && (hreg.hoffset=goodreg(cs))>=0) {
-                       bstack[0] = &areg;
-                       bstack[1] = nblock(cs);
-                       cp = &bstack[2];
-                       areg.type = cs->htype;
-                       cs->hclass = AUTO;
-                       build(ASSIGN);
-                       rcexpr(bstack[0]);
-                       cs->hoffset = hreg.hoffset;
-                       cs->hclass = REG;
-               } else
-                       cs->hclass = AUTO;
-               prste(cs);
-       }
-       for (cs=hshtab; cs<hshtab+HSHSIZ; cs++) {
-               if (cs->name[0] == '\0')
-                       continue;
-               if (cs->hclass == ARG || cs->hclass==AREG)
-                       error("Not an argument: %.8s", cs->name);
-       }
-       outcode("BN", SETREG, regvar);
-}
-
-blockhead()
-{
-       register r;
-
-       r = regvar;
-       blklev++;
-       declist(0);
-       if (r != regvar)
-               outcode("BN", SETREG, regvar);
-}
-
-/*
- * After the end of a block, delete local
- * symbols; save those that are external.
- * Also complain about undefined labels.
- */
-blkend()
-{
-       register struct hshtab *cs, *ncs;
-       struct hshtab *endcs;
-       register i;
-
-       blklev--;
-       for (cs=hshtab; cs->name[0] && cs<hshtab+HSHSIZ-1; ++cs)
-               ;
-       endcs = cs;
-       do  if (cs->name[0]) {
-               if (cs->hblklev <= blklev)
-                       continue;
-               if ((cs->hclass!=EXTERN || blklev!=0)
-                && ((cs->hflag&FLABL)==0 || blklev==0)) {
-                       if (cs->hclass==0)
-                               error("%.8s undefined", cs->name);
-                       if ((ncs = cs->hpdown)==NULL) {
-                               cs->name[0] = '\0';
-                               hshused--;
-                               cs->hflag =& FKEYW;
-                       } else {
-                               cpysymb(cs, ncs);
-                       }
-                       continue;
-               }
-               /*
-                * Retained name; must rehash.
-                */
-               for (i=0; i<NCPS; i++)
-                       symbuf[i] = cs->name[i];
-               mossym = cs->hflag&FMOS;
-               lookup();
-               if ((ncs=csym) != cs) {
-                       cs->name[0] = '\0';
-                       hshused--;
-                       i = ncs->hflag;
-                       cpysymb(ncs, cs);
-                       ncs->hflag =| i&FKEYW;
-                       cs->hflag =& FKEYW;
-               }
-               if (ncs->hblklev>1 || (ncs->hblklev>0 && ncs->hclass==EXTERN))
-                       ncs->hblklev--;
-       } while ((cs = (cs<&hshtab[HSHSIZ-1])? ++cs: hshtab) != endcs);
-}
-
-/*
- * write out special definitions of local symbols for
- * benefit of the debugger.  None of these are used
- * by the assembler except to save them.
- */
-prste(acs)
-struct hshtab *acs;
-{
-       register struct hshtab *cs;
-       register nkind;
-
-       cs = acs;
-       switch (cs->hclass) {
-       case REG:
-               nkind = RNAME;
-               break;
-
-       case AUTO:
-               nkind = ANAME;
-               break;
-
-       case STATIC:
-               nkind = SNAME;
-               break;
-
-       default:
-               return;
-
-       }
-       outcode("BSN", nkind, cs->name, cs->hoffset);
-}
-
-/*
- * In case of error, skip to the next
- * statement delimiter.
- */
-errflush(ao)
-{
-       register o;
-
-       o = ao;
-       while(o>RBRACE) /* ; { } */
-               o = symbol();
-       peeksym  = o;
-}
diff --git a/usr/src/cmd/c/c03.c b/usr/src/cmd/c/c03.c
deleted file mode 100644 (file)
index 993d3af..0000000
+++ /dev/null
@@ -1,695 +0,0 @@
-#
-/*
- * C compiler, phase 1
- *
- *
- * Handles processing of declarations,
- * except for top-level processing of
- * externals.
- */
-
-#include "c0.h"
-
-/*
- * Process a sequence of declaration statements
- */
-declist(sclass)
-{
-       register sc, offset;
-       struct hshtab typer;
-
-       offset = 0;
-       sc = sclass;
-       while (getkeywords(&sclass, &typer)) {
-               offset = declare(sclass, &typer, offset);
-               sclass = sc;
-       }
-       return(offset+align(INT, offset, 0));
-}
-
-/*
- * Read the keywords introducing a declaration statement
- * Store back the storage class, and fill in the type
- * entry, which looks like a hash table entry.
- */
-getkeywords(scptr, tptr)
-int *scptr;
-struct hshtab *tptr;
-{
-       register skw, tkw, longf;
-       int o, isadecl, ismos, unsignf;
-
-       isadecl = 0;
-       longf = 0;
-       unsignf = 0;
-       tptr->htype = INT;
-       tptr->hstrp = NULL;
-       tptr->hsubsp = NULL;
-       tkw = -1;
-       skw = *scptr;
-       ismos = skw==MOS||skw==MOU;
-       for (;;) {
-               mosflg = ismos && isadecl;
-               o = symbol();
-               if (o==NAME && csym->hclass==TYPEDEF && tkw<0) {
-                       tkw = csym->htype;
-                       tptr->hsubsp = csym->hsubsp;
-                       tptr->hstrp = csym->hstrp;
-                       isadecl++;
-                       continue;
-               }
-               switch (o==KEYW? cval: -1) {
-               case AUTO:
-               case STATIC:
-               case EXTERN:
-               case REG:
-               case TYPEDEF:
-                       if (skw && skw!=cval) {
-                               if (skw==ARG && cval==REG)
-                                       cval = AREG;
-                               else
-                                       error("Conflict in storage class");
-                       }
-                       skw = cval;
-                       break;
-       
-               case UNSIGN:
-                       unsignf++;
-                       break;
-
-               case LONG:
-                       longf++;
-                       break;
-
-               case ENUM:
-                       strdec(ismos, cval);
-                       cval = INT;
-                       goto types;
-
-               case UNION:
-               case STRUCT:
-                       tptr->hstrp = strdec(ismos, cval);
-                       cval = STRUCT;
-               case INT:
-               case CHAR:
-               case FLOAT:
-               case DOUBLE:
-               types:
-                       if (tkw>=0)
-                               error("Type clash");
-                       tkw = cval;
-                       break;
-       
-               default:
-                       peeksym = o;
-                       if (isadecl==0)
-                               return(0);
-                       if (tkw<0)
-                               tkw = INT;
-                       if (skw==0)
-                               skw = blklev==0? DEFXTRN: AUTO;
-                       if (unsignf) {
-                               if (tkw==INT)
-                                       tkw = UNSIGN;
-                               else
-                                       error("Misplaced 'unsigned'");
-                       }
-                       if (longf) {
-                               if (tkw==FLOAT)
-                                       tkw = DOUBLE;
-                               else if (tkw==INT)
-                                       tkw = LONG;
-                               else
-                                       error("Misplaced 'long'");
-                       }
-                       *scptr = skw;
-                       tptr->htype = tkw;
-                       return(1);
-               }
-               isadecl++;
-       }
-}
-
-/*
- * Process a structure, union, or enum declaration; a subroutine
- * of getkeywords.
- */
-struct str *
-strdec(mosf, kind)
-{
-       register elsize, o;
-       register struct hshtab *ssym;
-       int savebits;
-       struct hshtab **savememlist;
-       int savenmems;
-       struct str *strp;
-       struct hshtab *ds;
-       struct hshtab *mems[NMEMS];
-       struct hshtab typer;
-       int tagkind;
-
-       if (kind!=ENUM) {
-               tagkind = STRTAG;
-               mosflg = 1;
-       } else
-               tagkind = ENUMTAG;
-       ssym = 0;
-       if ((o=symbol())==NAME) {
-               ssym = csym;
-               mosflg = mosf;
-               o = symbol();
-               if (o==LBRACE && ssym->hblklev<blklev)
-                       pushdecl(ssym);
-               if (ssym->hclass==0) {
-                       ssym->hclass = tagkind;
-                       ssym->strp = gblock(sizeof(*strp));
-                       funcbase = curbase;
-                       ssym->strp->ssize = 0;
-                       ssym->strp->memlist = NULL;
-               }
-               if (ssym->hclass != tagkind)
-                       redec();
-               strp = ssym->strp;
-       } else {
-               strp = gblock(sizeof(*strp));
-               funcbase = curbase;
-               strp->ssize = 0;
-               strp->memlist = NULL;
-       }
-       mosflg = 0;
-       if (o != LBRACE) {
-               if (ssym==0)
-                       goto syntax;
-               if (ssym->hclass!=tagkind)
-                       error("Bad structure/union/enum name");
-               peeksym = o;
-       } else {
-               ds = defsym;
-               mosflg = 0;
-               savebits = bitoffs;
-               savememlist = memlist;
-               savenmems = nmems;
-               memlist = mems;
-               nmems = 2;
-               bitoffs = 0;
-               if (kind==ENUM) {
-                       typer.htype = INT;
-                       typer.hstrp = strp;
-                       declare(ENUM, &typer, 0);
-               } else
-                       elsize = declist(kind==UNION?MOU:MOS);
-               bitoffs = savebits;
-               defsym = ds;
-               if (strp->ssize)
-                       error("%.8s redeclared", ssym->name);
-               strp->ssize = elsize;
-               *memlist++ = NULL;
-               strp->memlist = gblock((memlist-mems)*sizeof(*memlist));
-               funcbase = curbase;
-               for (o=0; &mems[o] != memlist; o++)
-                       strp->memlist[o] = mems[o];
-               memlist = savememlist;
-               nmems = savenmems;
-               if ((o = symbol()) != RBRACE)
-                       goto syntax;
-       }
-       return(strp);
-   syntax:
-       decsyn(o);
-       return(0);
-}
-
-/*
- * Process a comma-separated list of declarators
- */
-declare(askw, tptr, offset)
-struct hshtab *tptr;
-{
-       register int o;
-       register int skw, isunion;
-
-       skw = askw;
-       isunion = 0;
-       if (skw==MOU) {
-               skw = MOS;
-               isunion++;
-               mosflg = 1;
-               if ((peeksym=symbol()) == SEMI) {
-                       o = length(tptr);
-                       if (o>offset)
-                               offset = o;
-               }
-       }
-       do {
-               if (skw==ENUM && (peeksym=symbol())==RBRACE) {
-                       o = peeksym;
-                       peeksym = -1;
-                       break;
-               }
-               o = decl1(skw, tptr, isunion?0:offset, NULL);
-               if (isunion) {
-                       o =+ align(CHAR, o, 0);
-                       if (o>offset)
-                               offset = o;
-               } else
-                       offset =+ o;
-       } while ((o=symbol()) == COMMA);
-       if (o==RBRACE) {
-               peeksym = o;
-               o = SEMI;
-       }
-       if (o!=SEMI && (o!=RPARN || skw!=ARG1))
-               decsyn(o);
-       return(offset);
-}
-
-/*
- * Process a single declarator
- */
-decl1(askw, atptr, offset, absname)
-struct hshtab *atptr, *absname;
-{
-       int t1, chkoff, a, elsize;
-       register int skw;
-       int type;
-       register struct hshtab *dsym;
-       register struct hshtab *tptr;
-       struct tdim dim;
-       struct field *fldp;
-       int *dp;
-       int isinit;
-
-       skw = askw;
-       tptr = atptr;
-       chkoff = 0;
-       mosflg = skw==MOS;
-       dim.rank = 0;
-       if (((peeksym=symbol())==SEMI || peeksym==RPARN) && absname==NULL)
-               return(0);
-       /*
-        * Filler field
-        */
-       if (peeksym==COLON && skw==MOS) {
-               peeksym = -1;
-               t1 = conexp();
-               elsize = align(tptr->htype, offset, t1);
-               bitoffs =+ t1;
-               return(elsize);
-       }
-       t1 = getype(&dim, absname);
-       if (t1 == -1)
-               return(0);
-       if (tptr->hsubsp) {
-               type = tptr->htype;
-               for (a=0; type&XTYPE;) {
-                       if ((type&XTYPE)==ARRAY)
-                               dim.dimens[dim.rank++] = tptr->hsubsp[a++];
-                       type =>> TYLEN;
-               }
-       }
-       type = tptr->htype & ~TYPE;
-       while (t1&XTYPE) {
-               if (type&BIGTYPE) {
-                       typov();
-                       type = t1 = 0;
-               }
-               type = type<<TYLEN | (t1 & XTYPE);
-               t1 =>> TYLEN;
-       }
-       type =| tptr->htype&TYPE;
-       if (absname)
-               defsym = absname;
-       dsym = defsym;
-       if (dsym->hblklev < blklev)
-               pushdecl(dsym);
-       if (dim.rank == 0)
-               dsym->subsp = NULL;
-       else {
-               dp = gblock(dim.rank*sizeof(dim.rank));
-               funcbase = curbase;
-               if (skw==EXTERN)
-                       maxdecl = curbase;
-               for (a=0; a<dim.rank; a++) {
-                       if ((t1 = dp[a] = dim.dimens[a])
-                        && (dsym->htype&XTYPE) == ARRAY
-                        && dsym->subsp[a] && t1!=dsym->subsp[a])
-                               redec();
-               }
-               dsym->subsp = dp;
-       }
-       if ((type&XTYPE) == FUNC) {
-               if (skw==AUTO)
-                       skw = EXTERN;
-               if ((skw!=EXTERN && skw!=TYPEDEF) && absname==NULL)
-                       error("Bad func. storage class");
-       }
-       if (!(dsym->hclass==0
-          || ((skw==ARG||skw==AREG) && dsym->hclass==ARG1)
-          || (skw==EXTERN && dsym->hclass==EXTERN && dsym->htype==type)))
-               if (skw==MOS && dsym->hclass==MOS && dsym->htype==type)
-                       chkoff = 1;
-               else {
-                       redec();
-                       goto syntax;
-               }
-       if (dsym->hclass && (dsym->htype&TYPE)==STRUCT && (type&TYPE)==STRUCT)
-               if (dsym->hstrp != tptr->hstrp) {
-                       error("Warning: structure redeclaration");
-                       nerror--;
-               }
-       dsym->htype = type;
-       if (tptr->hstrp)
-               dsym->hstrp = tptr->hstrp;
-       if (skw==TYPEDEF) {
-               dsym->hclass = TYPEDEF;
-               return(0);
-       }
-       if (absname)
-               return(0);
-       if (skw==ARG1) {
-               if (paraml==0)
-                       paraml = dsym;
-               else
-                       parame->hoffset = dsym;
-               parame = dsym;
-               dsym->hclass = skw;
-               return(0);
-       }
-       elsize = 0;
-       if (skw==MOS) {
-               elsize = length(dsym);
-               if ((peeksym = symbol())==COLON) {
-                       elsize = 0;
-                       peeksym = -1;
-                       t1 = conexp();
-                       a = align(type, offset, t1);
-                       if (dsym->hflag&FFIELD) {
-                               if (dsym->hstrp->bitoffs!=bitoffs
-                                || dsym->hstrp->flen!=t1)
-                                       redec();
-                       } else {
-                               dsym->hstrp = gblock(sizeof(*fldp));
-                               funcbase = curbase;
-                       }
-                       dsym->hflag =| FFIELD;
-                       dsym->hstrp->bitoffs = bitoffs;
-                       dsym->hstrp->flen = t1;
-                       bitoffs =+ t1;
-               } else
-                       a = align(type, offset, 0);
-               elsize =+ a;
-               offset =+ a;
-               if (++nmems >= NMEMS) {
-                       error("Too many structure members");
-                       nmems =- NMEMS/2;
-                       memlist =- NMEMS/2;
-               }
-               if (a)
-                       *memlist++ = &structhole;
-               if (chkoff && dsym->hoffset != offset)
-                       redec();
-               dsym->hoffset = offset;
-               *memlist++ = dsym;
-       }
-       if (skw==REG)
-               if ((dsym->hoffset = goodreg(dsym)) < 0)
-                       skw = AUTO;
-       dsym->hclass = skw;
-       isinit = 0;
-       if ((a=symbol())!=COMMA && a!=SEMI && a!=RBRACE)
-               isinit++;
-       if (a!=ASSIGN)
-               peeksym = a;
-       if (skw==AUTO) {
-       /*      if (STAUTO < 0) {       */
-                       autolen =- rlength(dsym);
-                       dsym->hoffset = autolen;
-                       if (autolen < maxauto)
-                               maxauto = autolen;
-       /*      } else {                        */
-       /*              dsym->hoffset = autolen;        */
-       /*              autolen =+ rlength(dsym);       */
-       /*              if (autolen > maxauto)          */
-       /*                      maxauto = autolen;      */
-       /*      }                       */
-               if (isinit)
-                       cinit(dsym, 0, AUTO);
-       } else if (skw==STATIC) {
-               dsym->hoffset = isn;
-               if (isinit) {
-                       outcode("BBN", DATA, LABEL, isn++);
-                       if (cinit(dsym, 1, STATIC) & ALIGN)
-                               outcode("B", EVEN);
-               } else
-                       outcode("BBNBN", BSS, LABEL, isn++, SSPACE, rlength(dsym));
-               outcode("B", PROG);
-       } else if (skw==REG && isinit)
-               cinit(dsym, 0, REG);
-       else if (skw==ENUM) {
-               if (type!=INT)
-                       error("Illegal enumeration %.8s", dsym->name);
-               dsym->hclass = ENUMCON;
-               dsym->hoffset = offset;
-               if (isinit)
-                       cinit(dsym, 0, ENUMCON);
-               elsize = dsym->hoffset-offset+1;
-       }
-       prste(dsym);
-syntax:
-       return(elsize);
-}
-
-/*
- * Push down an outer-block declaration
- * after redeclaration in an inner block.
- */
-pushdecl(asp)
-struct phshtab *asp;
-{
-       register struct phshtab *sp, *nsp;
-
-       sp = asp;
-       nsp = gblock(sizeof(*nsp));
-       maxdecl = funcbase = curbase;
-       cpysymb(nsp, sp);
-       sp->hclass = 0;
-       sp->hflag =& (FKEYW|FMOS);
-       sp->htype = 0;
-       sp->hoffset = 0;
-       sp->hblklev = blklev;
-       sp->hpdown = nsp;
-}
-
-/*
- * Copy the non-name part of a symbol
- */
-cpysymb(s1, s2)
-struct phshtab *s1, *s2;
-{
-       register struct phshtab *rs1, *rs2;
-
-       rs1 = s1;
-       rs2 = s2;
-       rs1->hclass = rs2->hclass;
-       rs1->hflag = rs2->hflag;
-       rs1->htype = rs2->htype;
-       rs1->hoffset = rs2->hoffset;
-       rs1->hsubsp = rs2->hsubsp;
-       rs1->hstrp = rs2->hstrp;
-       rs1->hblklev = rs2->hblklev;
-       rs1->hpdown = rs2->hpdown;
-}
-
-
-/*
- * Read a declarator and get the implied type
- */
-getype(adimp, absname)
-struct tdim *adimp;
-struct hshtab *absname;
-{
-       static struct hshtab argtype;
-       int type;
-       register int o;
-       register struct hshtab *ds;
-       register struct tdim *dimp;
-
-       ds = defsym;
-       dimp = adimp;
-       type = 0;
-       switch(o=symbol()) {
-
-       case TIMES:
-               type = getype(dimp, absname);
-               if (type==-1)
-                       return(type);
-               if (type&BIGTYPE) {
-                       typov();
-                       type = 0;
-               }
-               return(type<<TYLEN | PTR);
-
-       case LPARN:
-               if (absname==NULL || nextchar()!=')') {
-                       type = getype(dimp, absname);
-                       if (type==-1)
-                               return(type);
-                       ds = defsym;
-                       if ((o=symbol()) != RPARN)
-                               goto syntax;
-                       goto getf;
-               }
-
-       default:
-               peeksym = o;
-               if (absname) {
-                       defsym = ds = absname;
-                       absname = NULL;
-                       goto getf;
-               }
-               break;
-
-       case NAME:
-               defsym = ds = csym;
-       getf:
-               switch(o=symbol()) {
-
-               case LPARN:
-                       if (blklev==0) {
-                               blklev++;
-                               ds = defsym;
-                               declare(ARG1, &argtype, 0);
-                               defsym = ds;
-                               blklev--;
-                       } else
-                               if ((o=symbol()) != RPARN)
-                                       goto syntax;
-                       if (type&BIGTYPE) {
-                               typov();
-                               type = 0;
-                       }
-                       type = type<<TYLEN | FUNC;
-                       goto getf;
-
-               case LBRACK:
-                       if (dimp->rank>=5) {
-                               error("Rank too large");
-                               dimp->rank = 4;
-                       }
-                       if ((o=symbol()) != RBRACK) {
-                               peeksym = o;
-                               cval = conexp();
-                               defsym = ds;
-                               if ((o=symbol())!=RBRACK)
-                                       goto syntax;
-                       } else {
-                               if (dimp->rank!=0)
-                                       error("Null dimension");
-                               cval = 0;
-                       }
-                       dimp->dimens[dimp->rank++] = cval;
-                       if (type&BIGTYPE) {
-                               typov();
-                               type = 0;
-                       }
-                       type = type<<TYLEN | ARRAY;
-                       goto getf;
-               }
-               peeksym = o;
-               return(type);
-       }
-syntax:
-       decsyn(o);
-       return(-1);
-}
-
-/*
- * More bits required for type than allowed.
- */
-typov()
-{
-       error("Type is too complicated");
-}
-
-/*
- * Enforce alignment restrictions in structures,
- * including bit-field considerations.
- */
-align(type, offset, aflen)
-{
-       register a, t, flen;
-       char *ftl;
-
-       flen = aflen;
-       a = offset;
-       t = type;
-       ftl = "Field too long";
-       if (flen==0) {
-               a =+ (NBPC+bitoffs-1) / NBPC;
-               bitoffs = 0;
-       }
-       while ((t&XTYPE)==ARRAY)
-               t = decref(t);
-       if (t!=CHAR) {
-               a = (a+ALIGN) & ~ALIGN;
-               if (a>offset)
-                       bitoffs = 0;
-       }
-       if (flen) {
-               if (type==INT || type==UNSIGN) {
-                       if (flen > NBPW)
-                               error(ftl);
-                       if (flen+bitoffs > NBPW) {
-                               bitoffs = 0;
-                               a =+ NCPW;
-                       }
-               } else if (type==CHAR) {
-                       if (flen > NBPC)
-                               error(ftl);
-                       if (flen+bitoffs > NBPC) {
-                               bitoffs = 0;
-                               a =+ 1;
-                       }
-               } else
-                       error("Bad type for field");
-       }
-       return(a-offset);
-}
-
-/*
- * Complain about syntax error in declaration
- */
-decsyn(o)
-{
-       error("Declaration syntax");
-       errflush(o);
-}
-
-/*
- * Complain about a redeclaration
- */
-redec()
-{
-       error("%.8s redeclared", defsym->name);
-}
-
-/*
- * Determine if a variable is suitable for storage in
- * a register; if so return the register number
- */
-goodreg(hp)
-struct hshtab *hp;
-{
-       int type;
-
-       type = hp->htype;
-       /*
-        * Special dispensation for unions
-        */
-       if (type==STRUCT && length(hp)<=SZINT)
-               type = INT;
-       if ((type!=INT && type!=CHAR && type!=UNSIGN && (type&XTYPE)==0)
-        || (type&XTYPE)>PTR || regvar<3)
-               return(-1);
-       return(--regvar);
-}
diff --git a/usr/src/cmd/c/c04.c b/usr/src/cmd/c/c04.c
deleted file mode 100644 (file)
index 9667ffa..0000000
+++ /dev/null
@@ -1,428 +0,0 @@
-#
-/*
- * C compiler
- *
- *
- */
-
-#include "c0.h"
-
-/*
- * Reduce the degree-of-reference by one.
- * e.g. turn "ptr-to-int" into "int".
- */
-decref(at)
-{
-       register t;
-
-       t = at;
-       if ((t & ~TYPE) == 0) {
-               error("Illegal indirection");
-               return(t);
-       }
-       return((t>>TYLEN) & ~TYPE | t&TYPE);
-}
-
-/*
- * Increase the degree of reference by
- * one; e.g. turn "int" to "ptr-to-int".
- */
-incref(t)
-{
-       return(((t&~TYPE)<<TYLEN) | (t&TYPE) | PTR);
-}
-
-/*
- * Make a tree that causes a branch to lbl
- * if the tree's value is non-zero together with the cond.
- */
-cbranch(t, lbl, cond)
-struct tnode *t;
-{
-       treeout(t, 0);
-       outcode("BNNN", CBRANCH, lbl, cond, line);
-}
-
-/*
- * Write out a tree.
- */
-rcexpr(atp)
-struct tnode *atp;
-{
-       register struct tnode *tp;
-
-       /*
-        * Special optimization
-        */
-       if ((tp=atp)->op==INIT && tp->tr1->op==CON) {
-               if (tp->type==CHAR) {
-                       outcode("B1N0", BDATA, tp->tr1->value);
-                       return;
-               } else if (tp->type==INT || tp->type==UNSIGN) {
-                       outcode("BN", SINIT, tp->tr1->value);
-                       return;
-               }
-       }
-       treeout(tp, 0);
-       outcode("BN", EXPR, line);
-}
-
-treeout(atp, isstruct)
-struct tnode *atp;
-{
-       register struct tnode *tp;
-       register struct hshtab *hp;
-       register nextisstruct;
-
-       if ((tp = atp) == 0) {
-               outcode("B", NULLOP);
-               return;
-       }
-       nextisstruct = tp->type==STRUCT;
-       switch(tp->op) {
-
-       case NAME:
-               hp = tp->tr1;
-               if (hp->hclass==TYPEDEF)
-                       error("Illegal use of type name");
-               outcode("BNN", NAME, hp->hclass==0?STATIC:hp->hclass, tp->type);
-               if (hp->hclass==EXTERN)
-                       outcode("S", hp->name);
-               else
-                       outcode("N", hp->hoffset);
-               break;
-
-       case LCON:
-               outcode("BNNN", tp->op, tp->type, tp->lvalue);
-               break;
-
-       case CON:
-               outcode("BNN", tp->op, tp->type, tp->value);
-               break;
-
-       case FCON:
-               outcode("BNF", tp->op, tp->type, tp->cstr);
-               break;
-
-       case STRING:
-               outcode("BNNN", NAME, STATIC, tp->type, tp->tr1);
-               break;
-
-       case FSEL:
-               treeout(tp->tr1, nextisstruct);
-               outcode("BNNN",tp->op,tp->type,tp->tr2->bitoffs,tp->tr2->flen);
-               break;
-
-       case ETYPE:
-               error("Illegal use of type");
-               break;
-
-       case AMPER:
-               treeout(tp->tr1, 1);
-               outcode("BN", tp->op, tp->type);
-               break;
-
-
-       case CALL:
-               treeout(tp->tr1, 1);
-               treeout(tp->tr2, 0);
-               outcode("BN", CALL, tp->type);
-               break;
-
-       default:
-               treeout(tp->tr1, nextisstruct);
-               if (opdope[tp->op]&BINARY)
-                       treeout(tp->tr2, nextisstruct);
-               outcode("BN", tp->op, tp->type);
-               break;
-       }
-       if (nextisstruct && isstruct==0)
-               outcode("BNN", STRASG, STRUCT, tp->strp->ssize);
-}
-
-/*
- * Generate a branch
- */
-branch(lab)
-{
-       outcode("BN", BRANCH, lab);
-}
-
-/*
- * Generate a label
- */
-label(l)
-{
-       outcode("BN", LABEL, l);
-}
-
-/*
- * ap is a tree node whose type
- * is some kind of pointer; return the size of the object
- * to which the pointer points.
- */
-plength(ap)
-struct tname *ap;
-{
-       register t, l;
-       register struct tnode *p;
-
-       p = ap;
-       if (p==0 || ((t=p->type)&~TYPE) == 0)           /* not a reference */
-               return(1);
-       p->type = decref(t);
-       l = length(p);
-       p->type = t;
-       return(l);
-}
-
-/*
- * return the number of bytes in the object
- * whose tree node is acs.
- */
-length(acs)
-struct tnode *acs;
-{
-       register t, elsz;
-       long n;
-       register struct tnode *cs;
-       int nd;
-
-       cs = acs;
-       t = cs->type;
-       n = 1;
-       nd = 0;
-       while ((t&XTYPE) == ARRAY) {
-               t = decref(t);
-               n =* cs->subsp[nd++];
-       }
-       if ((t&~TYPE)==FUNC)
-               return(0);
-       if (t>=PTR)
-               elsz = SZPTR;
-       else switch(t&TYPE) {
-
-       case INT:
-       case UNSIGN:
-               elsz = SZINT;
-               break;
-
-       case CHAR:
-               elsz = 1;
-               break;
-
-       case FLOAT:
-               elsz = SZFLOAT;
-               break;
-
-       case LONG:
-               elsz = SZLONG;
-               break;
-
-       case DOUBLE:
-               elsz = SZDOUB;
-               break;
-
-       case STRUCT:
-               if ((elsz = cs->strp->ssize) == 0)
-                       error("Undefined structure");
-               break;
-       default:
-               error("Compiler error (length)");
-               return(0);
-       }
-       n *= elsz;
-       if (n >= (unsigned)50000) {
-               error("Warning: very large data structure");
-               nerror--;
-       }
-       return(n);
-}
-
-/*
- * The number of bytes in an object, rounded up to a word.
- */
-rlength(cs)
-struct tnode *cs;
-{
-       return((length(cs)+ALIGN) & ~ALIGN);
-}
-
-/*
- * After an "if (...) goto", look to see if the transfer
- * is to a simple label.
- */
-simplegoto()
-{
-       register struct hshtab *csp;
-
-       if ((peeksym=symbol())==NAME && nextchar()==';') {
-               csp = csym;
-               if (csp->hblklev == 0)
-                       pushdecl(csp);
-               if (csp->hclass==0 && csp->htype==0) {
-                       csp->htype = ARRAY;
-                       csp->hflag =| FLABL;
-                       if (csp->hoffset==0)
-                               csp->hoffset = isn++;
-               }
-               if ((csp->hclass==0||csp->hclass==STATIC)
-                &&  csp->htype==ARRAY) {
-                       peeksym = -1;
-                       return(csp->hoffset);
-               }
-       }
-       return(0);
-}
-
-/*
- * Return the next non-white-space character
- */
-nextchar()
-{
-       while (spnextchar()==' ')
-               peekc = 0;
-       return(peekc);
-}
-
-/*
- * Return the next character, translating all white space
- * to blank and handling line-ends.
- */
-spnextchar()
-{
-       register c;
-
-       if ((c = peekc)==0)
-               c = getchar();
-       if (c=='\t' || c=='\014')       /* FF */
-               c = ' ';
-       else if (c=='\n') {
-               c = ' ';
-               if (inhdr==0)
-                       line++;
-               inhdr = 0;
-       } else if (c=='\001') { /* SOH, insert marker */
-               inhdr++;
-               c = ' ';
-       }
-       peekc = c;
-       return(c);
-}
-
-/*
- * is a break or continue legal?
- */
-chconbrk(l)
-{
-       if (l==0)
-               error("Break/continue error");
-}
-
-/*
- * The goto statement.
- */
-dogoto()
-{
-       register struct tnode *np;
-
-       *cp++ = tree();
-       build(STAR);
-       chkw(np = *--cp, -1);
-       rcexpr(block(JUMP,0,NULL,NULL,np));
-}
-
-/*
- * The return statement, which has to convert
- * the returned object to the function's type.
- */
-doret()
-{
-       register struct tnode *t;
-
-       if (nextchar() != ';') {
-               t = tree();
-               *cp++ = &funcblk;
-               *cp++ = t;
-               build(ASSIGN);
-               cp[-1] = cp[-1]->tr2;
-               if (funcblk.type==CHAR)
-                       cp[-1] = block(ITOC, INT, NULL, NULL, cp[-1]);
-               build(RFORCE);
-               rcexpr(*--cp);
-       }
-       branch(retlab);
-}
-
-/*
- * Write a character on the error output.
- */
-/*
- * Coded output:
- *   B: beginning of line; an operator
- *   N: a number
- *   S: a symbol (external)
- *   1: number 1
- *   0: number 0
- */
-outcode(s, a)
-char *s;
-{
-       register *ap;
-       register FILE *bufp;
-       int n;
-       register char *np;
-
-       bufp = stdout;
-       if (strflg)
-               bufp = sbufp;
-       ap = &a;
-       for (;;) switch(*s++) {
-       case 'B':
-               putc(*ap++, bufp);
-               putc(0376, bufp);
-               continue;
-
-       case 'N':
-               putc(*ap, bufp);
-               putc(*ap++>>8, bufp);
-               continue;
-
-       case 'F':
-               n = 1000;
-               np = *ap++;
-               goto str;
-
-       case 'S':
-               n = NCPS;
-               np = *ap++;
-               if (*np)
-                       putc('_', bufp);
-       str:
-               while (n-- && *np) {
-                       putc(*np++&0177, bufp);
-               }
-               putc(0, bufp);
-               continue;
-
-       case '1':
-               putc(1, bufp);
-               putc(0, bufp);
-               continue;
-
-       case '0':
-               putc(0, bufp);
-               putc(0, bufp);
-               continue;
-
-       case '\0':
-               if (ferror(bufp)) {
-                       error("Write error on temp");
-                       exit(1);
-               }
-               return;
-
-       default:
-               error("Botch in outcode");
-       }
-}
diff --git a/usr/src/cmd/c/c05.c b/usr/src/cmd/c/c05.c
deleted file mode 100644 (file)
index 9e39061..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-#
-#include "c0.h"
-/*
- *  info on operators:
- *   01-- is binary operator
- *   02-- left (or only) operand must be lvalue
- *   04-- is relational operator
- *  010-- is assignment-type operator
- *  020-- non-float req. on left
- *  040-- non-float req. on right
- * 0100-- is commutative
- * 0200-- is right, not left-associative
- * 0400-- is leaf of tree
- * *0XX000-- XX is priority of operator
- */
-int opdope[] {
-       000000, /* EOFC */
-       000000, /* ; */
-       000000, /* { */
-       000000, /* } */
-       036000, /* [ */
-       002000, /* ] */
-       037000, /* ( */
-       002000, /* ) */
-       014201, /* : */
-       007001, /* , */
-       000001, /* field selection */
-       034201, /* CAST */
-       000000, /* ETYPE */
-       000001, /* integer->ptr */
-       000001, /* ptr->integer */
-       000001, /* long->ptr */
-       000000, /* 16 */
-       000000, /* 17 */
-       000000, /* 18 */
-       000000, /* 19 */
-       000400, /* name */
-       000400, /* short constant */
-       000400, /* string */
-       000400, /* float */
-       000400, /* double */
-       000400, /* long constant */
-       000400, /* long constant <= 16 bits */
-       000000, /* 27 */
-       000000, /* 28 */
-       000000, /* 29 */
-       034203, /* ++pre */
-       034203, /* --pre */
-       034203, /* ++post */
-       034203, /* --post */
-       034200, /* !un */
-       034202, /* &un */
-       034220, /* *un */
-       034200, /* -un */
-       034220, /* ~un */
-       036001, /* . (structure reference) */
-       030101, /* + */
-       030001, /* - */
-       032101, /* * */
-       032001, /* / */
-       032001, /* % */
-       026061, /* >> */
-       026061, /* << */
-       020161, /* & */
-       017161, /* | */
-       017161, /* ^ */
-       036001, /* -> */
-       000000, /* int -> double */
-       000000, /* double -> int */
-       016001, /* && */
-       015001, /* || */
-       030001, /* &~ */
-       000000, /* 56 */
-       000000, /* 57 */
-       000000, /* 58 */
-       000000, /* 59 */
-       022005, /* == */
-       022005, /* != */
-       024005, /* <= */
-       024005, /* < */
-       024005, /* >= */
-       024005, /* > */
-       024005, /* <p */
-       024005, /* <=p */
-       024005, /* >p */
-       024005, /* >=p */
-       012213, /* =+ */
-       012213, /* =- */
-       012213, /* =* */
-       012213, /* =/ */
-       012213, /* =% */
-       012253, /* =>> */
-       012253, /* =<< */
-       012253, /* =& */
-       012253, /* =| */
-       012253, /* =^ */
-       012213, /* = */
-       000000, /* 81 */
-       000000, /* 82 */
-       000000, /* 83 */
-       000000, /* 84 */
-       000000, /* 85 */
-       000000, /* 86 */
-       000000, /* 87 */
-       000000, /* 88 */
-       000000, /* 89 */
-       014201, /* ? */
-       034200, /* sizeof */
-       000000, /* 92 */
-       021101, /* min */
-       021101, /* minp */
-       021101, /* max */
-       021101, /* maxp */
-       007001, /* , */
-       000000, /* 98 */
-       000000, /* 99 */
-       036001, /* call */
-       036001, /* mcall */
-       000000, /* goto */
-       000000, /* jump cond */
-       000000, /* branch cond */
-       000000, /* 105 */
-       000000, /* 106 */
-       000000, /* 107 */
-       000000, /* 108 */
-       000000, /* char->int */
-       000000  /* force r0 */
-};
-
-/*
- * conversion table:
- * FTI: float (or double) to integer
- * ITF: integer to float
- * ITP: integer to pointer
- * ITL: integer to long
- * LTI: long to integer
- * LTF: long to float
- * FTL: float to long
- * PTI: pointer to integer
- * LTP: long to ptr (ptr[long])
- * XX: usually illegal
- * When FTI, LTI, FTL are added in they specify
- * that it is the left operand that should be converted.
- * For + this is done and the conversion is turned back into
- * ITF, ITL, LTF.
- * For = however the left operand can't be converted
- * and the specified conversion is applied to the rhs.
- */
-char cvtab[4][4] {
-/*             int     double          long            ptr */
-/* int */      0,      (FTI<<4)+ITF,   (LTI<<4)+ITL,   (ITP<<4)+ITP,   
-/* double */   ITF,    0,              LTF,            XX,
-/* long */     ITL,    (FTL<<4)+LTF,   0,              (LTP<<4)+LTP,
-/* ptr */      ITP,    XX,             LTP,            PTI,
-};
-
-/*
- * relate conversion numbers to operators
- */
-char   cvntab[] {
-       0, ITOF, ITOL, LTOF, ITOP, PTOI, FTOI, LTOI, FTOL, LTOP,
-};
-
-/*
- * character type table
- */
-char ctab[] {
-       EOFC,   INSERT, UNKN,   UNKN,   UNKN,   UNKN,   UNKN,   UNKN,
-       UNKN,   SPACE,  NEWLN,  SPACE,  SPACE,  UNKN,   UNKN,   UNKN,
-       UNKN,   UNKN,   UNKN,   UNKN,   UNKN,   UNKN,   UNKN,   UNKN,
-       UNKN,   UNKN,   UNKN,   UNKN,   UNKN,   UNKN,   UNKN,   UNKN,
-       SPACE,  EXCLA,  DQUOTE, SHARP,  UNKN,   MOD,    AND,    SQUOTE,
-       LPARN,  RPARN,  TIMES,  PLUS,   COMMA,  MINUS,  PERIOD, DIVIDE,
-       DIGIT,  DIGIT,  DIGIT,  DIGIT,  DIGIT,  DIGIT,  DIGIT,  DIGIT,
-       DIGIT,  DIGIT,  COLON,  SEMI,   LESS,   ASSIGN, GREAT,  QUEST,
-       UNKN,   LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
-       LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
-       LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
-       LETTER, LETTER, LETTER, LBRACK, BSLASH, RBRACK, EXOR,   LETTER,
-       UNKN,   LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
-       LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
-       LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER, LETTER,
-       LETTER, LETTER, LETTER, LBRACE, OR,     RBRACE, COMPL,  UNKN
-};
diff --git a/usr/src/cmd/c/c1.h b/usr/src/cmd/c/c1.h
deleted file mode 100644 (file)
index 2faa6f4..0000000
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * C code generator header
- */
-
-#include <stdio.h>
-
-#define        LTYPE   long    /* change to int for no long consts */
-#define        NCPS    8
-#define        NULL    0
-
-/*
- *  Tree node for unary and binary
- */
-struct tnode {
-       int     op;
-       int     type;
-       int     degree;
-       struct  tnode *tr1, *tr2;
-};
-
-/*
- * tree names for locals
- */
-struct tname {
-       int     op;
-       int     type;
-       char    class;
-       char    regno;
-       int     offset;
-       int     nloc;
-};
-
-/*
- * tree names for externals
- */
-struct xtname {
-       int     op;
-       int     type;
-       char    class;
-       char    regno;
-       int     offset;
-       char    name[NCPS];
-};
-
-struct tconst {
-       int     op;
-       int     type;
-       int     value;
-};
-
-/*
- * long constants
- */
-struct lconst {
-       int     op;
-       int     type;
-       LTYPE   lvalue;
-};
-
-struct ftconst {
-       int     op;
-       int     type;
-       int     value;
-       double  fvalue;
-};
-
-/*
- * Node used for field assignemnts
- */
-struct fasgn {
-       int     op;
-       int     type;
-       int     degree;
-       struct  tnode *tr1, *tr2;
-       int     mask;
-};
-
-struct optab {
-       char    tabdeg1;
-       char    tabtyp1;
-       char    tabdeg2;
-       char    tabtyp2;
-       char    *tabstring;
-};
-
-struct table {
-       int     tabop;
-       struct  optab *tabp;
-};
-
-struct instab {
-       int     iop;
-       char    *str1;
-       char    *str2;
-};
-
-struct swtab {
-       int     swlab;
-       int     swval;
-};
-
-char   maprel[];
-char   notrel[];
-int    nreg;
-int    isn;
-int    namsiz;
-int    line;
-int    nerror;
-struct table   cctab[];
-struct table   efftab[];
-struct table   regtab[];
-struct table   sptab[];
-struct table   lsptab[1];
-struct instab  instab[];
-struct instab  branchtab[];
-int    opdope[];
-char   *opntab[];
-int    nstack;
-int    nfloat;
-struct tname   sfuncr;
-char   *funcbase;
-char   *curbase;
-char   *coremax;
-struct tconst czero, cone;
-struct ftconst fczero;
-long   totspace;
-/*
- * Some special stuff for long comparisons
- */
-int    xlab1, xlab2, xop, xzero;
-
-/*
-       operators
-*/
-#define        EOFC    0
-#define        SEMI    1
-#define        LBRACE  2
-#define        RBRACE  3
-#define        LBRACK  4
-#define        RBRACK  5
-#define        LPARN   6
-#define        RPARN   7
-#define        COLON   8
-#define        COMMA   9
-#define        FSEL    10
-#define        FSELR   11
-#define        FSELT   12
-#define        FSELA   16
-#define        ULSH    17
-#define        ASULSH  18
-
-#define        KEYW    19
-#define        NAME    20
-#define        CON     21
-#define        STRING  22
-#define        FCON    23
-#define        SFCON   24
-#define        LCON    25
-#define        SLCON   26
-
-#define        AUTOI   27
-#define        AUTOD   28
-#define        INCBEF  30
-#define        DECBEF  31
-#define        INCAFT  32
-#define        DECAFT  33
-#define        EXCLA   34
-#define        AMPER   35
-#define        STAR    36
-#define        NEG     37
-#define        COMPL   38
-
-#define        DOT     39
-#define        PLUS    40
-#define        MINUS   41
-#define        TIMES   42
-#define        DIVIDE  43
-#define        MOD     44
-#define        RSHIFT  45
-#define        LSHIFT  46
-#define        AND     47
-#define        ANDN    55
-#define        OR      48
-#define        EXOR    49
-#define        ARROW   50
-#define        ITOF    51
-#define        FTOI    52
-#define        LOGAND  53
-#define        LOGOR   54
-#define        FTOL    56
-#define        LTOF    57
-#define        ITOL    58
-#define        LTOI    59
-#define        ITOP    13
-#define        PTOI    14
-#define        LTOP    15
-
-#define        EQUAL   60
-#define        NEQUAL  61
-#define        LESSEQ  62
-#define        LESS    63
-#define        GREATEQ 64
-#define        GREAT   65
-#define        LESSEQP 66
-#define        LESSP   67
-#define        GREATQP 68
-#define        GREATP  69
-
-#define        ASPLUS  70
-#define        ASMINUS 71
-#define        ASTIMES 72
-#define        ASDIV   73
-#define        ASMOD   74
-#define        ASRSH   75
-#define        ASLSH   76
-#define        ASAND   77
-#define        ASOR    78
-#define        ASXOR   79
-#define        ASSIGN  80
-#define        TAND    81
-#define        LTIMES  82
-#define        LDIV    83
-#define        LMOD    84
-#define        ASANDN  85
-#define        LASTIMES 86
-#define        LASDIV  87
-#define        LASMOD  88
-
-#define        QUEST   90
-#define        MAX     93
-#define        MAXP    94
-#define        MIN     95
-#define        MINP    96
-#define        LLSHIFT 91
-#define        ASLSHL  92
-#define        SEQNC   97
-#define        CALL1   98
-#define        CALL2   99
-#define        CALL    100
-#define        MCALL   101
-#define        JUMP    102
-#define        CBRANCH 103
-#define        INIT    104
-#define        SETREG  105
-#define        LOAD    106
-#define        ITOC    109
-#define        RFORCE  110
-
-/*
- * Intermediate code operators
- */
-#define        BRANCH  111
-#define        LABEL   112
-#define        NLABEL  113
-#define        RLABEL  114
-#define        STRASG  115
-#define        STRSET  116
-#define        BDATA   200
-#define        PROG    202
-#define        DATA    203
-#define        BSS     204
-#define        CSPACE  205
-#define        SSPACE  206
-#define        SYMDEF  207
-#define        SAVE    208
-#define        RETRN   209
-#define        EVEN    210
-#define        PROFIL  212
-#define        SWIT    213
-#define        EXPR    214
-#define        SNAME   215
-#define        RNAME   216
-#define        ANAME   217
-#define        NULLOP  218
-#define        SETSTK  219
-#define        SINIT   220
-#define        GLOBAL  221
-#define        C3BRANCH        222
-
-/*
- *     types
- */
-#define        INT     0
-#define        CHAR    1
-#define        FLOAT   2
-#define        DOUBLE  3
-#define        STRUCT  4
-#define        RSTRUCT 5
-#define        LONG    6
-#define        UNSIGN  7
-
-#define        TYLEN   2
-#define        TYPE    07
-#define        XTYPE   (03<<3)
-#define        PTR     010
-#define        FUNC    020
-#define        ARRAY   030
-
-/*
-       storage classes
-*/
-#define        KEYWC   1
-#define        MOS     10
-#define        AUTO    11
-#define        EXTERN  12
-#define        STATIC  13
-#define        REG     14
-#define        STRTAG  15
-#define        ARG     16
-#define        OFFS    20
-#define        XOFFS   21
-#define        SOFFS   22
-
-/*
-       Flag    bits
-*/
-
-#define        BINARY  01
-#define        LVALUE  02
-#define        RELAT   04
-#define        ASSGOP  010
-#define        LWORD   020
-#define        RWORD   040
-#define        COMMUTE 0100
-#define        RASSOC  0200
-#define        LEAF    0400
-#define        CNVRT   01000
diff --git a/usr/src/cmd/c/c10.c b/usr/src/cmd/c/c10.c
deleted file mode 100644 (file)
index 229391b..0000000
+++ /dev/null
@@ -1,1200 +0,0 @@
-#
-/*
-
-               C compiler, part 2
-
-
-*/
-
-#include "c1.h"
-
-#define        dbprint(op)     /* */
-#ifdef DEBUG
-#define        dbprint(op)     printf("        / %s", opntab[op])
-#endif
-
-char   maprel[] {      EQUAL, NEQUAL, GREATEQ, GREAT, LESSEQ,
-                       LESS, GREATQP, GREATP, LESSEQP, LESSP
-};
-
-char   notrel[] {      NEQUAL, EQUAL, GREAT, GREATEQ, LESS,
-                       LESSEQ, GREATP, GREATQP, LESSP, LESSEQP
-};
-
-struct tconst czero { CON, INT, 0};
-struct tconst cone  { CON, INT, 1};
-
-struct tname sfuncr { NAME, STRUCT, STATIC, 0, 0, 0 };
-
-struct table   *cregtab;
-
-int    nreg    3;
-int    isn     10000;
-
-main(argc, argv)
-char *argv[];
-{
-
-       if (argc<4) {
-               error("Arg count");
-               exit(1);
-       }
-       if (freopen(argv[1], "r", stdin)==NULL) {
-               error("Missing temp file");
-               exit(1);
-       }
-       if ((freopen(argv[3], "w", stdout)) == NULL) {
-               error("Can't create %s", argv[3]);
-               exit(1);
-       }
-       funcbase = curbase = coremax = sbrk(0);
-       getree();
-       /*
-        * If any floating-point instructions
-        * were used, generate a reference that
-        * pulls in the floating-point part of printf.
-        */
-       if (nfloat)
-               printf(".globl  fltused\n");
-       /*
-        * tack on the string file.
-        */
-       printf(".globl\n.data\n");
-       if (*argv[2] != '-') {
-               if (freopen(argv[2], "r", stdin)==NULL) {
-                       error("Missing temp file");
-                       exit(1);
-               }
-               getree();
-       }
-       if (totspace >= (unsigned)56000) {
-               error("Warning: possibly too much data");
-               nerror--;
-       }
-       exit(nerror!=0);
-}
-
-/*
- * Given a tree, a code table, and a
- * count of available registers, find the code table
- * for the appropriate operator such that the operands
- * are of the right type and the number of registers
- * required is not too large.
- * Return a ptr to the table entry or 0 if none found.
- */
-char *
-match(atree, table, nrleft, nocvt)
-struct tnode *atree;
-struct table *table;
-{
-#define        NOCVL   1
-#define        NOCVR   2
-       int op, d1, d2, dope;
-       struct tnode *p2;
-       register struct tnode *p1, *tree;
-       register struct optab *opt;
-
-       if ((tree=atree)==0)
-               return(0);
-       if (table==lsptab)
-               table = sptab;
-       if ((op = tree->op)==0)
-               return(0);
-       dope = opdope[op];
-       if ((dope&LEAF) == 0)
-               p1 = tree->tr1;
-       else
-               p1 = tree;
-       d1 = dcalc(p1, nrleft);
-       if ((dope&BINARY)!=0) {
-               p2 = tree->tr2;
-               /*
-                * If a subtree starts off with a conversion operator,
-                * try for a match with the conversion eliminated.
-                * E.g. int = double can be done without generating
-                * the converted int in a register by
-                * movf double,fr0; movfi fr0,int .
-                */
-               if (opdope[p2->op]&CNVRT && (nocvt&NOCVR)==0
-                        && (opdope[p2->tr1->op]&CNVRT)==0) {
-                       tree->tr2 = p2->tr1;
-                       if (opt = match(tree, table, nrleft, NOCVL))
-                               return(opt);
-                       tree->tr2 = p2;
-               } else if (opdope[p1->op]&CNVRT && (nocvt&NOCVL)==0
-                && (opdope[p1->tr1->op]&CNVRT)==0) {
-                       tree->tr1 = p1->tr1;
-                       if (opt = match(tree, table, nrleft, NOCVR))
-                               return(opt);
-                       tree->tr1 = p1;
-               }
-               d2 = dcalc(p2, nrleft);
-       }
-       for (; table->op!=op; table++)
-               if (table->op==0)
-                       return(0);
-       for (opt = table->tabp; opt->tabdeg1!=0; opt++) {
-               if (d1 > (opt->tabdeg1&077)
-                || (opt->tabdeg1 >= 0100 && (p1->op != STAR)))
-                       continue;
-               if (notcompat(p1, opt->tabtyp1, op)) {
-                       continue;
-               }
-               if ((opdope[op]&BINARY)!=0 && p2!=0) {
-                       if (d2 > (opt->tabdeg2&077)
-                        || (opt->tabdeg2 >= 0100) && (p2->op != STAR) )
-                               continue;
-                       if (notcompat(p2,opt->tabtyp2, 0))
-                               continue;
-               }
-               return(opt);
-       }
-       return(0);
-}
-
-/*
- * Given a tree, a code table, and a register,
- * produce code to evaluate the tree with the appropriate table.
- * Registers reg and upcan be used.
- * If there is a value, it is desired that it appear in reg.
- * The routine returns the register in which the value actually appears.
- * This routine must work or there is an error.
- * If the table called for is cctab, sptab, or efftab,
- * and tree can't be done using the called-for table,
- * another try is made.
- * If the tree can't be compiled using cctab, regtab is
- * used and a "tst" instruction is produced.
- * If the tree can't be compiled using sptab,
- * regtab is used and the register is pushed on the stack.
- * If the tree can't be compiled using efftab,
- * just use regtab.
- * Regtab must succeed or an "op not found" error results.
- *
- * A number of special cases are recognized, and
- * there is an interaction with the optimizer routines.
- */
-rcexpr(atree, atable, reg)
-struct tnode *atree;
-struct table *atable;
-{
-       register r;
-       int modf, nargs, recurf;
-       register struct tnode *tree;
-       register struct table *table;
-
-       table = atable;
-       recurf = 0;
-       if (reg<0) {
-               recurf++;
-               reg = ~reg;
-               if (reg>=020) {
-                       reg =- 020;
-                       recurf++;
-               }
-       }
-again:
-       if((tree=atree)==0)
-               return(0);
-       if (opdope[tree->op]&RELAT && tree->tr2->op==CON && tree->tr2->value==0
-        && table==cctab)
-               tree = atree = tree->tr1;
-       /*
-        * fieldselect(...) : in efftab mode,
-        * ignore the select, otherwise
-        * do the shift and mask.
-        */
-       if (tree->op == FSELT) {
-               if (table==efftab)
-                       atree = tree = tree->tr1;
-               else {
-                       tree->op = FSEL;
-                       atree = tree = optim(tree);
-               }
-       }
-       switch (tree->op)  {
-
-       /*
-        * Structure assignments
-        */
-       case STRASG:
-               strasg(tree);
-               return(0);
-
-       /*
-        * An initializing expression
-        */
-       case INIT:
-               tree = optim(tree);
-               doinit(tree->type, tree->tr1);
-               return(0);
-
-       /*
-        * Put the value of an expression in r0,
-        * for a switch or a return
-        */
-       case RFORCE:
-               tree = tree->tr1;
-               if((r=rcexpr(tree, regtab, reg)) != 0)
-                       movreg(r, 0, tree);
-               return(0);
-
-       /*
-        * sequential execution
-        */
-       case SEQNC:
-               r = nstack;
-               rcexpr(tree->tr1, efftab, reg);
-               nstack = r;
-               atree = tree = tree->tr2;
-               goto again;
-
-       /*
-        * In the generated &~ operator,
-        * fiddle things so a PDP-11 "bit"
-        * instruction will be produced when cctab is used.
-        */
-       case ANDN:
-               if (table==cctab) {
-                       tree->op = TAND;
-                       tree->tr2 = optim(tnode(COMPL, tree->type, tree->tr2));
-               }
-               break;
-
-       /*
-        * Handle a subroutine call. It has to be done
-        * here because if cexpr got called twice, the
-        * arguments might be compiled twice.
-        * There is also some fiddling so the
-        * first argument, in favorable circumstances,
-        * goes to (sp) instead of -(sp), reducing
-        * the amount of stack-popping.
-        */
-       case CALL:
-               r = 0;
-               nargs = 0;
-               modf = 0;
-               if (tree->tr1->op!=NAME || tree->tr1->class!=EXTERN) {
-                       nargs++;
-                       nstack++;
-               }
-               tree = tree->tr2;
-               if(tree->op) {
-                       while (tree->op==COMMA) {
-                               r =+ comarg(tree->tr2, &modf);
-                               tree = tree->tr1;
-                               nargs++;
-                       }
-                       r =+ comarg(tree, &modf);
-                       nargs++;
-               }
-               tree = atree;
-               tree->op = CALL2;
-               if (modf && tree->tr1->op==NAME && tree->tr1->class==EXTERN)
-                       tree->op = CALL1;
-               if (cexpr(tree, regtab, reg)<0)
-                       error("compiler botch: call");
-               popstk(r);
-               nstack =- nargs;
-               if (table==efftab || table==regtab)
-                       return(0);
-               r = 0;
-               goto fixup;
-
-       /*
-        * Longs need special treatment.
-        */
-       case ASLSH:
-       case LSHIFT:
-               if (tree->type==LONG) {
-                       if (tree->tr2->op==ITOL)
-                               tree->tr2 = tree->tr2->tr1;
-                       else
-                               tree->tr2 = optim(tnode(LTOI,INT,tree->tr2));
-                       if (tree->op==ASLSH)
-                               tree->op = ASLSHL;
-                       else
-                               tree->op = LLSHIFT;
-               }
-               break;
-
-       /*
-        * Try to change * to shift.
-        */
-       case TIMES:
-       case ASTIMES:
-               tree = pow2(tree);
-       }
-       /*
-        * Try to find postfix ++ and -- operators that can be
-        * pulled out and done after the rest of the expression
-        */
-       if (table!=cctab && table!=cregtab && recurf<2
-        && (opdope[tree->op]&LEAF)==0) {
-               if (r=delay(&atree, table, reg)) {
-                       tree = atree;
-                       table = efftab;
-                       reg = r-1;
-               }
-       }
-       /*
-        * Basically, try to reorder the computation
-        * so  reg = x+y  is done as  reg = x; reg =+ y
-        */
-       if (recurf==0 && reorder(&atree, table, reg)) {
-               if (table==cctab && atree->op==NAME)
-                       return(reg);
-       }
-       tree = atree;
-       if (table==efftab && tree->op==NAME)
-               return(reg);
-       if ((r=cexpr(tree, table, reg))>=0)
-               return(r);
-       if (table!=regtab && (table!=cctab||(opdope[tree->op]&RELAT)==0)) {
-               if((r=cexpr(tree, regtab, reg))>=0) {
-       fixup:
-                       modf = isfloat(tree);
-                       dbprint(tree->op);
-                       if (table==sptab || table==lsptab) {
-                               if (tree->type==LONG) {
-                                       printf("mov\tr%d,-(sp)\n",r+1);
-                                       nstack++;
-                               }
-                               printf("mov%c   r%d,%c(sp)\n", modf, r,
-                                       table==sptab? '-':0);
-                               nstack++;
-                       }
-                       if (table==cctab)
-                               printf("tst%c   r%d\n", modf, r);
-                       return(r);
-               }
-       }
-       /*
-        * There's a last chance for this operator
-        */
-       if (tree->op==LTOI) {
-               r = rcexpr(tree->tr1, regtab, reg);
-               if (r >= 0) {
-                       r++;
-                       goto fixup;
-               }
-       }
-       if (tree->type == STRUCT)
-               error("Illegal operation on structure");
-       else if (tree->op>0 && tree->op<RFORCE && opntab[tree->op])
-               error("No code table for op: %s", opntab[tree->op]);
-       else
-               error("No code table for op %d", tree->op);
-       return(reg);
-}
-
-/*
- * Try to compile the tree with the code table using
- * registers areg and up.  If successful,
- * return the register where the value actually ended up.
- * If unsuccessful, return -1.
- *
- * Most of the work is the macro-expansion of the
- * code table.
- */
-cexpr(atree, table, areg)
-struct tnode *atree;
-struct table *table;
-{
-       int c, r;
-       register struct tnode *p, *p1, *tree;
-       struct table *ctable;
-       struct tnode *p2;
-       char *string;
-       int reg, reg1, rreg, flag, opd;
-       char *opt;
-
-       tree = atree;
-       reg = areg;
-       p1 = tree->tr2;
-       c = tree->op;
-       opd = opdope[c];
-       /*
-        * When the value of a relational or a logical expression is
-        * desired, more work must be done.
-        */
-       if ((opd&RELAT||c==LOGAND||c==LOGOR||c==EXCLA) && table!=cctab) {
-               cbranch(tree, c=isn++, 1, reg);
-               rcexpr(&czero, table, reg);
-               branch(isn, 0);
-               label(c);
-               rcexpr(&cone, table, reg);
-               label(isn++);
-               return(reg);
-       }
-       if(c==QUEST) {
-               if (table==cctab)
-                       return(-1);
-               cbranch(tree->tr1, c=isn++, 0, reg);
-               flag = nstack;
-               rreg = rcexpr(p1->tr1, table, reg);
-               nstack = flag;
-               branch(r=isn++, 0);
-               label(c);
-               reg = rcexpr(p1->tr2, table, rreg);
-               if (rreg!=reg)
-                       movreg(reg, rreg, tree->tr2);
-               label(r);
-               return(rreg);
-       }
-       reg = oddreg(tree, reg);
-       reg1 = reg+1;
-       /*
-        * long values take 2 registers.
-        */
-       if ((tree->type==LONG||opd&RELAT&&tree->tr1->type==LONG) && tree->op!=ITOL)
-               reg1++;
-       /*
-        * Leaves of the expression tree
-        */
-       if ((r = chkleaf(tree, table, reg)) >= 0)
-               return(r);
-       /*
-        * x + (-1) is better done as x-1.
-        */
-
-       if ((tree->op==PLUS||tree->op==ASPLUS) &&
-           (p1=tree->tr2)->op == CON && p1->value == -1) {
-               p1->value = 1;
-               tree->op =+ (MINUS-PLUS);
-       }
-       /*
-        * Because of a peculiarity of the PDP11 table
-        * char = *intreg++ and *--intreg cannot go through.
-        */
-       if (tree->tr1->type==CHAR && tree->tr2->type!=CHAR
-        && (tree->tr2->op==AUTOI||tree->tr2->op==AUTOD))
-               tree->tr2 = tnode(LOAD, tree->tr2->type, tree->tr2);
-       if (table==cregtab)
-               table = regtab;
-       /*
-        * The following peculiar code depends on the fact that
-        * if you just want the codition codes set, efftab
-        * will generate the right code unless the operator is
-        * a shift or
-        * postfix ++ or --. Unravelled, if the table is
-        * cctab and the operator is not special, try first
-        * for efftab;  if the table isn't, if the operator is,
-        * or the first match fails, try to match
-        * with the table actually asked for.
-        */
-       /*
-        * Account for longs and oddregs; below is really
-        * r = nreg - reg - (reg-areg) - (reg1-reg-1);
-        */
-       r = nreg - reg + areg - reg1 + 1;
-       if (table!=cctab || c==INCAFT || c==DECAFT || tree->type==LONG
-        || c==ASRSH || c==ASLSH || c==ASULSH
-        || (opt = match(tree, efftab, r, 0)) == 0)
-               if ((opt=match(tree, table, r, 0))==0)
-                       return(-1);
-       string = opt->tabstring;
-       p1 = tree->tr1;
-       if (p1->op==FCON && p1->value>0) {
-               printf(".data\nL%d:%o;%o;%o;%o\n.text\n", p1->value, p1->fvalue);
-               p1->value = -p1->value;
-       }
-       p2 = 0;
-       if (opdope[tree->op]&BINARY) {
-               p2 = tree->tr2;
-               if (p2->op==FCON && p2->value>0) {
-                       printf(".data\nL%d:%o;%o;%o;%o\n.text\n", p2->value, p2->fvalue);
-                       p2->value = -p2->value;
-               }
-       }
-loop:
-       /*
-        * The 0200 bit asks for a tab.
-        */
-       if ((c = *string++) & 0200) {
-               c =& 0177;
-               putchar('\t');
-       }
-       switch (c) {
-
-       case '\n':
-               dbprint(tree->op);
-               break;
-
-       case '\0':
-               if (!isfloat(tree))
-                       if (tree->op==DIVIDE||tree->op==ASDIV||tree->op==PTOI)
-                               reg--;
-               return(reg);
-
-       /* A1 */
-       case 'A':
-               p = p1;
-               goto adr;
-
-       /* A2 */
-       case 'B':
-               p = p2;
-               goto adr;
-
-       adr:
-               c = 0;
-               while (*string=='\'') {
-                       c++;
-                       string++;
-               }
-               if (*string=='+') {
-                       c = 100;
-                       string++;
-               }
-               pname(p, c);
-               goto loop;
-
-       /* I */
-       case 'M':
-               if ((c = *string)=='\'')
-                       string++;
-               else
-                       c = 0;
-               prins(tree->op, c, instab);
-               goto loop;
-
-       /* B1 */
-       case 'C':
-               if ((opd&LEAF) != 0)
-                       p = tree;
-               else
-                       p = p1;
-               goto pbyte;
-
-       /* BF */
-       case 'P':
-               p = tree;
-               goto pb1;
-
-       /* B2 */
-       case 'D':
-               p = p2;
-       pbyte:
-               if (p->type==CHAR)
-                       putchar('b');
-       pb1:
-               if (isfloat(p))
-                       putchar('f');
-               goto loop;
-
-       /* BE */
-       case 'L':
-               if (p1->type==CHAR || p2->type==CHAR)
-                       putchar('b');
-               p = tree;
-               goto pb1;
-
-       /* F */
-       case 'G':
-               p = p1;
-               flag = 01;
-               goto subtre;
-
-       /* S */
-       case 'K':
-               p = p2;
-               flag = 02;
-               goto subtre;
-
-       /* H */
-       case 'H':
-               p = tree;
-               flag = 04;
-
-       subtre:
-               ctable = regtab;
-               if (flag&04)
-                       ctable = cregtab;
-               c = *string++ - 'A';
-               if (*string=='!') {
-                       string++;
-                       c =| 020;       /* force right register */
-               }
-               if ((c&02)!=0)
-                       ctable = sptab;
-               if ((c&04)!=0)
-                       ctable = cctab;
-               if ((flag&01) && ctable==regtab && (c&01)==0
-                 && (tree->op==DIVIDE||tree->op==MOD
-                  || tree->op==ASDIV||tree->op==ASMOD||tree->op==ITOL))
-                       ctable = cregtab;
-               if ((c&01)!=0) {
-                       p = p->tr1;
-                       if(collcon(p) && ctable!=sptab) {
-                               if (p->op==STAR)
-                                       p = p->tr1;
-                               p = p->tr1;
-                       }
-               }
-               if (table==lsptab && ctable==sptab)
-                       ctable = lsptab;
-               if (c&010)
-                       r = reg1;
-               else
-                       if (opdope[p->op]&LEAF || p->degree < 2)
-                               r = reg;
-                       else
-                               r = areg;
-               rreg = rcexpr(p, ctable, r);
-               if (ctable!=regtab && ctable!=cregtab)
-                       goto loop;
-               if (c&010) {
-                       if (c&020 && rreg!=reg1)
-                               movreg(rreg, reg1, p);
-                       else
-                               reg1 = rreg;
-               } else if (rreg!=reg)
-                       if ((c&020)==0 && oddreg(tree, 0)==0 && tree->type!=LONG
-                       && (flag&04
-                         || flag&01&&xdcalc(p2,nreg-rreg-1)<=(opt->tabdeg2&077)
-                         || flag&02&&xdcalc(p1,nreg-rreg-1)<=(opt->tabdeg1&077))) {
-                               reg = rreg;
-                               reg1 = rreg+1;
-                       } else
-                               movreg(rreg, reg, p);
-               goto loop;
-
-       /* R */
-       case 'I':
-               r = reg;
-               if (*string=='-') {
-                       string++;
-                       r--;
-               }
-               goto preg;
-
-       /* R1 */
-       case 'J':
-               r = reg1;
-       preg:
-               if (*string=='+') {
-                       string++;
-                       r++;
-               }
-               if (r>nreg || r>=4 && tree->type==DOUBLE)
-                       error("Register overflow: simplify expression");
-               printf("r%d", r);
-               goto loop;
-
-       case '-':               /* check -(sp) */
-               if (*string=='(') {
-                       nstack++;
-                       if (table!=lsptab)
-                               putchar('-');
-                       goto loop;
-               }
-               break;
-
-       case ')':               /* check (sp)+ */
-               putchar(')');
-               if (*string=='+')
-                       nstack--;
-               goto loop;
-
-       /* #1 */
-       case '#':
-               p = p1->tr1;
-               goto nmbr;
-
-       /* #2 */
-       case '"':
-               p = p2->tr1;
-
-       nmbr:
-               if(collcon(p)) {
-                       if (p->op==STAR) {
-                               printf("*");
-                               p = p->tr1;
-                       }
-                       if ((p = p->tr2)->op == CON) {
-                               if (p->value)
-                                       psoct(p->value);
-                       } else if (p->op==AMPER)
-                               pname(p->tr1, 0);
-               }
-               goto loop;
-
-       /*
-        * Certain adjustments for / % and PTOI
-        */
-       case 'T':
-               c = reg-1;
-               if (tree->op == PTOI) {
-                       printf("bic     r%d,r%d\nsbc    r%d\n", c,c,c);
-                       goto loop;
-               }
-               if (p1->type==UNSIGN || p1->type&XTYPE) {
-                       printf("clr     r%d\n", c);
-                       goto loop;
-               }
-               if (dcalc(p1, 5)>12 && !match(p1, cctab, 10, 0))
-                       printf("tst     r%d\n", reg);
-               printf("sxt     r%d\n", c);
-               goto loop;
-
-       case 'V':       /* adc sbc, clr, or sxt as required for longs */
-               switch(tree->op) {
-               case PLUS:
-               case ASPLUS:
-               case INCBEF:
-               case INCAFT:
-                       printf("adc");
-                       break;
-
-               case MINUS:
-               case ASMINUS:
-               case NEG:
-               case DECBEF:
-               case DECAFT:
-                       printf("sbc");
-                       break;
-
-               case ASSIGN:
-                       p = tree->tr2;
-                       goto lcasev;
-
-               case ASDIV:
-               case ASMOD:
-               case ASULSH:
-                       p = tree->tr1;
-               lcasev:
-                       if (p->type!=LONG) {
-                               if (p->type==UNSIGN || p->type&XTYPE)
-                                       printf("clr");
-                               else
-                                       printf("sxt");
-                               goto loop;
-                       }
-               default:
-                       while ((c = *string++)!='\n' && c!='\0');
-                       break;
-               }
-               goto loop;
-
-       /*
-        * Mask used in field assignments
-        */
-       case 'Z':
-               printf("$%o", tree->mask);
-               goto loop;
-
-       /*
-        * Relational on long values.
-        * Might bug out early. E.g.,
-        * (long<0) can be determined with only 1 test.
-        */
-       case 'X':
-               if (xlongrel(*string++ - '0'))
-                       return(reg);
-               goto loop;
-       }
-       putchar(c);
-       goto loop;
-}
-
-/*
- * This routine just calls sreorder (below)
- * on the subtrees and then on the tree itself.
- * It returns non-zero if anything changed.
- */
-reorder(treep, table, reg)
-struct tnode **treep;
-struct table *table;
-{
-       register r, o;
-       register struct tnode *p;
-
-       p = *treep;
-       o = p->op;
-       if (opdope[o]&LEAF || o==LOGOR || o==LOGAND)
-               return(0);
-       while(sreorder(&p->tr1, regtab, reg, 1))
-               ;
-       if (opdope[o]&BINARY) 
-               while(sreorder(&p->tr2, regtab, reg, 1))
-                       ;
-       r = 0;
-       if (table!=cctab)
-       while (sreorder(treep, table, reg, 0))
-               r++;
-       *treep = optim(*treep);
-       return(r);
-}
-
-/*
- * Basically this routine carries out two kinds of optimization.
- * First, it observes that "x + (reg = y)" where actually
- * the = is any assignment op is better done as "reg=y; x+reg".
- * In this case rcexpr is called to do the first part and the
- * tree is modified so the name of the register
- * replaces the assignment.
- * Moreover, expressions like "reg = x+y" are best done as
- * "reg = x; reg =+ y" (so long as "reg" and "y" are not the same!).
- */
-sreorder(treep, table, reg, recurf)
-struct tnode **treep;
-struct table *table;
-{
-       register struct tnode *p, *p1;
-
-       p = *treep;
-       if (opdope[p->op]&LEAF)
-               return(0);
-       if (p->op==PLUS && recurf)
-               if (reorder(&p->tr2, table, reg))
-                       *treep = p = optim(p);
-       p1 = p->tr1;
-       if (p->op==STAR || p->op==PLUS) {
-               if (recurf && reorder(&p->tr1, table, reg))
-                       *treep = p = optim(p);
-               p1 = p->tr1;
-       }
-       if (p1->op==NAME) switch(p->op) {
-               case ASLSH:
-               case ASRSH:
-               case ASSIGN:
-                       if (p1->class != REG||p1->type==CHAR||isfloat(p->tr2))
-                               return(0);
-                       if (p->op==ASSIGN) switch (p->tr2->op) {
-                       case TIMES:
-                               if (!ispow2(p->tr2))
-                                       break;
-                               p->tr2 = pow2(p->tr2);
-                       case PLUS:
-                       case MINUS:
-                       case AND:
-                       case ANDN:
-                       case OR:
-                       case EXOR:
-                       case LSHIFT:
-                       case RSHIFT:
-                               p1 = p->tr2->tr2;
-                               if (xdcalc(p1, 16) > 12
-                                || p1->op==NAME
-                                &&(p1->nloc==p->tr1->nloc
-                                 || p1->regno==p->tr1->nloc))
-                                       return(0);
-                               p1 = p->tr2;
-                               p->tr2 = p1->tr1;
-                               if (p1->tr1->op!=NAME
-                                || p1->tr1->class!=REG
-                                || p1->tr1->nloc!=p->tr1->nloc)
-                                       rcexpr(p, efftab, reg);
-                               p->tr2 = p1->tr2;
-                               p->op = p1->op + ASPLUS - PLUS;
-                               *treep = p;
-                               return(1);
-                       }
-                       goto OK;
-
-               case ASTIMES:
-                       if (!ispow2(p))
-                               return(0);
-               case ASPLUS:
-               case ASMINUS:
-               case ASAND:
-               case ASANDN:
-               case ASOR:
-               case ASXOR:
-               case INCBEF:
-               case DECBEF:
-               OK:
-                       if (table==cctab||table==cregtab)
-                               reg =+ 020;
-                       rcexpr(optim(p), efftab, ~reg);
-                       *treep = p1;
-                       return(1);
-       }
-       return(0);
-}
-
-/*
- * Delay handles postfix ++ and -- 
- * It observes that "x + y++" is better
- * treated as "x + y; y++".
- * If the operator is ++ or -- itself,
- * it calls rcexpr to load the operand, letting
- * the calling instance of rcexpr to do the
- * ++ using efftab.
- * Otherwise it uses sdelay to search for inc/dec
- * among the operands.
- */
-delay(treep, table, reg)
-struct tnode **treep;
-{
-       register struct tnode *p, *p1;
-       register r;
-
-       p = *treep;
-       if ((p->op==INCAFT||p->op==DECAFT)
-        && p->tr1->op==NAME) {
-               return(1+rcexpr(p->tr1, table, reg));
-       }
-       p1 = 0;
-       if (opdope[p->op]&BINARY) {
-               if (p->op==LOGAND || p->op==LOGOR)
-                       return(0);
-               }
-               p1 = sdelay(&p->tr2);
-       if (p1==0)
-               p1 = sdelay(&p->tr1);
-       if (p1) {
-               r = rcexpr(optim(p), table, reg);
-               *treep = p1;
-               return(r+1);
-       }
-       return(0);
-}
-
-sdelay(ap)
-struct tnode **ap;
-{
-       register struct tnode *p, *p1;
-
-       p = *ap;
-       if ((p->op==INCAFT||p->op==DECAFT) && p->tr1->op==NAME) {
-               *ap = ncopy(p->tr1);
-               return(p);
-       }
-       if (p->op==STAR || p->op==PLUS)
-               if (p1=sdelay(&p->tr1))
-                       return(p1);
-       if (p->op==PLUS)
-               return(sdelay(&p->tr2));
-       return(0);
-}
-
-/*
- * Copy a tree node for a register variable.
- * Used by sdelay because if *reg-- is turned
- * into *reg; reg-- the *reg will in turn
- * be changed to some offset class, accidentally
- * modifying the reg--.
- */
-ncopy(ap)
-struct tname *ap;
-{
-       register struct tname *p, *q;
-
-       p = ap;
-       if (p->class!=REG)
-               return(p);
-       q = getblk(sizeof(*p));
-       q->op = p->op;
-       q->type = p->type;
-       q->class = p->class;
-       q->offset = p->offset;
-       q->nloc = p->nloc;
-       return(q);
-}
-
-/*
- * If the tree can be immediately loaded into a register,
- * produce code to do so and return success.
- */
-chkleaf(atree, table, reg)
-struct tnode *atree;
-{
-       struct tnode lbuf;
-       register struct tnode *tree;
-
-       tree = atree;
-       if (tree->op!=STAR && dcalc(tree, nreg-reg) > 12)
-               return(-1);
-       lbuf.op = LOAD;
-       lbuf.type = tree->type;
-       lbuf.degree = tree->degree;
-       lbuf.tr1 = tree;
-       return(rcexpr(&lbuf, table, reg));
-}
-
-/*
- * Compile a function argument.
- * If the stack is currently empty, put it in (sp)
- * rather than -(sp); this will save a pop.
- * Return the number of bytes pushed,
- * for future popping.
- */
-comarg(atree, flagp)
-int *flagp;
-{
-       register struct tnode *tree;
-       register retval;
-       int i;
-       int size;
-
-       tree = atree;
-       if (tree->op==STRASG) {
-               size = tree->mask;
-               tree = tree->tr1;
-               tree = strfunc(tree);
-               if (size <= 2) {
-                       setype(tree, INT);
-                       goto normal;
-               }
-               if (size <= 4) {
-                       setype(tree, LONG);
-                       goto normal;
-               }
-               if (tree->op!=NAME && tree->op!=STAR) {
-                       error("Unimplemented structure assignment");
-                       return(0);
-               }
-               tree = tnode(AMPER, STRUCT+PTR, tree);
-               tree = tnode(PLUS, STRUCT+PTR, tree, tconst(size, INT));
-               tree = optim(tree);
-               retval = rcexpr(tree, regtab, 0);
-               size =>> 1;
-               if (size <= 5) {
-                       for (i=0; i<size; i++)
-                               printf("mov     -(r%d),-(sp)\n", retval);
-               } else {
-                       if (retval!=0)
-                               printf("mov     r%d,r0\n", retval);
-                       printf("mov     $%o,r1\n", size);
-                       printf("L%d:mov -(r0),-(sp)\ndec\tr1\njne\tL%d\n", isn, isn);
-                       isn++;
-               }
-               nstack++;
-               return(size*2);
-       }
-normal:
-       if (nstack || isfloat(tree) || tree->type==LONG) {
-               rcexpr(tree, sptab, 0);
-               retval = arlength(tree->type);
-       } else {
-               (*flagp)++;
-               rcexpr(tree, lsptab, 0);
-               retval = 0;
-       }
-       return(retval);
-}
-
-struct tnode *
-strfunc(atp)
-struct tnode *atp;
-{
-       register struct tnode *tp;
-
-       tp = atp;
-       if (tp->op != CALL)
-               return(tp);
-       setype(tp, STRUCT+PTR);
-       return(tnode(STAR, STRUCT, tp));
-}
-
-/*
- * Compile an initializing expression
- */
-doinit(atype, atree)
-struct tnode *atree;
-{
-       register struct tnode *tree;
-       register int type;
-       float sfval;
-       double fval;
-       long lval;
-
-       tree = atree;
-       type = atype;
-       if (type==CHAR) {
-               printf(".byte ");
-               if (tree->type&XTYPE)
-                       goto illinit;
-               type = INT;
-       }
-       if (type&XTYPE)
-               type = INT;
-       switch (type) {
-       case INT:
-       case UNSIGN:
-               if (tree->op==FTOI) {
-                       if (tree->tr1->op!=FCON && tree->tr1->op!=SFCON)
-                               goto illinit;
-                       tree = tree->tr1;
-                       tree->value = tree->fvalue;
-                       tree->op = CON;
-               } else if (tree->op==LTOI) {
-                       if (tree->tr1->op!=LCON)
-                               goto illinit;
-                       tree = tree->tr1;
-                       lval = tree->lvalue;
-                       tree->op = CON;
-                       tree->value = lval;
-               }
-               if (tree->op == CON)
-                       printf("%o\n", tree->value);
-               else if (tree->op==AMPER) {
-                       pname(tree->tr1, 0);
-                       putchar('\n');
-               } else
-                       goto illinit;
-               return;
-
-       case DOUBLE:
-       case FLOAT:
-               if (tree->op==ITOF) {
-                       if (tree->tr1->op==CON) {
-                               fval = tree->tr1->value;
-                       } else
-                               goto illinit;
-               } else if (tree->op==FCON || tree->op==SFCON)
-                       fval = tree->fvalue;
-               else if (tree->op==LTOF) {
-                       if (tree->tr1->op!=LCON)
-                               goto illinit;
-                       fval = tree->tr1->lvalue;
-               } else
-                       goto illinit;
-               if (type==FLOAT) {
-                       sfval = fval;
-                       printf("%o; %o\n", sfval);
-               } else
-                       printf("%o; %o; %o; %o\n", fval);
-               return;
-
-       case LONG:
-               if (tree->op==FTOL) {
-                       tree = tree->tr1;
-                       if (tree->op==SFCON)
-                               tree->op = FCON;
-                       if (tree->op!= FCON)
-                               goto illinit;
-                       lval = tree->fvalue;
-               } else if (tree->op==ITOL) {
-                       if (tree->tr1->op != CON)
-                               goto illinit;
-                       lval = tree->tr1->value;
-               } else if (tree->op==LCON)
-                       lval = tree->lvalue;
-               else
-                       goto illinit;
-               printf("%o; %o\n", lval);
-               return;
-       }
-illinit:
-       error("Illegal initialization");
-}
-
-movreg(r0, r1, tree)
-struct tnode *tree;
-{
-       register char *s;
-
-       if (r0==r1)
-               return;
-       if (tree->type==LONG) {
-               s = "mov        r%d,r%d\nmov    r%d,r%d\n";
-               if (r0 < r1)
-                       printf(s, r0+1,r1+1,r0,r1);
-               else
-                       printf(s, r0,r1,r0+1,r1+1);
-               return;
-       }
-       printf("mov%c   r%d,r%d\n", isfloat(tree), r0, r1);
-}
diff --git a/usr/src/cmd/c/c11.c b/usr/src/cmd/c/c11.c
deleted file mode 100644 (file)
index 332b66c..0000000
+++ /dev/null
@@ -1,1167 +0,0 @@
-#
-/*
- *  C compiler
- */
-
-#include "c1.h"
-
-max(a, b)
-{
-       if (a>b)
-               return(a);
-       return(b);
-}
-
-degree(at)
-struct tnode *at;
-{
-       register struct tnode *t, *t1;
-
-       if ((t=at)==0 || t->op==0)
-               return(0);
-       if (t->op == CON)
-               return(-3);
-       if (t->op == AMPER)
-               return(-2);
-       if (t->op==ITOL) {
-               if ((t1 = isconstant(t)) && (t1->value>=0 || t1->type==UNSIGN))
-                       return(-2);
-               if ((t1=t->tr1)->type==UNSIGN && opdope[t1->op]&LEAF)
-                       return(-1);
-       }
-       if ((opdope[t->op] & LEAF) != 0) {
-               if (t->type==CHAR || t->type==FLOAT)
-                       return(1);
-               return(0);
-       }
-       return(t->degree);
-}
-
-pname(ap, flag)
-struct tnode *ap;
-{
-       register i;
-       register struct tnode *p;
-       struct { int intx[2]; };
-
-       p = ap;
-loop:
-       switch(p->op) {
-
-       case LCON:
-               printf("$%o", flag>10? p->lvalue.intx[1]:p->lvalue.intx[0]);
-               return;
-
-       case SFCON:
-       case CON:
-               printf("$");
-               psoct(p->value);
-               return;
-
-       case FCON:
-               printf("L%d", (p->value>0? p->value: -p->value));
-               return;
-
-       case NAME:
-               i = p->offset;
-               if (flag>10)
-                       i =+ 2;
-               if (i) {
-                       psoct(i);
-                       if (p->class!=OFFS)
-                               putchar('+');
-                       if (p->class==REG)
-                               regerr();
-               }
-               switch(p->class) {
-
-               case SOFFS:
-               case XOFFS:
-                       pbase(p);
-
-               case OFFS:
-                       printf("(r%d)", p->regno);
-                       return;
-
-               case EXTERN:
-               case STATIC:
-                       pbase(p);
-                       return;
-
-               case REG:
-                       printf("r%d", p->nloc);
-                       return;
-
-               }
-               error("Compiler error: pname");
-               return;
-
-       case AMPER:
-               putchar('$');
-               p = p->tr1;
-               if (p->op==NAME && p->class==REG)
-                       regerr();
-               goto loop;
-
-       case AUTOI:
-               printf("(r%d)%c", p->nloc, flag==1?0:'+');
-               return;
-
-       case AUTOD:
-               printf("%c(r%d)", flag==2?0:'-', p->nloc);
-               return;
-
-       case STAR:
-               p = p->tr1;
-               putchar('*');
-               goto loop;
-
-       }
-       error("pname called illegally");
-}
-
-regerr()
-{
-       error("Illegal use of register");
-}
-
-pbase(ap)
-struct tnode *ap;
-{
-       register struct tnode *p;
-
-       p = ap;
-       if (p->class==SOFFS || p->class==STATIC)
-               printf("L%d", p->nloc);
-       else
-               printf("%.8s", &(p->nloc));
-}
-
-xdcalc(ap, nrleft)
-struct tnode *ap;
-{
-       register struct tnode *p;
-       register d;
-
-       p = ap;
-       d = dcalc(p, nrleft);
-       if (d<20 && p->type==CHAR) {
-               if (nrleft>=1)
-                       d = 20;
-               else
-                       d = 24;
-       }
-       return(d);
-}
-
-dcalc(ap, nrleft)
-struct tnode *ap;
-{
-       register struct tnode *p, *p1;
-
-       if ((p=ap)==0)
-               return(0);
-       switch (p->op) {
-
-       case NAME:
-               if (p->class==REG)
-                       return(9);
-
-       case AMPER:
-       case FCON:
-       case LCON:
-       case AUTOI:
-       case AUTOD:
-               return(12);
-
-       case CON:
-       case SFCON:
-               if (p->value==0)
-                       return(4);
-               if (p->value==1)
-                       return(5);
-               if (p->value > 0)
-                       return(8);
-               return(12);
-
-       case STAR:
-               p1 = p->tr1;
-               if (p1->op==NAME||p1->op==CON||p1->op==AUTOI||p1->op==AUTOD)
-                       if (p->type!=LONG)
-                               return(12);
-       }
-       if (p->type==LONG)
-               nrleft--;
-       return(p->degree <= nrleft? 20: 24);
-}
-
-notcompat(ap, ast, op)
-struct tnode *ap;
-{
-       register at, st;
-       register struct tnode *p;
-
-       p = ap;
-       at = p->type;
-       st = ast;
-       if (st==0)              /* word, byte */
-               return(at!=CHAR && at!=INT && at!=UNSIGN && at<PTR);
-       if (st==1)              /* word */
-               return(at!=INT && at!=UNSIGN && at<PTR);
-       if (st==9 && (at&XTYPE))
-               return(0);
-       st =- 2;
-       if ((at&(~(TYPE+XTYPE))) != 0)
-               at = 020;
-       if ((at&(~TYPE)) != 0)
-               at = at&TYPE | 020;
-       if (st==FLOAT && at==DOUBLE)
-               at = FLOAT;
-       if (p->op==NAME && p->class==REG && op==ASSIGN && st==CHAR)
-               return(0);
-       return(st != at);
-}
-
-prins(op, c, itable)
-struct instab *itable;
-{
-       register struct instab *insp;
-       register char *ip;
-
-       for (insp=itable; insp->op != 0; insp++) {
-               if (insp->op == op) {
-                       ip = c? insp->str2: insp->str1;
-                       if (ip==0)
-                               break;
-                       printf("%s", ip);
-                       return;
-               }
-       }
-       error("No match' for op %d", op);
-}
-
-collcon(ap)
-struct tnode *ap;
-{
-       register op;
-       register struct tnode *p;
-
-       p = ap;
-       if (p->op==STAR) {
-               if (p->type==LONG+PTR) /* avoid *x(r); *x+2(r) */
-                       return(0);
-               p = p->tr1;
-       }
-       if (p->op==PLUS) {
-               op = p->tr2->op;
-               if (op==CON || op==AMPER)
-                       return(1);
-       }
-       return(0);
-}
-
-isfloat(at)
-struct tnode *at;
-{
-       register struct tnode *t;
-
-       t = at;
-       if ((opdope[t->op]&RELAT)!=0)
-               t = t->tr1;
-       if (t->type==FLOAT || t->type==DOUBLE) {
-               nfloat = 1;
-               return('f');
-       }
-       return(0);
-}
-
-oddreg(t, areg)
-struct tnode *t;
-{
-       register reg;
-
-       reg = areg;
-       if (!isfloat(t)) {
-               if (opdope[t->op]&RELAT) {
-                       if (t->tr1->type==LONG)
-                               return((reg+1) & ~01);
-                       return(reg);
-               }
-               switch(t->op) {
-               case LLSHIFT:
-               case ASLSHL:
-                       return((reg+1)&~01);
-
-               case DIVIDE:
-               case MOD:
-               case ASDIV:
-               case ASMOD:
-               case PTOI:
-               case ULSH:
-               case ASULSH:
-                       reg++;
-
-               case TIMES:
-               case ASTIMES:
-                       return(reg|1);
-               }
-       }
-       return(reg);
-}
-
-arlength(t)
-{
-       if (t>=PTR)
-               return(2);
-       switch(t) {
-
-       case INT:
-       case CHAR:
-       case UNSIGN:
-               return(2);
-
-       case LONG:
-               return(4);
-
-       case FLOAT:
-       case DOUBLE:
-               return(8);
-       }
-       return(1024);
-}
-
-/*
- * Strings for switch code.
- */
-
-char   dirsw[] {"\
-cmp    r0,$%o\n\
-jhi    L%d\n\
-asl    r0\n\
-jmp    *L%d(r0)\n\
-.data\n\
-L%d:\
-" };
-
-char   hashsw[] {"\
-mov    r0,r1\n\
-clr    r0\n\
-div    $%o,r0\n\
-asl    r1\n\
-jmp    *L%d(r1)\n\
-.data\n\
-L%d:\
-"};
-
-/*
- * If the unsigned casts below won't compile,
- * try using the calls to lrem and ldiv.
- */
-
-pswitch(afp, alp, deflab)
-struct swtab *afp, *alp;
-{
-       int ncase, i, j, tabs, worst, best, range;
-       register struct swtab *swp, *fp, *lp;
-       int *poctab;
-
-       fp = afp;
-       lp = alp;
-       if (fp==lp) {
-               printf("jbr     L%d\n", deflab);
-               return;
-       }
-       isn++;
-       if (sort(fp, lp))
-               return;
-       ncase = lp-fp;
-       lp--;
-       range = lp->swval - fp->swval;
-       /* direct switch */
-       if (range>0 && range <= 3*ncase) {
-               if (fp->swval)
-                       printf("sub     $%o,r0\n", fp->swval);
-               printf(dirsw, range, deflab, isn, isn);
-               isn++;
-               for (i=fp->swval; ; i++) {
-                       if (i==fp->swval) {
-                               printf("L%d\n", fp->swlab);
-                               if (fp==lp)
-                                       break;
-                               fp++;
-                       } else
-                               printf("L%d\n", deflab);
-               }
-               printf(".text\n");
-               return;
-       }
-       /* simple switch */
-       if (ncase<10) {
-               for (fp = afp; fp<=lp; fp++)
-                       breq(fp->swval, fp->swlab);
-               printf("jbr     L%d\n", deflab);
-               return;
-       }
-       /* hash switch */
-       best = 077777;
-       poctab = getblk(((ncase+2)/2) * sizeof(*poctab));
-       for (i=ncase/4; i<=ncase/2; i++) {
-               for (j=0; j<i; j++)
-                       poctab[j] = 0;
-               for (swp=fp; swp<=lp; swp++)
-                       /* lrem(0, swp->swval, i) */
-                       poctab[(unsigned)swp->swval%i]++;
-               worst = 0;
-               for (j=0; j<i; j++)
-                       if (poctab[j]>worst)
-                               worst = poctab[j];
-               if (i*worst < best) {
-                       tabs = i;
-                       best = i*worst;
-               }
-       }
-       i = isn++;
-       printf(hashsw, tabs, i, i);
-       isn++;
-       for (i=0; i<tabs; i++)
-               printf("L%d\n", isn+i);
-       printf(".text\n");
-       for (i=0; i<tabs; i++) {
-               printf("L%d:", isn++);
-               for (swp=fp; swp<=lp; swp++) {
-                       /* lrem(0, swp->swval, tabs) */
-                       if ((unsigned)swp->swval%tabs == i) {
-                               /* ldiv(0, swp->swval, tabs) */
-                               breq((unsigned)swp->swval/tabs, swp->swlab);
-                       }
-               }
-               printf("jbr     L%d\n", deflab);
-       }
-}
-
-breq(v, l)
-{
-       if (v==0)
-               printf("tst     r0\n");
-       else
-               printf("cmp     r0,$%o\n", v);
-       printf("jeq     L%d\n", l);
-}
-
-sort(afp, alp)
-struct swtab *afp, *alp;
-{
-       register struct swtab *cp, *fp, *lp;
-       int intch, t;
-
-       fp = afp;
-       lp = alp;
-       while (fp < --lp) {
-               intch = 0;
-               for (cp=fp; cp<lp; cp++) {
-                       if (cp->swval == cp[1].swval) {
-                               error("Duplicate case (%d)", cp->swval);
-                               return(1);
-                       }
-                       if (cp->swval > cp[1].swval) {
-                               intch++;
-                               t = cp->swval;
-                               cp->swval = cp[1].swval;
-                               cp[1].swval = t;
-                               t = cp->swlab;
-                               cp->swlab = cp[1].swlab;
-                               cp[1].swlab = t;
-                       }
-               }
-               if (intch==0)
-                       break;
-       }
-       return(0);
-}
-
-ispow2(atree)
-{
-       register int d;
-       register struct tnode *tree;
-
-       tree = atree;
-       if (!isfloat(tree) && tree->tr2->op==CON) {
-               d = tree->tr2->value;
-               if (d>1 && (d&(d-1))==0)
-                       return(d);
-       }
-       return(0);
-}
-
-pow2(atree)
-struct tnode *atree;
-{
-       register int d, i;
-       register struct tnode *tree;
-
-       tree = atree;
-       if (d = ispow2(tree)) {
-               for (i=0; (d=>>1)!=0; i++);
-               tree->tr2->value = i;
-               switch (tree->op) {
-
-               case TIMES:
-                       tree->op = LSHIFT;
-                       break;
-
-               case ASTIMES:
-                       tree->op = ASLSH;
-                       break;
-
-               case DIVIDE:
-                       tree->op = ULSH;
-                       tree->tr2->value = -i;
-                       break;
-
-               case ASDIV:
-                       tree->op = ASULSH;
-                       tree->tr2->value = -i;
-                       break;
-
-               case MOD:
-                       tree->op = AND;
-                       tree->tr2->value = (1<<i)-1;
-                       break;
-
-               case ASMOD:
-                       tree->op = ASAND;
-                       tree->tr2->value = (1<<i)-1;
-                       break;
-
-               default:
-                       error("pow2 botch");
-               }
-               tree = optim(tree);
-       }
-       return(tree);
-}
-
-cbranch(atree, albl, cond, areg)
-struct tnode *atree;
-{
-       int l1, op;
-       register lbl, reg;
-       register struct tnode *tree;
-
-       lbl = albl;
-       reg = areg;
-again:
-       if ((tree=atree)==0)
-               return;
-       switch(tree->op) {
-
-       case LOGAND:
-               if (cond) {
-                       cbranch(tree->tr1, l1=isn++, 0, reg);
-                       cbranch(tree->tr2, lbl, 1, reg);
-                       label(l1);
-               } else {
-                       cbranch(tree->tr1, lbl, 0, reg);
-                       cbranch(tree->tr2, lbl, 0, reg);
-               }
-               return;
-
-       case LOGOR:
-               if (cond) {
-                       cbranch(tree->tr1, lbl, 1, reg);
-                       cbranch(tree->tr2, lbl, 1, reg);
-               } else {
-                       cbranch(tree->tr1, l1=isn++, 1, reg);
-                       cbranch(tree->tr2, lbl, 0, reg);
-                       label(l1);
-               }
-               return;
-
-       case EXCLA:
-               cbranch(tree->tr1, lbl, !cond, reg);
-               return;
-
-       case SEQNC:
-               rcexpr(tree->tr1, efftab, reg);
-               atree = tree->tr2;
-               goto again;
-
-       case ITOL:
-               tree = tree->tr1;
-               break;
-       }
-       op = tree->op;
-       if (opdope[op]&RELAT
-        && tree->tr1->op==ITOL && tree->tr2->op==ITOL) {
-               tree->tr1 = tree->tr1->tr1;
-               tree->tr2 = tree->tr2->tr1;
-               if (op>=LESSEQ && op<=GREAT
-                && (tree->tr1->type==UNSIGN || tree->tr2->type==UNSIGN))
-                       tree->op = op = op+LESSEQP-LESSEQ;
-       }
-       if (tree->type==LONG
-         || opdope[op]&RELAT&&tree->tr1->type==LONG) {
-               longrel(tree, lbl, cond, reg);
-               return;
-       }
-       rcexpr(tree, cctab, reg);
-       op = tree->op;
-       if ((opdope[op]&RELAT)==0)
-               op = NEQUAL;
-       else {
-               l1 = tree->tr2->op;
-               if ((l1==CON || l1==SFCON) && tree->tr2->value==0)
-                       op =+ 200;              /* special for ptr tests */
-               else
-                       op = maprel[op-EQUAL];
-       }
-       if (isfloat(tree))
-               printf("cfcc\n");
-       branch(lbl, op, !cond);
-}
-
-branch(lbl, aop, c)
-{
-       register op;
-
-       if(op=aop)
-               prins(op, c, branchtab);
-       else
-               printf("jbr");
-       printf("\tL%d\n", lbl);
-}
-
-longrel(atree, lbl, cond, reg)
-struct tnode *atree;
-{
-       int xl1, xl2, xo, xz;
-       register int op, isrel;
-       register struct tnode *tree;
-
-       if (reg&01)
-               reg++;
-       reorder(&atree, cctab, reg);
-       tree = atree;
-       isrel = 0;
-       if (opdope[tree->op]&RELAT) {
-               isrel++;
-               op = tree->op;
-       } else
-               op = NEQUAL;
-       if (!cond)
-               op = notrel[op-EQUAL];
-       xl1 = xlab1;
-       xl2 = xlab2;
-       xo = xop;
-       xlab1 = lbl;
-       xlab2 = 0;
-       xop = op;
-       xz = xzero;
-       xzero = !isrel || tree->tr2->op==ITOL && tree->tr2->tr1->op==CON
-               && tree->tr2->tr1->value==0;
-       if (tree->op==ANDN) {
-               tree->op = TAND;
-               tree->tr2 = optim(tnode(COMPL, LONG, tree->tr2));
-       }
-       if (cexpr(tree, cctab, reg) < 0) {
-               reg = rcexpr(tree, regtab, reg);
-               printf("ashc    $0,r%d\n", reg);
-               branch(xlab1, op, 0);
-       }
-       xlab1 = xl1;
-       xlab2 = xl2;
-       xop = xo;
-       xzero = xz;
-}
-
-/*
- * Tables for finding out how best to do long comparisons.
- * First dimen is whether or not the comparison is with 0.
- * Second is which test: e.g. a>b->
- *     cmp     a,b
- *     bgt     YES             (first)
- *     blt     NO              (second)
- *     cmp     a+2,b+2
- *     bhi     YES             (third)
- *  NO:        ...
- * Note some tests may not be needed.
- */
-char   lrtab[2][3][6] {
-       0,      NEQUAL, LESS,   LESS,   GREAT,  GREAT,
-       NEQUAL, 0,      GREAT,  GREAT,  LESS,   LESS,
-       EQUAL,  NEQUAL, LESSEQP,LESSP,  GREATQP,GREATP,
-
-       0,      NEQUAL, LESS,   LESS,   GREATEQ,GREAT,
-       NEQUAL, 0,      GREAT,  0,      0,      LESS,
-       EQUAL,  NEQUAL, EQUAL,  0,      0,      NEQUAL,
-};
-
-xlongrel(f)
-{
-       register int op, bno;
-
-       op = xop;
-       if (f==0) {
-               if (bno = lrtab[xzero][0][op-EQUAL])
-                       branch(xlab1, bno, 0);
-               if (bno = lrtab[xzero][1][op-EQUAL]) {
-                       xlab2 = isn++;
-                       branch(xlab2, bno, 0);
-               }
-               if (lrtab[xzero][2][op-EQUAL]==0)
-                       return(1);
-       } else {
-               branch(xlab1, lrtab[xzero][2][op-EQUAL], 0);
-               if (xlab2)
-                       label(xlab2);
-       }
-       return(0);
-}
-
-label(l)
-{
-       printf("L%d:", l);
-}
-
-popstk(a)
-{
-       switch(a) {
-
-       case 0:
-               return;
-
-       case 2:
-               printf("tst     (sp)+\n");
-               return;
-
-       case 4:
-               printf("cmp     (sp)+,(sp)+\n");
-               return;
-       }
-       printf("add     $%o,sp\n", a);
-}
-
-error(s, p1, p2, p3, p4, p5, p6)
-{
-
-       nerror++;
-       fprintf(stderr, "%d: ", line);
-       fprintf(stderr, s, p1, p2, p3, p4, p5, p6);
-       putc('\n', stderr);
-}
-
-psoct(an)
-{
-       register int n, sign;
-
-       sign = 0;
-       if ((n = an) < 0) {
-               n = -n;
-               sign = '-';
-       }
-       printf("%c%o", sign, n);
-}
-
-/*
- * Read in an intermediate file.
- */
-#define        STKS    100
-getree()
-{
-       struct tnode *expstack[STKS];
-       register struct tnode **sp;
-       register t, op;
-       static char s[9];
-       struct swtab *swp;
-       double atof();
-       char numbuf[64];
-       struct tname *np;
-       struct xtname *xnp;
-       struct ftconst *fp;
-       struct lconst *lp;
-       struct fasgn *sap;
-       int lbl, cond, lbl2, lbl3;
-
-       curbase = funcbase;
-       sp = expstack;
-       for (;;) {
-               if (sp >= &expstack[STKS])
-                       error("Stack overflow botch");
-               op = geti();
-               if ((op&0177400) != 0177000) {
-                       error("Intermediate file error");
-                       exit(1);
-               }
-               lbl = 0;
-               switch(op =& 0377) {
-
-       case SINIT:
-               printf("%o\n", geti());
-               break;
-
-       case EOFC:
-               return;
-
-       case BDATA:
-               if (geti() == 1) {
-                       printf(".byte ");
-                       for (;;)  {
-                               printf("%o", geti());
-                               if (geti() != 1)
-                                       break;
-                               printf(",");
-                       }
-                       printf("\n");
-               }
-               break;
-
-       case PROG:
-               printf(".text\n");
-               break;
-
-       case DATA:
-               printf(".data\n");
-               break;
-
-       case BSS:
-               printf(".bss\n");
-               break;
-
-       case SYMDEF:
-               outname(s);
-               printf(".globl%s%.8s\n", s[0]?" ":"", s);
-               sfuncr.nloc = 0;
-               break;
-
-       case RETRN:
-               printf("jmp     cret\n");
-               break;
-
-       case CSPACE:
-               t = outname(s);
-               printf(".comm   %.8s,%o\n", t, geti());
-               break;
-
-       case SSPACE:
-               printf(".=.+%o\n", (t=geti()));
-               totspace += (unsigned)t;
-               break;
-
-       case EVEN:
-               printf(".even\n");
-               break;
-
-       case SAVE:
-               printf("jsr     r5,csv\n");
-               break;
-
-       case SETSTK:
-               t = geti()-6;
-               if (t==2)
-                       printf("tst     -(sp)\n");
-               else if (t != 0)
-                       printf("sub     $%o,sp\n", t);
-               break;
-
-       case PROFIL:
-               t = geti();
-               printf("mov     $L%d,r0\njsr    pc,mcount\n", t);
-               printf(".bss\nL%d:.=.+2\n.text\n", t);
-               break;
-
-       case SNAME:
-               t = outname(s);
-               printf("~%s=L%d\n", t+1, geti());
-               break;
-
-       case ANAME:
-               t = outname(s);
-               printf("~%s=%o\n", t+1, geti());
-               break;
-
-       case RNAME:
-               t = outname(s);
-               printf("~%s=r%d\n", t+1, geti());
-               break;
-
-       case SWIT:
-               t = geti();
-               line = geti();
-               curbase = funcbase;
-               while(swp=getblk(sizeof(*swp)), swp->swlab = geti())
-                       swp->swval = geti();
-               pswitch(funcbase, swp, t);
-               break;
-
-       case C3BRANCH:          /* for fortran [sic] */
-               lbl = geti();
-               lbl2 = geti();
-               lbl3 = geti();
-               goto xpr;
-
-       case CBRANCH:
-               lbl = geti();
-               cond = geti();
-
-       case EXPR:
-       xpr:
-               line = geti();
-               if (sp != &expstack[1]) {
-                       error("Expression input botch");
-                       exit(1);
-               }
-               nstack = 0;
-               *sp = optim(*--sp);
-               if (op==CBRANCH)
-                       cbranch(*sp, lbl, cond, 0);
-               else if (op==EXPR)
-                       rcexpr(*sp, efftab, 0);
-               else {
-                       if ((*sp)->type==LONG) {
-                               rcexpr(tnode(RFORCE, (*sp)->type, *sp), efftab, 0);
-                               printf("ashc    $0,r0\n");
-                       } else {
-                               rcexpr(*sp, cctab, 0);
-                               if (isfloat(*sp))
-                                       printf("cfcc\n");
-                       }
-                       printf("jgt     L%d\n", lbl3);
-                       printf("jlt     L%d\njbr        L%d\n", lbl, lbl2);
-               }
-               curbase = funcbase;
-               break;
-
-       case NAME:
-               t = geti();
-               if (t==EXTERN) {
-                       np = getblk(sizeof(*xnp));
-                       np->type = geti();
-                       outname(np->name);
-               } else {
-                       np = getblk(sizeof(*np));
-                       np->type = geti();
-                       np->nloc = geti();
-               }
-               np->op = NAME;
-               np->class = t;
-               np->regno = 0;
-               np->offset = 0;
-               *sp++ = np;
-               break;
-
-       case CON:
-               t = geti();
-               *sp++ = tconst(geti(), t);
-               break;
-
-       case LCON:
-               geti(); /* ignore type, assume long */
-               t = geti();
-               op = geti();
-               if (t==0 && op>=0 || t == -1 && op<0) {
-                       *sp++ = tnode(ITOL, LONG, tconst(op, INT));
-                       break;
-               }
-               lp = getblk(sizeof(*lp));
-               lp->op = LCON;
-               lp->type = LONG;
-               lp->lvalue = ((long)t<<16) + (unsigned)op;      /* nonportable */
-               *sp++ = lp;
-               break;
-
-       case FCON:
-               t = geti();
-               outname(numbuf);
-               fp = getblk(sizeof(*fp));
-               fp->op = FCON;
-               fp->type = t;
-               fp->value = isn++;
-               fp->fvalue = atof(numbuf);
-               *sp++ = fp;
-               break;
-
-       case FSEL:
-               *sp = tnode(FSEL, geti(), *--sp, NULL);
-               t = geti();
-               (*sp++)->tr2 = tnode(COMMA, INT, tconst(geti(), INT), tconst(t, INT));
-               break;
-
-       case STRASG:
-               sap = getblk(sizeof(*sap));
-               sap->op = STRASG;
-               sap->type = geti();
-               sap->mask = geti();
-               sap->tr1 = *--sp;
-               sap->tr2 = NULL;
-               *sp++ = sap;
-               break;
-
-       case NULLOP:
-               *sp++ = tnode(0, 0, NULL, NULL);
-               break;
-
-       case LABEL:
-               label(geti());
-               break;
-
-       case NLABEL:
-               t = outname(s);
-               printf("%.8s:\n", t, t);
-               break;
-
-       case RLABEL:
-               t = outname(s);
-               printf("%.8s:\n~~%s:\n", t, t+1);
-               break;
-
-       case BRANCH:
-               branch(geti(), 0);
-               break;
-
-       case SETREG:
-               nreg = geti()-1;
-               break;
-
-       default:
-               if (opdope[op]&BINARY) {
-                       if (sp < &expstack[1]) {
-                               error("Binary expression botch");
-                               exit(1);
-                       }
-                       t = *--sp;
-                       *sp++ = tnode(op, geti(), *--sp, t);
-               } else
-                       sp[-1] = tnode(op, geti(), sp[-1]);
-               break;
-       }
-       }
-}
-
-geti()
-{
-       register i;
-
-       i = getchar();
-       i += getchar()<<8;
-       return(i);
-}
-
-outname(s)
-{
-       register char *p, c;
-       register n;
-
-       p = s;
-       n = 0;
-       while (c = getchar()) {
-               *p++ = c;
-               n++;
-       }
-       do {
-               *p++ = 0;
-       } while (n++ < 8);
-       return(s);
-}
-
-strasg(atp)
-struct fasgn *atp;
-{
-       register struct tnode *tp;
-       register nwords, i;
-
-       nwords = atp->mask/sizeof(int);
-       tp = atp->tr1;
-       if (tp->op != ASSIGN) {
-               if (tp->op==RFORCE) {   /* function return */
-                       if (sfuncr.nloc==0) {
-                               sfuncr.nloc = isn++;
-                               printf(".bss\nL%d:.=.+%o\n.text\n", sfuncr.nloc, nwords*sizeof(int));
-                       }
-                       atp->tr1 = tnode(ASSIGN, STRUCT, &sfuncr, tp->tr1);
-                       strasg(atp);
-                       printf("mov     $L%d,r0\n", sfuncr.nloc);
-                       return;
-               }
-               if (tp->op==CALL) {
-                       rcexpr(tp, efftab, 0);
-                       return;
-               }
-               error("Illegal structure operation");
-               return;
-       }
-       tp->tr2 = strfunc(tp->tr2);
-       if (nwords==1)
-               setype(tp, INT);
-       else if (nwords==sizeof(int))
-               setype(tp, LONG);
-       else {
-               if (tp->tr1->op!=NAME && tp->tr1->op!=STAR
-                || tp->tr2->op!=NAME && tp->tr2->op!=STAR) {
-                       error("unimplemented structure assignment");
-                       return;
-               }
-               tp->tr1 = tnode(AMPER, STRUCT+PTR, tp->tr1);
-               tp->tr2 = tnode(AMPER, STRUCT+PTR, tp->tr2);
-               tp->op = STRSET;
-               tp->type = STRUCT+PTR;
-               tp = optim(tp);
-               rcexpr(tp, efftab, 0);
-               if (nwords < 7) {
-                       for (i=0; i<nwords; i++)
-                               printf("mov     (r1)+,(r0)+\n");
-                       return;
-               }
-               if (nreg<=1)
-                       printf("mov     r2,-(sp)\n");
-               printf("mov     $%o,r2\n", nwords);
-               printf("L%d:mov (r1)+,(r0)+\ndec\tr2\njne\tL%d\n", isn, isn);
-               isn++;
-               if (nreg<=1)
-                       printf("mov     (sp)+,r2\n");
-               return;
-       }
-       rcexpr(tp, efftab, 0);
-}
-
-setype(p, t)
-register struct tnode *p;
-register t;
-{
-
-       for (;; p = p->tr1) {
-               p->type = t;
-               if (p->op==AMPER)
-                       t = decref(t);
-               else if (p->op==STAR)
-                       t = incref(t);
-               else if (p->op==ASSIGN)
-                       setype(p->tr2, t);
-               else if (p->op!=PLUS)
-                       break;
-       }
-}
-
-/*
- * Reduce the degree-of-reference by one.
- * e.g. turn "ptr-to-int" into "int".
- */
-decref(at)
-{
-       register t;
-
-       t = at;
-       if ((t & ~TYPE) == 0) {
-               error("Illegal indirection");
-               return(t);
-       }
-       return((t>>TYLEN) & ~TYPE | t&TYPE);
-}
-
-/*
- * Increase the degree of reference by
- * one; e.g. turn "int" to "ptr-to-int".
- */
-incref(t)
-{
-       return(((t&~TYPE)<<TYLEN) | (t&TYPE) | PTR);
-}
diff --git a/usr/src/cmd/c/c12.c b/usr/src/cmd/c/c12.c
deleted file mode 100644 (file)
index c58242e..0000000
+++ /dev/null
@@ -1,1080 +0,0 @@
-#
-/*
- *             C compiler part 2 -- expression optimizer
- *
- */
-
-#include "c1.h"
-
-optim(atree)
-struct tnode *atree;
-{
-       struct { int intx[4]; };
-       register op, dope;
-       int d1, d2;
-       struct tnode *t;
-       register struct tnode *tree;
-
-       if ((tree=atree)==0)
-               return(0);
-       if ((op = tree->op)==0)
-               return(tree);
-       if (op==NAME && tree->class==AUTO) {
-               tree->class = OFFS;
-               tree->regno = 5;
-               tree->offset = tree->nloc;
-       }
-       dope = opdope[op];
-       if ((dope&LEAF) != 0) {
-               if (op==FCON
-                && tree->fvalue.intx[1]==0
-                && tree->fvalue.intx[2]==0
-                && tree->fvalue.intx[3]==0) {
-                       tree->op = SFCON;
-                       tree->value = tree->fvalue.intx[0];
-               }
-               return(tree);
-       }
-       if ((dope&BINARY) == 0)
-               return(unoptim(tree));
-       /* is known to be binary */
-       if (tree->type==CHAR)
-               tree->type = INT;
-       switch(op) {
-       /*
-        * PDP-11 special:
-        * generate new =&~ operator out of =&
-        * by complementing the RHS.
-        */
-       case ASAND:
-               tree->op = ASANDN;
-               tree->tr2 = tnode(COMPL, tree->tr2->type, tree->tr2);
-               break;
-
-       /*
-        * On the PDP-11, int->ptr via multiplication
-        * Longs are just truncated.
-        */
-       case LTOP:
-               tree->op = ITOP;
-               tree->tr1 = unoptim(tnode(LTOI,INT,tree->tr1));
-       case ITOP:
-               tree->op = TIMES;
-               break;
-
-       case MINUS:
-               if ((t = isconstant(tree->tr2)) && (t->type!=UNSIGN || tree->type!=LONG)) {
-                       tree->op = PLUS;
-                       if (t->type==DOUBLE)
-                               /* PDP-11 FP representation */
-                               t->value =^ 0100000;
-                       else
-                               t->value = -t->value;
-               }
-               break;
-       }
-       op = tree->op;
-       dope = opdope[op];
-       if (dope&LVALUE && tree->tr1->op==FSEL)
-               return(lvfield(tree));
-       if ((dope&COMMUTE)!=0) {
-               d1 = tree->type;
-               tree = acommute(tree);
-               if (tree->op == op)
-                       tree->type = d1;
-               /*
-                * PDP-11 special:
-                * replace a&b by a ANDN ~ b.
-                * This will be undone when in
-                * truth-value context.
-                */
-               if (tree->op!=AND)
-                       return(tree);
-               /*
-                * long & pos-int is simpler
-                */
-               if (tree->type==LONG && tree->tr2->op==ITOL
-                && (tree->tr2->tr1->op==CON && tree->tr2->tr1->value>=0
-                  || tree->tr2->tr1->type==UNSIGN)) {
-                       tree->type = UNSIGN;
-                       t = tree->tr2;
-                       tree->tr2 = tree->tr2->tr1;
-                       t->tr1 = tree;
-                       tree->tr1 = tnode(LTOI, UNSIGN, tree->tr1);
-                       return(optim(t));
-               }
-               /*
-                * Keep constants to the right
-                */
-               if ((tree->tr1->op==ITOL && tree->tr1->tr1->op==CON)
-                 || tree->tr1->op==LCON) {
-                       t = tree->tr1;
-                       tree->tr1 = tree->tr2;
-                       tree->tr2 = t;
-               }
-               tree->op = ANDN;
-               op = ANDN;
-               tree->tr2 = tnode(COMPL, tree->tr2->type, tree->tr2);
-       }
-    again:
-       tree->tr1 = optim(tree->tr1);
-       tree->tr2 = optim(tree->tr2);
-       if (tree->type == LONG) {
-               t = lconst(tree->op, tree->tr1, tree->tr2);
-               if (t)
-                       return(t);
-       }
-       if ((dope&RELAT) != 0) {
-               if ((d1=degree(tree->tr1)) < (d2=degree(tree->tr2))
-                || d1==d2 && tree->tr1->op==NAME && tree->tr2->op!=NAME) {
-                       t = tree->tr1;
-                       tree->tr1 = tree->tr2;
-                       tree->tr2 = t;
-                       tree->op = maprel[op-EQUAL];
-               }
-               if (tree->tr1->type==CHAR && tree->tr2->op==CON
-                && (dcalc(tree->tr1, 0) <= 12 || tree->tr1->op==STAR)
-                && tree->tr2->value <= 127 && tree->tr2->value >= 0)
-                       tree->tr2->type = CHAR;
-       }
-       d1 = max(degree(tree->tr1), islong(tree->type));
-       d2 = max(degree(tree->tr2), 0);
-       switch (op) {
-
-       /*
-        * In assignment to fields, treat all-zero and all-1 specially.
-        */
-       case FSELA:
-               if (tree->tr2->op==CON && tree->tr2->value==0) {
-                       tree->op = ASAND;
-                       tree->tr2->value = ~tree->mask;
-                       return(optim(tree));
-               }
-               if (tree->tr2->op==CON && tree->mask==tree->tr2->value) {
-                       tree->op = ASOR;
-                       return(optim(tree));
-               }
-
-       case LTIMES:
-       case LDIV:
-       case LMOD:
-       case LASTIMES:
-       case LASDIV:
-       case LASMOD:
-               tree->degree = 10;
-               break;
-
-       case ANDN:
-               if (isconstant(tree->tr2) && tree->tr2->value==0) {
-                       return(tree->tr1);
-               }
-               goto def;
-
-       case CALL:
-               tree->degree = 10;
-               break;
-
-       case QUEST:
-       case COLON:
-               tree->degree = max(d1, d2);
-               break;
-
-       case DIVIDE:
-       case ASDIV:
-       case ASTIMES:
-       case PTOI:
-               if (tree->tr2->op==CON && tree->tr2->value==1)
-                       return(tree->tr1);
-       case MOD:
-       case ASMOD:
-               if (tree->tr1->type==UNSIGN && ispow2(tree))
-                       return(pow2(tree));
-               if ((op==MOD||op==ASMOD) && tree->type==DOUBLE) {
-                       error("Floating %% not defined");
-                       tree->type = INT;
-               }
-       case ULSH:
-       case ASULSH:
-               d1 =+ 2;
-               d2 =+ 2;
-               if (tree->type==LONG)
-                       return(hardlongs(tree));
-               goto constant;
-
-       case LSHIFT:
-       case RSHIFT:
-       case ASRSH:
-       case ASLSH:
-               if (tree->tr2->op==CON && tree->tr2->value==0) {
-                       return(tree->tr1);
-               }
-               /*
-                * PDP-11 special: turn right shifts into negative
-                * left shifts
-                */
-               if (tree->type == LONG) {
-                       d1++;
-                       d2++;
-               }
-               if (op==LSHIFT||op==ASLSH)
-                       goto constant;
-               if (tree->tr2->op==CON && tree->tr2->value==1
-                && tree->tr1->type!=UNSIGN)
-                       goto constant;
-               op =+ (LSHIFT-RSHIFT);
-               tree->op = op;
-               tree->tr2 = tnode(NEG, tree->type, tree->tr2);
-               if (tree->tr1->type==UNSIGN) {
-                       if (tree->op==LSHIFT)
-                               tree->op = ULSH;
-                       else if (tree->op==ASLSH)
-                               tree->op = ASULSH;
-               }
-               goto again;
-
-       constant:
-               if (tree->tr1->op==CON && tree->tr2->op==CON) {
-                       const(op, &tree->tr1->value, tree->tr2->value);
-                       return(tree->tr1);
-               }
-
-
-       def:
-       default:
-               if (dope&RELAT) {
-                       if (tree->tr1->type==LONG)      /* long relations are a mess */
-                               d1 = 10;
-                       if (opdope[tree->tr1->op]&RELAT && tree->tr2->op==CON
-                        && tree->tr2->value==0) {
-                               tree = tree->tr1;
-                               switch(op) {
-                               case GREATEQ:
-                                       return(&cone);
-                               case LESS:
-                                       return(&czero);
-                               case LESSEQ:
-                               case EQUAL:
-                                       tree->op = notrel[tree->op-EQUAL];
-                               }
-                               return(tree);
-                       }
-               }
-               tree->degree = d1==d2? d1+islong(tree->type): max(d1, d2);
-               break;
-       }
-       return(tree);
-}
-
-unoptim(atree)
-struct tnode *atree;
-{
-       struct { int intx[4]; };
-       register struct tnode *subtre, *tree;
-       register int *p;
-       double static fv;
-       struct ftconst *fp;
-
-       if ((tree=atree)==0)
-               return(0);
-    again:
-       if (tree->op==AMPER && tree->tr1->op==STAR) {
-               subtre = tree->tr1->tr1;
-               subtre->type = tree->type;
-               return(optim(subtre));
-       }
-       subtre = tree->tr1 = optim(tree->tr1);
-       switch (tree->op) {
-
-       case ITOL:
-               if (subtre->op==CON && subtre->type==INT && subtre->value<0) {
-                       subtre = getblk(sizeof(struct lconst));
-                       subtre->op = LCON;
-                       subtre->type = LONG;
-                       subtre->lvalue = tree->tr1->value;
-                       return(subtre);
-               }
-               break;
-
-       case FTOI:
-               if (tree->type==UNSIGN) {
-                       tree->op = FTOL;
-                       tree->type = LONG;
-                       tree = tnode(LTOI, UNSIGN, tree);
-               }
-               break;
-
-       case LTOF:
-               if (subtre->op==LCON) {
-                       tree = getblk(sizeof(*fp));
-                       tree->op = FCON;
-                       tree->type = DOUBLE;
-                       tree->value = isn++;
-                       tree->fvalue = subtre->lvalue;
-                       return(optim(tree));
-               }
-               break;
-
-       case ITOF:
-               if (tree->tr1->type==UNSIGN) {
-                       tree->tr1 = tnode(ITOL, LONG, tree->tr1);
-                       tree->op = LTOF;
-                       tree = optim(tree);
-               }
-               if (subtre->op!=CON)
-                       break;
-               fv = subtre->value;
-               p = &fv;
-               p++;
-               if (*p++==0 && *p++==0 && *p++==0) {
-                       tree = getblk(sizeof(*fp));
-                       tree->op = SFCON;
-                       tree->type = DOUBLE;
-                       tree->value = * (int *) &fv;
-                       tree->fvalue = fv;
-                       return(tree);
-               }
-               break;
-
-       case ITOC:
-               p = tree->tr1;
-               /*
-                * Sign-extend PDP-11 characters
-                */
-               if (p->op==CON) {
-                       p->value = p->value << 8 >> 8;
-                       return(p);
-               } else if (p->op==NAME) {
-                       p->type = CHAR;
-                       return(p);
-               }
-               break;
-
-       case LTOI:
-               p = tree->tr1;
-               switch (p->op) {
-
-               case LCON:
-                       p->op = CON;
-                       p->type = tree->type;
-                       p->value = p->lvalue;
-                       return(p);
-
-               case NAME:
-                       p->offset =+ 2;
-                       p->type = tree->type;
-                       return(p);
-
-               case STAR:
-                       p->type = tree->type;
-                       p->tr1->type = tree->type+PTR;
-                       p->tr1 = tnode(PLUS, tree->type, p->tr1, tconst(2, INT));
-                       return(optim(p));
-
-               case ITOL:
-                       return(p->tr1);
-
-               case PLUS:
-               case MINUS:
-               case AND:
-               case ANDN:
-               case OR:
-               case EXOR:
-                       p->tr2 = tnode(LTOI, tree->type, p->tr2);
-               case NEG:
-               case COMPL:
-                       p->tr1 = tnode(LTOI, tree->type, p->tr1);
-                       p->type = tree->type;
-                       return(optim(p));
-               }
-               break;
-
-       case FSEL:
-               tree->op = AND;
-               tree->tr1 = tree->tr2->tr1;
-               tree->tr2->tr1 = subtre;
-               tree->tr2->op = RSHIFT;
-               tree->tr1->value = (1 << tree->tr1->value) - 1;
-               return(optim(tree));
-
-       case FSELR:
-               tree->op = LSHIFT;
-               tree->type = UNSIGN;
-               tree->tr1 = tree->tr2;
-               tree->tr1->op = AND;
-               tree->tr2 = tree->tr2->tr2;
-               tree->tr1->tr2 = subtre;
-               tree->tr1->tr1->value = (1 << tree->tr1->tr1->value) -1;
-               return(optim(tree));
-
-       case AMPER:
-               if (subtre->op==STAR)
-                       return(subtre->tr1);
-               if (subtre->op==NAME && subtre->class == OFFS) {
-                       p = tnode(PLUS, tree->type, subtre, tree);
-                       subtre->type = tree->type;
-                       tree->op = CON;
-                       tree->type = INT;
-                       tree->degree = 0;
-                       tree->value = subtre->offset;
-                       subtre->class = REG;
-                       subtre->nloc = subtre->regno;
-                       subtre->offset = 0;
-                       return(optim(p));
-               }
-               break;
-
-       case STAR:
-               if (subtre->op==AMPER) {
-                       subtre->tr1->type = tree->type;
-                       return(subtre->tr1);
-               }
-               if (tree->type==STRUCT)
-                       break;
-               if (subtre->op==NAME && subtre->class==REG) {
-                       subtre->type = tree->type;
-                       subtre->class = OFFS;
-                       subtre->regno = subtre->nloc;
-                       return(subtre);
-               }
-               p = subtre->tr1;
-               if ((subtre->op==INCAFT||subtre->op==DECBEF)&&tree->type!=LONG
-                && p->op==NAME && p->class==REG && p->type==subtre->type) {
-                       p->type = tree->type;
-                       p->op = subtre->op==INCAFT? AUTOI: AUTOD;
-                       return(p);
-               }
-               if (subtre->op==PLUS && p->op==NAME && p->class==REG) {
-                       if (subtre->tr2->op==CON) {
-                               p->offset =+ subtre->tr2->value;
-                               p->class = OFFS;
-                               p->type = tree->type;
-                               p->regno = p->nloc;
-                               return(p);
-                       }
-                       if (subtre->tr2->op==AMPER) {
-                               subtre = subtre->tr2->tr1;
-                               subtre->class =+ XOFFS-EXTERN;
-                               subtre->regno = p->nloc;
-                               subtre->type = tree->type;
-                               return(subtre);
-                       }
-               }
-               break;
-       case EXCLA:
-               if ((opdope[subtre->op]&RELAT)==0)
-                       break;
-               tree = subtre;
-               tree->op = notrel[tree->op-EQUAL];
-               break;
-
-       case COMPL:
-               if (tree->type==CHAR)
-                       tree->type = INT;
-               if (tree->op == subtre->op)
-                       return(subtre->tr1);
-               if (subtre->op==CON) {
-                       subtre->value = ~subtre->value;
-                       return(subtre);
-               }
-               if (subtre->op==LCON) {
-                       subtre->lvalue = ~subtre->lvalue;
-                       return(subtre);
-               }
-               if (subtre->op==ITOL) {
-                       if (subtre->tr1->op==CON) {
-                               tree = getblk(sizeof(struct lconst));
-                               tree->op = LCON;
-                               tree->type = LONG;
-                               if (subtre->tr1->type==UNSIGN)
-                                       tree->lvalue = ~(long)(unsigned)subtre->tr1->value;
-                               else
-                                       tree->lvalue = ~subtre->tr1->value;
-                               return(tree);
-                       }
-                       if (subtre->tr1->type==UNSIGN)
-                               break;
-                       subtre->op = tree->op;
-                       subtre->type = subtre->tr1->type;
-                       tree->op = ITOL;
-                       tree->type = LONG;
-                       goto again;
-               }
-
-       case NEG:
-               if (tree->type==CHAR)
-                       tree->type = INT;
-               if (tree->op==subtre->op)
-                       return(subtre->tr1);
-               if (subtre->op==CON) {
-                       subtre->value = -subtre->value;
-                       return(subtre);
-               }
-               if (subtre->op==LCON) {
-                       subtre->lvalue = -subtre->lvalue;
-                       return(subtre);
-               }
-               if (subtre->op==ITOL && subtre->tr1->op==CON) {
-                       tree = getblk(sizeof(struct lconst));
-                       tree->op = LCON;
-                       tree->type = LONG;
-                       if (subtre->tr1->type==UNSIGN)
-                               tree->lvalue = -(long)(unsigned)subtre->tr1->value;
-                       else
-                               tree->lvalue = -subtre->tr1->value;
-                       return(tree);
-               }
-               /*
-                * PDP-11 FP negation
-                */
-               if (subtre->op==SFCON) {
-                       subtre->value =^ 0100000;
-                       subtre->fvalue.intx[0] =^ 0100000;
-                       return(subtre);
-               }
-               if (subtre->op==FCON) {
-                       subtre->fvalue.intx[0] =^ 0100000;
-                       return(subtre);
-               }
-       }
-       if ((opdope[tree->op]&LEAF)==0)
-               tree->degree = max(islong(tree->type), degree(subtre));
-       return(tree);
-}
-
-/*
- * Deal with assignments to partial-word fields.
- * The game is that select(x) =+ y turns into
- * select(x =+ select(y)) where the shifts and masks
- * are chosen properly.  The outer select
- * is discarded where the value doesn't matter.
- * Sadly, overflow is undetected on =+ and the like.
- * Pure assignment is handled specially.
- */
-
-lvfield(at)
-struct tnode *at;
-{
-       register struct tnode *t, *t1;
-       register struct fasgn *t2;
-
-       t = at;
-       switch (t->op) {
-
-       case ASSIGN:
-               t2 = getblk(sizeof(*t2));
-               t2->op = FSELA;
-               t2->type = UNSIGN;
-               t1 = t->tr1->tr2;
-               t2->mask = ((1<<t1->tr1->value)-1)<<t1->tr2->value;
-               t2->tr1 = t->tr1;
-               t2->tr2 = t->tr2;
-               t = t2;
-
-       case ASANDN:
-       case ASPLUS:
-       case ASMINUS:
-       case ASOR:
-       case ASXOR:
-       case INCBEF:
-       case INCAFT:
-       case DECBEF:
-       case DECAFT:
-               t1 = t->tr1;
-               t1->op = FSELR;
-               t->tr1 = t1->tr1;
-               t1->tr1 = t->tr2;
-               t->tr2 = t1;
-               t1 = t1->tr2;
-               t1 = tnode(COMMA, INT, tconst(t1->tr1->value, INT),
-                       tconst(t1->tr2->value, INT));
-               return(optim(tnode(FSELT, UNSIGN, t, t1)));
-
-       }
-       error("Unimplemented field operator");
-       return(t);
-}
-
-#define        LSTSIZ  20
-struct acl {
-       int nextl;
-       int nextn;
-       struct tnode *nlist[LSTSIZ];
-       struct tnode *llist[LSTSIZ+1];
-};
-
-acommute(atree)
-{
-       struct acl acl;
-       int d, i, op, flt, d1;
-       register struct tnode *t1, **t2, *tree;
-       struct tnode *t;
-
-       acl.nextl = 0;
-       acl.nextn = 0;
-       tree = atree;
-       op = tree->op;
-       flt = isfloat(tree);
-       insert(op, tree, &acl);
-       acl.nextl--;
-       t2 = &acl.llist[acl.nextl];
-       if (!flt) {
-               /* put constants together */
-               for (i=acl.nextl; i>0; i--) {
-                       if (t2[0]->op==CON && t2[-1]->op==CON) {
-                               acl.nextl--;
-                               t2--;
-                               const(op, &t2[0]->value, t2[1]->value);
-                       } else if (t = lconst(op, t2[-1], t2[0])) {
-                               acl.nextl--;
-                               t2--;
-                               t2[0] = t;
-                       }
-               }
-       }
-       if (op==PLUS || op==OR) {
-               /* toss out "+0" */
-               if (acl.nextl>0 && (t1 = isconstant(*t2)) && t1->value==0
-                || (*t2)->op==LCON && (*t2)->lvalue==0) {
-                       acl.nextl--;
-                       t2--;
-               }
-               if (acl.nextl <= 0) {
-                       if ((*t2)->type==CHAR)
-                               *t2 = tnode(LOAD, tree->type, *t2, NULL);
-                       (*t2)->type = tree->type;
-                       return(*t2);
-               }
-               /* subsume constant in "&x+c" */
-               if (op==PLUS && t2[0]->op==CON && t2[-1]->op==AMPER) {
-                       t2--;
-                       t2[0]->tr1->offset =+ t2[1]->value;
-                       acl.nextl--;
-               }
-       } else if (op==TIMES || op==AND) {
-               t1 = acl.llist[acl.nextl];
-               if (t1->op==CON) {
-                       if (t1->value==0)
-                               return(t1);
-                       if (op==TIMES && t1->value==1 && acl.nextl>0)
-                               if (--acl.nextl <= 0) {
-                                       t1 = acl.llist[0];
-                                       if (tree->type == UNSIGN)
-                                               t1->type = tree->type;
-                                       return(t1);
-                               }
-               }
-       }
-       if (op==PLUS && !flt)
-               distrib(&acl);
-       tree = *(t2 = &acl.llist[0]);
-       d = max(degree(tree), islong(tree->type));
-       if (op==TIMES && !flt)
-               d++;
-       for (i=0; i<acl.nextl; i++) {
-               t1 = acl.nlist[i];
-               t1->tr2 = t = *++t2;
-               d1 = degree(t);
-               /*
-                * PDP-11 strangeness:
-                * rt. op of ^ must be in a register.
-                */
-               if (op==EXOR && dcalc(t, 0)<=12) {
-                       t1->tr2 = t = optim(tnode(LOAD, t->type, t));
-                       d1 = t->degree;
-               }
-               t1->degree = d = d==d1? d+islong(t1->type): max(d, d1);
-               t1->tr1 = tree;
-               tree = t1;
-               if (tree->type==LONG) {
-                       if (tree->op==TIMES)
-                               tree = hardlongs(tree);
-                       else if (tree->op==PLUS && (t = isconstant(tree->tr1))
-                              && t->value < 0 && t->type!=UNSIGN) {
-                               tree->op = MINUS;
-                               t->value = - t->value;
-                               t = tree->tr1;
-                               tree->tr1 = tree->tr2;
-                               tree->tr2 = t;
-                       }
-               }
-       }
-       if (tree->op==TIMES && ispow2(tree))
-               tree->degree = max(degree(tree->tr1), islong(tree->type));
-       return(tree);
-}
-
-distrib(list)
-struct acl *list;
-{
-/*
- * Find a list member of the form c1c2*x such
- * that c1c2 divides no other such constant, is divided by
- * at least one other (say in the form c1*y), and which has
- * fewest divisors. Reduce this pair to c1*(y+c2*x)
- * and iterate until no reductions occur.
- */
-       register struct tnode **p1, **p2;
-       struct tnode *t;
-       int ndmaj, ndmin;
-       struct tnode **dividend, **divisor;
-       struct tnode **maxnod, **mindiv;
-
-    loop:
-       maxnod = &list->llist[list->nextl];
-       ndmaj = 1000;
-       dividend = 0;
-       for (p1 = list->llist; p1 <= maxnod; p1++) {
-               if ((*p1)->op!=TIMES || (*p1)->tr2->op!=CON)
-                       continue;
-               ndmin = 0;
-               for (p2 = list->llist; p2 <= maxnod; p2++) {
-                       if (p1==p2 || (*p2)->op!=TIMES || (*p2)->tr2->op!=CON)
-                               continue;
-                       if ((*p1)->tr2->value == (*p2)->tr2->value) {
-                               (*p2)->tr2 = (*p1)->tr1;
-                               (*p2)->op = PLUS;
-                               (*p1)->tr1 = (*p2);
-                               *p1 = optim(*p1);
-                               squash(p2, maxnod);
-                               list->nextl--;
-                               goto loop;
-                       }
-                       if (((*p2)->tr2->value % (*p1)->tr2->value) == 0)
-                               goto contmaj;
-                       if (((*p1)->tr2->value % (*p2)->tr2->value) == 0) {
-                               ndmin++;
-                               mindiv = p2;
-                       }
-               }
-               if (ndmin > 0 && ndmin < ndmaj) {
-                       ndmaj = ndmin;
-                       dividend = p1;
-                       divisor = mindiv;
-               }
-    contmaj:;
-       }
-       if (dividend==0)
-               return;
-       t = list->nlist[--list->nextn];
-       p1 = dividend;
-       p2 = divisor;
-       t->op = PLUS;
-       t->type = (*p1)->type;
-       t->tr1 = (*p1);
-       t->tr2 = (*p2)->tr1;
-       (*p1)->tr2->value =/ (*p2)->tr2->value;
-       (*p2)->tr1 = t;
-       t = optim(*p2);
-       if (p1 < p2) {
-               *p1 = t;
-               squash(p2, maxnod);
-       } else {
-               *p2 = t;
-               squash(p1, maxnod);
-       }
-       list->nextl--;
-       goto loop;
-}
-
-squash(p, maxp)
-struct tnode **p, **maxp;
-{
-       register struct tnode **np;
-
-       for (np = p; np < maxp; np++)
-               *np = *(np+1);
-}
-
-const(op, vp, av)
-int *vp;
-{
-       register int v;
-       struct { unsigned u;};
-
-       v = av;
-       switch (op) {
-
-       case PTOI:
-               (*vp).u =/ v;
-               return;
-
-       case PLUS:
-               *vp =+ v;
-               return;
-
-       case TIMES:
-               *vp =* v;
-               return;
-
-       case AND:
-               *vp =& v;
-               return;
-
-       case OR:
-               *vp =| v;
-               return;
-
-       case EXOR:
-               *vp =^ v;
-               return;
-
-       case DIVIDE:
-       case MOD:
-               if (v==0)
-                       error("Divide check");
-               else
-                       if (op==DIVIDE)
-                               *vp =/ v;
-                       else
-                               *vp =% v;
-               return;
-
-       case RSHIFT:
-               *vp =>> v;
-               return;
-
-       case LSHIFT:
-               *vp =<< v;
-               return;
-
-       case ANDN:
-               *vp =& ~ v;
-               return;
-       }
-       error("C error: const");
-}
-
-struct tnode *
-lconst(op, lp, rp)
-register struct tnode *lp, *rp;
-{
-       long l, r;
-
-       if (lp->op==LCON)
-               l = lp->lvalue;
-       else if (lp->op==ITOL && lp->tr1->op==CON) {
-               if (lp->tr1->type==INT)
-                       l = lp->tr1->value;
-               else
-                       l = (unsigned)lp->tr1->value;
-       } else
-               return(0);
-       if (rp->op==LCON)
-               r = rp->lvalue;
-       else if (rp->op==ITOL && rp->tr1->op==CON) {
-               if (rp->tr1->type==INT)
-                       r = rp->tr1->value;
-               else
-                       r = (unsigned)rp->tr1->value;
-       } else
-               return(0);
-       switch (op) {
-
-       case PLUS:
-               l += r;
-               break;
-
-       case MINUS:
-               l -= r;
-               break;
-
-       case TIMES:
-       case LTIMES:
-               l *= r;
-               break;
-
-       case DIVIDE:
-       case LDIV:
-               if (r==0)
-                       error("Divide check");
-               else
-                       l /= r;
-               break;
-
-       case MOD:
-       case LMOD:
-               if (r==0)
-                       error("Divide check");
-               else
-                       l %= r;
-               break;
-
-       case AND:
-               l &= r;
-               break;
-
-       case ANDN:
-               l &= ~r;
-               break;
-
-       case OR:
-               l |= r;
-               break;
-
-       case EXOR:
-               l ^= r;
-               break;
-
-       case LSHIFT:
-               l <<= r;
-               break;
-
-       case RSHIFT:
-               l >>= r;
-               break;
-
-       default:
-               return(0);
-       }
-       if (lp->op==LCON) {
-               lp->lvalue = l;
-               return(lp);
-       }
-       lp = getblk(sizeof(struct lconst));
-       lp->op = LCON;
-       lp->type = LONG;
-       lp->lvalue = l;
-       return(lp);
-}
-
-insert(op, atree, alist)
-struct acl *alist;
-{
-       register d;
-       register struct acl *list;
-       register struct tnode *tree;
-       int d1, i;
-       struct tnode *t;
-
-       tree = atree;
-       list = alist;
-ins:
-       if (tree->op != op)
-               tree = optim(tree);
-       if (tree->op == op && list->nextn < LSTSIZ-2) {
-               list->nlist[list->nextn++] = tree;
-               insert(op, tree->tr1, list);
-               insert(op, tree->tr2, list);
-               return;
-       }
-       if (!isfloat(tree)) {
-               /* c1*(x+c2) -> c1*x+c1*c2 */
-               if ((tree->op==TIMES||tree->op==LSHIFT)
-                 && tree->tr2->op==CON && tree->tr2->value>0
-                 && tree->tr1->op==PLUS && tree->tr1->tr2->op==CON) {
-                       d = tree->tr2->value;
-                       if (tree->op==TIMES)
-                               tree->tr2->value =* tree->tr1->tr2->value;
-                       else
-                               tree->tr2->value = tree->tr1->tr2->value << d;
-                       tree->tr1->tr2->value = d;
-                       tree->tr1->op = tree->op;
-                       tree->op = PLUS;
-                       tree = optim(tree);
-                       if (op==PLUS)
-                               goto ins;
-               }
-       }
-       d = degree(tree);
-       for (i=0; i<list->nextl; i++) {
-               if ((d1=degree(list->llist[i]))<d) {
-                       t = list->llist[i];
-                       list->llist[i] = tree;
-                       tree = t;
-                       d = d1;
-               }
-       }
-       list->llist[list->nextl++] = tree;
-}
-
-tnode(op, type, tr1, tr2)
-struct tnode *tr1, *tr2;
-{
-       register struct tnode *p;
-
-       p = getblk(sizeof(*p));
-       p->op = op;
-       p->type = type;
-       p->degree = 0;
-       p->tr1 = tr1;
-       if (opdope[op]&BINARY)
-               p->tr2 = tr2;
-       else
-               p->tr2 = NULL;
-       return(p);
-}
-
-tconst(val, type)
-{
-       register struct tconst *p;
-
-       p = getblk(sizeof(*p));
-       p->op = CON;
-       p->type = type;
-       p->value = val;
-       return(p);
-}
-
-getblk(size)
-{
-       register *p;
-
-       if (size&01)
-               abort();
-       p = curbase;
-       if ((curbase =+ size) >= coremax) {
-               if (sbrk(1024) == -1) {
-                       error("Out of space-- c1");
-                       exit(1);
-               }
-               coremax =+ 1024;
-       }
-       return(p);
-}
-
-islong(t)
-{
-       if (t==LONG)
-               return(2);
-       return(1);
-}
-
-isconstant(at)
-struct tnode *at;
-{
-       register struct tnode *t;
-
-       t = at;
-       if (t->op==CON || t->op==SFCON)
-               return(t);
-       if (t->op==ITOL && t->tr1->op==CON)
-               return(t->tr1);
-       return(0);
-}
-
-hardlongs(at)
-struct tnode *at;
-{
-       register struct tnode *t;
-
-       t = at;
-       switch(t->op) {
-
-       case TIMES:
-       case DIVIDE:
-       case MOD:
-               t->op =+ LTIMES-TIMES;
-               break;
-
-       case ASTIMES:
-       case ASDIV:
-       case ASMOD:
-               t->op =+ LASTIMES-ASTIMES;
-               t->tr1 = tnode(AMPER, LONG+PTR, t->tr1);
-               break;
-
-       default:
-               return(t);
-       }
-       return(optim(t));
-}
diff --git a/usr/src/cmd/c/c13.c b/usr/src/cmd/c/c13.c
deleted file mode 100644 (file)
index 0af8ae7..0000000
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- * C second pass -- tables
- */
-#include "c1.h"
-/*
- * Operator dope table-- see description in c0.
- */
-int opdope[] {
-       000000, /* EOFC */
-       000000, /* ; */
-       000000, /* { */
-       000000, /* } */
-       036000, /* [ */
-       002000, /* ] */
-       036000, /* ( */
-       002000, /* ) */
-       014201, /* : */
-       007001, /* , */
-       000000, /* field selection */
-       000000, /* reverse field selection */
-       000001, /* temporary field selection */
-       000001, /* int->ptr */
-       000001, /* ptr->int */
-       000001, /* long->ptr */
-       000001, /* field assignment */
-       000001, /* >> unsigned */
-       000001, /* >> unsigned */
-       000000, /* 19 */
-       000400, /* name */
-       000400, /* short constant */
-       000400, /* string */
-       000400, /* float */
-       000400, /* double */
-       0000400,        /* long const */
-       000400, /* long const <= 16 bits */
-       000400, /* autoi, *r++ */
-       000400, /* autod, *--r */
-       000000, /* 29 */
-       034203, /* ++pre */
-       034203, /* --pre */
-       034203, /* ++post */
-       034203, /* --post */
-       034220, /* !un */
-       034202, /* &un */
-       034220, /* *un */
-       034200, /* -un */
-       034220, /* ~un */
-       036001, /* . (structure reference) */
-       030101, /* + */
-       030001, /* - */
-       032101, /* * */
-       032001, /* / */
-       032001, /* % */
-       026061, /* >> */
-       026061, /* << */
-       020161, /* & */
-       016161, /* | */
-       016161, /* ^ */
-       036001, /* -> */
-       001000, /* int -> double */
-       001000, /* double -> int */
-       000001, /* && */
-       000001, /* || */
-       030001, /* &~ */
-       001000, /* double -> long */
-       001000, /* long -> double */
-       001000, /* integer -> long */
-       000000, /* long -> integer */
-       022005, /* == */
-       022005, /* != */
-       024005, /* <= */
-       024005, /* < */
-       024005, /* >= */
-       024005, /* > */
-       024005, /* <p */
-       024005, /* <=p */
-       024005, /* >p */
-       024005, /* >=p */
-       012213, /* =+ */
-       012213, /* =- */
-       012213, /* =* */
-       012213, /* =/ */
-       012213, /* =% */
-       012253, /* =>> */
-       012253, /* =<< */
-       012253, /* =& */
-       012253, /* =| */
-       012253, /* =^ */
-       012213, /* = */
-       030001, /* & for tests */
-       032001, /*  * (long) */
-       032001, /*  / (long) */
-       032001, /* % (long) */
-       012253, /* =& ~ */
-       012213, /* =* (long) */
-       012213, /* / (long) */
-       012213, /* % (long) */
-       000000, /* 89 */
-       014201, /* ? */
-       026061, /* long << */
-       012253, /* long =<< */
-       000101, /* max */
-       000101, /* maxp */
-       000101, /* min */
-       000101, /* minp */
-       000001, /* , */
-       000000, /* 98 */
-       000000, /* 99 */
-       036001, /* call */
-       036000, /* mcall */
-       000000, /* goto */
-       000000, /* jump cond */
-       000000, /* branch cond */
-       000400, /* set nregs */
-       000000, /* 106 */
-       000000, /* 107 */
-       000000, /* 108 */
-       000000, /* int->char */
-       000000, /* force r0 */
-       000000, /* 111 */
-       000000, /* 112 */
-       000000, /* 113 */
-       000000, /* 114 */
-       000000, /* structure assign */
-       000001, /* struct assignment setup */
-};
-
-char   *opntab[] {
-       0,
-       0,
-       0,
-       0,
-       0,
-       0,
-       0,
-       0,
-       ":",
-       ",",
-       "field select",
-       0,
-       0,
-       "int->ptr",
-       "ptr->int",
-       "long->ptr",
-       "field assign",
-       ">>",
-       ">>",
-       0,
-       "name",
-       "short constant",
-       "string",
-       "float",
-       "double",
-       "long constant",
-       "long constant",
-       "*r++",
-       "*--r",
-       0,
-       "++pre",
-       "--pre",
-       "++post",
-       "--post",
-       "!un",
-       "&",
-       "*",
-       "-",
-       "~",
-       ".",
-       "+",
-       "-",
-       "*",
-       "/",
-       "%",
-       ">>",
-       "<<",
-       "&",
-       "|",
-       "^",
-       "->",
-       "int->double",
-       "double->int",
-       "&&",
-       "||",
-       "&~",
-       "double->long",
-       "long->double",
-       "integer->long",
-       "long->integer",
-       "==",
-       "!=",
-       "<=",
-       "<",
-       ">=",
-       ">",
-       "<p",
-       "<=p",
-       ">p",
-       ">=p",
-       "+=",
-       "-=",
-       "*=",
-       "/=",
-       "%=",
-       ">>=",
-       "<<=",
-       "&=",
-       "|=",
-       "^=",
-       "=",
-       "& for tests",
-       "*",
-       "/",
-       "%",
-       "&= ~",
-       "*=",
-       "/=",
-       "%=",
-       0,
-       "?",
-       "<<",
-       "<<=",
-       "\\/",
-       "\\/",
-       "/\\",
-       "/\\",
-       0,
-       "call",
-       "call",
-       "call",
-       0,
-       "goto",
-       "jump cond",
-       "branch cond",
-       "set nregs",
-       "load value",
-       0,
-       0,
-       "int->char",
-       "force register",
-       "",
-       "",
-       "",
-       "",
-       "=structure",
-       "= (struct setup)",
-};
-
-/*
- * Strings for instruction tables.
- */
-char   mov[]   "mov";
-char   clr[]   "clr";
-char   cmp[]   "cmp";
-char   tst[]   "tst";
-char   add[]   "add";
-char   sub[]   "sub";
-char   inc[]   "inc";
-char   dec[]   "dec";
-char   mul[]   "mul";
-char   div[]   "div";
-char   asr[]   "asr";
-char   ash[]   "ash";
-char   asl[]   "asl";
-char   bic[]   "bic";
-char   bic1[]  "bic $1,";
-char   bit[]   "bit";
-char   bit1[]  "bit $1,";
-char   bis[]   "bis";
-char   bis1[]  "bis $1,";
-char   xor[]   "xor";
-char   neg[]   "neg";
-char   com[]   "com";
-char   stdol[] "*$";
-char   ashc[]  "ashc";
-char   slmul[] "lmul";
-char   sldiv[] "ldiv";
-char   slrem[] "lrem";
-char   almul[] "almul";
-char   aldiv[] "aldiv";
-char   alrem[] "alrem";
-char   jeq[]   "jeq";
-char   jne[]   "jne";
-char   jle[]   "jle";
-char   jgt[]   "jgt";
-char   jlt[]   "jlt";
-char   jge[]   "jge";
-char   jlos[]  "jlos";
-char   jhi[]   "jhi";
-char   jlo[]   "jlo";
-char   jhis[]  "jhis";
-char   nop[]   "/nop";
-char   jbr[]   "jbr";
-
-/*
- * Instruction tables, accessed by
- * I (first operand) or I' (second) macros.
- */
-
-struct instab instab[] {
-       LOAD,   mov,    tst,
-       ASSIGN, mov,    clr,
-       EQUAL,  cmp,    tst,
-       NEQUAL, cmp,    tst,
-       LESSEQ, cmp,    tst,
-       LESS,   cmp,    tst,
-       GREATEQ,cmp,    tst,
-       GREAT,  cmp,    tst,
-       LESSEQP,cmp,    tst,
-       LESSP,  cmp,    tst,
-       GREATQP,cmp,    tst,
-       GREATP, cmp,    tst,
-       PLUS,   add,    inc,
-       ASPLUS, add,    inc,
-       MINUS,  sub,    dec,
-       ASMINUS,sub,    dec,
-       INCBEF, add,    inc,
-       DECBEF, sub,    dec,
-       INCAFT, add,    inc,
-       DECAFT, sub,    dec,
-       TIMES,  mul,    mul,
-       ASTIMES,mul,    mul,
-       DIVIDE, div,    div,
-       ASDIV,  div,    div,
-       MOD,    div,    div,
-       ASMOD,  div,    div,
-       PTOI,   div,    div,
-       RSHIFT, ash,    asr,
-       ASRSH,  ash,    asr,
-       LSHIFT, ash,    asl,
-       ASLSH,  ash,    asl,
-       AND,    bic,    bic1,
-       ANDN,   bic,    bic1,
-       ASANDN, bic,    bic1,
-       TAND,   bit,    bit1,
-       OR,     bis,    bis1,
-       ASOR,   bis,    bis1,
-       EXOR,   xor,    xor,
-       ASXOR,  xor,    xor,
-       NEG,    neg,    neg,
-       COMPL,  com,    com,
-       CALL1,  stdol,  stdol,
-       CALL2,  "",     "",
-       LLSHIFT,ashc,   ashc,
-       ASLSHL, ashc,   ashc,
-       LTIMES, slmul,  slmul,
-       LDIV,   sldiv,  sldiv,
-       LMOD,   slrem,  slrem,
-       LASTIMES,almul, almul,
-       LASDIV, aldiv,  aldiv,
-       LASMOD, alrem,  alrem,
-       ULSH,   ashc,   ashc,
-       ASULSH, ashc,   ashc,
-       0,      0,      0};
-
-/*
- * Similar table for relationals.
- * The first string is for the positive
- * test, the second for the inverted one.
- * The '200+' entries are 
- * used in tests against 0 where a 'tst'
- * instruction is used; it clears the c-bit
- * the c-bit so ptr tests are funny.
- */
-struct instab branchtab[] {
-       EQUAL,  jeq,    jne,
-       NEQUAL, jne,    jeq,
-       LESSEQ, jle,    jgt,
-       LESS,   jlt,    jge,
-       GREATEQ,jge,    jlt,
-       GREAT,  jgt,    jle,
-       LESSEQP,jlos,   jhi,
-       LESSP,  jlo,    jhis,
-       GREATQP,jhis,   jlo,
-       GREATP, jhi,    jlos,
-       200+EQUAL,      jeq,    jne,
-       200+NEQUAL,     jne,    jeq,
-       200+LESSEQ,     jle,    jgt,
-       200+LESS,       jlt,    jge,
-       200+GREATEQ,    jge,    jlt,
-       200+GREAT,      jgt,    jle,
-       200+LESSEQP,    jeq,    jne,
-       200+LESSP,      nop,    jbr,
-       200+GREATQP,    jbr,    nop,
-       200+GREATP,     jne,    jeq,
-       0,      0,      0 };
diff --git a/usr/src/cmd/c/c2.h b/usr/src/cmd/c/c2.h
deleted file mode 100644 (file)
index 5a8c587..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Header for object code improver
- */
-
-#include <stdio.h>
-
-#define        JBR     1
-#define        CBR     2
-#define        JMP     3
-#define        LABEL   4
-#define        DLABEL  5
-#define        EROU    7
-#define        JSW     9
-#define        MOV     10
-#define        CLR     11
-#define        COM     12
-#define        INC     13
-#define        DEC     14
-#define        NEG     15
-#define        TST     16
-#define        ASR     17
-#define        ASL     18
-#define        SXT     19
-#define        CMP     20
-#define        ADD     21
-#define        SUB     22
-#define        BIT     23
-#define        BIC     24
-#define        BIS     25
-#define        MUL     26
-#define        DIV     27
-#define        ASH     28
-#define        XOR     29
-#define        TEXT    30
-#define        DATA    31
-#define        BSS     32
-#define        EVEN    33
-#define        MOVF    34
-#define        MOVOF   35
-#define        MOVFO   36
-#define        ADDF    37
-#define        SUBF    38
-#define        DIVF    39
-#define        MULF    40
-#define        CLRF    41
-#define        CMPF    42
-#define        NEGF    43
-#define        TSTF    44
-#define        CFCC    45
-#define        SOB     46
-#define        JSR     47
-#define        END     48
-
-#define        JEQ     0
-#define        JNE     1
-#define        JLE     2
-#define        JGE     3
-#define        JLT     4
-#define        JGT     5
-#define        JLO     6
-#define        JHI     7
-#define        JLOS    8
-#define        JHIS    9
-
-#define        BYTE    100
-#define        LSIZE   512
-
-struct node {
-       char    op;
-       char    subop;
-       struct  node    *forw;
-       struct  node    *back;
-       struct  node    *ref;
-       int     labno;
-       char    *code;
-       int     refc;
-};
-
-struct optab {
-       char    *opstring;
-       int     opcode;
-} optab[];
-
-char   line[LSIZE];
-struct node    first;
-char   *curlp;
-int    nbrbr;
-int    nsaddr;
-int    redunm;
-int    iaftbr;
-int    njp1;
-int    nrlab;
-int    nxjump;
-int    ncmot;
-int    nrevbr;
-int    loopiv;
-int    nredunj;
-int    nskip;
-int    ncomj;
-int    nsob;
-int    nrtst;
-int    nlit;
-
-int    nchange;
-int    isn;
-int    debug;
-int    lastseg;
-char   *lasta;
-char   *lastr;
-char   *firstr;
-char   revbr[];
-char   regs[12][20];
-char   conloc[20];
-char   conval[20];
-char   ccloc[20];
-
-#define        RT1     10
-#define        RT2     11
-#define        FREG    5
-#define        NREG    5
-#define        LABHS   127
-#define        OPHS    57
-
-struct optab *ophash[OPHS];
-struct node *nonlab();
-char   *copy();
-char   *sbrk();
-char   *findcon();
-struct node *insertl();
-struct node *codemove();
-char   *sbrk();
-char   *alloc();
diff --git a/usr/src/cmd/c/c20.c b/usr/src/cmd/c/c20.c
deleted file mode 100644 (file)
index 8bee9fe..0000000
+++ /dev/null
@@ -1,695 +0,0 @@
-#
-/*
- *      C object code improver
- */
-
-#include "c2.h"
-
-struct optab optab[] {
-       "jbr",  JBR,
-       "jeq",  CBR | JEQ<<8,
-       "jne",  CBR | JNE<<8,
-       "jle",  CBR | JLE<<8,
-       "jge",  CBR | JGE<<8,
-       "jlt",  CBR | JLT<<8,
-       "jgt",  CBR | JGT<<8,
-       "jlo",  CBR | JLO<<8,
-       "jhi",  CBR | JHI<<8,
-       "jlos", CBR | JLOS<<8,
-       "jhis", CBR | JHIS<<8,
-       "jmp",  JMP,
-       ".globl",EROU,
-       "mov",  MOV,
-       "clr",  CLR,
-       "com",  COM,
-       "inc",  INC,
-       "dec",  DEC,
-       "neg",  NEG,
-       "tst",  TST,
-       "asr",  ASR,
-       "asl",  ASL,
-       "sxt",  SXT,
-       "cmp",  CMP,
-       "add",  ADD,
-       "sub",  SUB,
-       "bit",  BIT,
-       "bic",  BIC,
-       "bis",  BIS,
-       "mul",  MUL,
-       "ash",  ASH,
-       "xor",  XOR,
-       ".text",TEXT,
-       ".data",DATA,
-       ".bss", BSS,
-       ".even",EVEN,
-       "movf", MOVF,
-       "movof",MOVOF,
-       "movfo",MOVFO,
-       "addf", ADDF,
-       "subf", SUBF,
-       "divf", DIVF,
-       "mulf", MULF,
-       "clrf", CLRF,
-       "cmpf", CMPF,
-       "negf", NEGF,
-       "tstf", TSTF,
-       "cfcc", CFCC,
-       "sob",  SOB,
-       "jsr",  JSR,
-       ".end", END,
-       0,      0};
-
-char   revbr[] { JNE, JEQ, JGT, JLT, JGE, JLE, JHIS, JLOS, JHI, JLO };
-int    isn     = 20000;
-int    lastseg = -1;
-
-main(argc, argv)
-char **argv;
-{
-       register int niter, maxiter, isend;
-       extern end;
-       int nflag;
-
-       if (argc>1 && argv[1][0]=='+') {
-               argc--;
-               argv++;
-               debug++;
-       }
-       nflag = 0;
-       if (argc>1 && argv[1][0]=='-') {
-               argc--;
-               argv++;
-               nflag++;
-       }
-       if (argc>1) {
-               if (freopen(argv[1], "r", stdin) == NULL) {
-                       fprintf(stderr, "C2: can't find %s\n", argv[1]);
-                       exit(1);
-               }
-       }
-       if (argc>2) {
-               if (freopen(argv[2], "w", stdout) == NULL) {
-                       fprintf(stderr, "C2: can't create %s\n", argv[2]);
-                       exit(1);
-               }
-       }
-       lasta = firstr = lastr = sbrk(2);
-       maxiter = 0;
-       opsetup();
-       do {
-               isend = input();
-               movedat();
-               niter = 0;
-               do {
-                       refcount();
-                       do {
-                               iterate();
-                               clearreg();
-                               niter++;
-                       } while (nchange);
-                       comjump();
-                       rmove();
-               } while (nchange || jumpsw());
-               addsob();
-               output();
-               if (niter > maxiter)
-                       maxiter = niter;
-               lasta = firstr;
-       } while (isend);
-       if (nflag) {
-               fprintf(stderr, "%d iterations\n", maxiter);
-               fprintf(stderr, "%d jumps to jumps\n", nbrbr);
-               fprintf(stderr, "%d inst. after jumps\n", iaftbr);
-               fprintf(stderr, "%d jumps to .+2\n", njp1);
-               fprintf(stderr, "%d redundant labels\n", nrlab);
-               fprintf(stderr, "%d cross-jumps\n", nxjump);
-               fprintf(stderr, "%d code motions\n", ncmot);
-               fprintf(stderr, "%d branches reversed\n", nrevbr);
-               fprintf(stderr, "%d redundant moves\n", redunm);
-               fprintf(stderr, "%d simplified addresses\n", nsaddr);
-               fprintf(stderr, "%d loops inverted\n", loopiv);
-               fprintf(stderr, "%d redundant jumps\n", nredunj);
-               fprintf(stderr, "%d common seqs before jmp's\n", ncomj);
-               fprintf(stderr, "%d skips over jumps\n", nskip);
-               fprintf(stderr, "%d sob's added\n", nsob);
-               fprintf(stderr, "%d redundant tst's\n", nrtst);
-               fprintf(stderr, "%d literals eliminated\n", nlit);
-               fprintf(stderr, "%dK core\n", (((int)lastr+01777)>>10)&077);
-       }
-       exit(0);
-}
-
-input()
-{
-       register struct node *p, *lastp;
-       register int oper;
-
-       lastp = &first;
-       for (;;) {
-               oper = getline();
-               switch (oper&0377) {
-       
-               case LABEL:
-                       p = (struct node *)alloc(sizeof first);
-                       if (line[0] == 'L') {
-                               p->op = LABEL;
-                               p->subop = 0;
-                               p->labno = getnum(line+1);
-                               p->code = 0;
-                       } else {
-                               p->op = DLABEL;
-                               p->subop = 0;
-                               p->labno = 0;
-                               p->code = copy(1, line);
-                       }
-                       break;
-       
-               case JBR:
-               case CBR:
-               case JMP:
-               case JSW:
-                       p = (struct node *)alloc(sizeof first);
-                       p->op = oper&0377;
-                       p->subop = oper>>8;
-                       if (*curlp=='L' && (p->labno = getnum(curlp+1)))
-                               p->code = 0;
-                       else {
-                               p->labno = 0;
-                               p->code = copy(1, curlp);
-                       }
-                       break;
-
-               default:
-                       p = (struct node *)alloc(sizeof first);
-                       p->op = oper&0377;
-                       p->subop = oper>>8;
-                       p->labno = 0;
-                       p->code = copy(1, curlp);
-                       break;
-
-               }
-               p->forw = 0;
-               p->back = lastp;
-               lastp->forw = p;
-               lastp = p;
-               p->ref = 0;
-               if (oper==EROU)
-                       return(1);
-               if (oper==END)
-                       return(0);
-       }
-}
-
-getline()
-{
-       register char *lp;
-       register c;
-
-       lp = line;
-       while ((c = getchar())==' ' || c=='\t')
-               ;
-       do {
-               if (c==':') {
-                       *lp++ = 0;
-                       return(LABEL);
-               }
-               if (c=='\n') {
-                       *lp++ = 0;
-                       return(oplook());
-               }
-               if (lp >= &line[LSIZE-2]) {
-                       fprintf(stderr, "C2: Sorry, input line too long\n");
-                       exit(1);
-               }
-               *lp++ = c;
-       } while ((c = getchar()) != EOF);
-       *lp++ = 0;
-       return(END);
-}
-
-getnum(ap)
-char *ap;
-{
-       register char *p;
-       register n, c;
-
-       p = ap;
-       n = 0;
-       while ((c = *p++) >= '0' && c <= '9')
-               n = n*10 + c - '0';
-       if (*--p != 0)
-               return(0);
-       return(n);
-}
-
-output()
-{
-       register struct node *t;
-       register struct optab *oper;
-       register int byte;
-
-       t = &first;
-       while (t = t->forw) switch (t->op) {
-
-       case END:
-               return;
-
-       case LABEL:
-               printf("L%d:", t->labno);
-               continue;
-
-       case DLABEL:
-               printf("%s:", t->code);
-               continue;
-
-       case TEXT:
-       case DATA:
-       case BSS:
-               lastseg = t->op;
-
-       default:
-               if ((byte = t->subop) == BYTE)
-                       t->subop = 0;
-               for (oper = optab; oper->opstring!=0; oper++) 
-                       if ((oper->opcode&0377) == t->op
-                        && (oper->opcode>>8) == t->subop) {
-                               printf("%s", oper->opstring);
-                               if (byte==BYTE)
-                                       printf("b");
-                               break;
-                       }
-               if (t->code) {
-                       reducelit(t);
-                       printf("\t%s\n", t->code);
-               } else if (t->op==JBR || t->op==CBR)
-                       printf("\tL%d\n", t->labno);
-               else
-                       printf("\n");
-               continue;
-
-       case JSW:
-               printf("L%d\n", t->labno);
-               continue;
-
-       case SOB:
-               printf("sob     %s", t->code);
-               if (t->labno)
-                       printf(",L%d", t->labno);
-               printf("\n");
-               continue;
-
-       case 0:
-               if (t->code)
-                       printf("%s", t->code);
-               printf("\n");
-               continue;
-       }
-}
-
-/*
- * Notice addresses of the form
- * $xx,xx(r)
- * and replace them with (pc),xx(r)
- *     -- Thanx and a tip of the Hatlo hat to Bliss-11.
- */
-reducelit(at)
-struct node *at;
-{
-       register char *c1, *c2;
-       char *c2s;
-       register struct node *t;
-
-       t = at;
-       if (*t->code != '$')
-               return;
-       c1 = t->code;
-       while (*c1 != ',')
-               if (*c1++ == '\0')
-                       return;
-       c2s = c1;
-       c1++;
-       if (*c1=='*')
-               c1++;
-       c2 = t->code+1;
-       while (*c1++ == *c2++);
-       if (*--c1!='(' || *--c2!=',')
-               return;
-       t->code = copy(2, "(pc)", c2s);
-       nlit++;
-}
-
-char *
-copy(na, ap)
-char *ap;
-{
-       register char *p, *np;
-       char *onp;
-       register n;
-
-       p = ap;
-       n = 0;
-       if (*p==0)
-               return(0);
-       do
-               n++;
-       while (*p++);
-       if (na>1) {
-               p = (&ap)[1];
-               while (*p++)
-                       n++;
-       }
-       onp = np = alloc(n);
-       p = ap;
-       while (*np++ = *p++)
-               ;
-       if (na>1) {
-               p = (&ap)[1];
-               np--;
-               while (*np++ = *p++);
-       }
-       return(onp);
-}
-
-opsetup()
-{
-       register struct optab *optp, **ophp;
-       register char *p;
-
-       for (optp = optab; p = optp->opstring; optp++) {
-               ophp = &ophash[(((p[0]<<3)+(p[1]<<1)+p[2])&077777) % OPHS];
-               while (*ophp++)
-                       if (ophp > &ophash[OPHS])
-                               ophp = ophash;
-               *--ophp = optp;
-       }
-}
-
-oplook()
-{
-       register struct optab *optp;
-       register char *lp, *np;
-       static char tmpop[32];
-       struct optab **ophp;
-
-       if (line[0]=='\0') {
-               curlp = line;
-               return(0);
-       }
-       np = tmpop;
-       for (lp = line; *lp && *lp!=' ' && *lp!='\t';)
-               *np++ = *lp++;
-       *np++ = 0;
-       while (*lp=='\t' || *lp==' ')
-               lp++;
-       curlp = lp;
-       ophp = &ophash[(((tmpop[0]<<3)+(tmpop[1]<<1)+tmpop[2])&077777) % OPHS];
-       while (optp = *ophp) {
-               np = optp->opstring;
-               lp = tmpop;
-               while (*lp == *np++)
-                       if (*lp++ == 0)
-                               return(optp->opcode);
-               if (*lp++=='b' && *lp++==0 && *--np==0)
-                       return(optp->opcode + (BYTE<<8));
-               ophp++;
-               if (ophp >= &ophash[OPHS])
-                       ophp = ophash;
-       }
-       if (line[0]=='L') {
-               lp = &line[1];
-               while (*lp)
-                       if (*lp<'0' || *lp++>'9')
-                               return(0);
-               curlp = line;
-               return(JSW);
-       }
-       curlp = line;
-       return(0);
-}
-
-refcount()
-{
-       register struct node *p, *lp;
-       static struct node *labhash[LABHS];
-       register struct node **hp, *tp;
-
-       for (hp = labhash; hp < &labhash[LABHS];)
-               *hp++ = 0;
-       for (p = first.forw; p!=0; p = p->forw)
-               if (p->op==LABEL) {
-                       labhash[p->labno % LABHS] = p;
-                       p->refc = 0;
-               }
-       for (p = first.forw; p!=0; p = p->forw) {
-               if (p->op==JBR || p->op==CBR || p->op==JSW) {
-                       p->ref = 0;
-                       lp = labhash[p->labno % LABHS];
-                       if (lp==0 || p->labno!=lp->labno)
-                       for (lp = first.forw; lp!=0; lp = lp->forw) {
-                               if (lp->op==LABEL && p->labno==lp->labno)
-                                       break;
-                       }
-                       if (lp) {
-                               tp = nonlab(lp)->back;
-                               if (tp!=lp) {
-                                       p->labno = tp->labno;
-                                       lp = tp;
-                               }
-                               p->ref = lp;
-                               lp->refc++;
-                       }
-               }
-       }
-       for (p = first.forw; p!=0; p = p->forw)
-               if (p->op==LABEL && p->refc==0
-                && (lp = nonlab(p))->op && lp->op!=JSW)
-                       decref(p);
-}
-
-iterate()
-{
-       register struct node *p, *rp, *p1;
-
-       nchange = 0;
-       for (p = first.forw; p!=0; p = p->forw) {
-               if ((p->op==JBR||p->op==CBR||p->op==JSW) && p->ref) {
-                       rp = nonlab(p->ref);
-                       if (rp->op==JBR && rp->labno && p->labno!=rp->labno) {
-                               nbrbr++;
-                               p->labno = rp->labno;
-                               decref(p->ref);
-                               rp->ref->refc++;
-                               p->ref = rp->ref;
-                               nchange++;
-                       }
-               }
-               if (p->op==CBR && (p1 = p->forw)->op==JBR) {
-                       rp = p->ref;
-                       do
-                               rp = rp->back;
-                       while (rp->op==LABEL);
-                       if (rp==p1) {
-                               decref(p->ref);
-                               p->ref = p1->ref;
-                               p->labno = p1->labno;
-                               p1->forw->back = p;
-                               p->forw = p1->forw;
-                               p->subop = revbr[p->subop];
-                               nchange++;
-                               nskip++;
-                       }
-               }
-               if (p->op==JBR || p->op==JMP) {
-                       while (p->forw && p->forw->op!=LABEL
-                               && p->forw->op!=DLABEL
-                               && p->forw->op!=EROU && p->forw->op!=END
-                               && p->forw->op!=0 && p->forw->op!=DATA) {
-                               nchange++;
-                               iaftbr++;
-                               if (p->forw->ref)
-                                       decref(p->forw->ref);
-                               p->forw = p->forw->forw;
-                               p->forw->back = p;
-                       }
-                       rp = p->forw;
-                       while (rp && rp->op==LABEL) {
-                               if (p->ref == rp) {
-                                       p->back->forw = p->forw;
-                                       p->forw->back = p->back;
-                                       p = p->back;
-                                       decref(rp);
-                                       nchange++;
-                                       njp1++;
-                                       break;
-                               }
-                               rp = rp->forw;
-                       }
-               }
-               if (p->op==JBR || p->op==JMP) {
-                       xjump(p);
-                       p = codemove(p);
-               }
-       }
-}
-
-xjump(p1)
-register struct node *p1;
-{
-       register struct node *p2, *p3;
-
-       if ((p2 = p1->ref)==0)
-               return;
-       for (;;) {
-               while ((p1 = p1->back) && p1->op==LABEL);
-               while ((p2 = p2->back) && p2->op==LABEL);
-               if (!equop(p1, p2) || p1==p2)
-                       return;
-               p3 = insertl(p2);
-               p1->op = JBR;
-               p1->subop = 0;
-               p1->ref = p3;
-               p1->labno = p3->labno;
-               p1->code = 0;
-               nxjump++;
-               nchange++;
-       }
-}
-
-struct node *
-insertl(oldp)
-register struct node *oldp;
-{
-       register struct node *lp;
-
-       if (oldp->op == LABEL) {
-               oldp->refc++;
-               return(oldp);
-       }
-       if (oldp->back->op == LABEL) {
-               oldp = oldp->back;
-               oldp->refc++;
-               return(oldp);
-       }
-       lp = (struct node *)alloc(sizeof first);
-       lp->op = LABEL;
-       lp->subop = 0;
-       lp->labno = isn++;
-       lp->ref = 0;
-       lp->code = 0;
-       lp->refc = 1;
-       lp->back = oldp->back;
-       lp->forw = oldp;
-       oldp->back->forw = lp;
-       oldp->back = lp;
-       return(lp);
-}
-
-struct node *
-codemove(p)
-struct node *p;
-{
-       register struct node *p1, *p2, *p3;
-       struct node *t, *tl;
-       int n;
-
-       p1 = p;
-       if (p1->op!=JBR || (p2 = p1->ref)==0)
-               return(p1);
-       while (p2->op == LABEL)
-               if ((p2 = p2->back) == 0)
-                       return(p1);
-       if (p2->op!=JBR && p2->op!=JMP)
-               goto ivloop;
-       p2 = p2->forw;
-       p3 = p1->ref;
-       while (p3) {
-               if (p3->op==JBR || p3->op==JMP) {
-                       if (p1==p3)
-                               return(p1);
-                       ncmot++;
-                       nchange++;
-                       p1->back->forw = p2;
-                       p1->forw->back = p3;
-                       p2->back->forw = p3->forw;
-                       p3->forw->back = p2->back;
-                       p2->back = p1->back;
-                       p3->forw = p1->forw;
-                       decref(p1->ref);
-                       return(p2);
-               } else
-                       p3 = p3->forw;
-       }
-       return(p1);
-ivloop:
-       if (p1->forw->op!=LABEL)
-               return(p1);
-       p3 = p2 = p2->forw;
-       n = 16;
-       do {
-               if ((p3 = p3->forw) == 0 || p3==p1 || --n==0)
-                       return(p1);
-       } while (p3->op!=CBR || p3->labno!=p1->forw->labno);
-       do 
-               if ((p1 = p1->back) == 0)
-                       return(p);
-       while (p1!=p3);
-       p1 = p;
-       tl = insertl(p1);
-       p3->subop = revbr[p3->subop];
-       decref(p3->ref);
-       p2->back->forw = p1;
-       p3->forw->back = p1;
-       p1->back->forw = p2;
-       p1->forw->back = p3;
-       t = p1->back;
-       p1->back = p2->back;
-       p2->back = t;
-       t = p1->forw;
-       p1->forw = p3->forw;
-       p3->forw = t;
-       p2 = insertl(p1->forw);
-       p3->labno = p2->labno;
-       p3->ref = p2;
-       decref(tl);
-       if (tl->refc<=0)
-               nrlab--;
-       loopiv++;
-       nchange++;
-       return(p3);
-}
-
-comjump()
-{
-       register struct node *p1, *p2, *p3;
-
-       for (p1 = first.forw; p1!=0; p1 = p1->forw)
-               if (p1->op==JBR && (p2 = p1->ref) && p2->refc > 1)
-                       for (p3 = p1->forw; p3!=0; p3 = p3->forw)
-                               if (p3->op==JBR && p3->ref == p2)
-                                       backjmp(p1, p3);
-}
-
-backjmp(ap1, ap2)
-struct node *ap1, *ap2;
-{
-       register struct node *p1, *p2, *p3;
-
-       p1 = ap1;
-       p2 = ap2;
-       for(;;) {
-               while ((p1 = p1->back) && p1->op==LABEL);
-               p2 = p2->back;
-               if (equop(p1, p2)) {
-                       p3 = insertl(p1);
-                       p2->back->forw = p2->forw;
-                       p2->forw->back = p2->back;
-                       p2 = p2->forw;
-                       decref(p2->ref);
-                       p2->labno = p3->labno;
-                       p2->ref = p3;
-                       nchange++;
-                       ncomj++;
-               } else
-                       return;
-       }
-}
diff --git a/usr/src/cmd/c/c21.c b/usr/src/cmd/c/c21.c
deleted file mode 100644 (file)
index 267c824..0000000
+++ /dev/null
@@ -1,791 +0,0 @@
-#
-/*
- * C object code improver-- second part
- */
-
-#include "c2.h"
-
-rmove()
-{
-       register struct node *p;
-       register int r;
-       register  r1, flt;
-
-       for (p=first.forw; p!=0; p = p->forw) {
-       flt = 0;
-       switch (p->op) {
-
-       case MOVF:
-       case MOVFO:
-       case MOVOF:
-               flt = NREG;
-
-       case MOV:
-               if (p->subop==BYTE)
-                       goto dble;
-               dualop(p);
-               if ((r = findrand(regs[RT1], flt)) >= 0) {
-                       if (r == flt+isreg(regs[RT2]) && p->forw->op!=CBR
-                          && p->forw->op!=SXT
-                          && p->forw->op!=CFCC) {
-                               p->forw->back = p->back;
-                               p->back->forw = p->forw;
-                               redunm++;
-                               continue;
-                       }
-               }
-               if (equstr(regs[RT1], "$0")) {
-                       p->op = CLR;
-                       strcpy(regs[RT1], regs[RT2]);
-                       regs[RT2][0] = 0;
-                       p->code = copy(1, regs[RT1]);
-                       goto sngl;
-               }
-               repladdr(p, 0, flt);
-               r = isreg(regs[RT1]);
-               r1 = isreg(regs[RT2]);
-               dest(regs[RT2], flt);
-               if (r >= 0)
-                       if (r1 >= 0)
-                               savereg(r1+flt, regs[r+flt]);
-                       else
-                               savereg(r+flt, regs[RT2]);
-               else
-                       if (r1 >= 0)
-                               savereg(r1+flt, regs[RT1]);
-                       else
-                               setcon(regs[RT1], regs[RT2]);
-               source(regs[RT1]);
-               setcc(regs[RT2]);
-               continue;
-
-       case ADDF:
-       case SUBF:
-       case DIVF:
-       case MULF:
-               flt = NREG;
-               goto dble;
-
-       case ADD:
-       case SUB:
-       case BIC:
-       case BIS:
-       case MUL:
-       case DIV:
-       case ASH:
-       dble:
-               dualop(p);
-               if (p->op==BIC && (equstr(regs[RT1], "$-1") || equstr(regs[RT1], "$177777"))) {
-                       p->op = CLR;
-                       strcpy(regs[RT1], regs[RT2]);
-                       regs[RT2][0] = 0;
-                       p->code = copy(1, regs[RT1]);
-                       goto sngl;
-               }
-               if ((p->op==BIC || p->op==BIS) && equstr(regs[RT1], "$0")) {
-                       if (p->forw->op!=CBR) {
-                               p->back->forw = p->forw;
-                               p->forw->back = p->back;
-                               continue;
-                       }
-               }
-               repladdr(p, 0, flt);
-               source(regs[RT1]);
-               dest(regs[RT2], flt);
-               if (p->op==DIV && (r = isreg(regs[RT2])>=0))
-                       regs[r+1][0] = 0;
-               ccloc[0] = 0;
-               continue;
-
-       case CLRF:
-       case NEGF:
-               flt = NREG;
-
-       case CLR:
-       case COM:
-       case INC:
-       case DEC:
-       case NEG:
-       case ASR:
-       case ASL:
-       case SXT:
-               singop(p);
-       sngl:
-               dest(regs[RT1], flt);
-               if (p->op==CLR && flt==0)
-                       if ((r = isreg(regs[RT1])) >= 0)
-                               savereg(r, "$0");
-                       else
-                               setcon("$0", regs[RT1]);
-               ccloc[0] = 0;
-               continue;
-
-       case TSTF:
-               flt = NREG;
-
-       case TST:
-               singop(p);
-               repladdr(p, 0, flt);
-               source(regs[RT1]);
-               if (equstr(regs[RT1], ccloc)) {
-                       p->back->forw = p->forw;
-                       p->forw->back = p->back;
-                       p = p->back;
-                       nrtst++;
-                       nchange++;
-               }
-               continue;
-
-       case CMPF:
-               flt = NREG;
-
-       case CMP:
-       case BIT:
-               dualop(p);
-               source(regs[RT1]);
-               source(regs[RT2]);
-               if(p->op==BIT) {
-                       if (equstr(regs[RT1], "$-1") || equstr(regs[RT1], "$177777")) {
-                               p->op = TST;
-                               strcpy(regs[RT1], regs[RT2]);
-                               regs[RT2][0] = 0;
-                               p->code = copy(1, regs[RT1]);
-                               nchange++;
-                               nsaddr++;
-                       } else if (equstr(regs[RT2], "$-1") || equstr(regs[RT2], "$177777")) {
-                               p->op = TST;
-                               regs[RT2][0] = 0;
-                               p->code = copy(1, regs[RT1]);
-                               nchange++;
-                               nsaddr++;
-                       }
-                       if (equstr(regs[RT1], "$0")) {
-                               p->op = TST;
-                               regs[RT2][0] = 0;
-                               p->code = copy(1, regs[RT1]);
-                               nchange++;
-                               nsaddr++;
-                       } else if (equstr(regs[RT2], "$0")) {
-                               p->op = TST;
-                               strcpy(regs[RT1], regs[RT2]);
-                               regs[RT2][0] = 0;
-                               p->code = copy(1, regs[RT1]);
-                               nchange++;
-                               nsaddr++;
-                       }
-               }
-               repladdr(p, 1, flt);
-               ccloc[0] = 0;
-               continue;
-
-       case CBR:
-               if (p->back->op==TST || p->back->op==CMP) {
-                       if (p->back->op==TST) {
-                               singop(p->back);
-                               savereg(RT2, "$0");
-                       } else
-                               dualop(p->back);
-                       r = compare(p->subop, findcon(RT1), findcon(RT2));
-                       if (r==0) {
-                               p->back->back->forw = p->forw;
-                               p->forw->back = p->back->back;
-                               decref(p->ref);
-                               p = p->back->back;
-                               nchange++;
-                       } else if (r>0) {
-                               p->op = JBR;
-                               p->subop = 0;
-                               p->back->back->forw = p;
-                               p->back = p->back->back;
-                               p = p->back;
-                               nchange++;
-                       }
-               }
-       case CFCC:
-               ccloc[0] = 0;
-               continue;
-
-       case JBR:
-               redunbr(p);
-
-       default:
-               clearreg();
-       }
-       }
-}
-
-jumpsw()
-{
-       register struct node *p, *p1;
-       register t;
-       register struct node *tp;
-       int nj;
-
-       t = 0;
-       nj = 0;
-       for (p=first.forw; p!=0; p = p->forw)
-               p->refc = ++t;
-       for (p=first.forw; p!=0; p = p1) {
-               p1 = p->forw;
-               if (p->op == CBR && p1->op==JBR && p->ref && p1->ref
-                && abs(p->refc - p->ref->refc) > abs(p1->refc - p1->ref->refc)) {
-                       if (p->ref==p1->ref)
-                               continue;
-                       p->subop = revbr[p->subop];
-                       tp = p1->ref;
-                       p1->ref = p->ref;
-                       p->ref = tp;
-                       t = p1->labno;
-                       p1->labno = p->labno;
-                       p->labno = t;
-                       nrevbr++;
-                       nj++;
-               }
-       }
-       return(nj);
-}
-
-addsob()
-{
-       register struct node *p, *p1;
-
-       for (p = &first; (p1 = p->forw)!=0; p = p1) {
-               if (p->op==DEC && isreg(p->code)>=0
-                && p1->op==CBR && p1->subop==JNE) {
-                       if (p->refc < p1->ref->refc)
-                               continue;
-                       if (toofar(p1))
-                               continue;
-                       p->labno = p1->labno;
-                       p->op = SOB;
-                       p->subop = 0;
-                       p1->forw->back = p;
-                       p->forw = p1->forw;
-                       nsob++;
-               }
-       }
-}
-
-toofar(p)
-struct node *p;
-{
-       register struct node *p1;
-       int len;
-
-       len = 0;
-       for (p1 = p->ref; p1 && p1!=p; p1 = p1->forw)
-               len += ilen(p1);
-       if (len < 128)
-               return(0);
-       return(1);
-}
-
-ilen(p)
-register struct node *p;
-{
-       register l;
-
-       switch (p->op) {
-       case LABEL:
-       case DLABEL:
-       case TEXT:
-       case EROU:
-       case EVEN:
-               return(0);
-
-       case CBR:
-               return(6);
-
-       default:
-               dualop(p);
-               return(2 + adrlen(regs[RT1]) + adrlen(regs[RT2]));
-       }
-}
-
-adrlen(s)
-register char *s;
-{
-       if (*s == 0)
-               return(0);
-       if (*s=='r')
-               return(0);
-       if (*s=='(' && *(s+1)=='r')
-               return(0);
-       if (*s=='-' && *(s+1)=='(')
-               return(0);
-       return(2);
-}
-
-abs(x)
-{
-       return(x<0? -x: x);
-}
-
-equop(ap1, p2)
-struct node *ap1, *p2;
-{
-       register char *cp1, *cp2;
-       register struct node *p1;
-
-       p1 = ap1;
-       if (p1->op!=p2->op || p1->subop!=p2->subop)
-               return(0);
-       if (p1->op>0 && p1->op<MOV)
-               return(0);
-       cp1 = p1->code;
-       cp2 = p2->code;
-       if (cp1==0 && cp2==0)
-               return(1);
-       if (cp1==0 || cp2==0)
-               return(0);
-       while (*cp1 == *cp2++)
-               if (*cp1++ == 0)
-                       return(1);
-       return(0);
-}
-
-decref(p)
-register struct node *p;
-{
-       if (--p->refc <= 0) {
-               nrlab++;
-               p->back->forw = p->forw;
-               p->forw->back = p->back;
-       }
-}
-
-struct node *
-nonlab(p)
-struct node *p;
-{
-       while (p && p->op==LABEL)
-               p = p->forw;
-       return(p);
-}
-
-char *
-alloc(n)
-register n;
-{
-       register char *p;
-
-       n++;
-       n &= ~01;
-       if (lasta+n >= lastr) {
-               if (sbrk(2000) == (char *)-1) {
-                       fprintf(stderr, "C Optimizer: out of space\n");
-                       exit(1);
-               }
-               lastr += 2000;
-       }
-       p = lasta;
-       lasta += n;
-       return(p);
-}
-
-clearreg()
-{
-       register int i;
-
-       for (i=0; i<2*NREG; i++)
-               regs[i][0] = '\0';
-       conloc[0] = 0;
-       ccloc[0] = 0;
-}
-
-savereg(ai, as)
-char *as;
-{
-       register char *p, *s, *sp;
-
-       sp = p = regs[ai];
-       s = as;
-       if (source(s))
-               return;
-       while (*p++ = *s) {
-               if (s[0]=='(' && s[1]=='r' && s[2]<'5') {
-                       *sp = 0;
-                       return;
-               }
-               if (*s++ == ',')
-                       break;
-       }
-       *--p = '\0';
-}
-
-dest(as, flt)
-char *as;
-{
-       register char *s;
-       register int i;
-
-       s = as;
-       source(s);
-       if ((i = isreg(s)) >= 0)
-               regs[i+flt][0] = 0;
-       for (i=0; i<NREG+NREG; i++)
-               if (*regs[i]=='*' && equstr(s, regs[i]+1))
-                       regs[i][0] = 0;
-       while ((i = findrand(s, flt)) >= 0)
-               regs[i][0] = 0;
-       while (*s) {
-               if ((*s=='(' && (*(s+1)!='r' || *(s+2)!='5')) || *s++=='*') {
-                       for (i=0; i<NREG+NREG; i++) {
-                               if (regs[i][0] != '$')
-                                       regs[i][0] = 0;
-                               conloc[0] = 0;
-                       }
-                       return;
-               }
-       }
-}
-
-singop(ap)
-struct node *ap;
-{
-       register char *p1, *p2;
-
-       p1 = ap->code;
-       p2 = regs[RT1];
-       while (*p2++ = *p1++);
-       regs[RT2][0] = 0;
-}
-
-
-dualop(ap)
-struct node *ap;
-{
-       register char *p1, *p2;
-       register struct node *p;
-
-       p = ap;
-       p1 = p->code;
-       p2 = regs[RT1];
-       while (*p1 && *p1!=',')
-               *p2++ = *p1++;
-       *p2++ = 0;
-       p2 = regs[RT2];
-       *p2 = 0;
-       if (*p1++ !=',')
-               return;
-       while (*p2++ = *p1++);
-}
-
-findrand(as, flt)
-char *as;
-{
-       register int i;
-       for (i = flt; i<NREG+flt; i++) {
-               if (equstr(regs[i], as))
-                       return(i);
-       }
-       return(-1);
-}
-
-isreg(as)
-char *as;
-{
-       register char *s;
-
-       s = as;
-       if (s[0]=='r' && s[1]>='0' && s[1]<='4' && s[2]==0)
-               return(s[1]-'0');
-       return(-1);
-}
-
-check()
-{
-       register struct node *p, *lp;
-
-       lp = &first;
-       for (p=first.forw; p!=0; p = p->forw) {
-               if (p->back != lp)
-                       abort();
-               lp = p;
-       }
-}
-
-source(ap)
-char *ap;
-{
-       register char *p1, *p2;
-
-       p1 = ap;
-       p2 = p1;
-       if (*p1==0)
-               return(0);
-       while (*p2++);
-       if (*p1=='-' && *(p1+1)=='('
-        || *p1=='*' && *(p1+1)=='-' && *(p1+2)=='('
-        || *(p2-2)=='+') {
-               while (*p1 && *p1++!='r');
-               if (*p1>='0' && *p1<='4')
-                       regs[*p1 - '0'][0] = 0;
-               return(1);
-       }
-       return(0);
-}
-
-repladdr(p, f, flt)
-struct node *p;
-{
-       register r;
-       int r1;
-       register char *p1, *p2;
-       static char rt1[50], rt2[50];
-
-       if (f)
-               r1 = findrand(regs[RT2], flt);
-       else
-               r1 = -1;
-       r = findrand(regs[RT1], flt);
-       if (r1 >= NREG)
-               r1 -= NREG;
-       if (r >= NREG)
-               r -= NREG;
-       if (r>=0 || r1>=0) {
-               p2 = regs[RT1];
-               for (p1 = rt1; *p1++ = *p2++;);
-               if (regs[RT2][0]) {
-                       p1 = rt2;
-                       *p1++ = ',';
-                       for (p2 = regs[RT2]; *p1++ = *p2++;);
-               } else
-                       rt2[0] = 0;
-               if (r>=0) {
-                       rt1[0] = 'r';
-                       rt1[1] = r + '0';
-                       rt1[2] = 0;
-                       nsaddr++;
-               }
-               if (r1>=0) {
-                       rt2[1] = 'r';
-                       rt2[2] = r1 + '0';
-                       rt2[3] = 0;
-                       nsaddr++;
-               }
-               p->code = copy(2, rt1, rt2);
-       }
-}
-
-movedat()
-{
-       register struct node *p1, *p2;
-       struct node *p3;
-       register seg;
-       struct node data;
-       struct node *datp;
-
-       if (first.forw == 0)
-               return;
-       if (lastseg != TEXT && lastseg != -1) {
-               p1 = (struct node *)alloc(sizeof(first));
-               p1->op = lastseg;
-               p1->subop = 0;
-               p1->code = NULL;
-               p1->forw = first.forw;
-               p1->back = &first;
-               first.forw->back = p1;
-               first.forw = p1;
-       }
-       datp = &data;
-       for (p1 = first.forw; p1!=0; p1 = p1->forw) {
-               if (p1->op == DATA) {
-                       p2 = p1->forw;
-                       while (p2 && p2->op!=TEXT)
-                               p2 = p2->forw;
-                       if (p2==0)
-                               break;
-                       p3 = p1->back;
-                       p1->back->forw = p2->forw;
-                       p2->forw->back = p3;
-                       p2->forw = 0;
-                       datp->forw = p1;
-                       p1->back = datp;
-                       p1 = p3;
-                       datp = p2;
-               }
-       }
-       if (data.forw) {
-               datp->forw = first.forw;
-               first.forw->back = datp;
-               data.forw->back = &first;
-               first.forw = data.forw;
-       }
-       seg = lastseg;
-       for (p1 = first.forw; p1!=0; p1 = p1->forw) {
-               if (p1->op==TEXT||p1->op==DATA||p1->op==BSS) {
-                       if (p2 = p1->forw) {
-                               if (p2->op==TEXT||p2->op==DATA||p2->op==BSS)
-                                       p1->op  = p2->op;
-                       }
-                       if (p1->op == seg || p1->forw&&p1->forw->op==seg) {
-                               p1->back->forw = p1->forw;
-                               p1->forw->back = p1->back;
-                               p1 = p1->back;
-                               continue;
-                       }
-                       seg = p1->op;
-               }
-       }
-}
-
-redunbr(p)
-register struct node *p;
-{
-       register struct node *p1;
-       register char *ap1;
-       char *ap2;
-
-       if ((p1 = p->ref) == 0)
-               return;
-       p1 = nonlab(p1);
-       if (p1->op==TST) {
-               singop(p1);
-               savereg(RT2, "$0");
-       } else if (p1->op==CMP)
-               dualop(p1);
-       else
-               return;
-       if (p1->forw->op!=CBR)
-               return;
-       ap1 = findcon(RT1);
-       ap2 = findcon(RT2);
-       p1 = p1->forw;
-       if (compare(p1->subop, ap1, ap2)>0) {
-               nredunj++;
-               nchange++;
-               decref(p->ref);
-               p->ref = p1->ref;
-               p->labno = p1->labno;
-               p->ref->refc++;
-       }
-}
-
-char *
-findcon(i)
-{
-       register char *p;
-       register r;
-
-       p = regs[i];
-       if (*p=='$')
-               return(p);
-       if ((r = isreg(p)) >= 0)
-               return(regs[r]);
-       if (equstr(p, conloc))
-               return(conval);
-       return(p);
-}
-
-compare(oper, cp1, cp2)
-register char *cp1, *cp2;
-{
-       register unsigned n1, n2;
-
-       if (*cp1++ != '$' || *cp2++ != '$')
-               return(-1);
-       n1 = 0;
-       while (*cp2 >= '0' && *cp2 <= '7') {
-               n1 <<= 3;
-               n1 += *cp2++ - '0';
-       }
-       n2 = n1;
-       n1 = 0;
-       while (*cp1 >= '0' && *cp1 <= '7') {
-               n1 <<= 3;
-               n1 += *cp1++ - '0';
-       }
-       if (*cp1=='+')
-               cp1++;
-       if (*cp2=='+')
-               cp2++;
-       do {
-               if (*cp1++ != *cp2)
-                       return(-1);
-       } while (*cp2++);
-       switch(oper) {
-
-       case JEQ:
-               return(n1 == n2);
-       case JNE:
-               return(n1 != n2);
-       case JLE:
-               return((int)n1 <= (int)n2);
-       case JGE:
-               return((int)n1 >= (int)n2);
-       case JLT:
-               return((int)n1 < (int)n2);
-       case JGT:
-               return((int)n1 > (int)n2);
-       case JLO:
-               return(n1 < n2);
-       case JHI:
-               return(n1 > n2);
-       case JLOS:
-               return(n1 <= n2);
-       case JHIS:
-               return(n1 >= n2);
-       }
-       return(-1);
-}
-
-setcon(ar1, ar2)
-char *ar1, *ar2;
-{
-       register char *cl, *cv, *p;
-
-       cl = ar2;
-       cv = ar1;
-       if (*cv != '$')
-               return;
-       if (!natural(cl))
-               return;
-       p = conloc;
-       while (*p++ = *cl++);
-       p = conval;
-       while (*p++ = *cv++);
-}
-
-equstr(ap1, ap2)
-char *ap1, *ap2;
-{
-       char *p1, *p2;
-
-       p1 = ap1;
-       p2 = ap2;
-       do {
-               if (*p1++ != *p2)
-                       return(0);
-       } while (*p2++);
-       return(1);
-}
-
-setcc(ap)
-char *ap;
-{
-       register char *p, *p1;
-
-       p = ap;
-       if (!natural(p)) {
-               ccloc[0] = 0;
-               return;
-       }
-       p1 = ccloc;
-       while (*p1++ = *p++);
-}
-
-natural(ap)
-char *ap;
-{
-       register char *p;
-
-       p = ap;
-       if (*p=='*' || *p=='(' || *p=='-'&&*(p+1)=='(')
-               return(0);
-       while (*p++);
-       p--;
-       if (*--p == '+' || *p ==')' && *--p != '5')
-               return(0);
-       return(1);
-}
diff --git a/usr/src/cmd/c/cvopt.c b/usr/src/cmd/c/cvopt.c
deleted file mode 100644 (file)
index 6592641..0000000
+++ /dev/null
@@ -1,363 +0,0 @@
-#include <stdio.h>
-
-int    tabflg;
-int    labno   = 1;
-FILE   *curbuf;
-FILE   *obuf;
-
-main(argc, argv)
-char **argv;
-{
-/*
-       A1 -> A
-       A2    B
-       A     O
-       B1    C
-       B2    D
-       BE    L
-       BF    P
-       C1    E
-       C2    F
-       F     G
-       H     H
-       R     I
-       R1    J
-       S     K
-       I     M
-       M     N
-
-               *       +1
-               S       +2
-               C       +4
-               1       +8
-
-       z  -> 4
-       c     10
-       a     14
-       e     20
-       n     63
-       *       +0100
-*/
-
-       int c, snlflg, nlflg, t, smode, m, ssmode, peekc;
-
-       smode = nlflg = snlflg = ssmode = 0;
-       if (argc>1)
-               if (freopen(argv[1], "r", stdin) == NULL) {
-                       fprintf(stderr, "%s?\n", argv[1]);
-                       return(1);
-               }
-       if (argc>2) 
-               if (freopen(argv[2], "w", stdout) == NULL) {
-                       fprintf(stderr, "%s?\n", argv[2]);
-                       return(1);
-               }
-       if ((obuf = fopen("cvopt.tmp", "w")) == NULL) {
-               fprintf(stderr, "cvopt.tmp?\n");
-               exit(1);
-       }
-       curbuf = obuf;
-loop:
-       c = getchar();
-       if (c!='\n' && c!='\t')
-               nlflg = 0;
-       if (ssmode!=0 && c!='%') {
-               ssmode = 0;
-               curbuf = stdout;
-               fprintf(curbuf, "L%d:<", labno++);
-       }
-       switch(c) {
-
-       case EOF:
-               fprintf(obuf, "0\n");
-               fclose(obuf);
-               fprintf(stdout, ".even\n");
-               if (freopen("cvopt.tmp", "r", stdin) == NULL) {
-                       fprintf(stderr, "tmp?\n");
-                       exit(1);
-               }
-               while ((c = getchar()) != EOF)
-                       putchar(c);
-               unlink("cvopt.tmp");
-               return(0);
-
-       case ':':
-               if (!smode)
-                       fprintf(curbuf, "=.+2; 0"); else
-                       put(':');
-               goto loop;
-
-       case 'A':
-               if ((c=getchar())=='1' || c=='2') {
-                       put(c+'A'-'1');
-                       goto loop;
-               }
-               put('O');
-               ungetc(c, stdin);
-               goto loop;
-
-       case 'B':
-               switch (getchar()) {
-
-               case '1':
-                       put('C');
-                       goto loop;
-
-               case '2':
-                       put('D');
-                       goto loop;
-
-               case 'E':
-                       put('L');
-                       goto loop;
-
-               case 'F':
-                       put('P');
-                       goto loop;
-               }
-               put('?');
-               goto loop;
-
-       case 'C':
-               put(getchar()+'E'-'1');
-               goto loop;
-
-       case 'F':
-               put('G');
-               goto subtre;
-
-       case 'R':
-               if ((c=getchar()) == '1')
-               put('J'); else {
-                       put('I');
-                       ungetc(c, stdin);
-               }
-               goto loop;
-
-       case 'H':
-               put('H');
-               goto subtre;
-
-       case 'I':
-               put('M');
-               goto loop;
-
-       case 'S':
-               put('K');
-subtre:
-               snlflg = 1;
-               t = 'A';
-l1:
-               switch (c=getchar()) {
-
-               case '*':
-                       t++;
-                       goto l1;
-
-               case 'S':
-                       t =+ 2;
-                       goto l1;
-
-               case 'C':
-                       t =+ 4;
-                       goto l1;
-
-               case '1':
-                       t =+ 8;
-                       goto l1;
-
-               case '2':
-                       t =+ 16;
-                       goto l1;
-               }
-               ungetc(c, stdin);
-               put(t);
-               goto loop;
-
-       case '#':
-               if(getchar()=='1')
-                       put('#'); else
-                       put('"');
-               goto loop;
-
-       case '%':
-               if (smode)
-                       curbuf = obuf;
-               if (ssmode==0) {
-                       if ((peekc=getchar())=='[') {
-                               curbuf = stdout;
-                               while((c=getchar())!=']')
-                                       put(c);
-                               getchar();
-                               fprintf(curbuf, ";");
-                               curbuf = obuf;
-                               goto loop;
-                       }
-                       ungetc(peekc, stdin);
-               }
-loop1:
-               switch (c=getchar()) {
-
-               case ' ':
-               case '\t':
-                       goto loop1;
-               case 'a':
-                       m = 16;
-                       t = flag();
-                       goto pf;
-
-               case ',':
-                       put(';');
-                       goto loop1;
-
-               case 'i':
-                       m = 12;
-                       t = flag();
-                       goto pf;
-               case 'z':
-                       m = 4;
-                       t = flag();
-                       goto pf;
-
-               case 'r':
-                       m = 9;
-                       t = flag();
-                       goto pf;
-
-               case '1':
-                       m = 5;
-                       t = flag();
-                       goto pf;
-
-               case 'c':
-                       t = 0;
-                       m = 8;
-                       goto pf;
-
-               case 'e':
-                       t = flag();
-                       m = 20;
-                       goto pf;
-
-               case 'n':
-                       t = flag();
-                       m = 63;
-pf:
-                       if ((c=getchar())=='*')
-                               m =+ 0100; else
-                               ungetc(c, stdin);
-                       fprintf(curbuf, ".byte %o,%o", m, t);
-                       goto loop1;
-               case '[':
-                       fprintf(curbuf, "L%d=", labno++);
-                       while ((c=getchar())!=']')
-                               put(c);
-                       ssmode = 0;
-                       smode = 0;
-                       goto loop;
-
-               case '\n':
-                       fprintf(curbuf, "\nL%d\n", labno);
-                       ssmode = 1;
-                       nlflg = 1;
-                       smode = 1;
-                       goto loop;
-               }
-               put(c);
-               goto loop1;
-
-       case '\t':
-               if (nlflg) {
-                       nlflg = 0;
-                       goto loop;
-               }
-               if (smode) {
-                       tabflg++;
-                       goto loop;
-               }
-               put('\t');
-               goto loop;
-
-       case '\n':
-               if (!smode)  {
-                       put('\n');
-                       goto loop;
-               }
-               if (nlflg) {
-                       nlflg = 0;
-                       fprintf(curbuf, "\\0>\n");
-                       curbuf = obuf;
-                       smode = 0;
-                       goto loop;
-               }
-               if (!snlflg)
-                       fprintf(curbuf, "\\n");
-               snlflg = 0;
-               fprintf(curbuf, ">\n<");
-               nlflg = 1;
-               goto loop;
-
-       case 'X':
-       case 'Y':
-       case 'T':
-               snlflg++;
-       }
-       put(c);
-       goto loop;
-}
-
-flag() {
-       register c, f;
-
-       f = 0;
-l1:
-       switch(c=getchar()) {
-
-       case 'w':
-               f = 1;
-               goto l1;
-
-       case 'i':
-               f = 2;
-               goto l1;
-
-       case 'b':
-               f = 3;
-               goto l1;
-
-       case 'f':
-               f = 4;
-               goto l1;
-
-       case 'd':
-               f = 5;
-               goto l1;
-
-       case 'u':
-               f = 9;
-               goto l1;
-
-       case 's':
-               f = 6;
-               goto l1;
-
-       case 'l':
-               f = 8;
-               goto l1;
-
-       case 'p':
-               f =+ 16;
-               goto l1;
-       }
-       ungetc(c, stdin);
-       return(f);
-}
-
-put(c)
-{
-       if (tabflg) {
-               tabflg = 0;
-               fprintf(curbuf, ">;.byte %o;<", c+0200);
-       } else
-               putc(c, curbuf);
-}
diff --git a/usr/src/cmd/c/makefile b/usr/src/cmd/c/makefile
deleted file mode 100644 (file)
index c7fdd05..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-CFLAGS = -O -n -s
-
-all:   c0 c1 c2
-
-cmp:   all
-       cmp c0 /lib/c0
-       cmp c1 /lib/c1
-       cmp c2 /lib/c2
-       rm c0 c1 c2 *.o
-
-cp:    all
-       cp c0 /lib/c0
-       cp c1 /lib/c1
-       cp c2 /lib/c2
-       rm c0 c1 c2 *.o
-
-fcp:   fc1
-       cp fc1 /lib/fc1
-       rm fc1 c1*.o
-
-c0: c00.o c01.o c02.o c03.o c04.o c05.o
-       cc $(CFLAGS) -o c0 c00.o c01.o c02.o c03.o c04.o c05.o
-
-c00.o c01.o c02.o c03.o c04.o c05.o: c0.h
-
-c1: c10.o c11.o c12.o c13.o table.o
-       cc $(CFLAGS) -o c1 c10.o c11.o c12.o c13.o table.o
-
-fc1: c10.o c11.o c12.o c13.o table.o
-       cc $(CFLAGS) -f -o fc1 c10.o c11.o c12.o c13.o table.o
-
-c10.o c11.o c12.o c13.o: c1.h
-
-table.o: table.s cvopt
-       cvopt <table.s >table.i
-       as -o table.o table.i
-       rm table.i
-
-c2: c20.o c21.o
-       cc -i -O -s -o c2 c20.o c21.o
-
-c20.o c21.o: c2.h
-
-cvopt: cvopt.c
-       cc $(CFLAGS) -o cvopt cvopt.c
diff --git a/usr/src/cmd/c/table.s b/usr/src/cmd/c/table.s
deleted file mode 100644 (file)
index f8ead47..0000000
+++ /dev/null
@@ -1,1601 +0,0 @@
-/
-/ c code tables-- compile to register
-/
-
-.globl _regtab
-
-.data
-_regtab=.
-       106.;   cr106
-       30.;    cr70
-       31.;    cr70
-       32.;    cr32
-       33.;    cr32
-       37.;    cr37
-       38.;    cr37
-       98.;    cr100
-       99.;    cr100
-       80.;    cr80
-       40.;    cr40
-       41.;    cr40    / - like +
-       42.;    cr42
-       43.;    cr43
-       14.;    cr43
-       44.;    cr43
-       45.;    cr45
-       46.;    cr40
-       55.;    cr40
-       48.;    cr40
-       49.;    cr49
-       70.;    cr70
-       71.;    cr70
-       72.;    cr72
-       73.;    cr73
-       74.;    cr74
-       75.;    cr75
-       76.;    cr72
-       78.;    cr70
-       85.;    cr70
-       79.;    cr79
-       102.;   cr102
-       51.;    cr51
-       52.;    cr52
-       56.;    cr56
-       57.;    cr57
-       58.;    cr58
-       59.;    cr59
-       91.;    cr91
-       82.;    cr82
-       83.;    cr82
-       84.;    cr82
-       86.;    cr86
-       87.;    cr86
-       88.;    cr86
-       16.;    cr16
-       92.;    cr92
-       17.;    cr43
-       18.;    cr74
-       109.; cr109
-       0
-.text
-
-/ goto
-cr102:
-%a,n
-       jmp     A1
-
-%n*,n
-       F*
-       jmp     #1(R)
-
-/ call
-cr100:
-%a,n
-       jsr     pc,IA1
-
-%n*,n
-       F*
-       jsr     pc,#1(R)
-
-%n,n
-       F
-       jsr     pc,(R)
-
-/ addressible
-cr106:
-%z,n
-       clr     R
-
-%zf,n
-       clrf    R
-
-%a,n
-%ad,n
-       movB1   A1,R
-
-%af,n
-       movof   A1,R
-
-%n*,n
-%nd*,n
-       F*
-       movB1   #1(R),R
-
-%nf*,n
-       F*
-       movof   #1(R),R
-
-%al,n
-       mov     A1+,R+
-       mov     A1,R
-
-%nl*,n
-       F*
-       mov     #1+2(R),R+
-       mov     #1(R),R
-
-%n,n
-       F
-
-/ ++,-- postfix
-cr32:
-%a,1
-       movB1   A1',R
-       I'B1    A1''
-
-%aw,n
-       mov     A1',R
-       I       A2,A1''
-
-%e*,1
-       F1*
-       movB1   #1(R1),R
-       I'B1    #1(R1)
-
-%n*,1
-       F*
-       movB1   #1(R),-(sp)
-       I'B1    #1(R)
-       movB1   (sp)+,R
-
-%ew*,n
-       F1*
-       mov     #1(R1),R
-       I       A2,#1(R1)
-
-%nw*,n
-       F*
-       mov     #1(R),-(sp)
-       I       A2,#1(R)
-       mov     (sp)+,R
-
-%al,1
-       F
-       I       $1,A1+
-       V       A1
-
-%el*,1
-       F1*
-       mov     #1+2(R1),R+
-       mov     #1(R1),R
-       I       $1,#1+2(R1)
-       V       #1(R1)
-
-%nl*,1
-       F*
-       mov     #1+2(R),-(sp)
-       mov     #1(R),-(sp)
-       I       $1,#1+2(R)
-       V       #1(R)
-       mov     (sp)+,R
-       mov     (sp)+,R+
-
-/ - unary, ~
-cr37:
-%n,n
-%nf,n
-       F
-       IBF     R
-
-%nl,n
-       F
-       I       R
-       I       R+
-       V       R
-
-/ =
-cr80:
-%a,n
-%ad,nf
-       S
-       movB1   R,A1
-
-%af,nf
-       S
-       movfo   R,A1
-
-%nd*,af
-       F*
-       S
-       movf    R,#1(R)
-
-%n*,aw
-       F*
-       movB1   A2,#1(R)
-       movB1   #1(R),R
-
-%nf*,af
-       F*
-       S
-       movfo   R,#1(R)
-
-%n*,e
-       F*
-       S1
-       movB1   R1,#1(R)
-       movB1   R1,R
-
-%ed*,nf
-       S
-       F1*
-       movf    R,#1(R1)
-
-%ef*,nf
-       S
-       F1*
-       movfo   R,#1(R1)
-
-%n*,n
-%nd*,nf
-       FS*
-       S
-       movB1   R,*(sp)+
-
-%nf*,nf
-       FS*
-       S
-       movfo   R,*(sp)+
-
-%al,nl
-       S
-       mov     R+,A1+
-       mov     R,A1
-
-%el*,nl
-       S
-       F1*
-       mov     R+,2+#1(R1)
-       mov     R,#1(R1)
-
-%nl*,nl
-       FS*
-       S
-       mov     R,*(sp)
-       add     $2,(sp)
-       mov     R+,*(sp)+
-
-/ field assign, value in reg.
-cr16:
-%a,n
-       S
-       bicB1   Z,A1'
-       bisB1   R,A1''
-
-%e*,n
-%      [fas1]
-
-%n*,n
-       SS
-       F*
-       bicB1   Z,#1(R)
-       bisB1   (sp),#1(R)
-       mov     (sp)+,R
-
-/ +, -, |, &~, <<
-cr40:
-%n,z
-       F
-
-%n,1
-       F
-       I'      R
-
-%[add1:]
-%n,aw
-%nf,ad
-       F
-       IB2     A2,R
-
-%[add2:]
-%n,ew*
-%nf,ed*
-       F
-       S1*
-       IB2     #2(R1),R
-
-%[add3:]
-%n,e
-%nf,ef
-       F
-       S1
-       IBF     R1,R
-
-%[add4:]
-%n,nw*
-%nf,nd*
-       SS*
-       F
-       IB2     *(sp)+,R
-
-%[add5:]
-%n,n
-%nf,nf
-       SS
-       F
-       IBF     (sp)+,R
-
-%nl,c
-%nl,au
-       F
-       I       A2,R+
-       V       R
-
-%nl,eu
-       F
-       S1
-       I       R1,R+
-       V       R
-
-%nl,al
-       F
-       I       A2,R
-       I       A2+,R+
-       V       R
-
-%[addl1:]
-%nl,el
-       F
-       S1
-       I       R1+,R+
-       V       R
-       I       R1,R
-
-%[addl2:]
-%nl,nl
-       SS
-       F
-       I       (sp)+,R
-       I       (sp)+,R+
-       V       R
-
-/ ^ -- xor
-cr49:
-%n,e
-%      [add3]
-
-%n,n
-       FS
-       S
-       xor     R,(sp)
-       mov     (sp)+,R
-
-%nl,el
-%      [addl1]
-
-%nl,nl
-       SS
-       F
-       I       R,(sp)
-       mov     (sp)+,R
-       I       R+,(sp)
-       mov     (sp)+,R+
-
-/ >> (all complicated cases taken care of by << -)
-cr45:
-%n,1
-       F
-       asr     R
-
-/ * -- R must be odd on integers
-cr42:
-%n,aw
-%nf,ad
-%      [add1]
-
-%n,ew*
-%nf,ed*
-%      [add2]
-
-%n,e
-%nf,ef
-%      [add3]
-
-%n,n
-%nf,nf
-%      [add5]
-
-/ / R must be odd on integers
-cr43:
-%n,aw
-       F
-       T
-       I       A2,R-
-
-%n,ew*
-       F
-       T
-       S1*
-       I       #2(R1),R-
-
-%n,e
-       F
-       T
-       S1
-       I       R1,R-
-
-%n,n
-       SS
-       F
-       T
-       I       (sp)+,R-
-
-%nf,ad
-%      [add1]
-
-%nf,ed*
-%      [add2]
-
-%nf,ef
-%      [add3]
-
-%nf,nf
-%      [add5]
-
-/ =+, =-, =|, =&~
-cr70:
-%[addq1:]
-%aw,aw
-       I       A2,A1'
-       mov     A1'',R
-
-%[addq1a:]
-%a,aw
-%ad,ad
-       movB1   A1',R
-       IBF     A2,R
-       movB1   R,A1''
-
-%[addq2:]
-%aw,nw*
-       S*
-       I       #2(R),A1'
-       mov     A1'',R
-
-%[addq3:]
-%aw,n
-       S
-       I       R,A1'
-       mov     A1'',R
-
-%[addq4:]
-%ew*,nw*
-       S*
-       F1*
-       I       #2(R),#1(R1)
-       mov     #1(R1),R
-
-%[addq4a:]
-%ad,ef
-       movf    A1',R
-       S1
-       IBF     R1,R
-       movf    R,A1''
-
-%[addq5:]
-%a,n
-%ad,nf
-       SS
-       movB1   A1',R
-       IBF     (sp)+,R
-       movB1   R,A1''
-
-%[addq6:]
-%af,nf
-       SS
-       movof   A1',R
-       IBF     (sp)+,R
-       movfo   R,A1''
-
-%[addq7:]
-%ew*,n
-       S
-       F1*
-       I       R,#1(R1)
-       mov     #1(R1),R
-
-%[addq8:]
-%nw*,n
-       SS
-       F*
-       I       (sp)+,#1(R)
-       mov     #1(R),R
-
-%[addq9:]
-%n*,n
-       FS*
-       SS
-       movB1   *2(sp),R
-       IBF     (sp)+,R
-       movB1   R,*(sp)+
-
-%[addq9a:]
-%nd*,nf
-       SS
-       F*
-       movB1   #1(R),R
-       IBF     (sp)+,R
-       movB1   R,#1(R)
-
-%[addq10:]
-%nf*,nf
-       SS
-       F*
-       movof   #1(R),R1
-       IBF     (sp)+,R1
-       movfo   R1,#1(R)
-       movf    R1,R
-
-%al,c
-       I       A2,A1+
-       V       A1
-       F
-
-%al,al
-       I       A2+,A1+
-       V       A1
-       I       A2,A1
-       F
-
-%al,nl
-       S
-       I       R+,A1+
-       V       A1
-       I       R,A1
-       F
-
-%nl*,c
-       F*
-       I       A2,#1+2(R)
-       V       #1(R)
-       mov     #1+2(R),R+
-       mov     #1(R),R
-
-%nl*,al
-       F*
-       I       A2+,#1+2(R)
-       V       #1(R)
-       I       A2,#1(R)
-       mov     #1+2(R),R+
-       mov     #1(R),R
-
-%nl*,nl
-       SS
-       F*
-       I       (sp)+,#1(R)
-       I       (sp)+,#1+2(R)
-       V       #1(R)
-       mov     #1+2(R),R+
-       mov     #1(R),R
-
-/ =*, =<< (for integer multiply, R must be odd)
-cr72:
-%a,aw
-%ad,ad
-%      [addq1a]
-
-%ad,ef
-%      [addq4a]
-
-%a,n
-%ad,nf
-%      [addq5]
-
-%af,nf
-%      [addq6]
-
-%n*,n
-%      [addq9]
-
-%nd*,nf
-%      [addq9a]
-
-%nf*,nf
-%      [addq10]
-
-/ =/ ;  R must be odd on integers
-cr73:
-%a,aw
-       movB1   A1',R
-       V       R-
-       IBF     A2,R-
-       movB1   R-,A1''
-
-%a,n
-       SS
-       movB1   A1',R
-       V       R-
-       I       (sp)+,R-
-       movB1   R-,A1''
-
-%e*,n
-       SS
-       F1*
-       movB1   #1(R1),R
-       V       R-
-       I       (sp)+,R-
-       movB1   R-,#1(R1)
-
-%n*,n
-       FS*
-       SS
-       movB1   *2(sp),R
-       V       R-
-       I       (sp)+,R-
-       movB1   R-,*(sp)+
-
-%ad,ad
-%      [addq1a]
-
-%ad,ef
-%      [addq4a]
-
-%ad,nf
-%      [addq5]
-
-%af,nf
-%      [addq6]
-
-%nd*,nf
-%      [addq9a]
-
-%nf*,nf
-%      [addq10]
-
-/ =mod; R must be odd on integers
-cr74:
-%a,aw
-       movB1   A1',R
-       V       R-
-       I       A2,R-
-       movB1   R,A1''
-
-%a,n
-       SS
-       movB1   A1',R
-       V       R-
-       I       (sp)+,R-
-       movB1   R,A1''
-
-%e*,n
-       SS
-       F1*
-       movB1   #1(R1),R
-       V       R-
-       I       (sp)+,R-
-       movB1   R,#1(R1)
-
-%n*,n
-       FS*
-       SS
-       movB1   *2(sp),R
-       V       R-
-       I       (sp)+,R-
-       mov     R,*(sp)+
-
-/ =^ -- =xor
-cr79:
-%aw,n
-%      [addq3]
-
-%ab,n
-       SS
-       movb    A1',R
-       xor     R,(sp)
-       mov     (sp)+,R
-       movb    R,A1''
-
-%n*,n
-       FS*
-       movB1   *(sp),-(sp)
-       S
-       xor     R,(sp)
-       movB1   (sp)+,R
-       movB1   R,*(sp)+
-
-/ =>> (all complicated cases done by =<< -)
-cr75:
-%a,1
-       asrB1   A1'
-       movB1   A1'',R
-
-%n*,1
-       F*
-       asrB1   #1(R)
-       movB1   #1(R),R
-
-/ << for longs
-cr91:
-%nl,aw
-%      [add1]
-
-%nl,ew*
-%      [add2]
-
-%nl,e
-%      [add3]
-
-%nl,nw*
-%      [add4]
-
-%nl,n
-%      [add5]
-
-/ int -> float
-cr51:
-%aw,n
-       movif   A1,R
-
-%nw*,n
-       F*
-       movif   #1(R),R
-
-%n,n
-       F
-       movif   R,R
-
-/ float, double -> int
-cr52:
-%nf,n
-       F
-       movfi   R,R
-
-/ double (float) to long
-cr56:
-%nf,n
-       F
-       setl
-       movfi   R,-(sp)
-       mov     (sp)+,R
-       mov     (sp)+,R+
-       seti
-
-/ long to double
-cr57:
-%al,n
-       setl
-       movif   A1,R
-       seti
-
-%nl*,n
-       F*
-       setl
-       movif   #1(R),R
-       seti
-
-%nl,n
-       FS
-       setl
-       movif   (sp)+,R
-       seti
-
-/ integer to long
-cr58:
-%eu,n
-       F1!
-       clr     R
-
-%nu,n
-       F
-       mov     R,R1
-       clr     R
-
-%e,n
-       F1!
-       sxt     R
-
-%n,n
-       F
-       mov     R,R1
-       sxt     R
-
-/ long to integer
-cr59:
-%al,n
-       mov     A1+,R
-
-%nl*,n
-       F*
-       mov     #1+2(R),R
-
-/ *, /, remainder for longs.
-cr82:
-%nl,nl
-       SS
-       FS
-       jsr     pc,I
-       add     $10,sp
-
-/ =*, =/, =rem for longs
-/ Operands of the form &x op y, so stack space is known.
-cr86:
-%n,nl
-       SS
-       FS
-       jsr     pc,I
-       add     $6,sp
-
-/ convert integer to character (sign extend)
-cr109:
-%n,n
-       F
-       movb    R,R
-
-/
-/ c code tables -- compile for side effects.
-/ Also set condition codes properly (except for ++, --)
-/
-
-.globl _efftab
-
-.data
-_efftab=.
-       30.;    ci70
-       31.;    ci70
-       32.;    ci70
-       33.;    ci70
-       80.;    ci80
-       70.;    ci70
-       71.;    ci70    / - like +
-       78.;    ci78
-       79.;    ci79
-       85.;    ci78
-       75.;    ci75
-       76.;    ci76
-       16.;    ci16
-       116.;   ci116
-       0
-.text
-
-/ =
-ci80:
-%[move1:]
-%a,z
-%ad,zf
-       I'B1    A1
-
-%[move2:]
-%n*,z
-%nd*,zf
-       F*
-       I'B1    #1(R)
-
-%[move3:]
-%a,aw
-%ab,a
-       IBE     A2,A1
-
-%[move4:]
-%ab,n*
-%a,nw*
-       S*
-       IBE     #2(R),A1
-
-%[move5:]
-%a,n
-       S
-       IB1     R,A1
-
-%[move6:]
-%n*,aw
-%nb*,a
-       F*
-       IBE     A2,#1(R)
-
-%[move7:]
-%n*,ew*
-%nb*,e*
-       F*
-       S1*
-       IBE     #2(R1),#1(R)
-
-%[move8:]
-%n*,e
-       F*
-       S1
-       IB1     R1,#1(R)
-
-%[move9:]
-%e*,nw*
-%eb*,n*
-       S*
-       F1*
-       IBE     #2(R),#1(R1)
-
-%[move10:]
-%e*,n
-       S
-       F1*
-       IB1     R,#1(R1)
-
-%[move11:]
-%n*,nw*
-%nb*,n*
-       FS*
-       S*
-       IBE     #2(R),*(sp)+
-
-%[move12:]
-%n*,n
-       FS*
-       S
-       IB1     R,*(sp)+
-
-%aw,nf
-       S
-       movfi   R,A1
-
-%ew*,nf
-       S
-       F1*
-       movfi   R,#1(R1)
-
-%al,z
-       clr     A1
-       clr     A1+
-
-%nl*,z
-       F*
-       clr     #1(R)
-       clr     2+#1(R)
-
-%[move13a:]
-%al,aw
-       I       A2,A1+
-       V       A1
-
-%al,nw*
-       S*
-       mov     #2(R),A1+
-       V       A1
-
-%al,n
-       S
-       mov     R,A1+
-       V       A1
-
-%al,nf
-       S
-       setl
-       movfi   R,A1
-       seti
-
-%el*,nf
-       S
-       F1*
-       setl
-       movfi   R,#1(R1)
-       seti
-
-%[move13:]
-%al,al
-       I       A2,A1
-       I       A2+,A1+
-       V       A1
-
-%[move14:]
-%al,nl*
-       S*
-       I       #2(R),A1
-       I       #2+2(R),A1+
-       V       A1
-
-%[move15:]
-%al,nl
-       S
-       I       R,A1
-       I       R+,A1+
-       V       A1
-
-%[move14a:]
-%nl*,aw
-       F*
-       I       A2,#1+2(R)
-       V       #1(R)
-
-%[move16a:]
-%nl*,al
-       F*
-       I       A2+,#1+2(R)
-       V       #1(R)
-       I       A2,#1(R)
-
-%[move16:]
-%el*,nl
-       S
-       F1*
-       I       R+,#1+2(R1)
-       V       #1(R1)
-       I       R,#1(R1)
-
-%nl*,n
-       SS
-       F*
-       mov     (sp)+,#1+2(R)
-       V       #1(R)
-
-%[move17:]
-%nl*,nl
-       SS
-       F*
-       I       (sp)+,#1(R)
-       I       (sp)+,#1+2(R)
-       V       #1(R)
-
-/ =| and =& ~
-ci78:
-%a,aw
-%ab,a
-%      [move3]
-
-%a,n
-%      [move5]
-
-%n*,aw
-%nb*,a
-%      [move6]
-
-%n*,ew*
-%nb*,e*
-%      [move7]
-
-%n*,e
-%      [move8]
-
-%e*,nw*
-%eb*,n*
-%      [move9]
-
-%e*,n
-%      [move10]
-
-%n*,nw*
-%nb*,n*
-%      [move11]
-
-%n*,n
-%      [move12]
-
-%al,c
-%al,au
-%      [move13a]
-
-%al,al
-%      [move13]
-
-%al,nl*
-%      [move14]
-
-%al,nl
-%      [move15]
-
-%nl*,c
-%      [move14a]
-
-%nl*,al
-%      [move16a]
-
-%el*,nl
-%      [move16]
-
-%nl*,nl
-%      [move17]
-
-/ =^
-ci79:
-%al,nl
-%      [move15]
-
-%el*,nl
-%      [move16]
-
-%nl*,nl
-       FS*
-       S
-       I       R,*(sp)
-       mov     (sp)+,R
-       I       R+,2(R)
-
-/ =+
-ci70:
-%n*,z
-%a,z
-
-%a,1
-       I'B1    A1
-
-%aw,aw
-%      [move3]
-
-%aw,nw*
-%      [move4]
-
-%aw,n
-%      [move5]
-
-%n*,1
-%      [move2]
-
-%ew*,nw*
-%      [move9]
-
-%a,nw*
-       S*
-       movB1   A1',R1
-       I       #2(R),R1
-       movB1   R1,A1''
-
-%a,n
-       S
-       movB1   A1',R1
-       I       R,R1
-       movB1   R1,A1''
-
-%ew*,n
-%      [move10]
-
-%nw*,n
-%      [move12]
-
-%n*,n
-       SS
-       F*
-       movB1   #1(R),R1
-       I       (sp)+,R1
-       movB1   R1,#1(R)
-
-%al,c
-%al,au
-%      [move13a]
-
-%al,al
-%      [move13]
-
-%al,nl*
-%      [move14]
-
-%al,nl
-%      [move15]
-
-%nl*,c
-%nl*,au
-%      [move14a]
-
-%nl*,al
-%      [move16a]
-
-%el*,nl
-%      [move16]
-
-%nl*,nl
-%      [move17]
-
-/ =>> (all harder cases handled by =<< -)
-ci75:
-%a,1
-       asrB1   A1
-
-%n*,1
-       F*
-       asrB1   #1(R)
-
-/ =<<
-ci76:
-%a,1
-       aslB1   A1
-
-%n*,1
-       F*
-       aslB1   #1(R)
-
-%r,aw
-       ash     A2,A1
-
-%r,nw*
-       S*
-       ash     #2(R),A1
-
-%r,n
-       S
-       ash     R,A1
-
-/ =<< for longs
-cr92:
-%al,aw
-       F
-       ashc    A2,R
-       mov     R,A1
-       mov     R+,A1+
-
-%al,n
-       SS
-       F
-       ashc    (sp)+,R
-       mov     R,A1
-       mov     R+,A1+
-
-%nl*,n
-       FS*
-       SS
-       mov     2(sp),R
-       mov     2(R),R+
-       mov     (R),R
-       ashc    (sp)+,R
-       mov     R,*(sp)
-       add     $2,(sp)
-       mov     R+,*(sp)+
-
-/ field = ...
-ci16:
-%a,a
-       bicB1   Z,A1'
-       bisB1   A2,A1''
-
-%a,n
-       S
-       bicB1   Z,A1'
-       bisB1   R,A1''
-
-%n*,a
-       F*
-       bicB1   Z,#1(R)
-       bisB1   A2,#1(R)
-
-%[fas1:]
-%e*,n
-       S
-       F1*
-       bicB1   Z,#1(R1)
-       bisB1   R,#1(R1)
-
-%n*,e
-       F*
-       S1
-       bicB1   Z,#1(R)
-       bisB1   R1,#1(R)
-
-%n*,n
-       SS
-       F*
-       bicB1   Z,#1(R)
-       bisB1   (sp)+,#1(R)
-
-/
-/ c code tables-- set condition codes
-/
-
-.globl _cctab
-
-.data
-_cctab=.
-       106.;   cc60
-       28.;    rest
-       55.;    rest
-       34.;    rest
-       35.;    rest
-       36.;    rest
-       37.;    rest
-       40.;    rest
-       41.;    rest
-       42.;    rest
-       43.;    rest
-       81.;    cc81    / & as in "if ((a&b)==0)"
-       48.;    rest
-       60.;    cc60
-       61.;    cc60
-       62.;    cc60
-       63.;    cc60
-       64.;    cc60
-       65.;    cc60
-       66.;    cc60
-       67.;    cc60
-       68.;    cc60
-       69.;    cc60
-       72.;    rest
-       73.;    rest
-       79.;    rest
-       0
-.text
-
-/ relationals
-cc60:
-%a,z
-%ad,zf
-%      [move1]
-
-%af,z
-       movof   A1,R
-
-%n*,z
-%nd*,zf
-%      [move2]
-
-%nf*,z
-       F*
-       movof   #1(R),R
-
-%n,z
-%nf,zf
-       FC
-
-%aw,aw
-%ab,ab
-%      [move3]
-
-%nw*,aw
-%nb*,ab
-%      [move6]
-
-%n,aw
-%nf,ad
-%      [add1]
-
-%nw*,ew*
-%nb*,eb*
-%      [move7]
-
-%nw*,e
-%      [move8]
-
-%n,ew*
-%nf,ed*
-%      [add2]
-
-%n,e
-%nf,ef
-%      [add3]
-
-%nw*,nw*
-%nb*,nb*
-%      [move11]
-
-%nw*,n
-%      [move12]
-
-%n,n
-%nf,nf
-%      [add5]
-
-%al,z
-       tst     A1
-       X0
-       tst     A1+
-       X1
-
-%al,c
-%al,au
-       tst     A1
-       X0
-       cmp     A1+,A2
-       X1
-
-%[lcmp1:]
-%al,al
-       I       A1,A2
-       X0
-       I       A1+,A2+
-       X1
-
-%nl*,z
-       F*
-       tst     #1(R)
-       X0
-       tst     #1+2(R)
-       X1
-
-%nl*,c
-%nl*,au
-       F*
-       tst     #1(R)
-       X0
-       cmp     #1+2(R),A2
-       X1
-
-%[lcmp2:]
-%nl*,al
-       F*
-       I       #1(R),A2
-       X0
-       I       #1+2(R),A2+
-       X1
-
-%nl,z
-       F
-       tst     R
-       X0
-       tst     R+
-       X1
-
-%nl,c
-%nl,au
-       F
-       tst     R
-       X0
-       cmp     R+,A2
-       X1
-
-%[lcmp3:]
-%nl,al
-       F
-       I       R,A2
-       X0
-       I       R+,A2+
-       X1
-
-%[lcmp4:]
-%nl*,el*
-       F*
-       S1*
-       I       #1(R),#2(R1)
-       X0
-       I       #1+2(R),#2+2(R1)
-       X1
-
-%[lcmp5:]
-%nl,el*
-       F
-       S1*
-       I       R,#2(R1)
-       X0
-       I       R+,#2+2(R1)
-       X1
-
-%[lcmp6:]
-%nl,nl
-       FS
-       S
-       mov     R,-(sp)
-       mov     4(sp),R
-       mov     (sp)+,2(sp)
-       I       (sp)+,(sp)+
-       X0
-       I       R,R+
-       X1
-
-/ & as in "if ((a&b) ==0)"
-cc81:
-%a,a
-%      [move3]
-
-%n*,a
-%      [move6]
-
-%n,a
-%      [add1]
-
-%n,e
-%      [add3]
-
-%n,n
-%      [add5]
-
-%al,c
-%al,au
-       /bit    $0,A1
-       /X0
-       bit     A2,A1+
-       X1
-
-%nl*,c
-%nl*,au
-       F*
-       /bit    $0,#2(R)
-       /X0
-       bit     A2,#2+2(R)
-       X1
-
-%al,al
-%      [lcmp1]
-
-%nl*,al
-%      [lcmp2]
-
-%nl,al
-%      [lcmp3]
-
-%nl*,el*
-%      [lcmp4]
-
-%nl,el*
-%      [lcmp5]
-
-%nl,nl
-%      [lcmp6]
-
-%nl,c
-%nl,au
-       F
-       /bit    $0,R
-       /X0
-       bit     A2,R+
-       X1
-
-/ set codes right
-rest:
-%n,n
-%nf,nf
-       H
-
-/
-/ c code tables-- expression to -(sp)
-/
-
-.globl _sptab
-
-.data
-_sptab=.
-       106.;   cs106
-       40.;    cs40
-       41.;    cs40
-       55.;    cs40
-       48.;    cs40
-       58.;    cs58
-       56.;    cs56
-       0
-.text
-
-/ name
-cs106:
-%z,n
-%zf,n
-       clrB1   -(sp)
-
-%aw,n
-       mov     A1,-(sp)
-
-%nw*,n
-       F*
-       mov     #1(R),-(sp)
-
-%al,n
-       mov     A1+,-(sp)
-       mov     A1,-(sp)
-
-/ +, -, |, &~
-cs40:
-%a,1
-       FS
-       I'      (sp)
-
-%a,aw
-       FS
-       I       A2,(sp)
-
-%a,nw*
-       FS
-       S*
-       I       #2(R),(sp)
-
-%a,n
-       FS
-       S
-       I       R,(sp)
-
-/ integer to long
-cs58:
-%nu,n
-       FS
-       clr     -(sp)
-
-%n,n
-       FS
-       sxt     -(sp)
-
-/ float to long
-cs56:
-%nf,n
-       F
-       setl
-       movfi   R,-(sp)
-       seti
-
-/ setup for structure assign
-ci116:
-%n,e
-       F!
-       S1!
-
-%n,n
-       SS
-       F!
-       mov     (sp)+,r1
-
diff --git a/usr/src/cmd/c2/Makefile b/usr/src/cmd/c2/Makefile
new file mode 100644 (file)
index 0000000..36b8516
--- /dev/null
@@ -0,0 +1,21 @@
+DESTDIR = 
+CFLAGS=-O -d2
+
+c2:    c20.o c21.o c22.o
+       $(CC) -o c2 c2?.o
+
+mon.o: /usr/lib/mon.c
+       $(CC) -c -p -DMASTER='"/usr/lib/c2.monsum"' -DINCREMENT='"/tmp/c2XXXXX"' /usr/lib/mon.c
+       
+c20.o: c20.c c2.h
+c21.o: c21.c c2.h
+c22.o:  c22.c c2.h
+       $(CC) $(CFLAGS) -S c22.c
+       ../as/:rofix c22.s
+       as -o c22.o c22.s
+
+clean :
+       rm -f *.o *.s
+
+install :
+       install -s c2 $(DESTDIR)/lib
diff --git a/usr/src/cmd/c2/c2.h b/usr/src/cmd/c2/c2.h
new file mode 100644 (file)
index 0000000..6f3798c
--- /dev/null
@@ -0,0 +1,159 @@
+/* @(#)c2.h 1.13 78/09/23 16:37:28 */
+/*
+ * Header for object code improver
+ */
+
+#define        JBR     1
+#define        CBR     2
+#define        JMP     3
+#define        LABEL   4
+#define        DLABEL  5
+#define        EROU    7
+#define        JSW     9
+#define        MOV     10
+#define        CLR     11
+#define        INC     12
+#define        DEC     13
+#define        TST     14
+#define        PUSH    15
+#define CVT 16
+#define        CMP     17
+#define        ADD     18
+#define        SUB     19
+#define        BIT     20
+#define        BIC     21
+#define        BIS     22
+#define        XOR     23
+#define        COM     24
+#define        NEG     25
+#define        MUL     26
+#define        DIV     27
+#define        ASH     28
+#define EXTV   29
+#define EXTZV  30
+#define INSV   31
+#define        CALLS   32
+#define RET    33
+#define        CASE    34
+#define        SOB     35
+#define        TEXT    36
+#define        DATA    37
+#define        BSS     38
+#define        ALIGN   39
+#define        END     40
+#define MOVZ 41
+#define WGEN 42
+#define SOBGEQ 43
+#define SOBGTR 44
+#define AOBLEQ 45
+#define AOBLSS 46
+#define ACB 47
+#define MOVA 48
+#define PUSHA 49
+#define LGEN 50
+#define SET 51
+
+#define        JEQ     0
+#define        JNE     1
+#define        JLE     2
+#define        JGE     3
+#define        JLT     4
+#define        JGT     5
+/* rearranged for unsigned branches so that jxxu = jxx + 6 */
+#define        JLOS    8
+#define        JHIS    9
+#define        JLO     10
+#define        JHI     11
+
+#define JBC 12
+#define JBS 13
+#define JLBC 14
+#define JLBS 15
+#define JBCC 16
+#define JBSC 17
+#define JBCS 18
+#define JBSS 19
+
+#define        BYTE    1
+#define        WORD    2
+#define LONG   3
+#define        FLOAT   4
+#define        DOUBLE  5
+#define QUAD   6
+#define OP2    7
+#define OP3    8
+#define OPB 9
+#define OPX 10
+
+#define T(a,b) (a|((b)<<8))
+#define U(a,b) (a|((b)<<4))
+
+struct optab {
+       char    opstring[7];
+       short   opcode;
+} optab[];
+
+struct node {
+       char    op;
+       char    subop;
+       short   refc;
+       struct  node    *forw;
+       struct  node    *back;
+       struct  node    *ref;
+       char    *code;
+       struct  optab   *pop;
+       short   labno;
+       short   seq;
+};
+
+struct {
+       short   combop;
+};
+
+char   line[512];
+struct node    first;
+char   *curlp;
+int    nbrbr;
+int    nsaddr;
+int    redunm;
+int    iaftbr;
+int    njp1;
+int    nrlab;
+int    nxjump;
+int    ncmot;
+int    nrevbr;
+int    loopiv;
+int    nredunj;
+int    nskip;
+int    ncomj;
+int    nsob;
+int    nrtst;
+int nbj;
+int nfield;
+
+int    nchange;
+int    isn;
+int    debug;
+char   *lasta;
+char   *lastr;
+char   *firstr;
+char   revbr[];
+#define        NREG    12
+char   *regs[NREG+5]; /* 0-11, 4 for operands, 1 for running off end */
+char   conloc[20];
+char   conval[20];
+char   ccloc[20];
+
+#define        RT1     12
+#define        RT2     13
+#define RT3 14
+#define RT4 15
+#define        LABHS   127
+
+struct { char lbyte; };
+
+char *copy();
+long getnum();
+struct node *codemove();
+struct node *insertl();
+struct node *nonlab();
diff --git a/usr/src/cmd/c2/c20.c b/usr/src/cmd/c2/c20.c
new file mode 100644 (file)
index 0000000..2c4d1a4
--- /dev/null
@@ -0,0 +1,657 @@
+#
+char C20[] = {"@(#)c20.c 1.27 78/10/23 14:06:38"}; /* sccs ident */
+/*
+ *      C object code improver
+ */
+
+#include "c2.h"
+#include <stdio.h>
+#include <ctype.h>
+
+char _sibuf[BUFSIZ], _sobuf[BUFSIZ];
+int ioflag;
+int    isn     = 20000;
+struct optab *oplook();
+struct optab *getline();
+
+struct node *
+alloc(an)
+{
+       register int n;
+       register char *p;
+
+       n = an;
+       n++;
+       n &= ~01;
+       if (lasta+n >= lastr) {
+               if (sbrk(2000) == -1) {
+                       fprintf(stderr, "Optimizer: out of space\n");
+                       exit(1);
+               }
+               lastr += 2000;
+       }
+       p = lasta;
+       lasta += n;
+       return(p);
+}
+
+main(argc, argv)
+char **argv;
+{
+       register int niter, maxiter, isend;
+       int nflag,infound;
+
+       nflag = 0; infound=0; argc--; argv++;
+       while (argc>0) {/* get flags */
+               if (**argv=='+') debug++;
+               else if (**argv=='-') {
+                       if ((*argv)[1]=='i') ioflag++; else nflag++;
+               } else if (infound==0) {
+                       if (freopen(*argv, "r", stdin) ==NULL) {
+                               fprintf(stderr,"C2: can't find %s\n", *argv);
+                               exit(1);
+                       }
+                       setbuf(stdin,_sibuf); ++infound;
+               } else if (freopen(*argv, "w", stdout) ==NULL) {
+                       fprintf(stderr,"C2: can't create %s\n", *argv);
+                       exit(1);
+               }
+               setbuf(stdout,_sobuf);
+               argc--; argv++;
+       }
+       lasta = lastr = sbrk(2);
+       opsetup();
+       lasta = firstr = lastr = alloc(0);
+       maxiter = 0;
+       do {
+               isend = input();
+               niter = 0;
+               bmove();
+               do {
+                       refcount();
+                       do {
+                               iterate();
+                               clearreg();
+                               niter++;
+                       } while (nchange);
+                       comjump();
+                       rmove();
+               } while (nchange || jumpsw());
+               addsob();
+               output();
+               if (niter > maxiter)
+                       maxiter = niter;
+               lasta = firstr;
+       } while (isend);
+       if (nflag) {
+               fprintf(stderr,"%d iterations\n", maxiter);
+               fprintf(stderr,"%d jumps to jumps\n", nbrbr);
+               fprintf(stderr,"%d inst. after jumps\n", iaftbr);
+               fprintf(stderr,"%d jumps to .+1\n", njp1);
+               fprintf(stderr,"%d redundant labels\n", nrlab);
+               fprintf(stderr,"%d cross-jumps\n", nxjump);
+               fprintf(stderr,"%d code motions\n", ncmot);
+               fprintf(stderr,"%d branches reversed\n", nrevbr);
+               fprintf(stderr,"%d redundant moves\n", redunm);
+               fprintf(stderr,"%d simplified addresses\n", nsaddr);
+               fprintf(stderr,"%d loops inverted\n", loopiv);
+               fprintf(stderr,"%d redundant jumps\n", nredunj);
+               fprintf(stderr,"%d common seqs before jmp's\n", ncomj);
+               fprintf(stderr,"%d skips over jumps\n", nskip);
+               fprintf(stderr,"%d sob's added\n", nsob);
+               fprintf(stderr,"%d redundant tst's\n", nrtst);
+               fprintf(stderr,"%d jump on bit\n", nbj);
+               fprintf(stderr,"%d field operations\n", nfield);
+               fprintf(stderr,"%dK core\n", ((unsigned)lastr+01777) >> 10);
+       }
+       fflush(stdout); exit(0);
+}
+
+input()
+{
+       register struct node *p, *lastp;
+       struct optab *op; register char *cp1;
+       static struct optab F77JSW = {".long", T(JSW,1)};
+
+       lastp = &first;
+       for (;;) {
+         top:
+               op = getline();
+               if (debug && op==0) fprintf(stderr,"? %s\n",line);
+               switch (op->opcode&0377) {
+       
+               case LABEL:
+                       p = alloc(sizeof first);
+                       if (line[0] == 'L') {
+                               p->combop = LABEL;
+                               p->labno = getnum(line+1);
+                               if (isn<=p->labno) isn=1+p->labno;
+                               p->code = 0;
+                       } else {
+                               p->combop = DLABEL;
+                               p->labno = 0;
+                               p->code = copy(line);
+                       }
+                       break;
+       
+               case LGEN:
+                       if (*curlp!='L') goto std;
+                       op= &F77JSW;
+               case JBR:
+                       if (op->opcode==T(JBR,RET)) goto std;
+               case CBR:
+               case JMP:
+               case JSW:
+               case SOBGEQ: case SOBGTR: case AOBLEQ: case AOBLSS: case ACB:
+                       p = alloc(sizeof first);
+                       p->combop = op->opcode; p->code=0; cp1=curlp;
+                       if (*cp1!='L' || 0==(p->labno = getnum(cp1+1))) {/* jbs, etc.? */
+                               while (*cp1++); while (*--cp1!=',' && cp1!=curlp);
+                               if (cp1==curlp || *++cp1!='L' || 0==(p->labno=getnum(cp1+1)))
+                                       p->labno = 0;
+                               else *--cp1=0;
+                               p->code = copy(curlp);
+                       }
+                       if (isn<=p->labno) isn=1+p->labno;
+                       break;
+
+               case MOVA:
+                       p=alloc(sizeof first);
+                       p->combop=op->opcode; p->code=0; cp1=curlp;
+                       if (*cp1++=='L') {
+                               while (*cp1++!=','); *--cp1=0;
+                               if (0!=(p->labno=getnum(curlp+1))) p->code=copy(cp1+1);
+                               else {*cp1=','; p->code=copy(curlp);}
+                       } else p->code=copy(--cp1);
+                       break;
+
+               case SET:
+                       printf("%s\n",line); goto top;
+
+               case BSS:
+               case DATA:
+                       for (;;) {
+                               printf("%s%c",line,(op->opcode==LABEL ? ':' : '\n'));
+                               if (op->opcode==TEXT) goto top;
+                               if (END==(op=getline())->opcode) {/* dangling .data is bad for you */
+                                       printf(".text\n");
+                                       break;
+                               }
+                       }
+
+               std:
+               default:
+                       p = alloc(sizeof first);
+                       p->combop = op->opcode;
+                       p->labno = 0;
+                       p->code = copy(curlp);
+                       break;
+
+               }
+               p->forw = 0;
+               p->back = lastp;
+               p->pop = op;
+               lastp->forw = p;
+               lastp = p;
+               p->ref = 0;
+               if (p->op==CASE) {
+                       char *lp; int ncase;
+                       lp=curlp; while (*lp++); while (*--lp!='$'); ncase=getnum(lp+1);
+                       if (LABEL!=(getline())->opcode) abort(-2);
+                       do {
+                               if (WGEN!=(getline())->opcode) abort(-3);
+                               p = alloc(sizeof first); p->combop = JSW; p->code = 0;
+                               lp=curlp; while(*lp++!='-'); *--lp=0; p->labno=getnum(curlp+1);
+                               if (isn<=p->labno) isn=1+p->labno;
+                               p->forw = 0; p->back = lastp; lastp->forw = p; lastp = p;
+                               p->ref = 0; p->pop=0;
+                       } while (--ncase>=0);
+               }
+               if (op->opcode==EROU)
+                       return(1);
+               if (op->opcode==END)
+                       return(0);
+       }
+}
+
+struct optab *
+getline()
+{
+       register char *lp;
+       register c;
+       static struct optab OPLABEL={"",LABEL};
+       static struct optab OPEND={"",END};
+
+       lp = line;
+       while (EOF!=(c=getchar()) && isspace(c));
+       while (EOF!=c) {
+               if (c==':') {
+                       *lp++ = 0;
+                       return(&OPLABEL);
+               }
+               if (c=='\n') {
+                       *lp++ = 0;
+                       return(oplook());
+               }
+               *lp++ = c;
+               c = getchar();
+       }
+       *lp++ = 0;
+       return(&OPEND);
+}
+
+long
+getnum(p)
+register char *p;
+{
+       register c; int neg; register long n;
+
+       n = 0; neg=0; if (*p=='-') {++neg; ++p;}
+       while (isdigit(c = *p++)) {
+                c -= '0'; n *= 10; if (neg) n -= c; else n += c;
+       }
+       if (*--p != 0)
+               return(0);
+       return(n);
+}
+
+output()
+{
+       register struct node *t;
+       int casebas;
+
+       t = &first;
+       while (t = t->forw) switch (t->op) {
+
+       case END:
+               return;
+
+       case LABEL:
+               printf("L%d:", t->labno);
+               continue;
+
+       case DLABEL:
+               printf("%s:", t->code);
+               continue;
+
+       case CASE:
+               casebas=0;
+
+       default: std:
+               if (t->pop==0) {/* must find it */
+                       register struct optab *p;
+                       for (p=optab; p->opstring[0]; ++p)
+                               if (p->opcode==t->combop) {t->pop=p; break;}
+               }
+               printf("%s", t->pop->opstring);
+               if (t->code) printf("\t%s", t->code);
+               if (t->labno!=0) printf("%cL%d\n",
+                                                       (t->code ? ',' : '\t'),
+                                                       t->labno);
+               else printf("\n");
+               continue;
+
+       case MOVA:
+               if (t->labno==0) goto std;
+               printf("mova%c\tL%d,%s\n","bwlq"[t->subop-BYTE],t->labno,t->code);
+               continue;
+
+       case JSW:
+               if (t->subop!=0) {/* F77JSW */
+                       printf(".long\tL%d\n",t->labno); continue;
+               }
+               if (casebas==0) printf("L%d:\n",casebas=isn++);
+               printf(".word   L%d-L%d\n", t->labno, casebas);
+               continue;
+
+       }
+}
+
+char *
+copy(ap)
+char *ap;
+{
+       register char *p, *np;
+       char *onp;
+       register n;
+       int na;
+
+       na = nargs();
+       p = ap;
+       n = 0;
+       if (*p==0)
+               return(0);
+       do
+               n++;
+       while (*p++);
+       if (na>1) {
+               p = (&ap)[1];
+               while (*p++)
+                       n++;
+       }
+       onp = np = alloc(n);
+       p = ap;
+       while (*np++ = *p++);
+       if (na>1) {
+               p = (&ap)[1];
+               np--;
+               while (*np++ = *p++);
+       }
+       return(onp);
+}
+
+#define        OPHS    560
+struct optab *ophash[OPHS];
+
+opsetup()
+{
+       register struct optab *optp, **ophp;
+       register int i,t;
+
+       for(i=NREG+5;--i>=0;) regs[i]=alloc(20);
+       for (optp = optab; optp->opstring[0]; optp++) {
+               t=7; i=0; while (--t>=0) i+= i+optp->opstring[t];
+               ophp = &ophash[i % OPHS];
+               while (*ophp++) {
+/*                     fprintf(stderr,"\ncollision: %d %s %s",
+/*                             ophp-1-ophash,optp->opstring,(*(ophp-1))->opstring);
+*/
+                       if (ophp > &ophash[OPHS])
+                               ophp = ophash;
+               }
+               *--ophp = optp;
+       }
+}
+
+struct optab *
+oplook()
+{
+       register struct optab *optp,**ophp;
+       register char *p,*p2;
+       register int t;
+       char tempop[20];
+       static struct optab OPNULL={"",0};
+
+       for (p=line, p2=tempop; *p && !isspace(*p); *p2++= *p++); *p2=0; p2=p;
+       while (isspace(*p2)) ++p2; curlp=p2;
+       t=0; while(--p>=line) t += t+*p; ophp = &ophash[t % OPHS];
+       while (optp = *ophp) {
+               if (equstr(tempop,optp->opstring)) return(optp);
+               if ((++ophp) >= &ophash[OPHS]) ophp = ophash;
+       }
+       curlp = line;
+       return(&OPNULL);
+}
+
+refcount()
+{
+       register struct node *p, *lp;
+       struct node *labhash[LABHS];
+       register struct node **hp;
+
+       for (hp = labhash; hp < &labhash[LABHS];)
+               *hp++ = 0;
+       for (p = first.forw; p!=0; p = p->forw)
+               if (p->op==LABEL) {
+                       labhash[p->labno % LABHS] = p;
+                       p->refc = 0;
+               }
+       for (p = first.forw; p!=0; p = p->forw) {
+               if (p->op==JBR || p->op==CBR || p->op==JSW
+                 || p->op==SOBGEQ || p->op==SOBGTR || p->op==AOBLEQ || p->op==AOBLSS
+                 || p->op==ACB || (p->op==MOVA && p->labno!=0)) {
+                       p->ref = 0;
+                       lp = labhash[p->labno % LABHS];
+                       if (lp==0 || p->labno!=lp->labno)
+                       for (lp = first.forw; lp!=0; lp = lp->forw) {
+                               if (lp->op==LABEL && p->labno==lp->labno)
+                                       break;
+                       }
+                       if (lp) {
+                               hp = nonlab(lp)->back;
+                               if (hp!=lp) {
+                                       p->labno = hp->labno;
+                                       lp = hp;
+                               }
+                               p->ref = lp;
+                               lp->refc++;
+                       }
+               }
+       }
+       for (p = first.forw; p!=0; p = p->forw)
+               if (p->op==LABEL && p->refc==0
+                && (lp = nonlab(p))->op && lp->op!=JSW)
+                       decref(p);
+}
+
+iterate()
+{
+       register struct node *p, *rp, *p1;
+
+       nchange = 0;
+       for (p = first.forw; p!=0; p = p->forw) {
+               if ((p->op==JBR||p->op==CBR||p->op==JSW) && p->ref) {
+                       rp = nonlab(p->ref);
+                       if (rp->op==JBR && rp->labno && p->labno!=rp->labno) {
+                               nbrbr++;
+                               p->labno = rp->labno;
+                               decref(p->ref);
+                               rp->ref->refc++;
+                               p->ref = rp->ref;
+                               nchange++;
+                       }
+               }
+               if (p->op==CBR && (p1 = p->forw)->combop==JBR) {/* combop: RET problems */
+                       rp = p->ref;
+                       do
+                               rp = rp->back;
+                       while (rp->op==LABEL);
+                       if (rp==p1) {
+                               decref(p->ref);
+                               p->ref = p1->ref;
+                               p->labno = p1->labno;
+                               p1->forw->back = p;
+                               p->forw = p1->forw;
+                               p->subop = revbr[p->subop];
+                               p->pop=0;
+                               nchange++;
+                               nskip++;
+                       }
+               }
+               if (p->op==JBR || p->op==JMP) {
+                       while (p->forw && p->forw->op!=LABEL && p->forw->op!=DLABEL
+                               && p->forw->op!=EROU && p->forw->op!=END
+                               && p->forw->op!=ALIGN
+                               && p->forw->op!=0 && p->forw->op!=DATA) {
+                               nchange++;
+                               iaftbr++;
+                               if (p->forw->ref)
+                                       decref(p->forw->ref);
+                               p->forw = p->forw->forw;
+                               p->forw->back = p;
+                       }
+                       rp = p->forw;
+                       while (rp && rp->op==LABEL) {
+                               if (p->ref == rp) {
+                                       p->back->forw = p->forw;
+                                       p->forw->back = p->back;
+                                       p = p->back;
+                                       decref(rp);
+                                       nchange++;
+                                       njp1++;
+                                       break;
+                               }
+                               rp = rp->forw;
+                       }
+                       xjump(p);
+                       p = codemove(p);
+               }
+       }
+}
+
+xjump(p1)
+register struct node *p1;
+{
+       register struct node *p2, *p3;
+       int nxj;
+
+       nxj = 0;
+       if ((p2 = p1->ref)==0)
+               return(0);
+       for (;;) {
+               while ((p1 = p1->back) && p1->op==LABEL);
+               while ((p2 = p2->back) && p2->op==LABEL);
+               if (!equop(p1, p2) || p1==p2)
+                       return(nxj);
+               p3 = insertl(p2);
+               p1->combop = JBR;
+               p1->pop=0;
+               p1->ref = p3;
+               p1->labno = p3->labno;
+               p1->code = 0;
+               nxj++;
+               nxjump++;
+               nchange++;
+       }
+}
+
+struct node *
+insertl(op)
+register struct node *op;
+{
+       register struct node *lp;
+
+       if (op->op == LABEL) {
+               op->refc++;
+               return(op);
+       }
+       if (op->back->op == LABEL) {
+               op = op->back;
+               op->refc++;
+               return(op);
+       }
+       lp = alloc(sizeof first);
+       lp->combop = LABEL;
+       lp->labno = isn++;
+       lp->ref = 0;
+       lp->code = 0;
+       lp->refc = 1;
+       lp->back = op->back;
+       lp->forw = op;
+       op->back->forw = lp;
+       op->back = lp;
+       return(lp);
+}
+
+struct node *
+codemove(ap)
+struct node *ap;
+{
+       register struct node *p1, *p2, *p3;
+       struct node *t, *tl;
+       int n;
+
+       p1 = ap;
+       if (p1->op!=JBR || (p2 = p1->ref)==0)
+               return(p1);
+       while (p2->op == LABEL)
+               if ((p2 = p2->back) == 0)
+                       return(p1);
+       if (p2->op!=JBR && p2->op!=JMP)
+               goto ivloop;
+       p2 = p2->forw;
+       p3 = p1->ref;
+       while (p3) {
+               if (p3->op==JBR || p3->op==JMP) {
+                       if (p1==p3)
+                               return(p1);
+                       ncmot++;
+                       nchange++;
+                       p1->back->forw = p2;
+                       p1->forw->back = p3;
+                       p2->back->forw = p3->forw;
+                       p3->forw->back = p2->back;
+                       p2->back = p1->back;
+                       p3->forw = p1->forw;
+                       decref(p1->ref);
+                       return(p2);
+               } else
+                       p3 = p3->forw;
+       }
+       return(p1);
+ivloop:
+       if (p1->forw->op!=LABEL)
+               return(p1);
+       p3 = p2 = p2->forw;
+       n = 16;
+       do {
+               if ((p3 = p3->forw) == 0 || p3==p1 || --n==0)
+                       return(p1);
+       } while (p3->op!=CBR || p3->labno!=p1->forw->labno);
+       do 
+               if ((p1 = p1->back) == 0)
+                       return(ap);
+       while (p1!=p3);
+       p1 = ap;
+       tl = insertl(p1);
+       p3->subop = revbr[p3->subop];
+       p3->pop=0;
+       decref(p3->ref);
+       p2->back->forw = p1;
+       p3->forw->back = p1;
+       p1->back->forw = p2;
+       p1->forw->back = p3;
+       t = p1->back;
+       p1->back = p2->back;
+       p2->back = t;
+       t = p1->forw;
+       p1->forw = p3->forw;
+       p3->forw = t;
+       p2 = insertl(p1->forw);
+       p3->labno = p2->labno;
+       p3->ref = p2;
+       decref(tl);
+       if (tl->refc<=0)
+               nrlab--;
+       loopiv++;
+       nchange++;
+       return(p3);
+}
+
+comjump()
+{
+       register struct node *p1, *p2, *p3;
+
+       for (p1 = first.forw; p1!=0; p1 = p1->forw)
+               if (p1->op==JBR && ((p2 = p1->ref) && p2->refc > 1 || p1->subop==RET))
+                       for (p3 = p1->forw; p3!=0; p3 = p3->forw)
+                               if (p3->op==JBR && p3->ref == p2)
+                                       backjmp(p1, p3);
+}
+
+backjmp(ap1, ap2)
+struct node *ap1, *ap2;
+{
+       register struct node *p1, *p2, *p3;
+
+       p1 = ap1;
+       p2 = ap2;
+       for(;;) {
+               while ((p1 = p1->back) && p1->op==LABEL);
+               p2 = p2->back;
+               if (equop(p1, p2)) {
+                       p3 = insertl(p1);
+                       p2->back->forw = p2->forw;
+                       p2->forw->back = p2->back;
+                       p2 = p2->forw;
+                       decref(p2->ref);
+                       p2->combop = JBR; /* to handle RET */
+                       p2->pop=0;
+                       p2->labno = p3->labno;
+                       p2->ref = p3;
+                       nchange++;
+                       ncomj++;
+               } else
+                       return;
+       }
+}
diff --git a/usr/src/cmd/c2/c21.c b/usr/src/cmd/c2/c21.c
new file mode 100644 (file)
index 0000000..00b9740
--- /dev/null
@@ -0,0 +1,955 @@
+#
+char C21[] = {"@(#)c21.c 1.59 79/01/20 11:07:52"}; /* sccs ident */
+/*
+ * C object code improver-- second part
+ */
+
+#include "c2.h"
+#include <stdio.h>
+#include <ctype.h>
+
+#define NUSE 6
+int ioflag;
+int biti[NUSE] = {1,2,4,8,16,32};
+int bitsize[4] = {0,8,16,32}; /* index by type codes */
+int pos,siz; long f; /* for bit field communication */
+struct node *uses[NUSE]; /* for backwards flow analysis */
+char *lastrand; /* last operand of instruction */
+struct node *bflow();
+struct node *bicopt();
+char *findcon();
+
+redun3(p,split) register struct node *p; int split; {
+/* check for 3 addr instr which should be 2 addr */
+       if (OP3==((p->subop>>4)&0xF)) {
+               if (split) splitrand(p);
+               if (equstr(regs[RT1],regs[RT3])
+                 && (p->op==ADD || p->op==MUL || p->op==BIS || p->op==XOR)) {
+                       register char *t=regs[RT1]; regs[RT1]=regs[RT2]; regs[RT2]=t;
+               }
+               if (equstr(regs[RT2],regs[RT3])) {
+                       p->subop=(p->subop&0xF)|(OP2<<4); p->pop=0;
+                       lastrand=regs[RT2]; *regs[RT3]=0; return(1);
+               }
+       } return(0);
+}
+
+bmove() {
+       register struct node *p, *lastp; register char *cp1,*cp2; register int r;
+       refcount();
+       for (p=lastp= &first; 0!=(p=p->forw); lastp=p);
+       clearreg(); clearuse();
+       for (p=lastp; p!= &first; p=p->back) {
+       if (debug) {
+               for (r=NUSE;--r>=0;) if (uses[r]) printf("%d: %s\n",r,uses[r]->code);
+               printf("-\n");
+       }
+       if (OP3==((p->subop>>4)&0xF) && 0!=redun3(p,1)) {newcode(p); redunm++;}
+       switch (p->op) {
+       case LABEL: case DLABEL:
+       if (p->back && p->back->op==JBR && p->back->subop!=RET)
+               for (r=NUSE; --r>=0;) if (uses[r] && regs[r][0]!= -1)
+                       p->ref=(struct node *) (((int)p->ref)|biti[r]);
+       case CALLS: case 0:
+               clearuse(); break;
+       case SUB:
+               if ((p->subop&0xF)!=LONG) goto std; cp1=p->code;
+               if (*cp1++!='$') goto std; splitrand(p);
+               if (equstr(regs[RT2],"fp") && !indexa(regs[RT1])) {/* address comp. */
+                       char buf[50]; cp2=buf; *cp2++='-'; 
+                       cp1=regs[RT1]+1; while (*cp2++= *cp1++); --cp2;
+                       cp1="(fp),"; while (*cp2++= *cp1++); --cp2;
+                       cp1=regs[RT3]; while (*cp2++= *cp1++);
+                       p->code=copy(buf); p->combop=T(MOVA,LONG); p->pop=0;
+               } else if (*cp1++=='-' && 0<=(r=getnum(cp1))) {
+                       p->op=ADD; p->pop=0; *--cp1='$'; p->code=cp1;
+               } goto std;
+       case ADD:
+               if ((p->subop&0xF)!=LONG) goto std; cp1=p->code;
+               if (*cp1++!='$') goto std; splitrand(p);
+               if (equstr(regs[RT2],"fp") && !indexa(regs[RT1])) {/* address comp. */
+                       cp2=cp1-1; cp1=regs[RT1]+1; while (*cp2++= *cp1++); --cp2;
+                       cp1="(fp)"; while (*cp2++= *cp1++); *--cp2=',';
+                       p->combop=T(MOVA,LONG); p->pop=0;
+               } else if (*cp1++=='-' && 0<=(r=getnum(cp1))) {
+                       p->op=SUB; p->pop=0; *--cp1='$'; p->code=cp1;
+               }
+       case CASE:
+       default: std:
+               p=bflow(p); break;
+       case JBR:
+               if (p->subop==RET) {uses[0]=p; regs[0][0]= -1; break;}
+               else if (p->ref->ref!=0) for (r=NUSE;--r>=0;)
+                       if (biti[r] & (int)p->ref->ref) {uses[r]=p; regs[r][0]= -1;}
+       case CBR: case JMP: case EROU: case JSW:
+       case TEXT: case DATA: case BSS: case ALIGN: case WGEN: case END: ;
+       }
+       }
+}
+
+rmove()
+{
+       register struct node *p, *lastp;
+       register int r;
+       int r1;
+
+       clearreg();
+       for (p=first.forw; p!=0; p = p->forw) {
+       lastp=p;
+       if (debug) {
+               for (r=0; r<NREG; r++)
+                       if (regs[r][0]) {
+                               r1=regs[r][0];
+                               printf("%d: %d%d %s\n", r, r1&0xF, r1>>4, regs[r]+1);
+                       }
+               printf("-\n");
+       }
+       switch (p->op) {
+
+       case CVT:
+               splitrand(p); goto mov;
+
+       case MOV:
+               splitrand(p);
+               if ((r = findrand(regs[RT1],p->subop)) >= 0) {
+                       if (r == isreg(regs[RT2]) && p->forw->op!=CBR) {
+                               delnode(p); redunm++; break;
+                       }
+               }
+       mov:
+               repladdr(p);
+               r = isreg(regs[RT1]);
+               r1 = isreg(regs[RT2]);
+               dest(regs[RT2],p->subop);
+               if (r >= 0)
+                       if (r1 >= 0) savereg(r1, regs[r]+1, p->subop);
+                       else savereg(r, regs[RT2], p->subop);
+               else
+                       if (r1 >= 0) savereg(r1, regs[RT1], p->subop);
+                       else setcon(regs[RT1], regs[RT2], p->subop);
+               break;
+
+/* .rx,.wx */
+       case COM:
+       case NEG:
+/* .rx,.wx or .rx,.rx,.wx */
+       case ADD:
+       case SUB:
+       case BIC:
+       case BIS:
+       case XOR:
+       case MUL:
+       case DIV:
+       case ASH:
+       case MOVZ:
+/* .rx,.rx,.rx,.wx */
+       case EXTV:
+       case EXTZV:
+       case INSV:
+               splitrand(p);
+               repladdr(p);
+               dest(lastrand,p->subop);
+               if (p->op==INSV) ccloc[0]=0;
+               break;
+
+/* .mx or .wx */
+       case CLR:
+       case INC:
+       case DEC:
+               splitrand(p);
+               dest(lastrand,p->subop);
+               if (p->op==CLR)
+                       if ((r = isreg(regs[RT1])) >= 0)
+                               savereg(r, "$0", p->subop);
+                       else
+                               setcon("$0", regs[RT1], p->subop);
+               break;
+
+/* .rx */
+       case TST:
+       case PUSH:
+               splitrand(p);
+               lastrand=regs[RT1+1]; /* fool repladdr into doing 1 operand */
+               repladdr(p);
+               if (p->op==TST && equstr(lastrand=regs[RT1], ccloc+1)
+                 && equtype(ccloc[0],p->subop) &&!source(lastrand)) {
+                       delnode(p); p = p->back; nrtst++; nchange++;
+               }
+               setcc(lastrand,p->subop);
+               break;
+
+/* .rx,.rx,.rx */
+       case CASE:
+/* .rx,.rx */
+       case CALLS:
+       case CMP:
+       case BIT:
+               splitrand(p);
+               /* fool repladdr into doing right number of operands */
+               if (p->op!=CASE) lastrand=regs[RT3]; else lastrand=regs[RT4];
+               repladdr(p);
+               if (p->op==CALLS) clearreg();
+               if (p->op==BIT) bitopt(p);
+               ccloc[0]=0; break;
+
+       case CBR:
+               if (p->subop>=JBC) {/* 2 operands can be optimized */
+                       splitrand(p); lastrand=regs[RT3]; repladdr(p);
+               }
+               ccloc[0] = 0;
+               break;
+
+       case JBR:
+               redunbr(p);
+
+/* .wx,.bb */
+       case SOB:
+
+       default:
+               clearreg();
+       }
+       }
+}
+
+char *
+byondrd(p) register struct node *p; {
+/* return pointer to register which is "beyond last read/modify operand" */
+       if (OP2==(p->subop>>4)) return(regs[RT3]);
+       switch (p->op) {
+               case PUSHA:
+               case TST: case INC: case DEC: case PUSH:        return(regs[RT2]);
+               case BIT: case CMP: case CALLS:                         return(regs[RT3]);
+               case CASE:                                                                      return(regs[RT4]);
+       }
+       return(lastrand);
+}
+
+struct node *
+bflow(p) register struct node *p; {
+       register char *cp1,*cp2,**preg; register int r;
+       splitrand(p);
+       if (0<=(r=isreg(lastrand)) && r<NUSE && p->op!=PUSH &&
+         uses[r]==p->forw && p->subop && equtype(regs[r][0],p->subop)) {
+               if (regs[r][1]!=0) {/* send directly to destination */
+                       if (p->op==INC || p->op==DEC) {
+                               if (p->op==DEC) p->op=SUB; else p->op=ADD;
+                               p->subop=(OP2<<4)+(p->subop&0xF); /* use 2 now, convert to 3 later */
+                               p->pop=0;
+                               cp1=lastrand; cp2=regs[RT2]; while (*cp2++= *cp1++); /* copy reg */
+                               cp1=lastrand; *cp1++='$'; *cp1++='1'; *cp1=0;
+                       }
+                       cp1=regs[r]+1; cp2=lastrand;
+                       if (OP2==(p->subop>>4)) {/* use 3 operand form of instruction */
+                               p->pop=0;
+                               p->subop += (OP3-OP2)<<4; lastrand=cp2=regs[RT3];
+                       }
+                       while (*cp2++= *cp1++);
+                       if (p->op==MOVA && p->forw->op==PUSH) {
+                               p->op=PUSHA; *regs[RT2]=0; p->pop=0;
+                       }
+                       delnode(p->forw);
+                       redun3(p,0);
+                       newcode(p); redunm++; uses[r]=0; *(short *)(regs[r])=0;
+               } else if (p->op==MOV && p->forw->op!=EXTV && p->forw->op!=EXTZV) {
+                       /* superfluous fetch */
+                       int nmatch;
+                       char src[20]; cp2=src; cp1=regs[RT1]; while (*cp2++= *cp1++);
+                       splitrand(p->forw); lastrand=byondrd(p->forw); nmatch=0;
+                       for (preg=regs+RT1;*preg!=lastrand;preg++) if (r==isreg(*preg)) {
+                               cp2= *preg; cp1=src; while (*cp2++= *cp1++); ++nmatch;
+                       }
+                       if (nmatch==1) {
+                               if (OP2==(p->forw->subop>>4) && equstr(src,regs[RT2])) {
+                                       p->forw->pop=0;
+                                       p->forw->subop += (OP3-OP2)<<4; cp1=regs[RT3];
+                                       *cp1++='r'; *cp1++=r+'0'; *cp1=0;
+                               }
+                               delnode(p); p=p->forw;
+                               redun3(p,0);
+                               newcode(p); redunm++; uses[r]=0; *(short *)(regs[r])=0;
+                       }
+               }
+       }
+       /* adjust 'lastrand' past any 'read' or 'modify' operands. */
+       lastrand=byondrd(p);
+       /* a 'write' clobbers the register. */
+       if (0<=(r=isreg(lastrand)) && r<NUSE
+         || OP2==(p->subop>>4) && 0<=(r=isreg(regs[RT2])) && r<NUSE)
+               {uses[r]=0; *(short *)(regs[r])=0;}
+       if (p->op==BIC) {p=bicopt(p); splitrand(p); lastrand=byondrd(p);}
+       if (p->op==BIS) bixprep(p,JBSS);
+       /* now look for 'read' or 'modify' (read & write) uses */
+       preg=regs+RT1; 
+       while (*(cp1= *preg++)) {
+               /* check for  r  */
+               if (lastrand!=cp1 && 0<=(r=isreg(cp1)) && r<NUSE && uses[r]==0) {
+                       uses[r]=p; cp2=regs[r]; *cp2++=p->subop;
+                       if (p->op==MOV || p->op==PUSH) {
+                               if (p->op==PUSH) cp1="-(sp)"; else cp1=regs[RT2];
+                               while (*cp2++= *cp1++);
+                       } else *cp2++=0;
+                       continue;
+               }
+               /* check for (r),(r)+,-(r),[r] */
+               do if (*cp1=='(' || *cp1=='[') {/* get register number */
+                       char t;
+                       cp2= ++cp1; while (*++cp1!=')' && *cp1!=']'); t= *cp1; *cp1=0;
+                       if (0<=(r=isreg(cp2)) && r<NUSE && (uses[r]==0 || uses[r]==p)) {
+                               uses[r]=p; regs[r][0]=(*--cp2=='[' ? OPX<<4 : OPB<<4);
+                       }
+                       *cp1=t;
+               } while (*++cp1);
+       }
+       /* pushax or movax possibility? */
+       cp1=regs[RT1];
+       if (*cp1++=='$'
+         && (*cp1=='_' || *cp1=='L' || (*cp1++=='v' && *cp1=='.'))
+         && natural(regs[RT1])) {
+               if (p->combop==T(MOV,LONG)) {
+                       if (regs[RT1][1]=='L' && 0!=(p->labno=getnum(regs[RT1]+2))) {
+                               cp1=p->code; while (*cp1++!=','); p->code= --cp1;
+                       }
+                       p->combop=T(MOVA,LONG); ++p->code; p->pop=0;
+               } else if (p->combop==T(PUSH,LONG)) {
+                       p->combop=T(PUSHA,LONG); ++p->code; p->pop=0;
+               } else if ((p->combop&0xFFFF)==T(ADD,U(LONG,OP3))
+                                && 0<=(r=isreg(regs[RT2]))) {
+                       cp1=cp2=p->code; ++cp1;
+                       do *cp2++= *cp1; while (*cp1++!=','); cp2[-1]='[';
+                       do *cp2++= *cp1; while (*cp1++!=','); cp2[-1]=']';
+                       if (!equstr(regs[RT3],"-(sp)")) p->combop=T(MOVA,BYTE);
+                       else {p->combop=T(PUSHA,BYTE); *cp2=0;}
+                       if (uses[r]==0) {uses[r]=p; regs[r][0]=OPX<<4;}
+                       p->pop=0;
+               }
+       }
+       return(p);
+}
+
+ispow2(n) register long n; {/* -1 -> no; else -> log to base 2 */
+       register int log;
+       if (n==0 || n&(n-1)) return(-1); log=0;
+       for (;;) {n >>= 1; if (n==0) return(log); ++log; if (n== -1) return(log);}
+}
+
+bitopt(p) register struct node *p; {
+       /* change "bitx $<power_of_2>,a" followed by JEQ or JNE
+       /* into JBC or JBS.  watch out for I/O registers. (?)
+       /* assumes that 'splitrand' has already been called.
+       */
+       register char *cp1,*cp2; int b;
+       cp1=regs[RT1]; cp2=regs[RT2];
+       if (*cp1++!='$' || !okio(cp2) || p->forw->op!=CBR || p->forw->subop&-2 ||
+               0>(b=ispow2(getnum(cp1))) || p->subop!=BYTE && indexa(cp2)) return;
+       if (b>=bitsize[p->subop]) {/* you dummy! */
+               if (source(cp2)) {/* side effect: auto increment or decrement */
+                       p->pop=0;
+                       p->op=TST; --cp1; while (*cp1++= *cp2++);
+                       regs[RT2][0]=0; newcode(p);
+               } else delnode(p);
+               p = p->forw;
+               if (p->subop==JEQ) {p->combop=JBR; p->pop=0;}
+               else delnode(p);
+               nchange++; nbj++; return;
+       }
+       if (cp1=p->forw->code) {/* destination is not an internal label */
+               cp2=regs[RT3]; while (*cp2++= *cp1++);
+       }
+       if (b==0 && (p->subop==LONG || !indexa(regs[RT2]))) {/* JLB optimization, ala BLISS */
+               cp2=regs[RT1]; cp1=regs[RT2]; while (*cp2++= *cp1++);
+               cp2=regs[RT2]; cp1=regs[RT3]; while (*cp2++= *cp1++);
+               *(regs[RT3])=0; p->forw->subop += JLBC-JBC;
+               p->forw->pop=0;
+       } else {
+               cp1=regs[RT1]+1;
+               if (b>9) *cp1++= b/10 +'0'; *cp1++= b%10 +'0'; *cp1=0; /* $<bit_number> */
+       }
+       nbj++; newcode(p); p->combop = p->forw->combop+((JBC-JEQ)<<8);
+       p->labno = p->forw->labno; delnode(p->forw);
+       p->pop=0;
+}
+
+isfield(n) register long n; {/* -1 -> no; else -> position of low bit */
+       register int pos; register long t;
+       t= ((n-1)|n) +1;
+       if (n!=0 && (0==t || 0==n || 0<=ispow2(t))) {
+               pos=0; while(!(n&1)) {n >>= 1; ++pos;} return(pos);
+       } else return(-1);
+}
+
+bixprep(p,bix) register struct node *p; {
+/* initial setup, single-bit checking for bisopt, bicopt.
+/* return: 0->don't bother any more; 1->worthwhile trying
+*/
+       register char *cp1,*cp2;
+       splitrand(p); cp1=regs[RT1]; cp2=regs[RT2];
+       if (*cp1++!='$' || 0>(pos=isfield(f=getnum(cp1)))
+         || !okio(cp2) || indexa(cp2) || source(cp2) || !okio(lastrand)) return(0);
+       f |= f-1; if (++f==0) siz=32-pos; else siz=ispow2(f)-pos;
+       if (siz==1 && pos>5 && (p->subop>>4)==OP2 && (p->subop&0xF)!=BYTE
+         && pos<bitsize[p->subop&0xF]) {
+               p->ref = insertl(p->forw); p->combop = CBR | (bix<<8);
+               p->pop=0;
+               p->labno = p->ref->labno;
+               if (pos>9) {*cp1++= pos/10 +'0'; pos %= 10;}
+               *cp1++=pos+'0'; *cp1=0; newcode(p); nbj++; return(0);
+       }
+       return(1);
+}
+
+
+struct node *
+bicopt(p) register struct node *p; {
+/* use field operations or MOVZ if possible.  done as part of 'bflow'.
+*/
+       register char *cp1,*cp2; int r;
+       char src[50];
+       if (!bixprep(p,JBCC)) return(p);
+       if (f<=0) {/* the BIC isolates low order bits */
+               siz=pos; pos=0;
+               if ((p->subop&0xF)==LONG && *(regs[RT2])!='$') {/* result of EXTZV is long */
+                       /* save source of BICL in 'src' */
+                       cp1=regs[RT2]; cp2=src; while (*cp2++= *cp1++);
+                       if (p->back->op==ASH) {/* try for more */
+                               splitrand(p->back); cp1=regs[RT1]; cp2=regs[RT3];
+                               if (*cp1++=='$' && *(regs[RT2])!='$' && !indexa(regs[RT2])
+                                 && 0>(f=getnum(cp1)) && equstr(src,cp2)
+                                 && 0<=(r=isreg(cp2)) && r<NUSE && uses[r]==0) {/* a good ASH */
+                                       pos -= f; cp1=regs[RT2]; cp2=src; while (*cp2++= *cp1++);
+                                       delnode(p->back);
+                               }
+                       }
+                       if (p->back->op==CVT || p->back->op==MOVZ) {/* greedy, aren't we? */
+                               splitrand(p->back); cp1=regs[RT1]; cp2=regs[RT2];
+                               if (equstr(src,cp2) && okio(cp1) && !indexa(cp1)
+                                 && 0<=(r=isreg(cp2)) && r<NUSE && uses[r]==0
+                                 && bitsize[p->back->subop&0xF]>=(pos+siz)
+                                 && bitsize[p->back->subop>>4]>=(pos+siz)) {/* good CVT */
+                                       cp1=regs[RT1]; cp2=src; while (*cp2++= *cp1++);
+                                       delnode(p->back);
+                               }
+                       }
+                       /* 'pos', 'siz' known; source of field is in 'src' */
+                       splitrand(p); /* retrieve destination of BICL */
+                       if (siz==8 && pos==0) {
+                               p->combop = T(MOVZ,U(BYTE,LONG));
+                               sprintf(line,"%s,%s",src,lastrand);
+                       } else {
+                               p->combop = T(EXTZV,LONG);
+                               sprintf(line,"$%d,$%d,%s,%s",pos,siz,src,lastrand);
+                       }
+                       p->pop=0;
+                       p->code = copy(line); nfield++; return(p);
+               }/* end EXTZV possibility */
+       }/* end low order bits */
+/* unfortunately, INSV clears the condition codes, thus cannot be used */
+/*     else {/* see if BICL2 of positive field should be INSV $0 */
+/*             if (p->subop==(LONG | (OP2<<4)) && 6<=(pos+siz)) {
+/*                     p->combop = INSV;
+/*                     sprintf(line,"$0,$%d,$%d,%s",pos,siz,lastrand);
+/*                     p->code = copy(line); nfield++; return(p);
+/*             }
+/*     }
+*/
+       return(p);
+}
+
+jumpsw()
+{
+       register struct node *p, *p1;
+       register t;
+       int nj;
+
+       t = 0;
+       nj = 0;
+       for (p=first.forw; p!=0; p = p->forw)
+               p->seq = ++t;
+       for (p=first.forw; p!=0; p = p1) {
+               p1 = p->forw;
+               if (p->op == CBR && p1->op==JBR && p->ref && p1->ref
+                && abs(p->seq - p->ref->seq) > abs(p1->seq - p1->ref->seq)) {
+                       if (p->ref==p1->ref)
+                               continue;
+                       p->subop = revbr[p->subop];
+                       p->pop=0;
+                       t = p1->ref;
+                       p1->ref = p->ref;
+                       p->ref = t;
+                       t = p1->labno;
+                       p1->labno = p->labno;
+                       p->labno = t;
+                       nrevbr++;
+                       nj++;
+               }
+       }
+       return(nj);
+}
+
+addsob()
+{
+       register struct node *p, *p1, *p2, *p3;
+
+       for (p = &first; (p1 = p->forw)!=0; p = p1) {
+       if (p->combop==T(DEC,LONG) && p1->op==CBR) {
+               if (abs(p->seq - p1->ref->seq) > 12) continue;
+               if (p1->subop==JGE || p1->subop==JGT) {
+                       if (p1->subop==JGE) p->combop=SOBGEQ; else p->combop=SOBGTR;
+                       p->pop=0;
+                       p->labno = p1->labno; delnode(p1); nsob++;
+               }
+       } else if (p->combop==T(INC,LONG)) {
+               if (p1->op==LABEL && p1->refc==1 && p1->forw->combop==T(CMP,LONG)
+                 && (p2=p1->forw->forw)->combop==T(CBR,JLE)
+                 && (p3=p2->ref->back)->combop==JBR && p3->ref==p1
+                 && p3->forw->op==LABEL && p3->forw==p2->ref) {
+                       /* change       INC LAB: CMP    to      LAB: INC CMP */
+                       p->back->forw=p1; p1->back=p->back;
+                       p->forw=p1->forw; p1->forw->back=p;
+                       p->back=p1; p1->forw=p;
+                       p1=p->forw;
+                       /* adjust beginning value by 1 */
+                               p2=alloc(sizeof first); p2->combop=T(DEC,LONG);
+                               p2->pop=0;
+                               p2->forw=p3; p2->back=p3->back; p3->back->forw=p2;
+                               p3->back=p2; p2->code=p->code; p2->labno=0;
+               }
+               if (p1->combop==T(CMP,LONG) && (p2=p1->forw)->op==CBR) {
+                       register char *cp1,*cp2;
+                       splitrand(p1); if (!equstr(p->code,regs[RT1])) continue;
+                       if (abs(p->seq - p2->ref->seq)>12) {/* outside byte displ range */
+                               if (p2->subop!=JLE) continue;
+                               p->combop=T(ACB,LONG);
+                               cp2=regs[RT1]; cp1=regs[RT2]; while (*cp2++= *cp1++); /* limit */
+                               cp2=regs[RT2]; cp1="$1"; while (*cp2++= *cp1++); /* increment */
+                               cp2=regs[RT3]; cp1=p->code; while (*cp2++= *cp1++); /* index */
+                               p->pop=0; newcode(p);
+                               p->labno = p2->labno; delnode(p2); delnode(p1); nsob++;
+                       } else if (p2->subop==JLE || p2->subop==JLT) {
+                               if (p2->subop==JLE) p->combop=AOBLEQ; else p->combop=AOBLSS;
+                               cp2=regs[RT1]; cp1=regs[RT2]; while (*cp2++= *cp1++); /* limit */
+                               cp2=regs[RT2]; cp1=p->code; while (*cp2++= *cp1++); /* index */
+                               p->pop=0; newcode(p);
+                               p->labno = p2->labno; delnode(p2); delnode(p1); nsob++;
+                       }
+               }
+       }
+       }
+}
+
+abs(x)
+{
+       return(x<0? -x: x);
+}
+
+equop(p1, p2)
+register struct node *p1;
+struct node *p2;
+{
+       register char *cp1, *cp2;
+
+       if (p1->combop != p2->combop)
+               return(0);
+       if (p1->op>0 && p1->op<MOV)
+               return(0);
+       if (p1->op==MOVA && p1->labno!=p2->labno) return(0);
+       cp1 = p1->code;
+       cp2 = p2->code;
+       if (cp1==0 && cp2==0)
+               return(1);
+       if (cp1==0 || cp2==0)
+               return(0);
+       while (*cp1 == *cp2++)
+               if (*cp1++ == 0)
+                       return(1);
+       return(0);
+}
+
+delnode(p) register struct node *p; {
+       p->back->forw = p->forw;
+       p->forw->back = p->back;
+}
+
+decref(p)
+register struct node *p;
+{
+       if (p && --p->refc <= 0) {
+               nrlab++;
+               delnode(p);
+       }
+}
+
+struct node *
+nonlab(ap)
+struct node *ap;
+{
+       register struct node *p;
+
+       p = ap;
+       while (p && p->op==LABEL)
+               p = p->forw;
+       return(p);
+}
+
+clearuse() {
+       register struct node **i;
+       for (i=uses+NUSE; i>uses;) *--i=0;
+}
+
+clearreg() {
+       register short **i;
+       for (i=regs+NREG; i>regs;) **--i=0;
+       conloc[0] = 0; ccloc[0] = 0;
+}
+
+savereg(ai, s, type)
+register char *s;
+{
+       register char *p, *sp;
+
+       sp = p = regs[ai];
+       if (source(s)) /* side effects in addressing */
+               return;
+       /* if any indexing, must be parameter or local */
+       /* indirection (as in "*-4(fp)") is ok, however */
+       *p++ = type;
+       while (*p++ = *s)
+               if (*s=='[' || *s++=='(' && *s!='a' && *s!='f') {*sp = 0; return;}
+}
+
+dest(s,type)
+register char *s;
+{
+       register int i;
+
+       source(s); /* handle addressing side effects */
+       if ((i = isreg(s)) >= 0) {
+               *(short *)(regs[i]) = 0; /* if register destination, that reg is a goner */
+               if (DOUBLE==(type&0xF) || DOUBLE==((type>>4)&0xF))
+                       *(short *)(regs[i+1]) = 0; /* clobber two at once */
+       }
+       for (i=NREG; --i>=0;)
+               if (regs[i][1]=='*' && equstr(s, regs[i]+2))
+                       *(short *)(regs[i]) = 0; /* previous indirection through destination is invalid */
+       while ((i = findrand(s,0)) >= 0) /* previous values of destination are invalid */
+               *(short *)(regs[i]) = 0;
+       if (!natural(s)) {/* wild store, everything except constants vanishes */
+               for (i=NREG; --i>=0;) if (regs[i][1] != '$') *(short *)(regs[i]) = 0;
+               conloc[0] = 0; ccloc[0] = 0;
+       } else setcc(s,type); /* natural destinations set condition codes */
+}
+
+splitrand(p) struct node *p; {
+/* separate operands at commas, set up 'regs' and 'lastrand' */
+register char *p1, *p2; register char **preg;
+preg=regs+RT1;
+if (p1=p->code) while (*p1) {
+       lastrand=p2= *preg++;
+       while (*p1) if (','==(*p2++= *p1++)) {--p2; break;}
+       *p2=0;
+}
+while (preg<(regs+RT1+5)) *(*preg++)=0;
+}
+
+compat(have, want) {
+register int hsrc, hdst;
+if (0==(want &= 0xF)) return(1); /* anything satisfies a wildcard want */
+hsrc=have&0xF; if (0==(hdst=((have>>4)&0xF)) || hdst>=OP2) hdst=hsrc;
+/* last term prevents floats, doubles from satisfying a request for an int */
+return(hsrc>=want && hdst>=want && !((want>=FLOAT) ^ (hdst>=FLOAT)));
+}
+
+equtype(t1,t2) {return(compat(t1,t2) && compat(t2,t1));}
+
+findrand(as, type)
+char *as;
+{
+       register char **i;
+       for (i = regs+NREG; --i>=regs;) {
+               if (**i && equstr(*i+1, as) && compat(**i,type))
+                       return(i-regs);
+       }
+       return(-1);
+}
+
+isreg(s)
+register char *s;
+{
+       if (*s++!='r' || !isdigit(*s++)) return(-1);
+       if (*s==0) return(*--s-'0');
+       if (*(s-1)=='1' && isdigit(*s++) && *s==0) return(10+*--s-'0');
+       return(-1);
+}
+
+check()
+{
+       register struct node *p, *lp;
+
+       lp = &first;
+       for (p=first.forw; p!=0; p = p->forw) {
+               if (p->back != lp)
+                       abort(-1);
+               lp = p;
+       }
+}
+
+source(ap)
+char *ap;
+{
+       register char *p1, *p2;
+
+       p1 = ap;
+       p2 = p1;
+       if (*p1==0)
+               return(0);
+       while (*p2++ && *(p2-1)!='[');
+       if (*p1=='-' && *(p1+1)=='('
+        || *p1=='*' && *(p1+1)=='-' && *(p1+2)=='('
+        || *(p2-2)=='+') {
+               while (*p1 && *p1++!='r');
+               if (isdigit(*p1++))
+                       if (isdigit(*p1)) *(short *)(regs[10+*p1-'0'])=0;
+                       else *(short *)(regs[*--p1-'0'])=0;
+               return(1);
+       }
+       return(0);
+}
+
+newcode(p) struct node *p; {
+       register char *p1,*p2,**preg;
+       preg=regs+RT1; p2=line;
+       while (*(p1= *preg++)) {while (*p2++= *p1++); *(p2-1)=',';}
+       *--p2=0;
+       p->code=copy(line);
+}
+
+repladdr(p)
+struct node *p;
+{
+       register r;
+       register char *p1, *p2;
+       char **preg; int nrepl;
+
+       preg=regs+RT1; nrepl=0;
+       while (lastrand!=(p1= *preg++))
+               if (!source(p1) && 0<=(r=findrand(p1,p->subop))) {
+                       *p1++='r'; if (r>9) {*p1++='1'; r -= 10;} *p1++=r+'0'; *p1=0;
+                       nrepl++; nsaddr++;
+               }
+       if (nrepl) newcode(p);
+}
+
+/* movedat()
+/* {
+/*     register struct node *p1, *p2;
+/*     struct node *p3;
+/*     register seg;
+/*     struct node data;
+/*     struct node *datp;
+/* 
+/*     if (first.forw == 0)
+/*             return;
+/*     datp = &data;
+/*     for (p1 = first.forw; p1!=0; p1 = p1->forw) {
+/*             if (p1->op == DATA) {
+/*                     p2 = p1->forw;
+/*                     while (p2 && p2->op!=TEXT)
+/*                             p2 = p2->forw;
+/*                     if (p2==0)
+/*                             break;
+/*                     p3 = p1->back;
+/*                     p1->back->forw = p2->forw;
+/*                     p2->forw->back = p3;
+/*                     p2->forw = 0;
+/*                     datp->forw = p1;
+/*                     p1->back = datp;
+/*                     p1 = p3;
+/*                     datp = p2;
+/*             }
+/*     }
+/*     if (data.forw) {
+/*             datp->forw = first.forw;
+/*             first.forw->back = datp;
+/*             data.forw->back = &first;
+/*             first.forw = data.forw;
+/*     }
+/*     seg = -1;
+/*     for (p1 = first.forw; p1!=0; p1 = p1->forw) {
+/*             if (p1->op==TEXT||p1->op==DATA||p1->op==BSS) {
+/*                     if (p1->op == seg || p1->forw&&p1->forw->op==seg) {
+/*                             p1->back->forw = p1->forw;
+/*                             p1->forw->back = p1->back;
+/*                             p1 = p1->back;
+/*                             continue;
+/*                     }
+/*                     seg = p1->op;
+/*             }
+/*     }
+/* }
+*/
+
+redunbr(p)
+register struct node *p;
+{
+       register struct node *p1;
+       register char *ap1;
+       char *ap2;
+
+       if ((p1 = p->ref) == 0)
+               return;
+       p1 = nonlab(p1);
+       if (p1->op==TST) {
+               splitrand(p1);
+               savereg(RT2, "$0", p1->subop);
+       } else if (p1->op==CMP)
+               splitrand(p1);
+       else
+               return;
+       if (p1->forw->op==CBR) {
+               ap1 = findcon(RT1, p1->subop);
+               ap2 = findcon(RT2, p1->subop);
+               p1 = p1->forw;
+               if (compare(p1->subop, ap1, ap2)) {
+                       nredunj++;
+                       nchange++;
+                       decref(p->ref);
+                       p->ref = p1->ref;
+                       p->labno = p1->labno;
+                       p->ref->refc++;
+               }
+       } else if (p1->op==TST && equstr(regs[RT1],ccloc+1) &&
+                       equtype(ccloc[0],p1->subop)) {
+               p1=insertl(p1->forw); decref(p->ref); p->ref=p1; 
+               nrtst++; nchange++;
+       }
+}
+
+char *
+findcon(i, type)
+{
+       register char *p;
+       register r;
+
+       p = regs[i];
+       if (*p=='$')
+               return(p);
+       if ((r = isreg(p)) >= 0 && compat(regs[r][0],type))
+               return(regs[r]+1);
+       if (equstr(p, conloc))
+               return(conval+1);
+       return(p);
+}
+
+compare(op, acp1, acp2)
+char *acp1, *acp2;
+{
+       register char *cp1, *cp2;
+       register n1;
+       int n2; int sign;
+
+       cp1 = acp1;
+       cp2 = acp2;
+       if (*cp1++ != '$' || *cp2++ != '$')
+               return(0);
+       n1 = 0; sign=1; if (*cp2=='-') {++cp2; sign= -1;}
+       while (isdigit(*cp2)) {n1 *= 10; n1 += (*cp2++ - '0')*sign;}
+       n2 = n1;
+       n1 = 0; sign=1; if (*cp1=='-') {++cp1; sign= -1;}
+       while (isdigit(*cp1)) {n1 *= 10; n1 += (*cp1++ - '0')*sign;}
+       if (*cp1=='+')
+               cp1++;
+       if (*cp2=='+')
+               cp2++;
+       do {
+               if (*cp1++ != *cp2)
+                       return(0);
+       } while (*cp2++);
+       cp1 = n1;
+       cp2 = n2;
+       switch(op) {
+
+       case JEQ:
+               return(cp1 == cp2);
+       case JNE:
+               return(cp1 != cp2);
+       case JLE:
+               return(((int)cp1) <= ((int)cp2));
+       case JGE:
+               return(((int)cp1) >= ((int)cp2));
+       case JLT:
+               return(((int)cp1) < ((int)cp2));
+       case JGT:
+               return(((int)cp1) > ((int)cp2));
+       case JLO:
+               return(cp1 < cp2);
+       case JHI:
+               return(cp1 > cp2);
+       case JLOS:
+               return(cp1 <= cp2);
+       case JHIS:
+               return(cp1 >= cp2);
+       }
+       return(0);
+}
+
+setcon(cv, cl, type)
+register char *cv, *cl;
+{
+       register char *p;
+
+       if (*cv != '$')
+               return;
+       if (!natural(cl))
+               return;
+       p = conloc;
+       while (*p++ = *cl++);
+       p = conval;
+       *p++ = type;
+       while (*p++ = *cv++);
+}
+
+equstr(p1, p2)
+register char *p1, *p2;
+{
+       do {
+               if (*p1++ != *p2)
+                       return(0);
+       } while (*p2++);
+       return(1);
+}
+
+setcc(ap,type)
+char *ap;
+{
+       register char *p, *p1;
+
+       p = ap;
+       if (!natural(p)) {
+               ccloc[0] = 0;
+               return;
+       }
+       p1 = ccloc;
+       *p1++ = type;
+       while (*p1++ = *p++);
+}
+
+okio(p) register char *p; {/* 0->probable I/O space address; 1->not */
+       if (ioflag && (!natural(p) || 0>getnum(p))) return(0);
+       return(1);
+}
+
+indexa(p) register char *p; {/* 1-> uses [r] addressing mode; 0->doesn't */
+       while (*p) if (*p++=='[') return(1);
+       return(0);
+}
+
+natural(p)
+register char *p;
+{/* 1->simple local, parameter, global, or register; 0->otherwise */
+       if (*p=='*' || *p=='(' || *p=='-'&&*(p+1)=='(' || *p=='$'&&getnum(p+1))
+               return(0);
+       while (*p++);
+       p--;
+       if (*--p=='+' || *p==']' || *p==')' && *(p-2)!='a' && *(p-2)!='f')
+               return(0);
+       return(1);
+}
diff --git a/usr/src/cmd/c2/c22.c b/usr/src/cmd/c2/c22.c
new file mode 100644 (file)
index 0000000..f3ff3f4
--- /dev/null
@@ -0,0 +1,300 @@
+#include "c2.h"
+char c22[] = "@(#)c22.c 1.5 78/09/23 16:37:33";
+#define readonly
+
+readonly char revbr[] = {
+       JNE, JEQ, JGT, JLT, JGE, JLE,
+       JNE, JEQ, JHI, JLO, JHIS, JLOS,
+       JBS, JBC, JLBS, JLBC, JBSC, JBCC, JBSS, JBCS };
+
+/* cursed be the preprocessor, whose impotence and stupidity
+/* prevented this table being macro-generated from ../as/instrs
+*/
+
+readonly struct optab optab[] = {
+"jbr",JBR,
+"jeql",T(CBR,JEQ),
+"jneq",T(CBR,JNE),
+"jleq",T(CBR,JLE),
+"jgeq",T(CBR,JGE),
+"jlss",T(CBR,JLT),
+"jgtr",T(CBR,JGT),
+"jbc",T(CBR,JBC),
+"jbs",T(CBR,JBS),
+"jlequ",T(CBR,JLOS),
+"jgequ",T(CBR,JHIS),
+"jlssu",T(CBR,JLO),
+"jgtru",T(CBR,JHI),
+"jlbc",T(CBR,JLBC),
+"jlbs",T(CBR,JLBS),
+"jbcc",T(CBR,JBCC),
+"jbsc",T(CBR,JBSC),
+"jbcs",T(CBR,JBCS),
+"jbss",T(CBR,JBSS),
+"acbb",T(ACB,BYTE),
+"acbd",T(ACB,DOUBLE),
+"acbf",T(ACB,FLOAT),
+"acbl",T(ACB,LONG),
+"acbw",T(ACB,WORD),
+"addb2",T(ADD,U(BYTE,OP2)),
+"addb3",T(ADD,U(BYTE,OP3)),
+"addd2",T(ADD,U(DOUBLE,OP2)),
+"addd3",T(ADD,U(DOUBLE,OP3)),
+"addf2",T(ADD,U(FLOAT,OP2)),
+"addf3",T(ADD,U(FLOAT,OP3)),
+"addl2",T(ADD,U(LONG,OP2)),
+"addl3",T(ADD,U(LONG,OP3)),
+"addw2",T(ADD,U(WORD,OP2)),
+"addw3",T(ADD,U(WORD,OP3)),
+"aobleq",AOBLEQ,
+"aoblss",AOBLSS,
+"ashl",T(ASH,LONG),
+"ashq",T(ASH,QUAD),
+"bbc",T(CBR,JBC),
+"bbcc",T(CBR,JBCC),
+"bbcci",T(CBR,JBCC),
+"bbcs",T(CBR,JBCS),
+"bbs",T(CBR,JBS),
+"bbsc",T(CBR,JBSC),
+"bbss",T(CBR,JBSS),
+"bbssi",T(CBR,JBSS),
+"bcc",T(CBR,JHIS),
+"bcs",T(CBR,JLO),
+"beql",T(CBR,JEQ),
+"beqlu",T(CBR,JEQ),
+"bgeq",T(CBR,JGE),
+"bgequ",T(CBR,JHIS),
+"bgtr",T(CBR,JGT),
+"bgtru",T(CBR,JHI),
+"bicb2",T(BIC,U(BYTE,OP2)),
+"bicb3",T(BIC,U(BYTE,OP3)),
+"bicl2",T(BIC,U(LONG,OP2)),
+"bicl3",T(BIC,U(LONG,OP3)),
+"bicw2",T(BIC,U(WORD,OP2)),
+"bicw3",T(BIC,U(WORD,OP3)),
+"bisb2",T(BIS,U(BYTE,OP2)),
+"bisb3",T(BIS,U(BYTE,OP3)),
+"bisl2",T(BIS,U(LONG,OP2)),
+"bisl3",T(BIS,U(LONG,OP3)),
+"bisw2",T(BIS,U(WORD,OP2)),
+"bisw3",T(BIS,U(WORD,OP3)),
+"bitb",T(BIT,BYTE),
+"bitl",T(BIT,LONG),
+"bitw",T(BIT,WORD),
+"blbs",T(CBR,JLBS),
+"blbc",T(CBR,JLBC),
+"bleq",T(CBR,JLE),
+"blequ",T(CBR,JLOS),
+"blss",T(CBR,JLT),
+"blssu",T(CBR,JLO),
+"bneq",T(CBR,JNE),
+"bnequ",T(CBR,JNE),
+"brb",JBR,
+"brw",JBR,
+"bvc",T(CBR,0),
+"bvs",T(CBR,0),
+"callg",CALLS,
+"calls",CALLS,
+"caseb",T(CASE,BYTE),
+"casel",T(CASE,LONG),
+"casew",T(CASE,WORD),
+"clrb",T(CLR,BYTE),
+"clrd",T(CLR,DOUBLE),
+"clrf",T(CLR,FLOAT),
+"clrl",T(CLR,LONG),
+"clrq",T(CLR,QUAD),
+"clrw",T(CLR,WORD),
+"cmpb",T(CMP,BYTE),
+"cmpd",T(CMP,DOUBLE),
+"cmpf",T(CMP,FLOAT),
+"cmpl",T(CMP,LONG),
+"cmpw",T(CMP,WORD),
+"cvtbd",T(CVT,U(BYTE,DOUBLE)),
+"cvtbf",T(CVT,U(BYTE,FLOAT)),
+"cvtbl",T(CVT,U(BYTE,LONG)),
+"cvtbw",T(CVT,U(BYTE,WORD)),
+"cvtdb",T(CVT,U(DOUBLE,BYTE)),
+"cvtdf",T(CVT,U(DOUBLE,FLOAT)),
+"cvtdl",T(CVT,U(DOUBLE,LONG)),
+"cvtdw",T(CVT,U(DOUBLE,WORD)),
+"cvtfb",T(CVT,U(FLOAT,BYTE)),
+"cvtfd",T(CVT,U(FLOAT,DOUBLE)),
+"cvtfl",T(CVT,U(FLOAT,LONG)),
+"cvtfw",T(CVT,U(FLOAT,WORD)),
+"cvtlb",T(CVT,U(LONG,BYTE)),
+"cvtld",T(CVT,U(LONG,DOUBLE)),
+"cvtlf",T(CVT,U(LONG,FLOAT)),
+"cvtlw",T(CVT,U(LONG,WORD)),
+"cvtrdl",T(CVT,U(DOUBLE,LONG)),
+"cvtrfl",T(CVT,U(FLOAT,LONG)),
+"cvtwb",T(CVT,U(WORD,BYTE)),
+"cvtwd",T(CVT,U(WORD,DOUBLE)),
+"cvtwf",T(CVT,U(WORD,FLOAT)),
+"cvtwl",T(CVT,U(WORD,LONG)),
+"decb",T(DEC,BYTE),
+"decl",T(DEC,LONG),
+"decw",T(DEC,WORD),
+"divb2",T(DIV,U(BYTE,OP2)),
+"divb3",T(DIV,U(BYTE,OP3)),
+"divd2",T(DIV,U(DOUBLE,OP2)),
+"divd3",T(DIV,U(DOUBLE,OP3)),
+"divf2",T(DIV,U(FLOAT,OP2)),
+"divf3",T(DIV,U(FLOAT,OP3)),
+"divl2",T(DIV,U(LONG,OP2)),
+"divl3",T(DIV,U(LONG,OP3)),
+"divw2",T(DIV,U(WORD,OP2)),
+"divw3",T(DIV,U(WORD,OP3)),
+"extv",T(EXTV,LONG),
+"extzv",T(EXTZV,LONG),
+"incb",T(INC,BYTE),
+"incl",T(INC,LONG),
+"incw",T(INC,WORD),
+"insv",T(INSV,-1),
+"jmp",JMP,
+"mcomb",T(COM,BYTE),
+"mcoml",T(COM,LONG),
+"mcomw",T(COM,WORD),
+"mnegb",T(NEG,BYTE),
+"mnegd",T(NEG,DOUBLE),
+"mnegf",T(NEG,FLOAT),
+"mnegl",T(NEG,LONG),
+"mnegw",T(NEG,WORD),
+"movab",T(MOVA,BYTE),
+"movad",T(MOVA,DOUBLE),
+"movaf",T(MOVA,FLOAT),
+"moval",T(MOVA,LONG),
+"movaq",T(MOVA,QUAD),
+"movaw",T(MOVA,WORD),
+"movb",T(MOV,BYTE),
+"movd",T(MOV,DOUBLE),
+"movf",T(MOV,FLOAT),
+"movl",T(MOV,LONG),
+"movq",T(MOV,QUAD),
+"movw",T(MOV,WORD),
+"movzbl",T(MOVZ,U(BYTE,LONG)),
+"movzbw",T(MOVZ,U(BYTE,WORD)),
+"movzwl",T(MOVZ,U(WORD,LONG)),
+"mulb2",T(MUL,U(BYTE,OP2)),
+"mulb3",T(MUL,U(BYTE,OP3)),
+"muld2",T(MUL,U(DOUBLE,OP2)),
+"muld3",T(MUL,U(DOUBLE,OP3)),
+"mulf2",T(MUL,U(FLOAT,OP2)),
+"mulf3",T(MUL,U(FLOAT,OP3)),
+"mull2",T(MUL,U(LONG,OP2)),
+"mull3",T(MUL,U(LONG,OP3)),
+"mulw2",T(MUL,U(WORD,OP2)),
+"mulw3",T(MUL,U(WORD,OP3)),
+"pushab",T(PUSHA,BYTE),
+"pushad",T(PUSHA,DOUBLE),
+"pushaf",T(PUSHA,FLOAT),
+"pushal",T(PUSHA,LONG),
+"pushaq",T(PUSHA,QUAD),
+"pushaw",T(PUSHA,WORD),
+"pushl",T(PUSH,LONG),
+"ret",T(JBR,RET),
+"sobgeq",SOBGEQ,
+"sobgtr",SOBGTR,
+"subb2",T(SUB,U(BYTE,OP2)),
+"subb3",T(SUB,U(BYTE,OP3)),
+"subd2",T(SUB,U(DOUBLE,OP2)),
+"subd3",T(SUB,U(DOUBLE,OP3)),
+"subf2",T(SUB,U(FLOAT,OP2)),
+"subf3",T(SUB,U(FLOAT,OP3)),
+"subl2",T(SUB,U(LONG,OP2)),
+"subl3",T(SUB,U(LONG,OP3)),
+"subw2",T(SUB,U(WORD,OP2)),
+"subw3",T(SUB,U(WORD,OP3)),
+"tstb",T(TST,BYTE),
+"tstd",T(TST,DOUBLE),
+"tstf",T(TST,FLOAT),
+"tstl",T(TST,LONG),
+"tstw",T(TST,WORD),
+"xorb2",T(XOR,U(BYTE,OP2)),
+"xorb3",T(XOR,U(BYTE,OP3)),
+"xorl2",T(XOR,U(LONG,OP2)),
+"xorl3",T(XOR,U(LONG,OP3)),
+"xorw2",T(XOR,U(WORD,OP2)),
+"xorw3",T(XOR,U(WORD,OP3)),
+".globl",EROU,
+".text",TEXT,
+".data",DATA,
+".bss",BSS,
+".align",ALIGN,
+".word",WGEN,
+".long",LGEN,
+".set",SET,
+".end",END,
+"adawi",0,
+"addp4",0,
+"addp6",0,
+"adwc",0,
+"ashp",0,
+"bicpsw",0,
+"bispsw",0,
+"bpt",0,
+"bsbb",0,
+"bsbw",0,
+"chme",0,
+"chmk",0,
+"chms",0,
+"chmu",0,
+"cmpc3",0,
+"cmpc5",0,
+"cmpp3",0,
+"cmpp4",0,
+"cmpv",0,
+"cmpzv",0,
+"crc",0,
+"cvtlp",0,
+"cvtpl",0,
+"cvttp",0,
+"cvtpt",0,
+"cvtps",0,
+"cvtsp",0,
+"divp",0,
+"editpc",0,
+"ediv",0,
+"emodd",0,
+"emodf",0,
+"emul",0,
+"ffc",0,
+"ffs",0,
+"halt",0,
+"index",0,
+"insque",0,
+"jsb",0,
+"ldpctx",0,
+"locc",0,
+"matchc",0,
+"mfpr",0,
+"movc3",0,
+"movc5",0,
+"movp",0,
+"movpsl",0,
+"movtc",0,
+"movtuc",0,
+"mtpr",0,
+"mulp",0,
+"nop",0,
+"polyd",0,
+"polyf",0,
+"popr",0,
+"prober",0,
+"probew",0,
+"pushr",0,
+"rei",0,
+"remque",0,
+"rotl",0,
+"rsb",0,
+"sbwc",0,
+"scanc",0,
+"skpc",0,
+"spanc",0,
+"subp4",0,
+"subp6",0,
+"svpctx",0,
+"xfc",0,
+"escd",0,
+"esce",0,
+"escf",0,
+       0,      0};
diff --git a/usr/src/cmd/calendar.c b/usr/src/cmd/calendar.c
deleted file mode 100644 (file)
index 35ca4e3..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/* /usr/lib/calendar produces an egrep -f file
-   that will select today's and tomorrow's
-   calendar entries, with special weekend provisions
-
-   used by calendar command
-*/
-#include <time.h>
-
-#define DAY (3600*24L)
-
-char *month[] = {
-       "[Jj]an",
-       "[Ff]eb",
-       "[Mm]ar",
-       "[Aa]pr",
-       "[Mm]ay",
-       "[Jj]un",
-       "[Jj]ul",
-       "[Aa]ug",
-       "[Ss]ep",
-       "[Oo]ct",
-       "[Nn]ov",
-       "[Dd]ec"
-};
-struct tm *localtime();
-
-tprint(t)
-long t;
-{
-       struct tm *tm;
-       tm = localtime(&t);
-       printf("(^|[ (,;])((%s[^ ]* *|%d/)0*%d)([^0123456789]|$)\n",
-               month[tm->tm_mon], tm->tm_mon + 1, tm->tm_mday);
-}
-
-main()
-{
-       long t;
-       time(&t);
-       tprint(t);
-       switch(localtime(&t)->tm_wday) {
-       case 5:
-               t += DAY;
-               tprint(t);
-       case 6:
-               t += DAY;
-               tprint(t);
-       default:
-               t += DAY;
-               tprint(t);
-       }
-}
diff --git a/usr/src/cmd/calendar/Makefile b/usr/src/cmd/calendar/Makefile
new file mode 100644 (file)
index 0000000..3fd2e00
--- /dev/null
@@ -0,0 +1,8 @@
+calendar:
+       cc -O -o calendar calendar.c
+install:
+       install -s calendar $(DESTDIR)/usr/lib
+       install -c calendar.sh $(DESTDIR)/usr/bin/calendar
+
+clean:
+       rm -f calendar
diff --git a/usr/src/cmd/calendar/calendar.c b/usr/src/cmd/calendar/calendar.c
new file mode 100644 (file)
index 0000000..35ca4e3
--- /dev/null
@@ -0,0 +1,52 @@
+/* /usr/lib/calendar produces an egrep -f file
+   that will select today's and tomorrow's
+   calendar entries, with special weekend provisions
+
+   used by calendar command
+*/
+#include <time.h>
+
+#define DAY (3600*24L)
+
+char *month[] = {
+       "[Jj]an",
+       "[Ff]eb",
+       "[Mm]ar",
+       "[Aa]pr",
+       "[Mm]ay",
+       "[Jj]un",
+       "[Jj]ul",
+       "[Aa]ug",
+       "[Ss]ep",
+       "[Oo]ct",
+       "[Nn]ov",
+       "[Dd]ec"
+};
+struct tm *localtime();
+
+tprint(t)
+long t;
+{
+       struct tm *tm;
+       tm = localtime(&t);
+       printf("(^|[ (,;])((%s[^ ]* *|%d/)0*%d)([^0123456789]|$)\n",
+               month[tm->tm_mon], tm->tm_mon + 1, tm->tm_mday);
+}
+
+main()
+{
+       long t;
+       time(&t);
+       tprint(t);
+       switch(localtime(&t)->tm_wday) {
+       case 5:
+               t += DAY;
+               tprint(t);
+       case 6:
+               t += DAY;
+               tprint(t);
+       default:
+               t += DAY;
+               tprint(t);
+       }
+}
diff --git a/usr/src/cmd/calendar/calendar.sh b/usr/src/cmd/calendar/calendar.sh
new file mode 100755 (executable)
index 0000000..606a6cb
--- /dev/null
@@ -0,0 +1,19 @@
+PATH=/bin:/usr/bin
+tmp=/tmp/cal$$
+trap "rm $tmp; exit" 0 1 2 13 15
+/usr/lib/calendar >$tmp
+case $# in
+0)
+       egrep -f $tmp calendar;;
+*)
+       sed '
+               s/\([^:]*\):.*:\(.*\):[^:]*$/y=\2 z=\1/
+       ' /etc/passwd \
+       | while read x
+       do
+               eval $x
+               if test -r $y/calendar; then
+                       egrep -f $tmp $y/calendar 2>/dev/null  | mail $z
+               fi
+       done
+esac
diff --git a/usr/src/cmd/call.c b/usr/src/cmd/call.c
new file mode 100644 (file)
index 0000000..9723e88
--- /dev/null
@@ -0,0 +1,42 @@
+char *dn;
+
+main(argc, argv)
+char *argv[];
+{
+       register f, n, c;
+
+
+       if(argc < 2)
+               goto arg;
+       dn = "/dev/dn0";
+       if(*argv[1] == '-') {
+               dn = argv[1]+1;
+               argc--;
+               argv++;
+       }
+       if(argc < 2)
+               goto arg;
+       c = 0;
+loop:
+       f = open(dn, 1);
+       if(f < 0)
+               goto slp;
+       for(n=0; argv[1][n]; n++)
+               ;
+       alarm(120);
+       if(write(f, argv[1], n) == n)
+               exit(0);
+
+slp:
+       if(f >= 0)
+               close(f);
+       c++;
+       if(c > 100)
+               exit(1);
+       sleep(10);
+       goto loop;
+
+arg:
+       printf("arg c\n");
+       exit(1);
+}
index 9645aa0..6452ae2 100644 (file)
@@ -48,13 +48,6 @@ char argv[];
                                if(sflg == 0 || j > 0)string[j++] = c;
                                puts();
                                sflg = 0;
                                if(sflg == 0 || j > 0)string[j++] = c;
                                puts();
                                sflg = 0;
-                               if(getnl() == 1){
-                                       puts();
-                                       printf("\n");
-                                       sflg = 1;
-                                       pflg[level]++;
-                                       tabs++;
-                               }
                                continue;
                        }
                        if(sflg == 0 || j > 0)string[j++] = c;
                                continue;
                        }
                        if(sflg == 0 || j > 0)string[j++] = c;
index 017a03c..a09c294 100644 (file)
@@ -2,9 +2,9 @@
 # include <stdio.h>
 # include <ctype.h>
 # include <signal.h>
 # include <stdio.h>
 # include <ctype.h>
 # include <signal.h>
+/* C command */
 
 
-/* cc command */
-
+# define SBSIZE 10000
 # define MAXINC 10
 # define MAXFIL 100
 # define MAXLIB 100
 # define MAXINC 10
 # define MAXFIL 100
 # define MAXLIB 100
@@ -16,6 +16,7 @@ char  *tmp3;
 char   *tmp4;
 char   *tmp5;
 char   *outfile;
 char   *tmp4;
 char   *tmp5;
 char   *outfile;
+char *copy(),*setsuf();
 # define CHSPACE 1000
 char   ts[CHSPACE+50];
 char   *tsa = ts;
 # define CHSPACE 1000
 char   ts[CHSPACE+50];
 char   *tsa = ts;
@@ -23,29 +24,27 @@ char        *tsp = ts;
 char   *av[50];
 char   *clist[MAXFIL];
 char   *llist[MAXLIB];
 char   *av[50];
 char   *clist[MAXFIL];
 char   *llist[MAXLIB];
+char   *alist[20];
+int dflag;
 int    pflag;
 int    sflag;
 int    cflag;
 int    eflag;
 int    pflag;
 int    sflag;
 int    cflag;
 int    eflag;
+int    gflag;
 int    exflag;
 int    oflag;
 int    proflag;
 int    noflflag;
 int    exflag;
 int    oflag;
 int    proflag;
 int    noflflag;
+int    exfail;
 char   *chpass ;
 char   *npassname ;
 char   *chpass ;
 char   *npassname ;
-char   pass0[20] = "/lib/c0";
-char   pass1[20] = "/lib/c1";
+char   pass0[40] = "/lib/ccom";
 char   pass2[20] = "/lib/c2";
 char   passp[20] = "/lib/cpp";
 char   *pref = "/lib/crt0.o";
 char   pass2[20] = "/lib/c2";
 char   passp[20] = "/lib/cpp";
 char   *pref = "/lib/crt0.o";
-char   *copy();
-char   *setsuf();
-char   *strcat();
-char   *strcpy();
 
 main(argc, argv)
 
 main(argc, argv)
-char *argv[]; 
-{
+char *argv[]; {
        char *t;
        char *savetsp;
        char *assource;
        char *t;
        char *savetsp;
        char *assource;
@@ -54,7 +53,6 @@ char *argv[];
        int idexit();
 
        i = nc = nl = f20 = nxo = 0;
        int idexit();
 
        i = nc = nl = f20 = nxo = 0;
-       setbuf(stdout, (char *)NULL);
        pv = ptemp;
        while(++i < argc) {
                if(*argv[i] == '-') switch (argv[i][1]) {
        pv = ptemp;
        while(++i < argc) {
                if(*argv[i] == '-') switch (argv[i][1]) {
@@ -67,7 +65,7 @@ char *argv[];
                case 'o':
                        if (++i < argc) {
                                outfile = argv[i];
                case 'o':
                        if (++i < argc) {
                                outfile = argv[i];
-                               if ((c=getsuf(outfile))=='c'||c=='o') {
+                               if ((t=getsuf(outfile))=='c'||t=='o') {
                                        error("Would overwrite %s", outfile);
                                        exit(8);
                                }
                                        error("Would overwrite %s", outfile);
                                        exit(8);
                                }
@@ -79,10 +77,15 @@ char *argv[];
                case 'p':
                        proflag++;
                        break;
                case 'p':
                        proflag++;
                        break;
+               case 'g':
+                       gflag++;
+                       break;
                case 'E':
                        exflag++;
                case 'P':
                        pflag++;
                case 'E':
                        exflag++;
                case 'P':
                        pflag++;
+                       if (argv[i][1]=='P')
+                       fprintf(stderr, "(Warning): -P option obsolete\n");
                        *pv++ = argv[i];
                case 'c':
                        cflag++;
                        *pv++ = argv[i];
                case 'c':
                        cflag++;
@@ -91,9 +94,9 @@ char *argv[];
                case 'f':
                        noflflag++;
                        if (npassname || chpass)
                case 'f':
                        noflflag++;
                        if (npassname || chpass)
-                               error("-f overwrites earlier option", (char *)NULL);
+                               error("-f overwrites earlier option",0);
                        npassname = "/lib/f";
                        npassname = "/lib/f";
-                       chpass = "1";
+                       chpass = "12";
                        break;
 
                case '2':
                        break;
 
                case '2':
@@ -109,14 +112,15 @@ char *argv[];
                case 'U':
                case 'C':
                        *pv++ = argv[i];
                case 'U':
                case 'C':
                        *pv++ = argv[i];
-                       if (pv >= ptemp+MAXOPT) {
-                               error("Too many DIUC options", (char *)NULL);
+                       if (pv >= ptemp+MAXOPT)
+                               {
+                               error("Too many DIUC options", 0);
                                --pv;
                                --pv;
-                       }
+                               }
                        break;
                case 't':
                        if (chpass)
                        break;
                case 't':
                        if (chpass)
-                               error("-t overwrites earlier option", (char *)NULL);
+                               error("-t overwrites earlier option",0);
                        chpass = argv[i]+2;
                        if (chpass[0]==0)
                                chpass = "012p";
                        chpass = argv[i]+2;
                        if (chpass[0]==0)
                                chpass = "012p";
@@ -124,48 +128,53 @@ char *argv[];
 
                case 'B':
                        if (npassname)
 
                case 'B':
                        if (npassname)
-                               error("-B overwrites earlier option", (char *)NULL);
+                               error("-B overwrites earlier option", 0);
                        npassname = argv[i]+2;
                        if (npassname[0]==0)
                        npassname = argv[i]+2;
                        if (npassname[0]==0)
-                               npassname = "/usr/src/cmd/c/o";
+                               npassname = "/usr/c/o";
                        break;
                        break;
-               } 
-               else {
-passa:
+
+               case 'd':
+                       dflag++;
+                       strcpyn(alist, argv[i], 19);
+                       break;
+               } else {
+               passa:
                        t = argv[i];
                        if((c=getsuf(t))=='c' || c=='s'|| exflag) {
                                clist[nc++] = t;
                        t = argv[i];
                        if((c=getsuf(t))=='c' || c=='s'|| exflag) {
                                clist[nc++] = t;
-                               if (nc>=MAXFIL) {
-                                       error("Too many source files", (char *)NULL);
+                               if (nc>=MAXFIL)
+                                       {
+                                       error("Too many source files",0);
                                        exit(1);
                                        exit(1);
-                               }
+                                       }
                                t = setsuf(t, 'o');
                        }
                        if (nodup(llist, t)) {
                                llist[nl++] = t;
                                t = setsuf(t, 'o');
                        }
                        if (nodup(llist, t)) {
                                llist[nl++] = t;
-                               if (nl >= MAXLIB) {
-                                       error("Too many object/library files", (char *)NULL);
+                               if (nl >= MAXLIB)
+                                       {
+                                       error("Too many object/library files",0);
                                        exit(1);
                                        exit(1);
-                               }
+                                       }
                                if (getsuf(t)=='o')
                                        nxo++;
                        }
                }
        }
                                if (getsuf(t)=='o')
                                        nxo++;
                        }
                }
        }
+       if (gflag) oflag = 0;
        if (npassname && chpass ==0)
                chpass = "012p";
        if (chpass && npassname==0)
        if (npassname && chpass ==0)
                chpass = "012p";
        if (chpass && npassname==0)
-               npassname = "/usr/src/cmd/c/";
+               npassname = "/usr/c/";
        if (chpass)
        if (chpass)
-               for (t=chpass; *t; t++) {
-                       switch (*t) {
+       for (t=chpass; *t; t++)
+               {
+               switch (*t)
+                       {
                        case '0':
                                strcpy (pass0, npassname);
                        case '0':
                                strcpy (pass0, npassname);
-                               strcat (pass0, "c0");
-                               continue;
-                       case '1':
-                               strcpy (pass1, npassname);
-                               strcat (pass1, "c1");
+                               strcat (pass0, "ccom");
                                continue;
                        case '2':
                                strcpy (pass2, npassname);
                                continue;
                        case '2':
                                strcpy (pass2, npassname);
@@ -185,19 +194,16 @@ passa:
                goto nocom;
        if (pflag==0) {
                tmp0 = copy("/tmp/ctm0a");
                goto nocom;
        if (pflag==0) {
                tmp0 = copy("/tmp/ctm0a");
-               while (access(tmp0, 0)==0)
-                       tmp0[9]++;
-               while((creat(tmp0, 0400))<0) {
-                       if (tmp0[9]=='z') {
-                               error("cc: cannot create temp", NULL);
-                               exit(1);
-                       }
+               while((c=fopen(tmp0, "r")) != NULL) {
+                       fclose(c);
                        tmp0[9]++;
                }
                        tmp0[9]++;
                }
+               while((creat(tmp0, 0400))<0)
+                       tmp0[9]++;
        }
        }
-       if (signal(SIGINT, SIG_IGN) != SIG_IGN)
+       if (signal(SIGINT, SIG_IGN) != SIG_IGN) /* interrupt */
                signal(SIGINT, idexit);
                signal(SIGINT, idexit);
-       if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
+       if (signal(SIGTERM, SIG_IGN) != SIG_IGN)        /* terminate */
                signal(SIGTERM, idexit);
        (tmp1 = copy(tmp0))[8] = '1';
        (tmp2 = copy(tmp0))[8] = '2';
                signal(SIGTERM, idexit);
        (tmp1 = copy(tmp0))[8] = '1';
        (tmp2 = copy(tmp0))[8] = '2';
@@ -213,8 +219,7 @@ passa:
                if (getsuf(clist[i])=='s') {
                        assource = clist[i];
                        goto assemble;
                if (getsuf(clist[i])=='s') {
                        assource = clist[i];
                        goto assemble;
-               } 
-               else
+               } else
                        assource = tmp3;
                if (pflag)
                        tmp4 = setsuf(clist[i], 'i');
                        assource = tmp3;
                if (pflag)
                        tmp4 = setsuf(clist[i], 'i');
@@ -226,41 +231,33 @@ passa:
                for(pv=ptemp; pv <pvt; pv++)
                        av[na++] = *pv;
                av[na++]=0;
                for(pv=ptemp; pv <pvt; pv++)
                        av[na++] = *pv;
                av[na++]=0;
-               if (callsys(passp, av)) {
-                       cflag++;
-                       eflag++;
-                       continue;
-               }
-               av[1] = tmp4;
+               if (callsys(passp, av))
+                       {exfail++; eflag++;}
+               av[1] =tmp4;
                tsp = savetsp;
                tsp = savetsp;
-               av[0]= "c0";
-               if (pflag) {
+               av[0]= "ccom";
+               if (pflag || exfail)
+                       {
                        cflag++;
                        continue;
                        cflag++;
                        continue;
-               }
-               av[2] = tmp1;
-               av[3] = tmp2;
+                       }
+               if(sflag)
+                       assource = tmp3 = setsuf(clist[i], 's');
+               av[2] = tmp3;
+               if(oflag)
+                       av[2] = tmp5;
                if (proflag) {
                if (proflag) {
-                       av[4] = "-P";
-                       av[5] = 0;
-               } 
-               else
+                       av[3] = "-XP";
                        av[4] = 0;
                        av[4] = 0;
-               if (callsys(pass0, av)) {
-                       cflag++;
-                       eflag++;
-                       continue;
+               } else
+                       av[3] = 0;
+               if (gflag) {
+                       int i;
+                       i = av[3] ? 4 : 3;
+                       av[i++] = "-Xg";
+                       av[i] = 0;
                }
                }
-               av[0] = "c1";
-               av[1] = tmp1;
-               av[2] = tmp2;
-               if (sflag)
-                       assource = tmp3 = setsuf(clist[i], 's');
-               av[3] = tmp3;
-               if (oflag)
-                       av[3] = tmp5;
-               av[4] = 0;
-               if(callsys(pass1, av)) {
+               if (callsys(pass0, av)) {
                        cflag++;
                        eflag++;
                        continue;
                        cflag++;
                        eflag++;
                        continue;
@@ -273,19 +270,21 @@ passa:
                        if (callsys(pass2, av)) {
                                unlink(tmp3);
                                tmp3 = assource = tmp5;
                        if (callsys(pass2, av)) {
                                unlink(tmp3);
                                tmp3 = assource = tmp5;
-                       } 
-                       else
+                       } else
                                unlink(tmp5);
                }
                if (sflag)
                        continue;
                                unlink(tmp5);
                }
                if (sflag)
                        continue;
-assemble:
+       assemble:
                av[0] = "as";
                av[0] = "as";
-               av[1] = "-u";
-               av[2] = "-o";
-               av[3] = setsuf(clist[i], 'o');
-               av[4] = assource;
-               av[5] = 0;
+               av[1] = "-o";
+               av[2] = setsuf(clist[i], 'o');
+               av[3] = assource;
+               if (dflag) {
+                       av[4] = alist;
+                       av[5] = 0;
+               } else
+                       av[4] = 0;
                cunlink(tmp1);
                cunlink(tmp2);
                cunlink(tmp4);
                cunlink(tmp1);
                cunlink(tmp2);
                cunlink(tmp4);
@@ -302,20 +301,19 @@ nocom:
                av[1] = "-X";
                av[2] = pref;
                j = 3;
                av[1] = "-X";
                av[2] = pref;
                j = 3;
-               if (noflflag) {
-                       j = 4;
-                       av[3] = "-lfpsim";
-               }
                if (outfile) {
                        av[j++] = "-o";
                        av[j++] = outfile;
                }
                while(i<nl)
                        av[j++] = llist[i++];
                if (outfile) {
                        av[j++] = "-o";
                        av[j++] = outfile;
                }
                while(i<nl)
                        av[j++] = llist[i++];
+               if (gflag)
+                       av[j++] = "-lg";
                if(f20)
                        av[j++] = "-l2";
                else {
                if(f20)
                        av[j++] = "-l2";
                else {
-                       av[j++] = "-lc";
+                       av[j++] = "/lib/libc.a";
+                       av[j++] = "-l";
                }
                av[j++] = 0;
                eflag |= callsys("/bin/ld", av);
                }
                av[j++] = 0;
                eflag |= callsys("/bin/ld", av);
@@ -346,10 +344,10 @@ dexit()
 }
 
 error(s, x)
 }
 
 error(s, x)
-char *s, *x;
 {
 {
-       fprintf(exflag?stderr:stdout, s, x);
+       fprintf(exflag?stderr:stdout , s, x);
        putc('\n', exflag? stderr : stdout);
        putc('\n', exflag? stderr : stdout);
+       exfail++;
        cflag++;
        eflag++;
 }
        cflag++;
        eflag++;
 }
@@ -379,7 +377,7 @@ char as[];
 
 char *
 setsuf(as, ch)
 
 char *
 setsuf(as, ch)
-char *as;
+char as[];
 {
        register char *s, *s1;
 
 {
        register char *s, *s1;
 
@@ -392,8 +390,7 @@ char *as;
 }
 
 callsys(f, v)
 }
 
 callsys(f, v)
-char f[], *v[]; 
-{
+char f[], *v[]; {
        int t, status;
 
        if ((t=fork())==0) {
        int t, status;
 
        if ((t=fork())==0) {
@@ -405,13 +402,13 @@ char f[], *v[];
                        printf("Try again\n");
                        return(100);
                }
                        printf("Try again\n");
                        return(100);
                }
-       while(t!=wait(&status))
-               ;
-       if (t = status&0377) {
-               if (t!=SIGINT) {
+       while(t!=wait(&status));
+       if ((t=(status&0377)) != 0 && t!=14) {
+               if (t!=2)               /* interrupt */
+                       {
                        printf("Fatal error in %s\n", f);
                        eflag = 8;
                        printf("Fatal error in %s\n", f);
                        eflag = 8;
-               }
+                       }
                dexit();
        }
        return((status>>8) & 0377);
                dexit();
        }
        return((status>>8) & 0377);
@@ -419,22 +416,22 @@ char f[], *v[];
 
 char *
 copy(as)
 
 char *
 copy(as)
-char *as;
+char as[];
 {
 {
-       char *malloc();
        register char *otsp, *s;
        register char *otsp, *s;
+       int i;
 
        otsp = tsp;
        s = as;
 
        otsp = tsp;
        s = as;
-       while (*tsp++ = *s++)
-               ;
-       if (tsp > tsa+CHSPACE) {
-               tsp = tsa = malloc(CHSPACE+50);
-               if (tsp==NULL) {
-                       error("no space for file names", (char *)NULL);
-                       dexit();
+       while(*tsp++ = *s++);
+       if (tsp >tsa+CHSPACE)
+               {
+               tsp = tsa = i = calloc(CHSPACE+50,1);
+               if (i== -1){
+                       error("no space for file names");
+                       dexit(8);
+                       }
                }
                }
-       }
        return(otsp);
 }
 
        return(otsp);
 }
 
@@ -461,7 +458,7 @@ char **l, *os;
 cunlink(f)
 char *f;
 {
 cunlink(f)
 char *f;
 {
-       if (f==NULL)
-               return;
-       unlink(f);
+       if (f==0)
+               return(0);
+       return(unlink(f));
 }
 }
index 7d473a8..f60a127 100644 (file)
@@ -1,21 +1,9 @@
 #include <stdio.h>
 FILE   *fin;
 #include <stdio.h>
 FILE   *fin;
-int    delim   = 0;
-/* today's version assumes no delimiters;
-they must be explicitly set
-*/
+int    delim   = '$';
 
 main(argc, argv) char **argv; {
 
 
 main(argc, argv) char **argv; {
 
-       while (argc > 1 && argv[1][0] == '-') {
-               switch (argv[1][1]) {
-               case 'd':
-                       delim = argv[1][2];
-                       break;
-               }
-               argc--;
-               argv++;
-       }
        if (argc <= 1)
                check(stdin);
        else
        if (argc <= 1)
                check(stdin);
        else
@@ -61,10 +49,8 @@ FILE *f;
                                if (*p != ' ') {
                                        if (*p == 'o' && *(p+1) == 'f')
                                                delim = 0;
                                if (*p != ' ') {
                                        if (*p == 'o' && *(p+1) == 'f')
                                                delim = 0;
-                                       else {
+                                       else
                                                delim = *p;
                                                delim = *p;
-                                               ndel = totdel = 0;
-                                       }
                                        break;
                                }
                        if (delim == 0)
                                        break;
                                }
                        if (delim == 0)
diff --git a/usr/src/cmd/cmake b/usr/src/cmd/cmake
deleted file mode 100755 (executable)
index 27e8279..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-C=
-for a
-do
-       s=.c
-       case $a in
-       *.y)    s=.y ;;
-       *.s)    s=.s ;;
-       esac
-       b=`basename $a $s`
-       D=/bin
-       echo $a:
-       case $b in
-       -cmp)   C=cmp
-               continue ;;
-       -cp)    C=cp
-               continue ;;
-       ac)     cc -n -s -O ac.c -o ac ;;
-       accton) cc -n -s -O accton.c -o accton; D=/etc ;;
-       ar)     cc -n -s -O ar.c -o ar ;;
-       arcv)   cc -n -s -O arcv.c -o arcv ;;
-       at)     cc -n -s -O at.c -o at ;;
-       atrun)  cc -n -s -O atrun.c -o atrun; D=/usr/lib ;;
-       basename)       cc -n -s -O basename.c -o basename ;;
-       bc)     yacc bc.y && mv y.tab.c bc.c && cc -n -s -O bc.c -o bc && rm bc.c ;;
-       cal)    cc -n -s -O cal.c -o cal ;;
-       calendar)       cc -n -s -O calendar.c -o calendar; D=/usr/lib ;;
-       cat)    cc -n -s -O cat.c -o cat ;;
-       cb)     cc -n -s -O cb.c -o cb ;;
-       cc)     cc -n -s -O cc.c -o cc ;;
-       checkeq)        cc -n -s -O checkeq.c -o checkeq ;;
-       chgrp)  cc -n -s -O chgrp.c -o chgrp ;;
-       chmod)  cc -n -s -O chmod.c -o chmod ;;
-       chown)  cc -n -s -O chown.c -o chown ;;
-       clri)   cc -n -s -O clri.c -o clri ;;
-       cmp)    cc -n -s -O cmp.c -o cmp ;;
-       col)    cc -n -s -O col.c -o col ;;
-       comm)   cc -n -s -O comm.c -o comm ;;
-       cp)     cc -n -s -O cp.c -o cp ;;
-       cron)   cc -n -s -O cron.c -o cron; D=/etc ;;
-       crypt)  cc -n -s -O crypt.c -o crypt ;;
-       cu)     cc -n -s -O cu.c -o cu ;;
-       date)   cc -n -s -O date.c -o date ;;
-       dcheck) cc -i -s -O dcheck.c -o dcheck ;;
-       dd)     cc -i -s -O dd.c -o dd ;;
-       deroff) cc -n -s -O deroff.c -o deroff ;;
-       df)     cc -n -s -O df.c -o df ;;
-       diff)   cc -n -s -O diff.c -o diff ;;
-       diff3)  cc -n -s -O diff3.c -o diff3; D=/usr/lib ;;
-       diffh)  cc -n -s -O diffh.c -o diffh; D=/usr/lib ;;
-       dmesg)  cc -n -s -O dmesg.c -o dmesg; D=/etc ;;
-       du)     cc -n -s -O du.c -o du ;;
-       dump)   cc -n -s -O dump.c -o dump ;;
-       dumpdir)        cc -n -s -O dumpdir.c -o dumpdir ;;
-       echo)   cc -n -s -O echo.c -o echo ;;
-       ed)     cc -n -s -O ed.c -o ed ;;
-       egrep)  yacc egrep.y && mv y.tab.c egrep.c && cc -n -s -O egrep.c -o egrep && rm egrep.c ;;
-       expr)   yacc expr.y && mv y.tab.c expr.c && cc -n -s -O expr.c -o expr && rm expr.c ;;
-       factor) as -o factor factor.s && strip factor;;
-       fgrep)  cc -i -s -O fgrep.c -o fgrep ;;
-       file)   cc -n -s -O file.c -o file ;;
-       find)   cc -n -s -O find.c -o find ;;
-       getty)  cc -n -s -O getty.c -o getty; D=/etc ;;
-       graph)  cc -n -s -O graph.c -o graph -lplot -lm ;;
-       grep)   cc -n -s -O grep.c -o grep ;;
-       icheck) cc -i -s -O icheck.c -o icheck ;;
-       init)   cc -n -s -O init.c -o init; D=/etc ;;
-       iostat) cc -n -s -O iostat.c -o iostat ;;
-       join)   cc -n -s -O join.c -o join ;;
-       kill)   cc -n -s -O kill.c -o kill ;;
-       ld)     cc -n -s -O ld.c -o ld ;;
-       ln)     cc -n -s -O ln.c -o ln ;;
-       login)  cc -n -s -O login.c -o login ;;
-       look)   cc -n -s -O look.c -o look ;;
-       ls)     cc -n -s -O ls.c -o ls ;;
-       mail)   cc -n -s -O mail.c -o mail ;;
-       makekey)        cc -n -s -O makekey.c -o makekey; D=/usr/lib ;;
-       mesg)   cc -n -s -O mesg.c -o mesg ;;
-       mkdir)  cc -n -s -O mkdir.c -o mkdir ;;
-       mkfs)   cc -n -s -O mkfs.c -o mkfs; D=/etc ;;
-       mknod)  cc -n -s -O mknod.c -o mknod; D=/etc ;;
-       mount)  cc -n -s -O mount.c -o mount; D=/etc ;;
-       mv)     cc -n -s -O mv.c -o mv ;;
-       ncheck) cc -i -s -O ncheck.c -o ncheck ;;
-       newgrp) cc -n -s -O newgrp.c -o newgrp ;;
-       nice)   cc -n -s -O nice.c -o nice ;;
-       nm)     cc -n -s -O nm.c -o nm ;;
-       od)     cc -n -s -O od.c -o od ;;
-       osh)    cc -n -s -O osh.c -o osh ;;
-       passwd) cc -n -s -O passwd.c -o passwd ;;
-       pr)     cc -n -s -O pr.c -o pr ;;
-       primes) as -o primes /usr/include/sys.s primes.s && strip primes ;;
-       prof)   cc -n -s -O -Dplot prof.c -lplot -o prof ;;
-       ps)     cc -n -s -O ps.c -o ps ;;
-       pstat)  cc -n -s -O pstat.c -o pstat ;;
-       ptx)    cc -n -s -O ptx.c -o ptx ;;
-       pwd)    cc -n -s -O pwd.c -o pwd ;;
-       quot)   cc -n -s -O quot.c -o quot ;;
-       random) cc -n -s -O random.c -o random ;;
-       ranlib) cc -n -s -O ranlib.c -o ranlib ;;
-       restor) cc -i -s -O restor.c -o restor ;;
-       rev)    cc -n -s -O rev.c -o rev ;;
-       rm)     cc -n -s -O rm.c -o rm ;;
-       rmdir)  cc -n -s -O rmdir.c -o rmdir ;;
-       sa)     cc -n -s -O sa.c -o sa ;;
-       size)   cc -n -s -O size.c -o size ;;
-       sleep)  cc -n -s -O sleep.c -o sleep ;;
-       sort)   cc -i -s -O sort.c -o sort ;;
-       sp)     cc -n -s -O sp.c -o sp ;;
-       spline) cc -n -s -O spline.c -o spline ;;
-       split)  cc -n -s -O split.c -o split ;;
-       strip)  cc -n -s -O strip.c -o strip ;;
-       stty)   cc -n -s -O stty.c -o stty ;;
-       su)     cc -n -s -O su.c -o su ;;
-       sum)    cc -n -s -O sum.c -o sum ;;
-       sync)   cc -n -s -O sync.c -o sync ;;
-       tabs)   cc -n -s -O tabs.c -o tabs ;;
-       tail)   cc -n -s -O tail.c -o tail ;;
-       tc)     cc -n -s -O tc.c -o tc ;;
-       tee)    cc -n -s -O tee.c -o tee ;;
-       test)   cc -n -s -O test.c -o test ;;
-       time)   cc -n -s -O time.c -o time ;;
-       tk)     cc -n -s -O tk.c -o tk ;;
-       touch)  cc -n -s -O touch.c -o touch ;;
-       tr)     cc -n -s -O tr.c -o tr ;;
-       tsort)  cc -n -s -O tsort.c -o tsort ;;
-       tty)    cc -n -s -O tty.c -o tty ;;
-       umount) cc -n -s -O umount.c -o umount; D=/etc ;;
-       uniq)   cc -n -s -O uniq.c -o uniq ;;
-       units)  cc -n -s -O units.c -o units ;;
-       update) cc -n -s -O update.c -o update; D=/etc ;;
-       vpr)    cc -n -s -O vpr.c -o vpr ;;
-       wall)   cc -n -s -O wall.c -o wall; D=/etc ;;
-       wc)     cc -n -s -O wc.c -o wc ;;
-       who)    cc -n -s -O who.c -o who ;;
-       write)  cc -n -s -O write.c -o write ;;
-       yes)    cc -n -s -O yes.c -o yes ;;
-       *)      echo "cmake: don't know about $b"
-               continue ;;
-       esac || continue
-       case $C in
-       cmp)    cmp $b $D/$b && rm $b ;;
-       cp)     cp $b $D/$b && rm $b ;;
-       esac
-done
index a26ac03..c222405 100644 (file)
@@ -1,5 +1,4 @@
 # include <stdio.h>
 # include <stdio.h>
-
 # define PL 256
 # define ESC '\033'
 # define RLF '\013'
 # define PL 256
 # define ESC '\033'
 # define RLF '\013'
 
 char *page[PL];
 char lbuff [LINELN], *line;
 
 char *page[PL];
 char lbuff [LINELN], *line;
-int bflag, xflag, fflag;
+int bflag, hflag, fflag;
 int half;
 int cp, lp;
 int ll, llh, mustwr;
 int pcp = 0;
 char *pgmname;
 int half;
 int cp, lp;
 int ll, llh, mustwr;
 int pcp = 0;
 char *pgmname;
-char *strcpy();
+char   *strcpy();
 
 main (argc, argv)
        int argc; char **argv;
 
 main (argc, argv)
        int argc; char **argv;
@@ -42,8 +41,8 @@ main (argc, argv)
                                bflag++;
                                break;
 
                                bflag++;
                                break;
 
-                       case 'x':
-                               xflag++;
+                       case 'h':
+                               hflag++;
                                break;
 
                        case 'f':
                                break;
 
                        case 'f':
@@ -243,10 +242,6 @@ emit (s, lineno)
        static int gflag = 0;
 
        if (*s) {
        static int gflag = 0;
 
        if (*s) {
-               if (gflag) {
-                       putchar (SI);
-                       gflag = 0;
-               }
                while (cline < lineno - 1) {
                        putchar ('\n');
                        pcp = 0;
                while (cline < lineno - 1) {
                        putchar ('\n');
                        pcp = 0;
@@ -264,7 +259,7 @@ emit (s, lineno)
                while (*p) {
                        ncp = pcp;
                        while (*p++ == ' ') {
                while (*p) {
                        ncp = pcp;
                        while (*p++ == ' ') {
-                               if ((++ncp & 7) == 0 && !xflag) {
+                               if ((++ncp & 7) == 0 && hflag) {
                                        pcp = ncp;
                                        putchar ('\t');
                                }
                                        pcp = ncp;
                                        putchar ('\t');
                                }
diff --git a/usr/src/cmd/cpall.c b/usr/src/cmd/cpall.c
new file mode 100644 (file)
index 0000000..d92d6e9
--- /dev/null
@@ -0,0 +1,29 @@
+char   buf[100];
+int    stat;
+
+main(argc, argv)
+char **argv;
+{
+       register i;
+       register char *c1, *c2;
+
+       if(argc < 3) {
+               write(2, "arg count\n", 10);
+               exit(1);
+       }
+       argc--;
+       c1 = buf;
+       c2 = argv[argc];
+       while(*c1++ = *c2++);
+       c1[-1] = '/';
+       *c1++ = '.';
+       *c1 = '\0';
+       for(i=1; i<argc; i++) {
+               if(fork()==0) {
+                       execl("/bin/cp", "cp", argv[i], buf);
+                       exit(1);
+               }
+               wait(&stat);
+       }
+       exit(0);
+}
diff --git a/usr/src/cmd/cpio.c b/usr/src/cmd/cpio.c
new file mode 100644 (file)
index 0000000..e63b80a
--- /dev/null
@@ -0,0 +1,789 @@
+/*     cpio    COMPILE:        cc -O cpio.c -s -i -o cpio -lS
+       cpio -- copy file collections
+
+*/
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <signal.h>
+#define EQ(x,y)        (strcmp(x,y)==0)
+/* for VAX, Interdata, ... */
+#define MKSHORT(v,lv) {U.l=1L;if(U.c[0]) U.l=lv,v[0]=U.s[1],v[1]=U.s[0]; else U.l=lv,v[0]=U.s[0],v[1]=U.s[1];}
+#define MAGIC  070707
+#define FILETYPE       060000
+#define IN     1
+#define OUT    2
+#define PASS   3
+#define HDRSIZE        ((sizeof Hdr)-256)
+#define LINKS  1000
+
+struct stat    Statb, Xstatb;
+
+struct header {
+       short   h_magic,
+               h_dev,
+               h_ino,
+               h_mode,
+               h_uid,
+               h_gid,
+               h_nlink,
+               h_rdev;
+       short   h_mtime[2];
+       short   h_namesize;
+       short   h_filesize[2];
+       char    h_name[256];
+} Hdr;
+
+int    Bufsize = 512;
+short  Buf[256], *Dbuf;
+int    Wct;
+short  *Wp;
+
+short  Option,
+       Dir,
+       Uncond,
+       Link,
+       Rename,
+       Toc,
+       Verbose,
+       Select,
+       Mod_time,
+       Swap;
+
+int    Ifile,
+       Ofile,
+       Input = 0,
+       Output = 1;
+long   Blocks;
+
+char   Fullname[256],
+       Name[256];
+int    Pathend;
+
+FILE   *Rtty,
+       *Wtty;
+
+char   *Pattern;
+short  Dev,
+       Uid,
+       Gid,
+       A_directory,
+       A_special;
+extern errno;
+char   *malloc();
+char   *cd();
+char   *Cd_name;
+FILE   *popen();
+
+union { long l; short s[2]; char c[4]; } U;
+
+/* for VAX, Interdata, ... */
+long mklong(v)
+short v[];
+{
+       U.l = 1;
+       if(U.c[0])
+               U.s[0] = v[1], U.s[1] = v[0];
+       else
+               U.s[0] = v[0], U.s[1] = v[1];
+       return U.l;
+}
+
+main(argc, argv)
+char **argv;
+{
+       register ct;
+       long    filesz;
+       register char *lastarg, *fullp;
+
+       if(argc < 2 || argc > 4) {
+usage:
+               err("Usage: cpio -o[vB] <name-list >collection\n%s\n%s\n",
+               "       cpio -i[drstuvB] [pattern] <collection",
+               "       cpio -p[dlruv] [pattern] directory <name-list");
+               exit(1);
+       }
+       signal(SIGSYS, 1);
+       lastarg = argv[argc-1];
+       if(*argv[1] != '-')
+               goto usage;
+       Uid = getuid();
+       umask(0);
+       Gid = getgid();
+
+       while(*++argv[1]) {
+               switch(*argv[1]) {
+               case 'B':
+                       Bufsize = 5120;
+                       break;
+               case 'i':
+                       Option = IN;
+                       Pattern = argc == 2? "*": argv[2];
+                       break;
+               case 'o':
+                       Option = OUT;
+                       break;
+               case 'p':
+                       if(access(lastarg, 2) == -1) {
+accerr:
+                               err("cannot write in <%s>\n", lastarg);
+                               exit(1);
+                       }
+                       strcpy(Fullname, lastarg);
+                       strcat(Fullname, "/");
+                       stat(Fullname, &Xstatb);
+                       if((Xstatb.st_mode&S_IFMT) != S_IFDIR)
+                               goto accerr;
+                       Option = PASS;
+                       Dev = Xstatb.st_dev;
+                       Pattern = argc == 3? "*": argv[2];
+                       break;
+               case 'd':
+                       Dir++;
+                       break;
+               case 'l':
+                       Link++;
+                       break;
+               case 'm':
+                       Mod_time++;
+                       break;
+               case 'r':
+                       Rename++;
+                       Rtty = fopen("/dev/tty", "r");
+                       Wtty = fopen("/dev/tty", "w");
+                       if(Rtty==NULL || Wtty==NULL) {
+                               err(
+                                 "Cannot rename (/dev/tty missing)\n");
+                               exit(1);
+                       }
+                       break;
+               case 's':
+                       Swap++;
+                       break;
+               case 't':
+                       Toc++;
+                       break;
+               case 'u':
+                       Uncond++;
+                       break;
+               case 'v':
+                       Verbose++;
+                       break;
+               default:
+                       goto usage;
+               }
+       }
+       if(!Option) {
+               err("Options must include o|i|p\n");
+               exit(1);
+       }
+
+       if(Option != PASS)
+               Wp = Dbuf = malloc(Bufsize);
+       Wct = Bufsize >> 1;
+
+       if(Option == PASS && Rename) {
+               err("Pass and Rename cannot be used together");
+               exit(1);
+       }
+       switch(Option) {
+
+       case OUT:
+               while(getname()) {
+                       if(mklong(Hdr.h_filesize) == 0L) {
+                               bwrite(&Hdr, HDRSIZE+Hdr.h_namesize);
+                               continue;
+                       }
+                       if((Ifile = open(Hdr.h_name, 0)) < 0) {
+                               err("<%s> ?\n", Hdr.h_name);
+                               continue;
+                       }
+                       bwrite(&Hdr, HDRSIZE+Hdr.h_namesize);
+                       for(filesz=mklong(Hdr.h_filesize); filesz>0; filesz-= 512){
+                               ct = filesz>512? 512: filesz;
+                               if(read(Ifile, Buf, ct) < 0) {
+                                       err("Cannot read %s\n", Hdr.h_name);
+                                       continue;
+                               }
+                               bwrite(Buf, ct);
+                       }
+                       close(Ifile);
+                       if(Verbose)
+                               err("%s\n", Hdr.h_name);
+               }
+               strcpy(Hdr.h_name, "TRAILER!!!");
+               MKSHORT(Hdr.h_filesize, 0L);
+               Hdr.h_namesize = strlen("TRAILER!!!") + 1;
+               bwrite(&Hdr, HDRSIZE+Hdr.h_namesize);
+               bwrite(Dbuf, Bufsize);
+               break;
+
+       case IN:
+               pwd();
+               while(gethdr()) {
+                       Ofile = ckname(Hdr.h_name)? openout(Hdr.h_name): 0;
+                       for(filesz=mklong(Hdr.h_filesize); filesz>0; filesz-= 512){
+                               ct = filesz>512? 512: filesz;
+                               bread(Buf, ct);
+                               if(Ofile) {
+                                       if(Swap)
+                                               swap(Buf, ct);
+                                       if(write(Ofile, Buf, ct) < 0) {
+                                        err("Cannot write %s\n", Hdr.h_name);
+                                        continue;
+                                       }
+                               }
+                       }
+                       if(Ofile) {
+                               close(Ofile);
+                               set_time(Cd_name, mklong(Hdr.h_mtime), mklong(Hdr.h_mtime));
+                       }
+                       if(!Select)
+                               continue;
+                       if(Verbose)
+                               if(Toc)
+                                       pentry(Hdr.h_name);
+                               else
+                                       puts(Hdr.h_name);
+                       else if(Toc)
+                               puts(Hdr.h_name);
+               }
+               break;
+
+       case PASS:
+               fullp = Fullname + strlen(Fullname);
+
+               while(getname()) {
+                       if(!ckname(Hdr.h_name))
+                               continue;
+                       strcpy(fullp, Hdr.h_name);
+
+                       if(Link
+                       && !A_directory
+                       && Dev == Statb.st_dev
+                       && (Uid == Statb.st_uid || !Uid)) {
+                               unlink(Fullname);
+                               if(link(Hdr.h_name, Fullname) < 0) {
+                                       err(
+                                        "Cannot link <%s> & <%s>\n",
+                                        Hdr.h_name, Fullname);
+                                       continue;
+                               }
+                               set_time(Hdr.h_name, mklong(Hdr.h_mtime), mklong(Hdr.h_mtime));
+                               goto ckverbose;
+                       }
+                       if(!(Ofile = openout(Fullname)))
+                               continue;
+                       if((Ifile = open(Hdr.h_name, 0)) < 0) {
+                               err("<%s> ?\n", Hdr.h_name);
+                               close(Ofile);
+                               continue;
+                       }
+                       filesz = Statb.st_size;
+                       for(; filesz > 0; filesz -= 512) {
+                               ct = filesz>512? 512: filesz;
+                               if(read(Ifile, Buf, ct) < 0) {
+                                       err("Cannot read %s\n", Hdr.h_name);
+                                       break;
+                               }
+                               if(Ofile)
+                                       if(write(Ofile, Buf, ct) < 0) {
+                                        err("Cannot write %s\n", Hdr.h_name);
+                                        break;
+                                       }
+                               ++Blocks;
+                       }
+                       close(Ifile);
+                       if(Ofile) {
+                               close(Ofile);
+                               set_time(Fullname, Statb.st_atime, mklong(Hdr.h_mtime));
+ckverbose:
+                               if(Verbose)
+                                       puts(Fullname);
+                       }
+               }
+       }
+       err("%D blocks\n", Blocks * (Bufsize>>9));
+       exit(0);
+}
+
+getname()
+{
+       register char *namep = Name;
+       static long tlong;
+
+       for(;;) {
+               if(gets(namep) == NULL)
+                       return 0;
+               if(*namep == '.' && namep[1] == '/')
+                       namep += 2;
+               strcpy(Hdr.h_name, namep);
+               if(stat(namep, &Statb) < 0) {
+                       err("< %s > ?\n", Hdr.h_name);
+                       continue;
+               }
+               A_directory = (Statb.st_mode & FILETYPE) == S_IFDIR;
+               A_special = ((Statb.st_mode & FILETYPE) == S_IFBLK)
+                       || ((Statb.st_mode & FILETYPE) == S_IFCHR);
+               Hdr.h_magic = MAGIC;
+               Hdr.h_namesize = strlen(Hdr.h_name) + 1;
+               Hdr.h_uid = Statb.st_uid;
+               Hdr.h_gid = Statb.st_gid;
+               Hdr.h_dev = Statb.st_dev;
+               Hdr.h_ino = Statb.st_ino;
+               Hdr.h_mode = Statb.st_mode;
+               MKSHORT(Hdr.h_mtime, Statb.st_mtime);
+               Hdr.h_nlink = Statb.st_nlink;
+               tlong = Hdr.h_mode & S_IFREG? Statb.st_size: 0L;
+               MKSHORT(Hdr.h_filesize, tlong);
+               Hdr.h_rdev = Statb.st_rdev;
+               return 1;
+       }
+}
+
+gethdr()
+{
+
+       bread(&Hdr, HDRSIZE);
+
+       if(Hdr.h_magic != MAGIC) {
+               err("Out of phase--get help");
+abort();
+               exit(1);
+       }
+       bread(Hdr.h_name, Hdr.h_namesize);
+       if(Swap) {
+               swap(Hdr.h_name, Hdr.h_namesize);
+       }
+       if(EQ(Hdr.h_name, "TRAILER!!!"))
+               return 0;
+       A_directory = (Hdr.h_mode & FILETYPE) == S_IFDIR;
+       A_special =((Hdr.h_mode & FILETYPE) == S_IFBLK)
+               || ((Hdr.h_mode & FILETYPE) == S_IFCHR);
+       return 1;
+}
+
+ckname(namep)
+register char *namep;
+{
+       ++Select;
+       if(!gmatch(namep, Pattern)) {
+               Select = 0;
+               return 0;
+       }
+       if(Rename && !A_directory) {
+               fprintf(Wtty, "Rename <%s>\n", namep);
+               fflush(Wtty);
+               fgets(namep, 128, Rtty);
+               if(feof(Rtty))
+                       exit(1);
+               namep[strlen(namep) - 1] = '\0';
+               if(EQ(namep, "")) {
+                       printf("Skipped\n");
+                       return 0;
+               }
+       }
+       return !Toc;
+}
+
+openout(namep)
+register char *namep;
+{
+       register f;
+       register char *np;
+
+       if(!strncmp(namep, "./", 2))
+               namep += 2;
+       np = namep;
+       if(Option == IN)
+               Cd_name = namep = cd(namep);
+       if(A_directory) {
+               if(!Dir
+               || Rename
+               || EQ(namep, ".")
+               || EQ(namep, "..")
+               || stat(namep, &Xstatb) == 0)
+                       return 0;
+
+               while(!makdir(namep))
+                       missdir(namep);
+ret:
+               chmod(namep, Hdr.h_mode);
+               if(Uid == 0)
+                       chown(namep, Hdr.h_uid, Hdr.h_gid);
+               set_time(namep, mklong(Hdr.h_mtime), mklong(Hdr.h_mtime));
+               return 0;
+       }
+       if(Hdr.h_nlink > 1)
+               if(!postml(namep, np))
+                       return 0;
+       if(A_special) {
+s_again:
+               if(mknod(namep, Hdr.h_mode, Hdr.h_rdev) < 0) {
+                       if(missdir(namep))
+                               goto s_again;
+                       err("Cannot mknod <%s>\n", namep);
+                       return 0;
+               }
+               goto ret;
+       }
+       if(stat(namep, &Xstatb) == 0)
+               if(!Uncond && (mklong(Hdr.h_mtime) < Xstatb.st_mtime)) {
+                       err("current <%s> newer\n", namep);
+                       return 0;
+               }
+       if(Option == PASS
+       && Hdr.h_ino == Xstatb.st_ino
+       && Hdr.h_dev == Xstatb.st_dev) {
+               err("Attempt to pass file to self!\n");
+               exit(1);
+       }
+c_again:
+       if((f = creat(namep, Hdr.h_mode)) < 0) {
+               if(missdir(namep))
+                       goto c_again;
+               err("Cannot create <%s> (errno:%d)\n", namep, errno);
+               return 0;
+       }
+       if(Uid == 0)
+               chown(namep, Hdr.h_uid, Hdr.h_gid);
+       return f;
+}
+
+bread(b, c)
+register c;
+register short *b;
+{
+       static nleft = 0;
+       static short *ip;
+       register short *p = ip;
+
+       c = (c+1)>>1;
+       while(c--) {
+               if(!nleft) {
+again:
+                       if(read(Input, Dbuf, Bufsize)!=Bufsize) {
+                               Input = chgreel(0, Input);
+                               goto again;
+                       }
+                       nleft = Bufsize >> 1;
+                       p = Dbuf;
+                       ++Blocks;
+               }
+               *b++ = *p++;
+               --nleft;
+       }
+       ip = p;
+}
+
+bwrite(rp, c)
+register short *rp;
+register c;
+{
+       register short *wp = Wp;
+
+       c = (c+1) >> 1;
+       while(c--) {
+               if(!Wct) {
+again:
+                       if(write(Output, Dbuf, Bufsize)<0) {
+                               Output = chgreel(1, Output);
+                               goto again;
+                       }
+                       Wct = Bufsize >> 1;
+                       wp = Dbuf;
+                       ++Blocks;
+               }
+               *wp++ = *rp++;
+               --Wct;
+       }
+       Wp = wp;
+}
+
+postml(namep, np)
+register char *namep, *np;
+{
+       register i;
+       static struct ml {
+               short   m_dev,
+                       m_ino;
+               char    m_name[2];
+       } *ml[LINKS];
+       static  mlinks = 0;
+       char *mlp;
+
+       for(i = 0; i < mlinks; ++i) {
+               if(mlinks == LINKS) break;
+               if(ml[i]->m_ino==Hdr.h_ino &&
+                       ml[i]->m_dev==Hdr.h_dev) {
+                       if(Verbose)
+                         printf("%s linked to %s\n", ml[i]->m_name,
+                               np);
+                       unlink(namep);
+                       if(Option == IN) {
+                               Fullname[Pathend] = '\0';
+                               strcat(Fullname, ml[i]->m_name);
+                               mlp = Fullname;
+                       } else
+                               mlp = ml[i]->m_name;
+l_again:
+                       if(link(mlp, namep) < 0) {
+                               if(missdir(np))
+                                       goto l_again;
+                               err("Cannot link <%s>&<%s>.\n",
+                                       ml[i]->m_name, np);
+                       }
+                       set_time(namep, mklong(Hdr.h_mtime), mklong(Hdr.h_mtime));
+                       return 0;
+               }
+       }
+       if(mlinks == LINKS
+       || (ml[mlinks] = malloc(strlen(np) + sizeof(struct ml))) == 0) {
+               static int first=1;
+
+               if(first)
+                       if(mlinks == LINKS)
+                               err("Too many links\n");
+                       else
+                               err("No memory for links\n");
+               mlinks = LINKS;
+               first = 0;
+               return 1;
+       }
+       ml[mlinks]->m_dev = Hdr.h_dev;
+       ml[mlinks]->m_ino = Hdr.h_ino;
+       strcpy(ml[mlinks]->m_name, np);
+       ++mlinks;
+       return 1;
+}
+
+pentry(namep)
+register char *namep;
+{
+
+       register i;
+       static short lastid = -1;
+#include <pwd.h>
+       static struct passwd *pw;
+       struct passwd *getpwuid();
+       static char tbuf[32];
+
+       printf("%-7o", Hdr.h_mode & 0177777);
+       if(lastid == Hdr.h_uid)
+               printf("%-6s", pw->pw_name);
+       else {
+               setpwent();
+               if(pw = getpwuid(Hdr.h_uid)) {
+                       printf("%-6s", pw->pw_name);
+                       lastid = Hdr.h_uid;
+               } else
+                       printf("%-6d", Hdr.h_uid);
+       }
+       printf("%7D ", mklong(Hdr.h_filesize));
+       U.l = mklong(Hdr.h_mtime);
+       strcpy(tbuf, ctime(&U.l));
+       tbuf[24] = '\0';
+       printf(" %s  %s\n", &tbuf[4], namep);
+}
+
+gmatch(s, p)
+register char *s, *p;
+{
+       register int c;
+       int cc, ok, lc, scc;
+
+       if(EQ(p, "*"))
+               return 1;
+       scc = *s;
+       lc = 077777;
+       switch (c = *p) {
+
+       case '[':
+               ok = 0;
+               while (cc = *++p) {
+                       switch (cc) {
+
+                       case ']':
+                               if (ok)
+                                       return(gmatch(++s, ++p));
+                               else
+                                       return(0);
+
+                       case '-':
+                               ok |= (lc <= scc & scc <= (cc=p[1]));
+                       }
+                       if (scc==(lc=cc)) ok++;
+               }
+               return(0);
+
+       case '?':
+       caseq:
+               if(scc) return(gmatch(++s, ++p));
+               return(0);
+       case '*':
+               return(umatch(s, ++p));
+       case 0:
+               return(!scc);
+       }
+       if (c==scc) goto caseq;
+       return(0);
+}
+
+umatch(s, p)
+register char *s, *p;
+{
+       if(*p==0) return(1);
+       while(*s)
+               if (gmatch(s++,p)) return(1);
+       return(0);
+}
+
+makdir(namep)
+register char *namep;
+{
+       static status;
+
+       if(fork())
+               wait(&status);
+       else {
+               close(2);
+               execl("/bin/mkdir", "mkdir", namep, 0);
+               exit(1);
+       }
+       return ((status>>8) & 0377)? 0: 1;
+}
+
+swap(buf, ct)
+register ct;
+register union swp { short     shortw; char    charv[2]; } *buf;
+{
+       register char c;
+
+       ct = (ct + 1) >> 1;
+
+       while(ct--) {
+               c = buf->charv[0];
+               buf->charv[0] = buf->charv[1];
+               buf->charv[1] = c;
+               ++buf;
+       }
+}
+set_time(namep, atime, mtime)
+register *namep;
+long atime, mtime;
+{
+       static long timevec[2];
+
+       if(Uid || !Mod_time)
+               return;
+       timevec[0] = atime;
+       timevec[1] = mtime;
+       utime(namep, timevec);
+}
+chgreel(x, fl)
+{
+       register f;
+       char str[22];
+       FILE *devtty;
+       struct stat statb;
+
+       err("errno: %d, ", errno);
+       err("Can't %s\n", x? "write output": "read input");
+       fstat(fl, &statb);
+       if((statb.st_mode&S_IFMT) != S_IFCHR)
+               exit(1);
+again:
+       err("If you want to go on, type device/file name when ready\n");
+       devtty = fopen("/dev/tty", "r");
+       fgets(str, 20, devtty);
+       str[strlen(str) - 1] = '\0';
+       if(!*str)
+               exit(1);
+       close(fl);
+       if((f = open(str, x? 1: 0)) < 0) {
+               err("That didn't work");
+               fclose(devtty);
+               goto again;
+       }
+       return f;
+}
+missdir(namep)
+register char *namep;
+{
+       register char *np;
+       register ct = 0;
+
+       if(!Dir)
+               return 0;
+       for(np = namep; *np; ++np)
+               if(*np == '/') {
+                       *np = '\0';
+                       if(stat(namep, &Xstatb) == -1)
+                               makdir(namep), ++ct;
+                       *np = '/';
+               }
+       return ct;
+}
+err(a, b, c)
+{
+       fprintf(stderr, a, b, c);
+}
+pwd()
+{
+       FILE *dir;
+
+       dir = popen("pwd", "r");
+       fgets(Fullname, 128, dir);
+       pclose(dir);
+       Pathend = strlen(Fullname);
+       Fullname[Pathend - 1] = '/';
+}
+char * cd(n)
+register char *n;
+{
+       char *p_save = Name, *n_save = n, *p_end = 0;
+       register char *p = Name;
+       static char dotdot[]="../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../";
+       int slashes;
+
+       for(; *p && *n == *p; ++p, ++n) { /* whatever part of strings == */
+               if(*p == '/')
+                       p_save = p+1, n_save = n+1;
+       }
+
+       p = p_save;
+       *p++ = '\0';
+       for(slashes = 0; *p; ++p) { /* if prev is longer, chdir("..") */
+               if(*p == '/')
+                       ++slashes;
+       }
+       p = p_save;
+       if(slashes) {
+               slashes = slashes * 3 - 1;
+               dotdot[slashes] = '\0';
+               chdir(dotdot);
+               dotdot[slashes] = '/';
+       }
+
+       n = n_save;
+       for(; *n; ++n, ++p) {
+               *p = *n;
+               if(*n == '/')
+                       p_end = p+1, n_save = n+1;
+       }
+       *p = '\0';
+
+       if(p_end) {
+               *p_end = '\0';
+               if(chdir(p_save) == -1) {
+                       if(!missdir(p_save)) {
+cd_err:
+                               err("Cannot chdir\n");
+                               abort();
+                       } else if(chdir(p_save) == -1)
+                               goto cd_err;
+               }
+       } else
+               *p_save = '\0';
+       return n_save;
+}
diff --git a/usr/src/cmd/cpp/Makefile b/usr/src/cmd/cpp/Makefile
new file mode 100644 (file)
index 0000000..9aa37c2
--- /dev/null
@@ -0,0 +1,21 @@
+CC=cc
+CFLAGS=-O -Dunix=1 -Dvax=1 -d2
+
+cpp :  cpp.o cpy.o rodata.o
+       $(CC) $(CFLAGS) -o cpp cpp.o rodata.o cpy.o  
+
+cpy.c : cpy.y
+       yacc cpy.y
+       ../as/:yyfix yyexca yyact yypact yypgo yyr1 yyr2 yychk yydef
+       mv y.tab.c cpy.c
+cpy.o :        cpy.c yylex.c
+rodata.o : cpy.c
+       $(CC) $(CFLAGS) -S rodata.c
+       ../as/:rofix rodata.s
+       as -o rodata.o rodata.s
+
+clean :
+       rm -f *.s *.o cpy.c rodata.c
+
+install :
+       install -s cpp $(DESTDIR)/lib
index 3d64dfa..fcff9bb 100644 (file)
@@ -1,28 +1,56 @@
+August 25, 1978
+
 Files in this directory form the C preprocessor, which handles '#include'
 files and macro definition and expansion for the C compiler.
 This new version was written by John F. Reiser and is from 5 to 12
 Files in this directory form the C preprocessor, which handles '#include'
 files and macro definition and expansion for the C compiler.
 This new version was written by John F. Reiser and is from 5 to 12
-times faster than the old.
+times faster (on UNIX systems) than the old.
 
 To create the executable file 'cpp' in the current directory:
        make
 
 To install the preprocessor 'cpp' so it will be used by the C compiler:
 
 To create the executable file 'cpp' in the current directory:
        make
 
 To install the preprocessor 'cpp' so it will be used by the C compiler:
-       : backup the existing version
+       : safety first: backup the existing version
        cp /lib/cpp /lib/ocpp
        : install the new version
        cp cpp /lib/cpp
 
        cp /lib/cpp /lib/ocpp
        : install the new version
        cp cpp /lib/cpp
 
+Invocation
+       cpp [-CEPR] [-Dname] ... [-Dname=def] ... [-Idirectory] ...
+               [-Uname] ... [<infile>] [<outfile>]
+
+       If there are two non-flag arguments then the first is the name of the
+       input file and the second is the name of the output file.  If there is
+       one non-flag argument then it is the name of the input file and the
+       output is written on the standard output.  If there are no non-flag
+       arguments then the input is taken from the standard input and the output
+       is written on the standard output.  Flag arguments are:
+
+               -C      retain comments in output
+               -Dname  define name as "1"
+               -Dname=def      define name as def
+               -E      ignored
+               -Idirectory     add directory to search list for #include files
+               -P      don't insert lines "# 12 \"foo.c\"" into output
+               -R      allow recursive macros
+               -Uname  undefine name
+               
 Documentation clarifications:
        Symbols defined on the command line by "-Dfoo" are defined as "1",
                i.e., as if they had been defined by "#define foo 1" or "-Dfoo=1".
 Documentation clarifications:
        Symbols defined on the command line by "-Dfoo" are defined as "1",
                i.e., as if they had been defined by "#define foo 1" or "-Dfoo=1".
+       The directory search order for #include files is
+               1) the directory of the file which contains the #include request
+                  (e.g. #include is relative to the file being scanned when
+                  the request is made)
+               2) the directories specified by -I, in left-to-right order
+               3) the standard directory(s) (which for UNIX is /usr/include)
        An unescaped linefeed (the single character "\n") terminates a
                character constant or quoted string.
        An escaped linefeed (the two-character sequence "\\\n") may be
                used in the body of a '#define' statement to continue
                the definition onto the next line.  The escaped linefeed is
                not included in the macro body.
        An unescaped linefeed (the single character "\n") terminates a
                character constant or quoted string.
        An escaped linefeed (the two-character sequence "\\\n") may be
                used in the body of a '#define' statement to continue
                the definition onto the next line.  The escaped linefeed is
                not included in the macro body.
-       Comments are uniformly removed.  They are also ignored, except
-               that a comment terminates a token.
+       Comments are uniformly removed (except if the argument -C is specified).
+               They are also ignored, except that a comment terminates a token.
                Thus "foo/* la di da */bar" may expand 'foo' and 'bar' but
                will never expand 'foobar'.  If neither 'foo' nor 'bar' is a
                macro then the output is "foobar", even if 'foobar'
                Thus "foo/* la di da */bar" may expand 'foo' and 'bar' but
                will never expand 'foobar'.  If neither 'foo' nor 'bar' is a
                macro then the output is "foobar", even if 'foobar'
@@ -31,18 +59,25 @@ Documentation clarifications:
                        foo(1,2)
                produces "21" because the comment causes a break which enables
                the recognition of 'b' and 'a' as formals in the string "b/**/a".
                        foo(1,2)
                produces "21" because the comment causes a break which enables
                the recognition of 'b' and 'a' as formals in the string "b/**/a".
-       Macro formals are recognized even inside character constants
-               and quoted strings.  The output from
+       Macro formal parameters are recognized in '#define' bodies even inside
+               character constants and quoted strings.  The output from
                        #define foo(a) '\a'
                        foo(bar)
                        #define foo(a) '\a'
                        foo(bar)
-               is the seven characters " '\\bar'".
+               is the seven characters " '\\bar'".  Macro names are not recognized
+               inside character constants or quoted strings during the regular scan.
+               Thus
+                       #define foo bar
+                       printf("foo");
+               does not expand 'foo' in the second line, because it is inside
+               a quoted string which is not part of a '#define' macro definition.
        Macros are not expanded while processing a '#define' or '#undef'.
                Thus
                        #define foo bletch
                        #define bar foo
                        #undef foo
                        bar
        Macros are not expanded while processing a '#define' or '#undef'.
                Thus
                        #define foo bletch
                        #define bar foo
                        #undef foo
                        bar
-               produces "foo".
+               produces "foo".  The token appearing immediately after a
+               '#ifdef' or '#ifndef' is not expanded (of course!).
        Macros are not expanded during the scan which determines the actual
                parameters to another macro call.  Thus
                        #define foo(a,b)b a
        Macros are not expanded during the scan which determines the actual
                parameters to another macro call.  Thus
                        #define foo(a,b)b a
@@ -67,8 +102,24 @@ Bugs fixed:
        The following example expands to "# # #" :
                #define foo #
                foo foo foo
        The following example expands to "# # #" :
                #define foo #
                foo foo foo
-       Recursion in macro definitions is strictly obeyed (to the extent that
-               space is available).  In particular,
+       If the -R flag is not specified then the invocation of some recursive
+               macros is trapped and the recursion forcibly terminated with an
+               error message.  The recursions that are trapped are the ones
+               in which the nesting level is non-decreasing from some point on.
+               In particular,
+                       #define a a
+                       a
+               will be detected.  (Use "#undef a" if that is what you want.)
+               The recursion
+                       #define a c b
+                       #define b c a
+                       #define c foo
+                       a
+               will not be detected because the nesting level decreases after
+               each expansion of "c".
+       The -R flag specifically allows recursive macros and recursion will
+               be strictly obeyed (to the extent that space is available).
+               Assuming that -R is specified:
                        #define a a
                        a
                causes an infinite loop with very little output.  The tail recursion
                        #define a a
                        a
                causes an infinite loop with very little output.  The tail recursion
@@ -86,7 +137,7 @@ Bugs fixed:
 Stylistic choice:
        Nothing (not even linefeeds) is output while a false '#if', '#ifdef',
                or '#ifndef' is in effect.  Thus when all conditions become true
 Stylistic choice:
        Nothing (not even linefeeds) is output while a false '#if', '#ifdef',
                or '#ifndef' is in effect.  Thus when all conditions become true
-               a line of the form "# 12345 foo.c" is output.
+               a line of the form "# 12345 \"foo.c\"" is output (unless -P).
        Error and warning messages always appear on standard error (file
                descriptor 2).
        Mismatch between the number of formals and actuals in a macro call
        Error and warning messages always appear on standard error (file
                descriptor 2).
        Mismatch between the number of formals and actuals in a macro call
diff --git a/usr/src/cmd/cpp/makefile b/usr/src/cmd/cpp/makefile
deleted file mode 100644 (file)
index e8e6a89..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-CFLAGS=-O -n -s
-
-all:   cpp
-
-cp:    cpp
-       cp cpp /lib
-       rm *.o cpp
-
-cmp:   cpp
-       cmp cpp /lib/cpp
-       rm *.o cpp
-
-cpp: cpp.o cpy.o
-       cc $(CFLAGS) cpp.o cpy.o -o cpp
-cpp.o: cpp.c
-       cc $(CFLAGS) -c -Dunix=1 -Dpdp11=1 cpp.c
-cpy.o: cpy.y yylex.c
index 6bc7d8d..7a6ba83 100644 (file)
@@ -19,7 +19,7 @@ yylex() {
        struct symtab {
                char *name;
                char *value;
        struct symtab {
                char *name;
                char *value;
-       } *sp;
+       } *sp, *lookup();
 
 for (;;) {
        newp=skipbl(newp);
 
 for (;;) {
        newp=skipbl(newp);
index eda9e9c..b10c8b3 100644 (file)
@@ -7,11 +7,11 @@
 
 #define        LISTS   512
 
 
 #define        LISTS   512
 
-#define        EXACT   100
-#define        ANY     101
-#define        LIST    102
-#define        RANGE   103
-#define        EOS     104
+#define        EXACT   0
+#define        ANY     1
+#define        LIST    2
+#define        RANGE   3
+#define        EOS     4
 char   crontab[]       = "/usr/lib/crontab";
 time_t itime;
 struct tm *loct;
 char   crontab[]       = "/usr/lib/crontab";
 time_t itime;
 struct tm *loct;
@@ -246,7 +246,7 @@ register c;
                c = getchar();
        }
        ungetc(c, stdin);
                c = getchar();
        }
        ungetc(c, stdin);
-       if (n>=100)
+       if (n>100)
                return(-1);
        return(n);
 }
                return(-1);
        return(n);
 }
diff --git a/usr/src/cmd/cvtbl.c b/usr/src/cmd/cvtbl.c
new file mode 100644 (file)
index 0000000..edaddbb
--- /dev/null
@@ -0,0 +1,105 @@
+main(argc,argv)
+       char *argv[];
+{
+/* program to convert tables to new format */
+char *col[20], *len[20];
+char s[200], *p;
+char stt[30];
+int i,j,k,m, first;
+extern int cin, cout;
+for(i=0;i<20;i++)
+       col[i]=len[i]=0;
+first=1;
+while (argc>1 || first)
+       {
+       first=0;
+       if (argc>1)
+               {
+               cin = copen(argv[1], 'r');
+               cout = copen(tmpnam(stt), 'w');
+               }
+       if (cin<0)
+               {
+               printf("can't open file %s\n",argv[1]);
+               cexit(1);
+               }
+       while (gets(s))
+               {
+               puts(s);
+               if (!prefix(".TS", s))
+                       continue;
+               gets(s);
+               k=0;
+               for(p=s; *p; p++)
+                       {
+                       if (letter(*p))
+                               {
+                               col[k++]=p;
+                               while (letter(*p))
+                                       p++;
+                               if (digit(*p))
+                                       len[k-1]=p;
+                               while (digit(*p))
+                                       p++;
+                               }
+                       if (*p==0)break;
+                       }
+               for(i=m=0; i<k; i++)
+                       m=max(length(col[i]),m);
+               for(i=0; i<m; i++)
+                       {
+                       for(j=0; j<k; j++)
+                               {
+                               printf("%c ", *(col[j])++);
+                               if (!letter(*(col[j]))) col[j]--;
+                               if (i==0 && len[i])
+                                       {
+                                       p=len[j];
+                                       while (digit(*p))
+                                               putchar(*p++);
+                                       }
+                               }
+                       if (i+1==m)
+                               printf(".");
+                       printf("\n");
+                       }
+               for(i=0;i<20; i++)
+                       col[i]=len[i]=0;
+               }
+       if (argc>1)
+               {
+               printf(-1, s, "mv %s %s", stt, argv[1]);
+               system(s);
+               argc--;
+               argv++;
+               }
+       }
+}
+length(s)
+       char *s;
+{
+int k;
+for(k=0; s[k]; k++)
+       if (!letter(s[k])) break;
+return(k);
+}
+digit(c)
+{
+return(c>='0' && c<= '9');
+}
+letter(c)
+{
+return((c>='a' && c<= 'z') || (c>= 'A' && c<='Z'));
+}
+prefix(small, big)
+       char *small, *big;
+{
+int c;
+while ((c= *small++) == *big++)
+       if (c==0) return(1);
+return(c==0);
+}
+max(a,b)
+{
+return(a>b? a : b);
+}
diff --git a/usr/src/cmd/dc/Makefile b/usr/src/cmd/dc/Makefile
new file mode 100644 (file)
index 0000000..468ca19
--- /dev/null
@@ -0,0 +1,7 @@
+dc:    dc.c dc.h
+       cc -O dc.c -o dc
+
+install: dc
+       install -s dc $(DESTDIR)/usr/bin
+clean:
+       rm -f *.o
index 7b3078e..e1c8a41 100644 (file)
@@ -1540,7 +1540,6 @@ struct blk *p;
 }
 subt(){
        arg1=pop();
 }
 subt(){
        arg1=pop();
-       EMPTYS;
        savk = sunputc(arg1);
        chsign(arg1);
        sputc(arg1,savk);
        savk = sunputc(arg1);
        chsign(arg1);
        sputc(arg1,savk);
diff --git a/usr/src/cmd/dc/makefile b/usr/src/cmd/dc/makefile
deleted file mode 100644 (file)
index 40f420f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-all:   dc
-
-cmp:   dc
-       cmp dc /bin/dc
-       rm dc
-
-cp:    dc
-       cp dc /bin/dc
-       rm dc
-
-dc:    dc.c dc.h
-       cc -n -s -O dc.c -o dc
index 3766aa9..6c7019b 100644 (file)
@@ -174,8 +174,6 @@ register struct dinode *ip;
                return;
        if (ip->di_nlink==((ecount[i])&0377) && ip->di_nlink!=0)
                return;
                return;
        if (ip->di_nlink==((ecount[i])&0377) && ip->di_nlink!=0)
                return;
-       if (ino < ROOTINO && ip->di_nlink==0 && ecount[i]==0)
-               return;
        if (headpr==0) {
                printf("     entries  link cnt\n");
                headpr++;
        if (headpr==0) {
                printf("     entries  link cnt\n");
                headpr++;
@@ -192,7 +190,7 @@ char *buf;
 
        lseek(fi, bno*BSIZE, 0);
        if (read(fi, buf, cnt) != cnt) {
 
        lseek(fi, bno*BSIZE, 0);
        if (read(fi, buf, cnt) != cnt) {
-               printf("read error %D\n", bno);
+               printf("read error %d\n", bno);
                for(i=0; i<BSIZE; i++)
                        buf[i] = 0;
        }
                for(i=0; i<BSIZE; i++)
                        buf[i] = 0;
        }
index 930af9b..85d5c03 100644 (file)
@@ -1,7 +1,7 @@
 #include <stdio.h>
 #include <signal.h>
 
 #include <stdio.h>
 #include <signal.h>
 
-#define        BIG     32767
+#define        BIG     2147483647
 #define        LCASE   01
 #define        UCASE   02
 #define        SWAB    04
 #define        LCASE   01
 #define        UCASE   02
 #define        SWAB    04
index 2d7c3e0..e3732c3 100644 (file)
@@ -116,7 +116,7 @@ while((c = getc(infile)) != rdelim)
                        else if(c == '\\')
                                if((c = getc(infile)) == EOF)
                                        c = eof();
                        else if(c == '\\')
                                if((c = getc(infile)) == EOF)
                                        c = eof();
-return(c = ' ');
+return(C);
 }
 
 
 }
 
 
@@ -313,10 +313,13 @@ while(C==' ' || c=='\t')
        ;
 if( (c1=c) == '\n')
        return;
        ;
 if( (c1=c) == '\n')
        return;
-c2 = C;
-if(c1=='.' && c2!='.')
+if(c1 == '.')
+       {
        inmacro = NO;
        inmacro = NO;
-if(c2 == '\n')
+       SKIP;
+       return;
+       }
+if( (c2=C) == '\n')
        return;
 
 if(c1=='E' && c2=='Q' && filesp==files)
        return;
 
 if(c1=='E' && c2=='Q' && filesp==files)
@@ -349,9 +352,6 @@ else if(c1=='h' && c2=='w')
        { SKIP; }
 else
        {
        { SKIP; }
 else
        {
-       if(c1=='.' && c2=='.')
-               while(C == '.')
-                       ;
        ++inmacro;
        regline(YES);
        --inmacro;
        ++inmacro;
        regline(YES);
        --inmacro;
@@ -364,7 +364,7 @@ macro()
 {
 /*
 do { SKIP; }
 {
 /*
 do { SKIP; }
-       while(C!='.' || C!='.' || C=='.');      /* look for  .. */
+       while(C!='.' || C!='.');        /* look for  .EN */
 SKIP;
 inmacro = YES;
 }
 SKIP;
 inmacro = YES;
 }
index b773b77..8d534f1 100644 (file)
@@ -6,8 +6,8 @@
 daddr_t        blkno   = 1;
 char   *dargv[] = {
        0,
 daddr_t        blkno   = 1;
 char   *dargv[] = {
        0,
-       "/dev/rp0",
-       "/dev/rp3",
+       "/dev/rp0a",
+       "/dev/rp1g",
        0
 };
 
        0
 };
 
diff --git a/usr/src/cmd/diff3.c b/usr/src/cmd/diff3.c
deleted file mode 100644 (file)
index 0983b6f..0000000
+++ /dev/null
@@ -1,421 +0,0 @@
-#include <stdio.h>
-#
-
-/* diff3 - 3-way differential file comparison*/
-
-/* diff3 [-e] d13 d23 f1 f2 f3 
- *
- * d13 = diff report on f1 vs f3
- * d23 = diff report on f2 vs f3
- * f1, f2, f3 the 3 files
-*/
-
-struct  range {int from,to; };
-       /* from is first in range of changed lines
-        * to is last+1
-        * from=to=line after point of insertion
-       * for added lines
-       */
-struct diff {struct range old, new;};
-
-#define NC 200
-/* de is used to gather editing scripts,
- * that are later spewed out in reverse order.
- * its first element must be all zero
- * the "new" component of de contains line positions
- * or byte positions depending on when you look(!?)
-*/
-struct diff d13[NC];
-struct diff d23[NC];
-struct diff de[NC];
-char line[256];
-FILE *fp[3];
-int linct[3] = {0,0,0};
-/*     the number of the last-read line in each file
- *     is kept in cline[0-2]
-*/
-int cline[3];
-/*     the latest known correspondence between line
- *     numbers of the 3 files is stored in last[1-3]
-*/
-int last[4];
-int eflag;
-int debug  = 0;
-
-main(argc,argv)
-char **argv;
-{
-       register i,m,n;
-       if(*argv[1]=='-') {
-               switch(argv[1][1]) {
-               default:
-                       eflag = 3;
-                       break;
-               case '3':
-                       eflag = 2;
-                       break;
-               case 'x':
-                       eflag = 1;
-               }
-               argv++;
-               argc--;
-       }
-       if(argc<6) {
-               fprintf(stderr,"diff3: arg count\n");
-               exit(1);
-       }
-       m = readin(argv[1],d13);
-       n = readin(argv[2],d23);
-       for(i=0;i<=2;i++)
-               if((fp[i] = fopen(argv[i+3],"r")) == NULL) {
-                       printf("diff3: can't open %s\n",argv[i+3]);
-                       exit(1);
-               }
-       merge(m,n);
-}
-
-/*pick up the line numbers of allcahnges from
- * one change file
- * (this puts the numbers in a vector, which is not
- * strictly necessary, since the vector is processed
- * in one sequential pass. The vector could be optimized
- * out of existence)
-*/
-
-readin(name,dd)
-char *name;
-struct diff *dd;
-{
-       register i;
-       int a,b,c,d;
-       char kind;
-       char *p;
-       fp[0] = fopen(name,"r");
-       for(i=0;getchange(fp[0]);i++) {
-               if(i>=NC) {
-                       fprintf(stderr,"diff3: too many changes\n");
-                       exit(0);
-               }
-               p = line;
-               a = b = number(&p);
-               if(*p==',') {
-                       p++;
-                       b = number(&p);
-               }
-               kind = *p++;
-               c = d = number(&p);
-               if(*p==',') {
-                       p++;
-                       d = number(&p);
-               }
-               if(kind=='a')
-                       a++;
-               if(kind=='d')
-                       c++;
-               b++;
-               d++;
-               dd[i].old.from = a;
-               dd[i].old.to = b;
-               dd[i].new.from = c;
-               dd[i].new.to = d;
-       }
-       dd[i].old.from = dd[i-1].old.to;
-       dd[i].new.from = dd[i-1].new.to;
-       fclose(fp[0]);
-       return(i);
-}
-
-number(lc)
-char **lc;
-{
-       register nn;
-       nn = 0;
-       while(digit(**lc))
-               nn = nn*10 + *(*lc)++ - '0';
-       return(nn);
-}
-
-digit(c)
-{
-       return(c>='0'&&c<='9');
-}
-
-getchange(b)
-FILE *b;
-{
-       while(getline(b))
-               if(digit(line[0]))
-                       return(1);
-       return(0);
-}
-
-getline(b)
-FILE *b;
-{
-       register i, c;
-       for(i=0;i<sizeof(line)-1;i++) {
-               c = getc(b);
-               if(c==EOF)
-                       break;
-               line[i] = c;
-               if(c=='\n') {
-                       line[++i] = 0;
-                       return(i);
-               }
-       }
-       return(0);
-}
-
-merge(m1,m2)
-{
-       register struct diff *d1, *d2, *d3;
-       int dup;
-       int j;
-       int t1,t2;
-       d1 = d13;
-       d2 = d23;
-       j = 0;
-       for(;(t1 = d1<d13+m1) | (t2 = d2<d23+m2);) {
-               if(debug) {
-                       printf("%d,%d=%d,%d %d,%d=%d,%d\n",
-                       d1->old.from,d1->old.to,
-                       d1->new.from,d1->new.to,
-                       d2->old.from,d2->old.to,
-                       d2->new.from,d2->new.to);
-               }
-/*                     first file is different from others*/
-               if(!t2||t1&&d1->new.to < d2->new.from) {
-/*                     stuff peculiar to 1st file */
-                       if(eflag==0) {
-                               separate("1");
-                               change(1,&d1->old,0);
-                               keep(2,&d1->old,&d1->new);
-                               change(3,&d1->new,0);
-                       }
-                       d1++;
-                       continue;
-               }
-/*                     second file is different from others*/
-               if(!t1||t2&&d2->new.to < d1->new.from) {
-                       if(eflag==0) {
-                               separate("2");
-                               keep(1,&d2->old,&d2->new);
-                               change(2,&d2->old,0);
-                               change(3,&d2->new,0);
-                       }
-                       d2++;
-                       continue;
-               }
-/*                     merge overlapping changes in first file
- *                     this happens after extension see below*/
-               if(d1+1<d13+m1 &&
-                  d1->new.to>=d1[1].new.from) {
-                       d1[1].old.from = d1->old.from;
-                       d1[1].new.from = d1->new.from;
-                       d1++;
-                       continue;
-               }
-/*                     merge overlapping changes in second*/
-               if(d2+1<d23+m2 &&
-                  d2->new.to>=d2[1].new.from) {
-                       d2[1].old.from = d2->old.from;
-                       d2[1].new.from = d2->new.from;
-                       d2++;
-                       continue;
-               }
-/*                     stuff peculiar to third file or different in all*/
-               if(d1->new.from==d2->new.from&&
-                  d1->new.to==d2->new.to) {
-                       dup = duplicate(&d1->old,&d2->old);
-/*                             dup=0 means all files differ
- *                             dup =1 meands files 1&2 identical*/
-                       if(eflag==0) {
-                               separate(dup?"3":"");
-                               change(1,&d1->old,dup);
-                               change(2,&d2->old,0);
-                               d3 = d1->old.to>d1->old.from?d1:d2;
-                               change(3,&d3->new,0);
-                       } else
-                               j = edit(d1,dup,j);
-                       d1++;
-                       d2++;
-                       continue;
-               }
-/*                     overlapping changes from file1 & 2
- *                     extend changes appropriately to
- *                     make them coincide*/
-                if(d1->new.from<d2->new.from) {
-                       d2->old.from -= d2->new.from-d1->new.from;
-                       d2->new.from = d1->new.from;
-               }
-               else if(d2->new.from<d1->new.from) {
-                       d1->old.from -= d1->new.from-d2->new.from;
-                       d1->new.from = d2->new.from;
-               }
-               if(d1->new.to >d2->new.to) {
-                       d2->old.to += d1->new.to - d2->new.to;
-                       d2->new.to = d1->new.to;
-               }
-               else if(d2->new.to >d1->new.to) {
-                       d1->old.to += d2->new.to - d1->new.to;
-                       d1->new.to = d2->new.to;
-               }
-       }
-       if(eflag)
-               edscript(j);
-}
-
-separate(s)
-char *s;
-{
-       printf("====%s\n",s);
-}
-
-/*     the range of ines rold.from thru rold.to in file i
- *     is to be changed. it is to be printed only if
- *     it does not duplicate something to be printed later
-*/
-change(i,rold,dup)
-struct range *rold;
-{
-       printf("%d:",i);
-       last[i] = rold->to;
-       prange(rold);
-       if(dup)
-               return;
-       if(debug)
-               return;
-       i--;
-       skip(i,rold->from,(char *)0);
-       skip(i,rold->to,"  ");
-}
-
-/*     print the range of line numbers, rold.from  thru rold.to
- *     as n1,n2 or n1
-*/
-prange(rold)
-struct range *rold;
-{
-       if(rold->to<=rold->from)
-               printf("%da\n",rold->from-1);
-       else {
-               printf("%d",rold->from);
-               if(rold->to > rold->from+1)
-                       printf(",%d",rold->to-1);
-               printf("c\n");
-       }
-}
-
-/*     no difference was reported by diff between file 1(or 2)
- *     and file 3, and an artificial dummy difference (trange)
- *     must be ginned up to correspond to the change reported
- *     in the other file
-*/
-keep(i,rold,rnew)
-struct range *rold, *rnew;
-{
-       register delta;
-       struct range trange;
-       delta = last[3] - last[i];
-       trange.from = rnew->from - delta;
-       trange.to = rnew->to - delta;
-       change(i,&trange,1);
-}
-
-/*     skip to just befor line number from in file i
- *     if "pr" is nonzero, print all skipped stuff
- * w   with string pr as a prefix
-*/
-skip(i,from,pr)
-char *pr;
-{
-       register j,n;
-       for(n=0;cline[i]<from-1;n+=j) {
-               if((j=getline(fp[i]))==0)
-                       trouble();
-               if(pr)
-                       printf("%s%s",pr,line);
-               cline[i]++;
-       }
-       return(n);
-}
-
-/*     return 1 or 0 according as the old range
- *     (in file 1) contains exactly the same data
- *     as the new range (in file 2)
-*/
-duplicate(r1,r2)
-struct range *r1, *r2;
-{
-       register c,d;
-       register nchar;
-       int nline;
-       if(r1->to-r1->from != r2->to-r2->from)
-               return(0);
-       skip(0,r1->from,(char *)0);
-       skip(1,r2->from,(char *)0);
-       nchar = 0;
-       for(nline=0;nline<r1->to-r1->from;nline++) {
-               do {
-                       c = getc(fp[0]);
-                       d = getc(fp[1]);
-                       if(c== -1||d== -1)
-                               trouble();
-                       nchar++;
-                       if(c!=d) {
-                               repos(nchar);
-                               return;
-                       }
-               } while(c!= '\n');
-       }
-       repos(nchar);
-       return(1);
-}
-
-repos(nchar)
-{
-       register i;
-       for(i=0;i<2;i++) 
-               fseek(fp[i], (long)-nchar, 1);
-}
-
-trouble()
-{
-       fprintf(stderr,"diff3: logic error\n");
-       abort();
-}
-
-/*     collect an editing script for later regurgitation
-*/
-edit(diff,dup,j)
-struct diff *diff;
-{
-       if(((dup+1)&eflag)==0)
-               return(j);
-       j++;
-       de[j].old.from = diff->old.from;
-       de[j].old.to = diff->old.to;
-       de[j].new.from = de[j-1].new.to
-           +skip(2,diff->new.from,(char *)0);
-       de[j].new.to = de[j].new.from
-           +skip(2,diff->new.to,(char *)0);
-       return(j);
-}
-
-/*             regurgitate */
-edscript(n)
-{
-       register j,k;
-       char block[512];
-       for(n=n;n>0;n--) {
-               prange(&de[n].old);
-               fseek(fp[2], (long)de[n].new.from, 0);
-               for(k=de[n].new.to-de[n].new.from;k>0;k-= j) {
-                       j = k>512?512:k;
-                       if(fread(block,1,j,fp[2])!=j)
-                               trouble();
-                       fwrite(block, 1, j, stdout);
-               }
-               printf(".\n");
-       }
-}
diff --git a/usr/src/cmd/diff3/Makefile b/usr/src/cmd/diff3/Makefile
new file mode 100644 (file)
index 0000000..d9606e1
--- /dev/null
@@ -0,0 +1,11 @@
+CFLAGS=-O -d2
+
+diff3: diff3.o
+       cc -o diff3 diff3.o
+
+install: diff3
+       install -s diff3 $(DESTDIR)/usr/lib
+       install -c diff3.sh $(DESTDIR)/usr/bin/diff3
+
+clean:
+       rm -f diff3.o diff3     
diff --git a/usr/src/cmd/diff3/diff3.c b/usr/src/cmd/diff3/diff3.c
new file mode 100644 (file)
index 0000000..0983b6f
--- /dev/null
@@ -0,0 +1,421 @@
+#include <stdio.h>
+#
+
+/* diff3 - 3-way differential file comparison*/
+
+/* diff3 [-e] d13 d23 f1 f2 f3 
+ *
+ * d13 = diff report on f1 vs f3
+ * d23 = diff report on f2 vs f3
+ * f1, f2, f3 the 3 files
+*/
+
+struct  range {int from,to; };
+       /* from is first in range of changed lines
+        * to is last+1
+        * from=to=line after point of insertion
+       * for added lines
+       */
+struct diff {struct range old, new;};
+
+#define NC 200
+/* de is used to gather editing scripts,
+ * that are later spewed out in reverse order.
+ * its first element must be all zero
+ * the "new" component of de contains line positions
+ * or byte positions depending on when you look(!?)
+*/
+struct diff d13[NC];
+struct diff d23[NC];
+struct diff de[NC];
+char line[256];
+FILE *fp[3];
+int linct[3] = {0,0,0};
+/*     the number of the last-read line in each file
+ *     is kept in cline[0-2]
+*/
+int cline[3];
+/*     the latest known correspondence between line
+ *     numbers of the 3 files is stored in last[1-3]
+*/
+int last[4];
+int eflag;
+int debug  = 0;
+
+main(argc,argv)
+char **argv;
+{
+       register i,m,n;
+       if(*argv[1]=='-') {
+               switch(argv[1][1]) {
+               default:
+                       eflag = 3;
+                       break;
+               case '3':
+                       eflag = 2;
+                       break;
+               case 'x':
+                       eflag = 1;
+               }
+               argv++;
+               argc--;
+       }
+       if(argc<6) {
+               fprintf(stderr,"diff3: arg count\n");
+               exit(1);
+       }
+       m = readin(argv[1],d13);
+       n = readin(argv[2],d23);
+       for(i=0;i<=2;i++)
+               if((fp[i] = fopen(argv[i+3],"r")) == NULL) {
+                       printf("diff3: can't open %s\n",argv[i+3]);
+                       exit(1);
+               }
+       merge(m,n);
+}
+
+/*pick up the line numbers of allcahnges from
+ * one change file
+ * (this puts the numbers in a vector, which is not
+ * strictly necessary, since the vector is processed
+ * in one sequential pass. The vector could be optimized
+ * out of existence)
+*/
+
+readin(name,dd)
+char *name;
+struct diff *dd;
+{
+       register i;
+       int a,b,c,d;
+       char kind;
+       char *p;
+       fp[0] = fopen(name,"r");
+       for(i=0;getchange(fp[0]);i++) {
+               if(i>=NC) {
+                       fprintf(stderr,"diff3: too many changes\n");
+                       exit(0);
+               }
+               p = line;
+               a = b = number(&p);
+               if(*p==',') {
+                       p++;
+                       b = number(&p);
+               }
+               kind = *p++;
+               c = d = number(&p);
+               if(*p==',') {
+                       p++;
+                       d = number(&p);
+               }
+               if(kind=='a')
+                       a++;
+               if(kind=='d')
+                       c++;
+               b++;
+               d++;
+               dd[i].old.from = a;
+               dd[i].old.to = b;
+               dd[i].new.from = c;
+               dd[i].new.to = d;
+       }
+       dd[i].old.from = dd[i-1].old.to;
+       dd[i].new.from = dd[i-1].new.to;
+       fclose(fp[0]);
+       return(i);
+}
+
+number(lc)
+char **lc;
+{
+       register nn;
+       nn = 0;
+       while(digit(**lc))
+               nn = nn*10 + *(*lc)++ - '0';
+       return(nn);
+}
+
+digit(c)
+{
+       return(c>='0'&&c<='9');
+}
+
+getchange(b)
+FILE *b;
+{
+       while(getline(b))
+               if(digit(line[0]))
+                       return(1);
+       return(0);
+}
+
+getline(b)
+FILE *b;
+{
+       register i, c;
+       for(i=0;i<sizeof(line)-1;i++) {
+               c = getc(b);
+               if(c==EOF)
+                       break;
+               line[i] = c;
+               if(c=='\n') {
+                       line[++i] = 0;
+                       return(i);
+               }
+       }
+       return(0);
+}
+
+merge(m1,m2)
+{
+       register struct diff *d1, *d2, *d3;
+       int dup;
+       int j;
+       int t1,t2;
+       d1 = d13;
+       d2 = d23;
+       j = 0;
+       for(;(t1 = d1<d13+m1) | (t2 = d2<d23+m2);) {
+               if(debug) {
+                       printf("%d,%d=%d,%d %d,%d=%d,%d\n",
+                       d1->old.from,d1->old.to,
+                       d1->new.from,d1->new.to,
+                       d2->old.from,d2->old.to,
+                       d2->new.from,d2->new.to);
+               }
+/*                     first file is different from others*/
+               if(!t2||t1&&d1->new.to < d2->new.from) {
+/*                     stuff peculiar to 1st file */
+                       if(eflag==0) {
+                               separate("1");
+                               change(1,&d1->old,0);
+                               keep(2,&d1->old,&d1->new);
+                               change(3,&d1->new,0);
+                       }
+                       d1++;
+                       continue;
+               }
+/*                     second file is different from others*/
+               if(!t1||t2&&d2->new.to < d1->new.from) {
+                       if(eflag==0) {
+                               separate("2");
+                               keep(1,&d2->old,&d2->new);
+                               change(2,&d2->old,0);
+                               change(3,&d2->new,0);
+                       }
+                       d2++;
+                       continue;
+               }
+/*                     merge overlapping changes in first file
+ *                     this happens after extension see below*/
+               if(d1+1<d13+m1 &&
+                  d1->new.to>=d1[1].new.from) {
+                       d1[1].old.from = d1->old.from;
+                       d1[1].new.from = d1->new.from;
+                       d1++;
+                       continue;
+               }
+/*                     merge overlapping changes in second*/
+               if(d2+1<d23+m2 &&
+                  d2->new.to>=d2[1].new.from) {
+                       d2[1].old.from = d2->old.from;
+                       d2[1].new.from = d2->new.from;
+                       d2++;
+                       continue;
+               }
+/*                     stuff peculiar to third file or different in all*/
+               if(d1->new.from==d2->new.from&&
+                  d1->new.to==d2->new.to) {
+                       dup = duplicate(&d1->old,&d2->old);
+/*                             dup=0 means all files differ
+ *                             dup =1 meands files 1&2 identical*/
+                       if(eflag==0) {
+                               separate(dup?"3":"");
+                               change(1,&d1->old,dup);
+                               change(2,&d2->old,0);
+                               d3 = d1->old.to>d1->old.from?d1:d2;
+                               change(3,&d3->new,0);
+                       } else
+                               j = edit(d1,dup,j);
+                       d1++;
+                       d2++;
+                       continue;
+               }
+/*                     overlapping changes from file1 & 2
+ *                     extend changes appropriately to
+ *                     make them coincide*/
+                if(d1->new.from<d2->new.from) {
+                       d2->old.from -= d2->new.from-d1->new.from;
+                       d2->new.from = d1->new.from;
+               }
+               else if(d2->new.from<d1->new.from) {
+                       d1->old.from -= d1->new.from-d2->new.from;
+                       d1->new.from = d2->new.from;
+               }
+               if(d1->new.to >d2->new.to) {
+                       d2->old.to += d1->new.to - d2->new.to;
+                       d2->new.to = d1->new.to;
+               }
+               else if(d2->new.to >d1->new.to) {
+                       d1->old.to += d2->new.to - d1->new.to;
+                       d1->new.to = d2->new.to;
+               }
+       }
+       if(eflag)
+               edscript(j);
+}
+
+separate(s)
+char *s;
+{
+       printf("====%s\n",s);
+}
+
+/*     the range of ines rold.from thru rold.to in file i
+ *     is to be changed. it is to be printed only if
+ *     it does not duplicate something to be printed later
+*/
+change(i,rold,dup)
+struct range *rold;
+{
+       printf("%d:",i);
+       last[i] = rold->to;
+       prange(rold);
+       if(dup)
+               return;
+       if(debug)
+               return;
+       i--;
+       skip(i,rold->from,(char *)0);
+       skip(i,rold->to,"  ");
+}
+
+/*     print the range of line numbers, rold.from  thru rold.to
+ *     as n1,n2 or n1
+*/
+prange(rold)
+struct range *rold;
+{
+       if(rold->to<=rold->from)
+               printf("%da\n",rold->from-1);
+       else {
+               printf("%d",rold->from);
+               if(rold->to > rold->from+1)
+                       printf(",%d",rold->to-1);
+               printf("c\n");
+       }
+}
+
+/*     no difference was reported by diff between file 1(or 2)
+ *     and file 3, and an artificial dummy difference (trange)
+ *     must be ginned up to correspond to the change reported
+ *     in the other file
+*/
+keep(i,rold,rnew)
+struct range *rold, *rnew;
+{
+       register delta;
+       struct range trange;
+       delta = last[3] - last[i];
+       trange.from = rnew->from - delta;
+       trange.to = rnew->to - delta;
+       change(i,&trange,1);
+}
+
+/*     skip to just befor line number from in file i
+ *     if "pr" is nonzero, print all skipped stuff
+ * w   with string pr as a prefix
+*/
+skip(i,from,pr)
+char *pr;
+{
+       register j,n;
+       for(n=0;cline[i]<from-1;n+=j) {
+               if((j=getline(fp[i]))==0)
+                       trouble();
+               if(pr)
+                       printf("%s%s",pr,line);
+               cline[i]++;
+       }
+       return(n);
+}
+
+/*     return 1 or 0 according as the old range
+ *     (in file 1) contains exactly the same data
+ *     as the new range (in file 2)
+*/
+duplicate(r1,r2)
+struct range *r1, *r2;
+{
+       register c,d;
+       register nchar;
+       int nline;
+       if(r1->to-r1->from != r2->to-r2->from)
+               return(0);
+       skip(0,r1->from,(char *)0);
+       skip(1,r2->from,(char *)0);
+       nchar = 0;
+       for(nline=0;nline<r1->to-r1->from;nline++) {
+               do {
+                       c = getc(fp[0]);
+                       d = getc(fp[1]);
+                       if(c== -1||d== -1)
+                               trouble();
+                       nchar++;
+                       if(c!=d) {
+                               repos(nchar);
+                               return;
+                       }
+               } while(c!= '\n');
+       }
+       repos(nchar);
+       return(1);
+}
+
+repos(nchar)
+{
+       register i;
+       for(i=0;i<2;i++) 
+               fseek(fp[i], (long)-nchar, 1);
+}
+
+trouble()
+{
+       fprintf(stderr,"diff3: logic error\n");
+       abort();
+}
+
+/*     collect an editing script for later regurgitation
+*/
+edit(diff,dup,j)
+struct diff *diff;
+{
+       if(((dup+1)&eflag)==0)
+               return(j);
+       j++;
+       de[j].old.from = diff->old.from;
+       de[j].old.to = diff->old.to;
+       de[j].new.from = de[j-1].new.to
+           +skip(2,diff->new.from,(char *)0);
+       de[j].new.to = de[j].new.from
+           +skip(2,diff->new.to,(char *)0);
+       return(j);
+}
+
+/*             regurgitate */
+edscript(n)
+{
+       register j,k;
+       char block[512];
+       for(n=n;n>0;n--) {
+               prange(&de[n].old);
+               fseek(fp[2], (long)de[n].new.from, 0);
+               for(k=de[n].new.to-de[n].new.from;k>0;k-= j) {
+                       j = k>512?512:k;
+                       if(fread(block,1,j,fp[2])!=j)
+                               trouble();
+                       fwrite(block, 1, j, stdout);
+               }
+               printf(".\n");
+       }
+}
diff --git a/usr/src/cmd/diff3/diff3.sh b/usr/src/cmd/diff3/diff3.sh
new file mode 100755 (executable)
index 0000000..d56219f
--- /dev/null
@@ -0,0 +1,17 @@
+e=
+case $1 in
+-*)
+       e=$1
+       shift;;
+esac
+if test $# = 3 -a -f $1 -a -f $2 -a -f $3
+then
+       :
+else
+       echo usage: diff3 file1 file2 file3 1>&2
+       exit
+fi
+trap "rm -f /tmp/d3[ab]$$" 0 1 2 13 15
+diff $1 $3 >/tmp/d3a$$
+diff $2 $3 >/tmp/d3b$$
+/usr/lib/diff3 $e /tmp/d3[ab]$$ $1 $2 $3
diff --git a/usr/src/cmd/dpr.c b/usr/src/cmd/dpr.c
new file mode 100644 (file)
index 0000000..ab7b7b9
--- /dev/null
@@ -0,0 +1,267 @@
+#include <signal.h>
+/*
+ *     dpr -- off line print via dataphone daemon to GCOS
+ *             normally invoked through opr
+ */
+
+char   tfname[]        = "/usr/dpd/tfaXXXXX";
+char   cfname[]        = "/usr/dpd/cfaXXXXX";
+char   lfname[]        = "/usr/dpd/lfaXXXXX";
+char   dfname[]        = "/usr/dpd/dfaXXXXX";
+int    nact;
+int    tff;
+int    mailflg;
+char   person[10];
+int    inchar;
+int    maxrec  = 400;
+
+main(argc, argv)
+int argc;
+char *argv[];
+{
+       register char *arg, *remote;
+       int c, f, flag;
+       int out();
+
+       pidfn();
+       if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
+               signal(SIGHUP, out);
+       if (signal(SIGINT, SIG_IGN) != SIG_IGN)
+               signal(SIGINT, out);
+       if (signal(SIGQUIT, SIG_IGN) != SIG_IGN)
+               signal(SIGQUIT, out);
+       remote = "$     remote  **,onl";
+       flag = 0;
+       tff = nfile(tfname);
+       while (argc>1 && (arg = argv[1])[0]=='-') {
+               if (arg[1] && arg[2]) {
+                       remote[12] = arg[1];
+                       remote[13] = arg[2];
+                       remote[14] = 0;
+               } else switch (arg[1]) {
+
+               case '-':
+                       remote[12] = 'r';
+                       remote[13] = '1';
+                       remote[14] = '\0';
+                       break;
+
+               case 'c':
+                       flag = '+';
+                       break;
+
+               case 'r':
+                       flag = '-';
+                       break;
+
+               case 'm':
+                       mailflg = 1;
+                       break;
+               }
+               argc--;
+               argv++;
+       }
+       card('S', "");
+       card('L', "$    sgrade  2");
+       ident();
+       card('L', remote);
+       card('L', "$    select  ken/mh322");
+       card('L', "$    data    i*,ncksum,copy");
+
+       if(argc == 1)
+               copy(0);
+       while(--argc) {
+               arg = *++argv;
+               if(flag == '+')
+                       goto cf;
+               if(*arg == '/' && flag != '-') {
+                       card('F', arg);
+                       nact++;
+                       continue;
+               }
+               if(link(arg, lfname) < 0)
+                       goto cf;
+               card('F', lfname);
+               card('U', lfname);
+               lfname[inchar]++;
+               nact++;
+               goto df;
+
+       cf:
+               f = open(arg, 0);
+               if(f < 0) {
+                       printf("Cannot open %s\n", arg);
+                       continue;
+               }
+               copy(f);
+               close(f);
+
+       df:
+               if(flag == '-') {
+                       f = unlink(arg);
+                       if(f < 0)
+                               printf("Cannot remove %s\n", arg);
+               }
+       }
+
+       card('L', "$    endcopy");
+       card('L', "$    endjob");
+       if(nact) {
+               tfname[inchar]--;
+               f = link(tfname, dfname);
+               if(f < 0) {
+                       printf("Cannot rename %s\n", dfname);
+                       tfname[inchar]++;
+                       out();
+               }
+               unlink(tfname);
+               execl("/etc/dpd", "dpd", 0);
+               dfname[inchar]++;
+       }
+       out();
+}
+
+copy(f)
+int f;
+{
+       int ff, i, nr, nc;
+       static int buf[256];
+
+       card('F', cfname);
+       card('U', cfname);
+       ff = nfile(cfname);
+       nc = 0;
+       nr = 0;
+       while((i = read(f, buf, 512)) > 0) {
+               write(ff, buf, i);
+               nc += i;
+               if(nc >= 512) {
+                       nc -= 512;
+                       nr++;
+                       if(nr > maxrec) {
+                               printf("Copy file is too large\n");
+                               break;
+                       }
+               }
+       }
+       close(ff);
+       nact++;
+}
+
+card(c, s)
+int c;
+char s[];
+{
+       char *p1, *p2;
+       static char buf[512];
+       int col;
+
+       p1 = buf;
+       p2 = s;
+       col = 0;
+       *p1++ = c;
+       while((c = *p2++) != '\0') {
+               *p1++ = c;
+               col++;
+       }
+       *p1++ = '\n';
+       write(tff, buf, col+2);
+}
+
+ident()
+{
+       int c, n;
+       register char *b1p, *pp, *b2p;
+       static char b1[100], b2[100];
+
+       b1p = b1;
+       if(getpw(getuid(), b1p)) {
+               b1p = "pdp::::m0000,m000:";
+       }
+       n = 0;
+       b2p = b2;
+       while(*b2p++ = "$       ident   "[n++]);
+       b2p--;
+       n = 5;
+       while(--n) while(*b1p++ != ':');
+       while((*b2p++ = *b1p++) != ':');
+       b2p[-1] = ',';
+       b1p = b1;
+       pp = person;
+       while((c = *b1p++) != ':') {
+               *b2p++ = c;
+               *pp++ = c;
+       }
+       *b2p++ = 0;
+       *pp++ = 0;
+       card('L', b2);
+       if (mailflg)
+               card('M', person);
+}
+
+pidfn()
+{
+       register i, j, c;
+       int s;
+       int p;
+
+       s = p = getpid();
+       p &= 077777;
+       i = 0;
+       while(tfname[i] != 'X')
+               i++;
+       i += 4;
+       for(j=0; j<5; j++) {
+               c = (p%10) + '0';
+               if(s<0 && j==4)
+                       c += 4;
+               p /= 10;
+               tfname[i] = c;
+               cfname[i] = c;
+               lfname[i] = c;
+               dfname[i] = c;
+               i--;
+       }
+       inchar = i;
+}
+
+nfile(name)
+char *name;
+{
+       register f;
+
+       f = creat(name, 0666);
+       if(f < 0) {
+               printf("Cannot create %s\n", name);
+               out();
+       }
+       name[inchar]++;
+       return(f);
+}
+
+out()
+{
+       register i;
+
+       signal(SIGHUP, SIG_IGN);
+       signal(SIGINT, SIG_IGN);
+       signal(SIGQUIT, SIG_IGN);
+       i = inchar;
+       while(tfname[i] != 'a') {
+               tfname[i]--;
+               unlink(tfname);
+       }
+       while(cfname[i] != 'a') {
+               cfname[i]--;
+               unlink(cfname);
+       }
+       while(lfname[i] != 'a') {
+               lfname[i]--;
+               unlink(lfname);
+       }
+       while(dfname[i] != 'a') {
+               dfname[i]--;
+               unlink(dfname);
+       }
+       exit(0);
+}
diff --git a/usr/src/cmd/draw.c b/usr/src/cmd/draw.c
new file mode 100644 (file)
index 0000000..21727d8
--- /dev/null
@@ -0,0 +1,3 @@
+/*
+see agf for this source
+*/
index 986d424..b58ca76 100644 (file)
@@ -65,7 +65,7 @@ char *argv[];
 
        tsize = 2300L*12L*10L;
        tape = "/dev/rmt1";
 
        tsize = 2300L*12L*10L;
        tape = "/dev/rmt1";
-       disk = "/dev/rrp3";
+       disk = "/dev/rrp1g";
        increm = "/etc/ddate";
        incno = '9';
        uflag = 0;
        increm = "/etc/ddate";
        incno = '9';
        uflag = 0;
@@ -90,7 +90,7 @@ char *argv[];
                if (argc > 1) {
                        argv++;
                        argc--;
                if (argc > 1) {
                        argv++;
                        argc--;
-                       density = atoi(*argv)/10;
+                       density = atoi(*argv);
                }
                break;
 
                }
                break;
 
index 37f20f0..8660886 100644 (file)
@@ -1,4 +1,4 @@
-#define MAXINO 3000
+#define MAXINO 2000
 #define BITS   8
 #define MAXXTR 60
 #define NCACHE 3
 #define BITS   8
 #define MAXXTR 60
 #define NCACHE 3
index 58b81c6..22de9fd 100644 (file)
@@ -23,7 +23,7 @@
 char gotofn[NSTATES][NCHARS];
 int state[NSTATES];
 char out[NSTATES];
 char gotofn[NSTATES][NCHARS];
 int state[NSTATES];
 char out[NSTATES];
-int line 1;
+int line 1;
 int name[MAXLIN];
 int left[MAXLIN];
 int right[MAXLIN];
 int name[MAXLIN];
 int left[MAXLIN];
 int right[MAXLIN];
@@ -32,7 +32,7 @@ int foll[MAXLIN];
 int positions[MAXPOS];
 char chars[MAXLIN];
 int nxtpos;
 int positions[MAXPOS];
 char chars[MAXLIN];
 int nxtpos;
-int nxtchar 0;
+int nxtchar 0;
 int tmpstat[MAXLIN];
 int initstat[MAXLIN];
 int xstate;
 int tmpstat[MAXLIN];
 int initstat[MAXLIN];
 int xstate;
@@ -50,7 +50,7 @@ int   hflag   = 1;
 int    sflag;
 int    vflag;
 int    nfile;
 int    sflag;
 int    vflag;
 int    nfile;
-long   blkno;
+int    blkno;
 long   tln;
 int    nsucc;
 
 long   tln;
 int    nsucc;
 
@@ -506,10 +506,10 @@ char *file;
        ccount = 0;
        lnum = 1;
        tln = 0;
        ccount = 0;
        lnum = 1;
        tln = 0;
+       blkno = 0;
        p = buf;
        nlp = p;
        if ((ccount = read(f,p,512))<=0) goto done;
        p = buf;
        nlp = p;
        if ((ccount = read(f,p,512))<=0) goto done;
-       blkno = ccount;
        istat = cstat = gotofn[0]['\n'];
        if (out[cstat]) goto found;
        for (;;) {
        istat = cstat = gotofn[0]['\n'];
        if (out[cstat]) goto found;
        for (;;) {
@@ -529,7 +529,7 @@ char *file;
                                                }
                                                else {
                                                        if (nfile > 1 && hflag) printf("%s:", file);
                                                }
                                                else {
                                                        if (nfile > 1 && hflag) printf("%s:", file);
-                                                       if (bflag) printf("%ld:", (blkno-ccount-1)/512);
+                                                       if (bflag) printf("%d:", blkno);
                                                        if (nflag) printf("%ld:", lnum);
                                                        if (p <= nlp) {
                                                                while (nlp < &buf[1024]) putchar(*nlp++);
                                                        if (nflag) printf("%ld:", lnum);
                                                        if (p <= nlp) {
                                                                while (nlp < &buf[1024]) putchar(*nlp++);
@@ -554,9 +554,7 @@ char *file;
                                        else {
                                                if ((ccount = read(f, p, &buf[1024]-p)) <= 0) goto done;
                                        }
                                        else {
                                                if ((ccount = read(f, p, &buf[1024]-p)) <= 0) goto done;
                                        }
-                                       if(nlp>p && nlp<=p+ccount)
-                                               nlp = p+ccount;
-                                       blkno += ccount;
+                                       blkno++;
                                }
                        }
                }
                                }
                        }
                }
@@ -580,9 +578,7 @@ char *file;
                        else {
                                if ((ccount = read(f, p, &buf[1024] - p)) <= 0) break;
                        }
                        else {
                                if ((ccount = read(f, p, &buf[1024] - p)) <= 0) break;
                        }
-                       if(nlp>p && nlp<=p+ccount)
-                               nlp = p+ccount;
-                       blkno += ccount;
+                       blkno++;
                }
        }
 done:  close(f);
                }
        }
 done:  close(f);
diff --git a/usr/src/cmd/eqn/Makefile b/usr/src/cmd/eqn/Makefile
new file mode 100644 (file)
index 0000000..8843a9d
--- /dev/null
@@ -0,0 +1,34 @@
+CFLAGS=-O -d2
+YFLAGS=-d
+
+SOURCE = e.y e.h diacrit.c eqnbox.c font.c fromto.c funny.c glob.c integral.c \
+ io.c lex.c lookup.c mark.c matrix.c move.c over.c paren.c \
+ pile.c shift.c size.c sqrt.c text.c
+
+FILES = e.o diacrit.o eqnbox.o font.o fromto.o funny.o glob.o integral.o \
+ io.o lex.o lookup.o mark.o matrix.o move.o over.o paren.o \
+ pile.o shift.o size.o sqrt.o text.o
+
+eqn:   $(FILES)
+       cc $(CFLAGS) $(FILES) -o eqn
+
+e.c:   e.def
+
+e.def: e.y
+       yacc -d e.y
+       mv y.tab.c e.c
+       mv y.tab.h e.def
+
+$(FILES):      e.h e.def
+
+install: eqn
+       install -s eqn $(DESTDIR)/usr/bin
+
+clean:
+       rm -f *.o e.c e.def eqn
+       
+list:
+       pr TODO $(SOURCE) makefile
+
+lint:  y.tab.c
+       lint -spb *.c
diff --git a/usr/src/cmd/eqn/makefile b/usr/src/cmd/eqn/makefile
deleted file mode 100644 (file)
index 50c64a0..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-CFLAGS=-O
-YFLAGS=-d
-
-all:   eqn
-
-cp:    eqn
-       cp eqn /bin/eqn
-       rm *.o e.c e.def eqn
-
-cmp:   eqn
-       cmp eqn /bin/eqn
-       rm *.o e.c e.def eqn
-
-SOURCE = e.y e.h diacrit.c eqnbox.c font.c fromto.c funny.c glob.c integral.c \
- io.c lex.c lookup.c mark.c matrix.c move.c over.c paren.c \
- pile.c shift.c size.c sqrt.c text.c
-
-FILES = e.o diacrit.o eqnbox.o font.o fromto.o funny.o glob.o integral.o \
- io.o lex.o lookup.o mark.o matrix.o move.o over.o paren.o \
- pile.o shift.o size.o sqrt.o text.o
-
-eqn:   $(FILES)
-       cc -n -s $(CFLAGS) $(FILES) -o eqn
-
-e.c:   e.def
-
-e.def: e.y
-       yacc -d e.y
-       mv y.tab.c e.c
-       mv y.tab.h e.def
-
-$(FILES):      e.h e.def
-
-list:
-       pr TODO $(SOURCE) makefile
-
-gcos:  y.tab.c
-       fsend e.h e.y *.c
-
-src:   makefile $(SOURCE)
-       cp $? /usr/src/cmd/eqn
-       touch src
-
-lint:  y.tab.c
-       lint -spb *.c
diff --git a/usr/src/cmd/f77/Makefile b/usr/src/cmd/f77/Makefile
new file mode 100644 (file)
index 0000000..9025a88
--- /dev/null
@@ -0,0 +1,92 @@
+# Makefile for the Fortran 77 command
+#  Running on the VAX
+#  Generating code for the VAX
+#  Using the Johnson C compiler's second pass (binary version)
+COMPFLGS = -O -DTARGET=VAX -DFAMILY=SCJ -DHERE=VAX -DOUTPUT=BINARY -DPOLISH=POSTFIX
+FILES = Makefile defs defines locdefs drivedefs ftypes scjdefs tokens fio.h\
+       driver.c \
+       main.c proc.c init.c\
+       gram.head gram.dcl gram.expr gram.exec gram.io\
+       lex.c equiv.c data.c expr.c exec.c intr.c\
+       io.c misc.c error.c put.c putscjb.c vax.c vaxx.c 
+
+
+OBJECTS = main.o init.o proc.o gram.o lex.o \
+         equiv.o data.o expr.o exec.o intr.o io.o misc.o error.o\
+         put.o putscjb.o vax.o vaxx.o
+
+compiler: f77 f77pass1
+
+f77 : driver.o vaxx.o
+       cc -n driver.o vaxx.o -o f77
+       @size f77
+
+f77pass1 : $(OBJECTS)
+       @echo LOAD
+       @$(CC) $(LDFLAGS) $(OBJECTS) -o f77pass1
+       @size f77pass1
+
+gram.c:        gram.head gram.dcl gram.expr gram.exec gram.io tokdefs
+       ( sed <tokdefs "s/#define/%token/" ;\
+               cat gram.head gram.dcl gram.expr gram.exec gram.io ) >gram.in
+       $(YACC) $(YFLAGS) gram.in
+       mv y.tab.c gram.c
+       rm gram.in
+
+tokdefs: tokens
+       grep -n . <tokens | sed "s/\([^:]*\):\(.*\)/#define \2 \1/" >tokdefs
+
+lex.o : tokdefs
+driver.o $(OBJECTS)  : defs defines locdefs ftypes
+driver.o : drivedefs
+
+locdefs : vaxdefs
+       cp vaxdefs locdefs
+
+put.o putscjb.o : scjdefs
+io.o : fio.h
+scjdefs : nmanifest    ;
+
+nmanifest :# /usr/tbl/scj/manifest
+#      @echo "***Warning: /usr/tbl/scj/manifest has changed***"
+
+fio.h :# /usr/sif/fort/libI77/fio.h
+#      @echo "***Warning : /usr/sif/fort/libI77/fio.h has changed***"
+
+archall:
+       ar rc ../fortarch $(FILES)
+
+arch :  ../fortarch
+
+../fortarch:  $(FILES)
+       @ar uv ../fortarch $?
+       @wc ../fortarch
+
+
+printall:
+       pr $(FILES) | $P
+       touch print
+
+print: $(FILES)
+       pr $? | $P
+       touch print
+
+lint:
+       @echo "nohup lint -p ... >Lintout&"
+       @nohup lint -p error.c exec.c intr.c expr.c gram.c init.c io.c\
+               lex.c main.c proc.c misc.c put.c putscjb.c vax.c vaxx.c\
+               equiv.c data.c -lS >Lintout&
+
+clean:
+       -rm -f gram.c *.o f77 f77pass1
+       du
+
+install: 
+       install -s f77 $(DESTDIR)/usr/bin
+       install -s f77pass1 $(DESTDIR)/usr/lib
+
+src : $(FILES) vaxdefs
+       cp $? /usr/src/cmd/f77
+       touch src
+.c.o :
+       cc -c $(CFLAGS) $(COMPFLGS) $*.c
index b9539cc..a4e1f8f 100644 (file)
@@ -17,7 +17,7 @@
 #define MAXSTNO 201
 #define MAXEXT 200
 #define MAXEQUIV 150
 #define MAXSTNO 201
 #define MAXEXT 200
 #define MAXEQUIV 150
-#define MAXLABLIST 125
+#define MAXLABLIST 100
 
 typedef union expression *expptr;
 typedef union taggedblock *tagptr;
 
 typedef union expression *expptr;
 typedef union taggedblock *tagptr;
diff --git a/usr/src/cmd/f77/dmrdefs b/usr/src/cmd/f77/dmrdefs
deleted file mode 100644 (file)
index 8937b54..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-#define P2BAD -1
-#define P2NAME 20
-#define P2ICON 21
-#define P2PLUS 40
-#define P2PLUSEQ       70
-#define P2MINUS        41
-#define P2NEG  37
-#define P2STAR 42
-#define P2STAREQ       72
-#define P2ADDR 35
-#define P2INDIRECT     36
-#define P2BITNOT       38
-#define P2BITAND       47
-#define P2BITOR        48
-#define P2BITXOR       49
-#define P2QUEST        90
-#define P2COLON        8
-#define P2ANDAND       53
-#define P2OROR 54
-#define P2GOTO 111
-#define P2LISTOP       9
-#define P2ASSIGN       80
-#define P2COMOP        97
-#define P2SLASH        43
-#define P2MOD  44
-#define P2RSHIFT       45
-#define P2LSHIFT       46
-#define P2CALL 100
-
-#define P2NOT  34
-#define P2EQ   60
-#define P2NE   61
-#define P2LE   62
-#define P2LT   63
-#define P2GE   64
-#define P2GT   65
-#define P2EXTERN       12
-#define P2STATIC       13
-#define P2REG  14
-#define P2CONV -1
-#define P2FORCE        110
-#define P2CBRANCH      103
-#define P2ARIF 222
-
-#define P2EXPR 214
-#define P2JUMP 102
-#define P2LABEL        112
-#define P2RLABEL       114
-#define P2SWITCH       213
-#define P2LCON 25
-#define P2NULL 218
-#define P2EOF  0
-#define P2RETURN       209
-#define P2SAVE 208
-#define P2SETREG       105
-#define P2SETSTK       219
-#define P2PROG 202
-
-#define P2CHAR 1
-
-#if TARGET==PDP11
-#      define P2SHORT  0
-#      define P2INT    0
-#      define P2LONG   6
-#else
-#      define P2SHORT  0
-#      define P2INT    6
-#      define P2LONG   6
-#endif
-
-#define P2REAL 2
-#define P2DREAL        3
-#define P2PTR  010
-#define P2FUNCT        020
-
-#define P2ITOF 51
-#define P2FTOI 52
-#define P2FTOL 56
-#define P2LTOF 57
-#define P2ITOL 58
-#define P2LTOI 59
-#define P2ITOC 109
-
-#define P2PROFIL       212
index c992da6..a330f9d 100644 (file)
@@ -1,15 +1,15 @@
 /*
   Driver for Fortran 77 Compiler
 /*
   Driver for Fortran 77 Compiler
-  For the PDP11, Running on the PDP11
+  For the VAX, Running on the VAX
   Using the Ritchie C compiler's second pass
 */
 
   Using the Ritchie C compiler's second pass
 */
 
-#if HERE!=PDP11 || TARGET!=PDP11 || FAMILY!=DMR
+#if HERE!=VAX || TARGET!=VAX || FAMILY!=SCJ
        Wrong Definitions File!
 #endif
 
        Wrong Definitions File!
 #endif
 
-#define PASS1NAME      "/lib/f77pass1"
-#define PASS2NAME      "/lib/c1"
+#define PASS1NAME      "/usr/lib/f77pass1"
+#define PASS2NAME      "/lib/f1"
 #define PASS2OPT       "/lib/c2"
 #define NOFLPASS2      "/lib/fc1"
 #define ASMNAME        "/bin/as"
 #define PASS2OPT       "/lib/c2"
 #define NOFLPASS2      "/lib/fc1"
 #define ASMNAME        "/bin/as"
@@ -25,4 +25,5 @@ static char *liblist [ ] =
        "-lI77",
        "-lm",
        "-lc",
        "-lI77",
        "-lm",
        "-lc",
+       "-l",
        NULL };
        NULL };
index daf3456..bfcc268 100644 (file)
@@ -1,4 +1,4 @@
-char *xxxvers[] = "\n FORTRAN 77 DRIVER, VERSION 1.13,   20 APRIL 1979\n";
+char *xxxvers[] = "\n FORTRAN 77 DRIVER, VERSION 1.11,   28 JULY 1978\n";
 #include <stdio.h>
 #include <ctype.h>
 #include "defines"
 #include <stdio.h>
 #include <ctype.h>
 #include "defines"
@@ -11,8 +11,6 @@ static FILEP diagfile = {stderr} ;
 static int pid;
 static int sigivalue   = 0;
 static int sigqvalue   = 0;
 static int pid;
 static int sigivalue   = 0;
 static int sigqvalue   = 0;
-static int sighvalue   = 0;
-static int sigtvalue   = 0;
 
 static char *pass1name = PASS1NAME ;
 static char *pass2name = PASS2NAME ;
 
 static char *pass1name = PASS1NAME ;
 static char *pass2name = PASS2NAME ;
@@ -47,7 +45,6 @@ static char *rflagp   = rflags;
 static char **loadargs;
 static char **loadp;
 
 static char **loadargs;
 static char **loadp;
 
-static flag erred      = NO;
 static flag loadflag   = YES;
 static flag saveasmflag        = NO;
 static flag profileflag        = NO;
 static flag loadflag   = YES;
 static flag saveasmflag        = NO;
 static flag profileflag        = NO;
@@ -73,8 +70,6 @@ int intrupt();
 
 sigivalue = (int) signal(SIGINT, 1) & 01;
 sigqvalue = (int) signal(SIGQUIT,1) & 01;
 
 sigivalue = (int) signal(SIGINT, 1) & 01;
 sigqvalue = (int) signal(SIGQUIT,1) & 01;
-sighvalue = (int) signal(SIGHUP, 1) & 01;
-sigtvalue = (int) signal(SIGTERM,1) & 01;
 enbint(intrupt);
 
 pid = getpid();
 enbint(intrupt);
 
 pid = getpid();
@@ -241,10 +236,7 @@ for(i = 0 ; i<argc ; ++i)
                case 'r':       /* Ratfor file */
                case 'e':       /* EFL file */
                        if( unreadable(argv[i]) )
                case 'r':       /* Ratfor file */
                case 'e':       /* EFL file */
                        if( unreadable(argv[i]) )
-                               {
-                               erred = YES;
                                break;
                                break;
-                               }
                        s = fortfile;
                        t = lastfield(argv[i]);
                        while( *s++ = *t++)
                        s = fortfile;
                        t = lastfield(argv[i]);
                        while( *s++ = *t++)
@@ -256,7 +248,6 @@ for(i = 0 ; i<argc ; ++i)
                                if(sys(sprintf(buff, "%s %s >%s", macroname, infname, prepfname) ))
                                        {
                                        rmf(prepfname);
                                if(sys(sprintf(buff, "%s %s >%s", macroname, infname, prepfname) ))
                                        {
                                        rmf(prepfname);
-                                       erred = YES;
                                        break;
                                        }
                                infname = prepfname;
                                        break;
                                        }
                                infname = prepfname;
@@ -271,7 +262,7 @@ for(i = 0 ; i<argc ; ++i)
                                rmf(infname);
                        if(status)
                                {
                                rmf(infname);
                        if(status)
                                {
-                               erred = YES;
+                               loadflag = NO;
                                rmf(fortfile);
                                break;
                                }
                                rmf(fortfile);
                                break;
                                }
@@ -282,7 +273,7 @@ for(i = 0 ; i<argc ; ++i)
                                *lastchar(infname) = 'f';
        
                                if( dofort(argv[i]) )
                                *lastchar(infname) = 'f';
        
                                if( dofort(argv[i]) )
-                                       erred = YES;
+                                       loadflag = NO;
                                else    {
                                        if( nodup(t = setdoto(argv[i])) )
                                                *loadp++ = t;
                                else    {
                                        if( nodup(t = setdoto(argv[i])) )
                                                *loadp++ = t;
@@ -294,9 +285,9 @@ for(i = 0 ; i<argc ; ++i)
                case 'f':       /* Fortran file */
                case 'F':
                        if( unreadable(argv[i]) )
                case 'f':       /* Fortran file */
                case 'F':
                        if( unreadable(argv[i]) )
-                               erred = YES;
-                       else if( dofort(argv[i]) )
-                               erred = YES;
+                               break;
+                       if( dofort(argv[i]) )
+                               loadflag = NO;
                        else if( nodup(t=setdoto(argv[i])) )
                                *loadp++ = t;
                        break;
                        else if( nodup(t=setdoto(argv[i])) )
                                *loadp++ = t;
                        break;
@@ -304,16 +295,13 @@ for(i = 0 ; i<argc ; ++i)
                case 'c':       /* C file */
                case 's':       /* Assembler file */
                        if( unreadable(argv[i]) )
                case 'c':       /* C file */
                case 's':       /* Assembler file */
                        if( unreadable(argv[i]) )
-                               {
-                               erred = YES;
                                break;
                                break;
-                               }
 #if HERE==PDP11 || HERE==VAX
                        fprintf(diagfile, "%s:\n", argv[i]);
 #endif
                        sprintf(buff, "cc -c %s", argv[i] );
                        if( sys(buff) )
 #if HERE==PDP11 || HERE==VAX
                        fprintf(diagfile, "%s:\n", argv[i]);
 #endif
                        sprintf(buff, "cc -c %s", argv[i] );
                        if( sys(buff) )
-                               erred = YES;
+                               loadflag = NO;
                        else
                                if( nodup(t = setdoto(argv[i])) )
                                        *loadp++ = t;
                        else
                                if( nodup(t = setdoto(argv[i])) )
                                        *loadp++ = t;
@@ -332,9 +320,9 @@ for(i = 0 ; i<argc ; ++i)
                        break;
                }
 
                        break;
                }
 
-if(loadflag && !erred)
+if(loadflag)
        doload(loadargs, loadp);
        doload(loadargs, loadp);
-done(erred);
+done(0);
 }
 \f
 dofort(s)
 }
 \f
 dofort(s)
@@ -610,7 +598,7 @@ return( await(waitpid) );
 
 
 
 
 
 
-#include "errno.h"
+#include <errno.h>
 
 /* modified version from the Shell */
 texec(f, av)
 
 /* modified version from the Shell */
 texec(f, av)
@@ -661,10 +649,6 @@ if(sigivalue == 0)
        signal(SIGINT,k);
 if(sigqvalue == 0)
        signal(SIGQUIT,k);
        signal(SIGINT,k);
 if(sigqvalue == 0)
        signal(SIGQUIT,k);
-if(sighvalue == 0)
-       signal(SIGHUP,k);
-if(sigtvalue == 0)
-       signal(SIGTERM,k);
 }
 
 
 }
 
 
@@ -712,6 +696,7 @@ if(fp = fopen(s, "r"))
 else
        {
        fprintf(diagfile, "Error: Cannot read file %s\n", s);
 else
        {
        fprintf(diagfile, "Error: Cannot read file %s\n", s);
+       loadflag = NO;
        return(YES);
        }
 }
        return(YES);
        }
 }
@@ -754,27 +739,13 @@ rmf(asmpass2);
 content(filename)
 char *filename;
 {
 content(filename)
 char *filename;
 {
-#ifdef VERSION6
-       struct stat
-               {
-               char cjunk[9];
-               char size0;
-               int size1;
-               int ijunk[12];
-               } buf;
-#else
-#      include <sys/types.h>
-#      include <sys/stat.h>
-       struct stat buf;
-#endif
-
+#include <sys/types.h>
+#include <sys/stat.h>
+struct stat buf;
 if(stat(filename,&buf) < 0) 
        return(-1);
 if(stat(filename,&buf) < 0) 
        return(-1);
-#ifdef VERSION6
-       return(buf.size0 || buf.size1);
-#else
+else
        return( buf.st_size > 0 );
        return( buf.st_size > 0 );
-#endif
 }
 
 
 }
 
 
index 1351ad6..dc7cfd6 100644 (file)
@@ -64,8 +64,7 @@ else if(ctlstack->ctltype == CTLELSE)
        popctl();
        }
 
        popctl();
        }
 
-else
-       execerr("endif out of place", 0);
+else   execerr("endif out of place", 0);
 }
 
 
 }
 
 
@@ -89,6 +88,7 @@ LOCAL popctl()
 if( ctlstack-- < ctls )
        fatal("control stack empty");
 --blklevel;
 if( ctlstack-- < ctls )
        fatal("control stack empty");
 --blklevel;
+poplab();
 }
 
 
 }
 
 
@@ -453,7 +453,6 @@ while(here == dorange)
                }
 
        popctl();
                }
 
        popctl();
-       poplab();
        dorange = 0;
        for(q = ctlstack ; q>=ctls ; --q)
                if(q->ctltype == CTLDO)
        dorange = 0;
        for(q = ctlstack ; q>=ctls ; --q)
                if(q->ctltype == CTLDO)
@@ -524,8 +523,6 @@ putgoto(l1);
 exreturn(p)
 register expptr p;
 {
 exreturn(p)
 register expptr p;
 {
-if(procclass != CLPROC)
-       warn("RETURN statement in main or block data");
 if(p && (proctype!=TYSUBR || procclass!=CLPROC) )
        {
        err("alternate return in nonsubroutine");
 if(p && (proctype!=TYSUBR || procclass!=CLPROC) )
        {
        err("alternate return in nonsubroutine");
@@ -538,7 +535,7 @@ if(p)
        putgoto(retlabel);
        }
 else
        putgoto(retlabel);
        }
 else
-       putgoto(proctype==TYSUBR ? ret0label : retlabel);
+       putgoto(procclass==TYSUBR ? ret0label : retlabel);
 }
 
 
 }
 
 
index 5989952..992c87a 100644 (file)
@@ -150,47 +150,23 @@ register int t;
 register expptr p;
 {
 register expptr q;
 register expptr p;
 {
 register expptr q;
-register int pt;
-expptr opconv();
 
 if(t==TYUNKNOWN || t==TYERROR)
        fatal1("mkconv of impossible type %d", t);
 
 if(t==TYUNKNOWN || t==TYERROR)
        fatal1("mkconv of impossible type %d", t);
-pt = p->vtype;
-if(t == pt)
+if(t == p->vtype)
        return(p);
 
        return(p);
 
-else if( ISCONST(p) && pt!=TYADDR)
+else if( ISCONST(p) && p->vtype!=TYADDR)
        {
        q = mkconst(t);
        consconv(t, &(q->const), p->vtype, &(p->const));
        frexpr(p);
        }
        {
        q = mkconst(t);
        consconv(t, &(q->const), p->vtype, &(p->const));
        frexpr(p);
        }
-#if TARGET == PDP11
-       else if(ISINT(t) && pt==TYCHAR)
-               {
-               q = mkexpr(OPBITAND, opconv(p,TYSHORT), ICON(255));
-               if(t == TYLONG)
-                       q = opconv(q, TYLONG);
-               }
-#endif
 else
 else
-       q = opconv(p, t);
-
-if(t == TYCHAR)
-       q->vleng = ICON(1);
-return(q);
-}
-
-
-
-expptr opconv(p, t)
-expptr p;
-int t;
-{
-register expptr q;
-
-q = mkexpr(OPCONV, p, 0);
-q->vtype = t;
+       {
+       q = mkexpr(OPCONV, p, 0);
+       q->vtype = t;
+       }
 return(q);
 }
 
 return(q);
 }
 
@@ -212,15 +188,10 @@ int tag;
 register chainp ep, pp;
 ptr cpblock();
 
 register chainp ep, pp;
 ptr cpblock();
 
-static int blksize[ ] =
-       {       0,
-               sizeof(struct nameblock),
-               sizeof(struct constblock),
-               sizeof(struct exprblock),
-               sizeof(struct addrblock),
-               sizeof(struct primblock),
-               sizeof(struct listblock),
-               sizeof(struct errorblock)
+static int blksize[ ] = { 0, sizeof(struct nameblock), sizeof(struct constblock),
+                sizeof(struct exprblock), sizeof(struct addrblock),
+                sizeof(struct primblock), sizeof(struct listblock),
+                sizeof(struct errorblock)
        };
 
 if(p == NULL)
        };
 
 if(p == NULL)
@@ -862,6 +833,7 @@ int regn;
 
 if(p->tag != TPRIM)
        return(p);
 
 if(p->tag != TPRIM)
        return(p);
+
 np = p->namep;
 
 /* is name on the replace list? */
 np = p->namep;
 
 /* is name on the replace list? */
@@ -1143,10 +1115,7 @@ switch( p->vstg)
        case STGAUTO:
                t = ALLOC(addrblock);
                t->tag = TADDR;
        case STGAUTO:
                t = ALLOC(addrblock);
                t->tag = TADDR;
-               if(p->vclass==CLPROC && p->vprocclass==PTHISPROC)
-                       t->vclass = CLVAR;
-               else
-                       t->vclass = p->vclass;
+               t->vclass = p->vclass;
                t->vtype = p->vtype;
                t->vstg = p->vstg;
                t->memno = p->vardesc.varno;
                t->vtype = p->vtype;
                t->vstg = p->vstg;
                t->memno = p->vardesc.varno;
@@ -1614,8 +1583,6 @@ switch(op)
        case OPCONV:
                if(rt == 0)
                        return(0);
        case OPCONV:
                if(rt == 0)
                        return(0);
-               if(lt==TYCHAR && ISINT(rt) )
-                       return(TYCHAR);
        case OPASSIGN:
        case OPPLUSEQ:
        case OPSTAREQ:
        case OPASSIGN:
        case OPPLUSEQ:
        case OPSTAREQ:
@@ -1656,11 +1623,7 @@ LOCAL expptr fold(e)
 register struct exprblock *e;
 {
 struct constblock *p;
 register struct exprblock *e;
 {
 struct constblock *p;
-#ifdef VERSION6
-       expptr lp, rp;
-#else
-       register expptr lp, rp;
-#endif
+register expptr lp, rp;
 int etype, mtype, ltype, rtype, opcode;
 int i, ll, lr;
 char *q, *s;
 int etype, mtype, ltype, rtype, opcode;
 int i, ll, lr;
 char *q, *s;
@@ -1798,15 +1761,9 @@ register union constant *lv, *rv;
 {
 switch(lt)
        {
 {
 switch(lt)
        {
-       case TYCHAR:
-               *(lv->ccp = ckalloc(1)) = rv->ci;
-               break;
-
        case TYSHORT:
        case TYLONG:
        case TYSHORT:
        case TYLONG:
-               if(rt == TYCHAR)
-                       lv->ci = rv->ccp[0];
-               else if( ISINT(rt) )
+               if( ISINT(rt) )
                        lv->ci = rv->ci;
                else    lv->ci = rv->cd[0];
                break;
                        lv->ci = rv->ci;
                else    lv->ci = rv->cd[0];
                break;
@@ -2151,7 +2108,7 @@ if(ISICON(rp))
        }
 if( ISINT(rtype) )
        {
        }
 if( ISINT(rtype) )
        {
-       if(ltype==TYSHORT && rtype==TYSHORT && (!ISCONST(lp) || tyint==TYSHORT) )
+       if(ltype==TYSHORT && rtype==TYSHORT)
                q = call2(TYSHORT, "pow_hh", lp, rp);
        else    {
                if(ltype == TYSHORT)
                q = call2(TYSHORT, "pow_hh", lp, rp);
        else    {
                if(ltype == TYSHORT)
index 4a911fb..7fd6b19 100644 (file)
@@ -255,7 +255,7 @@ ubound:       SSTAR
 labellist: label
                { nstars = 1; labarray[0] = $1; }
        | labellist SCOMMA label
 labellist: label
                { nstars = 1; labarray[0] = $1; }
        | labellist SCOMMA label
-               { if(nstars < MAXLABLIST)  labarray[nstars++] = $3; }
+               { labarray[nstars++] = $3; }
        ;
 
 label:   labelval
        ;
 
 label:   labelval
index c1199c0..b2d33ef 100644 (file)
@@ -40,11 +40,7 @@ iffable:  let lhs SEQUALS expr
        | call SLPAR SRPAR
                { excall($1, 0, 0, labarray); }
        | call SLPAR callarglist SRPAR
        | call SLPAR SRPAR
                { excall($1, 0, 0, labarray); }
        | call SLPAR callarglist SRPAR
-               { if(nstars < MAXLABLIST)
-                       excall($1, mklist($3), nstars, labarray);
-                 else
-                       err("too many alternate returns");
-               }
+               { excall($1, mklist($3), nstars, labarray); }
        | SRETURN end_spec opt_expr
                { exreturn($3);  thiswasbranch = YES; }
        | stop end_spec opt_expr
        | SRETURN end_spec opt_expr
                { exreturn($3);  thiswasbranch = YES; }
        | stop end_spec opt_expr
@@ -67,11 +63,7 @@ goto:          SGOTO end_spec label
        | SASGOTO end_spec name opt_comma SLPAR labellist SRPAR
                { exasgoto($3);  thiswasbranch = YES; }
        | SCOMPGOTO end_spec SLPAR labellist SRPAR opt_comma expr
        | SASGOTO end_spec name opt_comma SLPAR labellist SRPAR
                { exasgoto($3);  thiswasbranch = YES; }
        | SCOMPGOTO end_spec SLPAR labellist SRPAR opt_comma expr
-               { if(nstars < MAXLABLIST)
-                       putcmgo(fixtype($7), nstars, labarray);
-                 else
-                       err("computed GOTO list too long");
-               }
+               { putcmgo(fixtype($7), nstars, labarray); }
        ;
 
 opt_comma:
        ;
 
 opt_comma:
@@ -93,7 +85,7 @@ callarglist:  callarg
 
 callarg:  expr
        | SSTAR label
 
 callarg:  expr
        | SSTAR label
-               { if(nstars<MAXLABLIST) labarray[nstars++] = $2; $$ = 0; }
+               { labarray[nstars++] = $2; $$ = 0; }
        ;
 
 stop:    SPAUSE
        ;
 
 stop:    SPAUSE
index a8a834f..2455cbf 100644 (file)
@@ -6,11 +6,9 @@ static int ndim;
 static int vartype;
 static ftnint varleng;
 static struct { ptr lb, ub; } dims[8];
 static int vartype;
 static ftnint varleng;
 static struct { ptr lb, ub; } dims[8];
-static struct labelblock *labarray[MAXLABLIST];
+static struct labelblock *labarray[100];
 static int lastwasbranch = NO;
 static int thiswasbranch = NO;
 static int lastwasbranch = NO;
 static int thiswasbranch = NO;
-extern ftnint yystno;
-
 ftnint convci();
 double convcd();
 struct addrblock *nextdata(), *mkbitcon();
 ftnint convci();
 double convcd();
 struct addrblock *nextdata(), *mkbitcon();
@@ -68,11 +66,11 @@ stat:         thislabel entry
 
 thislabel:  SLABEL
                {
 
 thislabel:  SLABEL
                {
-               if(yystno != 0)
+               if($1)
                        {
                        {
-                       $$ = thislabel =  mklabel(yystno);
+                       $$ = thislabel =  mklabel( (ftnint) $1);
                        if( ! headerdone )
                        if( ! headerdone )
-                               puthead(NULL, procclass);
+                               puthead();
                        if(thislabel->labdefined)
                                execerr("label %s already defined",
                                        convic(thislabel->stateno) );
                        if(thislabel->labdefined)
                                execerr("label %s already defined",
                                        convic(thislabel->stateno) );
index 0d7db8d..9a148f3 100644 (file)
@@ -9,7 +9,7 @@ FILEP asmfile;
 FILEP initfile;
 long int headoffset;
 
 FILEP initfile;
 long int headoffset;
 
-char token[200];
+char token[100];
 int toklen;
 int lineno;
 char *infname;
 int toklen;
 int lineno;
 char *infname;
diff --git a/usr/src/cmd/f77/letters b/usr/src/cmd/f77/letters
new file mode 100644 (file)
index 0000000..b0883f3
--- /dev/null
@@ -0,0 +1 @@
+abcdefghijklmnopqrstuvwxyz
index 85bb1e9..38bb206 100644 (file)
@@ -20,8 +20,7 @@
 
 
 LOCAL int stkey;
 
 
 LOCAL int stkey;
-ftnint yystno;
-LOCAL long int stno;
+LOCAL int stno;
 LOCAL long int nxtstno;
 LOCAL int parlev;
 LOCAL int expcom;
 LOCAL long int nxtstno;
 LOCAL int parlev;
 LOCAL int expcom;
@@ -185,7 +184,7 @@ case NEWSTMT :      /* need a new statement */
        crunch();
        tokno = 0;
        lexstate = FIRSTTOKEN;
        crunch();
        tokno = 0;
        lexstate = FIRSTTOKEN;
-       yystno = stno;
+       yylval = stno;
        stno = nxtstno;
        toklen = 0;
        return(SLABEL);
        stno = nxtstno;
        toklen = 0;
        return(SLABEL);
@@ -322,7 +321,7 @@ top:
                }
        else    {       /* read body of line */
                while( endcd<bend && (c=getc(infile)) != '\n' && c!=EOF )
                }
        else    {       /* read body of line */
                while( endcd<bend && (c=getc(infile)) != '\n' && c!=EOF )
-                       *endcd++ = c;
+                       *endcd++ = (c == '\t' ? BLANK : c);
                if(c == EOF)
                        return(STEOF);
                if(c != '\n')
                if(c == EOF)
                        return(STEOF);
                if(c != '\n')
@@ -337,18 +336,18 @@ top:
                                *endcd++ = BLANK;
                }
        ++thislin;
                                *endcd++ = BLANK;
                }
        ++thislin;
-       if( !isspace(a[5]) && a[5]!='0')
+       if(a[5]!=BLANK && a[5]!='0')
                return(STCONTINUE);
        for(p=a; p<aend; ++p)
                return(STCONTINUE);
        for(p=a; p<aend; ++p)
-               if( !isspace(*p) ) goto initline;
+               if(*p != BLANK) goto initline;
        for(p = b ; p<endcd ; ++p)
        for(p = b ; p<endcd ; ++p)
-               if( !isspace(*p) ) goto initline;
+               if(*p != BLANK) goto initline;
        goto top;
 
 initline:
        nxtstno = 0;
        for(p = a ; p<a+5 ; ++p)
        goto top;
 
 initline:
        nxtstno = 0;
        for(p = a ; p<a+5 ; ++p)
-               if( !isspace(*p) )
+               if(*p != BLANK)
                        if(isdigit(*p))
                                nxtstno = 10*nxtstno + (*p - '0');
                        else    {
                        if(isdigit(*p))
                                nxtstno = 10*nxtstno + (*p - '0');
                        else    {
@@ -374,8 +373,7 @@ j = s;
 prvstr = s;
 for(i=s ; i<=lastch ; ++i)
        {
 prvstr = s;
 for(i=s ; i<=lastch ; ++i)
        {
-       if(isspace(*i) )
-               continue;
+       if(*i == BLANK) continue;
        if(*i=='\'' ||  *i=='"')
                {
                quote = *i;
        if(*i=='\'' ||  *i=='"')
                {
                quote = *i;
@@ -471,7 +469,7 @@ for(i=s ; i<=lastch ; ++i)
                else if(parlev == 0)
                        if(*i == '=') expeql = 1;
                        else if(*i == ',') expcom = 1;
                else if(parlev == 0)
                        if(*i == '=') expeql = 1;
                        else if(*i == ',') expcom = 1;
-copychar:              /*not a string or space -- copy, shifting case if necessary */
+copychar:              /*not a string of BLANK -- copy, shifting case if necessary */
                if(shiftcase && isupper(*i))
                        *j++ = tolower(*i);
                else    *j++ = *i;
                if(shiftcase && isupper(*i))
                        *j++ = tolower(*i);
                else    *j++ = *i;
@@ -558,7 +556,7 @@ if(pk = keystart[k])
                j = nextch;
                while(*++i==*++j && *i!='\0')
                        ;
                j = nextch;
                while(*++i==*++j && *i!='\0')
                        ;
-               if(*i=='\0' && j<=lastch+1)
+               if(*i == '\0')
                        {
                        nextch = j;
                        return(pk->keyval);
                        {
                        nextch = j;
                        return(pk->keyval);
index b315a5d..8d2a746 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef TARGET
 TARGET NOT DEFINED !!!
 #endif
 #ifndef TARGET
 TARGET NOT DEFINED !!!
 #endif
-#if TARGET!=PDP11
+#if TARGET!=VAX
 Target= TARGET OUT OF RANGE!!
 #endif
 
 Target= TARGET OUT OF RANGE!!
 #endif
 
@@ -14,40 +14,41 @@ Family = FAMILY OUT OF RANGE
 
 #define TYLENG TYLONG
 
 
 #define TYLENG TYLONG
 
-#define TYINT  TYSHORT
-#define SZADDR 2
+#define TYINT  TYLONG
+#define SZADDR 4
 #define SZSHORT        2
 #define SZSHORT        2
-#define SZINT  2
+#define SZINT  4
 
 #define SZLONG 4
 #define SZLENG SZLONG
 
 #define ALIADDR SZADDR
 #define ALISHORT SZSHORT
 
 #define SZLONG 4
 #define SZLENG SZLONG
 
 #define ALIADDR SZADDR
 #define ALISHORT SZSHORT
-#define ALILONG 2
-#define ALIDOUBLE 2
+#define ALILONG 4
+#define ALIDOUBLE 4
 #define ALIINT ALILONG
 #define ALILENG        ALILONG
 
 #define ALIINT ALILONG
 #define ALILENG        ALILONG
 
+#define AUTOREG 13
+#define ARGREG 12
+#define CARGREG 12
+#define ARGOFFSET 4
+#define SAVESPACE 40
 
 
-#define AUTOREG 5
-#define ARGREG 4
-#define SAVESPACE 6
 
 #define FUDGEOFFSET 1
 #define BITSPERCHAR 8
 #define XL 8
 
 
 #define FUDGEOFFSET 1
 #define BITSPERCHAR 8
 #define XL 8
 
-#define USETEXT        "\t.text"
-#define USECONST       "\t.data"
-#define USEBSS "\t.bss"
-#define USEINIT        "\t.data"
+#define USETEXT        ".text"
+#define USECONST       ".data\t0"
+#define USEBSS ".data\t1"
+#define USEINIT        ".data\t2"
 
 #define BLANKCOMMON "_BLNK_"
 
 #define LABELFMT "%s:\n"
 
 #define BLANKCOMMON "_BLNK_"
 
 #define LABELFMT "%s:\n"
-#define MAXSHORT 32767
 
 
-#define MAXREGVAR 2
-#define TYIREG TYSHORT
-#define MSKIREG  M(TYSHORT)
+#define MAXREGVAR 4
+#define TYIREG TYLONG
+#define MSKIREG  (M(TYSHORT)|M(TYLONG))
index 90064a7..d475cad 100644 (file)
@@ -1,4 +1,4 @@
-char *xxxvers[] = "\nFORTRAN 77 PASS 1, VERSION 1.21,  20 APRIL 1979\n";
+char *xxxvers[] = "\nFORTRAN 77 PASS 1, VERSION 1.16,  3 NOVEMBER 1978\n";
 
 #include "defs"
 
 
 #include "defs"
 
diff --git a/usr/src/cmd/f77/makefile b/usr/src/cmd/f77/makefile
deleted file mode 100644 (file)
index 86a9af1..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#      Makefile for the Fortran 77 compiler
-#      running on the PDP11,
-#      generating code for the PDP11,
-#      using the Ritchie pass 2
-
-all:   f77 f77pass1
-
-cp:    all
-       cp f77 /bin
-       cp f77pass1 /lib
-       rm *.o gram.c f77 f77pass1
-
-cmp:   all
-       cmp f77 /bin/f77
-       cmp f77pass1 /lib/f77pass1
-       rm *.o gram.c f77 f77pass1
-
-CFL = -DTARGET=PDP11 -DFAMILY=DMR -DHERE=PDP11 -DOUTPUT=BINARY -DPOLISH=POSTFIX
-CFLAGS = -O -s $(CFL)
-LDFLAGS = -i -s
-
-OBJECTS = main.o init.o gram.o lex.o proc.o \
-         equiv.o data.o expr.o exec.o intr.o io.o misc.o error.o\
-         put.o putdmr.o pdp11.o pdp11x.o
-
-compiler :: f77 f77pass1
-       touch compiler
-
-compiler :: /lib/c1
-       @echo "***Warning: /lib/c1 has changed"
-
-f77 : driver.o pdp11x.o
-       cc -n -s driver.o pdp11x.o -o f77
-       @size f77
-f77pass1 : $(OBJECTS)
-       @echo LOAD
-       @$(CC) $(LDFLAGS)  $(OBJECTS) -o f77pass1
-       @size f77pass1
-
-gram.c:        gram.head gram.dcl gram.expr gram.exec gram.io tokdefs
-       ( sed <tokdefs "s/#define/%token/" ;\
-               cat gram.head gram.dcl gram.expr gram.exec gram.io ) >gram.in
-       $(YACC) $(YFLAGS) gram.in
-       mv y.tab.c gram.c
-       rm gram.in
-
-tokdefs: tokens
-       grep -n . <tokens | sed "s/\([^:]*\):\(.*\)/#define \2 \1/" >tokdefs
-
-lex.o : tokdefs
-driver.o $(OBJECTS)  : defs defines locdefs ftypes
-driver.o : drivedefs
-
-locdefs : pdp11defs
-       cp pdp11defs locdefs
-
-put.o putdmr.o pdp11.o : dmrdefs
-io.o : fio.h
-
-lint:
-       @echo "LINT DRIVER" >Lintout
-       @lint -p $(CFL) driver.c pdp11x.c >>Lintout
-       echo "LINT PASS1" >>Lintout
-       @nohup lint -p $(CFL) error.c exec.c intr.c expr.c gram.c init.c io.c\
-               lex.c main.c proc.c misc.c put.c putdmr.c pdp11.c pdp11x.c\
-               equiv.c data.c >>Lintout&
-
-cleanup:
-       -rm f gram.c *.o
-       du
-
-install: /usr/bin/f77 /usr/lib/f77pass1
-
-/usr/bin/f77 : f77
-       strip f77
-       @size f77 /usr/bin/f77
-       cp f77 /usr/bin/f77
-
-/usr/lib/f77pass1 : f77pass1
-       strip f77pass1
-       @size f77pass1 /usr/lib/f77pass1
-       -chmod u-t /usr/lib/f77pass1
-       @/usr/lib/f77pass1 2>/dev/null
-       cp f77pass1 /usr/lib/f77pass1
-       echo "***Now do a    chmod u+t /usr/lib/f77pass1    in su mode"
diff --git a/usr/src/cmd/f77/malloc.c b/usr/src/cmd/f77/malloc.c
deleted file mode 100644 (file)
index f2a4094..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-#define ASSERT(p) if(!(p))botch("p");else
-botch(s)
-char *s;
-{
-       printf("assertion botched: %s\n",s);
-       abort();
-}
-/*     C storage allocator
- *     circular first-fit strategy
- *     works with noncontiguous, but monotonically linked, arena
- *     each block is preceded by a ptr to the (pointer of) 
- *     the next following block
- *     blocks are exact number of words long; BUSY
- *     bit in ptr is 1 for busy, 0 for idle
- *     gaps in arena are merely noted as busy blocks
- *     last block of arena (pointed to by alloct) is empty and
- *     has a pointer to first
- *     idle blocks are coalesced during space search
-*/
-/*     all these defines must be powers of 2 */
-#define WORD sizeof(struct store)
-#define BLOCK 1024
-#define BUSY 1
-#define NULL 0
-#define testbusy(p) ((int)(p)&BUSY)
-#define setbusy(p) ((int)(p)+BUSY)
-#define clearbusy(p) ((int)(p)&~BUSY)
-
-struct store { struct store *ptr; };
-
-struct store allocs[] = {      /*initial arena*/
-       setbusy(&allocs[1].ptr),
-       setbusy(&allocs[0].ptr)
-};
-struct store *allocp = &allocs[1];     /*search ptr*/
-struct store *alloct = &allocs[1];     /*arena top*/
-struct store *allocx;          /*for benefit of realloc*/
-struct store *sbrk();
-
-struct store *
-malloc(nbytes)
-unsigned nbytes;
-{
-       register struct store *p, *q;
-       register nw;
-       static temp;    /*coroutines assume no auto*/
-
-       nw = (nbytes+2*WORD-1)/WORD;
-       ASSERT(allocp>allocs && allocp<=alloct);
-       for(p=allocp; ; ) {
-               for(temp=0; ; ) {
-                       if(!testbusy(p->ptr)) {
-                               while(!testbusy((q=p->ptr)->ptr)) {
-                                       ASSERT(q>p&&q<alloct);
-                                       p->ptr = q->ptr;
-                               }
-                               if(q>=p+nw && p+nw>=p)
-                                       goto found;
-                       }
-                       q = p;
-                       p = clearbusy(p->ptr);
-                       if(p>q)
-                               ASSERT(p<=alloct);
-                       else if(q!=alloct || p!=allocs) {
-                               write(2,"corrupt arena\n",14);
-                               exit(0175);
-                       } else if(++temp>1)
-                               break;
-               }
-               temp = (nw+BLOCK/WORD)&~(BLOCK/WORD-1);
-               q = sbrk(0);
-               if(q+temp < q)
-                       return(NULL);
-               q = sbrk(temp*WORD);
-               if((int)q == -1)
-                       return(NULL);
-               ASSERT(q>alloct);
-               alloct->ptr = q;
-               if(q!=alloct+1)
-                       alloct->ptr = setbusy(alloct->ptr);
-               alloct = q->ptr = q+temp-1;
-               alloct->ptr = setbusy(allocs);
-       }
-found:
-       allocp = p + nw;
-       ASSERT(allocp<=alloct);
-       if(q>allocp) {
-               allocx = allocp->ptr;
-               allocp->ptr = p->ptr;
-       }
-       p->ptr = setbusy(allocp);
-       return(p+1);
-}
-/*     freeing strategy tuned for LIFO allocation
-*/
-free(p)
-register struct store *p;
-{
-       ASSERT(p>clearbusy(allocs[1].ptr)&&p<=alloct);
-       allocp = --p;
-       ASSERT(testbusy(p->ptr));
-       p->ptr = clearbusy(p->ptr);
-       ASSERT(p->ptr > allocp && p->ptr <= alloct);
-}
-\f
-struct { unsigned tag:4, vtype:4;};
-
-prbusy()
-{
-       register struct store *p, *q;
-
-       ASSERT(allocp>allocs && allocp<=alloct);
-       for(p=allocs; ; ) {
-                       if(testbusy(p->ptr))
-                               {
-                               printf("busy 0%o, tag %d, type %d, length %d\n",
-                                       p, p[1].tag, p[1].vtype,
-                                       clearbusy(p->ptr) - (int) p - 2 );
-                               }
-                       q = p;
-                       p = clearbusy(p->ptr);
-                       if(p>q)
-                               ASSERT(p<=alloct);
-                       else if(q!=alloct || p!=allocs)
-                               {
-                               write(2,"corrupt arena\n",14);
-                               exit(0175);
-                               }
-                       else return;
-       }
-}
diff --git a/usr/src/cmd/f77/nnnn b/usr/src/cmd/f77/nnnn
new file mode 100644 (file)
index 0000000..fb207b6
--- /dev/null
@@ -0,0 +1,6 @@
+OBJECTS = main.o init.o proc.o gram.o lex.o \
+         equiv.o data.o expr.o exec.o intr.o io.o misc.o error.o\
+         put.o putscjb.o vax.o vaxx.o
+
+f77pass1: $(OBJECTS)
+       cc $(OBJECTS) libS.a -o f77pass1
diff --git a/usr/src/cmd/f77/pdp11.c b/usr/src/cmd/f77/pdp11.c
deleted file mode 100644 (file)
index 8936b92..0000000
+++ /dev/null
@@ -1,465 +0,0 @@
-#include "defs"
-#if FAMILY == DMR
-#      include "dmrdefs"
-#endif
-#if FAMILY==SCJ && OUTPUT==BINARY
-#      include "scjdefs"
-#endif
-
-/*
-      PDP 11-SPECIFIC PRINTING ROUTINES
-*/
-
-int maxregvar = 0;
-static char textline[50];
-int regnum[] = { 3, 2 };
-
-
-prsave()
-{
-}
-
-
-
-goret(type)
-int type;
-{
-#if  FAMILY == DMR
-       p2op(P2RETURN);
-#endif
-#if FAMILY==SCJ
-       p2pass(sprintf(textline, "\tjmp\tcret"));
-#endif
-}
-
-
-
-
-/*
- * move argument slot arg1 (relative to ap)
- * to slot arg2 (relative to ARGREG)
- */
-
-mvarg(type, arg1, arg2)
-int type, arg1, arg2;
-{
-mvarg1(arg1+4, arg2);
-if(type == TYLONG)
-       mvarg1(arg1+6, arg2+2);
-}
-
-
-
-
-mvarg1(m, n)
-int m, n;
-{
-#if FAMILY == DMR
-       p2reg(ARGREG, P2SHORT|P2PTR);
-       p2op2(P2ICON, P2SHORT);
-       p2i(n);
-       p2op2(P2PLUS, P2SHORT|P2PTR);
-       p2op2(P2INDIRECT, P2SHORT);
-       p2reg(AUTOREG, P2SHORT|P2PTR);
-       p2op2(P2ICON, P2SHORT);
-       p2i(m);
-       p2op2(P2PLUS, P2SHORT|P2PTR);
-       p2op2(P2INDIRECT, P2SHORT);
-       p2op2(P2ASSIGN, P2SHORT);
-       putstmt();
-#endif
-#if FAMILY == SCJ
-       p2pass(sprintf(textline, "\tmov\t%d.(r5),%d.(r4)", m, n));
-#endif
-}
-
-
-
-
-prlabel(fp, k)
-FILEP fp;
-int k;
-{
-fprintf(fp, "L%d:\n", k);
-}
-
-
-
-prconi(fp, type, n)
-FILEP fp;
-int type;
-ftnint n;
-{
-register int *np;
-np = &n;
-if(type == TYLONG)
-       fprintf(fp, "\t%d.;%d.\n", np[0], np[1]);
-else
-       fprintf(fp, "\t%d.\n", np[1]);
-}
-
-
-
-prcona(fp, a)
-FILEP fp;
-ftnint a;
-{
-fprintf(fp, "L%ld\n", a);
-}
-
-
-
-#if HERE!=PDP11
-BAD NEWS
-#endif
-
-#if HERE==PDP11
-prconr(fp, type, x)
-FILEP fp;
-int type;
-double x;
-{
-register int k, *n;
-n = &x;        /* nonportable cheat */
-k = (type==TYREAL ? 2 : 4);
-fprintf(fp, "\t");
-while(--k >= 0)
-       fprintf(fp, "%d.%c", *n++, (k==0 ? '\n' : ';') );
-}
-#endif
-
-
-
-
-preven(k)
-int k;
-{
-if(k > 1)
-       fprintf(asmfile, "\t.even\n", k);
-}
-
-
-
-#if FAMILY == SCJ
-
-prcmgoto(p, nlab, skiplabel, labarray)
-expptr p;
-int nlab, skiplabel, labarray;
-{
-int regno;
-
-putforce(p->vtype, p);
-
-if(p->vtype == TYLONG)
-       {
-       regno = 1;
-       p2pass(sprintf(textline, "\ttst\tr0"));
-       p2pass(sprintf(textline, "\tbne\tL%d", skiplabel));
-       }
-else
-       regno = 0;
-
-p2pass(sprintf(textline, "\tcmp\tr%d,$%d.", regno, nlab));
-p2pass(sprintf(textline, "\tbhi\tL%d", skiplabel));
-p2pass(sprintf(textline, "\tasl\tr%d", regno));
-p2pass(sprintf(textline, "\tjmp\t*L%d(r%d)", labarray, regno));
-}
-
-
-prarif(p, neg,zer,pos)
-expptr p;
-int neg, zer, pos;
-{
-register int ptype;
-
-putforce( ptype = p->vtype, p);
-if( ISINT(ptype) )
-       {
-       p2pass(sprintf(textline, "\ttst\tr0"));
-       p2pass(sprintf(textline, "\tjlt\tL%d", neg));
-       p2pass(sprintf(textline, "\tjgt\tL%d", pos));
-       if(ptype != TYSHORT)
-               {
-               p2pass(sprintf(textline, "\ttst\tr1"));
-               p2pass(sprintf(textline, "\tjeq\tL%d", zer));
-               }
-       p2pass(sprintf(textline, "\tjbr\tL%d", pos));
-       }
-else
-       {
-       p2pass(sprintf(textline, "\ttstf\tr0"));
-       p2pass(sprintf(textline, "\tcfcc"));
-       p2pass(sprintf(textline, "\tjeq\tL%d", zer));
-       p2pass(sprintf(textline, "\tjlt\tL%d", neg));
-       p2pass(sprintf(textline, "\tjmp\tL%d", pos));
-       }
-}
-
-#endif
-
-
-
-
-char *memname(stg, mem)
-int stg, mem;
-{
-static char s[20];
-
-switch(stg)
-       {
-       case STGCOMMON:
-       case STGEXT:
-               sprintf(s, "_%s", varstr(XL, extsymtab[mem].extname) );
-               break;
-
-       case STGBSS:
-       case STGINIT:
-               sprintf(s, "v.%d", mem);
-               break;
-
-       case STGCONST:
-               sprintf(s, "L%d", mem);
-               break;
-
-       case STGEQUIV:
-               sprintf(s, "q.%d", mem);
-               break;
-
-       default:
-               fatal1("memname: invalid vstg %d", stg);
-       }
-return(s);
-}
-
-
-prlocvar(s, len)
-char *s;
-ftnint len;
-{
-fprintf(asmfile, "%s:", s);
-prskip(asmfile, len);
-}
-
-
-
-prext(name, leng, init)
-char *name;
-ftnint leng;
-int init;
-{
-if(leng==0 || init)
-       fprintf(asmfile, "\t.globl\t_%s\n", name);
-else
-       fprintf(asmfile, "\t.comm\t_%s,%ld.\n", name, leng);
-}
-
-
-
-prendproc()
-{
-}
-
-
-
-prtail()
-{
-#if FAMILY == SCJ
-       p2pass(sprintf(textline, "\t.globl\tcsv,cret"));
-#else
-       p2op(P2EOF);
-#endif
-}
-
-
-
-prolog(ep, argvec)
-struct entrypoint *ep;
-struct addrblock *argvec;
-{
-int i, argslot, proflab;
-register chainp p;
-register struct nameblock *q;
-register struct dimblock *dp;
-struct constblock *mkaddcon();
-
-if(procclass == CLMAIN)
-       prentry("MAIN__");
-
-if(ep->entryname)
-       prentry( varstr(XL, ep->entryname->extname) );
-
-if(procclass == CLBLOCK)
-       return;
-if(profileflag)
-       proflab = newlabel();
-#if FAMILY == SCJ
-       if(profileflag)
-               {
-               fprintf(asmfile, "L%d:\t. = .+2\n", proflab);
-               p2pass(sprintf(textline, "\tmov\t$L%d,r0", proflab));
-               p2pass(sprintf(textline, "\tjsr\tpc,mcount"));
-               }
-       p2pass(sprintf(textline, "\tjsr\tr5,csv"));
-       p2pass(sprintf(textline, "\tsub\t$.F%d,sp", procno));
-#else
-       if(profileflag)
-               p2op2(P2PROFILE, proflab);
-       p2op(P2SAVE);
-       p2op2(P2SETSTK, ( (((int) autoleng)+1) & ~01) );
-#endif
-
-if(argvec == NULL)
-       addreg(argloc = 4);
-else
-       {
-       addreg( argloc = argvec->memoffset->const.ci );
-       if(proctype == TYCHAR)
-               {
-               mvarg(TYADDR, 0, chslot);
-               mvarg(TYLENG, SZADDR, chlgslot);
-               argslot = SZADDR + SZLENG;
-               }
-       else if( ISCOMPLEX(proctype) )
-               {
-               mvarg(TYADDR, 0, cxslot);
-               argslot = SZADDR;
-               }
-       else
-               argslot = 0;
-
-       for(p = ep->arglist ; p ; p =p->nextp)
-               {
-               q = p->datap;
-               mvarg(TYADDR, argslot, q->vardesc.varno);
-               argslot += SZADDR;
-               }
-       for(p = ep->arglist ; p ; p = p->nextp)
-               {
-               q = p->datap;
-               if(q->vtype==TYCHAR || q->vclass==CLPROC)
-                       {
-                       if( q->vleng && ! ISCONST(q->vleng) )
-                               mvarg(TYLENG, argslot, q->vleng->memno);
-                       argslot += SZLENG;
-                       }
-               }
-       }
-
-for(p = ep->arglist ; p ; p = p->nextp)
-       if(dp = ( (struct nameblock *) (p->datap) ) ->vdim)
-               {
-               for(i = 0 ; i < dp->ndim ; ++i)
-                       if(dp->dims[i].dimexpr)
-                               puteq( fixtype(cpexpr(dp->dims[i].dimsize)),
-                                       fixtype(cpexpr(dp->dims[i].dimexpr)));
-               if(dp->basexpr)
-                       puteq(  cpexpr(fixtype(dp->baseoffset)),
-                               cpexpr(fixtype(dp->basexpr)));
-               }
-
-if(typeaddr)
-       puteq( cpexpr(typeaddr), mkaddcon(ep->typelabel) );
-putgoto(ep->entrylabel);
-}
-
-
-
-prentry(s)
-char *s;
-{
-#if FAMILY == SCJ
-       p2pass(sprintf(textline, "_%s:", s));
-#else
-       p2op(P2RLABEL);
-       putc('_', textfile);
-       p2str(s);
-#endif
-}
-
-
-
-
-addreg(k)
-int k;
-{
-#if FAMILY == SCJ
-       p2pass(sprintf(textline, "\tmov\tr5,r4"));
-       p2pass(sprintf(textline, "\tadd\t$%d.,r4", k));
-#else
-       p2reg(ARGREG, P2SHORT);
-       p2reg(AUTOREG, P2SHORT);
-       p2op2(P2ICON, P2SHORT);
-       p2i(k);
-       p2op2(P2PLUS, P2SHORT);
-       p2op2(P2ASSIGN, P2SHORT);
-       putstmt();
-#endif
-}
-
-
-
-
-
-prhead(fp)
-FILEP fp;
-{
-#if FAMILY==SCJ
-#      if OUTPUT == BINARY
-               p2triple(P2LBRACKET, ARGREG-1-highregvar, procno);
-               p2word( (long) (BITSPERCHAR*autoleng) );
-               p2flush();
-#      else
-               fprintf(fp, "[%02d\t%06ld\t%02d\t\n", procno,
-                       BITSPERCHAR*autoleng, ARGREG-1-highregvar);
-#      endif
-#endif
-}
-\f
-prdbginfo()
-{
-register char *s;
-char *t, buff[50];
-register struct nameblock *p;
-struct hashentry *hp;
-
-if(s = entries->entryname->extname)
-       s = varstr(XL, s);
-else if(procclass == CLMAIN)
-       s = "MAIN__";
-else
-       return;
-
-if(procclass != CLBLOCK)
-       fprintf(asmfile, "~~%s = _%s\n", s, s);
-
-for(hp = hashtab ; hp<lasthash ; ++hp)
-    if(p = hp->varp)
-       {
-       s = NULL;
-       if(p->vstg == STGARG)
-               s = sprintf(buff, "%o", p->vardesc.varno+argloc);
-       else if(p->vclass == CLVAR)
-               switch(p->vstg)
-                       {
-                       case STGBSS:
-                       case STGINIT:
-                       case STGEQUIV:
-                               t = memname(p->vstg, p->vardesc.varno);
-                               if(p->voffset)
-                                       s = sprintf(buff, "%s+%o", t, p->voffset);
-                               else
-                                       s = sprintf(buff, "%s", t);
-                               break;
-
-                       case STGAUTO:
-                               s = sprintf(buff, "%o", p->voffset);
-                               break;
-
-                       default:
-                               break;
-                       }
-       if(s)
-               fprintf(asmfile, "~%s = %s\n", varstr(VL,p->varname), s);
-       }
-fprintf(asmfile, "~~:\n");
-}
diff --git a/usr/src/cmd/f77/pdp11defs b/usr/src/cmd/f77/pdp11defs
deleted file mode 100644 (file)
index b315a5d..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef TARGET
-TARGET NOT DEFINED !!!
-#endif
-#if TARGET!=PDP11
-Target= TARGET OUT OF RANGE!!
-#endif
-
-#ifndef FAMILY
-FAMILY NOT DEFINED!!!
-#endif
-#if FAMILY!=SCJ && FAMILY!=DMR
-Family = FAMILY OUT OF RANGE
-#endif
-
-#define TYLENG TYLONG
-
-#define TYINT  TYSHORT
-#define SZADDR 2
-#define SZSHORT        2
-#define SZINT  2
-
-#define SZLONG 4
-#define SZLENG SZLONG
-
-#define ALIADDR SZADDR
-#define ALISHORT SZSHORT
-#define ALILONG 2
-#define ALIDOUBLE 2
-#define ALIINT ALILONG
-#define ALILENG        ALILONG
-
-
-#define AUTOREG 5
-#define ARGREG 4
-#define SAVESPACE 6
-
-#define FUDGEOFFSET 1
-#define BITSPERCHAR 8
-#define XL 8
-
-#define USETEXT        "\t.text"
-#define USECONST       "\t.data"
-#define USEBSS "\t.bss"
-#define USEINIT        "\t.data"
-
-#define BLANKCOMMON "_BLNK_"
-
-#define LABELFMT "%s:\n"
-#define MAXSHORT 32767
-
-#define MAXREGVAR 2
-#define TYIREG TYSHORT
-#define MSKIREG  M(TYSHORT)
diff --git a/usr/src/cmd/f77/pdp11x.c b/usr/src/cmd/f77/pdp11x.c
deleted file mode 100644 (file)
index 5a8cc3f..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#include <stdio.h>
-#include "defines"
-#include "locdefs"
-
-
-
-prchars(fp, s)
-FILEP fp;
-register int *s;
-{
-register int i;
-
-fprintf(fp, ".byte ");
-for(i = 0; i<SZSHORT ; ++i)
-       fprintf(fp, "%o%c", *s++, (i==SZSHORT-1 ? '\n' : ',' ) );
-}
-
-
-
-
-
-pruse(fp, s)
-FILEP fp;
-char *s;
-{
-fprintf(fp, "%s\n", s);
-}
-
-
-
-
-
-prskip(fp, k)
-FILEP fp;
-ftnint k;
-{
-/* works around bug in the pdp11 assembler that bombs on  . = .+x  for x>= 32768 */
-for( ; k > 30000 ; k -= 30000)
-       fprintf(fp, "\t. = .+30000.\n");
-fprintf(fp, "\t. = .+%ld.\n", k);
-}
-
-
-prcomblock(fp, name)
-FILEP fp;
-char *name;
-{
-fprintf(fp, LABELFMT, name);
-}
-
-
index 48008a8..007aaa2 100644 (file)
@@ -54,6 +54,11 @@ parstate = INEXEC;
 docommon();
 doequiv();
 docomleng();
 docommon();
 doequiv();
 docomleng();
+#if TARGET == PDP11
+/* fake jump to start the optimizer */
+if(procclass != CLBLOCK)
+       putgoto( fudgelabel = newlabel() );
+#endif
 for(p = entries ; p ; p = p->nextp)
        doentry(p);
 }
 for(p = entries ; p ; p = p->nextp)
        doentry(p);
 }
@@ -70,9 +75,9 @@ register struct entrypoint *p;
 
 p = ALLOC(entrypoint);
 if(class == CLMAIN)
 
 p = ALLOC(entrypoint);
 if(class == CLMAIN)
-       puthead("MAIN__", CLMAIN);
+       puthead("MAIN__");
 else
 else
-       puthead(NULL, CLBLOCK);
+       puthead(NULL);
 if(class == CLMAIN)
        newentry( mkname(5, "MAIN_") );
 p->entryname = progname;
 if(class == CLMAIN)
        newentry( mkname(5, "MAIN_") );
 p->entryname = progname;
@@ -123,7 +128,7 @@ register struct nameblock *q;
 register struct entrypoint *p;
 
 if(class != CLENTRY)
 register struct entrypoint *p;
 
 if(class != CLENTRY)
-       puthead( varstr(XL, procname = entry->extname), class);
+       puthead( varstr(XL, procname = entry->extname) );
 if(class == CLENTRY)
        fprintf(diagfile, "       entry ");
 fprintf(diagfile, "   %s:\n", nounder(XL, entry->extname));
 if(class == CLENTRY)
        fprintf(diagfile, "       entry ");
 fprintf(diagfile, "   %s:\n", nounder(XL, entry->extname));
diff --git a/usr/src/cmd/f77/putdmr.c b/usr/src/cmd/f77/putdmr.c
deleted file mode 100644 (file)
index 429f10f..0000000
+++ /dev/null
@@ -1,1281 +0,0 @@
-/*  INTERMEDIATE CODE GENERATION FOR D. M. RITCHIE C COMPILERS */
-#if FAMILY != DMR
-       WRONG put FILE !!!!
-#endif
-
-#include "defs"
-#include "dmrdefs"
-
-
-extern int ops2[];
-extern int types2[];
-
-
-puthead(s, class)
-char *s;
-int class;
-{
-if( ! headerdone )
-       {
-       p2op2(P2SETREG, ARGREG-maxregvar);
-       p2op(P2PROG);
-       headerdone = YES;
-#if TARGET == PDP11
-       /* fake jump to start the optimizer */
-       if(class != CLBLOCK)
-               putgoto( fudgelabel = newlabel() );
-#endif
-       }
-}
-
-
-
-
-putnreg()
-{
-p2op2(P2SETREG, ARGREG-nregvar);
-}
-
-
-
-
-
-
-puteof()
-{
-p2op(P2EOF);
-}
-
-
-
-putstmt()
-{
-p2op2(P2EXPR, lineno);
-}
-
-
-
-
-/* put out code for if( ! p) goto l  */
-putif(p,l)
-register expptr p;
-int l;
-{
-register int k;
-if( (k = (p = fixtype(p))->vtype) != TYLOGICAL)
-       {
-       if(k != TYERROR)
-               err("non-logical expression in IF statement");
-       frexpr(p);
-       }
-else
-       {
-       putex1(p);
-       p2op2(P2CBRANCH, l);
-       p2i(0);
-       p2i(lineno);
-       }
-}
-
-
-
-
-
-/* put out code for  goto l   */
-putgoto(label)
-int label;
-{
-p2op2(P2GOTO, label);
-}
-
-
-/* branch to address constant or integer variable */
-putbranch(p)
-register struct addrblock *p;
-{
-register int type;
-
-type = p->vtype;
-if(p->tag != TADDR)
-       fatal("invalid goto label");
-putaddr(p, YES);
-if(type != TYINT)
-       p2op2(P2LTOI, P2INT);
-p2op2(P2INDIRECT, P2INT);
-p2op2(P2JUMP, P2INT);
-putstmt();
-}
-
-
-
-/* put out label  l:     */
-putlabel(label)
-int label;
-{
-p2op2(P2LABEL, label);
-}
-
-
-
-
-putexpr(p)
-expptr p;
-{
-putex1(p);
-putstmt();
-}
-
-
-
-
-
-prarif(p, neg, zero, pos)
-expptr p;
-int neg ,zero, pos;
-{
-putx(p);
-p2op(P2ARIF);
-p2i(neg);
-p2i(zero);
-p2i(pos);
-p2i(lineno);
-}
-
-
-
-putcmgo(index, nlab, labs)
-expptr index;
-int nlab;
-struct labelblock *labs[];
-{
-register int i;
-int skiplabel;
-
-if(! ISINT(index->vtype) )
-       {
-       execerr("computed goto index must be integer", NULL);
-       return;
-       }
-
-putforce(TYINT, mkconv(TYINT, index) );
-p2op(P2SWITCH);
-p2i(skiplabel = newlabel() );
-p2i(lineno);
-for(i = 0 ; i<nlab ; ++i)
-       {
-       p2i(labs[i]->labelno);
-       p2i(i+1);
-       }
-p2i(0);
-putlabel(skiplabel);
-}
-\f
-putx(p)
-register expptr p;
-{
-struct addrblock *putcall(), *putcx1(), *realpart();
-char *memname();
-int opc;
-int type, ncomma;
-
-switch(p->tag)
-       {
-       case TERROR:
-               free(p);
-               break;
-
-       case TCONST:
-               switch(type = p->vtype)
-                       {
-                       case TYLOGICAL:
-                               type = tylogical;
-                       case TYLONG:
-                       case TYSHORT:
-                               if(type == TYSHORT)
-                                       {
-                                       p2op2(P2ICON, P2SHORT);
-                                       p2i( (short)(p->const.ci) );
-                                       }
-                               else
-                                       {
-                                       p2op2(P2LCON, P2LONG);
-                                       p2li(p->const.ci);
-                                       }
-                               free(p);
-                               break;
-
-                       case TYADDR:
-                               p2op(P2NAME);
-                               p2i(P2STATIC);
-                               p2i(P2INT);
-                               p2i( (int) p->const.ci);
-                               p2op2(P2ADDR, P2PTR);
-                               free(p);
-                               break;
-
-                       default:
-                               putx( putconst(p) );
-                               break;
-                       }
-               break;
-
-       case TEXPR:
-               switch(opc = p->opcode)
-                       {
-                       case OPCALL:
-                       case OPCCALL:
-                               if( ISCOMPLEX(p->vtype) )
-                                       putcxop(p);
-                               else    putcall(p);
-                               break;
-
-                       case OPMIN:
-                       case OPMAX:
-                               putmnmx(p);
-                               break;
-
-
-                       case OPASSIGN:
-                               if( ISCOMPLEX(p->leftp->vtype) || ISCOMPLEX(p->rightp->vtype) )
-                                       frexpr( putcxeq(p) );
-                               else if( ISCHAR(p) )
-                                       putcheq(p);
-                               else
-                                       goto putopp;
-                               break;
-
-                       case OPEQ:
-                       case OPNE:
-                               if( ISCOMPLEX(p->leftp->vtype) || ISCOMPLEX(p->rightp->vtype) )
-                                       {
-                                       putcxcmp(p);
-                                       break;
-                                       }
-                       case OPLT:
-                       case OPLE:
-                       case OPGT:
-                       case OPGE:
-                               if(ISCHAR(p->leftp))
-                                       putchcmp(p);
-                               else
-                                       goto putopp;
-                               break;
-
-                       case OPPOWER:
-                               putpower(p);
-                               break;
-
-                       case OPMOD:
-                               goto putopp;
-                       case OPSTAR:
-
-                       case OPPLUS:
-                       case OPMINUS:
-                       case OPSLASH:
-                       case OPNEG:
-                               if( ISCOMPLEX(p->vtype) )
-                                       putcxop(p);
-                               else    goto putopp;
-                               break;
-
-                       case OPCONV:
-                               if( ISCOMPLEX(p->vtype) )
-                                       putcxop(p);
-                               else if( ISCOMPLEX(p->leftp->vtype) )
-                                       {
-                                       ncomma = 0;
-                                       putx( mkconv(p->vtype,
-                                               realpart(putcx1(p->leftp, &ncomma))));
-                                       putcomma(ncomma, p->vtype, NO);
-                                       free(p);
-                                       }
-                               else    goto putopp;
-                               break;
-
-                       case OPNOT:
-                       case OPOR:
-                       case OPAND:
-                       case OPEQV:
-                       case OPNEQV:
-                       case OPADDR:
-                       case OPPLUSEQ:
-                       case OPSTAREQ:
-                       case OPCOMMA:
-                       case OPQUEST:
-                       case OPCOLON:
-                       case OPBITOR:
-                       case OPBITAND:
-                       case OPBITXOR:
-                       case OPBITNOT:
-                       case OPLSHIFT:
-                       case OPRSHIFT:
-               putopp:
-                               putop(p);
-                               break;
-
-                       default:
-                               fatal1("putx: invalid opcode %d", opc);
-                       }
-               break;
-
-       case TADDR:
-               putaddr(p, YES);
-               break;
-
-       default:
-               fatal1("putx: impossible tag %d", p->tag);
-       }
-}
-
-
-
-LOCAL putop(p)
-register expptr p;
-{
-int k, ncomma;
-int type2, ptype, ltype;
-int convop;
-register expptr lp, tp;
-
-switch(p->opcode)      /* check for special cases and rewrite */
-       {
-
-       case OPCONV:
-               lp = p->leftp;
-               while(p->tag==TEXPR && p->opcode==OPCONV &&
-                    (  ( (ptype = p->vtype) == (ltype = lp->vtype) ) ||
-                    (ISREAL(ptype)&&ISREAL(ltype)) ||
-                    (ONEOF(ptype, M(TYSHORT)|M(TYADDR)) &&
-                       ONEOF(ltype, M(TYSHORT)|M(TYADDR))) ||
-                       (ptype==TYINT && ONEOF(ltype, M(TYSUBR)|M(TYCHAR))) ))
-                               {
-                               free(p);
-                               p = lp;
-                               lp = p->leftp;
-                               }
-               if(p->tag!=TEXPR || p->opcode!=OPCONV || ISCOMPLEX((ltype = lp->vtype)) )
-                       {
-                       putx(p);
-                       return;
-                       }
-               ltype = lp->vtype;
-               switch(ptype = p->vtype)
-                       {
-                       case TYCHAR:
-                               p->leftp = lp = mkconv(TYSHORT, lp);
-                               convop = P2ITOC;
-                               break;
-
-                       case TYSHORT:
-                       case TYADDR:
-                               switch(ltype)
-                                       {
-                                       case TYLONG:
-                                               convop = P2LTOI; break;
-                                       case TYREAL:
-                                       case TYDREAL:
-                                               convop = P2FTOI; break;
-                                       default:
-                                               goto badconv;
-                                       }
-                               break;
-
-                       case TYLONG:
-                               switch(ltype)
-                                       {
-                                       case TYCHAR:
-                                       case TYSHORT:
-                                       case TYADDR:
-                                               convop = P2ITOL; break;
-                                       case TYREAL:
-                                       case TYDREAL:
-                                               convop = P2FTOL; break;
-                                       default:
-                                               goto badconv;
-                                       }
-                               break;
-
-                       case TYREAL:
-                       case TYDREAL:
-                               switch(ltype)
-                                       {
-                                       case TYCHAR:
-                                       case TYSHORT:
-                                       case TYADDR:
-                                               convop = P2ITOF; break;
-                                       case TYLONG:
-                                               convop = P2LTOF; break;
-                                       default:
-                                               goto badconv;
-                                       }
-                               break;
-
-                       default:
-                       badconv:
-                               fatal("putop: impossible conversion");
-                       }
-               putx(lp);
-               p2op2(convop, types2[ptype]);
-               free(p);
-               return;
-
-       case OPADDR:
-               lp = p->leftp;
-               if(lp->tag != TADDR)
-                       {
-                       tp = mktemp(lp->vtype, lp->vleng);
-                       putx( mkexpr(OPASSIGN, cpexpr(tp), lp) );
-                       ncomma = 1;
-                       lp = tp;
-                       }
-               else    ncomma = 0;
-               putaddr(lp, NO);
-               putcomma(ncomma, TYINT, NO);
-               free(p);
-               return;
-
-       case OPASSIGN:
-               if(p->vtype==TYLOGICAL && tylogical!=TYINT &&
-                  p->rightp->tag==TEXPR && p->rightp->opcode!=OPCALL && p->rightp->opcode!=OPCCALL)
-                       {
-                       p->rightp->vtype = TYINT;
-                       p->rightp = mkconv(tylogical, p->rightp);
-                       }
-               break;
-       }
-
-if( (k = ops2[p->opcode]) <= 0)
-       fatal1("putop: invalid opcode %d", p->opcode);
-putx(p->leftp);
-if(p->rightp)
-       putx(p->rightp);
-type2 = (p->vtype==TYLOGICAL ? P2INT : types2[p->vtype]);
-p2op2(k, type2);
-
-if(p->vleng)
-       frexpr(p->vleng);
-free(p);
-}
-\f
-putforce(t, p)
-int t;
-expptr p;
-{
-p = mkconv(t, fixtype(p));
-putx(p);
-p2op2(P2FORCE, (t==TYSHORT ? P2SHORT : (t==TYLONG ? P2LONG : P2DREAL)) );
-putstmt();
-}
-
-
-
-LOCAL putpower(p)
-expptr p;
-{
-expptr base;
-struct addrblock *t1, *t2;
-ftnint k;
-int type;
-int ncomma;
-
-if(!ISICON(p->rightp) || (k = p->rightp->const.ci)<2)
-       fatal("putpower: bad call");
-base = p->leftp;
-type = base->vtype;
-t1 = mktemp(type, NULL);
-t2 = NULL;
-ncomma = 1;
-putassign(cpexpr(t1), cpexpr(base) );
-
-for( ; (k&1)==0 && k>2 ; k>>=1 )
-       {
-       ++ncomma;
-       putsteq(t1, t1);
-       }
-
-if(k == 2)
-       putx( mkexpr(OPSTAR, cpexpr(t1), cpexpr(t1)) );
-else
-       {
-       t2 = mktemp(type, NULL);
-       ++ncomma;
-       putassign(cpexpr(t2), cpexpr(t1));
-       
-       for(k>>=1 ; k>1 ; k>>=1)
-               {
-               ++ncomma;
-               putsteq(t1, t1);
-               if(k & 1)
-                       {
-                       ++ncomma;
-                       putsteq(t2, t1);
-                       }
-               }
-       putx( mkexpr(OPSTAR, cpexpr(t2),
-               mkexpr(OPSTAR, cpexpr(t1), cpexpr(t1)) ));
-       }
-putcomma(ncomma, type, NO);
-frexpr(t1);
-if(t2)
-       frexpr(t2);
-frexpr(p);
-}
-
-
-
-
-LOCAL struct addrblock *intdouble(p, ncommap)
-struct addrblock *p;
-int *ncommap;
-{
-register struct addrblock *t;
-
-t = mktemp(TYDREAL, NULL);
-++*ncommap;
-putassign(cpexpr(t), p);
-return(t);
-}
-
-
-
-
-
-LOCAL putcxeq(p)
-register struct exprblock *p;
-{
-register struct addrblock *lp, *rp;
-int ncomma;
-
-ncomma = 0;
-lp = putcx1(p->leftp, &ncomma);
-rp = putcx1(p->rightp, &ncomma);
-putassign(realpart(lp), realpart(rp));
-if( ISCOMPLEX(p->vtype) )
-       {
-       ++ncomma;
-       putassign(imagpart(lp), imagpart(rp));
-       }
-putcomma(ncomma, TYREAL, NO);
-frexpr(rp);
-free(p);
-return(lp);
-}
-
-
-
-LOCAL putcxop(p)
-expptr p;
-{
-struct addrblock *putcx1();
-int ncomma;
-
-ncomma = 0;
-putaddr( putcx1(p, &ncomma), NO);
-putcomma(ncomma, TYINT, NO);
-}
-
-
-
-LOCAL struct addrblock *putcx1(p, ncommap)
-register expptr p;
-int *ncommap;
-{
-struct addrblock *q, *lp, *rp;
-register struct addrblock *resp;
-int opcode;
-int ltype, rtype;
-
-if(p == NULL)
-       return(NULL);
-
-switch(p->tag)
-       {
-       case TCONST:
-               if( ISCOMPLEX(p->vtype) )
-                       p = putconst(p);
-               return( p );
-
-       case TADDR:
-               if( ! addressable(p) )
-                       {
-                       ++*ncommap;
-                       resp = mktemp(tyint, NULL);
-                       putassign( cpexpr(resp), p->memoffset );
-                       p->memoffset = resp;
-                       }
-               return( p );
-
-       case TEXPR:
-               if( ISCOMPLEX(p->vtype) )
-                       break;
-               ++*ncommap;
-               resp = mktemp(TYDREAL, NO);
-               putassign( cpexpr(resp), p);
-               return(resp);
-
-       default:
-               fatal1("putcx1: bad tag %d", p->tag);
-       }
-
-opcode = p->opcode;
-if(opcode==OPCALL || opcode==OPCCALL)
-       {
-       ++*ncommap;
-       return( putcall(p) );
-       }
-else if(opcode == OPASSIGN)
-       {
-       ++*ncommap;
-       return( putcxeq(p) );
-       }
-resp = mktemp(p->vtype, NULL);
-if(lp = putcx1(p->leftp, ncommap) )
-       ltype = lp->vtype;
-if(rp = putcx1(p->rightp, ncommap) )
-       rtype = rp->vtype;
-
-switch(opcode)
-       {
-       case OPCOMMA:
-               frexpr(resp);
-               resp = rp;
-               rp = NULL;
-               break;
-
-       case OPNEG:
-               putassign( realpart(resp), mkexpr(OPNEG, realpart(lp), NULL) );
-               putassign( imagpart(resp), mkexpr(OPNEG, imagpart(lp), NULL) );
-               *ncommap += 2;
-               break;
-
-       case OPPLUS:
-       case OPMINUS:
-               putassign( realpart(resp), mkexpr(opcode, realpart(lp), realpart(rp) ));
-               if(rtype < TYCOMPLEX)
-                       putassign( imagpart(resp), imagpart(lp) );
-               else if(ltype < TYCOMPLEX)
-                       {
-                       if(opcode == OPPLUS)
-                               putassign( imagpart(resp), imagpart(rp) );
-                       else    putassign( imagpart(resp), mkexpr(OPNEG, imagpart(rp), NULL) );
-                       }
-               else
-                       putassign( imagpart(resp), mkexpr(opcode, imagpart(lp), imagpart(rp) ));
-
-               *ncommap += 2;
-               break;
-
-       case OPSTAR:
-               if(ltype < TYCOMPLEX)
-                       {
-                       if( ISINT(ltype) )
-                               lp = intdouble(lp, ncommap);
-                       putassign( realpart(resp), mkexpr(OPSTAR, cpexpr(lp), realpart(rp) ));
-                       putassign( imagpart(resp), mkexpr(OPSTAR, cpexpr(lp), imagpart(rp) ));
-                       }
-               else if(rtype < TYCOMPLEX)
-                       {
-                       if( ISINT(rtype) )
-                               rp = intdouble(rp, ncommap);
-                       putassign( realpart(resp), mkexpr(OPSTAR, cpexpr(rp), realpart(lp) ));
-                       putassign( imagpart(resp), mkexpr(OPSTAR, cpexpr(rp), imagpart(lp) ));
-                       }
-               else    {
-                       putassign( realpart(resp), mkexpr(OPMINUS,
-                               mkexpr(OPSTAR, realpart(lp), realpart(rp)),
-                               mkexpr(OPSTAR, imagpart(lp), imagpart(rp)) ));
-                       putassign( imagpart(resp), mkexpr(OPPLUS,
-                               mkexpr(OPSTAR, realpart(lp), imagpart(rp)),
-                               mkexpr(OPSTAR, imagpart(lp), realpart(rp)) ));
-                       }
-               *ncommap += 2;
-               break;
-
-       case OPSLASH:
-               /* fixexpr has already replaced all divisions
-                * by a complex by a function call
-                */
-               if( ISINT(rtype) )
-                       rp = intdouble(rp, ncommap);
-               putassign( realpart(resp), mkexpr(OPSLASH, realpart(lp), cpexpr(rp)) );
-               putassign( imagpart(resp), mkexpr(OPSLASH, imagpart(lp), cpexpr(rp)) );
-               *ncommap += 2;
-               break;
-
-       case OPCONV:
-               putassign( realpart(resp), realpart(lp) );
-               if( ISCOMPLEX(lp->vtype) )
-                       q = imagpart(lp);
-               else if(rp != NULL)
-                       q = realpart(rp);
-               else
-                       q = mkrealcon(TYDREAL, 0.0);
-               putassign( imagpart(resp), q);
-               *ncommap += 2;
-               break;
-
-       default:
-               fatal1("putcx1 of invalid opcode %d", opcode);
-       }
-
-frexpr(lp);
-frexpr(rp);
-free(p);
-return(resp);
-}
-
-
-
-
-LOCAL putcxcmp(p)
-register struct exprblock *p;
-{
-int opcode;
-int ncomma;
-register struct addrblock *lp, *rp;
-struct exprblock *q;
-
-ncomma = 0;
-opcode = p->opcode;
-lp = putcx1(p->leftp, &ncomma);
-rp = putcx1(p->rightp, &ncomma);
-
-q = mkexpr( opcode==OPEQ ? OPAND : OPOR ,
-       mkexpr(opcode, realpart(lp), realpart(rp)),
-       mkexpr(opcode, imagpart(lp), imagpart(rp)) );
-putx( fixexpr(q) );
-putcomma(ncomma, TYINT, NO);
-
-free(lp);
-free(rp);
-free(p);
-}
-\f
-LOCAL struct addrblock *putch1(p, ncommap)
-register expptr p;
-int * ncommap;
-{
-register struct addrblock *t;
-struct addrblock *mktemp(), *putconst();
-
-switch(p->tag)
-       {
-       case TCONST:
-               return( putconst(p) );
-
-       case TADDR:
-               return(p);
-
-       case TEXPR:
-               ++*ncommap;
-
-               switch(p->opcode)
-                       {
-                       case OPCALL:
-                       case OPCCALL:
-                               t = putcall(p);
-                               break;
-
-                       case OPCONCAT:
-                               t = mktemp(TYCHAR, cpexpr(p->vleng) );
-                               putcat( cpexpr(t), p );
-                               break;
-
-                       case OPCONV:
-                               if(!ISICON(p->vleng) || p->vleng->const.ci!=1
-                                  || ! INT(p->leftp->vtype) )
-                                       fatal("putch1: bad character conversion");
-                               t = mktemp(TYCHAR, ICON(1) );
-                               putop( mkexpr(OPASSIGN, cpexpr(t), p) );
-                               break;
-                       default:
-                               fatal1("putch1: invalid opcode %d", p->opcode);
-                       }
-               return(t);
-
-       default:
-               fatal1("putch1: bad tag %d", p->tag);
-       }
-/* NOTREACHED */
-}
-\f
-
-
-
-LOCAL putchop(p)
-expptr p;
-{
-int ncomma;
-
-ncomma = 0;
-putaddr( putch1(p, &ncomma) , NO );
-putcomma(ncomma, TYCHAR, YES);
-}
-
-
-
-
-LOCAL putcheq(p)
-register struct exprblock *p;
-{
-int ncomma;
-
-ncomma = 0;
-if( p->rightp->tag==TEXPR && p->rightp->opcode==OPCONCAT )
-       putcat(p->leftp, p->rightp);
-else if( ISONE(p->leftp->vleng) && ISONE(p->rightp->vleng) )
-       {
-       putaddr( putch1(p->leftp, &ncomma) , YES );
-       putaddr( putch1(p->rightp, &ncomma) , YES );
-       putcomma(ncomma, TYINT, NO);
-       p2op2(P2ASSIGN, P2CHAR);
-       }
-else
-       {
-       putx( call2(TYINT, "s_copy", p->leftp, p->rightp) );
-       putcomma(ncomma, TYINT, NO);
-       }
-frexpr(p->vleng);
-free(p);
-}
-
-
-
-
-LOCAL putchcmp(p)
-register struct exprblock *p;
-{
-int ncomma;
-
-ncomma = 0;
-if(ISONE(p->leftp->vleng) && ISONE(p->rightp->vleng) )
-       {
-       putaddr( putch1(p->leftp, &ncomma) , YES );
-       putaddr( putch1(p->rightp, &ncomma) , YES );
-       p2op2(ops2[p->opcode], P2CHAR);
-       free(p);
-       putcomma(ncomma, TYINT, NO);
-       }
-else
-       {
-       p->leftp = call2(TYINT,"s_cmp", p->leftp, p->rightp);
-       p->rightp = ICON(0);
-       putop(p);
-       }
-}
-
-
-
-
-
-LOCAL putcat(lhs, rhs)
-register struct addrblock *lhs;
-register expptr rhs;
-{
-int n, ncomma;
-struct addrblock *lp, *cp;
-
-ncomma = 0;
-n = ncat(rhs);
-lp = mktmpn(n, TYLENG, NULL);
-cp = mktmpn(n, TYADDR, NULL);
-
-n = 0;
-putct1(rhs, lp, cp, &n, &ncomma);
-
-putx( call4(TYSUBR, "s_cat", lhs, cp, lp, mkconv(TYLONG, ICON(n)) ) );
-putcomma(ncomma, TYINT, NO);
-}
-
-
-
-
-
-LOCAL ncat(p)
-register expptr p;
-{
-if(p->tag==TEXPR && p->opcode==OPCONCAT)
-       return( ncat(p->leftp) + ncat(p->rightp) );
-else   return(1);
-}
-
-
-
-
-LOCAL putct1(q, lp, cp, ip, ncommap)
-register expptr q;
-register struct addrblock *lp, *cp;
-int *ip, *ncommap;
-{
-int i;
-struct addrblock *lp1, *cp1;
-
-if(q->tag==TEXPR && q->opcode==OPCONCAT)
-       {
-       putct1(q->leftp, lp, cp, ip, ncommap);
-       putct1(q->rightp, lp, cp , ip, ncommap);
-       frexpr(q->vleng);
-       free(q);
-       }
-else
-       {
-       i = (*ip)++;
-       lp1 = cpexpr(lp);
-       lp1->memoffset = mkexpr(OPPLUS, lp1->memoffset, ICON(i*SZLENG));
-       cp1 = cpexpr(cp);
-       cp1->memoffset = mkexpr(OPPLUS, cp1->memoffset, ICON(i*SZADDR));
-       putassign( lp1, cpexpr(q->vleng) );
-       putassign( cp1, addrof(putch1(q,ncommap)) );
-       *ncommap += 2;
-       }
-}
-\f
-LOCAL putaddr(p, indir)
-register struct addrblock *p;
-int indir;
-{
-int type, type2, funct;
-expptr offp;
-
-type = p->vtype;
-type2 = types2[type];
-if(p->vclass == CLPROC)
-       {
-       funct = P2FUNCT;
-       if(type == TYUNKNOWN)
-               type2 = P2INT;
-       }
-else
-       funct = 0;
-if(p->memoffset && (!ISICON(p->memoffset) || p->memoffset->const.ci!=0) )
-       offp = cpexpr(p->memoffset);
-else
-       offp = NULL;
-
-#if FUDGEOFFSET != 1
-if(offp)
-       offp = mkexpr(OPSTAR, ICON(FUDGEOFFSET), offp);
-#endif
-
-switch(p->vstg)
-       {
-       case STGAUTO:
-               p2reg(AUTOREG, P2PTR);
-               p2offset(type2|P2PTR, offp);
-               if(indir)
-                       p2op2(P2INDIRECT, type2);
-               break;
-
-       case STGLENG:
-       case STGARG:
-               p2reg(ARGREG, type2|P2PTR|((funct?funct:P2PTR)<<2));
-               if(p->memno)
-                       {
-                       putx( ICON(p->memno) );
-                       p2op2(P2PLUS, type2|P2PTR|(funct<<2));
-                       }
-               if(p->vstg == STGARG)
-                       {
-                       p2op2(P2INDIRECT, type2|P2PTR);
-                       p2offset(type2|P2PTR|(funct<<2), offp);
-                       }
-               if(indir)
-                       p2op2(P2INDIRECT, type2|funct);
-               break;
-
-       case STGBSS:
-       case STGINIT:
-       case STGEXT:
-       case STGCOMMON:
-       case STGEQUIV:
-       case STGCONST:
-               p2op(P2NAME);
-               p2i(P2EXTERN);
-               p2i(type2|funct);
-               p2str( memname(p->vstg,p->memno) );
-               if(!indir || offp!=NULL)
-                       p2op2(P2ADDR, type2|P2PTR);
-               p2offset(type2|P2PTR, offp);
-               if(indir && offp!=NULL)
-                       p2op2(P2INDIRECT, type2);
-               break;
-
-       case STGREG:
-               if(indir)
-                       p2reg(p->memno, type2);
-               break;
-
-       default:
-               fatal1("putaddr: invalid vstg %d", p->vstg);
-       }
-frexpr(p);
-}
-
-
-
-
-\f
-LOCAL struct addrblock *putcall(p)
-register struct exprblock *p;
-{
-chainp arglist, charsp, cp;
-int first;
-struct addrblock *t;
-register struct exprblock *q;
-struct exprblock *fval;
-int type, type2, ctype, indir;
-
-if( (type = p->vtype) == TYLOGICAL)
-       type = tylogical;
-type2 = types2[type];
-charsp = NULL;
-first = YES;
-indir =  (p->opcode == OPCCALL);
-
-if(p->rightp)
-       {
-       arglist = p->rightp->listp;
-       free(p->rightp);
-       }
-else
-       arglist = NULL;
-
-if(!indir)  for(cp = arglist ; cp ; cp = cp->nextp)
-       {
-       q = cp->datap;
-       if( ISCONST(q) )
-               {
-               if(q->vtype == TYSHORT)
-                       q = mkconv(tyint, q);
-               cp->datap = q = putconst(q);
-               }
-       if( ISCHAR(q) )
-               charsp = hookup(charsp, mkchain(cpexpr(q->vleng), 0) );
-       else if(q->vclass == CLPROC)
-               charsp = hookup(charsp, mkchain( ICON(0) , 0));
-       }
-
-if(type == TYCHAR)
-       {
-       if( ISICON(p->vleng) )
-               fval = mktemp(TYCHAR, p->vleng);
-       else    {
-               err("adjustable character function");
-               return(NULL);
-               }
-       }
-else if( ISCOMPLEX(type) )
-       fval = mktemp(type, NULL);
-else
-       fval = NULL;
-
-ctype = (fval ? P2INT : type2);
-putaddr(p->leftp, YES);
-
-if(fval)
-       {
-       first = NO;
-       putaddr( cpexpr(fval), NO);
-       if(type==TYCHAR)
-               {
-               putx( mkconv(TYLENG, p->vleng) );
-               p2op2(P2LISTOP, P2INT);
-               }
-       }
-
-for(cp = arglist ; cp ; cp = cp->nextp)
-       {
-       q = cp->datap;
-       if(q->tag==TADDR && (indir || q->vstg!=STGREG) )
-               putaddr(q, indir && q->vtype!=TYCHAR);
-       else if( ISCOMPLEX(q->vtype) )
-               putcxop(q);
-       else if (ISCHAR(q) )
-               putchop(q);
-       else if( ! ISERROR(q) )
-               {
-               if(indir)
-                       putx(q);
-               else    {
-                       t = mktemp(q->vtype, q->vleng);
-                       putassign( cpexpr(t), q );
-                       putaddr(t, NO);
-                       putcomma(1, q->vtype, YES);
-                       }
-               }
-       if(first)
-               first = NO;
-       else
-               p2op2(P2LISTOP, P2INT);
-       }
-
-if(arglist)
-       frchain(&arglist);
-for(cp = charsp ; cp ; cp = cp->nextp)
-       {
-       putx( mkconv(TYLENG, cp->datap) );
-       if(first)
-               first = NO;
-       else
-               p2op2(P2LISTOP, P2INT);
-       }
-frchain(&charsp);
-
-if(first)
-       p2op(P2NULL);
-p2op2(P2CALL, ctype);
-free(p);
-return(fval);
-}
-
-
-
-LOCAL putmnmx(p)
-register struct exprblock *p;
-{
-int op, type;
-int ncomma;
-struct exprblock *qp;
-chainp p0, p1;
-struct addrblock *sp, *tp;
-
-type = p->vtype;
-op = (p->opcode==OPMIN ? OPLT : OPGT );
-p0 = p->leftp->listp;
-free(p->leftp);
-free(p);
-
-sp = mktemp(type, NULL);
-tp = mktemp(type, NULL);
-qp = mkexpr(OPCOLON, cpexpr(tp), cpexpr(sp));
-qp = mkexpr(OPQUEST, mkexpr(op, cpexpr(tp),cpexpr(sp)), qp);
-qp = fixexpr(qp);
-
-ncomma = 1;
-putassign( cpexpr(sp), p0->datap );
-
-for(p1 = p0->nextp ; p1 ; p1 = p1->nextp)
-       {
-       ++ncomma;
-       putassign( cpexpr(tp), p1->datap );
-       if(p1->nextp)
-               {
-               ++ncomma;
-               putassign( cpexpr(sp), cpexpr(qp) );
-               }
-       else
-               putx(qp);
-       }
-
-putcomma(ncomma, type, NO);
-frtemp(sp);
-frtemp(tp);
-frchain( &p0 );
-}
-
-
-
-
-LOCAL putcomma(n, type, indir)
-int n, type, indir;
-{
-type = types2[type];
-if(indir)
-       type |= P2PTR;
-while(--n >= 0)
-       p2op2(P2COMOP, type);
-}
-\f
-/*
- *  routines that put bytes on the pass2 input stream
-*/
-
-
-p2i(k)
-int k;
-{
-register char *s;
-s = &k;
-
-putc(*s++, textfile);
-putc(*s, textfile);
-}
-
-
-
-
-p2op(op)
-int op;
-{
-putc(op, textfile);
-putc(0376, textfile);   /* MAGIC NUMBER */
-}
-
-
-
-
-p2str(s)
-register char *s;
-{
-do
-       putc(*s, textfile);
-               while(*s++);
-}
-
-
-
-p2op2(op, i)
-int op, i;
-{
-p2op(op);
-p2i(i);
-}
-
-
-
-p2reg(k, type)
-int k;
-{
-p2op2(P2NAME, P2REG);
-p2i(type);
-p2i(k);
-}
-
-
-
-LOCAL p2li(n)
-long int n;
-{
-register int *p, i;
-
-p = &n;
-for(i = 0 ; i< sizeof(long int)/sizeof(int) ; ++i)
-       p2i(*p++);
-}
-
-
-
-LOCAL p2offset(type, offp)
-int type;
-register expptr offp;
-{
-expptr shorten();
-
-if(offp)
-       {
-#if SZINT < SZLONG
-       if(shortsubs)
-               offp = shorten(offp);
-#endif
-       if(offp->vtype != TYLONG)
-               offp = mkconv(TYINT, offp);
-       if(offp->vtype == TYLONG)
-               {
-               putx(offp);
-               p2op2(P2LTOI, P2INT);
-               }
-       else
-               putx( offp );
-       p2op2(P2PLUS, type);
-       }
-}
diff --git a/usr/src/cmd/f77/putscj.c b/usr/src/cmd/f77/putscj.c
deleted file mode 100644 (file)
index da10260..0000000
+++ /dev/null
@@ -1,1422 +0,0 @@
-/* INTERMEDIATE CODE GENERATION FOR S C JOHNSON C COMPILERS */
-/* NEW VERSION USING BINARY POLISH POSTFIX INTERMEDIATE */
-#if FAMILY != SCJ
-       WRONG put FULE !!!!
-#endif
-
-#include "defs"
-#include "scjdefs"
-
-#define FOUR 4
-extern int ops2[];
-extern int types2[];
-
-#define P2BUFFMAX 128
-static long int p2buff[P2BUFFMAX];
-static long int *p2bufp                = &p2buff[0];
-static long int *p2bufend      = &p2buff[P2BUFFMAX];
-
-
-puthead(s)
-char *s;
-{
-char buff[100];
-#if TARGET == VAX
-       if(s)
-               p2pass( sprintf(buff, "\t.globl\t_%s", s) );
-#endif
-/* put out fake copy of left bracket line, to be redone later */
-if( ! headerdone )
-       {
-#if FAMILY==SCJ && OUTPUT==BINARY
-       p2flush();
-#endif
-       headoffset = ftell(textfile);
-       prhead(textfile);
-       headerdone = YES;
-       p2triple(P2STMT, (strlen(infname)+FOUR-1)/FOUR, 0);
-       p2str(infname);
-       }
-}
-
-
-
-
-
-/* It is necessary to precede each procedure with a "left bracket"
- * line that tells pass 2 how many register variables and how
- * much automatic space is required for the function.  This compiler
- * does not know how much automatic space is needed until the
- * entire procedure has been processed.  Therefore, "puthead"
- * is called at the begining to record the current location in textfile,
- * then to put out a placeholder left bracket line.  This procedure
- * repositions the file and rewrites that line, then puts the
- * file pointer back to the end of the file.
- */
-
-putbracket()
-{
-long int hereoffset;
-
-#if FAMILY==SCJ && OUTPUT==BINARY
-       p2flush();
-#endif
-hereoffset = ftell(textfile);
-if(fseek(textfile, headoffset, 0))
-       fatal("fseek failed");
-prhead(textfile);
-if(fseek(textfile, hereoffset, 0))
-       fatal("fseek failed 2");
-}
-
-
-
-
-putrbrack(k)
-int k;
-{
-p2op(P2RBRACKET, k);
-}
-
-
-
-putnreg()
-{
-}
-
-
-
-
-
-
-puteof()
-{
-p2op(P2EOF, 0);
-p2flush();
-}
-
-
-
-putstmt()
-{
-p2triple(P2STMT, 0, lineno);
-}
-
-
-
-
-/* put out code for if( ! p) goto l  */
-putif(p,l)
-register expptr p;
-int l;
-{
-register int k;
-
-if( ( k = (p = fixtype(p))->vtype) != TYLOGICAL)
-       {
-       if(k != TYERROR)
-               err("non-logical expression in IF statement");
-       frexpr(p);
-       }
-else
-       {
-       putex1(p);
-       p2icon( (long int) l , P2INT);
-       p2op(P2CBRANCH, 0);
-       putstmt();
-       }
-}
-
-
-
-
-
-/* put out code for  goto l   */
-putgoto(label)
-int label;
-{
-p2triple(P2GOTO, 1, label);
-putstmt();
-}
-
-
-/* branch to address constant or integer variable */
-putbranch(p)
-register struct addrblock *p;
-{
-putex1(p);
-p2op(P2GOTO, P2INT);
-putstmt();
-}
-
-
-
-/* put out label  l:     */
-putlabel(label)
-int label;
-{
-p2op(P2LABEL, label);
-}
-
-
-
-
-putexpr(p)
-expptr p;
-{
-putex1(p);
-putstmt();
-}
-
-
-
-
-putcmgo(index, nlab, labs)
-expptr index;
-int nlab;
-struct labelblock *labs[];
-{
-int i, labarray, skiplabel;
-
-if(! ISINT(index->vtype) )
-       {
-       execerr("computed goto index must be integer", NULL);
-       return;
-       }
-
-#if TARGET == VAX
-       /* use special case instruction */
-       vaxgoto(index, nlab, labs);
-#else
-       labarray = newlabel();
-       preven(ALIADDR);
-       prlabel(asmfile, labarray);
-       prcona(asmfile, (ftnint) (skiplabel = newlabel()) );
-       for(i = 0 ; i < nlab ; ++i)
-               prcona(asmfile, (ftnint)(labs[i]->labelno) );
-       prcmgoto(index, nlab, skiplabel, labarray);
-       putlabel(skiplabel);
-#endif
-}
-\f
-putx(p)
-expptr p;
-{
-struct addrblock *putcall(), *putcx1(), *realpart();
-char *memname();
-int opc;
-int ncomma;
-int type, k;
-
-switch(p->tag)
-       {
-       case TERROR:
-               free(p);
-               break;
-
-       case TCONST:
-               switch(type = p->vtype)
-                       {
-                       case TYLOGICAL:
-                               type = tyint;
-                       case TYLONG:
-                       case TYSHORT:
-                               p2icon(p->const.ci, types2[type]);
-                               free(p);
-                               break;
-
-                       case TYADDR:
-                               p2triple(P2ICON, 1, P2INT|P2PTR);
-                               p2word(0L);
-                               p2name(memname(STGCONST, (int) p->const.ci) );
-                               free(p);
-                               break;
-
-                       default:
-                               putx( putconst(p) );
-                               break;
-                       }
-               break;
-
-       case TEXPR:
-               switch(opc = p->opcode)
-                       {
-                       case OPCALL:
-                       case OPCCALL:
-                               if( ISCOMPLEX(p->vtype) )
-                                       putcxop(p);
-                               else    putcall(p);
-                               break;
-
-                       case OPMIN:
-                       case OPMAX:
-                               putmnmx(p);
-                               break;
-
-
-                       case OPASSIGN:
-                               if( ISCOMPLEX(p->leftp->vtype) || ISCOMPLEX(p->rightp->vtype) )
-                                       frexpr( putcxeq(p) );
-                               else if( ISCHAR(p) )
-                                       putcheq(p);
-                               else
-                                       goto putopp;
-                               break;
-
-                       case OPEQ:
-                       case OPNE:
-                               if( ISCOMPLEX(p->leftp->vtype) || ISCOMPLEX(p->rightp->vtype) )
-                                       {
-                                       putcxcmp(p);
-                                       break;
-                                       }
-                       case OPLT:
-                       case OPLE:
-                       case OPGT:
-                       case OPGE:
-                               if(ISCHAR(p->leftp))
-                                       putchcmp(p);
-                               else
-                                       goto putopp;
-                               break;
-
-                       case OPPOWER:
-                               putpower(p);
-                               break;
-
-                       case OPSTAR:
-#if FAMILY == SCJ
-                               /*   m * (2**k) -> m<<k   */
-                               if(INT(p->leftp->vtype) && ISICON(p->rightp) &&
-                                  ( (k = log2(p->rightp->const.ci))>0) )
-                                       {
-                                       p->opcode = OPLSHIFT;
-                                       frexpr(p->rightp);
-                                       p->rightp = ICON(k);
-                                       goto putopp;
-                                       }
-#endif
-
-                       case OPMOD:
-                               goto putopp;
-                       case OPPLUS:
-                       case OPMINUS:
-                       case OPSLASH:
-                       case OPNEG:
-                               if( ISCOMPLEX(p->vtype) )
-                                       putcxop(p);
-                               else    goto putopp;
-                               break;
-
-                       case OPCONV:
-                               if( ISCOMPLEX(p->vtype) )
-                                       putcxop(p);
-                               else if( ISCOMPLEX(p->leftp->vtype) )
-                                       {
-                                       ncomma = 0;
-                                       putx( mkconv(p->vtype,
-                                               realpart(putcx1(p->leftp, &ncomma))));
-                                       putcomma(ncomma, p->vtype, NO);
-                                       free(p);
-                                       }
-                               else    goto putopp;
-                               break;
-
-                       case OPNOT:
-                       case OPOR:
-                       case OPAND:
-                       case OPEQV:
-                       case OPNEQV:
-                       case OPADDR:
-                       case OPPLUSEQ:
-                       case OPSTAREQ:
-                       case OPCOMMA:
-                       case OPQUEST:
-                       case OPCOLON:
-                       case OPBITOR:
-                       case OPBITAND:
-                       case OPBITXOR:
-                       case OPBITNOT:
-                       case OPLSHIFT:
-                       case OPRSHIFT:
-               putopp:
-                               putop(p);
-                               break;
-
-                       default:
-                               fatal1("putx: invalid opcode %d", opc);
-                       }
-               break;
-
-       case TADDR:
-               putaddr(p, YES);
-               break;
-
-       default:
-               fatal1("putx: impossible tag %d", p->tag);
-       }
-}
-
-
-
-LOCAL putop(p)
-expptr p;
-{
-int k;
-expptr lp, tp;
-int pt, lt;
-int comma;
-
-switch(p->opcode)      /* check for special cases and rewrite */
-       {
-       case OPCONV:
-               pt = p->vtype;
-               lp = p->leftp;
-               lt = lp->vtype;
-               while(p->tag==TEXPR && p->opcode==OPCONV &&
-                    ( (ISREAL(pt)&&ISREAL(lt)) ||
-                       (INT(pt)&&(ONEOF(lt,MSKINT|MSKADDR|MSKCHAR|M(TYSUBR)))) ))
-                       {
-#if SZINT < SZLONG
-                       if(lp->tag != TEXPR)
-                               {
-                               if(pt==TYINT && lt==TYLONG)
-                                       break;
-                               if(lt==TYINT && pt==TYLONG)
-                                       break;
-                               }
-#endif
-                       free(p);
-                       p = lp;
-                       pt = lt;
-                       lp = p->leftp;
-                       lt = lp->vtype;
-                       }
-               if(p->tag==TEXPR && p->opcode==OPCONV)
-                       break;
-               putx(p);
-               return;
-
-       case OPADDR:
-               comma = NO;
-               lp = p->leftp;
-               if(lp->tag != TADDR)
-                       {
-                       tp = mktemp(lp->vtype, lp->vleng);
-                       putx( mkexpr(OPASSIGN, cpexpr(tp), lp) );
-                       lp = tp;
-                       comma = YES;
-                       }
-               putaddr(lp, NO);
-               if(comma)
-                       putcomma(1, TYINT, NO);
-               free(p);
-               return;
-       }
-
-if( (k = ops2[p->opcode]) <= 0)
-       fatal1("putop: invalid opcode %d", p->opcode);
-putx(p->leftp);
-if(p->rightp)
-       putx(p->rightp);
-p2op(k, types2[p->vtype]);
-
-if(p->vleng)
-       frexpr(p->vleng);
-free(p);
-}
-\f
-putforce(t, p)
-int t;
-expptr p;
-{
-p = mkconv(t, fixtype(p));
-putx(p);
-p2op(P2FORCE,
-       (t==TYSHORT ? P2SHORT : (t==TYLONG ? P2LONG : P2DREAL)) );
-putstmt();
-}
-
-
-
-LOCAL putpower(p)
-expptr p;
-{
-expptr base;
-struct addrblock *t1, *t2;
-ftnint k;
-int type;
-int ncomma;
-
-if(!ISICON(p->rightp) || (k = p->rightp->const.ci)<2)
-       fatal("putpower: bad call");
-base = p->leftp;
-type = base->vtype;
-t1 = mktemp(type, NULL);
-t2 = NULL;
-ncomma = 1;
-putassign(cpexpr(t1), cpexpr(base) );
-
-for( ; (k&1)==0 && k>2 ; k>>=1 )
-       {
-       ++ncomma;
-       putsteq(t1, t1);
-       }
-
-if(k == 2)
-       putx( mkexpr(OPSTAR, cpexpr(t1), cpexpr(t1)) );
-else
-       {
-       t2 = mktemp(type, NULL);
-       ++ncomma;
-       putassign(cpexpr(t2), cpexpr(t1));
-       
-       for(k>>=1 ; k>1 ; k>>=1)
-               {
-               ++ncomma;
-               putsteq(t1, t1);
-               if(k & 1)
-                       {
-                       ++ncomma;
-                       putsteq(t2, t1);
-                       }
-               }
-       putx( mkexpr(OPSTAR, cpexpr(t2),
-               mkexpr(OPSTAR, cpexpr(t1), cpexpr(t1)) ));
-       }
-putcomma(ncomma, type, NO);
-frexpr(t1);
-if(t2)
-       frexpr(t2);
-frexpr(p);
-}
-
-
-
-
-LOCAL struct addrblock *intdouble(p, ncommap)
-struct addrblock *p;
-int *ncommap;
-{
-register struct addrblock *t;
-
-t = mktemp(TYDREAL, NULL);
-++*ncommap;
-putassign(cpexpr(t), p);
-return(t);
-}
-
-
-
-
-
-LOCAL putcxeq(p)
-register struct exprblock *p;
-{
-register struct addrblock *lp, *rp;
-int ncomma;
-
-ncomma = 0;
-lp = putcx1(p->leftp, &ncomma);
-rp = putcx1(p->rightp, &ncomma);
-putassign(realpart(lp), realpart(rp));
-if( ISCOMPLEX(p->vtype) )
-       {
-       ++ncomma;
-       putassign(imagpart(lp), imagpart(rp));
-       }
-putcomma(ncomma, TYREAL, NO);
-frexpr(rp);
-free(p);
-return(lp);
-}
-
-
-
-LOCAL putcxop(p)
-expptr p;
-{
-struct addrblock *putcx1();
-int ncomma;
-
-ncomma = 0;
-putaddr( putcx1(p, &ncomma), NO);
-putcomma(ncomma, TYINT, NO);
-}
-
-
-
-LOCAL struct addrblock *putcx1(p, ncommap)
-register expptr p;
-int *ncommap;
-{
-struct addrblock *q, *lp, *rp;
-register struct addrblock *resp;
-int opcode;
-int ltype, rtype;
-
-if(p == NULL)
-       return(NULL);
-
-switch(p->tag)
-       {
-       case TCONST:
-               if( ISCOMPLEX(p->vtype) )
-                       p = putconst(p);
-               return( p );
-
-       case TADDR:
-               if( ! addressable(p) )
-                       {
-                       ++*ncommap;
-                       resp = mktemp(tyint, NULL);
-                       putassign( cpexpr(resp), p->memoffset );
-                       p->memoffset = resp;
-                       }
-               return( p );
-
-       case TEXPR:
-               if( ISCOMPLEX(p->vtype) )
-                       break;
-               ++*ncommap;
-               resp = mktemp(TYDREAL, NO);
-               putassign( cpexpr(resp), p);
-               return(resp);
-
-       default:
-               fatal1("putcx1: bad tag %d", p->tag);
-       }
-
-opcode = p->opcode;
-if(opcode==OPCALL || opcode==OPCCALL)
-       {
-       ++*ncommap;
-       return( putcall(p) );
-       }
-else if(opcode == OPASSIGN)
-       {
-       ++*ncommap;
-       return( putcxeq(p) );
-       }
-resp = mktemp(p->vtype, NULL);
-if(lp = putcx1(p->leftp, ncommap) )
-       ltype = lp->vtype;
-if(rp = putcx1(p->rightp, ncommap) )
-       rtype = rp->vtype;
-
-switch(opcode)
-       {
-       case OPCOMMA:
-               frexpr(resp);
-               resp = rp;
-               rp = NULL;
-               break;
-
-       case OPNEG:
-               putassign( realpart(resp), mkexpr(OPNEG, realpart(lp), NULL) );
-               putassign( imagpart(resp), mkexpr(OPNEG, imagpart(lp), NULL) );
-               *ncommap += 2;
-               break;
-
-       case OPPLUS:
-       case OPMINUS:
-               putassign( realpart(resp), mkexpr(opcode, realpart(lp), realpart(rp) ));
-               if(rtype < TYCOMPLEX)
-                       putassign( imagpart(resp), imagpart(lp) );
-               else if(ltype < TYCOMPLEX)
-                       {
-                       if(opcode == OPPLUS)
-                               putassign( imagpart(resp), imagpart(rp) );
-                       else    putassign( imagpart(resp), mkexpr(OPNEG, imagpart(rp), NULL) );
-                       }
-               else
-                       putassign( imagpart(resp), mkexpr(opcode, imagpart(lp), imagpart(rp) ));
-
-               *ncommap += 2;
-               break;
-
-       case OPSTAR:
-               if(ltype < TYCOMPLEX)
-                       {
-                       if( ISINT(ltype) )
-                               lp = intdouble(lp, ncommap);
-                       putassign( realpart(resp), mkexpr(OPSTAR, cpexpr(lp), realpart(rp) ));
-                       putassign( imagpart(resp), mkexpr(OPSTAR, cpexpr(lp), imagpart(rp) ));
-                       }
-               else if(rtype < TYCOMPLEX)
-                       {
-                       if( ISINT(rtype) )
-                               rp = intdouble(rp, ncommap);
-                       putassign( realpart(resp), mkexpr(OPSTAR, cpexpr(rp), realpart(lp) ));
-                       putassign( imagpart(resp), mkexpr(OPSTAR, cpexpr(rp), imagpart(lp) ));
-                       }
-               else    {
-                       putassign( realpart(resp), mkexpr(OPMINUS,
-                               mkexpr(OPSTAR, realpart(lp), realpart(rp)),
-                               mkexpr(OPSTAR, imagpart(lp), imagpart(rp)) ));
-                       putassign( imagpart(resp), mkexpr(OPPLUS,
-                               mkexpr(OPSTAR, realpart(lp), imagpart(rp)),
-                               mkexpr(OPSTAR, imagpart(lp), realpart(rp)) ));
-                       }
-               *ncommap += 2;
-               break;
-
-       case OPSLASH:
-               /* fixexpr has already replaced all divisions
-                * by a complex by a function call
-                */
-               if( ISINT(rtype) )
-                       rp = intdouble(rp, ncommap);
-               putassign( realpart(resp), mkexpr(OPSLASH, realpart(lp), cpexpr(rp)) );
-               putassign( imagpart(resp), mkexpr(OPSLASH, imagpart(lp), cpexpr(rp)) );
-               *ncommap += 2;
-               break;
-
-       case OPCONV:
-               putassign( realpart(resp), realpart(lp) );
-               if( ISCOMPLEX(lp->vtype) )
-                       q = imagpart(lp);
-               else if(rp != NULL)
-                       q = realpart(rp);
-               else
-                       q = mkrealcon(TYDREAL, 0.0);
-               putassign( imagpart(resp), q);
-               *ncommap += 2;
-               break;
-
-       default:
-               fatal1("putcx1 of invalid opcode %d", opcode);
-       }
-
-frexpr(lp);
-frexpr(rp);
-free(p);
-return(resp);
-}
-
-
-
-
-LOCAL putcxcmp(p)
-register struct exprblock *p;
-{
-int opcode;
-int ncomma;
-register struct addrblock *lp, *rp;
-struct exprblock *q;
-
-ncomma = 0;
-opcode = p->opcode;
-lp = putcx1(p->leftp, &ncomma);
-rp = putcx1(p->rightp, &ncomma);
-
-q = mkexpr( opcode==OPEQ ? OPAND : OPOR ,
-       mkexpr(opcode, realpart(lp), realpart(rp)),
-       mkexpr(opcode, imagpart(lp), imagpart(rp)) );
-putx( fixexpr(q) );
-putcomma(ncomma, TYINT, NO);
-
-free(lp);
-free(rp);
-free(p);
-}
-\f
-LOCAL struct addrblock *putch1(p, ncommap)
-register expptr p;
-int * ncommap;
-{
-register struct addrblock *t;
-struct addrblock *mktemp(), *putconst();
-
-switch(p->tag)
-       {
-       case TCONST:
-               return( putconst(p) );
-
-       case TADDR:
-               return(p);
-
-       case TEXPR:
-               ++*ncommap;
-
-               switch(p->opcode)
-                       {
-                       case OPCALL:
-                       case OPCCALL:
-                               t = putcall(p);
-                               break;
-
-                       case OPCONCAT:
-                               t = mktemp(TYCHAR, cpexpr(p->vleng) );
-                               putcat( cpexpr(t), p );
-                               break;
-
-                       case OPCONV:
-                               if(!ISICON(p->vleng) || p->vleng->const.ci!=1
-                                  || ! INT(p->leftp->vtype) )
-                                       fatal("putch1: bad character conversion");
-                               t = mktemp(TYCHAR, ICON(1) );
-                               putop( mkexpr(OPASSIGN, cpexpr(t), p) );
-                               break;
-                       default:
-                               fatal1("putch1: invalid opcode %d", p->opcode);
-                       }
-               return(t);
-
-       default:
-               fatal1("putch1: bad tag %d", p->tag);
-       }
-/* NOTREACHED */
-}
-\f
-
-
-
-LOCAL putchop(p)
-expptr p;
-{
-int ncomma;
-
-ncomma = 0;
-putaddr( putch1(p, &ncomma) , NO );
-putcomma(ncomma, TYCHAR, YES);
-}
-
-
-
-
-LOCAL putcheq(p)
-register struct exprblock *p;
-{
-int ncomma;
-
-ncomma = 0;
-if( p->rightp->tag==TEXPR && p->rightp->opcode==OPCONCAT )
-       putcat(p->leftp, p->rightp);
-else if( ISONE(p->leftp->vleng) && ISONE(p->rightp->vleng) )
-       {
-       putaddr( putch1(p->leftp, &ncomma) , YES );
-       putaddr( putch1(p->rightp, &ncomma) , YES );
-       putcomma(ncomma, TYINT, NO);
-       p2op(P2ASSIGN, P2CHAR);
-       }
-else
-       {
-       putx( call2(TYINT, "s_copy", p->leftp, p->rightp) );
-       putcomma(ncomma, TYINT, NO);
-       }
-
-frexpr(p->vleng);
-free(p);
-}
-
-
-
-
-LOCAL putchcmp(p)
-register struct exprblock *p;
-{
-int ncomma;
-
-ncomma = 0;
-if(ISONE(p->leftp->vleng) && ISONE(p->rightp->vleng) )
-       {
-       putaddr( putch1(p->leftp, &ncomma) , YES );
-       putaddr( putch1(p->rightp, &ncomma) , YES );
-       p2op(ops2[p->opcode], P2CHAR);
-       free(p);
-       putcomma(ncomma, TYINT, NO);
-       }
-else
-       {
-       p->leftp = call2(TYINT,"s_cmp", p->leftp, p->rightp);
-       p->rightp = ICON(0);
-       putop(p);
-       }
-}
-
-
-
-
-
-LOCAL putcat(lhs, rhs)
-register struct addrblock *lhs;
-register expptr rhs;
-{
-int n, ncomma;
-struct addrblock *lp, *cp;
-
-ncomma = 0;
-n = ncat(rhs);
-lp = mktmpn(n, TYLENG, NULL);
-cp = mktmpn(n, TYADDR, NULL);
-
-n = 0;
-putct1(rhs, lp, cp, &n, &ncomma);
-
-putx( call4(TYSUBR, "s_cat", lhs, cp, lp, ICON(n) ) );
-putcomma(ncomma, TYINT, NO);
-}
-
-
-
-
-
-LOCAL ncat(p)
-register expptr p;
-{
-if(p->tag==TEXPR && p->opcode==OPCONCAT)
-       return( ncat(p->leftp) + ncat(p->rightp) );
-else   return(1);
-}
-
-
-
-
-LOCAL putct1(q, lp, cp, ip, ncommap)
-register expptr q;
-register struct addrblock *lp, *cp;
-int *ip, *ncommap;
-{
-int i;
-struct addrblock *lp1, *cp1;
-
-if(q->tag==TEXPR && q->opcode==OPCONCAT)
-       {
-       putct1(q->leftp, lp, cp, ip, ncommap);
-       putct1(q->rightp, lp, cp , ip, ncommap);
-       frexpr(q->vleng);
-       free(q);
-       }
-else
-       {
-       i = (*ip)++;
-       lp1 = cpexpr(lp);
-       lp1->memoffset = mkexpr(OPPLUS, lp1->memoffset, ICON(i*SZLENG));
-       cp1 = cpexpr(cp);
-       cp1->memoffset = mkexpr(OPPLUS, cp1->memoffset, ICON(i*SZADDR));
-       putassign( lp1, cpexpr(q->vleng) );
-       putassign( cp1, addrof(putch1(q,ncommap)) );
-       *ncommap += 2;
-       }
-}
-\f
-LOCAL putaddr(p, indir)
-register struct addrblock *p;
-int indir;
-{
-int type, type2, funct;
-ftnint offset, simoffset();
-expptr offp, shorten();
-
-type = p->vtype;
-type2 = types2[type];
-funct = (p->vclass==CLPROC ? P2FUNCT<<2 : 0);
-
-offp = (p->memoffset ? cpexpr(p->memoffset) : NULL);
-
-
-#if (FUDGEOFFSET != 1)
-if(offp)
-       offp = mkexpr(OPSTAR, ICON(FUDGEOFFSET), offp);
-#endif
-
-offset = simoffset( &offp );
-#if SZINT < SZLONG
-       if(offp)
-               if(shortsubs)
-                       offp = shorten(offp);
-               else
-                       offp = mkconv(TYINT, offp);
-#else
-       if(offp)
-               offp = mkconv(TYINT, offp);
-#endif
-
-switch(p->vstg)
-       {
-       case STGAUTO:
-               if(indir && !offp)
-                       {
-                       p2oreg(offset, AUTOREG, type2);
-                       break;
-                       }
-
-               if(!indir && !offp && !offset)
-                       {
-                       p2reg(AUTOREG, type2 | P2PTR);
-                       break;
-                       }
-
-               p2reg(AUTOREG, type2 | P2PTR);
-               if(offp)
-                       {
-                       putx(offp);
-                       if(offset)
-                               p2icon(offset, P2INT);
-                       }
-               else
-                       p2icon(offset, P2INT);
-               if(offp && offset)
-                       p2op(P2PLUS, type2 | P2PTR);
-               p2op(P2PLUS, type2 | P2PTR);
-               if(indir)
-                       p2op(P2INDIRECT, type2);
-               break;
-
-       case STGARG:
-               p2oreg(
-#ifdef ARGOFFSET
-                       ARGOFFSET +
-#endif
-                       (ftnint) (FUDGEOFFSET*p->memno),
-                       ARGREG,   type2 | P2PTR | funct );
-
-               if(offp)
-                       putx(offp);
-               if(offset)
-                       p2icon(offset, P2INT);
-               if(offp && offset)
-                       p2op(P2PLUS, type2 | P2PTR);
-               if(offp || offset)
-                       p2op(P2PLUS, type2 | P2PTR);
-               if(indir)
-                       p2op(P2INDIRECT, type2);
-               break;
-
-       case STGLENG:
-               if(indir)
-                       {
-                       p2oreg(
-#ifdef ARGOFFSET
-                               ARGOFFSET +
-#endif
-                               (ftnint) (FUDGEOFFSET*p->memno),
-                               ARGREG,   type2 | P2PTR );
-                       }
-               else    {
-                       p2reg(ARGREG, type2 | P2PTR );
-                       p2icon(
-#ifdef ARGOFFSET
-                               ARGOFFSET +
-#endif
-                               (ftnint) (FUDGEOFFSET*p->memno), P2INT);
-                       p2op(P2PLUS, type2 | P2PTR );
-                       }
-               break;
-
-
-       case STGBSS:
-       case STGINIT:
-       case STGEXT:
-       case STGCOMMON:
-       case STGEQUIV:
-       case STGCONST:
-               if(offp)
-                       {
-                       putx(offp);
-                       putmem(p, P2ICON, offset);
-                       p2op(P2PLUS, type2 | P2PTR);
-                       if(indir)
-                               p2op(P2INDIRECT, type2);
-                       }
-               else
-                       putmem(p, (indir ? P2NAME : P2ICON), offset);
-
-               break;
-
-       case STGREG:
-               if(indir)
-                       p2reg(p->memno, type2);
-               else
-                       fatal("attempt to take address of a register");
-               break;
-
-       default:
-               fatal1("putaddr: invalid vstg %d", p->vstg);
-       }
-frexpr(p);
-}
-
-
-
-
-LOCAL putmem(p, class, offset)
-expptr p;
-int class;
-ftnint offset;
-{
-int type2;
-int funct;
-char *name,  *memname();
-
-funct = (p->vclass==CLPROC ? P2FUNCT<<2 : 0);
-type2 = types2[p->vtype];
-if(p->vclass == CLPROC)
-       type2 |= (P2FUNCT<<2);
-name = memname(p->vstg, p->memno);
-if(class == P2ICON)
-       {
-       p2triple(P2ICON, name[0]!='\0', type2|P2PTR);
-       p2word(offset);
-       if(name[0])
-               p2name(name);
-       }
-else
-       {
-       p2triple(P2NAME, offset!=0, type2);
-       if(offset != 0)
-               p2word(offset);
-       p2name(name);
-       }
-}
-
-
-\f
-LOCAL struct addrblock *putcall(p)
-struct exprblock *p;
-{
-chainp arglist, charsp, cp;
-int n, first;
-struct addrblock *t;
-struct exprblock *q;
-struct exprblock *fval;
-int type, type2, ctype, indir;
-
-type2 = types2[type = p->vtype];
-charsp = NULL;
-indir =  (p->opcode == OPCCALL);
-n = 0;
-first = YES;
-
-if(p->rightp)
-       {
-       arglist = p->rightp->listp;
-       free(p->rightp);
-       }
-else
-       arglist = NULL;
-
-for(cp = arglist ; cp ; cp = cp->nextp)
-       if(indir)
-               ++n;
-       else    {
-               q = cp->datap;
-               if(q->tag == TCONST)
-                       cp->datap = q = putconst(q);
-               if( ISCHAR(q) )
-                       {
-                       charsp = hookup(charsp, mkchain(cpexpr(q->vleng), 0) );
-                       n += 2;
-                       }
-               else if(q->vclass == CLPROC)
-                       {
-                       charsp = hookup(charsp, mkchain( ICON(0) , 0));
-                       n += 2;
-                       }
-               else
-                       n += 1;
-               }
-
-if(type == TYCHAR)
-       {
-       if( ISICON(p->vleng) )
-               {
-               fval = mktemp(TYCHAR, p->vleng);
-               n += 2;
-               }
-       else    {
-               err("adjustable character function");
-               return;
-               }
-       }
-else if( ISCOMPLEX(type) )
-       {
-       fval = mktemp(type, NULL);
-       n += 1;
-       }
-else
-       fval = NULL;
-
-ctype = (fval ? P2INT : type2);
-putaddr(p->leftp, NO);
-
-if(fval)
-       {
-       first = NO;
-       putaddr( cpexpr(fval), NO);
-       if(type==TYCHAR)
-               {
-               putx( mkconv(TYLENG,p->vleng) );
-               p2op(P2LISTOP, type2);
-               }
-       }
-
-for(cp = arglist ; cp ; cp = cp->nextp)
-       {
-       q = cp->datap;
-       if(q->tag==TADDR && (indir || q->vstg!=STGREG) )
-               putaddr(q, indir && q->vtype!=TYCHAR);
-       else if( ISCOMPLEX(q->vtype) )
-               putcxop(q);
-       else if (ISCHAR(q) )
-               putchop(q);
-       else if( ! ISERROR(q) )
-               {
-               if(indir)
-                       putx(q);
-               else    {
-                       t = mktemp(q->vtype, q->vleng);
-                       putassign( cpexpr(t), q );
-                       putaddr(t, NO);
-                       putcomma(1, q->vtype, YES);
-                       }
-               }
-       if(first)
-               first = NO;
-       else
-               p2op(P2LISTOP, type2);
-       }
-
-if(arglist)
-       frchain(&arglist);
-for(cp = charsp ; cp ; cp = cp->nextp)
-       {
-       putx( mkconv(TYLENG,cp->datap) );
-       p2op(P2LISTOP, type2);
-       }
-frchain(&charsp);
-p2op(n>0 ? P2CALL : P2CALL0 , ctype);
-free(p);
-return(fval);
-}
-
-
-
-LOCAL putmnmx(p)
-register struct exprblock *p;
-{
-int op, type;
-int ncomma;
-struct exprblock *qp;
-chainp p0, p1;
-struct addrblock *sp, *tp;
-
-type = p->vtype;
-op = (p->opcode==OPMIN ? OPLT : OPGT );
-p0 = p->leftp->listp;
-free(p->leftp);
-free(p);
-
-sp = mktemp(type, NULL);
-tp = mktemp(type, NULL);
-qp = mkexpr(OPCOLON, cpexpr(tp), cpexpr(sp));
-qp = mkexpr(OPQUEST, mkexpr(op, cpexpr(tp),cpexpr(sp)), qp);
-qp = fixexpr(qp);
-
-ncomma = 1;
-putassign( cpexpr(sp), p0->datap );
-
-for(p1 = p0->nextp ; p1 ; p1 = p1->nextp)
-       {
-       ++ncomma;
-       putassign( cpexpr(tp), p1->datap );
-       if(p1->nextp)
-               {
-               ++ncomma;
-               putassign( cpexpr(sp), cpexpr(qp) );
-               }
-       else
-               putx(qp);
-       }
-
-putcomma(ncomma, type, NO);
-frtemp(sp);
-frtemp(tp);
-frchain( &p0 );
-}
-
-
-
-
-LOCAL putcomma(n, type, indir)
-int n, type, indir;
-{
-type = types2[type];
-if(indir)
-       type |= P2PTR;
-while(--n >= 0)
-       p2op(P2COMOP, type);
-}
-
-
-
-
-ftnint simoffset(p0)
-expptr *p0;
-{
-ftnint offset, prod;
-register expptr p, lp, rp;
-
-offset = 0;
-p = *p0;
-if(p == NULL)
-       return(0);
-
-if( ! ISINT(p->vtype) )
-       return(0);
-
-if(p->tag==TEXPR && p->opcode==OPSTAR)
-       {
-       lp = p->leftp;
-       rp = p->rightp;
-       if(ISICON(rp) && lp->tag==TEXPR && lp->opcode==OPPLUS && ISICON(lp->rightp))
-               {
-               p->opcode = OPPLUS;
-               lp->opcode = OPSTAR;
-               prod = rp->const.ci * lp->rightp->const.ci;
-               lp->rightp->const.ci = rp->const.ci;
-               rp->const.ci = prod;
-               }
-       }
-
-if(p->tag==TEXPR && p->opcode==OPPLUS && ISICON(p->rightp))
-       {
-       rp = p->rightp;
-       lp = p->leftp;
-       offset += rp->const.ci;
-       frexpr(rp);
-       free(p);
-       *p0 = lp;
-       }
-
-if(p->tag == TCONST)
-       {
-       offset += p->const.ci;
-       frexpr(p);
-       *p0 = NULL;
-       }
-
-return(offset);
-}
-\f
-
-
-
-
-p2op(op, type)
-int op, type;
-{
-p2triple(op, 0, type);
-}
-
-p2icon(offset, type)
-ftnint offset;
-int type;
-{
-p2triple(P2ICON, 0, type);
-p2word(offset);
-}
-
-
-
-
-p2oreg(offset, reg, type)
-ftnint offset;
-int reg, type;
-{
-p2triple(P2OREG, reg, type);
-p2word(offset);
-p2name("");
-}
-
-
-
-
-p2reg(reg, type)
-int reg, type;
-{
-p2triple(P2REG, reg, type);
-}
-
-
-
-p2pass(s)
-char *s;
-{
-p2triple(P2PASS, (strlen(s) + FOUR-1)/FOUR, 0);
-p2str(s);
-}
-
-
-
-
-p2str(s)
-register char *s;
-{
-union { long int word; char str[FOUR]; } u;
-register int i;
-
-i = 0;
-u.word = 0;
-while(*s)
-       {
-       u.str[i++] = *s++;
-       if(i == FOUR)
-               {
-               p2word(u.word);
-               u.word = 0;
-               i = 0;
-               }
-       }
-if(i > 0)
-       p2word(u.word);
-}
-
-
-
-
-p2triple(op, var, type)
-int op, var, type;
-{
-register long word;
-word = op | (var<<8);
-word |= ( (long int) type) <<16;
-p2word(word);
-}
-
-
-
-
-p2name(s)
-char *s;
-{
-int i;
-union  { long int word[2];  char str[8]; } u;
-
-u.word[0] = u.word[1] = 0;
-for(i = 0 ; i<8 && *s ; ++i)
-       u.str[i] = *s++;
-p2word(u.word[0]);
-p2word(u.word[1]);
-}
-
-
-
-
-p2word(w)
-long int w;
-{
-*p2bufp++ = w;
-if(p2bufp >= p2bufend)
-       p2flush();
-}
-
-
-
-p2flush()
-{
-if(p2bufp > p2buff)
-       write(fileno(textfile), p2buff, (p2bufp-p2buff)*sizeof(long int));
-p2bufp = p2buff;
-}
diff --git a/usr/src/cmd/f77/putscjb.c b/usr/src/cmd/f77/putscjb.c
new file mode 100644 (file)
index 0000000..8c7d54f
--- /dev/null
@@ -0,0 +1,1419 @@
+/* INTERMEDIATE CODE GENERATION FOR S C JOHNSON C COMPILERS */
+/* NEW VERSION USING BINARY POLISH POSTFIX INTERMEDIATE */
+#if FAMILY != SCJ
+       WRONG put FULE !!!!
+#endif
+
+#include "defs"
+#include "scjdefs"
+
+#define FOUR 4
+extern int ops2[];
+extern int types2[];
+
+#define P2BUFFMAX 128
+static long int p2buff[P2BUFFMAX];
+static long int *p2bufp                = &p2buff[0];
+static long int *p2bufend      = &p2buff[P2BUFFMAX];
+
+
+puthead(s)
+char *s;
+{
+char buff[100];
+#if TARGET == VAX
+       if(s)
+               p2pass( sprintf(buff, "\t.globl\t_%s", s) );
+#endif
+/* put out fake copy of left bracket line, to be redone later */
+if( ! headerdone )
+       {
+#if FAMILY==SCJ && OUTPUT==BINARY
+       p2flush();
+#endif
+       headoffset = ftell(textfile);
+       prhead(textfile);
+       headerdone = YES;
+       p2triple(P2STMT, (strlen(infname)+FOUR-1)/FOUR, 0);
+       p2str(infname);
+       }
+}
+
+
+
+
+
+/* It is necessary to precede each procedure with a "left bracket"
+ * line that tells pass 2 how many register variables and how
+ * much automatic space is required for the function.  This compiler
+ * does not know how much automatic space is needed until the
+ * entire procedure has been processed.  Therefore, "puthead"
+ * is called at the begining to record the current location in textfile,
+ * then to put out a placeholder left bracket line.  This procedure
+ * repositions the file and rewrites that line, then puts the
+ * file pointer back to the end of the file.
+ */
+
+putbracket()
+{
+long int hereoffset;
+
+#if FAMILY==SCJ && OUTPUT==BINARY
+       p2flush();
+#endif
+hereoffset = ftell(textfile);
+if(fseek(textfile, headoffset, 0))
+       fatal("fseek failed");
+prhead(textfile);
+if(fseek(textfile, hereoffset, 0))
+       fatal("fseek failed 2");
+}
+
+
+
+
+putrbrack(k)
+int k;
+{
+p2op(P2RBRACKET, k);
+}
+
+
+
+putnreg()
+{
+}
+
+
+
+
+
+
+puteof()
+{
+p2op(P2EOF, 0);
+p2flush();
+}
+
+
+
+putstmt()
+{
+p2triple(P2STMT, 0, lineno);
+}
+
+
+
+
+/* put out code for if( ! p) goto l  */
+putif(p,l)
+register expptr p;
+int l;
+{
+register int k;
+
+if( ( k = (p = fixtype(p))->vtype) != TYLOGICAL)
+       {
+       if(k != TYERROR)
+               err("non-logical expression in IF statement");
+       frexpr(p);
+       }
+else
+       {
+       putex1(p);
+       p2icon( (long int) l , P2INT);
+       p2op(P2CBRANCH, 0);
+       putstmt();
+       }
+}
+
+
+
+
+
+/* put out code for  goto l   */
+putgoto(label)
+int label;
+{
+p2triple(P2GOTO, 1, label);
+putstmt();
+}
+
+
+/* branch to address constant or integer variable */
+putbranch(p)
+register struct addrblock *p;
+{
+putex1(p);
+p2op(P2GOTO, P2INT);
+putstmt();
+}
+
+
+
+/* put out label  l:     */
+putlabel(label)
+int label;
+{
+p2op(P2LABEL, label);
+}
+
+
+
+
+putexpr(p)
+expptr p;
+{
+putex1(p);
+putstmt();
+}
+
+
+
+
+putcmgo(index, nlab, labs)
+expptr index;
+int nlab;
+struct labelblock *labs[];
+{
+int i, labarray, skiplabel;
+
+if(! ISINT(index->vtype) )
+       {
+       execerr("computed goto index must be integer", NULL);
+       return;
+       }
+
+#if TARGET == VAX
+       /* use special case instruction */
+       vaxgoto(index, nlab, labs);
+#else
+       labarray = newlabel();
+       preven(ALIADDR);
+       prlabel(asmfile, labarray);
+       prcona(asmfile, (ftnint) (skiplabel = newlabel()) );
+       for(i = 0 ; i < nlab ; ++i)
+               prcona(asmfile, (ftnint)(labs[i]->labelno) );
+       prcmgoto(index, nlab, skiplabel, labarray);
+       putlabel(skiplabel);
+#endif
+}
+\f
+putx(p)
+expptr p;
+{
+struct addrblock *putcall(), *putcx1(), *realpart();
+char *memname();
+int opc;
+int ncomma;
+int type, k;
+
+switch(p->tag)
+       {
+       case TERROR:
+               free(p);
+               break;
+
+       case TCONST:
+               switch(type = p->vtype)
+                       {
+                       case TYLOGICAL:
+                               type = tyint;
+                       case TYLONG:
+                       case TYSHORT:
+                               p2icon(p->const.ci, types2[type]);
+                               free(p);
+                               break;
+
+                       case TYADDR:
+                               p2triple(P2ICON, 1, P2INT|P2PTR);
+                               p2word(0L);
+                               p2name(memname(STGCONST, (int) p->const.ci) );
+                               free(p);
+                               break;
+
+                       default:
+                               putx( putconst(p) );
+                               break;
+                       }
+               break;
+
+       case TEXPR:
+               switch(opc = p->opcode)
+                       {
+                       case OPCALL:
+                       case OPCCALL:
+                               if( ISCOMPLEX(p->vtype) )
+                                       putcxop(p);
+                               else    putcall(p);
+                               break;
+
+                       case OPMIN:
+                       case OPMAX:
+                               putmnmx(p);
+                               break;
+
+
+                       case OPASSIGN:
+                               if( ISCOMPLEX(p->leftp->vtype) || ISCOMPLEX(p->rightp->vtype) )
+                                       frexpr( putcxeq(p) );
+                               else if( ISCHAR(p) )
+                                       putcheq(p);
+                               else
+                                       goto putopp;
+                               break;
+
+                       case OPEQ:
+                       case OPNE:
+                               if( ISCOMPLEX(p->leftp->vtype) || ISCOMPLEX(p->rightp->vtype) )
+                                       {
+                                       putcxcmp(p);
+                                       break;
+                                       }
+                       case OPLT:
+                       case OPLE:
+                       case OPGT:
+                       case OPGE:
+                               if(ISCHAR(p->leftp))
+                                       putchcmp(p);
+                               else
+                                       goto putopp;
+                               break;
+
+                       case OPPOWER:
+                               putpower(p);
+                               break;
+
+                       case OPSTAR:
+#if FAMILY == SCJ
+                               /*   m * (2**k) -> m<<k   */
+                               if(INT(p->leftp->vtype) && ISICON(p->rightp) &&
+                                  ( (k = log2(p->rightp->const.ci))>0) )
+                                       {
+                                       p->opcode = OPLSHIFT;
+                                       frexpr(p->rightp);
+                                       p->rightp = ICON(k);
+                                       goto putopp;
+                                       }
+#endif
+
+                       case OPMOD:
+                               goto putopp;
+                       case OPPLUS:
+                       case OPMINUS:
+                       case OPSLASH:
+                       case OPNEG:
+                               if( ISCOMPLEX(p->vtype) )
+                                       putcxop(p);
+                               else    goto putopp;
+                               break;
+
+                       case OPCONV:
+                               if( ISCOMPLEX(p->vtype) )
+                                       putcxop(p);
+                               else if( ISCOMPLEX(p->leftp->vtype) )
+                                       {
+                                       ncomma = 0;
+                                       putx( mkconv(p->vtype,
+                                               realpart(putcx1(p->leftp, &ncomma))));
+                                       putcomma(ncomma, p->vtype, NO);
+                                       free(p);
+                                       }
+                               else    goto putopp;
+                               break;
+
+                       case OPNOT:
+                       case OPOR:
+                       case OPAND:
+                       case OPEQV:
+                       case OPNEQV:
+                       case OPADDR:
+                       case OPPLUSEQ:
+                       case OPSTAREQ:
+                       case OPCOMMA:
+                       case OPQUEST:
+                       case OPCOLON:
+                       case OPBITOR:
+                       case OPBITAND:
+                       case OPBITXOR:
+                       case OPBITNOT:
+                       case OPLSHIFT:
+                       case OPRSHIFT:
+               putopp:
+                               putop(p);
+                               break;
+
+                       default:
+                               fatal1("putx: invalid opcode %d", opc);
+                       }
+               break;
+
+       case TADDR:
+               putaddr(p, YES);
+               break;
+
+       default:
+               fatal1("putx: impossible tag %d", p->tag);
+       }
+}
+
+
+
+LOCAL putop(p)
+expptr p;
+{
+int k;
+expptr lp, tp;
+int pt, lt;
+int comma;
+
+switch(p->opcode)      /* check for special cases and rewrite */
+       {
+       case OPCONV:
+               pt = p->vtype;
+               lp = p->leftp;
+               lt = lp->vtype;
+               while(p->tag==TEXPR && p->opcode==OPCONV &&
+                    ( (ISREAL(pt)&&ISREAL(lt)) ||
+                       (INT(pt)&&(ONEOF(lt,MSKINT|MSKADDR|MSKCHAR))) ))
+                       {
+#if SZINT < SZLONG
+                       if(lp->tag != TEXPR)
+                               {
+                               if(pt==TYINT && lt==TYLONG)
+                                       break;
+                               if(lt==TYINT && pt==TYLONG)
+                                       break;
+                               }
+#endif
+                       free(p);
+                       p = lp;
+                       pt = lt;
+                       lp = p->leftp;
+                       lt = lp->vtype;
+                       }
+               if(p->tag==TEXPR && p->opcode==OPCONV)
+                       break;
+               putx(p);
+               return;
+
+       case OPADDR:
+               comma = NO;
+               lp = p->leftp;
+               if(lp->tag != TADDR)
+                       {
+                       tp = mktemp(lp->vtype, lp->vleng);
+                       putx( mkexpr(OPASSIGN, cpexpr(tp), lp) );
+                       lp = tp;
+                       comma = YES;
+                       }
+               putaddr(lp, NO);
+               if(comma)
+                       putcomma(1, TYINT, NO);
+               free(p);
+               return;
+       }
+
+if( (k = ops2[p->opcode]) <= 0)
+       fatal1("putop: invalid opcode %d", p->opcode);
+putx(p->leftp);
+if(p->rightp)
+       putx(p->rightp);
+p2op(k, types2[p->vtype]);
+
+if(p->vleng)
+       frexpr(p->vleng);
+free(p);
+}
+\f
+putforce(t, p)
+int t;
+expptr p;
+{
+p = mkconv(t, fixtype(p));
+putx(p);
+p2op(P2FORCE,
+       (t==TYSHORT ? P2SHORT : (t==TYLONG ? P2LONG : P2DREAL)) );
+putstmt();
+}
+
+
+
+LOCAL putpower(p)
+expptr p;
+{
+expptr base;
+struct addrblock *t1, *t2;
+ftnint k;
+int type;
+int ncomma;
+
+if(!ISICON(p->rightp) || (k = p->rightp->const.ci)<2)
+       fatal("putpower: bad call");
+base = p->leftp;
+type = base->vtype;
+t1 = mktemp(type, NULL);
+t2 = NULL;
+ncomma = 1;
+putassign(cpexpr(t1), cpexpr(base) );
+
+for( ; (k&1)==0 && k>2 ; k>>=1 )
+       {
+       ++ncomma;
+       putsteq(t1, t1);
+       }
+
+if(k == 2)
+       putx( mkexpr(OPSTAR, cpexpr(t1), cpexpr(t1)) );
+else
+       {
+       t2 = mktemp(type, NULL);
+       ++ncomma;
+       putassign(cpexpr(t2), cpexpr(t1));
+       
+       for(k>>=1 ; k>1 ; k>>=1)
+               {
+               ++ncomma;
+               putsteq(t1, t1);
+               if(k & 1)
+                       {
+                       ++ncomma;
+                       putsteq(t2, t1);
+                       }
+               }
+       putx( mkexpr(OPSTAR, cpexpr(t2),
+               mkexpr(OPSTAR, cpexpr(t1), cpexpr(t1)) ));
+       }
+putcomma(ncomma, type, NO);
+frexpr(t1);
+if(t2)
+       frexpr(t2);
+frexpr(p);
+}
+
+
+
+
+LOCAL struct addrblock *intdouble(p, ncommap)
+struct addrblock *p;
+int *ncommap;
+{
+register struct addrblock *t;
+
+t = mktemp(TYDREAL, NULL);
+++*ncommap;
+putassign(cpexpr(t), p);
+return(t);
+}
+
+
+
+
+
+LOCAL putcxeq(p)
+register struct exprblock *p;
+{
+register struct addrblock *lp, *rp;
+int ncomma;
+
+ncomma = 0;
+lp = putcx1(p->leftp, &ncomma);
+rp = putcx1(p->rightp, &ncomma);
+putassign(realpart(lp), realpart(rp));
+if( ISCOMPLEX(p->vtype) )
+       {
+       ++ncomma;
+       putassign(imagpart(lp), imagpart(rp));
+       }
+putcomma(ncomma, TYREAL, NO);
+frexpr(rp);
+free(p);
+return(lp);
+}
+
+
+
+LOCAL putcxop(p)
+expptr p;
+{
+struct addrblock *putcx1();
+int ncomma;
+
+ncomma = 0;
+putaddr( putcx1(p, &ncomma), NO);
+putcomma(ncomma, TYINT, NO);
+}
+
+
+
+LOCAL struct addrblock *putcx1(p, ncommap)
+register expptr p;
+int *ncommap;
+{
+struct addrblock *q, *lp, *rp;
+register struct addrblock *resp;
+int opcode;
+int ltype, rtype;
+
+if(p == NULL)
+       return(NULL);
+
+switch(p->tag)
+       {
+       case TCONST:
+               if( ISCOMPLEX(p->vtype) )
+                       p = putconst(p);
+               return( p );
+
+       case TADDR:
+               if( ! addressable(p) )
+                       {
+                       ++*ncommap;
+                       resp = mktemp(tyint, NULL);
+                       putassign( cpexpr(resp), p->memoffset );
+                       p->memoffset = resp;
+                       }
+               return( p );
+
+       case TEXPR:
+               if( ISCOMPLEX(p->vtype) )
+                       break;
+               ++*ncommap;
+               resp = mktemp(TYDREAL, NO);
+               putassign( cpexpr(resp), p);
+               return(resp);
+
+       default:
+               fatal1("putcx1: bad tag %d", p->tag);
+       }
+
+opcode = p->opcode;
+if(opcode==OPCALL || opcode==OPCCALL)
+       {
+       ++*ncommap;
+       return( putcall(p) );
+       }
+else if(opcode == OPASSIGN)
+       {
+       ++*ncommap;
+       return( putcxeq(p) );
+       }
+resp = mktemp(p->vtype, NULL);
+if(lp = putcx1(p->leftp, ncommap) )
+       ltype = lp->vtype;
+if(rp = putcx1(p->rightp, ncommap) )
+       rtype = rp->vtype;
+
+switch(opcode)
+       {
+       case OPCOMMA:
+               frexpr(resp);
+               resp = rp;
+               rp = NULL;
+               break;
+
+       case OPNEG:
+               putassign( realpart(resp), mkexpr(OPNEG, realpart(lp), NULL) );
+               putassign( imagpart(resp), mkexpr(OPNEG, imagpart(lp), NULL) );
+               *ncommap += 2;
+               break;
+
+       case OPPLUS:
+       case OPMINUS:
+               putassign( realpart(resp), mkexpr(opcode, realpart(lp), realpart(rp) ));
+               if(rtype < TYCOMPLEX)
+                       putassign( imagpart(resp), imagpart(lp) );
+               else if(ltype < TYCOMPLEX)
+                       {
+                       if(opcode == OPPLUS)
+                               putassign( imagpart(resp), imagpart(rp) );
+                       else    putassign( imagpart(resp), mkexpr(OPNEG, imagpart(rp), NULL) );
+                       }
+               else
+                       putassign( imagpart(resp), mkexpr(opcode, imagpart(lp), imagpart(rp) ));
+
+               *ncommap += 2;
+               break;
+
+       case OPSTAR:
+               if(ltype < TYCOMPLEX)
+                       {
+                       if( ISINT(ltype) )
+                               lp = intdouble(lp, ncommap);
+                       putassign( realpart(resp), mkexpr(OPSTAR, cpexpr(lp), realpart(rp) ));
+                       putassign( imagpart(resp), mkexpr(OPSTAR, cpexpr(lp), imagpart(rp) ));
+                       }
+               else if(rtype < TYCOMPLEX)
+                       {
+                       if( ISINT(rtype) )
+                               rp = intdouble(rp, ncommap);
+                       putassign( realpart(resp), mkexpr(OPSTAR, cpexpr(rp), realpart(lp) ));
+                       putassign( imagpart(resp), mkexpr(OPSTAR, cpexpr(rp), imagpart(lp) ));
+                       }
+               else    {
+                       putassign( realpart(resp), mkexpr(OPMINUS,
+                               mkexpr(OPSTAR, realpart(lp), realpart(rp)),
+                               mkexpr(OPSTAR, imagpart(lp), imagpart(rp)) ));
+                       putassign( imagpart(resp), mkexpr(OPPLUS,
+                               mkexpr(OPSTAR, realpart(lp), imagpart(rp)),
+                               mkexpr(OPSTAR, imagpart(lp), realpart(rp)) ));
+                       }
+               *ncommap += 2;
+               break;
+
+       case OPSLASH:
+               /* fixexpr has already replaced all divisions
+                * by a complex by a function call
+                */
+               if( ISINT(rtype) )
+                       rp = intdouble(rp, ncommap);
+               putassign( realpart(resp), mkexpr(OPSLASH, realpart(lp), cpexpr(rp)) );
+               putassign( imagpart(resp), mkexpr(OPSLASH, imagpart(lp), cpexpr(rp)) );
+               *ncommap += 2;
+               break;
+
+       case OPCONV:
+               putassign( realpart(resp), realpart(lp) );
+               if( ISCOMPLEX(lp->vtype) )
+                       q = imagpart(lp);
+               else if(rp != NULL)
+                       q = realpart(rp);
+               else
+                       q = mkrealcon(TYDREAL, 0.0);
+               putassign( imagpart(resp), q);
+               *ncommap += 2;
+               break;
+
+       default:
+               fatal1("putcx1 of invalid opcode %d", opcode);
+       }
+
+frexpr(lp);
+frexpr(rp);
+free(p);
+return(resp);
+}
+
+
+
+
+LOCAL putcxcmp(p)
+register struct exprblock *p;
+{
+int opcode;
+int ncomma;
+register struct addrblock *lp, *rp;
+struct exprblock *q;
+
+ncomma = 0;
+opcode = p->opcode;
+lp = putcx1(p->leftp, &ncomma);
+rp = putcx1(p->rightp, &ncomma);
+
+q = mkexpr( opcode==OPEQ ? OPAND : OPOR ,
+       mkexpr(opcode, realpart(lp), realpart(rp)),
+       mkexpr(opcode, imagpart(lp), imagpart(rp)) );
+putx( fixexpr(q) );
+putcomma(ncomma, TYINT, NO);
+
+free(lp);
+free(rp);
+free(p);
+}
+\f
+LOCAL struct addrblock *putch1(p, ncommap)
+register expptr p;
+int * ncommap;
+{
+register struct addrblock *t;
+struct addrblock *mktemp(), *putconst();
+
+switch(p->tag)
+       {
+       case TCONST:
+               return( putconst(p) );
+
+       case TADDR:
+               return(p);
+
+       case TEXPR:
+               ++*ncommap;
+
+               switch(p->opcode)
+                       {
+                       case OPCALL:
+                       case OPCCALL:
+                               t = putcall(p);
+                               break;
+
+                       case OPCONCAT:
+                               t = mktemp(TYCHAR, cpexpr(p->vleng) );
+                               putcat( cpexpr(t), p );
+                               break;
+
+                       case OPCONV:
+                               if(!ISICON(p->vleng) || p->vleng->const.ci!=1
+                                  || ! INT(p->leftp->vtype) )
+                                       fatal("putch1: bad character conversion");
+                               t = mktemp(TYCHAR, ICON(1) );
+                               putassign( cpexpr(t), p);
+                               break;
+                       default:
+                               fatal1("putch1: invalid opcode %d", p->opcode);
+                       }
+               return(t);
+
+       default:
+               fatal1("putch1: bad tag %d", p->tag);
+       }
+/* NOTREACHED */
+}
+\f
+
+
+
+LOCAL putchop(p)
+expptr p;
+{
+int ncomma;
+
+ncomma = 0;
+putaddr( putch1(p, &ncomma) , NO );
+putcomma(ncomma, TYCHAR, YES);
+}
+
+
+
+
+LOCAL putcheq(p)
+register struct exprblock *p;
+{
+int ncomma;
+
+ncomma = 0;
+if( p->rightp->tag==TEXPR && p->rightp->opcode==OPCONCAT )
+       putcat(p->leftp, p->rightp);
+else if( ISONE(p->leftp->vleng) && ISONE(p->rightp->vleng) )
+       {
+       putaddr( putch1(p->leftp, &ncomma) , YES );
+       putaddr( putch1(p->rightp, &ncomma) , YES );
+       p2op(P2ASSIGN, P2CHAR);
+       }
+else   putx( call2(TYINT, "s_copy", p->leftp, p->rightp) );
+
+putcomma(ncomma, TYINT, NO);
+frexpr(p->vleng);
+free(p);
+}
+
+
+
+
+LOCAL putchcmp(p)
+register struct exprblock *p;
+{
+int ncomma;
+
+ncomma = 0;
+if(ISONE(p->leftp->vleng) && ISONE(p->rightp->vleng) )
+       {
+       putaddr( putch1(p->leftp, &ncomma) , YES );
+       putaddr( putch1(p->rightp, &ncomma) , YES );
+       p2op(ops2[p->opcode], P2CHAR);
+       free(p);
+       putcomma(ncomma, TYINT, NO);
+       }
+else
+       {
+       p->leftp = call2(TYINT,"s_cmp", p->leftp, p->rightp);
+       p->rightp = ICON(0);
+       putop(p);
+       }
+}
+
+
+
+
+
+LOCAL putcat(lhs, rhs)
+register struct addrblock *lhs;
+register expptr rhs;
+{
+int n, ncomma;
+struct addrblock *lp, *cp;
+
+ncomma = 0;
+n = ncat(rhs);
+lp = mktmpn(n, TYLENG, NULL);
+cp = mktmpn(n, TYADDR, NULL);
+
+n = 0;
+putct1(rhs, lp, cp, &n, &ncomma);
+
+putx( call4(TYSUBR, "s_cat", lhs, cp, lp, ICON(n) ) );
+putcomma(ncomma, TYINT, NO);
+}
+
+
+
+
+
+LOCAL ncat(p)
+register expptr p;
+{
+if(p->tag==TEXPR && p->opcode==OPCONCAT)
+       return( ncat(p->leftp) + ncat(p->rightp) );
+else   return(1);
+}
+
+
+
+
+LOCAL putct1(q, lp, cp, ip, ncommap)
+register expptr q;
+register struct addrblock *lp, *cp;
+int *ip, *ncommap;
+{
+int i;
+struct addrblock *lp1, *cp1;
+
+if(q->tag==TEXPR && q->opcode==OPCONCAT)
+       {
+       putct1(q->leftp, lp, cp, ip, ncommap);
+       putct1(q->rightp, lp, cp , ip, ncommap);
+       frexpr(q->vleng);
+       free(q);
+       }
+else
+       {
+       i = (*ip)++;
+       lp1 = cpexpr(lp);
+       lp1->memoffset = mkexpr(OPPLUS, lp1->memoffset, ICON(i*SZLENG));
+       cp1 = cpexpr(cp);
+       cp1->memoffset = mkexpr(OPPLUS, cp1->memoffset, ICON(i*SZADDR));
+       putassign( lp1, cpexpr(q->vleng) );
+       putassign( cp1, addrof(putch1(q,ncommap)) );
+       *ncommap += 2;
+       }
+}
+\f
+LOCAL putaddr(p, indir)
+register struct addrblock *p;
+int indir;
+{
+int type, type2, funct;
+ftnint offset, simoffset();
+expptr offp, shorten();
+
+type = p->vtype;
+type2 = types2[type];
+funct = (p->vclass==CLPROC ? P2FUNCT<<2 : 0);
+
+offp = (p->memoffset ? cpexpr(p->memoffset) : NULL);
+
+
+#if (FUDGEOFFSET != 1)
+if(offp)
+       offp = mkexpr(OPSTAR, ICON(FUDGEOFFSET), offp);
+#endif
+
+offset = simoffset( &offp );
+#if SZINT < SZLONG
+       if(offp)
+               if(shortsubs)
+                       offp = shorten(offp);
+               else
+                       offp = mkconv(TYINT, offp);
+#else
+       if(offp)
+               offp = mkconv(TYINT, offp);
+#endif
+
+switch(p->vstg)
+       {
+       case STGAUTO:
+               if(indir && !offp)
+                       {
+                       p2oreg(offset, AUTOREG, type2);
+                       break;
+                       }
+
+               if(!indir && !offp && !offset)
+                       {
+                       p2reg(AUTOREG, type2 | P2PTR);
+                       break;
+                       }
+
+               p2reg(AUTOREG, type2 | P2PTR);
+               if(offp)
+                       {
+                       putx(offp);
+                       if(offset)
+                               p2icon(offset, P2INT);
+                       }
+               else
+                       p2icon(offset, P2INT);
+               if(offp && offset)
+                       p2op(P2PLUS, type2 | P2PTR);
+               p2op(P2PLUS, type2 | P2PTR);
+               if(offp && offset)
+               if(indir)
+                       p2op(P2INDIRECT, type2);
+               break;
+
+       case STGARG:
+               p2oreg(
+#ifdef ARGOFFSET
+                       ARGOFFSET +
+#endif
+                       (ftnint) (FUDGEOFFSET*p->memno),
+                       ARGREG,   type2 | P2PTR | funct );
+
+               if(offp)
+                       putx(offp);
+               if(offset)
+                       p2icon(offset, P2INT);
+               if(offp && offset)
+                       p2op(P2PLUS, type2 | P2PTR);
+               if(offp || offset)
+                       p2op(P2PLUS, type2 | P2PTR);
+               if(indir)
+                       p2op(P2INDIRECT, type2);
+               break;
+
+       case STGLENG:
+               if(indir)
+                       {
+                       p2oreg(
+#ifdef ARGOFFSET
+                               ARGOFFSET +
+#endif
+                               (ftnint) (FUDGEOFFSET*p->memno),
+                               ARGREG,   type2 | P2PTR | funct);
+                       }
+               else    {
+                       p2op(P2PLUS, types2[TYLENG] | P2PTR );
+                       p2reg(ARGREG, types2[TYLENG] | P2PTR );
+                       p2icon(
+#ifdef ARGOFFSET
+                               ARGOFFSET +
+#endif
+                               (ftnint) (FUDGEOFFSET*p->memno), P2INT);
+                       }
+               break;
+
+
+       case STGBSS:
+       case STGINIT:
+       case STGEXT:
+       case STGCOMMON:
+       case STGEQUIV:
+       case STGCONST:
+               if(offp)
+                       {
+                       putx(offp);
+                       putmem(p, P2ICON, offset);
+                       p2op(P2PLUS, type2 | P2PTR);
+                       if(indir)
+                               p2op(P2INDIRECT, type2);
+                       }
+               else
+                       putmem(p, (indir ? P2NAME : P2ICON), offset);
+
+               break;
+
+       case STGREG:
+               if(indir)
+                       p2reg(p->memno, type2);
+               else
+                       fatal("attempt to take address of a register");
+               break;
+
+       default:
+               fatal1("putaddr: invalid vstg %d", p->vstg);
+       }
+frexpr(p);
+}
+
+
+
+
+LOCAL putmem(p, class, offset)
+expptr p;
+int class;
+ftnint offset;
+{
+int type2;
+int funct;
+char *name,  *memname();
+
+funct = (p->vclass==CLPROC ? P2FUNCT<<2 : 0);
+type2 = types2[p->vtype];
+if(p->vclass == CLPROC)
+       type2 |= (P2FUNCT<<2);
+name = memname(p->vstg, p->memno);
+if(class == P2ICON)
+       {
+       p2triple(P2ICON, name[0]!='\0', type2|P2PTR);
+       p2word(offset);
+       if(name[0])
+               p2name(name);
+       }
+else
+       {
+       p2triple(P2NAME, offset!=0, type2);
+       if(offset != 0)
+               p2word(offset);
+       p2name(name);
+       }
+}
+
+
+\f
+LOCAL struct addrblock *putcall(p)
+struct exprblock *p;
+{
+chainp arglist, charsp, cp;
+int n, first;
+struct addrblock *t;
+struct exprblock *q;
+struct exprblock *fval;
+int type, type2, ctype, indir;
+
+type2 = types2[type = p->vtype];
+charsp = NULL;
+indir =  (p->opcode == OPCCALL);
+n = 0;
+first = YES;
+
+if(p->rightp)
+       {
+       arglist = p->rightp->listp;
+       free(p->rightp);
+       }
+else
+       arglist = NULL;
+
+for(cp = arglist ; cp ; cp = cp->nextp)
+       if(indir)
+               ++n;
+       else    {
+               q = cp->datap;
+               if(q->tag == TCONST)
+                       cp->datap = q = putconst(q);
+               if( ISCHAR(q) )
+                       {
+                       charsp = hookup(charsp, mkchain(cpexpr(q->vleng), 0) );
+                       n += 2;
+                       }
+               else if(q->vclass == CLPROC)
+                       {
+                       charsp = hookup(charsp, mkchain( ICON(0) , 0));
+                       n += 2;
+                       }
+               else
+                       n += 1;
+               }
+
+if(type == TYCHAR)
+       {
+       if( ISICON(p->vleng) )
+               {
+               fval = mktemp(TYCHAR, p->vleng);
+               n += 2;
+               }
+       else    {
+               err("adjustable character function");
+               return;
+               }
+       }
+else if( ISCOMPLEX(type) )
+       {
+       fval = mktemp(type, NULL);
+       n += 1;
+       }
+else
+       fval = NULL;
+
+ctype = (fval ? P2INT : type2);
+putaddr(p->leftp, NO);
+
+if(fval)
+       {
+       first = NO;
+       putaddr( cpexpr(fval), NO);
+       if(type==TYCHAR)
+               {
+               putx( cpexpr(p->vleng) );
+               p2op(P2LISTOP, type2);
+               }
+       }
+
+for(cp = arglist ; cp ; cp = cp->nextp)
+       {
+       q = cp->datap;
+       if(q->tag==TADDR && (indir || q->vstg!=STGREG) )
+               putaddr(q, indir && q->vtype!=TYCHAR);
+       else if( ISCOMPLEX(q->vtype) )
+               putcxop(q);
+       else if (ISCHAR(q) )
+               putchop(q);
+       else if( ! ISERROR(q) )
+               {
+               if(indir)
+                       putx(q);
+               else    {
+                       t = mktemp(q->vtype, q->vleng);
+                       putassign( cpexpr(t), q );
+                       putaddr(t, NO);
+                       putcomma(1, q->vtype, YES);
+                       }
+               }
+       if(first)
+               first = NO;
+       else
+               p2op(P2LISTOP, type2);
+       }
+
+if(arglist)
+       frchain(&arglist);
+for(cp = charsp ; cp ; cp = cp->nextp)
+       {
+       putx( mkconv(TYLENG,cp->datap) );
+       p2op(P2LISTOP, type2);
+       }
+frchain(&charsp);
+p2op(n>0 ? P2CALL : P2CALL0 , ctype);
+free(p);
+return(fval);
+}
+
+
+
+LOCAL putmnmx(p)
+register struct exprblock *p;
+{
+int op, type;
+int ncomma;
+struct exprblock *qp;
+chainp p0, p1;
+struct addrblock *sp, *tp;
+
+type = p->vtype;
+op = (p->opcode==OPMIN ? OPLT : OPGT );
+p0 = p->leftp->listp;
+free(p->leftp);
+free(p);
+
+sp = mktemp(type, NULL);
+tp = mktemp(type, NULL);
+qp = mkexpr(OPCOLON, cpexpr(tp), cpexpr(sp));
+qp = mkexpr(OPQUEST, mkexpr(op, cpexpr(tp),cpexpr(sp)), qp);
+qp = fixexpr(qp);
+
+ncomma = 1;
+putassign( cpexpr(sp), p0->datap );
+
+for(p1 = p0->nextp ; p1 ; p1 = p1->nextp)
+       {
+       ++ncomma;
+       putassign( cpexpr(tp), p1->datap );
+       if(p1->nextp)
+               {
+               ++ncomma;
+               putassign( cpexpr(sp), cpexpr(qp) );
+               }
+       else
+               putx(qp);
+       }
+
+putcomma(ncomma, type, NO);
+frtemp(sp);
+frtemp(tp);
+frchain( &p0 );
+}
+
+
+
+
+LOCAL putcomma(n, type, indir)
+int n, type, indir;
+{
+type = types2[type];
+if(indir)
+       type |= P2PTR;
+while(--n >= 0)
+       p2op(P2COMOP, type);
+}
+
+
+
+
+ftnint simoffset(p0)
+expptr *p0;
+{
+ftnint offset, prod;
+register expptr p, lp, rp;
+
+offset = 0;
+p = *p0;
+if(p == NULL)
+       return(0);
+
+if( ! ISINT(p->vtype) )
+       return(0);
+
+if(p->tag==TEXPR && p->opcode==OPSTAR)
+       {
+       lp = p->leftp;
+       rp = p->rightp;
+       if(ISICON(rp) && lp->tag==TEXPR && lp->opcode==OPPLUS && ISICON(lp->rightp))
+               {
+               p->opcode = OPPLUS;
+               lp->opcode = OPSTAR;
+               prod = rp->const.ci * lp->rightp->const.ci;
+               lp->rightp->const.ci = rp->const.ci;
+               rp->const.ci = prod;
+               }
+       }
+
+if(p->tag==TEXPR && p->opcode==OPPLUS && ISICON(p->rightp))
+       {
+       rp = p->rightp;
+       lp = p->leftp;
+       offset += rp->const.ci;
+       frexpr(rp);
+       free(p);
+       *p0 = lp;
+       }
+
+if(p->tag == TCONST)
+       {
+       offset += p->const.ci;
+       frexpr(p);
+       *p0 = NULL;
+       }
+
+return(offset);
+}
+\f
+
+
+
+
+p2op(op, type)
+int op, type;
+{
+p2triple(op, 0, type);
+}
+
+p2icon(offset, type)
+ftnint offset;
+int type;
+{
+p2triple(P2ICON, 0, type);
+p2word(offset);
+}
+
+
+
+
+p2oreg(offset, reg, type)
+ftnint offset;
+int reg, type;
+{
+p2triple(P2OREG, reg, type);
+p2word(offset);
+p2name("");
+}
+
+
+
+
+p2reg(reg, type)
+int reg, type;
+{
+p2triple(P2REG, reg, type);
+}
+
+
+
+p2pass(s)
+char *s;
+{
+p2triple(P2PASS, (strlen(s) + FOUR-1)/FOUR, 0);
+p2str(s);
+}
+
+
+
+
+p2str(s)
+register char *s;
+{
+union { long int word; char str[FOUR]; } u;
+register int i;
+
+i = 0;
+u.word = 0;
+while(*s)
+       {
+       u.str[i++] = *s++;
+       if(i == FOUR)
+               {
+               p2word(u.word);
+               u.word = 0;
+               i = 0;
+               }
+       }
+if(i > 0)
+       p2word(u.word);
+}
+
+
+
+
+p2triple(op, var, type)
+int op, var, type;
+{
+register long word;
+word = op | (var<<8);
+word |= ( (long int) type) <<16;
+p2word(word);
+}
+
+
+
+
+p2name(s)
+char *s;
+{
+int i;
+union  { long int word[2];  char str[8]; } u;
+
+u.word[0] = u.word[1] = 0;
+for(i = 0 ; i<8 && *s ; ++i)
+       u.str[i] = *s++;
+p2word(u.word[0]);
+p2word(u.word[1]);
+}
+
+
+
+
+p2word(w)
+long int w;
+{
+*p2bufp++ = w;
+if(p2bufp >= p2bufend)
+       p2flush();
+}
+
+
+
+p2flush()
+{
+if(p2bufp > p2buff)
+       write(fileno(textfile), p2buff, (p2bufp-p2buff)*sizeof(long int));
+p2bufp = p2buff;
+}
diff --git a/usr/src/cmd/f77/vax.c b/usr/src/cmd/f77/vax.c
new file mode 100644 (file)
index 0000000..8d410e9
--- /dev/null
@@ -0,0 +1,355 @@
+#include "defs"
+#if OUTPUT==BINARY
+#      include "scjdefs"
+#endif
+
+/*
+       PDP11-780/VAX - SPECIFIC PRINTING ROUTINES
+*/
+
+static char textline[50];
+int maxregvar = MAXREGVAR;
+int regnum[] =  { 11, 10, 9, 8, 7, 6 } ;
+static int regmask[] = { 0, 0x800, 0xc00, 0xe00, 0xf00, 0xf80, 0xfc0 };
+
+
+
+
+prsave()
+{
+int proflab;
+p2pass( sprintf(textline, "\t.word\t0x%x", regmask[highregvar]) );     /*  register variable mask */
+if(profileflag)
+       {
+       proflab = newlabel();
+       fprintf(asmfile, "L%d:\t.space\t4\n", proflab);
+       p2pass( sprintf(textline, "\tmovab\tL%d,r0", proflab) );
+       p2pass( sprintf(textline, "\tjsb\tmcount") );
+       }
+p2pass( sprintf(textline, "\tsubl2\t$.F%d,sp", procno) );
+}
+
+
+
+goret(type)
+int type;
+{
+p2pass( sprintf(textline, "\tret") );
+}
+
+
+
+
+/*
+ * move argument slot arg1 (relative to ap)
+ * to slot arg2 (relative to ARGREG)
+ */
+
+mvarg(type, arg1, arg2)
+int type, arg1, arg2;
+{
+p2pass( sprintf(textline, "\tmovl\t%d(ap),%d(fp)", arg1+ARGOFFSET, arg2+argloc) );
+}
+
+
+
+
+prlabel(fp, k)
+FILEP fp;
+int k;
+{
+fprintf(fp, "L%d:\n", k);
+}
+
+
+
+prconi(fp, type, n)
+FILEP fp;
+int type;
+ftnint n;
+{
+fprintf(fp, "\t%s\t%ld\n", (type==TYSHORT ? ".word" : ".long"), n);
+}
+
+
+
+prcona(fp, a)
+FILEP fp;
+ftnint a;
+{
+fprintf(fp, "\t.long\tL%ld\n", a);
+}
+
+
+
+#ifndef vax
+prconr(fp, type, x)
+FILEP fp;
+int type;
+float x;
+{
+fprintf(fp, "\t%s\t0f%e\n", (type==TYREAL ? ".float" : ".double"), x);
+}
+#endif
+
+#ifdef vax
+prconr(fp, type, x)
+FILEP fp;
+int type;
+double x;
+{
+long int *n;
+n = &x;        /* nonportable cheat */
+if(type == TYREAL)
+       fprintf(fp, "\t.long\t0x%X\n", n[0]);
+else
+       fprintf(fp, "\t.long\t0x%X,0x%X\n", n[0], n[1]);
+}
+#endif
+
+
+
+
+
+
+
+preven(k)
+int k;
+{
+register int lg;
+
+if(k > 4)
+       lg = 3;
+else if(k > 2)
+       lg = 2;
+else if(k > 1)
+       lg = 1;
+else
+       return;
+fprintf(asmfile, "\t.align\t%d\n", lg);
+}
+
+
+
+vaxgoto(index, nlab, labs)
+expptr index;
+register int nlab;
+struct labelblock *labs[];
+{
+register int i;
+register int arrlab;
+
+putforce(TYINT, index);
+p2pass( sprintf(textline, "\tcasel\tr0,$1,$%d", nlab-1) );
+p2pass( sprintf(textline, "L%d:", arrlab = newlabel() ) );
+for(i = 0; i< nlab ; ++i)
+       p2pass( sprintf(textline, "\t.word\tL%d-L%d", labs[i]->labelno, arrlab) );
+}
+
+
+prarif(p, neg, zer, pos)
+ptr p;
+int neg, zer, pos;
+{
+putforce(p->vtype, p);
+if( ISINT(p->vtype) )
+       p2pass( sprintf(textline, "\ttstl\tr0") );
+else
+       p2pass( sprintf(textline, "\ttstd\tr0") );
+p2pass( sprintf(textline, "\tjlss\tL%d", neg) );
+p2pass( sprintf(textline, "\tjeql\tL%d", zer) );
+p2pass( sprintf(textline, "\tjbr\tL%d", pos) );
+}
+
+
+
+
+char *memname(stg, mem)
+int stg, mem;
+{
+static char s[20];
+
+switch(stg)
+       {
+       case STGCOMMON:
+       case STGEXT:
+               sprintf(s, "_%s", varstr(XL, extsymtab[mem].extname) );
+               break;
+
+       case STGBSS:
+       case STGINIT:
+               sprintf(s, "v.%d", mem);
+               break;
+
+       case STGCONST:
+               sprintf(s, "L%d", mem);
+               break;
+
+       case STGEQUIV:
+               sprintf(s, "q.%d", mem);
+               break;
+
+       default:
+               fatal1("memname: invalid vstg %d", stg);
+       }
+return(s);
+}
+
+
+
+
+prlocvar(s, len)
+char *s;
+ftnint len;
+{
+fprintf(asmfile, "\t.lcomm\t%s,%ld\n", s, len);
+}
+
+
+
+prext(name, leng, init)
+char *name;
+ftnint leng;
+int init;
+{
+if(leng == 0)
+       fprintf(asmfile, "\t.globl\t_%s\n", name);
+else
+       fprintf(asmfile, "\t.comm\t_%s,%ld\n", name, leng);
+}
+
+
+
+
+
+prendproc()
+{
+}
+
+
+
+
+prtail()
+{
+}
+
+
+
+
+
+prolog(ep, argvec)
+struct entrypoint *ep;
+struct addrblock *argvec;
+{
+int i, argslot, proflab;
+int size;
+register chainp p;
+register struct nameblock *q;
+register struct dimblock *dp;
+expptr tp;
+
+if(procclass == CLMAIN)
+       p2pass( "_MAIN__:" );
+if(ep->entryname)
+       p2pass( sprintf(textline, "_%s:",  varstr(XL, ep->entryname->extname)) );
+if(procclass == CLBLOCK)
+       return;
+prsave();
+if(argvec)
+       {
+       argloc = argvec->memoffset->const.ci;
+       if(proctype == TYCHAR)
+               {
+               mvarg(TYADDR, 0, chslot);
+               mvarg(TYLENG, SZADDR, chlgslot);
+               argslot = SZADDR + SZLENG;
+               }
+       else if( ISCOMPLEX(proctype) )
+               {
+               mvarg(TYADDR, 0, cxslot);
+               argslot = SZADDR;
+               }
+       else
+               argslot = 0;
+
+       for(p = ep->arglist ; p ; p =p->nextp)
+               {
+               q = p->datap;
+               mvarg(TYADDR, argslot, q->vardesc.varno);
+               argslot += SZADDR;
+               }
+       for(p = ep->arglist ; p ; p = p->nextp)
+               {
+               q = p->datap;
+               if(q->vtype==TYCHAR || q->vclass==CLPROC)
+                       {
+                       if(q->vleng && q->vleng->tag!=TCONST)
+                               mvarg(TYLENG, argslot, q->vleng->vardesc.varno);
+                       argslot += SZLENG;
+                       }
+               }
+       p2pass( sprintf(textline, "\taddl3\t$%d,fp,ap", argloc-ARGOFFSET) );
+       }
+
+for(p = ep->arglist ; p ; p = p->nextp)
+       {
+       q = p->datap;
+       if(dp = q->vdim)
+               {
+               for(i = 0 ; i < dp->ndim ; ++i)
+                       if(dp->dims[i].dimexpr)
+                               puteq( fixtype(cpexpr(dp->dims[i].dimsize)),
+                                       fixtype(cpexpr(dp->dims[i].dimexpr)));
+               size = typesize[ q->vtype ];
+               /* on VAX, get more efficient subscripting if subscripts
+                  have zero-base, so fudge the argument pointers for arrays.
+                  Not done if array bounds are being checked.
+               */
+               if(dp->basexpr)
+                       {
+                       puteq(  cpexpr(fixtype(dp->baseoffset)),
+                               cpexpr(fixtype(dp->basexpr)));
+                       if(! checksubs)
+                               {
+                               putforce(TYINT,
+                                       fixtype( mkexpr(OPSTAR, ICON(size),
+                                               cpexpr(dp->baseoffset)) ));
+                               p2pass( sprintf(textline, "\tsubl2\tr0,%d(ap)",
+                                       p->datap->vardesc.varno + ARGOFFSET) );
+                               }
+                       }
+               else if(!checksubs && dp->baseoffset->const.ci!=0)
+                       p2pass( sprintf(textline, "\tsubl2\t$%ld,%d(ap)",
+                               dp->baseoffset->const.ci * size,
+                               p->datap->vardesc.varno + ARGOFFSET) );
+               }
+       }
+
+if(typeaddr)
+       puteq( cpexpr(typeaddr), mkaddcon(ep->typelabel) );
+putgoto(ep->entrylabel);
+}
+
+
+
+
+prhead(fp)
+FILEP fp;
+{
+#if FAMILY==SCJ
+#      if OUTPUT == BINARY
+               p2triple(P2LBRACKET, ARGREG-highregvar, procno);
+               p2word( (long) (BITSPERCHAR*autoleng) );
+               p2flush();
+#      else
+               fprintf(fp, "[%02d\t%06ld\t%02d\t\n", procno,
+                       BITSPERCHAR*autoleng, ARGREG-highregvar);
+#      endif
+#endif
+}
+
+
+
+prdbginfo()
+{
+}
diff --git a/usr/src/cmd/f77/vaxdefs b/usr/src/cmd/f77/vaxdefs
new file mode 100644 (file)
index 0000000..8d2a746
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef TARGET
+TARGET NOT DEFINED !!!
+#endif
+#if TARGET!=VAX
+Target= TARGET OUT OF RANGE!!
+#endif
+
+#ifndef FAMILY
+FAMILY NOT DEFINED!!!
+#endif
+#if FAMILY!=SCJ && FAMILY!=DMR
+Family = FAMILY OUT OF RANGE
+#endif
+
+#define TYLENG TYLONG
+
+#define TYINT  TYLONG
+#define SZADDR 4
+#define SZSHORT        2
+#define SZINT  4
+
+#define SZLONG 4
+#define SZLENG SZLONG
+
+#define ALIADDR SZADDR
+#define ALISHORT SZSHORT
+#define ALILONG 4
+#define ALIDOUBLE 4
+#define ALIINT ALILONG
+#define ALILENG        ALILONG
+
+#define AUTOREG 13
+#define ARGREG 12
+#define CARGREG 12
+#define ARGOFFSET 4
+#define SAVESPACE 40
+
+
+#define FUDGEOFFSET 1
+#define BITSPERCHAR 8
+#define XL 8
+
+#define USETEXT        ".text"
+#define USECONST       ".data\t0"
+#define USEBSS ".data\t1"
+#define USEINIT        ".data\t2"
+
+#define BLANKCOMMON "_BLNK_"
+
+#define LABELFMT "%s:\n"
+
+#define MAXREGVAR 4
+#define TYIREG TYLONG
+#define MSKIREG  (M(TYSHORT)|M(TYLONG))
diff --git a/usr/src/cmd/f77/vaxx.c b/usr/src/cmd/f77/vaxx.c
new file mode 100644 (file)
index 0000000..ff35c43
--- /dev/null
@@ -0,0 +1,42 @@
+#include <stdio.h>
+#include "defines"
+#include "locdefs"
+
+
+
+prchars(fp, s)
+FILEP fp;
+int *s;
+{
+
+fprintf(fp, ".byte 0%o,0%o\n", s[0], s[1]);
+}
+
+
+
+pruse(fp, s)
+FILEP fp;
+char *s;
+{
+fprintf(fp, "\t%s\n", s);
+}
+
+
+
+prskip(fp, k)
+FILEP fp;
+ftnint k;
+{
+fprintf(fp, "\t.space\t%ld\n", k);
+}
+
+
+
+
+
+prcomblock(fp, name)
+FILEP fp;
+char *name;
+{
+fprintf(fp, LABELFMT, name);
+}
diff --git a/usr/src/cmd/factor.s b/usr/src/cmd/factor.s
deleted file mode 100644 (file)
index b28f42f..0000000
+++ /dev/null
@@ -1,351 +0,0 @@
-.globl sqrt
-exit = 1.
-read = 3.
-write = 4.
-ldfps = 170100^tst
-/
-       ldfps   $240
-
-       clr     argflg
-       cmp     (sp)+,$2
-       blt     begin
-       tst     (sp)+
-       mov     (sp),r2
-       jsr     r5,atof; getch1
-       inc     argflg
-       br      begin1
-begin:
-       tst     argflg
-       beq 9f; sys exit; 9:
-       jsr     r5,atof; getch
-begin1:
-       tstf    fr0
-       cfcc
-       bpl 9f; jmp ouch; 9:
-       bne 9f; sys exit; 9:
-       cmpf    big,fr0
-       cfcc
-       bgt 9f; jmp ouch; 9:
-/
-       movf    fr0,n
-       jsr     pc,sqrt
-       movf    fr0,v
-       mov     $1,r0
-       sys     write; nl; 1
-/
-       movf    $one,fr0
-       movf    fr0,fr4
-/
-       movf    n,fr0
-       movf    $two,fr1
-       jsr     r5,xt
-/
-       movf    n,fr0
-       movif   $3,fr1
-       jsr     r5,xt
-/
-       movf    n,fr0
-       movif   $5,fr1
-       jsr     r5,xt
-/
-       movf    n,fr0
-       movif   $7,fr1
-       jsr     r5,xt
-/
-       movf    n,fr0
-       movif   $11.,fr1
-       jsr     r5,xt
-/
-       movf    n,fr0
-       movif   $13.,fr1
-       jsr     r5,xt
-/
-       movf    n,fr0
-       movif   $17.,fr1
-       mov     $tab+6,r4
-       jsr     pc,xx
-       jmp     begin
-/
-xt:
-       movf    fr0,fr2
-       divf    fr1,fr2
-       modf    $one,fr2
-       movf    fr3,fr2
-       mulf    fr1,fr2
-       cmpf    fr2,fr0
-       cfcc
-       beq     hit2
-       rts     r5
-/
-/
-out1:
-       mov     $tab,r4
-       br      in1
-
-out2:
-       modf    fr4,fr2
-       cfcc
-       bne 9f; mov $xx0,-(sp); jmp hit; 9:
-       br      in2
-xx:
-       mov     (r4)+,kazoo
-xx0:
-       mov     $kazoo,r0
-       mov     $100.,r1
-       clr     r2
-       mov     $gorp,r3
-       mov     $gorp+6,r5
-xx1:
-       movf    fr0,fr2
-       divf    fr1,fr2
-       cmp     r4,$tabend
-       bhis    out1
-in1:
-       movf    fr2,(r3)
-       bit     r2,(r5)
-       beq     out2
-in2:
-kazoo  =.+2
-       addf    $kazoo,fr1
-       mov     (r4)+,(r0)
-       sob     r1,xx1
-       mov     $100.,r1
-       mov     $127.,r2
-       cmpf    v,fr1
-       cfcc
-       bge     xx1
-       cmpf    $one,fr0
-       cfcc
-       beq     1f
-       mov     $1,r0
-       sys     write; sp5; 5
-       movf    n,fr0
-       jsr     r5,ftoa; wrchar
-       mov     $1,r0
-       sys     write; nl; 1
-1:
-       rts     pc
-/
-/
-/
-hit2:
-       movf    fr1,t
-       movf    fr3,n
-       movf    fr3,fr0
-       jsr     pc,sqrt
-       movf    fr0,v
-       mov     $1,r0
-       sys     write; sp5; 5
-       movf    t,fr0
-       jsr     r5,ftoa; wrchar
-       mov     $1,r0
-       sys     write; nl; 1
-       movf    n,fr0
-       movf    t,fr1
-       cmp     r4,$tab
-       bne     1f
-       mov     $tabend,r4
-1:
-       mov     -(r4),kazoo
-       jmp     xt
-/
-hit:
-       movf    fr1,t
-       movf    fr3,n
-       movf    fr3,fr0
-       jsr     pc,sqrt
-       movf    fr0,v
-       mov     $1,r0
-       sys     write; sp5; 5
-       movf    t,fr0
-       jsr     r5,ftoa; wrchar
-       mov     $1,r0
-       sys     write; nl; 1
-       movf    n,fr0
-       movf    t,fr1
-       mov     $kazoo,r0
-       rts     pc
-/
-/
-/      get one character from the console.
-/      called from atof.
-/
-getch:
-       clr     r0
-       sys     read; ch; 1
-       bec 9f; sys exit; 9:
-       tst r0; bne 9f; sys exit; 9:
-       mov     ch,r0
-       rts     r5
-/
-/
-/      get one character form the argument string.
-getch1:
-       movb    (r2)+,r0
-       rts     r5
-/
-/      write one character on the console
-/      called from ftoa.
-/
-wrchar:
-       mov     r0,ch
-       mov     $1,r0
-       sys     write; ch; 1
-       rts     r5
-/
-/
-/      read and convert a line from the console into fr0.
-/
-atof:
-       mov     r1,-(sp)
-       movif   $10.,r3
-       clrf    r0
-1:
-       jsr     r5,*(r5)
-       sub     $'0,r0
-       cmp     r0,$9.
-       bhi     2f
-       mulf    r3,r0
-       movif   r0,r1
-       addf    r1,r0
-       br      1b
-2:
-       cmp     r0,$' -'0
-       beq     1b
-/
-       mov     (sp)+,r1
-       tst     (r5)+
-       rts     r5
-
-/
-/
-/
-/
-ftoa:
-       mov     $ebuf,r2
-1:
-       modf    tenth,fr0
-       movf    fr0,fr2
-       movf    fr1,fr0
-       addf    $epsilon,fr2
-       modf    $ten,fr2
-       movfi   fr3,r0
-       movb    r0,-(r2)
-       tstf    fr0
-       cfcc
-       bne     1b
-1:
-       movb    (r2)+,r0
-       add     $60,r0
-       jsr     r5,*(r5)
-       cmp     r2,$ebuf
-       blo     1b
-       tst     (r5)+
-       rts     r5
-/
-epsilon = 037114
-tenth: 037314; 146314; 146314; 146315
-       .bss
-buf:   .=.+18.
-ebuf:
-       .text
-/
-/
-/
-/      complain about a number which the program
-/      is unable to digest
-ouch:
-       mov     $2,r0
-       sys     write; 1f; 2f-1f
-       jmp     begin
-/
-1:     <Ouch.\n>
-2:     .even
-/
-/
-one    = 40200
-two    = 40400
-four   = 40600
-ten    = 41040
-/
-       .data
-big:   056177; 177777; 177777; 177777
-nl:    <\n>
-sp5:   <     >
-       .even
-/
-tab:
-       41040; 40400; 40600; 40400; 40600; 40700; 40400; 40700
-       40600; 40400; 40600; 40700; 40700; 40400; 40700; 40600
-       40400; 40700; 40600; 40700; 41000; 40600; 40400; 40600
-       40400; 40600; 41000; 40700; 40600; 40700; 40400; 40600
-       40700; 40400; 40700; 40700; 40600; 40400; 40600; 40700
-       40400; 40700; 40600; 40400; 40600; 40400; 41040; 40400
-tabend:
-/
-       .bss
-ch:    .=.+2
-t:     .=.+8
-n:     .=.+8
-v:     .=.+8
-gorp:  .=.+8
-argflg:        .=.+2
-       .text
-ldfps = 170100^tst
-stfps = 170200^tst
-/
-/      sqrt replaces the f.p. number in fr0 by its
-/      square root.  newton's method
-/
-.globl sqrt, _sqrt
-/
-/
-_sqrt:
-       mov     r5,-(sp)
-       mov     sp,r5
-       movf    4(r5),fr0
-       jsr     pc,sqrt
-       mov     (sp)+,r5
-       rts     pc
-
-sqrt:
-       tstf    fr0
-       cfcc
-       bne     1f
-       clc
-       rts     pc              /sqrt(0)
-1:
-       bgt     1f
-       clrf    fr0
-       sec
-       rts     pc              / sqrt(-a)
-1:
-       mov     r0,-(sp)
-       stfps   -(sp)
-       mov     (sp),r0
-       bic     $!200,r0                / retain mode
-       ldfps   r0
-       movf    fr1,-(sp)
-       movf    fr2,-(sp)
-/
-       movf    fr0,fr1
-       movf    fr0,-(sp)
-       asr     (sp)
-       add     $20100,(sp)
-       movf    (sp)+,fr0       /initial guess
-       mov     $4,r0
-1:
-       movf    fr1,fr2
-       divf    fr0,fr2
-       addf    fr2,fr0
-       mulf    $half,fr0       / x = (x+a/x)/2
-       sob     r0,1b
-2:
-       movf    (sp)+,fr2
-       movf    (sp)+,fr1
-       ldfps   (sp)+
-       mov     (sp)+,r0
-       clc
-       rts     pc
-/
-half   = 40000
diff --git a/usr/src/cmd/false.sh b/usr/src/cmd/false.sh
new file mode 100755 (executable)
index 0000000..379a4c9
--- /dev/null
@@ -0,0 +1 @@
+exit 1
index 826c097..1c8eba9 100644 (file)
@@ -24,7 +24,7 @@ int   bflag, cflag, fflag, lflag, nflag, vflag, xflag;
 int    hflag   = 1;
 int    sflag;
 int    nfile;
 int    hflag   = 1;
 int    sflag;
 int    nfile;
-long   blkno;
+int    blkno;
 int    nsucc;
 long   tln;
 FILE   *wordf;
 int    nsucc;
 long   tln;
 FILE   *wordf;
@@ -117,7 +117,7 @@ char *file;
        register ccount;
        char buf[1024];
        int f;
        register ccount;
        char buf[1024];
        int f;
-       int failed;
+       int failed, ecnt;
        char *nlp;
        if (file) {
                if ((f = open(file, 0)) < 0) {
        char *nlp;
        if (file) {
                if ((f = open(file, 0)) < 0) {
@@ -130,7 +130,7 @@ char *file;
        failed = 0;
        lnum = 1;
        tln = 0;
        failed = 0;
        lnum = 1;
        tln = 0;
-       blkno = 0;
+       blkno = -1;
        p = buf;
        nlp = p;
        c = w;
        p = buf;
        nlp = p;
        c = w;
@@ -141,7 +141,7 @@ char *file;
                                if ((ccount = read(f, p, &buf[1024] - p)) <= 0) break;
                        }
                        else if ((ccount = read(f, p, 512)) <= 0) break;
                                if ((ccount = read(f, p, &buf[1024] - p)) <= 0) break;
                        }
                        else if ((ccount = read(f, p, 512)) <= 0) break;
-                       blkno += ccount;
+                       blkno++;
                }
                nstate:
                        if (c->inp == *p) {
                }
                nstate:
                        if (c->inp == *p) {
@@ -168,38 +168,42 @@ char *file;
                                else goto nstate;
                        }
                if (c->out) {
                                else goto nstate;
                        }
                if (c->out) {
+                       ecnt = 0;
                        while (*p++ != '\n') {
                        while (*p++ != '\n') {
-                               if (--ccount <= 0) {
+                               ecnt++;
+                                  if (--ccount <= 0) {
                                        if (p == &buf[1024]) p = buf;
                                        if (p > &buf[512]) {
                                                if ((ccount = read(f, p, &buf[1024] - p)) <= 0) break;
                                        }
                                        else if ((ccount = read(f, p, 512)) <= 0) break;
                                        if (p == &buf[1024]) p = buf;
                                        if (p > &buf[512]) {
                                                if ((ccount = read(f, p, &buf[1024] - p)) <= 0) break;
                                        }
                                        else if ((ccount = read(f, p, 512)) <= 0) break;
-                                       blkno += ccount;
-                               }
-                       }
-                       if ( (vflag && (failed == 0 || xflag == 0)) || (vflag == 0 && xflag && failed) )
-                               goto nomatch;
-       succeed:        nsucc = 1;
-                       if (cflag) tln++;
-                       else if (sflag)
-                               ;       /* ugh */
-                       else if (lflag) {
-                               printf("%s\n", file);
-                               close(f);
-                               return;
+                                       blkno++;
+                                  }
                        }
                        }
-                       else {
-                               if (nfile > 1 && hflag) printf("%s:", file);
-                               if (bflag) printf("%ld:", (blkno-ccount-1)/512);
-                               if (nflag) printf("%ld:", lnum);
-                               if (p <= nlp) {
-                                       while (nlp < &buf[1024]) putchar(*nlp++);
-                                       nlp = buf;
+                       if (vflag == 0) {
+                               if (xflag)
+                                       if (failed || ecnt > 1) goto nogood;
+               succeed:        nsucc = 1;
+                               if (cflag) tln++;
+                               else if (sflag)
+                                       ;       /* ugh */
+                               else if (lflag) {
+                                       printf("%s\n", file);
+                                       close(f);
+                                       return;
+                               }
+                               else {
+                                       if (nfile > 1 && hflag) printf("%s:", file);
+                                       if (bflag) printf("%d:", blkno);
+                                       if (nflag) printf("%ld:", lnum);
+                                       if (p <= nlp) {
+                                               while (nlp < &buf[1024]) putchar(*nlp++);
+                                               nlp = buf;
+                                       }
+                                       while (nlp < p) putchar(*nlp++);
                                }
                                }
-                               while (nlp < p) putchar(*nlp++);
                        }
                        }
-       nomatch:        lnum++;
+               nogood: lnum++;
                        nlp = p;
                        c = w;
                        failed = 0;
                        nlp = p;
                        c = w;
                        failed = 0;
index b431a4a..f0f53e6 100644 (file)
@@ -13,11 +13,11 @@ char *fort[] = {
        "function","subroutine","common","dimension","block","integer",
        "real","data","double",0};
 char *asc[] = {
        "function","subroutine","common","dimension","block","integer",
        "real","data","double",0};
 char *asc[] = {
-       "sys","mov","tst","clr","jmp",0};
+       "chmk","mov","tst","clr","jmp",0};
 char *c[] = {
        "int","char","float","double","struct","extern",0};
 char *as[] = {
 char *c[] = {
        "int","char","float","double","struct","extern",0};
 char *as[] = {
-       "globl","byte","even","text","data","bss","comm",0};
+       "globl","byte","align","text","data","comm",0};
 int    ifile;
 
 main(argc, argv)
 int    ifile;
 
 main(argc, argv)
index d0aea47..1a9acb1 100644 (file)
@@ -54,7 +54,7 @@ main(argc, argv) char *argv[];
        Home[strlen(Home) - 1] = '\0';
        Argc = argc; Argv = argv;
        if(argc<3) {
        Home[strlen(Home) - 1] = '\0';
        Argc = argc; Argv = argv;
        if(argc<3) {
-usage:         pr("Usage: find path-list predicate-list\n");
+usage:         fprintf(stderr, "Usage: find path-list predicate-list\n");
                exit(1);
        }
        for(Ai = paths = 1; Ai < (argc-1); ++Ai, ++paths)
                exit(1);
        }
        for(Ai = paths = 1; Ai < (argc-1); ++Ai, ++paths)
@@ -63,11 +63,11 @@ usage:              pr("Usage: find path-list predicate-list\n");
        if(paths == 1) /* no path-list */
                goto usage;
        if(!(exlist = exp())) { /* parse and compile the arguments */
        if(paths == 1) /* no path-list */
                goto usage;
        if(!(exlist = exp())) { /* parse and compile the arguments */
-               pr("find: parsing error\n");
+               fprintf(stderr, "find: parsing error\n");
                exit(1);
        }
        if(Ai<argc) {
                exit(1);
        }
        if(Ai<argc) {
-               pr("find: missing conjunction\n");
+               fprintf(stderr, "find: missing conjunction\n");
                exit(1);
        }
        for(Pi = 1; Pi < paths; ++Pi) {
                exit(1);
        }
        for(Pi = 1; Pi < paths; ++Pi) {
@@ -78,7 +78,7 @@ usage:                pr("Usage: find path-list predicate-list\n");
                        sp = cp + 1;
                        *cp = '\0';
                        if(chdir(*Pathname? Pathname: "/") == -1) {
                        sp = cp + 1;
                        *cp = '\0';
                        if(chdir(*Pathname? Pathname: "/") == -1) {
-                               pr("find: bad starting directory\n");
+                               fprintf(stderr, "find: bad starting directory\n");
                                exit(2);
                        }
                        *cp = '/';
                                exit(2);
                        }
                        *cp = '/';
@@ -90,6 +90,7 @@ usage:                pr("Usage: find path-list predicate-list\n");
                strcpy(Pathname, "TRAILER!!!");
                Statb.st_size = 0;
                cpio();
                strcpy(Pathname, "TRAILER!!!");
                Statb.st_size = 0;
                cpio();
+               printf("%D blocks\n", Blocks*10);
        }
        exit(0);
 }
        }
        exit(0);
 }
@@ -129,7 +130,7 @@ struct anode *e2() { /* parse NOT (!) */
        int not();
 
        if(Randlast) {
        int not();
 
        if(Randlast) {
-               pr("find: operand follows operand\n");
+               fprintf(stderr, "find: operand follows operand\n");
                exit(1);
        }
        Randlast++;
                exit(1);
        }
        Randlast++;
@@ -139,7 +140,7 @@ struct anode *e2() { /* parse NOT (!) */
        return(e3());
 }
 struct anode *e3() { /* parse parens and predicates */
        return(e3());
 }
 struct anode *e3() { /* parse parens and predicates */
-       int exeq(), ok(), glob(),  mtime(), atime(), ctime(), user(),
+       int exeq(), ok(), glob(),  mtime(), atime(), user(),
                group(), size(), perm(), links(), print(),
                type(), ino(), cpio(), newer();
        struct anode *p1;
                group(), size(), perm(), links(), print(),
                type(), ino(), cpio(), newer();
        struct anode *p1;
@@ -166,15 +167,11 @@ struct anode *e3() { /* parse parens and predicates */
                return(mk(mtime, (struct anode *)atoi(b), (struct anode *)s));
        else if(EQ(a, "-atime"))
                return(mk(atime, (struct anode *)atoi(b), (struct anode *)s));
                return(mk(mtime, (struct anode *)atoi(b), (struct anode *)s));
        else if(EQ(a, "-atime"))
                return(mk(atime, (struct anode *)atoi(b), (struct anode *)s));
-       else if(EQ(a, "-ctime"))
-               return(mk(ctime, (struct anode *)atoi(b), (struct anode *)s));
        else if(EQ(a, "-user")) {
                if((i=getunum("/etc/passwd", b)) == -1) {
        else if(EQ(a, "-user")) {
                if((i=getunum("/etc/passwd", b)) == -1) {
-                       if(gmatch(b, "[0-9][0-9][0-9]*")
-                       || gmatch(b, "[0-9][0-9]")
-                       || gmatch(b, "[0-9]"))
+                       if(gmatch(b, "[0-9][0-9]*"))
                                return mk(user, (struct anode *)atoi(b), (struct anode *)s);
                                return mk(user, (struct anode *)atoi(b), (struct anode *)s);
-                       pr("find: cannot find -user name\n");
+                       fprintf(stderr, "find: cannot find -user name\n");
                        exit(1);
                }
                return(mk(user, (struct anode *)i, (struct anode *)s));
                        exit(1);
                }
                return(mk(user, (struct anode *)i, (struct anode *)s));
@@ -183,11 +180,9 @@ struct anode *e3() { /* parse parens and predicates */
                return(mk(ino, (struct anode *)atoi(b), (struct anode *)s));
        else if(EQ(a, "-group")) {
                if((i=getunum("/etc/group", b)) == -1) {
                return(mk(ino, (struct anode *)atoi(b), (struct anode *)s));
        else if(EQ(a, "-group")) {
                if((i=getunum("/etc/group", b)) == -1) {
-                       if(gmatch(b, "[0-9][0-9][0-9]*")
-                       || gmatch(b, "[0-9][0-9]")
-                       || gmatch(b, "[0-9]"))
+                       if(gmatch(b, "[0-9][0-9]*"))
                                return mk(group, (struct anode *)atoi(b), (struct anode *)s);
                                return mk(group, (struct anode *)atoi(b), (struct anode *)s);
-                       pr("find: cannot find -group name\n");
+                       fprintf(stderr, "find: cannot find -group name\n");
                        exit(1);
                }
                return(mk(group, (struct anode *)i, (struct anode *)s));
                        exit(1);
                }
                return(mk(group, (struct anode *)i, (struct anode *)s));
@@ -223,7 +218,7 @@ struct anode *e3() { /* parse parens and predicates */
        }
        else if(EQ(a, "-cpio")) {
                if((Cpio = creat(b, 0666)) < 0) {
        }
        else if(EQ(a, "-cpio")) {
                if((Cpio = creat(b, 0666)) < 0) {
-                       pr("find: cannot create "), pr(s), pr("\n");
+                       fprintf(stderr, "find: cannot create < %s >\n", s);
                        exit(1);
                }
                Buf = (short *)sbrk(512);
                        exit(1);
                }
                Buf = (short *)sbrk(512);
@@ -232,13 +227,13 @@ struct anode *e3() { /* parse parens and predicates */
        }
        else if(EQ(a, "-newer")) {
                if(stat(b, &Statb) < 0) {
        }
        else if(EQ(a, "-newer")) {
                if(stat(b, &Statb) < 0) {
-                       pr("find: cannot access "), pr(b), pr("\n");
+                       fprintf(stderr, "find: cannot access < %s >\n", b);
                        exit(1);
                }
                Newer = Statb.st_mtime;
                return mk(newer, (struct anode *)0, (struct anode *)0);
        }
                        exit(1);
                }
                Newer = Statb.st_mtime;
                return mk(newer, (struct anode *)0, (struct anode *)0);
        }
-err:   pr("find: bad option "), pr(a), pr("\n");
+err:   fprintf(stderr, "find: bad option < %s >\n", a);
        exit(1);
 }
 struct anode *mk(f, l, r)
        exit(1);
 }
 struct anode *mk(f, l, r)
@@ -255,7 +250,7 @@ char *nxtarg() { /* get next arg from command line */
        static strikes = 0;
 
        if(strikes==3) {
        static strikes = 0;
 
        if(strikes==3) {
-               pr("find: incomplete statement\n");
+               fprintf(stderr, "find: incomplete statement\n");
                exit(1);
        }
        if(Ai>=Argc) {
                exit(1);
        }
        if(Ai>=Argc) {
@@ -302,11 +297,6 @@ register struct { int f, t, s; } *p;
 {
        return(scomp((int)((Now - Statb.st_atime) / A_DAY), p->t, p->s));
 }
 {
        return(scomp((int)((Now - Statb.st_atime) / A_DAY), p->t, p->s));
 }
-ctime(p)
-register struct { int f, t, s; } *p; 
-{
-       return(scomp((int)((Now - Statb.st_ctime) / A_DAY), p->t, p->s));
-}
 user(p)
 register struct { int f, u, s; } *p; 
 {
 user(p)
 register struct { int f, u, s; } *p; 
 {
@@ -353,17 +343,13 @@ register struct { int f, com; } *p;
 ok(p)
 struct { int f, com; } *p;
 {
 ok(p)
 struct { int f, com; } *p;
 {
-       int c;  int yes;
+       char c;  int yes;
        yes = 0;
        fflush(stdout); /* to flush possible `-print' */
        yes = 0;
        fflush(stdout); /* to flush possible `-print' */
-       pr("< "), pr(Argv[p->com]), pr(" ... "), pr(Pathname), pr(" >?   ");
+       fprintf(stderr, "< %s ... %s > ?   ", Argv[p->com], Pathname);
        fflush(stderr);
        if((c=getchar())=='y') yes = 1;
        fflush(stderr);
        if((c=getchar())=='y') yes = 1;
-       while(c!='\n')
-               if(c==EOF)
-                       exit(2);
-               else
-                       c = getchar();
+       while(c!='\n') c = getchar();
        if(yes) return(doex(p->com));
        return(0);
 }
        if(yes) return(doex(p->com));
        return(0);
 }
@@ -420,13 +406,11 @@ cpio()
                        bwrite(Buf, 512);
                return;
        }
                        bwrite(Buf, 512);
                return;
        }
-       if(!mklong(hdr.h_filesize)) {
-               bwrite((short *)&hdr, (sizeof hdr-256)+hdr.h_namesize);
+       if(!mklong(hdr.h_filesize))
                return;
                return;
-       }
        if((ifile = open(Fname, 0)) < 0) {
 cerror:
        if((ifile = open(Fname, 0)) < 0) {
 cerror:
-               pr("find: cannot copy "), pr(hdr.h_name), pr("\n");
+               fprintf(stderr, "find: cannot copy < %s >\n", hdr.h_name);
                return;
        }
        bwrite((short *)&hdr, (sizeof hdr-256)+hdr.h_namesize);
                return;
        }
        bwrite((short *)&hdr, (sizeof hdr-256)+hdr.h_namesize);
@@ -529,7 +513,7 @@ char *name, *fname;
        char *endofname;
 
        if(stat(fname, &Statb)<0) {
        char *endofname;
 
        if(stat(fname, &Statb)<0) {
-               pr("find: bad status-- "), pr(name), pr("\n");
+               fprintf(stderr, "find: bad status < %s >\n", name);
                return(0);
        }
        (*exlist->F)(exlist);
                return(0);
        }
        (*exlist->F)(exlist);
@@ -548,13 +532,15 @@ char *name, *fname;
                dsize = 512<(dirsize-offset)? 512: (dirsize-offset);
                if(!dir) {
                        if((dir=open(".", 0))<0) {
                dsize = 512<(dirsize-offset)? 512: (dirsize-offset);
                if(!dir) {
                        if((dir=open(".", 0))<0) {
-                               pr("find: cannot open "), pr(name), pr("\n");
+                               fprintf(stderr, "find: cannot open < %s >\n",
+                                       name);
                                rv = 0;
                                goto ret;
                        }
                        if(offset) lseek(dir, (long)offset, 0);
                        if(read(dir, (char *)dentry, dsize)<0) {
                                rv = 0;
                                goto ret;
                        }
                        if(offset) lseek(dir, (long)offset, 0);
                        if(read(dir, (char *)dentry, dsize)<0) {
-                               pr("find: cannot read "), pr(name), pr("\n");
+                               fprintf(stderr, "find: cannot read < %s >\n",
+                                       name);
                                rv = 0;
                                goto ret;
                        }
                                rv = 0;
                                goto ret;
                        }
@@ -564,7 +550,8 @@ char *name, *fname;
                        }
                } else 
                        if(read(dir, (char *)dentry, dsize)<0) {
                        }
                } else 
                        if(read(dir, (char *)dentry, dsize)<0) {
-                               pr("find: cannot read "), pr(name), pr("\n");
+                               fprintf(stderr, "find: cannot read < %s >\n",
+                                       name);
                                rv = 0;
                                goto ret;
                        }
                                rv = 0;
                                goto ret;
                        }
@@ -591,7 +578,7 @@ char *name, *fname;
                                *endofname = '\0';
                                chdir(Home);
                                if(chdir(Pathname) == -1) {
                                *endofname = '\0';
                                chdir(Home);
                                if(chdir(Pathname) == -1) {
-                                       pr("find: bad directory tree\n");
+                                       fprintf(stderr, "find: bad directory tree\n");
                                        exit(1);
                                }
                        }
                                        exit(1);
                                }
                        }
@@ -603,7 +590,7 @@ ret:
                close(dir);
        if(chdir("..") == -1) {
                *endofname = '\0';
                close(dir);
        if(chdir("..") == -1) {
                *endofname = '\0';
-               pr("find: bad directory "), pr(name), pr("\n");
+               fprintf(stderr, "find: bad directory <%s>\n", name);
                rv = 1;
        }
        return(rv);
                rv = 1;
        }
        return(rv);
@@ -696,13 +683,16 @@ chgreel(x, fl)
        char str[22];
        FILE *devtty;
        struct stat statb;
        char str[22];
        FILE *devtty;
        struct stat statb;
+       extern errno;
 
 
-       pr("find: can't "), pr(x? "write output": "read input"), pr("\n");
+       fprintf(stderr, "find: errno: %d, ", errno);
+       fprintf(stderr, "find: can't %s\n", x? "write output": "read input");
        fstat(fl, &statb);
        if((statb.st_mode&S_IFMT) != S_IFCHR)
                exit(1);
 again:
        fstat(fl, &statb);
        if((statb.st_mode&S_IFMT) != S_IFCHR)
                exit(1);
 again:
-       pr("If you want to go on, type device/file name when ready\n");
+       fprintf(stderr, "If you want to go on, type device/file name %s\n",
+               "when ready");
        devtty = fopen("/dev/tty", "r");
        fgets(str, 20, devtty);
        str[strlen(str) - 1] = '\0';
        devtty = fopen("/dev/tty", "r");
        fgets(str, 20, devtty);
        str[strlen(str) - 1] = '\0';
@@ -710,14 +700,9 @@ again:
                exit(1);
        close(fl);
        if((f = open(str, x? 1: 0)) < 0) {
                exit(1);
        close(fl);
        if((f = open(str, x? 1: 0)) < 0) {
-               pr("That didn't work");
+               fprintf(stderr, "That didn't work");
                fclose(devtty);
                goto again;
        }
        return f;
 }
                fclose(devtty);
                goto again;
        }
        return f;
 }
-pr(s)
-char *s;
-{
-       fputs(s, stderr);
-}
index 35ee772..d675ce9 100644 (file)
@@ -9,7 +9,6 @@
 #define KILL   '@'
 
 struct sgttyb tmode;
 #define KILL   '@'
 
 struct sgttyb tmode;
-struct tchars tchars = { '\177', '\034', '\021', '\023', '\004', '\377' };
 
 struct tab {
        char    tname;          /* this table name */
 
 struct tab {
        char    tname;          /* this table name */
@@ -79,6 +78,18 @@ struct       tab {
        B300, B300,
        "\n\rlogin: ",
 
        B300, B300,
        "\n\rlogin: ",
 
+/* table '6' -- 2400  */
+       '6' , '6' ,
+       ANYP+RAW , ANYP+ECHO+CRMOD ,
+       B2400 , B2400 ,
+       "\n\r\007login : ",
+/* table '7' - - 4800 */
+       '7' , '7' ,
+       ANYP+RAW , ANYP+ECHO+CRMOD ,
+       B4800 , B4800 ,
+       "\n\r\007login : " ,
 /* table 'i' -- Interdata Console */
        'i', 'i',
        RAW+CRMOD, CRMOD+ECHO+LCASE,
 /* table 'i' -- Interdata Console */
        'i', 'i',
        RAW+CRMOD, CRMOD+ECHO+LCASE,
@@ -90,12 +101,6 @@ struct      tab {
        ANYP+RAW/*+HUPCL*/, ANYP+ECHO/*+HUPCL*/,
        B300, B300,
        "*",
        ANYP+RAW/*+HUPCL*/, ANYP+ECHO/*+HUPCL*/,
        B300, B300,
        "*",
-/* table '6' -- 2400 11/23 line */
-       '6', '6',
-       ANYP+RAW+NL1+CR1, ANYP+ECHO,
-       B2400, B2400,
-       "\n\rlogin: ",
-
 };
 
 #define        NITAB   sizeof itab/sizeof itab[0]
 };
 
 #define        NITAB   sizeof itab/sizeof itab[0]
@@ -129,32 +134,27 @@ main(argc, argv)
 char **argv;
 {
        register struct tab *tabp;
 char **argv;
 {
        register struct tab *tabp;
-       int tname;
+       char tname;
 
 
+/*
+       signal(SIGINT, SIG_IGN);
+       signal(SIGQUIT, SIG_DFL);
+*/
        tname = '0';
        if (argc > 1)
                tname = argv[1][0];
        tname = '0';
        if (argc > 1)
                tname = argv[1][0];
-       switch (tname) {
-
-       case '3':               /* adapt to connect speed (212) */
-               ioctl(0, TIOCGETP, &tmode);
-               if (tmode.sg_ispeed==B300)
-                       tname = '0';
-               else
-                       tname = '3';
-               break;
-       }
        for (;;) {
                for(tabp = itab; tabp < &itab[NITAB]; tabp++)
                        if(tabp->tname == tname)
                                break;
                if(tabp >= &itab[NITAB])
                        tabp = itab;
        for (;;) {
                for(tabp = itab; tabp < &itab[NITAB]; tabp++)
                        if(tabp->tname == tname)
                                break;
                if(tabp >= &itab[NITAB])
                        tabp = itab;
+               tmode.sg_ispeed = tabp->ispeed;
+               tmode.sg_ospeed = tabp->ospeed;
                tmode.sg_flags = tabp->iflags;
                tmode.sg_ispeed = tabp->ispeed;
                tmode.sg_ospeed = tabp->ospeed;
                tmode.sg_flags = tabp->iflags;
                tmode.sg_ispeed = tabp->ispeed;
                tmode.sg_ospeed = tabp->ospeed;
-               ioctl(0, TIOCSETP, &tmode);
-               ioctl(0, TIOCSETC, &tchars);
+               stty(0, &tmode);
                puts(tabp->message);
                if(getname()) {
                        tmode.sg_erase = ERASE;
                puts(tabp->message);
                if(getname()) {
                        tmode.sg_erase = ERASE;
diff --git a/usr/src/cmd/graph.c b/usr/src/cmd/graph.c
deleted file mode 100644 (file)
index 7bd4125..0000000
+++ /dev/null
@@ -1,693 +0,0 @@
-#include <stdio.h>
-#include <ctype.h>
-#include <math.h>
-#define        INF     1.e+37
-#define        F       .25
-
-struct xy {
-       int     xlbf;   /*flag:explicit lower bound*/
-       int     xubf;   /*flag:explicit upper bound*/
-       int     xqf;    /*flag:explicit quantum*/
-       double (*xf)(); /*transform function, e.g. log*/
-       float   xa,xb;  /*scaling coefficients*/
-       float   xlb,xub;        /*lower and upper bound*/
-       float   xquant; /*quantum*/
-       float   xoff;           /*screen offset fraction*/
-       float   xsize;          /*screen fraction*/
-       int     xbot,xtop;      /*screen coords of border*/     
-       float   xmult;  /*scaling constant*/
-} xd,yd;
-struct val {
-       float xv;
-       float yv;
-       int lblptr;
-} *xx;
-
-char *labs;
-int labsiz;
-
-int tick = 50;
-int top = 4000;
-int bot = 200;
-float absbot;
-int    n;
-int    erasf = 1;
-int    gridf = 2;
-int    symbf = 0;
-int    absf = 0;
-int    transf;
-int    brkf;
-float  dx;
-char   *plotsymb;
-
-double atof();
-#define BSIZ 80
-char   labbuf[BSIZ];
-char   titlebuf[BSIZ];
-
-char *modes[] = {
-       "disconnected",
-       "solid",
-       "dotted",
-       "dotdashed",
-       "shortdashed",
-       "longdashed"
-};
-int mode = 1;
-char *realloc();
-char *malloc();
-
-double ident(x)
-double x;
-{
-       return(x);
-}
-
-main(argc,argv)
-char *argv[];
-{
-
-       space(0,0,4096,4096);
-       init(&xd);
-       init(&yd);
-       xd.xsize = yd.xsize = 1.;
-       xx = (struct val *)malloc((unsigned)sizeof(struct val));
-       labs = malloc(1);
-       labs[labsiz++] = 0;
-       setopt(argc,argv);
-       if(erasf)
-               erase();
-       readin();
-       transpose();
-       scale(&xd,(struct val *)&xx->xv);
-       scale(&yd,(struct val *)&xx->yv);
-       axes();
-       title();
-       plot();
-       move(1,1);
-       closevt();
-       return(0);
-}
-
-init(p)
-struct xy *p;
-{
-       p->xf = ident;
-       p->xmult = 1;
-}
-
-setopt(argc,argv)
-char *argv[];
-{
-       char *p1, *p2;
-       float temp;
-
-       xd.xlb = yd.xlb = INF;
-       xd.xub = yd.xub = -INF;
-       while(--argc > 0) {
-               argv++;
-again:         switch(argv[0][0]) {
-               case '-':
-                       argv[0]++;
-                       goto again;
-               case 'l': /* label for plot */
-                       p1 = titlebuf;
-                       if (argc>=2) {
-                               argv++;
-                               argc--;
-                               p2 = argv[0];
-                               while (*p1++ = *p2++);
-                       }
-                       break;
-
-               case 'd':       /*disconnected,obsolete option*/
-               case 'm': /*line mode*/
-                       mode = 0;
-                       if(!numb(&temp,&argc,&argv))
-                               break;
-                       if(temp>=sizeof(modes)/sizeof(*modes))
-                               mode = 1;
-                       else if(temp>=0)
-                               mode = temp;
-                       break;
-
-               case 'a': /*automatic abscissas*/
-                       absf = 1;
-                       dx = 1;
-                       if(!numb(&dx,&argc,&argv))
-                               break;
-                       if(numb(&absbot,&argc,&argv))
-                               absf = 2;
-                       break;
-
-               case 's': /*save screen, overlay plot*/
-                       erasf = 0;
-                       break;
-
-               case 'g': /*grid style 0 none, 1 ticks, 2 full*/
-                       gridf = 0;
-                       if(!numb(&temp,&argc,&argv))
-                               temp = argv[0][1]-'0';  /*for caompatibility*/
-                       if(temp>=0&&temp<=2)
-                               gridf = temp;
-                       break;
-
-               case 'c': /*character(s) for plotting*/
-                       if(argc >= 2) {
-                               symbf = 1;
-                               plotsymb = argv[1];
-                               argv++;
-                               argc--;
-                       }
-                       break;
-
-               case 't':       /*transpose*/
-                       transf = 1;
-                       break;
-               case 'b':       /*breaks*/
-                       brkf = 1;
-                       break;
-               case 'x':       /*x limits */
-                       limread(&xd,&argc,&argv);
-                       break;
-               case 'y':
-                       limread(&yd,&argc,&argv);
-                       break;
-               case 'h': /*set height of plot */
-                       if(!numb(&yd.xsize, &argc,&argv))
-                               badarg();
-                       break;
-               case 'w': /*set width of plot */
-                       if(!numb(&xd.xsize, &argc, &argv))
-                               badarg();
-                       break;
-               case 'r': /* set offset to right */
-                       if(!numb(&xd.xoff, &argc, &argv))
-                               badarg();
-                       break;
-               case 'u': /*set offset up the screen*/
-                       if(!numb(&yd.xoff,&argc,&argv))
-                               badarg();
-                       break;
-               default:
-                       badarg();
-               }
-       }
-}
-
-limread(p, argcp, argvp)
-register struct xy *p;
-int *argcp;
-char ***argvp;
-{
-       if(*argcp>1 && (*argvp)[1][0]=='l') {
-               (*argcp)--;
-               (*argvp)++;
-               p->xf = log10;
-       }
-       if(!numb(&p->xlb,argcp,argvp))
-               return;
-       p->xlbf = 1;
-       if(!numb(&p->xub,argcp,argvp))
-               return;
-       p->xubf = 1;
-       if(!numb(&p->xquant,argcp,argvp))
-               return;
-       p->xqf = 1;
-}
-
-numb(np, argcp, argvp)
-int *argcp;
-float *np;
-register char ***argvp;
-{
-       register char c;
-
-       if(*argcp <= 1)
-               return(0);
-       while((c=(*argvp)[1][0]) == '+')
-               (*argvp)[1]++;
-       if(!(isdigit(c) || c=='-'&&(*argvp)[1][1]<'A' || c=='.'))
-               return(0);
-       *np = atof((*argvp)[1]);
-       (*argcp)--;
-       (*argvp)++;
-       return(1);
-}
-
-readin()
-{
-       register t;
-       struct val *temp;
-
-       if(absf==1) {
-               if(xd.xlbf)
-                       absbot = xd.xlb;
-               else if(xd.xf==log10)
-                       absbot = 1;
-       }
-       for(;;) {
-               temp = (struct val *)realloc((char*)xx,
-                       (unsigned)(n+1)*sizeof(struct val));
-               if(temp==0)
-                       return;
-               xx = temp;
-               if(absf)
-                       xx[n].xv = n*dx + absbot;
-               else
-                       if(!getfloat(&xx[n].xv))
-                               return;
-               if(!getfloat(&xx[n].yv))
-                       return;
-               xx[n].lblptr = -1;
-               t = getstring();
-               if(t>0)
-                       xx[n].lblptr = copystring(t);
-               n++;
-               if(t<0)
-                       return;
-       }
-}
-
-transpose()
-{
-       register i;
-       float f;
-       struct xy t;
-       if(!transf)
-               return;
-       t = xd; xd = yd; yd = t;
-       for(i= 0;i<n;i++) {
-               f = xx[i].xv; xx[i].xv = xx[i].yv; xx[i].yv = f;
-       }
-}
-
-copystring(k)
-{
-       register char *temp;
-       register i;
-       int q;
-
-       temp = realloc(labs,(unsigned)(labsiz+1+k));
-       if(temp==0)
-               return(0);
-       labs = temp;
-       q = labsiz;
-       for(i=0;i<=k;i++)
-               labs[labsiz++] = labbuf[i];
-       return(q);
-}
-
-float
-modceil(f,t)
-float f,t;
-{
-
-       t = fabs(t);
-       return(ceil(f/t)*t);
-}
-
-float
-modfloor(f,t)
-float f,t;
-{
-       t = fabs(t);
-       return(floor(f/t)*t);
-}
-
-getlim(p,v)
-register struct xy *p;
-struct val *v;
-{
-       register i;
-
-       i = 0;
-       do {
-               if(!p->xlbf && p->xlb>v[i].xv)
-                       p->xlb = v[i].xv;
-               if(!p->xubf && p->xub<v[i].xv)
-                       p->xub = v[i].xv;
-               i++;
-       } while(i < n);
-}
-
-struct z {
-       float lb,ub,mult,quant;
-} setloglim(), setlinlim();
-
-setlim(p)
-register struct xy *p;
-{
-       float t,delta,sign;
-       struct z z;
-       int mark[50];
-       float lb,ub;
-       int lbf,ubf;
-
-       lb = p->xlb;
-       ub = p->xub;
-       delta = ub-lb;
-       if(p->xqf) {
-               if(delta*p->xquant <=0 )
-                       badarg();
-               return;
-       }
-       sign = 1;
-       lbf = p->xlbf;
-       ubf = p->xubf;
-       if(delta < 0) {
-               sign = -1;
-               t = lb;
-               lb = ub;
-               ub = t;
-               t = lbf;
-               lbf = ubf;
-               ubf = t;
-       }
-       else if(delta == 0) {
-               if(ub > 0) {
-                       ub = 2*ub;
-                       lb = 0;
-               } 
-               else
-                       if(lb < 0) {
-                               lb = 2*lb;
-                               ub = 0;
-                       } 
-                       else {
-                               ub = 1;
-                               lb = -1;
-                       }
-       }
-       if(p->xf==log10 && lb>0 && ub>lb) {
-               z = setloglim(lbf,ubf,lb,ub);
-               p->xlb = z.lb;
-               p->xub = z.ub;
-               p->xmult *= z.mult;
-               p->xquant = z.quant;
-               if(setmark(mark,p)<2) {
-                       p->xqf = lbf = ubf = 1;
-                       lb = z.lb; ub = z.ub;
-               } else
-                       return;
-       }
-       z = setlinlim(lbf,ubf,lb,ub);
-       if(sign > 0) {
-               p->xlb = z.lb;
-               p->xub = z.ub;
-       } else {
-               p->xlb = z.ub;
-               p->xub = z.lb;
-       }
-       p->xmult *= z.mult;
-       p->xquant = sign*z.quant;
-}
-
-struct z
-setloglim(lbf,ubf,lb,ub)
-float lb,ub;
-{
-       float r,s,t;
-       struct z z;
-
-       for(s=1; lb*s<1; s*=10) ;
-       lb *= s;
-       ub *= s;
-       for(r=1; 10*r<=lb; r*=10) ;
-       for(t=1; t<ub; t*=10) ;
-       z.lb = !lbf ? r : lb;
-       z.ub = !ubf ? t : ub;
-       if(ub/lb<100) {
-               if(!lbf) {
-                       if(lb >= 5*z.lb)
-                               z.lb *= 5;
-                       else if(lb >= 2*z.lb)
-                               z.lb *= 2;
-               }
-               if(!ubf) {
-                       if(ub*5 <= z.ub)
-                               z.ub /= 5;
-                       else if(ub*2 <= z.ub)
-                               z.ub /= 2;
-               }
-       }
-       z.mult = s;
-       z.quant = r;
-       return(z);
-}
-
-struct z
-setlinlim(lbf,ubf,xlb,xub)
-int lbf,ubf;
-float xlb,xub;
-{
-       struct z z;
-       float r,s,delta;
-       float ub,lb;
-
-loop:
-       ub = xub;
-       lb = xlb;
-       delta = ub - lb;
-       /*scale up by s, a power of 10, so range (delta) exceeds 1*/
-       /*find power of 10 quantum, r, such that delta/10<=r<delta*/
-       r = s = 1;
-       while(delta*s < 10)
-               s *= 10;
-       delta *= s;
-       while(10*r < delta)
-               r *= 10;
-       lb *= s;
-       ub *= s;
-       /*set r=(1,2,5)*10**n so that 3-5 quanta cover range*/
-       if(r>=delta/2)
-               r /= 2;
-       else if(r<delta/5)
-               r *= 2;
-       z.ub = ubf? ub: modceil(ub,r);
-       z.lb = lbf? lb: modfloor(lb,r);
-       if(!lbf && z.lb<=r && z.lb>0) {
-               xlb = 0;
-               goto loop;
-       }
-       else if(!ubf && z.ub>=-r && z.ub<0) {
-               xub = 0;
-               goto loop;
-       }
-       z.quant = r;
-       z.mult = s;
-       return(z);
-}
-
-scale(p,v)
-register struct xy *p;
-struct val *v;
-{
-       float edge;
-
-       getlim(p,v);
-       setlim(p);
-       edge = top-bot;
-       p->xa = p->xsize*edge/((*p->xf)(p->xub) - (*p->xf)(p->xlb));
-       p->xbot = bot + edge*p->xoff;
-       p->xtop = p->xbot + (top-bot)*p->xsize;
-       p->xb = p->xbot - (*p->xf)(p->xlb)*p->xa + .5;
-}
-
-axes()
-{
-       register i;
-       int mark[50];
-       int xn, yn;
-       if(gridf==0)
-               return;
-
-       line(xd.xbot,yd.xbot,xd.xtop,yd.xbot);
-       cont(xd.xtop,yd.xtop);
-       cont(xd.xbot,yd.xtop);
-       cont(xd.xbot,yd.xbot);
-
-       xn = setmark(mark,&xd);
-       for(i=0; i<xn; i++) {
-               if(gridf==2)
-                       line(mark[i],yd.xbot,mark[i],yd.xtop);
-               if(gridf==1) {
-                       line(mark[i],yd.xbot,mark[i],yd.xbot+tick);
-                       line(mark[i],yd.xtop-tick,mark[i],yd.xtop);
-               }
-       }
-       yn = setmark(mark,&yd);
-       for(i=0; i<yn; i++) {
-               if(gridf==2)
-                       line(xd.xbot,mark[i],xd.xtop,mark[i]);
-               if(gridf==1) {
-                       line(xd.xbot,mark[i],xd.xbot+tick,mark[i]);
-                       line(xd.xtop-tick,mark[i],xd.xtop,mark[i]);
-               }
-       }
-}
-
-setmark(xmark,p)
-int *xmark;
-register struct xy *p;
-{
-       int xn = 0;
-       float x,xl,xu;
-       float q;
-       if(p->xf==log10&&!p->xqf) {
-               for(x=p->xquant; x<p->xub; x*=10) {
-                       submark(xmark,&xn,x,p);
-                       if(p->xub/p->xlb<=100) {
-                               submark(xmark,&xn,2*x,p);
-                               submark(xmark,&xn,5*x,p);
-                       }
-               }
-       } else {
-               xn = 0;
-               q = p->xquant;
-               if(q>0) {
-                       xl = modceil(p->xlb+q/6,q);
-                       xu = modfloor(p->xub-q/6,q)+q/2;
-               } else {
-                       xl = modceil(p->xub-q/6,q);
-                       xu = modfloor(p->xlb+q/6,q)-q/2;
-               }
-               for(x=xl; x<=xu; x+=fabs(p->xquant))
-                       xmark[xn++] = (*p->xf)(x)*p->xa + p->xb;
-       }
-       return(xn);
-}
-submark(xmark,pxn,x,p)
-int *xmark;
-int *pxn;
-float x;
-struct xy *p;
-{
-       if(1.001*p->xlb < x && .999*p->xub > x)
-               xmark[(*pxn)++] = log10(x)*p->xa + p->xb;
-}
-
-plot()
-{
-       int ix,iy;
-       int i;
-       int conn;
-
-       conn = 0;
-       if(mode!=0)
-               linemod(modes[mode]);
-       for(i=0; i<n; i++) {
-               if(!conv(xx[i].xv,&xd,&ix) ||
-                  !conv(xx[i].yv,&yd,&iy)) {
-                       conn = 0;
-                       continue;
-               }
-               if(mode!=0) {
-                       if(conn != 0)
-                               cont(ix,iy);
-                       else
-                               move(ix,iy);
-                       conn = 1;
-               }
-               conn &= symbol(ix,iy,xx[i].lblptr);
-       }
-       linemod(modes[1]);
-}
-
-conv(xv,p,ip)
-float xv;
-register struct xy *p;
-int *ip;
-{
-       long ix;
-       ix = p->xa*(*p->xf)(xv*p->xmult) + p->xb;
-       if(ix<p->xbot || ix>p->xtop)
-               return(0);
-       *ip = ix;
-       return(1);
-}
-
-getfloat(p)
-float *p;
-{
-       register i;
-
-       i = scanf("%f",p);
-       return(i==1);
-}
-
-getstring()
-{
-       register i;
-       char junk[20];
-       i = scanf("%1s",labbuf);
-       if(i==-1)
-               return(-1);
-       switch(*labbuf) {
-       default:
-               if(!isdigit(*labbuf)) {
-                       ungetc(*labbuf,stdin);
-                       i = scanf("%s",labbuf);
-                       break;
-               }
-       case '.':
-       case '+':
-       case '-':
-               ungetc(*labbuf,stdin);
-               return(0);
-       case '"':
-               i = scanf("%[^\"\n]",labbuf);
-               scanf("%[\"]",junk);
-               break;
-       }
-       if(i==-1)
-               return(-1);
-       return(strlen(labbuf));
-}
-
-
-symbol(ix,iy,k)
-{
-
-       if(symbf==0&&k<0) {
-               if(mode==0)
-                       point(ix,iy);
-               return(1);
-       } 
-       else {
-               move(ix,iy);
-               label(k>=0?labs+k:plotsymb);
-               move(ix,iy);
-               return(!brkf|k<0);
-       }
-}
-
-title()
-{
-       move(xd.xbot,yd.xbot-60);
-       if (titlebuf[0]) {
-               label(titlebuf);
-               label("       ");
-       }
-       if(erasf&&gridf) {
-               axlab('x',&xd);
-               label("  ");
-               axlab('y',&yd);
-       }
-}
-
-axlab(c,p)
-char c;
-struct xy *p;
-{
-       char buf[50];
-       sprintf(buf,"%g -%s%c- %g", p->xlb/p->xmult,
-               p->xf==log10?"log ":"", c, p->xub/p->xmult);
-       label(buf);
-}
-
-badarg()
-{
-       fprintf(stderr,"graph: error in arguments\n");
-       exit(1);
-}
diff --git a/usr/src/cmd/graph/Makefile b/usr/src/cmd/graph/Makefile
new file mode 100644 (file)
index 0000000..c5fdee8
--- /dev/null
@@ -0,0 +1,9 @@
+CFLAGS=-O
+
+graph: graph.c
+       cc $(CFLAGS) -o graph graph.c /usr/lib/libplot.a -lm
+
+install: graph
+       install -s graph $(DESTDIR)/usr/bin
+clean:
+       rm -f *.o graph
diff --git a/usr/src/cmd/graph/graph.c b/usr/src/cmd/graph/graph.c
new file mode 100644 (file)
index 0000000..7bd4125
--- /dev/null
@@ -0,0 +1,693 @@
+#include <stdio.h>
+#include <ctype.h>
+#include <math.h>
+#define        INF     1.e+37
+#define        F       .25
+
+struct xy {
+       int     xlbf;   /*flag:explicit lower bound*/
+       int     xubf;   /*flag:explicit upper bound*/
+       int     xqf;    /*flag:explicit quantum*/
+       double (*xf)(); /*transform function, e.g. log*/
+       float   xa,xb;  /*scaling coefficients*/
+       float   xlb,xub;        /*lower and upper bound*/
+       float   xquant; /*quantum*/
+       float   xoff;           /*screen offset fraction*/
+       float   xsize;          /*screen fraction*/
+       int     xbot,xtop;      /*screen coords of border*/     
+       float   xmult;  /*scaling constant*/
+} xd,yd;
+struct val {
+       float xv;
+       float yv;
+       int lblptr;
+} *xx;
+
+char *labs;
+int labsiz;
+
+int tick = 50;
+int top = 4000;
+int bot = 200;
+float absbot;
+int    n;
+int    erasf = 1;
+int    gridf = 2;
+int    symbf = 0;
+int    absf = 0;
+int    transf;
+int    brkf;
+float  dx;
+char   *plotsymb;
+
+double atof();
+#define BSIZ 80
+char   labbuf[BSIZ];
+char   titlebuf[BSIZ];
+
+char *modes[] = {
+       "disconnected",
+       "solid",
+       "dotted",
+       "dotdashed",
+       "shortdashed",
+       "longdashed"
+};
+int mode = 1;
+char *realloc();
+char *malloc();
+
+double ident(x)
+double x;
+{
+       return(x);
+}
+
+main(argc,argv)
+char *argv[];
+{
+
+       space(0,0,4096,4096);
+       init(&xd);
+       init(&yd);
+       xd.xsize = yd.xsize = 1.;
+       xx = (struct val *)malloc((unsigned)sizeof(struct val));
+       labs = malloc(1);
+       labs[labsiz++] = 0;
+       setopt(argc,argv);
+       if(erasf)
+               erase();
+       readin();
+       transpose();
+       scale(&xd,(struct val *)&xx->xv);
+       scale(&yd,(struct val *)&xx->yv);
+       axes();
+       title();
+       plot();
+       move(1,1);
+       closevt();
+       return(0);
+}
+
+init(p)
+struct xy *p;
+{
+       p->xf = ident;
+       p->xmult = 1;
+}
+
+setopt(argc,argv)
+char *argv[];
+{
+       char *p1, *p2;
+       float temp;
+
+       xd.xlb = yd.xlb = INF;
+       xd.xub = yd.xub = -INF;
+       while(--argc > 0) {
+               argv++;
+again:         switch(argv[0][0]) {
+               case '-':
+                       argv[0]++;
+                       goto again;
+               case 'l': /* label for plot */
+                       p1 = titlebuf;
+                       if (argc>=2) {
+                               argv++;
+                               argc--;
+                               p2 = argv[0];
+                               while (*p1++ = *p2++);
+                       }
+                       break;
+
+               case 'd':       /*disconnected,obsolete option*/
+               case 'm': /*line mode*/
+                       mode = 0;
+                       if(!numb(&temp,&argc,&argv))
+                               break;
+                       if(temp>=sizeof(modes)/sizeof(*modes))
+                               mode = 1;
+                       else if(temp>=0)
+                               mode = temp;
+                       break;
+
+               case 'a': /*automatic abscissas*/
+                       absf = 1;
+                       dx = 1;
+                       if(!numb(&dx,&argc,&argv))
+                               break;
+                       if(numb(&absbot,&argc,&argv))
+                               absf = 2;
+                       break;
+
+               case 's': /*save screen, overlay plot*/
+                       erasf = 0;
+                       break;
+
+               case 'g': /*grid style 0 none, 1 ticks, 2 full*/
+                       gridf = 0;
+                       if(!numb(&temp,&argc,&argv))
+                               temp = argv[0][1]-'0';  /*for caompatibility*/
+                       if(temp>=0&&temp<=2)
+                               gridf = temp;
+                       break;
+
+               case 'c': /*character(s) for plotting*/
+                       if(argc >= 2) {
+                               symbf = 1;
+                               plotsymb = argv[1];
+                               argv++;
+                               argc--;
+                       }
+                       break;
+
+               case 't':       /*transpose*/
+                       transf = 1;
+                       break;
+               case 'b':       /*breaks*/
+                       brkf = 1;
+                       break;
+               case 'x':       /*x limits */
+                       limread(&xd,&argc,&argv);
+                       break;
+               case 'y':
+                       limread(&yd,&argc,&argv);
+                       break;
+               case 'h': /*set height of plot */
+                       if(!numb(&yd.xsize, &argc,&argv))
+                               badarg();
+                       break;
+               case 'w': /*set width of plot */
+                       if(!numb(&xd.xsize, &argc, &argv))
+                               badarg();
+                       break;
+               case 'r': /* set offset to right */
+                       if(!numb(&xd.xoff, &argc, &argv))
+                               badarg();
+                       break;
+               case 'u': /*set offset up the screen*/
+                       if(!numb(&yd.xoff,&argc,&argv))
+                               badarg();
+                       break;
+               default:
+                       badarg();
+               }
+       }
+}
+
+limread(p, argcp, argvp)
+register struct xy *p;
+int *argcp;
+char ***argvp;
+{
+       if(*argcp>1 && (*argvp)[1][0]=='l') {
+               (*argcp)--;
+               (*argvp)++;
+               p->xf = log10;
+       }
+       if(!numb(&p->xlb,argcp,argvp))
+               return;
+       p->xlbf = 1;
+       if(!numb(&p->xub,argcp,argvp))
+               return;
+       p->xubf = 1;
+       if(!numb(&p->xquant,argcp,argvp))
+               return;
+       p->xqf = 1;
+}
+
+numb(np, argcp, argvp)
+int *argcp;
+float *np;
+register char ***argvp;
+{
+       register char c;
+
+       if(*argcp <= 1)
+               return(0);
+       while((c=(*argvp)[1][0]) == '+')
+               (*argvp)[1]++;
+       if(!(isdigit(c) || c=='-'&&(*argvp)[1][1]<'A' || c=='.'))
+               return(0);
+       *np = atof((*argvp)[1]);
+       (*argcp)--;
+       (*argvp)++;
+       return(1);
+}
+
+readin()
+{
+       register t;
+       struct val *temp;
+
+       if(absf==1) {
+               if(xd.xlbf)
+                       absbot = xd.xlb;
+               else if(xd.xf==log10)
+                       absbot = 1;
+       }
+       for(;;) {
+               temp = (struct val *)realloc((char*)xx,
+                       (unsigned)(n+1)*sizeof(struct val));
+               if(temp==0)
+                       return;
+               xx = temp;
+               if(absf)
+                       xx[n].xv = n*dx + absbot;
+               else
+                       if(!getfloat(&xx[n].xv))
+                               return;
+               if(!getfloat(&xx[n].yv))
+                       return;
+               xx[n].lblptr = -1;
+               t = getstring();
+               if(t>0)
+                       xx[n].lblptr = copystring(t);
+               n++;
+               if(t<0)
+                       return;
+       }
+}
+
+transpose()
+{
+       register i;
+       float f;
+       struct xy t;
+       if(!transf)
+               return;
+       t = xd; xd = yd; yd = t;
+       for(i= 0;i<n;i++) {
+               f = xx[i].xv; xx[i].xv = xx[i].yv; xx[i].yv = f;
+       }
+}
+
+copystring(k)
+{
+       register char *temp;
+       register i;
+       int q;
+
+       temp = realloc(labs,(unsigned)(labsiz+1+k));
+       if(temp==0)
+               return(0);
+       labs = temp;
+       q = labsiz;
+       for(i=0;i<=k;i++)
+               labs[labsiz++] = labbuf[i];
+       return(q);
+}
+
+float
+modceil(f,t)
+float f,t;
+{
+
+       t = fabs(t);
+       return(ceil(f/t)*t);
+}
+
+float
+modfloor(f,t)
+float f,t;
+{
+       t = fabs(t);
+       return(floor(f/t)*t);
+}
+
+getlim(p,v)
+register struct xy *p;
+struct val *v;
+{
+       register i;
+
+       i = 0;
+       do {
+               if(!p->xlbf && p->xlb>v[i].xv)
+                       p->xlb = v[i].xv;
+               if(!p->xubf && p->xub<v[i].xv)
+                       p->xub = v[i].xv;
+               i++;
+       } while(i < n);
+}
+
+struct z {
+       float lb,ub,mult,quant;
+} setloglim(), setlinlim();
+
+setlim(p)
+register struct xy *p;
+{
+       float t,delta,sign;
+       struct z z;
+       int mark[50];
+       float lb,ub;
+       int lbf,ubf;
+
+       lb = p->xlb;
+       ub = p->xub;
+       delta = ub-lb;
+       if(p->xqf) {
+               if(delta*p->xquant <=0 )
+                       badarg();
+               return;
+       }
+       sign = 1;
+       lbf = p->xlbf;
+       ubf = p->xubf;
+       if(delta < 0) {
+               sign = -1;
+               t = lb;
+               lb = ub;
+               ub = t;
+               t = lbf;
+               lbf = ubf;
+               ubf = t;
+       }
+       else if(delta == 0) {
+               if(ub > 0) {
+                       ub = 2*ub;
+                       lb = 0;
+               } 
+               else
+                       if(lb < 0) {
+                               lb = 2*lb;
+                               ub = 0;
+                       } 
+                       else {
+                               ub = 1;
+                               lb = -1;
+                       }
+       }
+       if(p->xf==log10 && lb>0 && ub>lb) {
+               z = setloglim(lbf,ubf,lb,ub);
+               p->xlb = z.lb;
+               p->xub = z.ub;
+               p->xmult *= z.mult;
+               p->xquant = z.quant;
+               if(setmark(mark,p)<2) {
+                       p->xqf = lbf = ubf = 1;
+                       lb = z.lb; ub = z.ub;
+               } else
+                       return;
+       }
+       z = setlinlim(lbf,ubf,lb,ub);
+       if(sign > 0) {
+               p->xlb = z.lb;
+               p->xub = z.ub;
+       } else {
+               p->xlb = z.ub;
+               p->xub = z.lb;
+       }
+       p->xmult *= z.mult;
+       p->xquant = sign*z.quant;
+}
+
+struct z
+setloglim(lbf,ubf,lb,ub)
+float lb,ub;
+{
+       float r,s,t;
+       struct z z;
+
+       for(s=1; lb*s<1; s*=10) ;
+       lb *= s;
+       ub *= s;
+       for(r=1; 10*r<=lb; r*=10) ;
+       for(t=1; t<ub; t*=10) ;
+       z.lb = !lbf ? r : lb;
+       z.ub = !ubf ? t : ub;
+       if(ub/lb<100) {
+               if(!lbf) {
+                       if(lb >= 5*z.lb)
+                               z.lb *= 5;
+                       else if(lb >= 2*z.lb)
+                               z.lb *= 2;
+               }
+               if(!ubf) {
+                       if(ub*5 <= z.ub)
+                               z.ub /= 5;
+                       else if(ub*2 <= z.ub)
+                               z.ub /= 2;
+               }
+       }
+       z.mult = s;
+       z.quant = r;
+       return(z);
+}
+
+struct z
+setlinlim(lbf,ubf,xlb,xub)
+int lbf,ubf;
+float xlb,xub;
+{
+       struct z z;
+       float r,s,delta;
+       float ub,lb;
+
+loop:
+       ub = xub;
+       lb = xlb;
+       delta = ub - lb;
+       /*scale up by s, a power of 10, so range (delta) exceeds 1*/
+       /*find power of 10 quantum, r, such that delta/10<=r<delta*/
+       r = s = 1;
+       while(delta*s < 10)
+               s *= 10;
+       delta *= s;
+       while(10*r < delta)
+               r *= 10;
+       lb *= s;
+       ub *= s;
+       /*set r=(1,2,5)*10**n so that 3-5 quanta cover range*/
+       if(r>=delta/2)
+               r /= 2;
+       else if(r<delta/5)
+               r *= 2;
+       z.ub = ubf? ub: modceil(ub,r);
+       z.lb = lbf? lb: modfloor(lb,r);
+       if(!lbf && z.lb<=r && z.lb>0) {
+               xlb = 0;
+               goto loop;
+       }
+       else if(!ubf && z.ub>=-r && z.ub<0) {
+               xub = 0;
+               goto loop;
+       }
+       z.quant = r;
+       z.mult = s;
+       return(z);
+}
+
+scale(p,v)
+register struct xy *p;
+struct val *v;
+{
+       float edge;
+
+       getlim(p,v);
+       setlim(p);
+       edge = top-bot;
+       p->xa = p->xsize*edge/((*p->xf)(p->xub) - (*p->xf)(p->xlb));
+       p->xbot = bot + edge*p->xoff;
+       p->xtop = p->xbot + (top-bot)*p->xsize;
+       p->xb = p->xbot - (*p->xf)(p->xlb)*p->xa + .5;
+}
+
+axes()
+{
+       register i;
+       int mark[50];
+       int xn, yn;
+       if(gridf==0)
+               return;
+
+       line(xd.xbot,yd.xbot,xd.xtop,yd.xbot);
+       cont(xd.xtop,yd.xtop);
+       cont(xd.xbot,yd.xtop);
+       cont(xd.xbot,yd.xbot);
+
+       xn = setmark(mark,&xd);
+       for(i=0; i<xn; i++) {
+               if(gridf==2)
+                       line(mark[i],yd.xbot,mark[i],yd.xtop);
+               if(gridf==1) {
+                       line(mark[i],yd.xbot,mark[i],yd.xbot+tick);
+                       line(mark[i],yd.xtop-tick,mark[i],yd.xtop);
+               }
+       }
+       yn = setmark(mark,&yd);
+       for(i=0; i<yn; i++) {
+               if(gridf==2)
+                       line(xd.xbot,mark[i],xd.xtop,mark[i]);
+               if(gridf==1) {
+                       line(xd.xbot,mark[i],xd.xbot+tick,mark[i]);
+                       line(xd.xtop-tick,mark[i],xd.xtop,mark[i]);
+               }
+       }
+}
+
+setmark(xmark,p)
+int *xmark;
+register struct xy *p;
+{
+       int xn = 0;
+       float x,xl,xu;
+       float q;
+       if(p->xf==log10&&!p->xqf) {
+               for(x=p->xquant; x<p->xub; x*=10) {
+                       submark(xmark,&xn,x,p);
+                       if(p->xub/p->xlb<=100) {
+                               submark(xmark,&xn,2*x,p);
+                               submark(xmark,&xn,5*x,p);
+                       }
+               }
+       } else {
+               xn = 0;
+               q = p->xquant;
+               if(q>0) {
+                       xl = modceil(p->xlb+q/6,q);
+                       xu = modfloor(p->xub-q/6,q)+q/2;
+               } else {
+                       xl = modceil(p->xub-q/6,q);
+                       xu = modfloor(p->xlb+q/6,q)-q/2;
+               }
+               for(x=xl; x<=xu; x+=fabs(p->xquant))
+                       xmark[xn++] = (*p->xf)(x)*p->xa + p->xb;
+       }
+       return(xn);
+}
+submark(xmark,pxn,x,p)
+int *xmark;
+int *pxn;
+float x;
+struct xy *p;
+{
+       if(1.001*p->xlb < x && .999*p->xub > x)
+               xmark[(*pxn)++] = log10(x)*p->xa + p->xb;
+}
+
+plot()
+{
+       int ix,iy;
+       int i;
+       int conn;
+
+       conn = 0;
+       if(mode!=0)
+               linemod(modes[mode]);
+       for(i=0; i<n; i++) {
+               if(!conv(xx[i].xv,&xd,&ix) ||
+                  !conv(xx[i].yv,&yd,&iy)) {
+                       conn = 0;
+                       continue;
+               }
+               if(mode!=0) {
+                       if(conn != 0)
+                               cont(ix,iy);
+                       else
+                               move(ix,iy);
+                       conn = 1;
+               }
+               conn &= symbol(ix,iy,xx[i].lblptr);
+       }
+       linemod(modes[1]);
+}
+
+conv(xv,p,ip)
+float xv;
+register struct xy *p;
+int *ip;
+{
+       long ix;
+       ix = p->xa*(*p->xf)(xv*p->xmult) + p->xb;
+       if(ix<p->xbot || ix>p->xtop)
+               return(0);
+       *ip = ix;
+       return(1);
+}
+
+getfloat(p)
+float *p;
+{
+       register i;
+
+       i = scanf("%f",p);
+       return(i==1);
+}
+
+getstring()
+{
+       register i;
+       char junk[20];
+       i = scanf("%1s",labbuf);
+       if(i==-1)
+               return(-1);
+       switch(*labbuf) {
+       default:
+               if(!isdigit(*labbuf)) {
+                       ungetc(*labbuf,stdin);
+                       i = scanf("%s",labbuf);
+                       break;
+               }
+       case '.':
+       case '+':
+       case '-':
+               ungetc(*labbuf,stdin);
+               return(0);
+       case '"':
+               i = scanf("%[^\"\n]",labbuf);
+               scanf("%[\"]",junk);
+               break;
+       }
+       if(i==-1)
+               return(-1);
+       return(strlen(labbuf));
+}
+
+
+symbol(ix,iy,k)
+{
+
+       if(symbf==0&&k<0) {
+               if(mode==0)
+                       point(ix,iy);
+               return(1);
+       } 
+       else {
+               move(ix,iy);
+               label(k>=0?labs+k:plotsymb);
+               move(ix,iy);
+               return(!brkf|k<0);
+       }
+}
+
+title()
+{
+       move(xd.xbot,yd.xbot-60);
+       if (titlebuf[0]) {
+               label(titlebuf);
+               label("       ");
+       }
+       if(erasf&&gridf) {
+               axlab('x',&xd);
+               label("  ");
+               axlab('y',&yd);
+       }
+}
+
+axlab(c,p)
+char c;
+struct xy *p;
+{
+       char buf[50];
+       sprintf(buf,"%g -%s%c- %g", p->xlb/p->xmult,
+               p->xf==log10?"log ":"", c, p->xub/p->xmult);
+       label(buf);
+}
+
+badarg()
+{
+       fprintf(stderr,"graph: error in arguments\n");
+       exit(1);
+}
index da87cb4..395ccdd 100644 (file)
@@ -9,7 +9,6 @@
 
 #include <stdio.h>
 #include <ctype.h>
 
 #include <stdio.h>
 #include <ctype.h>
-#include <sys/param.h>
 
 #define        CBRA    1
 #define        CCHR    2
 
 #define        CBRA    1
 #define        CCHR    2
@@ -41,6 +40,7 @@ int   hflag   = 1;
 int    sflag;
 int    yflag;
 int    circf;
 int    sflag;
 int    yflag;
 int    circf;
+int    blkno;
 long   tln;
 int    nsucc;
 char   *braslist[NBRA];
 long   tln;
 int    nsucc;
 char   *braslist[NBRA];
@@ -439,7 +439,6 @@ register char *lp, *ep;
 succeed(f)
 char *f;
 {
 succeed(f)
 char *f;
 {
-       long ftell();
        nsucc = 1;
        if (sflag)
                return;
        nsucc = 1;
        if (sflag)
                return;
@@ -455,7 +454,7 @@ char *f;
        if (nfile > 1 && hflag)
                printf("%s:", f);
        if (bflag)
        if (nfile > 1 && hflag)
                printf("%s:", f);
        if (bflag)
-               printf("%ld:", (ftell(stdin)-1)/BSIZE);
+               printf("%u:", blkno);
        if (nflag)
                printf("%ld:", lnum);
        printf("%s\n", linebuf);
        if (nflag)
                printf("%ld:", lnum);
        printf("%s\n", linebuf);
diff --git a/usr/src/cmd/group.c b/usr/src/cmd/group.c
new file mode 100644 (file)
index 0000000..f629967
--- /dev/null
@@ -0,0 +1,12 @@
+#include <grp.h>
+#define        NULL    0
+
+struct group *getgrgid(), *grp;
+
+main()
+{
+       if((grp=getgrgid(getgid())) == NULL) 
+               printf("%d\n", getgid());
+       else
+               printf("%s\n", grp->gr_name);
+}
diff --git a/usr/src/cmd/in b/usr/src/cmd/in
deleted file mode 100644 (file)
index 5bb6521..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-cmake -cp \
-ac \
-calendar \
-cmp \
-comm \
-crypt \
-dcheck \
-dd \
-diff \
-diffh \
-du \
-dump \
-dumpdir \
-ed \
-fgrep \
-grep \
-icheck \
-init \
-iostat \
-ls \
-mail \
-mkfs \
-nm \
-od \
-prof \
-ps \
-quot \
-restor \
-size \
-strip \
-sum \
-tail \
-tee \
-tsort \
-units
index 1a2534d..7ac4a4b 100644 (file)
@@ -274,7 +274,7 @@ register struct tab *p;
                        for(i=0; i<8; i++)
                                if(wtmp.ut_line[i] != p->line[i])
                                        goto contin;
                        for(i=0; i<8; i++)
                                if(wtmp.ut_line[i] != p->line[i])
                                        goto contin;
-                       lseek(f, -(long)sizeof(wtmp), 1);
+                       lseek(f, (long)-sizeof(wtmp), 1);
                        for(i=0; i<8; i++)
                                wtmp.ut_name[i] = 0;
                        time(&wtmp.ut_time);
                        for(i=0; i<8; i++)
                                wtmp.ut_name[i] = 0;
                        time(&wtmp.ut_time);
diff --git a/usr/src/cmd/install.sh b/usr/src/cmd/install.sh
new file mode 100755 (executable)
index 0000000..8e8bfb1
--- /dev/null
@@ -0,0 +1,21 @@
+cmd=/bin/mv
+case $1 in
+       -s )    /usr/bin/strip $2
+               shift
+               ;;
+       -c )    cmd=cp
+               shift
+esac
+
+if [ ! ${2-""} ]
+then   echo 'install : no destination specified.'
+       exit 1
+fi
+
+$cmd $1 $2
+if [ -d $2 ]
+then   file=$2/$1
+else   file=$2
+fi
+chmod 755 $file
+chown root $file
index 8e03f88..0eb92a3 100644 (file)
@@ -11,6 +11,11 @@ struct
        unsigned        value;
 } nl[] = {
        "_dk_busy", 0, 0,
        unsigned        value;
 } nl[] = {
        "_dk_busy", 0, 0,
+       "_dk_time", 0, 0,
+       "_dk_numb", 0, 0,
+       "_dk_wds", 0, 0,
+       "_tk_nin", 0, 0,
+       "_tk_nout", 0, 0,
        "_io_info", 0, 0,
        "\0\0\0\0\0\0\0\0", 0, 0
 };
        "_io_info", 0, 0,
        "\0\0\0\0\0\0\0\0", 0, 0
 };
@@ -87,7 +92,17 @@ char *argv[];
 
 loop:
        lseek(mf, (long)nl[0].value, 0);
 
 loop:
        lseek(mf, (long)nl[0].value, 0);
-       read(mf, (char *)&s, sizeof s);
+       read(mf, &s.busy, sizeof s.busy);
+       lseek(mf, (long)nl[1].value, 0);
+       read(mf, s.etime, sizeof s.etime);
+       lseek(mf, (long)nl[2].value, 0);
+       read(mf, s.numb, sizeof s.numb);
+       lseek(mf, (long)nl[3].value, 0);
+       read(mf, s.wds, sizeof s.wds);
+       lseek(mf, (long)nl[4].value, 0);
+       read(mf, &s.tin, sizeof s.tin);
+       lseek(mf, (long)nl[5].value, 0);
+       read(mf, &s.tout, sizeof s.tout);
        for(i=0; i<40; i++) {
                t = s.etime[i];
                s.etime[i] -= s1.etime[i];
        for(i=0; i<40; i++) {
                t = s.etime[i];
                s.etime[i] -= s1.etime[i];
@@ -166,7 +181,7 @@ stats(dn)
        }
        f3 = s.wds[dn];
        f3 = f3*32.;
        }
        f3 = s.wds[dn];
        f3 = f3*32.;
-       f4 = xf[dn];
+       f4 = xf[2];             /* so far, only RP06's */
        f4 = f4*1.0e-6;
        f5 = f1 - f4*f3;
        f6 = f1 - f5;
        f4 = f4*1.0e-6;
        f5 = f1 - f4*f3;
        f6 = f1 - f5;
@@ -255,7 +270,7 @@ biostats()
 {
 register i;
 
 {
 register i;
 
-       lseek(mf,(long)nl[1].value, 0);
+       lseek(mf,(long)nl[6].value, 0);
        read(mf, (char *)&io_info, sizeof(io_info));
        printf("%D\t%D\t%D\t%D\n",
         io_info.nread-io_delta.nread, io_info.nreada-io_delta.nreada,
        read(mf, (char *)&io_info, sizeof(io_info));
        printf("%D\t%D\t%D\t%D\n",
         io_info.nread-io_delta.nread, io_info.nreada-io_delta.nreada,
index 48f52a9..fec3bd8 100644 (file)
+#
+char LD[] = "@(#)ld.c 1.10 78/12/07 15:34:58"; /* sccs ident */
 /*
 /*
- *  link editor
+ *  link editor for VAX
  */
 
  */
 
-#include <signal.h>
-#include "sys/types.h"
-#include "sys/stat.h"
-
-/*     Layout of a.out file :
+/*     layout of a.out file:
  *
  *
- *     header of 8 words       magic number 405, 407, 410, 411
+ *     header of 8 words       magic number 0410:
+                                       data starts at 1st 0777
+                                       boundary above text
+                               magic number 0407:
+                                       data starts immediately after
+                                       text
  *                             text size       )
  *                             text size       )
- *                             data size       ) in bytes but even
+ *                             data size       ) in bytes
  *                             bss size        )
  *                             symbol table size
  *                             entry point
  *                             bss size        )
  *                             symbol table size
  *                             entry point
- *                             {unused}
- *                             flag set if no relocation
- *
+ *                             size of text relocation info
+ *                             size of data relocation info
  *
  *
+ *  'segment'   origin   comments
  *     header:         0
  *     header:         0
- *     text:           16
- *     data:           16+textsize
- *     relocation:     16+textsize+datasize
- *     symbol table:   16+2*(textsize+datasize) or 16+textsize+datasize
+ *     text:           32       0 padded to multiple of 4 bytes
+ *     data:           32+textsize     0 padded to multiple of 4 bytes
+ *     text relocation:        32+textsize+datasize
+ *     data relocation:        32+textsize+datasize+textrelocationsize
+ *     symbol table:   32+textsize+datasize+textrelocationsize+datarelocationsize
  *
  */
  *
  */
+#include <signal.h>
+#include <stdio.h>
+#include <ar.h>
+#include <a.out.h>
+
+struct {short hiword; short loword;}; /* stupid fp-11 */
+fixl(p) register long *p;{
+       register short t;
+       t=p->hiword; p->hiword=p->loword; p->loword=t;
+}
+
+writel(p,n,f) long *p; FILE *f; {
+#ifdef vax
+       fwrite(p,sizeof(*p),n,f);
+#else
+       while (n--) {
+               fwrite(&(*p).loword,2,1,f);
+               fwrite(&(*p).hiword,2,1,f);
+               p++;
+       }
+#endif
+}
+
+long htoi(p) register char *p; {/* hex to integer conversion */
+register long n = 0;
+while (*p) {
+       n <<= 4;
+       if              (*p<='9' && *p>='0') n += *p - '0';
+       else if (*p<='f' && *p>='a') n += *p -'a' +10;
+       else if (*p<='F' && *p>='A') n += *p -'A' +10;
+       p++;
+}
+return(n);
+}
+
+typedef        char *STRING;
+typedef        int BOOL;
 #define TRUE   1
 #define FALSE  0
 
 #define TRUE   1
 #define FALSE  0
 
-
-#define        ARCMAGIC 0177545
-#define OMAGIC 0405
-#define        FMAGIC  0407
+#define        OMAGIC  0407
 #define        NMAGIC  0410
 #define        NMAGIC  0410
-#define        IMAGIC  0411
-
-#define        EXTERN  040
-#define        UNDEF   00
-#define        ABS     01
-#define        TEXT    02
-#define        DATA    03
-#define        BSS     04
-#define        COMM    05      /* internal use only */
-
-#define        RABS    00
-#define        RTEXT   02
-#define        RDATA   04
-#define        RBSS    06
-#define        REXT    010
-
-#define NOVLY  16
+
+/*
+ * Symbol types
+ */
+#define        UNDEF   0x0
+#define        ABS     0x2
+#define        TEXT    0x4
+#define        DATA    0x6
+#define        BSS     0x8
+#define        DATAO   0xA
+#define        BSSO    0xC
+#define        TEXTO   0xE
+#define        ABSO    0x10
+
+#define        COMM    0x12    /* for internal use only */
+
+#define        EXTERN  0x1
+#define        TYPE    0x1E
+#define STABTYPS 0xE0
+/*
+ * address reference types
+ */
+#define PCREL  1
+#define LEN1   0
+#define LEN2   2
+#define LEN4   4
+
+#define        HW      01
+#define        FW      03
+#define        DW      07
+
+#define        PAGRND  0777
+
+#define        TYPMASK 0x1E
+#define        TYMASK  (0x1E)
+#define TMASK  0x1F
+
+#define        RABS    (ABS)
+#define        RTEXT   TEXT
+#define        RDATA   DATA
+#define        RBSS    BSS
+#define        RDATAO  DATAO
+#define        RBSSO   BSSO
+#define        RTEXTO  TEXTO
+#define        RABSO   ABSO
+#define        REXT    (01<<3)
+#define        ROFF    (02<<3)
+#define        REFMASK 0x7
+
+#define NOVLY  1
 #define        RELFLG  01
 #define        NROUT   256
 #define        NSYM    1103
 #define        RELFLG  01
 #define        NROUT   256
 #define        NSYM    1103
-#define        NSYMPR  1000
+#define        NSYMPR  500
 
 char   premeof[] = "Premature EOF";
 
 char   premeof[] = "Premature EOF";
-char   goodnm[] = "__.SYMDEF";
-
-/* table of contents stuff */
-#define TABSZ  700
-struct tab
-{      char cname[8];
-       long cloc;
-} tab[TABSZ];
-int tnum;
 
 
+typedef struct {
+       long    loc;
+} LIBLIST;
 
 /* overlay management */
 int    vindex;
 
 /* overlay management */
 int    vindex;
-struct overlay {
+typedef struct {
        int     argsav;
        int     symsav;
        int     argsav;
        int     symsav;
-       struct liblist  *libsav;
-       char    *vname;
-       int     ctsav, cdsav, cbsav;
-       int     offt, offd, offb, offs;
-} vnodes[NOVLY];
+       LIBLIST *libsav;
+       STRING  vname;
+       long    ctsav, cdsav, cbsav;
+       long    offt, offd, offb, offtr, offdr, offs;
+} OVERLAY;
+OVERLAY        vnodes[NOVLY];
 
 /* input management */
 
 /* input management */
-struct page {
-       int     nuser;
+typedef struct {
+       short   *fakeptr;
        int     bno;
        int     nibuf;
        int     bno;
        int     nibuf;
-       int     buff[256];
-} page[2];
+       int     nuser;
+       char    buff[512];
+} PAGE;
+
+PAGE   page[2];
 
 struct {
 
 struct {
-       int     nuser;
+       short   *fakeptr;
        int     bno;
        int     bno;
+       int     nibuf;
+       int     nuser;
 } fpage;
 
 } fpage;
 
-struct stream {
-       int     *ptr;
+typedef struct {
+       char    *ptr;
        int     bno;
        int     nibuf;
        int     bno;
        int     nibuf;
-       int     size;
-       struct page     *pno;
-};
-
-struct stream text;
-struct stream reloc;
+       long    size;
+       long    pos;
+       PAGE    *pno;
+} STREAM;
 
 
-struct {
-       char    aname[14];
-       long    atime;
-       char    auid, agid;
-       int     amode;
-       long    asize;
-} archdr;
+STREAM text;
+STREAM reloc;
 
 
-struct {
-       int     fmagic;
-       int     tsize;
-       int     dsize;
-       int     bsize;
-       int     ssize;
-       int     entry;
-       int     pad;
-       int     relflg;
-} filhdr;
+struct ar_hdr archdr;
 
 
+struct exec filhdr;
 
 /* one entry for each archive member referenced;
  * set in first pass; needs restoring for overlays
  */
 
 /* one entry for each archive member referenced;
  * set in first pass; needs restoring for overlays
  */
-struct liblist {
-       long    loc;
-};
 
 
-struct liblist liblist[NROUT];
-struct liblist *libp = liblist;
+LIBLIST        liblist[NROUT];
+LIBLIST        *libp = liblist;
 
 
 /* symbol management */
 
 
 /* symbol management */
-struct symbol {
+typedef struct {
        char    sname[8];
        char    stype;
        char    spare;
        char    sname[8];
        char    stype;
        char    spare;
-       int     svalue;
-};
+       short   symhash;        /* index of hash table entry pointing to this symbol */
+       long    svalue;
+} SYMBOL;
 
 
-struct local {
+typedef struct {
        int locindex;           /* index to symbol in file */
        int locindex;           /* index to symbol in file */
-       struct symbol *locsymbol;       /* ptr to symbol table */
-};
+       SYMBOL *locsymbol;      /* ptr to symbol table */
+} LOCAL;
 
 
-struct symbol  cursym;                 /* current symbol */
-struct symbol  symtab[NSYM];           /* actual symbols */
-struct symbol  **symhash[NSYM];        /* ptr to hash table entry */
-struct symbol  *lastsym;               /* last symbol entered */
-int    symindex;               /* next available symbol table entry */
-struct symbol  *hshtab[NSYM+2];        /* hash table for symbols */
-struct local   local[NSYMPR];
+SYMBOL cursym;                 /* current symbol */
+SYMBOL *symtab;                /* actual symbols */
+SYMBOL *lastsym;               /* last symbol entered */
+SYMBOL *nextsym;               /* next available symbol table entry */
+int nsym;                      /* number of symbols allocated in symtab */
+SYMBOL *hshtab[NSYM+2];        /* hash table for symbols */
+LOCAL  *local;
 
 /* internal symbols */
 
 /* internal symbols */
-struct symbol  *p_etext;
-struct symbol  *p_edata;
-struct symbol  *p_end;
-struct symbol  *entrypt;
+SYMBOL *p_data;
+SYMBOL *p_etext;
+SYMBOL *p_edata;
+SYMBOL *p_end;
+SYMBOL *entrypt;
 
 int    trace;
 /* flags */
 
 int    trace;
 /* flags */
@@ -168,55 +223,79 @@ int       Sflag;          /* discard all except locals and globals*/
 int    rflag;          /* preserve relocation bits, don't define common */
 int    arflag;         /* original copy of rflag */
 int    sflag;          /* discard all symbols */
 int    rflag;          /* preserve relocation bits, don't define common */
 int    arflag;         /* original copy of rflag */
 int    sflag;          /* discard all symbols */
-int    nflag;          /* pure procedure */
-int    Oflag;          /* set magic # to 0405 (overlay) */
+int    nflag = 1;      /* pure procedure */
 int    dflag;          /* define common even with rflag */
 int    iflag;          /* I/D space separated */
 int    dflag;          /* define common even with rflag */
 int    iflag;          /* I/D space separated */
-int    vflag;          /* overlays used */
+BOOL   vflag;          /* overlays used */
 
 int    ofilfnd;
 
 int    ofilfnd;
-char   *ofilename = "l.out";
+char   *ofilename      = "l.out";
 int    infil;
 char   *filname;
 
 int    infil;
 char   *filname;
 
+long   textbase;
 /* cumulative sizes set in pass 1 */
 /* cumulative sizes set in pass 1 */
-int    tsize;
-int    dsize;
-int    bsize;
-int    ssize;
+long   tsize;
+long   dsize;
+long   bsize;
+long   trsize;
+long   drsize;
+long   ssize;
 
 /* symbol relocation; both passes */
 
 /* symbol relocation; both passes */
-int    ctrel;
-int    cdrel;
-int    cbrel;
+long   ctrel;
+long   cdrel;
+long   cbrel;
+long   ctorel;
+long   cdorel;
+long   cborel;
 
 int    errlev;
 int    delarg  = 4;
 
 int    errlev;
 int    delarg  = 4;
-char   tfname[] = "/tmp/ldaXXXXX";
-
-
-/* output management */
-struct buf {
-       int     fildes;
-       int     nleft;
-       int     *xnext;
-       int     iobuf[256];
-};
-struct buf     toutb;
-struct buf     doutb;
-struct buf     troutb;
-struct buf     droutb;
-struct buf     soutb;
-
-struct symbol  **lookup();
-struct symbol  **slookup();
-struct symbol  *lookloc();
+
+
+FILE   *tout;
+FILE   *dout;
+char   *doutn  = "";
+FILE   *trout;
+char   *troutn = "";
+FILE   *drout;
+char   *droutn = "";
+FILE   *sout;
+char   *soutn  = "";
+
+char   *mktemp();
+char   get();
+char   getb();
+short  gets();
+long   get3();
+long   getl();
+SYMBOL **lookup();
+FILE   *tcreat();
+long   round();
+SYMBOL **slookup();
+SYMBOL *lookloc();
+
+symwrite(sp,n,f) SYMBOL *sp; FILE *f; {
+#ifdef vax
+       fwrite(sp,sizeof(*symtab),n,f);
+#else
+       while (n--) {
+               fwrite(sp,sizeof(*symtab)-sizeof(sp->svalue),1,f);
+               writel(&(sp->svalue),1,f); sp++;
+       }
+#endif
+}
 
 delexit()
 {
        unlink("l.out");
 
 delexit()
 {
        unlink("l.out");
+       unlink(doutn);
+       unlink(troutn);
+       unlink(droutn);
+       unlink(soutn);
        if (delarg==0)
        if (delarg==0)
-               chmod(ofilename, 0777 & ~umask(0));
+               chmod(ofilename, 0777);
        exit(delarg);
 }
 
        exit(delarg);
 }
 
@@ -226,18 +305,17 @@ char **argv;
        register int c, i; 
        int num;
        register char *ap, **p;
        register int c, i; 
        int num;
        register char *ap, **p;
-       int found; 
+       BOOL found; 
        int vscan; 
        char save;
 
        if (signal(SIGINT, SIG_IGN) != SIG_IGN)
                signal(SIGINT, delexit);
        int vscan; 
        char save;
 
        if (signal(SIGINT, SIG_IGN) != SIG_IGN)
                signal(SIGINT, delexit);
-       if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
-               signal(SIGTERM, delexit);
        if (argc == 1)
                exit(4);
        p = argv+1;
 
        if (argc == 1)
                exit(4);
        p = argv+1;
 
+       nextsym=symtab=sbrk(0); nsym=0;
        /* scan files once to find symdefs */
        for (c=1; c<argc; c++) {
                if (trace) printf("%s:\n", *p);
        /* scan files once to find symdefs */
        for (c=1; c<argc; c++) {
                if (trace) printf("%s:\n", *p);
@@ -249,7 +327,7 @@ char **argv;
                        switch (ap[i]) {
                        case 'o':
                                if (++c >= argc)
                        switch (ap[i]) {
                        case 'o':
                                if (++c >= argc)
-                                       error(2, "Bad output file");
+                                       error(1, "Bad output file");
                                ofilename = *p++;
                                ofilfnd++;
                                continue;
                                ofilename = *p++;
                                ofilfnd++;
                                continue;
@@ -257,7 +335,7 @@ char **argv;
                        case 'u':
                        case 'e':
                                if (++c >= argc)
                        case 'u':
                        case 'e':
                                if (++c >= argc)
-                                       error(2, "Bad 'use' or 'entry'");
+                                       error(1, "Bad 'use' or 'entry'");
                                enter(slookup(*p++));
                                if (ap[i]=='e')
                                        entrypt = lastsym;
                                enter(slookup(*p++));
                                if (ap[i]=='e')
                                        entrypt = lastsym;
@@ -265,7 +343,7 @@ char **argv;
 
                        case 'v':
                                if (++c >= argc)
 
                        case 'v':
                                if (++c >= argc)
-                                       error(2, "-v: arg missing");
+                                       error(1, "-v: arg missing");
                                vflag=TRUE;
                                vscan = vindex; 
                                found=FALSE;
                                vflag=TRUE;
                                vscan = vindex; 
                                found=FALSE;
@@ -281,13 +359,21 @@ char **argv;
 
                        case 'D':
                                if (++c >= argc)
 
                        case 'D':
                                if (++c >= argc)
-                                       error(2, "-D: arg missing");
-                               num = atoi(*p++);
+                                       error(1, "-D: arg missing");
+                               num = htoi(*p++);
                                if (dsize>num)
                                if (dsize>num)
-                                       error(2, "-D: too small");
+                                       error(1, "-D: too small");
                                dsize = num;
                                continue;
 
                                dsize = num;
                                continue;
 
+                       case 'T':
+                               if (++c >= argc)
+                                       error(1, "-T: arg missing");
+                               if (tsize!=0)
+                                       error(1, "-T: too late, some text already loaded");
+                               textbase = htoi(*p++);
+                               continue;
+
                        case 'l':
                                save = ap[--i]; 
                                ap[i]='-';
                        case 'l':
                                save = ap[--i]; 
                                ap[i]='-';
@@ -321,6 +407,10 @@ char **argv;
                                nflag++;
                                continue;
 
                                nflag++;
                                continue;
 
+                       case 'N':
+                               nflag = 0;
+                               continue;
+
                        case 'd':
                                dflag++;
                                continue;
                        case 'd':
                                dflag++;
                                continue;
@@ -329,16 +419,12 @@ char **argv;
                                iflag++;
                                continue;
 
                                iflag++;
                                continue;
 
-                       case 'O':
-                               Oflag++;
-                               continue;
-
                        case 't':
                                trace++;
                                continue;
 
                        default:
                        case 't':
                                trace++;
                                continue;
 
                        default:
-                               error(2, "bad flag");
+                               error(1, "bad flag");
                        } /*endsw*/
                        break;
                        } /*endfor*/
                        } /*endsw*/
                        break;
                        } /*endfor*/
@@ -346,24 +432,28 @@ char **argv;
                        load1arg(ap);
        }
        endload(argc, argv);
                        load1arg(ap);
        }
        endload(argc, argv);
+       exit(0);
 }
 
 /* used after pass 1 */
 }
 
 /* used after pass 1 */
-int    nsym;
-int    torigin;
-int    dorigin;
-int    borigin;
+long   torigin;
+long   dorigin;
+long   borigin;
+long   database;
 
 endload(argc, argv)
 int argc; 
 char **argv;
 {
        register int c, i; 
 
 endload(argc, argv)
 int argc; 
 char **argv;
 {
        register int c, i; 
-       int dnum;
+       long dnum;
        register char *ap, **p;
        register char *ap, **p;
+
+       brk(nextsym);
        filname = 0;
        middle();
        setupout();
        filname = 0;
        middle();
        setupout();
+       if (-1==(local=sbrk(NSYMPR*sizeof(*local)))) error(1,"Memory overflow");
        p = argv+1;
        libp = liblist;
        for (c=1; c<argc; c++) {
        p = argv+1;
        libp = liblist;
        for (c=1; c<argc; c++) {
@@ -373,11 +463,8 @@ char **argv;
                        for (i=1; ap[i]; i++) {
                        switch (ap[i]) {
                        case 'D':
                        for (i=1; ap[i]; i++) {
                        switch (ap[i]) {
                        case 'D':
-                               for (dnum = atoi(*p); dorigin<dnum; dorigin += 2) {
-                                       putw(0, &doutb);
-                                       if (rflag)
-                                               putw(0, &droutb);
-                               }
+                               for (dnum = htoi(*p); dorigin<dnum; dorigin++) putc(0, dout);
+                       case 'T':
                        case 'u':
                        case 'e':
                        case 'o':
                        case 'u':
                        case 'e':
                        case 'o':
@@ -403,18 +490,20 @@ char **argv;
 
 record(c, nam)
 int c; 
 
 record(c, nam)
 int c; 
-char *nam;
+STRING nam;
 {
 {
-       register struct overlay *v;
+       register OVERLAY *v;
 
        v = &vnodes[vindex++];
        v->argsav = c;
 
        v = &vnodes[vindex++];
        v->argsav = c;
-       v->symsav = symindex;
+       v->symsav = nextsym-symtab;
        v->libsav = libp;
        v->vname = nam;
        v->offt = tsize; 
        v->offd = dsize; 
        v->offb = bsize; 
        v->libsav = libp;
        v->vname = nam;
        v->offt = tsize; 
        v->offd = dsize; 
        v->offb = bsize; 
+       v->offtr = trsize;
+       v->offdr = drsize;
        v->offs = ssize;
        v->ctsav = ctrel; 
        v->cdsav = cdrel; 
        v->offs = ssize;
        v->ctsav = ctrel; 
        v->cdsav = cdrel; 
@@ -424,8 +513,8 @@ char *nam;
 restore(vscan)
 int vscan;
 {
 restore(vscan)
 int vscan;
 {
-       register struct overlay *v;
-       register int saved;
+       register OVERLAY *v;
+       register SYMBOL *saved,*sp;
 
        v = &vnodes[vscan];
        vindex = vscan+1;
 
        v = &vnodes[vscan];
        vindex = vscan+1;
@@ -436,133 +525,76 @@ int vscan;
        tsize = v->offt; 
        dsize = v->offd; 
        bsize = v->offb; 
        tsize = v->offt; 
        dsize = v->offd; 
        bsize = v->offb; 
+       trsize = v->offtr;
+       drsize = v->offdr;
        ssize = v->offs;
        ssize = v->offs;
-       saved = v->symsav;
-       while (symindex>saved)
-               *symhash[--symindex]=0;
+       saved = symtab + v->symsav;
+       sp = nextsym;
+       while (sp>saved)
+               hshtab[(--sp)->symhash]=0;
+       nextsym = saved;
 }
 
 /* scan file to find defined symbols */
 }
 
 /* scan file to find defined symbols */
-load1arg(acp)
-char *acp;
+load1arg(cp)
+register char *cp;
 {
 {
-       register char *cp;
-       long nloc;
+       long loc;
 
 
-       cp = acp;
-       switch ( getfile(cp)) {
-       case 0:
+       if (getfile(cp)==0)
                load1(0, 0L);
                load1(0, 0L);
-               break;
-
-       /* regular archive */
-       case 1:
-               nloc = 1;
-               while ( step(nloc))
-                       nloc += (archdr.asize + sizeof(archdr) + 1) >> 1;
-               break;
-
-       /* table of contents */
-       case 2:
-               tnum = archdr.asize / sizeof(struct tab);
-               if (tnum >= TABSZ) {
-                       error(2, "fast load buffer too small");
+       else {
+               loc = sizeof(int);
+               for (;;) {
+                       dseek(&text, loc, (long)sizeof(archdr));
+                       if (text.size <= 0) {
+                               libp->loc = -1;
+                               libp++;
+                               return;
+                       }
+                       mget((short *)&archdr, sizeof archdr, &text);
+                       if (load1(1, loc+sizeof(archdr))) {
+                               libp->loc = loc;
+                               libp++;
+                       }
+#ifndef vax
+                       if (archdr.ar_size.loword==0) fixl(&archdr.ar_size);
+#endif
+                       loc += round(archdr.ar_size, 1) + sizeof(archdr);
                }
                }
-               lseek(infil, (long)(sizeof(filhdr.fmagic)+sizeof(archdr)), 0);
-               read(infil, (char *)tab, tnum * sizeof(struct tab));
-               while (ldrand());
-               libp->loc = -1;
-               libp++;
-               break;
-       /* out of date table of contents */
-       case 3:
-               error(0, "out of date (warning)");
-               for(nloc = 1+((archdr.asize+sizeof(archdr)+1) >> 1); step(nloc);
-                       nloc += (archdr.asize + sizeof(archdr) + 1) >> 1);
-               break;
        }
        close(infil);
 }
 
        }
        close(infil);
 }
 
-step(nloc)
-long nloc;
-{
-       dseek(&text, nloc, sizeof archdr);
-       if (text.size <= 0) {
-               libp->loc = -1;
-               libp++;
-               return(0);
-       }
-       mget((int *)&archdr, sizeof archdr);
-       if (load1(1, nloc + (sizeof archdr) / 2)) {
-               libp->loc = nloc;
-               libp++;
-       }
-       return(1);
-}
-
-ldrand()
-{
-       int i;
-       struct symbol *sp, **pp;
-       struct liblist *oldp = libp;
-       for(i = 0; i<tnum; i++) {
-               if ((pp = slookup(tab[i].cname)) == 0)
-                       continue;
-               sp = *pp;
-               if (sp->stype != EXTERN+UNDEF)
-                       continue;
-               step(tab[i].cloc >> 1);
-       }
-       return(oldp != libp);
-}
-
-add(a,b,s)
-int a, b;
-char *s;
-{
-       long r;
-
-       r = (long)(unsigned)a + (unsigned)b;
-       if (r >= 0200000)
-               error(1,s);
-       return(r);
-}
-
-
 /* single file or archive member */
 load1(libflg, loc)
 long loc;
 {
 /* single file or archive member */
 load1(libflg, loc)
 long loc;
 {
-       register struct symbol *sp;
-       int savindex;
-       int ndef, nloc, type, mtype;
+       register SYMBOL *sp;
+       SYMBOL *savnext;
+       int ndef, nlocal, type;
 
        readhdr(loc);
        ctrel = tsize;
        cdrel += dsize;
        cbrel += bsize;
        ndef = 0;
 
        readhdr(loc);
        ctrel = tsize;
        cdrel += dsize;
        cbrel += bsize;
        ndef = 0;
-       nloc = sizeof cursym;
-       savindex = symindex;
-       if ((filhdr.relflg&RELFLG)==1) {
-               error(1, "No relocation bits");
-               return(0);
-       }
-       loc += (sizeof filhdr)/2 + filhdr.tsize + filhdr.dsize;
-       dseek(&text, loc, filhdr.ssize);
+       nlocal = sizeof(cursym);
+       savnext = nextsym;
+/*     if (filhdr.a_trsize+filhdr.a_drsize==0) {
+/*             error(0, "No relocation bits");
+/*             return(0);
+/*     }
+*/
+       loc += filhdr.a_text + filhdr.a_data +
+                       filhdr.a_trsize + filhdr.a_drsize + sizeof(filhdr);
+       dseek(&text, loc, filhdr.a_syms);
        while (text.size > 0) {
        while (text.size > 0) {
-               mget((int *)&cursym, sizeof cursym);
+               symget(&cursym, &text);
                type = cursym.stype;
                type = cursym.stype;
-               if (Sflag) {
-                       mtype = type&037;
-                       if (mtype==1 || mtype>4) {
-                               continue;
-                       }
-               }
                if ((type&EXTERN)==0) {
                if ((type&EXTERN)==0) {
-                       if (Xflag==0 || cursym.sname[0]!='L')
-                               nloc += sizeof cursym;
+                       if (Xflag==0 || cursym.sname[0]!='L' || type&STABTYPS)
+                               nlocal += sizeof cursym;
                        continue;
                }
                symreloc();
                        continue;
                }
                symreloc();
@@ -582,82 +614,99 @@ long loc;
                sp->svalue = cursym.svalue;
        }
        if (libflg==0 || ndef) {
                sp->svalue = cursym.svalue;
        }
        if (libflg==0 || ndef) {
-               tsize = add(tsize,filhdr.tsize,"text overflow");
-               dsize = add(dsize,filhdr.dsize,"data overflow");
-               bsize = add(bsize,filhdr.bsize,"bss overflow");
-               ssize = add(ssize,nloc,"symbol table overflow");
+               tsize += filhdr.a_text;
+               dsize += round(filhdr.a_data, FW);
+               bsize += round(filhdr.a_bss, FW);
+               ssize += nlocal;
+               trsize += filhdr.a_trsize;
+               drsize += filhdr.a_drsize;
                return(1);
        }
        /*
         * No symbols defined by this library member.
         * Rip out the hash table entries and reset the symbol table.
         */
                return(1);
        }
        /*
         * No symbols defined by this library member.
         * Rip out the hash table entries and reset the symbol table.
         */
-       while (symindex>savindex)
-               *symhash[--symindex]=0;
+       while (nextsym>savnext)
+               hshtab[(--nextsym)->symhash]=0;
        return(0);
 }
 
 middle()
 {
        return(0);
 }
 
 middle()
 {
-       register struct symbol *sp, *symp;
-       register t, csize;
-       int nund, corigin;
+       register SYMBOL *sp, *symp;
+       long csize, t, corigin, ocsize;
+       int nund, rnd;
+       char s;
 
 
-       torigin=0; 
-       dorigin=0; 
-       borigin=0;
+       torigin = 0; 
+       dorigin = 0; 
+       borigin = 0;
 
 
+       p_data = *slookup("_data");
        p_etext = *slookup("_etext");
        p_edata = *slookup("_edata");
        p_end = *slookup("_end");
        /*
         * If there are any undefined symbols, save the relocation bits.
         */
        p_etext = *slookup("_etext");
        p_edata = *slookup("_edata");
        p_end = *slookup("_end");
        /*
         * If there are any undefined symbols, save the relocation bits.
         */
-       symp = &symtab[symindex];
+       symp = nextsym;
        if (rflag==0) {
                for (sp = symtab; sp<symp; sp++)
                        if (sp->stype==EXTERN+UNDEF && sp->svalue==0
        if (rflag==0) {
                for (sp = symtab; sp<symp; sp++)
                        if (sp->stype==EXTERN+UNDEF && sp->svalue==0
-                               && sp!=p_end && sp!=p_edata && sp!=p_etext) {
+                               && sp!=p_end && sp!=p_edata && sp!=p_etext
+                               && sp!=p_data) {
                                rflag++;
                                dflag = 0;
                                break;
                        }
        }
                                rflag++;
                                dflag = 0;
                                break;
                        }
        }
-       if (rflag)
-               nflag = sflag = iflag = Oflag = 0;
+       if (rflag) 
+               sflag = iflag = 0;
        /*
         * Assign common locations.
         */
        csize = 0;
        /*
         * Assign common locations.
         */
        csize = 0;
+       database = round(tsize+textbase, (nflag? PAGRND:FW));
        if (dflag || rflag==0) {
        if (dflag || rflag==0) {
+               ldrsym(p_data, (long)0 , EXTERN+DATA);
                ldrsym(p_etext, tsize, EXTERN+TEXT);
                ldrsym(p_edata, dsize, EXTERN+DATA);
                ldrsym(p_end, bsize, EXTERN+BSS);
                ldrsym(p_etext, tsize, EXTERN+TEXT);
                ldrsym(p_edata, dsize, EXTERN+DATA);
                ldrsym(p_end, bsize, EXTERN+BSS);
-               for (sp = symtab; sp<symp; sp++)
-                       if (sp->stype==EXTERN+UNDEF && (t = sp->svalue)!=0) {
-                               t = (t+1) & ~01;
+               for (sp = symtab; sp<symp; sp++) {
+                       if ((s=sp->stype)==EXTERN+UNDEF && (t = sp->svalue)!=0) {
+                               if (t>DW)
+                                       rnd = DW;
+                               else if (t>FW)
+                                       rnd = FW;
+                               else
+                                       rnd = HW;
+                               csize = round(csize, rnd);
                                sp->svalue = csize;
                                sp->stype = EXTERN+COMM;
                                sp->svalue = csize;
                                sp->stype = EXTERN+COMM;
-                               csize = add(csize, t, "bss overflow");
+                               ocsize = csize; 
+                               csize += t;
+                       }
+                       if (((s&TMASK) == EXTERN+UNDEF) && (s & STABTYPS)) {
+                               sp->svalue = ocsize;
+                               sp->stype = (s & STABTYPS) | (EXTERN+COMM);
                        }
                        }
+               }
        }
        /*
         * Now set symbols to their final value
         */
        }
        /*
         * Now set symbols to their final value
         */
-       if (nflag || iflag)
-               tsize = (tsize + 077) & ~077;
-       dorigin = tsize;
-       if (nflag)
-               dorigin = (tsize+017777) & ~017777;
-       if (iflag)
-               dorigin = 0;
+       csize = round(csize, FW);
+       torigin = textbase;
+       dorigin = database;
        corigin = dorigin + dsize;
        borigin = corigin + csize;
        corigin = dorigin + dsize;
        borigin = corigin + csize;
+       cdorel = 0;
+       cborel = dsize+csize;
        nund = 0;
        nund = 0;
-       for (sp = symtab; sp<symp; sp++) switch (sp->stype) {
+       for (sp = symtab; sp<symp; sp++) switch (sp->stype & TMASK) {
        case EXTERN+UNDEF:
                errlev |= 01;
        case EXTERN+UNDEF:
                errlev |= 01;
-               if (arflag==0 && sp->svalue==0) {
+               if ((arflag==0 || dflag) && sp->svalue==0) {
                        if (nund==0)
                                printf("Undefined:\n");
                        nund++;
                        if (nund==0)
                                printf("Undefined:\n");
                        nund++;
@@ -682,81 +731,87 @@ middle()
                continue;
 
        case EXTERN+COMM:
                continue;
 
        case EXTERN+COMM:
-               sp->stype = EXTERN+BSS;
+               sp->stype = (sp->stype & STABTYPS) | (EXTERN+BSS);
                sp->svalue += corigin;
                continue;
        }
        if (sflag || xflag)
                ssize = 0;
                sp->svalue += corigin;
                continue;
        }
        if (sflag || xflag)
                ssize = 0;
-       bsize = add(bsize, csize, "bss overflow");
+       bsize += csize;
        nsym = ssize / (sizeof cursym);
 }
 
 ldrsym(asp, val, type)
        nsym = ssize / (sizeof cursym);
 }
 
 ldrsym(asp, val, type)
-struct symbol *asp;
+long val;
+SYMBOL *asp;
 {
 {
-       register struct symbol *sp;
+       register SYMBOL *sp;
 
        if ((sp = asp) == 0)
                return;
        if (sp->stype != EXTERN+UNDEF || sp->svalue) {
                printf("%.8s: ", sp->sname);
 
        if ((sp = asp) == 0)
                return;
        if (sp->stype != EXTERN+UNDEF || sp->svalue) {
                printf("%.8s: ", sp->sname);
-               error(1, "Multiply defined");
+               error(0, "Multiply defined (internal)");
                return;
        }
        sp->stype = type;
        sp->svalue = val;
 }
 
                return;
        }
        sp->stype = type;
        sp->svalue = val;
 }
 
+extern char _sibuf[BUFSIZ]; /* the space is forced upon us; might as well use it */
+
 setupout()
 {
 setupout()
 {
-       tcreat(&toutb, 0);
-       mktemp(tfname);
-       tcreat(&doutb, 1);
+       tout = fopen(ofilename, "w");
+       if (tout==NULL)
+               error(1, "cannot create output");
+       setbuf(tout,_sibuf);
+       dout = tcreat(&doutn, "/tmp/ldaaXXXXX");
        if (sflag==0 || xflag==0)
        if (sflag==0 || xflag==0)
-               tcreat(&soutb, 1);
+               sout = tcreat(&soutn, "/tmp/ldbaXXXXX");
        if (rflag) {
        if (rflag) {
-               tcreat(&troutb, 1);
-               tcreat(&droutb, 1);
+               trout = tcreat(&troutn, "/tmp/ldcaXXXXX");
+               drout = tcreat(&droutn, "/tmp/lddaXXXXX");
        }
        }
-       filhdr.fmagic = (Oflag ? OMAGIC :( iflag ? IMAGIC : ( nflag ? NMAGIC : FMAGIC )));
-       filhdr.tsize = tsize;
-       filhdr.dsize = dsize;
-       filhdr.bsize = bsize;
-       filhdr.ssize = sflag? 0: (ssize + (sizeof cursym)*symindex);
+       filhdr.a_magic = nflag? NMAGIC:OMAGIC;
+       filhdr.a_text = nflag? tsize:round(tsize, FW);
+       filhdr.a_data = dsize;
+       filhdr.a_bss = bsize;
+       filhdr.a_trsize = trsize;
+       filhdr.a_drsize = drsize;
+       filhdr.a_syms = sflag? 0: (ssize + (sizeof cursym)*(nextsym-symtab));
        if (entrypt) {
                if (entrypt->stype!=EXTERN+TEXT)
        if (entrypt) {
                if (entrypt->stype!=EXTERN+TEXT)
-                       error(1, "Entry point not in text");
+                       error(0, "Entry point not in text");
                else
                else
-                       filhdr.entry = entrypt->svalue | 01;
+                       filhdr.a_entry = entrypt->svalue;
        } else
        } else
-               filhdr.entry=0;
-       filhdr.pad = 0;
-       filhdr.relflg = (rflag==0);
-       mput(&toutb, (int *)&filhdr, sizeof filhdr);
+               filhdr.a_entry=0;
+       filhdr.a_trsize = (rflag ? trsize:0);
+       filhdr.a_drsize = (rflag ? drsize:0);
+       writel(&filhdr,8,tout);
 }
 
 }
 
-tcreat(buf, tempflg)
-struct buf *buf;
+FILE *
+tcreat(namep, name)
+char **namep, *name;
 {
 {
-       register int ufd; 
-       char *nam;
-       nam = (tempflg ? tfname : ofilename);
-       if ((ufd = creat(nam, 0666)) < 0)
-               error(2, tempflg?"cannot create temp":"cannot create output");
-       close(ufd); 
-       buf->fildes = open(nam, 2);
-       if (tempflg)
-               unlink(tfname);
-       buf->nleft = sizeof(buf->iobuf)/sizeof(int);
-       buf->xnext = buf->iobuf;
+       register FILE *fp;
+       register char *tnm;
+
+       tnm = mktemp(name);
+       if ((fp = fopen(tnm, "w")) == NULL)
+               error(1, "Cannot create temp file");
+       chmod(tnm, 0600);
+       *namep = tnm;
+       return(fp);
 }
 
 load2arg(acp)
 char *acp;
 {
        register char *cp;
 }
 
 load2arg(acp)
 char *acp;
 {
        register char *cp;
-       register struct liblist *lp;
+       register LIBLIST *lp;
 
        cp = acp;
        if (getfile(cp) == 0) {
 
        cp = acp;
        if (getfile(cp) == 0) {
@@ -767,10 +822,10 @@ char *acp;
                load2(0L);
        } else {        /* scan archive members referenced */
                for (lp = libp; lp->loc != -1; lp++) {
                load2(0L);
        } else {        /* scan archive members referenced */
                for (lp = libp; lp->loc != -1; lp++) {
-                       dseek(&text, lp->loc, sizeof archdr);
-                       mget((int *)&archdr, sizeof archdr);
-                       mkfsym(archdr.aname);
-                       load2(lp->loc + (sizeof archdr) / 2);
+                       dseek(&text, lp->loc, (long)sizeof(archdr));
+                       mget((short *)&archdr, sizeof(archdr), &text);
+                       mkfsym(archdr.ar_name);
+                       load2(lp->loc + (long)sizeof(archdr));
                }
                libp = ++lp;
        }
                }
                libp = ++lp;
        }
@@ -780,10 +835,10 @@ char *acp;
 load2(loc)
 long loc;
 {
 load2(loc)
 long loc;
 {
-       register struct symbol *sp;
-       register struct local *lp;
+       register SYMBOL *sp;
+       register LOCAL *lp;
        register int symno;
        register int symno;
-       int type, mtype;
+       int type;
 
        readhdr(loc);
        ctrel = torigin;
 
        readhdr(loc);
        ctrel = torigin;
@@ -795,143 +850,149 @@ long loc;
         */
        lp = local;
        symno = -1;
         */
        lp = local;
        symno = -1;
-       loc += (sizeof filhdr)/2;
-       dseek(&text, loc + filhdr.tsize + filhdr.dsize, filhdr.ssize);
+       loc += sizeof(filhdr);
+       dseek(&text, loc+filhdr.a_text+filhdr.a_data+
+               filhdr.a_trsize+filhdr.a_drsize, filhdr.a_syms);
        while (text.size > 0) {
                symno++;
        while (text.size > 0) {
                symno++;
-               mget((int *)&cursym, sizeof cursym);
+               symget(&cursym, &text);
                symreloc();
                type = cursym.stype;
                symreloc();
                type = cursym.stype;
-               if (Sflag) {
-                       mtype = type&037;
-                       if (mtype==1 || mtype>4) continue;
-               }
                if ((type&EXTERN) == 0) {
                if ((type&EXTERN) == 0) {
-                       if (!sflag&&!xflag&&(!Xflag||cursym.sname[0]!='L'))
-                               mput(&soutb, (int *)&cursym, sizeof cursym);
+                       if (!sflag&&!xflag&&(!Xflag||cursym.sname[0]!='L'||type&STABTYPS))
+                               symwrite(&cursym, 1, sout);
                        continue;
                }
                if ((sp = *lookup()) == 0)
                        continue;
                }
                if ((sp = *lookup()) == 0)
-                       error(2, "internal error: symbol not found");
+                       error(1, "internal error: symbol not found");
                if (cursym.stype == EXTERN+UNDEF) {
                if (cursym.stype == EXTERN+UNDEF) {
-                       if (lp >= &local[NSYMPR])
-                               error(2, "Local symbol overflow");
+                       if (lp >= local+NSYMPR)
+                               error(1, "Local symbol overflow");
                        lp->locindex = symno;
                        lp++->locsymbol = sp;
                        continue;
                }
                        lp->locindex = symno;
                        lp++->locsymbol = sp;
                        continue;
                }
+               if(cursym.stype & STABTYPS) continue;
                if (cursym.stype!=sp->stype || cursym.svalue!=sp->svalue) {
                        printf("%.8s: ", cursym.sname);
                if (cursym.stype!=sp->stype || cursym.svalue!=sp->svalue) {
                        printf("%.8s: ", cursym.sname);
-                       error(1, "Multiply defined");
+                       error(0, "Multiply defined");
                }
        }
                }
        }
-       dseek(&text, loc, filhdr.tsize);
-       dseek(&reloc, loc + half(filhdr.tsize + filhdr.dsize), filhdr.tsize);
-       load2td(lp, ctrel, &toutb, &troutb);
-       dseek(&text, loc+half(filhdr.tsize), filhdr.dsize);
-       dseek(&reloc, loc+filhdr.tsize+half(filhdr.dsize), filhdr.dsize);
-       load2td(lp, cdrel, &doutb, &droutb);
-       torigin += filhdr.tsize;
-       dorigin += filhdr.dsize;
-       borigin += filhdr.bsize;
+       dseek(&text, loc, filhdr.a_text);
+       dseek(&reloc, loc+filhdr.a_text+filhdr.a_data, filhdr.a_trsize);
+       load2td(lp, ctrel, tout, trout);
+       dseek(&text, loc+filhdr.a_text, filhdr.a_data);
+       dseek(&reloc, loc+filhdr.a_text+filhdr.a_data+filhdr.a_trsize, filhdr.a_drsize);
+       load2td(lp, cdrel, dout, drout);
+       while (filhdr.a_data&FW) {
+               putc(0, dout); filhdr.a_data++;
+       }
+       torigin += filhdr.a_text;
+       dorigin += filhdr.a_data;
+       borigin += filhdr.a_bss;
+       cdorel += filhdr.a_data;
+       cborel += filhdr.a_bss;
 }
 
 load2td(lp, creloc, b1, b2)
 }
 
 load2td(lp, creloc, b1, b2)
-struct local *lp;
-struct buf *b1, *b2;
+LOCAL *lp;
+long creloc;
+FILE *b1, *b2;
 {
 {
-       register r, t;
-       register struct symbol *sp;
+       register r1;
+       register char r2; 
+       register long t;
+       register SYMBOL *sp;
+       long tw,u,l;
 
        for (;;) {
 
        for (;;) {
-               /*
-                        * The pickup code is copied from "get" for speed.
-                        */
-
-               /* next text or data word */
-               if (--text.size <= 0) {
-                       if (text.size < 0)
-                               break;
-                       text.size++;
-                       t = get(&text);
-               } else if (--text.nibuf < 0) {
-                       text.nibuf++;
-                       text.size++;
-                       t = get(&text);
-               } else
-                       t = *text.ptr++;
-
-               /* next relocation word */
-               if (--reloc.size <= 0) {
-                       if (reloc.size < 0)
-                               error(2, "Relocation error");
-                       reloc.size++;
-                       r = get(&reloc);
-               } else if (--reloc.nibuf < 0) {
-                       reloc.nibuf++;
-                       reloc.size++;
-                       r = get(&reloc);
-               } else
-                       r = *reloc.ptr++;
-
-               switch (r&016) {
-
-               case RTEXT:
-                       t += ctrel;
-                       break;
-
-               case RDATA:
-                       t += cdrel;
-                       break;
-
-               case RBSS:
-                       t += cbrel;
-                       break;
-
-               case REXT:
-                       sp = lookloc(lp, r);
-                       if (sp->stype==EXTERN+UNDEF) {
-                               r = (r&01) + ((nsym+(sp-symtab))<<4) + REXT;
-                               break;
+       if (reloc.size==0) {while (text.size) putc(get(&text),b1); break;}
+       t=getl(&reloc); /* position of relocatable stuff */
+       if (rflag) putl(t+creloc,b2); /* remember for subsequent link editing */
+       while (text.pos<t) putc(get(&text),b1); /* advance to proper position */
+       r1=get3(&reloc); /* kind of relocation */
+       r2 = getb(&reloc);
+       switch (r2&06) {/* read raw datum according to its length */
+               case LEN1: tw=get(&text); break;
+               case LEN2: tw=gets(&text); break;
+               case LEN4: tw=getl(&text); break;
+       }
+       if (r2&REXT) {
+               sp=lookloc(lp,r1); /* find the symbol */
+               if (sp->stype==EXTERN+UNDEF) { /* still undefined */
+                       r2=(r2&(REFMASK+REXT+ROFF));
+                       r1 = nsym+(sp-symtab); /* new reloc */
+               }
+               else {
+                       if (sp->stype==EXTERN+DATA && r2&ROFF) {
+                               r1=RDATAO;
+                               r2&=REFMASK;
                        }
                        }
-                       t += sp->svalue;
-                       r = (r&01) + ((sp->stype-(EXTERN+ABS))<<1);
-                       break;
+                       else if (sp->stype==EXTERN+BSS && r2&ROFF) {
+                               r1=RBSSO;
+                               r2&=REFMASK;
+                       }
+                       else if (sp->stype==EXTERN+ABS && r2&ROFF) {
+                               r1=RABSO;
+                               r2&=REFMASK;
+                       }
+                       else if (sp->stype==EXTERN+TEXT && r2&ROFF) {
+                               r1=RTEXTO;
+                               r2&=REFMASK;
+                       }
+                       else {if (r2&ROFF) {if (rflag) {error(0,"!-r; see JFR"); rflag=0;}}
+                                else tw += database;
+                                r1=sp->stype&TYPE;
+                                r2&=REFMASK;
+                       }
+                       tw += sp->svalue - database;
                }
                }
-               if (r&01)
-                       t -= creloc;
-               putw(t, b1);
-               if (rflag)
-                       putw(r, b2);
+       } else switch (r1&TYMASK) {
+               case RTEXT:     tw += ctrel; break;
+               case RTEXTO:tw += round(filhdr.a_text,PAGRND)+ctrel-database; break;
+               case RDATA: tw += cdrel; break;
+               case RDATAO:tw += cdorel; break;
+               case RBSS:      tw += cbrel; break;
+               case RBSSO: tw += cborel-filhdr.a_data; break;
+               case RABSO: tw += round(filhdr.a_text,PAGRND)-database; break;
+       }
+       if (rflag) { /* remember for subsequent link editing */
+               put3(r1,b2);
+               putb(r2,b2);
+       }
+       if (r2&PCREL) tw -= creloc; /* assembler already subtracted text.pos */
+       switch (r2&06) {/* output relocated datum according to its length */
+               case LEN1: l= -128; u=127; putc((char)tw,b1); break;
+               case LEN2: l= -32768; u=32767; puts((short)tw,b1); break;
+               case LEN4: l=0x80000000; u=0x7FFFFFFF; putl(tw,b1); break;
+       }
+       if (tw<l || u<tw) error(0,"Displacement overflow");
        }
 }
 
 finishout()
 {
        }
 }
 
 finishout()
 {
-       register n, *p;
-
-       if (nflag||iflag) {
-               n = torigin;
-               while (n&077) {
-                       n += 2;
-                       putw(0, &toutb);
-                       if (rflag)
-                               putw(0, &troutb);
+
+       if (!nflag)
+               while (tsize&FW) {
+                       putc(0, tout); tsize++;
                }
                }
-       }
-       copy(&doutb);
+       fclose(dout);
+       copy(doutn);
        if (rflag) {
        if (rflag) {
-               copy(&troutb);
-               copy(&droutb);
+               fclose(trout);
+               copy(troutn);
+               fclose(drout);
+               copy(droutn);
        }
        if (sflag==0) {
        }
        if (sflag==0) {
-               if (xflag==0)
-                       copy(&soutb);
-               for (p = (int *)symtab; p < (int *)&symtab[symindex];)
-                       putw(*p++, &toutb);
+               if (xflag==0) {
+                       fclose(sout);
+                       copy(soutn);
+               }
+               symwrite(symtab, nextsym-symtab, tout);
        }
        }
-       flush(&toutb);
-       close(toutb.fildes);
+       fclose(tout);
        if (!ofilfnd) {
                unlink("a.out");
                link("l.out", "a.out");
        if (!ofilfnd) {
                unlink("a.out");
                link("l.out", "a.out");
@@ -941,21 +1002,17 @@ finishout()
        delexit();
 }
 
        delexit();
 }
 
-copy(buf)
-struct buf *buf;
+copy(np)
+char *np;
 {
 {
-       register f, *p, n;
-
-       flush(buf);
-       lseek(f = buf->fildes, (long)0, 0);
-       while ((n = read(f, (char *)doutb.iobuf, sizeof(doutb.iobuf))) > 1) {
-               n >>= 1;
-               p = (int *)doutb.iobuf;
-               do
-                       putw(*p++, &toutb);
-               while (--n);
-       }
-       close(f);
+       register c;
+       register FILE *fp;
+
+       if ((fp = fopen(np, "r")) == NULL)
+               error(1, "cannot recopy output");
+       while ((c = getc(fp)) != EOF)
+               putc(c, tout);
+       fclose(fp);
 }
 
 mkfsym(s)
 }
 
 mkfsym(s)
@@ -965,65 +1022,78 @@ char *s;
        if (sflag || xflag)
                return;
        cp8c(s, cursym.sname);
        if (sflag || xflag)
                return;
        cp8c(s, cursym.sname);
-       cursym.stype = 037;
+       cursym.stype = TEXT;
        cursym.svalue = torigin;
        cursym.svalue = torigin;
-       mput(&soutb, (int *)&cursym, sizeof cursym);
+       symwrite(&cursym, 1, sout);
 }
 
 }
 
-mget(aloc, an)
-int *aloc;
+mget(loc, n, sp)
+register STREAM *sp;
+register char *loc;
 {
 {
-       register *loc, n;
-       register *p;
-
-       n = an;
-       n >>= 1;
-       loc = aloc;
-       if ((text.nibuf -= n) >= 0) {
-               if ((text.size -= n) > 0) {
-                       p = text.ptr;
+       register char *p;
+
+       if ((sp->nibuf -= n) >= 0) {
+               if ((sp->size -= n) > 0) {
+                       p = sp->ptr;
+                       sp->pos += n;
                        do
                                *loc++ = *p++;
                        while (--n);
                        do
                                *loc++ = *p++;
                        while (--n);
-                       text.ptr = p;
+                       sp->ptr = p;
                        return;
                } else
                        return;
                } else
-                       text.size += n;
+                       sp->size += n;
        }
        }
-       text.nibuf += n;
+       sp->nibuf += n;
        do {
        do {
-               *loc++ = get(&text);
-       } 
-       while (--n);
+               *loc++ = get(sp);
+       } while (--n);
 }
 
 }
 
-mput(buf, aloc, an)
-struct buf *buf; 
-int *aloc;
-{
-       register *loc;
-       register n;
+short
+gets(sp) STREAM *sp; {
+short t; mget(&t,2,sp); return(t);
+}
 
 
-       loc = aloc;
-       n = an>>1;
-       do {
-               putw(*loc++, buf);
-       } 
-       while (--n);
+char
+getb(sp) STREAM *sp; {
+char t; mget(&t,1,sp); return(t);
 }
 
 }
 
-dseek(asp, aloc, s)
-long aloc;
-struct stream *asp;
+long
+get3(sp) STREAM *sp; {
+long t; t=0; mget(&t,3,sp); return(t);
+}
+
+long
+getl(sp) STREAM *sp; {
+       long t; mget(&t,4,sp);
+#ifndef vax
+       fixl(&t);
+#endif
+       return(t);
+}
+
+symget(sp,f) SYMBOL *sp; STREAM *f; {
+       mget(sp,sizeof(*sp),f);
+#ifndef vax
+       fixl(&sp->svalue);
+#endif
+}
+
+dseek(sp, loc, s)
+register STREAM *sp;
+long loc, s;
 {
 {
-       register struct stream *sp;
-       register struct page *p;
-       /* register */ long b, o;
+       register PAGE *p;
+       register b, o;
        int n;
 
        int n;
 
-       b = aloc >> 8;
-       o = aloc & 0377;
-       sp = asp;
+       b = loc>>9;
+       o = loc&0777;
+       if (o&01)
+               error(1, "loader error; odd offset");
        --sp->pno->nuser;
        if ((p = &page[0])->bno!=b && (p = &page[1])->bno!=b)
                if (p->nuser==0 || (p = &page[0])->nuser==0) {
        --sp->pno->nuser;
        if ((p = &page[0])->bno!=b && (p = &page[1])->bno!=b)
                if (p->nuser==0 || (p = &page[0])->nuser==0) {
@@ -1031,57 +1101,53 @@ struct stream *asp;
                                if (page[0].bno < page[1].bno)
                                        p = &page[0];
                        p->bno = b;
                                if (page[0].bno < page[1].bno)
                                        p = &page[0];
                        p->bno = b;
-                       lseek(infil, (aloc & ~0377L) << 1, 0);
-                       if ((n = read(infil, (char *)p->buff, 512)>>1) < 0)
+                       lseek(infil, loc & ~0777L, 0);
+                       if ((n = read(infil, p->buff, sizeof(p->buff))) < 0)
                                n = 0;
                        p->nibuf = n;
        } else
                                n = 0;
                        p->nibuf = n;
        } else
-               error(2, "No pages");
+               error(1, "No pages");
        ++p->nuser;
        sp->bno = b;
        sp->pno = p;
        ++p->nuser;
        sp->bno = b;
        sp->pno = p;
-       sp->ptr = p->buff + o;
-       if (s != -1)
-               sp->size = half(s);
+       if (s != -1) {sp->size = s; sp->pos = 0;}
+       sp->ptr = (short *)(p->buff + o);
        if ((sp->nibuf = p->nibuf-o) <= 0)
                sp->size = 0;
 }
 
        if ((sp->nibuf = p->nibuf-o) <= 0)
                sp->size = 0;
 }
 
-half(i)
-{
-       return((i>>1)&077777);
-}
-
+char
 get(asp)
 get(asp)
-struct stream *asp;
+STREAM *asp;
 {
 {
-       register struct stream *sp;
+       register STREAM *sp;
 
        sp = asp;
 
        sp = asp;
-       if (--sp->nibuf < 0) {
-               dseek(sp, (long)(sp->bno + 1) << 8, -1);
-               --sp->nibuf;
+       if ((sp->nibuf -= sizeof(char)) < 0) {
+               dseek(sp, ((long)(sp->bno+1)<<9), (long)-1);
+               sp->nibuf -= sizeof(char);
        }
        }
-       if (--sp->size <= 0) {
+       if ((sp->size -= sizeof(char)) <= 0) {
                if (sp->size < 0)
                if (sp->size < 0)
-                       error(2, premeof);
+                       error(1, premeof);
                ++fpage.nuser;
                --sp->pno->nuser;
                ++fpage.nuser;
                --sp->pno->nuser;
-               sp->pno = (struct page *)&fpage;
+               sp->pno = &fpage;
        }
        }
+       sp->pos += sizeof(char);
        return(*sp->ptr++);
 }
 
 getfile(acp)
        return(*sp->ptr++);
 }
 
 getfile(acp)
-char *acp;
+STRING acp;
 {
 {
-       register char *cp;
+       register STRING cp;
        register int c;
        register int c;
-       struct stat x;
+       int arcmag;
 
        cp = acp; 
        infil = -1;
 
        cp = acp; 
        infil = -1;
-       archdr.aname[0] = '\0';
+       archdr.ar_name[0] = '\0';
        filname = cp;
        if (cp[0]=='-' && cp[1]=='l') {
                if(cp[2] == '\0')
        filname = cp;
        if (cp[0]=='-' && cp[1]=='l') {
                if(cp[2] == '\0')
@@ -1097,37 +1163,23 @@ char *acp;
                }
        }
        if (infil == -1 && (infil = open(filname, 0)) < 0)
                }
        }
        if (infil == -1 && (infil = open(filname, 0)) < 0)
-               error(2, "cannot open");
+               error(1, "cannot open");
        page[0].bno = page[1].bno = -1;
        page[0].nuser = page[1].nuser = 0;
        page[0].bno = page[1].bno = -1;
        page[0].nuser = page[1].nuser = 0;
-       text.pno = reloc.pno = (struct page *)&fpage;
+       text.pno = reloc.pno = &fpage;
        fpage.nuser = 2;
        fpage.nuser = 2;
-       dseek(&text, 0L, 2);
+       dseek(&text, 0L, (long)sizeof(int));
        if (text.size <= 0)
        if (text.size <= 0)
-               error(2, premeof);
-       if(get(&text) != ARCMAGIC)
-               return(0);      /* regualr file */
-       dseek(&text, 1L, sizeof archdr);        /* word addressing */
-       if(text.size <= 0)
-               return(1);      /* regular archive */
-       mget((int *)&archdr, sizeof archdr);
-       if(strncmp(archdr.aname, goodnm, 14) != 0)
-               return(1);      /* regular archive */
-       else {
-               fstat(infil, &x);
-               if(x.st_mtime > archdr.atime)
-               {
-                       return(3);
-               }
-               else return(2);
-       }
+               error(1, premeof);
+       mget(&arcmag, sizeof(arcmag), &text);
+       return(arcmag==ARMAG);
 }
 
 }
 
-struct symbol **lookup()
+SYMBOL **lookup()
 {
        int i; 
 {
        int i; 
-       int clash;
-       register struct symbol **hp;
+       BOOL clash;
+       register SYMBOL **hp;
        register char *cp, *cp1;
 
        i = 0;
        register char *cp, *cp1;
 
        i = 0;
@@ -1150,7 +1202,7 @@ struct symbol **lookup()
        return(hp);
 }
 
        return(hp);
 }
 
-struct symbol **slookup(s)
+SYMBOL **slookup(s)
 char *s;
 {
        cp8c(s, cursym.sname);
 char *s;
 {
        cp8c(s, cursym.sname);
@@ -1160,17 +1212,21 @@ char *s;
 }
 
 enter(hp)
 }
 
 enter(hp)
-struct symbol **hp;
+register SYMBOL **hp;
 {
 {
-       register struct symbol *sp;
+       register SYMBOL *sp;
 
        if (*hp==0) {
 
        if (*hp==0) {
-               if (symindex>=NSYM)
-                       error(2, "Symbol table overflow");
-               symhash[symindex] = hp;
-               *hp = lastsym = sp = &symtab[symindex++];
+               if ((nextsym-symtab)>=NSYM)
+                       error(1, "Symbol table overflow");
+               if ((nextsym-symtab)>=nsym) {
+                       if (-1==sbrk(NSYM/5 * sizeof(*symtab))) error(1,"Memory overflow");
+                       nsym += NSYM/5;
+               }
+               *hp = lastsym = sp = nextsym++;
                cp8c(cursym.sname, sp->sname);
                sp->stype = cursym.stype;
                cp8c(cursym.sname, sp->sname);
                sp->stype = cursym.stype;
+               sp->symhash = hp-hshtab;
                sp->svalue = cursym.svalue;
                return(1);
        } else {
                sp->svalue = cursym.svalue;
                return(1);
        } else {
@@ -1181,7 +1237,7 @@ struct symbol **hp;
 
 symreloc()
 {
 
 symreloc()
 {
-       switch (cursym.stype) {
+       switch (cursym.stype & 017) {
 
        case TEXT:
        case EXTERN+TEXT:
 
        case TEXT:
        case EXTERN+TEXT:
@@ -1212,46 +1268,55 @@ char *s;
                printf("ld:");
        if (filname) {
                printf("%s", filname);
                printf("ld:");
        if (filname) {
                printf("%s", filname);
-               if (archdr.aname[0])
-                       printf("(%.14s)", archdr.aname);
+               if (archdr.ar_name[0])
+                       printf("(%.14s)", archdr.ar_name);
                printf(": ");
        }
        printf("%s\n", s);
                printf(": ");
        }
        printf("%s\n", s);
-       if (n > 1)
+       if (n)
                delexit();
                delexit();
-       errlev = n;
+       errlev = 2;
 }
 
 }
 
-struct symbol *
-lookloc(alp, r)
-struct local *alp;
+SYMBOL *
+lookloc(lp, r)
+register LOCAL *lp;
 {
 {
-       register struct local *clp, *lp;
+       register LOCAL *clp;
        register sn;
 
        register sn;
 
-       lp = alp;
-       sn = (r>>4) & 07777;
+       sn = r;
        for (clp = local; clp<lp; clp++)
                if (clp->locindex == sn)
                        return(clp->locsymbol);
        for (clp = local; clp<lp; clp++)
                if (clp->locindex == sn)
                        return(clp->locsymbol);
-       error(2, "Local symbol botch");
+       error(1, "Local symbol botch");
 }
 
 readhdr(loc)
 long loc;
 {
 }
 
 readhdr(loc)
 long loc;
 {
-       register st, sd;
-
-       dseek(&text, loc, sizeof filhdr);
-       mget((int *)&filhdr, sizeof filhdr);
-       if (filhdr.fmagic != FMAGIC)
-               error(2, "Bad format");
-       st = (filhdr.tsize+01) & ~01;
-       filhdr.tsize = st;
-       cdrel = -st;
-       sd = (filhdr.dsize+01) & ~01;
-       cbrel = - (st+sd);
-       filhdr.bsize = (filhdr.bsize+01) & ~01;
+       long *p; int i;
+       dseek(&text, loc, (long)sizeof(filhdr));
+       mget((short *)&filhdr, sizeof(filhdr), &text);
+#ifndef vax
+       for (p= &filhdr,i=8;--i>=0;) fixl(p++);
+#endif
+       if (filhdr.a_magic!=A_MAGIC1 && filhdr.a_magic!=A_MAGIC2 &&
+               filhdr.a_magic!=A_MAGIC3 && filhdr.a_magic!=A_MAGIC4)
+                       error(1,"Bad magic number");
+       if (filhdr.a_text&01 || filhdr.a_data&01) {
+               printf("tsize=%X  dsize=%X\n",filhdr.a_text,filhdr.a_data);
+               error(1, "Text/data size odd");
+       }
+       filhdr.a_bss = round(filhdr.a_bss, FW);
+       if (filhdr.a_magic == NMAGIC) {
+               cdrel = -round(filhdr.a_text, PAGRND);
+               cbrel = cdrel - filhdr.a_data;
+       } else if (filhdr.a_magic == OMAGIC) {
+               cdrel = -filhdr.a_text;
+               cbrel = cdrel - filhdr.a_data;
+       } else
+               error(1, "Bad format");
 }
 
 cp8c(from, to)
 }
 
 cp8c(from, to)
@@ -1268,8 +1333,8 @@ char *from, *to;
 }
 
 eq(s1, s2)
 }
 
 eq(s1, s2)
-char *s1; 
-char *s2;
+STRING s1; 
+STRING s2;
 {
        while (*s1==*s2++)
                if ((*s1++)==0)
 {
        while (*s1==*s2++)
                if ((*s1++)==0)
@@ -1277,22 +1342,35 @@ char *s2;
        return(FALSE);
 }
 
        return(FALSE);
 }
 
-putw(w, b)
-register struct buf *b;
+long
+round(v, r)
+long v;
+unsigned r;
 {
 {
-       *(b->xnext)++ = w;
-       if (--b->nleft <= 0)
-               flush(b);
+       v += r;
+       v &= ~(long)r;
+       return(v);
 }
 
 }
 
-flush(b)
-register struct buf *b;
-{
-       register n;
+puts(w, f)
+FILE *f; short w; {
+fwrite(&w,sizeof(short),1,f);
+}
+
+putb(w, f)
+FILE *f; char w; {
+fwrite(&w,sizeof(char),1,f);
+}
+
+put3(w, f)
+FILE *f; long w; {
+fwrite(&w,3,1,f);
+}
 
 
-       if ((n = (char *)b->xnext - (char *)b->iobuf) > 0)
-               if (write(b->fildes, (char *)b->iobuf, n) != n)
-                       error(2, "output error");
-       b->xnext = b->iobuf;
-       b->nleft = sizeof(b->iobuf)/sizeof(int);
+putl(w, f)
+FILE *f; long w; {
+#ifndef vax
+       fixl(&w);
+#endif
+       fwrite(&w,sizeof(long),1,f);
 }
 }
index 43efc11..048dcad 100644 (file)
@@ -13,13 +13,15 @@ OBJECTS = copy.o dounit.o learn.o list.o mem.o \
 
 CFLAGS = -O
 LIBRARY =
 
 CFLAGS = -O
 LIBRARY =
-LLIB   = /usr/lib/learn
+LLIB   = $(DESTDIR)/usr/lib/learn
 
 
-cp:    all
-       cp learn /bin
-       cp tee $(LLIB)
-       cp lcount $(LLIB)
-       rm learn tee lcount *.o
+all:   learn tee lcount
+       
+install:       all
+       install -s learn $(DESTDIR)/usr/bin
+       install -s tee $(LLIB)
+       install -s lcount $(LLIB)
+       rm *.o
        @echo "Now do 'make lessons' if you need to extract the lesson archives"
        @echo "Then do 'make play; make log' to make playpen and log directories"
 
        @echo "Now do 'make lessons' if you need to extract the lesson archives"
        @echo "Then do 'make play; make log' to make playpen and log directories"
 
@@ -29,16 +31,14 @@ cmp:        all
        cmp lcount $(LLIB)/lcount
        rm learn tee lcount *.o
 
        cmp lcount $(LLIB)/lcount
        rm learn tee lcount *.o
 
-all:   learn tee lcount
-
 learn: $(OBJECTS)
 learn: $(OBJECTS)
-       cc -n -s -o learn $(CFLAGS) $(OBJECTS) $(LIBRARY)
+       cc -o learn $(CFLAGS) $(OBJECTS) $(LIBRARY)
 
 $(OBJECTS): lrnref
 learn.o: lrndef
 
 lcount tee:
 
 $(OBJECTS): lrnref
 learn.o: lrndef
 
 lcount tee:
-       cc $(CFLAGS) -s -n $@.c -o $@ $(LIBRARY)
+       cc $(CFLAGS) $@.c -o $@ $(LIBRARY)
 
 lessons:       $(LESSONS)
 
 
 lessons:       $(LESSONS)
 
diff --git a/usr/src/cmd/learn/omakefile b/usr/src/cmd/learn/omakefile
new file mode 100644 (file)
index 0000000..4ea6d42
--- /dev/null
@@ -0,0 +1,69 @@
+LESSONS = files editor morefiles macros eqn C
+
+FILES = lrndef lrnref \
+       copy.c dounit.c learn.c list.c \
+       makpipe.c maktee.c mem.c mysys.c selsub.c selunit.c \
+       start.c whatnow.c wrapup.c \
+       lcount.c tee.c \
+       makefile
+
+OBJECTS = copy.o dounit.o learn.o list.o mem.o \
+       makpipe.o maktee.o mysys.o selsub.o selunit.o \
+       start.o whatnow.o wrapup.o
+
+CFLAGS = -O
+LIBRARY =
+LLIB   = /usr/lib/learn
+
+cp:    all
+       cp learn /bin
+       cp tee $(LLIB)
+       cp lcount $(LLIB)
+       rm learn tee lcount *.o
+       @echo "Now do 'make lessons' if you need to extract the lesson archives"
+
+cmp:   all
+       cmp learn /bin/learn
+       cmp tee $(LLIB)/tee
+       cmp lcount $(LLIB)/lcount
+       rm learn tee lcount *.o
+
+all:   learn tee lcount
+
+learn: $(OBJECTS)
+       cc -n -s -o learn $(CFLAGS) $(OBJECTS) $(LIBRARY)
+
+$(OBJECTS): lrnref
+learn.o: lrndef
+
+tee:
+       cc $(CFLAGS) -s -n tee.c -o tee $(LIBRARY)
+
+lcount:
+       cc $(CFLAGS) -s -n lcount.c -o lcount $(LIBRARY)
+
+lessons:       $(LESSONS)
+
+files:
+       -if test ! -r $(LLIB)/files; then mkdir $(LLIB)/files; fi
+       (cd $(LLIB)/files; ar x ../files.a)
+
+morefiles:
+       -if test ! -r $(LLIB)/morefiles; then mkdir $(LLIB)/morefiles; fi
+       (cd $(LLIB)/morefiles; ar x ../morefiles.a)
+
+editor:
+       -if test ! -r $(LLIB)/editor; then mkdir $(LLIB)/editor; fi
+       (cd $(LLIB)/editor; ar x ../editor.a)
+
+macros:
+       -if test ! -r $(LLIB)/macros; then mkdir $(LLIB)/macros; fi
+       (cd $(LLIB)/macros; ar x ../macros.a)
+
+eqn:
+       -if test ! -r $(LLIB)/eqn; then mkdir $(LLIB)/eqn; fi
+       (cd $(LLIB)/eqn; ar x ../eqn.a)
+
+C:
+       -if test ! -r $(LLIB)/C; then mkdir $(LLIB)/C; fi
+       (cd $(LLIB)/C; ar x ../C.a)
diff --git a/usr/src/cmd/learn/origmakefile b/usr/src/cmd/learn/origmakefile
new file mode 100644 (file)
index 0000000..e7aa1f1
--- /dev/null
@@ -0,0 +1,68 @@
+LESSONS = files editor morefiles macros eqn C
+
+FILES = lrndef lrnref \
+       copy.c dounit.c learn.c list.c \
+       makpipe.c maktee.c mem.c mysys.c selsub.c selunit.c \
+       start.c whatnow.c wrapup.c \
+       lcount.c tee.c \
+       makefile ../README
+
+OBJECTS = copy.o dounit.o learn.o list.o mem.o \
+       makpipe.o maktee.o mysys.o selsub.o selunit.o \
+       start.o whatnow.o wrapup.o
+
+CFLAGS = -O
+LIBRARY = -lS
+
+a.out: $(OBJECTS)
+       cc -n $(CFLAGS) $(OBJECTS) $(LIBRARY)
+
+$(OBJECTS): lrnref
+learn.o: lrndef
+
+list:
+       pr $(FILES)
+
+bin:
+       cp a.out /usr/bin/learn
+       strip /usr/bin/learn
+
+lcount tee:
+       cc $(CFLAGS) -s $@.c -o ../lib/$@ $(LIBRARY)
+
+lessons:       $(LESSONS)
+
+play log:
+       -rm -r ../lib/$@; mkdir ../lib/$@; chmod +w ../lib/$@
+
+$(LESSONS):
+       -rm -r ../lib/$@
+       mkdir ../lib/$@
+       (cd ../lib/$@; ar x ../$@.a)
+
+everything:    a.out bin tee lcount lessons play log check
+
+archives:
+       (cd ../lib/files; ar r ../files.a L*)
+       (cd ../lib/morefiles; ar r ../morefiles.a L*)
+       (cd ../lib/editor; ar r ../editor.a L*)
+       (cd ../lib/macros; ar r ../macros.a L*)
+       (cd ../lib/eqn; ar r ../eqn.a L* tinyms Init)
+       (cd ../lib/C; ar r ../C.a L* get*)
+
+export:
+       : make the directories
+       mkdir export export/source export/lib
+       : copy source files
+       -cp $(FILES) export/source
+       : non-directories in lib
+       -for i in ../lib/*;\
+       do if test -f $$i; then cp $$i export/lib; fi;\
+       done
+
+check:
+       -@test -r ../lib/tee || echo 'tee not present; make tee'
+       -@test -r ../lib/lcount || echo 'lcount not present; make lcount'
+       -@test -r ../lib/play || echo 'play directory not present; make play'
+       -@test -r ../lib/log || echo 'log directory not present; make log'
+       -@for i in $(LESSONS); do test -r ../lib/$$i/L0 || echo $$i not unarchived, make $$i; done
diff --git a/usr/src/cmd/learn/temp b/usr/src/cmd/learn/temp
new file mode 100644 (file)
index 0000000..8fe50c0
--- /dev/null
@@ -0,0 +1,5 @@
+play:
+       -rm -r ../lib/play; mkdir ../lib/play; chmod +w ../lib/play
+
+log:
+       -rm -r ../lib/log; mkdir ../lib/log; chmod +w ../lib/log
diff --git a/usr/src/cmd/lex/Makefile b/usr/src/cmd/lex/Makefile
new file mode 100644 (file)
index 0000000..b70572b
--- /dev/null
@@ -0,0 +1,27 @@
+CFLAGS = -O
+
+all: lex
+
+lex: lmain.o y.tab.o sub1.o sub2.o header.o
+       cc lmain.o y.tab.o sub1.o sub2.o header.o -o lex
+
+smallex:
+       cc -DSMALL -O lmain.c y.tab.c sub1.c sub2.c header.c -o smallex
+
+y.tab.c: parser.y
+       yacc parser.y
+lmain.o:lmain.c ldefs.c once.c
+       cc -c -O lmain.c
+sub1.o: sub1.c ldefs.c
+       cc -c -O sub1.c
+sub2.o: sub2.c ldefs.c
+       cc -c -O sub2.c
+header.o: header.c ldefs.c
+       cc -c -O header.c
+
+install: all
+       install -s lex $(DESTDIR)/usr/bin
+       install -c ncform $(DESTDIR)/usr/lib/lex
+
+clean:
+       rm -f *.o lex y.tab.c
diff --git a/usr/src/cmd/lex/err b/usr/src/cmd/lex/err
new file mode 100644 (file)
index 0000000..19ba694
--- /dev/null
@@ -0,0 +1,41 @@
+cc -c -O lmain.c
+"lmain.c", line 123: warning: illegal pointer combination
+"lmain.c", line 124: warning: illegal pointer combination
+"lmain.c", line 126: warning: illegal pointer combination
+"lmain.c", line 139: warning: illegal pointer combination
+"lmain.c", line 140: warning: illegal pointer combination
+"lmain.c", line 142: warning: illegal pointer combination
+"lmain.c", line 143: warning: illegal pointer combination
+"lmain.c", line 144: warning: illegal pointer combination
+"lmain.c", line 147: warning: illegal pointer combination
+"lmain.c", line 148: warning: illegal pointer combination
+"lmain.c", line 171: warning: illegal pointer combination
+"lmain.c", line 172: warning: illegal pointer combination
+"lmain.c", line 173: warning: illegal pointer combination
+"lmain.c", line 193: warning: illegal combination of pointer and integer
+"lmain.c", line 202: warning: illegal combination of pointer and integer
+cc -O -c y.tab.c
+"y.tab.c", line 63: warning: illegal combination of pointer and integer
+"y.tab.c", line 66: warning: illegal combination of pointer and integer
+"y.tab.c", line 68: warning: illegal pointer combination
+"y.tab.c", line 69: warning: illegal pointer combination
+"y.tab.c", line 70: warning: illegal pointer combination
+"y.tab.c", line 72: warning: illegal pointer combination
+"y.tab.c", line 220: warning: illegal combination of pointer and integer
+"y.tab.c", line 233: warning: illegal combination of pointer and integer
+"y.tab.c", line 384: warning: illegal combination of pointer and integer
+"y.tab.c", line 410: warning: illegal combination of pointer and integer
+"y.tab.c", line 454: warning: illegal combination of pointer and integer
+"y.tab.c", line 456: warning: illegal combination of pointer and integer
+"y.tab.c", line 475: warning: illegal combination of pointer and integer
+"parser.y", line 92: warning: illegal combination of pointer and integer
+cc -c -O sub1.c
+"sub1.c", line 488: warning: illegal combination of pointer and integer
+cc -c -O sub2.c
+"sub2.c", line 25: warning: illegal combination of pointer and integer
+"sub2.c", line 39: warning: illegal combination of pointer and integer
+"sub2.c", line 172: warning: illegal combination of pointer and integer
+"sub2.c", line 240: warning: illegal combination of pointer and integer
+"sub2.c", line 851: warning: illegal pointer combination
+cc -c -O header.c
+cc lmain.o y.tab.o sub1.o sub2.o header.o -o lex
index 7f6f663..3ef43af 100644 (file)
@@ -11,8 +11,9 @@ main(argc,argv)
   char **argv; {
        register int i;
 # ifdef DEBUG
   char **argv; {
        register int i;
 # ifdef DEBUG
-       signal(10,buserr);
-       signal(11,segviol);
+#include <signal.h>
+       signal(SIGBUS,buserr);
+       signal(SIGSEGV,segviol);
 # endif
        while (argc > 1 && argv[1][0] == '-' ){
                i = 0;
 # endif
        while (argc > 1 && argv[1][0] == '-' ){
                i = 0;
@@ -62,7 +63,7 @@ main(argc,argv)
                /* may be gotten: name, left, right, nullstr, parent */
        scopy("INITIAL",sp);
        sname[0] = sp;
                /* may be gotten: name, left, right, nullstr, parent */
        scopy("INITIAL",sp);
        sname[0] = sp;
-       sp =+ slength("INITIAL") + 1;
+       sp += slength("INITIAL") + 1;
        sname[1] = 0;
        if(yyparse(0)) exit(1); /* error return code */
                /* may be disposed of: def, subs, dchar */
        sname[1] = 0;
        if(yyparse(0)) exit(1); /* error return code */
                /* may be disposed of: def, subs, dchar */
diff --git a/usr/src/cmd/lex/makefile b/usr/src/cmd/lex/makefile
deleted file mode 100644 (file)
index fc3baf8..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-CFLAGS = -O
-all: lex libln.a
-
-cmp:   all
-       cmp lex /bin/lex
-       ls -l libln.a /lib/libln.a
-       rm -f *.o libln.a lex y.tab.c
-
-cp:    all
-       cp lex /bin/lex
-       cp libln.a /lib
-       rm -f *.o libln.a lex y.tab.c
-
-lex: lmain.o y.tab.o sub1.o sub2.o header.o
-       cc -i -s lmain.o y.tab.o sub1.o sub2.o header.o -o lex
-
-smallex:
-       cc -DSMALL -n -s -O lmain.c y.tab.c sub1.c sub2.c header.c -o smallex
-
-y.tab.c: parser.y
-       yacc parser.y
-
-lmain.o:lmain.c ldefs.c once.c
-       cc -c -O lmain.c
-
-sub1.o: sub1.c ldefs.c
-       cc -c -O sub1.c
-
-sub2.o: sub2.c ldefs.c
-       cc -c -O sub2.c
-
-header.o: header.c ldefs.c
-       cc -c -O header.c
-
-libln.a:
-       cc -c -O lib/allprint.c lib/main.c lib/reject.c lib/yyless.c
-       cc -c -O lib/yywrap.c
-       rm -f libln.a
-       ar rvc libln.a allprint.o main.o reject.o yyless.o yywrap.o
-       rm allprint.o main.o reject.o yyless.o yywrap.o
diff --git a/usr/src/cmd/lex/ncform b/usr/src/cmd/lex/ncform
new file mode 100644 (file)
index 0000000..8ca51b4
--- /dev/null
@@ -0,0 +1,179 @@
+int yylineno =1;
+# define YYU(x) x
+# define NLSTATE yyprevious=YYNEWLINE
+char yytext[YYLMAX];
+struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
+char yysbuf[YYLMAX];
+char *yysptr = yysbuf;
+int *yyfnd;
+extern struct yysvf *yyestate;
+int yyprevious = YYNEWLINE;
+yylook(){
+       register struct yysvf *yystate, **lsp;
+       register struct yywork *yyt;
+       struct yysvf *yyz;
+       int yych;
+       struct yywork *yyr;
+# ifdef LEXDEBUG
+       int debug;
+# endif
+       char *yylastch;
+       /* start off machines */
+# ifdef LEXDEBUG
+       debug = 0;
+# endif
+       if (!yymorfg)
+               yylastch = yytext;
+       else {
+               yymorfg=0;
+               yylastch = yytext+yyleng;
+               }
+       for(;;){
+               lsp = yylstate;
+               yyestate = yystate = yybgin;
+               if (yyprevious==YYNEWLINE) yystate++;
+               for (;;){
+# ifdef LEXDEBUG
+                       if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
+# endif
+                       yyt = yystate->yystoff;
+                       if(yyt == yycrank){             /* may not be any transitions */
+                               yyz = yystate->yyother;
+                               if(yyz == 0)break;
+                               if(yyz->yystoff == yycrank)break;
+                               }
+                       *yylastch++ = yych = input();
+               tryagain:
+# ifdef LEXDEBUG
+                       if(debug){
+                               fprintf(yyout,"char ");
+                               allprint(yych);
+                               putchar('\n');
+                               }
+# endif
+                       yyr = yyt;
+                       if ( (int)yyt > (int)yycrank){
+                               yyt = yyr + yych;
+                               if (yyt <= yytop && yyt->verify+yysvec == yystate){
+                                       if(yyt->advance+yysvec == YYLERR)       /* error transitions */
+                                               {unput(*--yylastch);break;}
+                                       *lsp++ = yystate = yyt->advance+yysvec;
+                                       goto contin;
+                                       }
+                               }
+# ifdef YYOPTIM
+                       else if((int)yyt < (int)yycrank) {              /* r < yycrank */
+                               yyt = yyr = yycrank+(yycrank-yyt);
+# ifdef LEXDEBUG
+                               if(debug)fprintf(yyout,"compressed state\n");
+# endif
+                               yyt = yyt + yych;
+                               if(yyt <= yytop && yyt->verify+yysvec == yystate){
+                                       if(yyt->advance+yysvec == YYLERR)       /* error transitions */
+                                               {unput(*--yylastch);break;}
+                                       *lsp++ = yystate = yyt->advance+yysvec;
+                                       goto contin;
+                                       }
+                               yyt = yyr + YYU(yymatch[yych]);
+# ifdef LEXDEBUG
+                               if(debug){
+                                       fprintf(yyout,"try fall back character ");
+                                       allprint(YYU(yymatch[yych]));
+                                       putchar('\n');
+                                       }
+# endif
+                               if(yyt <= yytop && yyt->verify+yysvec == yystate){
+                                       if(yyt->advance+yysvec == YYLERR)       /* error transition */
+                                               {unput(*--yylastch);break;}
+                                       *lsp++ = yystate = yyt->advance+yysvec;
+                                       goto contin;
+                                       }
+                               }
+                       if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
+# ifdef LEXDEBUG
+                               if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
+# endif
+                               goto tryagain;
+                               }
+# endif
+                       else
+                               {unput(*--yylastch);break;}
+               contin:
+# ifdef LEXDEBUG
+                       if(debug){
+                               fprintf(yyout,"state %d char ",yystate-yysvec-1);
+                               allprint(yych);
+                               putchar('\n');
+                               }
+# endif
+                       ;
+                       }
+# ifdef LEXDEBUG
+               if(debug){
+                       fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
+                       allprint(yych);
+                       putchar('\n');
+                       }
+# endif
+               while (lsp-- > yylstate){
+                       *yylastch-- = 0;
+                       if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
+                               yyolsp = lsp;
+                               if(yyextra[*yyfnd]){            /* must backup */
+                                       while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
+                                               lsp--;
+                                               unput(*yylastch--);
+                                               }
+                                       }
+                               yyprevious = YYU(*yylastch);
+                               yylsp = lsp;
+                               yyleng = yylastch-yytext+1;
+                               yytext[yyleng] = 0;
+# ifdef LEXDEBUG
+                               if(debug){
+                                       fprintf(yyout,"\nmatch ");
+                                       sprint(yytext);
+                                       fprintf(yyout," action %d\n",*yyfnd);
+                                       }
+# endif
+                               return(*yyfnd++);
+                               }
+                       unput(*yylastch);
+                       }
+               if (yytext[0] == 0  /* && feof(yyin) */)
+                       {
+                       yysptr=yysbuf;
+                       return(0);
+                       }
+               yyprevious = yytext[0] = input();
+               if (yyprevious>0)
+                       output(yyprevious);
+               yylastch=yytext;
+# ifdef LEXDEBUG
+               if(debug)putchar('\n');
+# endif
+               }
+       }
+yyback(p, m)
+       int *p;
+{
+if (p==0) return(0);
+while (*p)
+       {
+       if (*p++ == m)
+               return(1);
+       }
+return(0);
+}
+       /* the following are only used in the lex library */
+yyinput(){
+       return(input());
+       }
+yyoutput(c)
+  int c; {
+       output(c);
+       }
+yyunput(c)
+   int c; {
+       unput(c);
+       }
index 099e1fd..f9b5249 100644 (file)
@@ -1,6 +1,6 @@
        /* because of external definitions, this code should occur only once */
 # ifdef ASCII
        /* because of external definitions, this code should occur only once */
 # ifdef ASCII
-int ctable[2*NCH] {
+int ctable[2*NCH] {
   0,  1,  2,  3,  4,  5,  6,  7,  8,  9,
  10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
  20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
   0,  1,  2,  3,  4,  5,  6,  7,  8,  9,
  10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
  20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
@@ -16,7 +16,7 @@ int ctable[2*NCH] {
 120,121,122,123,124,125,126,127};
 # endif
 # ifdef EBCDIC
 120,121,122,123,124,125,126,127};
 # endif
 # ifdef EBCDIC
-int ctable[2*NCH] {
+int ctable[2*NCH] {
   0,  1,  2,  3,  4,  5,  6,  7,  8,  9,
  10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
  20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
   0,  1,  2,  3,  4,  5,  6,  7,  8,  9,
  10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
  20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
@@ -44,34 +44,34 @@ int ctable[2*NCH] {
 240,241,242,243,244,245,246,247,248,249,
 250,251,252,253,254,255};
 # endif
 240,241,242,243,244,245,246,247,248,249,
 250,251,252,253,254,255};
 # endif
-int ZCH NCH;
-FILE *fout NULL, *errorf {stdout};
-int sect DEFSECTION;
-int prev '\n'; /* previous input character */
-int pres '\n'; /* present input character */
-int peek '\n'; /* next input character */
-char *pushptr pushc;
-char *slptr slist;
+int ZCH NCH;
+FILE *fout = NULL, *errorf = {stdout};
+int sect DEFSECTION;
+int prev = '\n';       /* previous input character */
+int pres = '\n';       /* present input character */
+int peek = '\n';       /* next input character */
+char *pushptr pushc;
+char *slptr slist;
 
 # if (unix || ibm)
 
 # if (unix || ibm)
-char *cname "/usr/lib/lex/ncform";
-char *ratname "/usr/lib/lex/nrform";
+char *cname "/usr/lib/lex/ncform";
+char *ratname "/usr/lib/lex/nrform";
 # endif
 
 # ifdef gcos
 # endif
 
 # ifdef gcos
-char *cname "pounce/lexcform";
-char *ratname "pounce/lexrform";
+char *cname "pounce/lexcform";
+char *ratname "pounce/lexrform";
 # endif
 # endif
-int ccount 1;
-int casecount 1;
-int aptr 1;
-int nstates NSTATES, maxpos MAXPOS;
-int treesize TREESIZE, ntrans NTRANS;
+int ccount 1;
+int casecount 1;
+int aptr 1;
+int nstates = NSTATES, maxpos = MAXPOS;
+int treesize = TREESIZE, ntrans = NTRANS;
 int yytop;
 int yytop;
-int outsize NOUTPUT;
-int sptr 1;
-int optim TRUE;
-int report 2;
+int outsize NOUTPUT;
+int sptr 1;
+int optim TRUE;
+int report 2;
 int debug;             /* 1 = on */
 int charc;
 int sargc;
 int debug;             /* 1 = on */
 int charc;
 int sargc;
@@ -122,7 +122,7 @@ int stnum;
 char match[NCH];
 char extra[NACTIONS];
 char *pchar, *pcptr;
 char match[NCH];
 char extra[NACTIONS];
 char *pchar, *pcptr;
-int pchlen TOKENSIZE;
+int pchlen TOKENSIZE;
  long rcount;
 int *verify, *advance, *stoff;
 int scon;
  long rcount;
 int *verify, *advance, *stoff;
 int scon;
index 2f152b4..81df2d0 100644 (file)
@@ -44,12 +44,12 @@ end:                delim | ;
 defns: defns STR STR
        ={      scopy($2,dp);
                def[dptr] = dp;
 defns: defns STR STR
        ={      scopy($2,dp);
                def[dptr] = dp;
-               dp =+ slength($2) + 1;
+               dp += slength($2) + 1;
                scopy($3,dp);
                subs[dptr++] = dp;
                if(dptr >= DEFSIZE)
                        error("Too many definitions");
                scopy($3,dp);
                subs[dptr++] = dp;
                if(dptr >= DEFSIZE)
                        error("Too many definitions");
-               dp =+ slength($3) + 1;
+               dp += slength($3) + 1;
                if(dp >= dchar+DEFCHAR)
                        error("Definitions too long");
                subs[dptr]=def[dptr]=0; /* for lookup - require ending null */
                if(dp >= dchar+DEFCHAR)
                        error("Definitions too long");
                subs[dptr]=def[dptr]=0; /* for lookup - require ending null */
@@ -374,7 +374,7 @@ yylex(){
                                                        sname[sptr] = 0;        /* required by lookup */
                                                        if(sptr >= STARTSIZE)
                                                                error("Too many start conditions");
                                                        sname[sptr] = 0;        /* required by lookup */
                                                        if(sptr >= STARTSIZE)
                                                                error("Too many start conditions");
-                                                       sp =+ slength(sp) + 1;
+                                                       sp += slength(sp) + 1;
                                                        if(sp >= schar+STARTCHAR)
                                                                error("Start conditions too long");
                                                        }
                                                        if(sp >= schar+STARTCHAR)
                                                                error("Start conditions too long");
                                                        }
@@ -632,7 +632,7 @@ yylex(){
                                else {
                                        yylval = ccptr;
                                        scopy(token,ccptr);
                                else {
                                        yylval = ccptr;
                                        scopy(token,ccptr);
-                                       ccptr =+ slength(token) + 1;
+                                       ccptr += slength(token) + 1;
                                        if(ccptr >= ccl+CCLSIZE)
                                                error("Too many large character classes");
                                        }
                                        if(ccptr >= ccl+CCLSIZE)
                                                error("Too many large character classes");
                                        }
index f2aeb8a..45dc1a9 100644 (file)
@@ -1,4 +1,5 @@
 # include "ldefs.c"
 # include "ldefs.c"
+char *
 getl(p)        /* return next line of input, throw away trailing '\n' */
        /* returns 0 if eof is had immediately */
   char *p;
 getl(p)        /* return next line of input, throw away trailing '\n' */
        /* returns 0 if eof is had immediately */
   char *p;
@@ -170,7 +171,7 @@ ctrans(ss)
        case '\\': c = '\\'; break;
        case '0': case '1': case '2': case '3':
        case '4': case '5': case '6': case '7':
        case '\\': c = '\\'; break;
        case '0': case '1': case '2': case '3':
        case '4': case '5': case '6': case '7':
-               c =- '0';
+               c -= '0';
                while ((k = *(*ss+1)) >= '0' && k <= '7')
                        {
                        c = c*8 + k - '0';
                while ((k = *(*ss+1)) >= '0' && k <= '7')
                        {
                        c = c*8 + k - '0';
@@ -187,7 +188,7 @@ cclinter(sw)
        int m;
        if(!sw){                /* is NCCL */
                for(i=1;i<NCH;i++)
        int m;
        if(!sw){                /* is NCCL */
                for(i=1;i<NCH;i++)
-                       symbol[i] =^ 1;                 /* reverse value */
+                       symbol[i] ^= 1;                 /* reverse value */
                }
        for(i=1;i<NCH;i++)
                if(symbol[i]) break;
                }
        for(i=1;i<NCH;i++)
                if(symbol[i]) break;
@@ -246,7 +247,7 @@ usescape(c)
        case 'f': c = 014; break;               /* form feed for ascii */
        case '0': case '1': case '2': case '3':
        case '4': case '5': case '6': case '7':
        case 'f': c = 014; break;               /* form feed for ascii */
        case '0': case '1': case '2': case '3':
        case '4': case '5': case '6': case '7':
-               c =- '0';
+               c -= '0';
                while('0' <= (d=gch()) && d <= '7'){
                        c = c * 8 + (d-'0');
                        if(!('0' <= peek && peek <= '7')) break;
                while('0' <= (d=gch()) && d <= '7'){
                        c = c * 8 + (d-'0');
                        if(!('0' <= peek && peek <= '7')) break;
index f4960c0..ce0741d 100644 (file)
@@ -379,7 +379,7 @@ packtrans(st,tch,tst,cnt,tryit)
        char cwork[NCH];
        int upper;
 
        char cwork[NCH];
        int upper;
 
-       rcount =+ cnt;
+       rcount += cnt;
        cmin = -1;
        cval = NCH;
        ast = tst;
        cmin = -1;
        cval = NCH;
        ast = tst;
@@ -731,7 +731,7 @@ layout(){
 # endif
                if(chset){
                        do {
 # endif
                if(chset){
                        do {
-                               startup =+ 1;
+                               ++startup;
                                if(startup > outsize - ZCH)
                                        error("output table overflow");
                                for(j = bot; j<= top; j++){
                                if(startup > outsize - ZCH)
                                        error("output table overflow");
                                for(j = bot; j<= top; j++){
@@ -754,7 +754,7 @@ layout(){
                        }
                else {
                        do {
                        }
                else {
                        do {
-                               startup =+ 1;
+                               ++startup;
                                if(startup > outsize - ZCH)
                                        error("output table overflow");
                                for(j = bot; j<= top; j++){
                                if(startup > outsize - ZCH)
                                        error("output table overflow");
                                for(j = bot; j<= top; j++){
@@ -794,7 +794,7 @@ layout(){
                }
        fprintf(fout,"# define YYTYPE %s\n",stnum+1 > NCH ? "int" : "char");
        fprintf(fout,"struct yywork { YYTYPE verify, advance; } yycrank[] ={\n");
                }
        fprintf(fout,"# define YYTYPE %s\n",stnum+1 > NCH ? "int" : "char");
        fprintf(fout,"struct yywork { YYTYPE verify, advance; } yycrank[] ={\n");
-       for(i=0;i<=yytop;i=+4){
+       for(i=0;i<=yytop;i+=4){
                for(j=0;j<4;j++){
                        k = i+j;
                        if(verify[k])
                for(j=0;j<4;j++){
                        k = i+j;
                        if(verify[k])
@@ -834,7 +834,7 @@ layout(){
                fprintf(fout,"char yymatch[] ={\n");
                if (chset==0) /* no chset, put out in normal order */
                        {
                fprintf(fout,"char yymatch[] ={\n");
                if (chset==0) /* no chset, put out in normal order */
                        {
-                       for(i=0; i<NCH; i=+8){
+                       for(i=0; i<NCH; i+=8){
                                for(j=0; j<8; j++){
                                        int fbch;
                                        fbch = match[i+j];
                                for(j=0; j<8; j++){
                                        int fbch;
                                        fbch = match[i+j];
@@ -867,7 +867,7 @@ layout(){
                }
        /* put out yyextra */
        fprintf(fout,"char yyextra[] ={\n");
                }
        /* put out yyextra */
        fprintf(fout,"char yyextra[] ={\n");
-       for(i=0;i<casecount;i=+8){
+       for(i=0;i<casecount;i+=8){
                for(j=0;j<8;j++)
                        fprintf(fout, "%d,", i+j<NACTIONS ?
                                extra[i+j] : 0);
                for(j=0;j<8;j++)
                        fprintf(fout, "%d,", i+j<NACTIONS ?
                                extra[i+j] : 0);
@@ -914,7 +914,7 @@ bprint(a,s,n)
        fprintf(fout,"common /L%s/ %s\n",s,s);
        fprintf(fout,"define S%s %d\n",s,n);
        fprintf(fout,"integer %s (S%s)\n",s,s);
        fprintf(fout,"common /L%s/ %s\n",s,s);
        fprintf(fout,"define S%s %d\n",s,n);
        fprintf(fout,"integer %s (S%s)\n",s,s);
-       for(i=1;i<n;i=+8){
+       for(i=1;i<n;i+=8){
                fprintf(fout,"data %s (%d)/%d/",s,i,a[i]);
                for(j=1;j<8;j++){
                        k = i+j;
                fprintf(fout,"data %s (%d)/%d/",s,i,a[i]);
                for(j=1;j<8;j++){
                        k = i+j;
diff --git a/usr/src/cmd/lex/y.tab.c b/usr/src/cmd/lex/y.tab.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/src/cmd/line.c b/usr/src/cmd/line.c
new file mode 100644 (file)
index 0000000..baa7695
--- /dev/null
@@ -0,0 +1,14 @@
+main()
+{
+char *ttyname() ;
+register char *tty , *cp ;
+cp  = ttyname(0) ;
+cp++ ;
+while (*cp++ != '/') ;
+tty = cp ;
+while (*cp)cp++ ;
+*++cp = '\n' ;
+*++cp = '\0' ;
+write(1,tty,10) ;
+}
diff --git a/usr/src/cmd/lint/Makefile b/usr/src/cmd/lint/Makefile
new file mode 100644 (file)
index 0000000..71c5528
--- /dev/null
@@ -0,0 +1,54 @@
+M=/usr/src/cmd/mip
+LOAD1=
+LOAD2=
+CFLAGS=-O
+
+all:   head
+
+install: head
+       install -s lpass1 $(DESTDIR)/usr/lib/lint1
+       install -s lpass2 $(DESTDIR)/usr/lib/lint2
+       install -c llib-lc $(DESTDIR)/usr/lib
+       install -c llib-port $(DESTDIR)/usr/lib
+       install -c SHELL $(DESTDIR)/usr/bin/lint
+
+cmp:   head
+       cmp lpass1 /usr/lib/lint1
+       cmp lpass2 /usr/lib/lint2
+       rm lpass1 lpass2 *.o cgram.c
+
+clean : 
+       rm -f *.o lpass1 lpass2 cgram.c
+
+head: lpass1 lpass2 ;
+lpass1: cgram.o xdefs.o scan.o comm1.o pftn.o trees.o optim.o lint.o
+       cc $(LOAD1) cgram.o xdefs.o scan.o comm1.o pftn.o trees.o optim.o lint.o
+       mv a.out lpass1
+trees.o: $M/manifest macdefs $M/mfile1 $M/trees.c
+       cc -c $(CFLAGS) -I$M -I. $M/trees.c
+optim.o: $M/manifest macdefs $M/mfile1 $M/optim.c
+       cc -c $(CFLAGS) -I$M -I. $M/optim.c
+pftn.o: $M/manifest macdefs $M/mfile1 $M/pftn.c
+       cc -c $(CFLAGS) -I$M -I. $M/pftn.c
+lint.o: $M/manifest macdefs $M/mfile1 lmanifest
+       cc -c $(CFLAGS) -I$M -I. lint.c
+scan.o: $M/manifest macdefs $M/mfile1 $M/scan.c
+       cc -c $(CFLAGS) -I$M -I. $M/scan.c
+xdefs.o: $M/manifest $M/mfile1 macdefs $M/xdefs.c
+       cc -c $(CFLAGS) -I$M -I. $M/xdefs.c
+cgram.o: $M/manifest $M/mfile1 macdefs cgram.c
+       cc -c $(CFLAGS) -I$M -I. cgram.c
+cgram.c: $M/cgram.y
+       yacc $M/cgram.y
+       mv y.tab.c cgram.c
+comm1.o: $M/manifest $M/mfile1 $M/common macdefs $M/comm1.c
+       cc -c $(CFLAGS) -I. -I$M $M/comm1.c
+shrink:
+       rm *.o
+clobber: shrink
+       rm lpass1 lpass2
+lpass2: lpass2.o
+       cc $(LOAD2) lpass2.o
+       mv a.out lpass2
+lpass2.o: $M/manifest lmanifest
+       cc $(CFLAGS) -c -I$M -I. lpass2.c
index 77c772a..dbb6feb 100755 (executable)
@@ -10,7 +10,7 @@ do
        case $A in
        -l*)    (/lib/cpp $O $LL/llib$A | ${L}1 -v$X-L$A >>$T)2>&1 ;;
        -[IDOU]*)       O="$O $A" ;;
        case $A in
        -l*)    (/lib/cpp $O $LL/llib$A | ${L}1 -v$X-L$A >>$T)2>&1 ;;
        -[IDOU]*)       O="$O $A" ;;
-       -X)     LL=/usr/src/lint L=/usr/src/lint/lpass ;;
+       -X)     LL=/usr/src/cmd/lint L=/usr/src/cmd/lint/lpass ;;
        -*)     X="$X$A" ;;
        *)      (/lib/cpp $O $A | ${L}1 $X-L$A >>$T)2>&1
        esac
        -*)     X="$X$A" ;;
        *)      (/lib/cpp $O $A | ${L}1 $X-L$A >>$T)2>&1
        esac
diff --git a/usr/src/cmd/lint/llib-lc b/usr/src/cmd/lint/llib-lc
new file mode 100644 (file)
index 0000000..ebff38e
--- /dev/null
@@ -0,0 +1,105 @@
+       /* LINTLIBRARY */
+#include <stdio.h>
+#include <sgtty.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <time.h>
+int    errno;
+int    alarm(s) unsigned s; { return(s); }
+char   *brk(a) char *a; { return(a); }
+int    chdir(s) char *s; { return(0); }
+int    chmod(s, m) char *s; { return(0); }
+int    chown(s, u, g) char *s; { return(0); }
+int    close(f) { return(0); }
+int    creat(s, m) char *s; { return(0); }
+int    dup(f) { return(f); }
+       /* VARARGS */
+       execl(f, a) char *f, *a; {;}
+       execv(s, v) char *s, *v[]; {;}
+       exit(s) {;}
+int    fork() { return(0); }
+int    fstat(f, b) struct stat *b; { return(0); }
+int    getgid() { return(1); }
+int    getegid() { return(1); }
+int    getpid() { return(1); }
+int    getuid() { return(1); }
+int    geteuid() { return(1); }
+int    gtty(f, b) struct sgttyb *b; { return(0); }
+int    kill(p, s) { return(0); }
+int    link(a, b) char *a, *b; { return(0); }
+long   lseek(f, o, d) long o; { return(0); }
+int    mknod(n, m, a) char *n; { return(0); }
+char   *mktemp(p) char *p; { return(p);}
+int    mount(s, n, f) char *s, *n; { return(0); }
+int    nice(p) { return(0); }
+int    open(f, m) char *f; { return(0); }
+       pause() {;}
+int    pipe(f) int f[2]; { return(0); }
+       profil(b, s, o, i) char *b; {;}
+int    ptrace(r, p, a, d) { return(0); }
+int    read(f, b, l) char *b; { return(l); }
+char   *sbrk(i) { return((char *)0); }
+int    seek(f, o, p) { return(0); }
+int    setgid(g) { return(0); }
+int    setuid(u) { return(0); }
+int    (*signal(c, f))() int (*f)(); { return(f); }
+int    stat(s, b) char *s; struct stat *b; { return(0); }
+char   *strcat(a, b) char *a, *b; { ; }
+int    strcmp(a, b) char *a, *b; { return(1); }
+char   *strcpy(a, b) char *a, *b; { ; }
+int    strlen(s) char *s; { return(1); }
+int    stty(f, b) struct sgttyb *b; { return(0); }
+long   tell(f) { return((long)0); }
+int    system(s) char *s; { return(0); }
+time_t time(t) time_t *t; { return( 0 );}
+int    unlink(s) char *s; { return(0); }
+int    wait(s) int *s; { return(1); }
+int    write(f, b, l) char *b; { return(l); }
+char   *calloc(n,s) unsigned n, s; { static char c[1]; return(c); }
+char   *malloc(n) unsigned n; {static char c; return(&c);}
+char   *realloc(p, n) char *p; unsigned n; { static char c; return(&c);}
+       free(p) char *p; {;}
+       fclose(f) FILE *f; {return(0);}
+       fflush(f) FILE *f; {return(0);}
+char   *fgets( s, l, f ) char *s; FILE *f; { return(s); }
+FILE   *fopen(s,m) char *s, *m; { return(stdin); }
+FILE   *freopen(s, m, f) char *s, *m; FILE *f; { return(stdin); }
+FILE   *fdopen(fd, m) char *m; { return(stdin);}
+       /* VARARGS */
+       fprintf( f, s ) FILE *f; char *s; {;}
+       fputs(s,f) char *s; FILE *f; {;}
+       fread( p, s, n, f ) char *p; FILE *f; {return(1);}
+       /* VARARGS */
+       fscanf( f, s ) FILE *f; char *s; {return(1);}
+int    fwrite( p, s, n, f ) char *p; FILE *f; {return(0);}
+       intss(){return(1); }
+       /* VARARGS */
+       printf( s ) char *s; {;}
+       rewind(f) FILE *f; {;}
+       /* VARARGS */
+       scanf( f ) char *f; {return(1); }
+       setbuf( f, b ) FILE *f; char *b; {;}
+       /* VARARGS */
+char   *sprintf( s, f ) char *s, *f; { return(s);}
+       /* VARARGS */
+       sscanf( s, f ) char *s, *f; { return(1); }
+       ungetc( c, f ) FILE *f; {  return(c); }
+char   *ctime(c) time_t *c;{ return(""); }
+struct tm *localtime(c) time_t *c; { return localtime(c); }
+struct tm *gmtime(c) time_t *c; { return gmtime(c); }
+char   *asctime(t) struct tm *t; { return(""); }
+       abort() {}
+int    abs(i) int i; { return(i); }
+double atof(s) char *s; { return(1.); }
+char   *crypt(k,s) char *k, *s; { return(""); }
+       setkey(k) char *k; {}
+       encrypt(s, i) char *s; {}
+char   *ecvt(v, n, d, s) double v; int *d, *s; { return(""); }
+char   *fcvt(v, n, d, s) double v; int *d, *s; { return(""); }
+char   *gcvt(v, n, b) double v; char *b; { return(""); }
+       monitor(l, h, b, s, n) int (*l)(), (*h)(); short *b; {}
+       perror(s) char *s; {}
+       setjmp(e) int e[3]; { return(0); }
+       sleep(i) unsigned i; {}
+struct _iobuf _iob[_NFILE];
+char   _ctype_[];
diff --git a/usr/src/cmd/lint/llib-port b/usr/src/cmd/lint/llib-port
new file mode 100644 (file)
index 0000000..c4773af
--- /dev/null
@@ -0,0 +1,44 @@
+       /* LINTLIBRARY */
+#include <stdio.h>
+       exit(s) {;}
+long   lseek(f, o, d) long o; { return(0); }
+char   *mktemp(p) char *p; { return(p);}
+int    (*signal(c, f))() int (*f)(); { return(f); }
+char   *strcat(a, b) char *a, *b; { ; }
+int    strcmp(a, b) char *a, *b; { return(1); }
+char   *strcpy(a, b) char *a, *b; { ; }
+int    strlen(s) char *s; { return(1); }
+long   tell(f) { return((long)0); }
+long   time(t) long *t; { return(0);}
+char   *calloc(n,s) unsigned n, s; { static char c[1]; return(c); }
+char   *malloc(n) unsigned n; {static char c; return(&c);}
+char   *realloc(p, n) char *p; unsigned n; { static char c; return(&c);}
+       free(p) char *p; {;}
+       fclose(f) FILE *f; {return(0);}
+       fflush(f) FILE *f; {return(0);}
+char   *fgets( s, l, f ) char *s; FILE *f; { return(s); }
+FILE   *fopen(s,m) char *s, *m; { return(stdin); }
+FILE   *freopen(s, m, f) char *s, *m; FILE *f; { return(stdin); }
+FILE   *fdopen(fd, m) char *m; { return(stdin);}
+       /* VARARGS */
+       fprintf( f, s ) FILE *f; char *s; {;}
+       fputs(s,f) char *s; FILE *f; {;}
+       fread( p, s, n, f ) char *p; FILE *f; {return(1);}
+       /* VARARGS */
+       fscanf( f, s ) FILE *f; char *s; {return(1);}
+int    fwrite( p, s, n, f ) char *p; FILE *f; {return(0);}
+       intss(){return(1); }
+       /* VARARGS */
+       printf( s ) char *s; {;}
+       rewind(f) FILE *f; {;}
+       /* VARARGS */
+       scanf( f ) char *f; {return(1); }
+       setbuf( f, b ) FILE *f; char *b; {;}
+       /* VARARGS */
+char   *sprintf( s, f ) char *s, *f; { return(s);}
+       /* VARARGS */
+       sscanf( s, f ) char *s, *f; { return(1); }
+       ungetc( c, f ) FILE *f; {  return(c); }
+       wdleng(){return(0); }
+struct _iobuf _iob[_NFILE];
+char   _ctype_[129];
diff --git a/usr/src/cmd/lint/makefile b/usr/src/cmd/lint/makefile
deleted file mode 100644 (file)
index f7fe44d..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-M=/usr/src/cmd/mip
-LOAD1=-i -s
-LOAD2=-s -n
-CFLAGS=-O
-
-all:   head
-
-cp:    head
-       cp lpass1 /usr/lib/lint1
-       cp lpass2 /usr/lib/lint2
-       rm lpass1 lpass2 *.o cgram.c
-
-cmp:   head
-       cmp lpass1 /usr/lib/lint1
-       cmp lpass2 /usr/lib/lint2
-       rm lpass1 lpass2 *.o cgram.c
-
-head: lpass1 lpass2 ;
-lpass1: cgram.o xdefs.o scan.o comm1.o pftn.o trees.o optim.o lint.o
-       cc $(LOAD1) cgram.o xdefs.o scan.o comm1.o pftn.o trees.o optim.o lint.o
-       mv a.out lpass1
-trees.o: $M/manifest macdefs $M/mfile1 $M/trees.c
-       cc -c $(CFLAGS) -I$M -I. $M/trees.c
-optim.o: $M/manifest macdefs $M/mfile1 $M/optim.c
-       cc -c $(CFLAGS) -I$M -I. $M/optim.c
-pftn.o: $M/manifest macdefs $M/mfile1 $M/pftn.c
-       cc -c $(CFLAGS) -I$M -I. $M/pftn.c
-lint.o: $M/manifest macdefs $M/mfile1 lmanifest
-       cc -c $(CFLAGS) -I$M -I. lint.c
-scan.o: $M/manifest macdefs $M/mfile1 $M/scan.c
-       cc -c $(CFLAGS) -I$M -I. $M/scan.c
-xdefs.o: $M/manifest $M/mfile1 macdefs $M/xdefs.c
-       cc -c $(CFLAGS) -I$M -I. $M/xdefs.c
-cgram.o: $M/manifest $M/mfile1 macdefs cgram.c
-       cc -c $(CFLAGS) -I$M -I. cgram.c
-cgram.c: $M/cgram.y
-       yacc $M/cgram.y
-       mv y.tab.c cgram.c
-comm1.o: $M/manifest $M/mfile1 $M/common macdefs $M/comm1.c
-       cc -c $(CFLAGS) -I. -I$M $M/comm1.c
-shrink:
-       rm *.o
-clobber: shrink
-       rm lpass1 lpass2
-lpass2: lpass2.o
-       cc -o lpass2 $(LOAD2) lpass2.o
-lpass2.o: $M/manifest lmanifest
-       cc $(CFLAGS) -c -I$M -I. lpass2.c
-lintall:       cgram.c
-       lint -hpv -I. -I$M  cgram.c $M/xdefs.c $M/scan.c $M/pftn.c $M/trees.c $M/optim.c lint.c $M/reader.c local2.c order.c $M/match.c $M/allo.c $M/comm1.c table.c
-install:
-       echo better be newgrp bin...
-       diff SHELL /usr/bin/lint
-       diff llib-lc /usr/lib
-       diff llib-port /usr/lib
-       cp lpass1 /usr/lib/lint1
-       cp lpass2 /usr/lib/lint2
-       cp llib-* /usr/lib
-       cp SHELL /usr/bin/lint
-       cp SHELL llib-* lmanifest macdefs lint.c lpass2.c /usr/src/cmd/lint
index b09a404..5ff334a 100644 (file)
@@ -26,7 +26,7 @@ int   setpwent();
 char   *ttyname();
 char   *crypt();
 char   *getpass();
 char   *ttyname();
 char   *crypt();
 char   *getpass();
-char   *rindex(), *index();
+char   *rindex();
 extern char **environ;
 
 main(argc, argv)
 extern char **environ;
 
 main(argc, argv)
@@ -89,7 +89,7 @@ char **argv;
        t = ttyslot();
        if (t>0 && (f = open("/etc/utmp", 1)) >= 0) {
                lseek(f, (long)(t*sizeof(utmp)), 0);
        t = ttyslot();
        if (t>0 && (f = open("/etc/utmp", 1)) >= 0) {
                lseek(f, (long)(t*sizeof(utmp)), 0);
-               SCPYN(utmp.ut_line, index(ttyn+1, '/')+1);
+               SCPYN(utmp.ut_line, rindex(ttyn, '/')+1);
                write(f, (char *)&utmp, sizeof(utmp));
                close(f);
        }
                write(f, (char *)&utmp, sizeof(utmp));
                close(f);
        }
diff --git a/usr/src/cmd/lookbib.sh b/usr/src/cmd/lookbib.sh
new file mode 100755 (executable)
index 0000000..1cc2d98
--- /dev/null
@@ -0,0 +1,17 @@
+A=
+case $1 in
+       -p)     A="$1 $2"
+               shift; shift;;
+       -*)     A=$1
+               shift;;
+esac
+case $1 in
+       -p)     A="$A $1 $2"
+               shift; shift;;
+       -*)     A="$A $1"
+               shift;;
+esac
+if test $1x = x 
+then /usr/lib/refer/mkey -s
+else echo $* | /usr/lib/refer/mkey -s
+fi | /usr/lib/refer/hunt $A /usr/dict/papers/Ind
diff --git a/usr/src/cmd/lorder.sh b/usr/src/cmd/lorder.sh
new file mode 100755 (executable)
index 0000000..7fd6003
--- /dev/null
@@ -0,0 +1,34 @@
+trap "rm -f $$sym?ef; exit" 0 1 2 13 15
+case $# in
+0)     echo usage: lorder file ...
+       exit ;;
+1)     case $1 in
+       *.o)    set $1 $1
+       esac
+esac
+nm -g $* | sed '
+       /^$/d
+       /:$/{
+               /\.o:/!d
+               s/://
+               h
+               s/.*/& &/
+               p
+               d
+       }
+       /[TD] /{
+               s/.* //
+               G
+               s/\n/ /
+               w '$$symdef'
+               d
+       }
+       s/.* //
+       G
+       s/\n/ /
+       w '$$symref'
+       d
+'
+sort $$symdef -o $$symdef
+sort $$symref -o $$symref
+join $$symref $$symdef | sed 's/[^ ]* *//'
diff --git a/usr/src/cmd/lpd.c b/usr/src/cmd/lpd.c
new file mode 100644 (file)
index 0000000..8ef7088
--- /dev/null
@@ -0,0 +1,180 @@
+#include <signal.h>
+/*
+ * Line-printer daemon for Versatek
+ *
+ */
+
+#define        TIMEOUT 100
+#define        DAEMUID 1
+
+struct {
+       int     ino;
+       char    name[14];
+} dbuf;
+
+char   line[128];
+char   banbuf[64];
+int    linel;
+int    dfb[259];
+char   dfname[26] = "/usr/lpd/";
+int    waittm  = 60;
+
+main(argc, argv)
+{
+       register char *p1, *p2;
+       register df;
+
+       setuid(DAEMUID);
+       signal(SIGHUP, SIG_IGN);
+       signal(SIGINT, SIG_IGN);
+       signal(SIGQUIT, SIG_IGN);
+/*
+ * Close all files, open root as 0, 1, 2
+ * to assure standard environment
+ */
+       for (df=0; df<=15; df++)
+               close(df);
+       open("/", 0);
+       dup(0);
+       dup(0);
+       if ((df=creat("/usr/lpd/lock", 0)) < 0)
+               exit(0);
+       close(df);
+       if (fork())
+               exit(0);
+again:
+       df = open("/usr/lpd", 0);
+       do {
+               if (read(df, &dbuf, sizeof dbuf) < sizeof dbuf) {
+                       unlink("/usr/lpd/lock");
+                       exit(0);
+               }
+       } while (dbuf.ino==0 || dbuf.name[0]!='d' || dbuf.name[1]!='f');
+       close(df);
+       p1 = dbuf.name;
+       p2 = &dfname[9];
+       while (p1 < &dbuf.name[14])
+               *p2++ = *p1++;
+       if (trysend(dfname) == 0)
+               goto again;
+       sleep(waittm);
+       goto again;
+}
+
+trysend(file)
+{
+       register char *p1, *p2;
+       register i;
+       extern int badexit();
+
+       if (fopen(file, dfb) < 0)
+               return(0);
+       banbuf[0] = 0;
+       while (getline()) switch (line[0]) {
+       case 'L':
+               p1 = line+1;
+               p2 = banbuf;
+               while (*p2++ = *p1++);
+               continue;
+
+       case 'F':
+               if (send())
+                       return(1);
+               continue;
+
+       case 'U':
+               continue;
+
+       case 'M':
+               continue;
+       }
+/*
+ * Second pass.
+ * Unlink files and send mail.
+ */
+       lseek(dfb[0], 0L, 0);
+       dfb[1] = 0;
+       while (getline()) switch (line[0]) {
+
+       default:
+               continue;
+
+       case 'U':
+               unlink(&line[1]);
+               continue;
+
+       case 'M':
+               sendmail();
+               continue;
+       }
+       close(dfb[0]);
+       unlink(file);
+}
+
+sendmail()
+{
+       static int p[2];
+       register i;
+       int stat;
+
+       pipe(p);
+       if (fork()==0) {
+               alarm(0);
+               close(0);
+               dup(p[0]);
+               for (i=3; i<=15; i++)
+                       close(i);
+               execl("/bin/mail", "mail", &line[1], 0);
+               exit(0);
+       }
+       close(1);
+       dup(p[1]);
+       printf("Your printer job is done\n");
+       close(1);
+       close(p[0]);
+       close(p[1]);
+       open("/", 0);
+       wait(&stat);
+}
+
+getline()
+{
+       register char *lp;
+       register c;
+
+       lp = line;
+       linel = 0;
+       while ((c = getc(dfb)) != '\n') {
+               if (c<0)
+                       return(0);
+               if (c=='\t') {
+                       do {
+                               *lp++ = ' ';
+                               linel++;
+                       } while ((linel & 07) != 0);
+                       continue;
+               }
+               *lp++ = c;
+               linel++;
+       }
+       *lp++ = 0;
+       return(1);
+}
+
+send()
+{
+       int p;
+
+       if (p = fork()) {
+               if (p == -1)
+                       return(1);
+               wait(&p);
+               return(p);
+       }
+       if (banbuf[0]) {
+               execl("/usr/bin/vpr", "vpr", "-b", banbuf, line+1, 0);
+               return(1);
+       }
+       execl("/usr/bin/vpr", "vpr", line, 0);
+       return(1);
+}
diff --git a/usr/src/cmd/lpr.c b/usr/src/cmd/lpr.c
new file mode 100644 (file)
index 0000000..fec6ad1
--- /dev/null
@@ -0,0 +1,261 @@
+#include <signal.h>
+/*
+ *     lpr -- on-line printer spooler
+ *             normally invoked through opr
+ */
+
+char   tfname[]        = "/usr/lpd/tfaXXXXX";
+char   cfname[]        = "/usr/lpd/cfaXXXXX";
+char   lfname[]        = "/usr/lpd/lfaXXXXX";
+char   dfname[]        = "/usr/lpd/dfaXXXXX";
+int    nact;
+int    tff;
+int    mailflg;
+char   person[10];
+int    inchar;
+int    maxrec  = 400;
+
+main(argc, argv)
+int argc;
+char *argv[];
+{
+       register char *arg, *remote;
+       int c, f, flag;
+       int out();
+
+       pidfn();
+       if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
+               signal(SIGHUP, out);
+       if (signal(SIGINT, SIG_IGN) != SIG_IGN)
+               signal(SIGINT, out);
+       if (signal(SIGQUIT, SIG_IGN) != SIG_IGN)
+               signal(SIGQUIT, out);
+       remote = "$     remote  **,onl";
+       flag = 0;
+       tff = nfile(tfname);
+       while (argc>1 && (arg = argv[1])[0]=='-') {
+               if (arg[1] && arg[2]) {
+                       remote[12] = arg[1];
+                       remote[13] = arg[2];
+                       remote[14] = 0;
+               } else switch (arg[1]) {
+
+               case '-':
+                       remote[12] = 'r';
+                       remote[13] = '1';
+                       remote[14] = '\0';
+                       break;
+
+               case 'c':
+                       flag = '+';
+                       break;
+
+               case 'r':
+                       flag = '-';
+                       break;
+
+               case 'm':
+                       mailflg = 1;
+                       break;
+               }
+               argc--;
+               argv++;
+       }
+       ident();
+       if(argc == 1)
+               copy(0);
+       while(--argc) {
+               arg = *++argv;
+               if(flag == '+')
+                       goto cf;
+               if(*arg == '/' && flag != '-') {
+                       card('F', arg);
+                       nact++;
+                       continue;
+               }
+               if(link(arg, lfname) < 0)
+                       goto cf;
+               card('F', lfname);
+               card('U', lfname);
+               lfname[inchar]++;
+               nact++;
+               goto df;
+
+       cf:
+               f = open(arg, 0);
+               if(f < 0) {
+                       printf("Cannot open %s\n", arg);
+                       continue;
+               }
+               copy(f);
+               close(f);
+
+       df:
+               if(flag == '-') {
+                       f = unlink(arg);
+                       if(f < 0)
+                               printf("Cannot remove %s\n", arg);
+               }
+       }
+
+       if(nact) {
+               tfname[inchar]--;
+               f = link(tfname, dfname);
+               if(f < 0) {
+                       printf("Cannot rename %s\n", dfname);
+                       tfname[inchar]++;
+                       out();
+               }
+               unlink(tfname);
+               execl("/usr/lib/lpd", "lpd", 0);
+               dfname[inchar]++;
+               printf("Daemon doesn't exist\n");
+               exit(0);
+       }
+       out();
+}
+
+copy(f)
+int f;
+{
+       int ff, i, nr, nc;
+       static int buf[256];
+
+       card('F', cfname);
+       card('U', cfname);
+       ff = nfile(cfname);
+       nc = 0;
+       nr = 0;
+       while((i = read(f, buf, 512)) > 0) {
+               write(ff, buf, i);
+               nc += i;
+               if(nc >= 512) {
+                       nc -= 512;
+                       nr++;
+                       if(nr > maxrec) {
+                               printf("Copy file is too large\n");
+                               break;
+                       }
+               }
+       }
+       close(ff);
+       nact++;
+}
+
+card(c, s)
+int c;
+char s[];
+{
+       char *p1, *p2;
+       static char buf[512];
+       int col;
+
+       p1 = buf;
+       p2 = s;
+       col = 0;
+       *p1++ = c;
+       while((c = *p2++) != '\0') {
+               *p1++ = c;
+               col++;
+       }
+       *p1++ = '\n';
+       write(tff, buf, col+2);
+}
+
+ident()
+{
+       int c, n;
+       register char *b1p, *pp, *b2p;
+       static char b1[100], b2[100];
+
+       b1p = b1;
+       if(getpw(getuid(), b1p)) {
+               b1p = "pdp::::m0000,m000:";
+       }
+       n = 0;
+       b2p = b2;
+       while(*b2p++ = "$       ident   "[n++]);
+       b2p--;
+       n = 5;
+       while(--n) while(*b1p++ != ':');
+       while((*b2p++ = *b1p++) != ':');
+       b2p[-1] = ',';
+       b1p = b1;
+       pp = person;
+       while((c = *b1p++) != ':') {
+               *b2p++ = c;
+               *pp++ = c;
+       }
+       *b2p++ = 0;
+       *pp++ = 0;
+       card('L', person);
+       if (mailflg)
+               card('M', person);
+}
+
+pidfn()
+{
+       register i, j, c;
+       int s;
+       int p;
+
+       s = p = getpid();
+       p &= 077777;
+       i = 0;
+       while(tfname[i] != 'X')
+               i++;
+       i += 4;
+       for(j=0; j<5; j++) {
+               c = (p%10) + '0';
+               if(s<0 && j==4)
+                       c += 4;
+               p /= 10;
+               tfname[i] = c;
+               cfname[i] = c;
+               lfname[i] = c;
+               dfname[i] = c;
+               i--;
+       }
+       inchar = i;
+}
+
+nfile(name)
+char *name;
+{
+       register f;
+
+       f = creat(name, 0666);
+       if(f < 0) {
+               printf("Cannot create %s\n", name);
+               out();
+       }
+       name[inchar]++;
+       return(f);
+}
+
+out()
+{
+       register i;
+
+       signal(SIGHUP, SIG_IGN);
+       signal(SIGINT, SIG_IGN);
+       signal(SIGQUIT, SIG_IGN);
+       i = inchar;
+       while(tfname[i] != 'a') {
+               tfname[i]--;
+               unlink(tfname);
+       }
+       while(cfname[i] != 'a') {
+               cfname[i]--;
+               unlink(cfname);
+       }
+       while(lfname[i] != 'a') {
+               lfname[i]--;
+               unlink(lfname);
+       }
+       while(dfname[i] != 'a') {
+               dfname[i]--;
+               unlink(dfname);
+       }
+       exit(0);
+}
diff --git a/usr/src/cmd/lpr/chrtab.c b/usr/src/cmd/lpr/chrtab.c
deleted file mode 100644 (file)
index 4d8a81a..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-char   chrtab[][16] = {
-0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, sp, */
-0010,0010,0010,0010,0010,0010,0010,0010,0000,0000,0010,0000,0000,0000,0000,0000, /*, !, */
-0024,0024,0024,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, ", */
-0000,0000,0000,0044,0044,0176,0044,0044,0176,0044,0044,0000,0000,0000,0000,0000, /*, #, */
-0000,0010,0010,0010,0076,0101,0100,0076,0001,0101,0076,0010,0010,0000,0000,0000, /*, $, */
-0000,0000,0000,0141,0142,0004,0010,0010,0020,0043,0103,0000,0000,0000,0000,0000, /*, %, */
-0000,0000,0070,0104,0110,0060,0060,0111,0106,0106,0071,0000,0000,0000,0000,0000, /*, &, */
-0004,0010,0020,0040,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, ', */
-0000,0004,0010,0020,0040,0040,0040,0040,0040,0040,0020,0010,0004,0000,0000,0000, /*, (, */
-0000,0040,0020,0010,0004,0004,0004,0004,0004,0004,0010,0020,0040,0000,0000,0000, /*, ), */
-0000,0000,0000,0010,0111,0052,0034,0177,0034,0052,0111,0010,0000,0000,0000,0000, /*, *, */
-0000,0000,0000,0000,0010,0010,0010,0177,0010,0010,0010,0000,0000,0000,0000,0000, /*, +, */
-0000,0000,0000,0000,0000,0000,0000,0000,0000,0030,0030,0010,0020,0000,0000,0000, /*, ,, */
-0000,0000,0000,0000,0000,0000,0000,0176,0000,0000,0000,0000,0000,0000,0000,0000, /*, -, */
-0000,0000,0000,0000,0000,0000,0000,0000,0000,0030,0030,0000,0000,0000,0000,0000, /*, ., */
-0000,0000,0001,0002,0004,0010,0010,0010,0020,0040,0100,0000,0000,0000,0000,0000, /*, /, */
-0000,0030,0044,0102,0102,0102,0102,0102,0102,0044,0030,0000,0000,0000,0000,0000, /*, 0, */
-0000,0010,0030,0010,0010,0010,0010,0010,0010,0010,0034,0000,0000,0000,0000,0000, /*, 1, */
-0000,0070,0104,0004,0004,0010,0020,0040,0100,0100,0174,0000,0000,0000,0000,0000, /*, 2, */
-0000,0176,0004,0004,0010,0014,0002,0002,0002,0104,0070,0000,0000,0000,0000,0000, /*, 3, */
-0000,0004,0014,0024,0044,0104,0176,0004,0004,0004,0004,0000,0000,0000,0000,0000, /*, 4, */
-0000,0174,0100,0100,0130,0144,0002,0002,0102,0044,0030,0000,0000,0000,0000,0000, /*, 5, */
-0000,0074,0102,0100,0130,0144,0102,0102,0102,0044,0030,0000,0000,0000,0000,0000, /*, 6, */
-0000,0176,0004,0004,0010,0010,0020,0020,0040,0040,0040,0000,0000,0000,0000,0000, /*, 7, */
-0000,0034,0042,0101,0042,0076,0101,0101,0101,0101,0076,0000,0000,0000,0000,0000, /*, 8, */
-0000,0034,0042,0101,0101,0101,0043,0036,0004,0010,0020,0040,0000,0000,0000,0000, /*, 9, */
-0000,0000,0000,0000,0000,0000,0030,0030,0000,0030,0030,0000,0000,0000,0000,0000, /*, :, */
-0000,0000,0000,0000,0000,0000,0030,0030,0000,0030,0030,0020,0040,0000,0000,0000, /*, ;, */
-0002,0004,0010,0020,0040,0100,0040,0020,0010,0004,0002,0000,0000,0000,0000,0000, /*, <, */
-0000,0000,0000,0000,0177,0000,0177,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, =, */
-0100,0040,0020,0010,0004,0002,0004,0010,0020,0040,0100,0000,0000,0000,0000,0000, /*, >, */
-0000,0030,0044,0102,0001,0002,0004,0010,0010,0000,0010,0000,0000,0000,0000,0000, /*, ?, */
-0000,0074,0102,0101,0115,0123,0121,0121,0121,0111,0046,0000,0000,0000,0000,0000, /*, @, */
-0000,0010,0024,0042,0101,0101,0177,0101,0101,0101,0101,0000,0000,0000,0000,0000, /*, A, */
-0000,0176,0101,0101,0101,0176,0101,0101,0101,0101,0176,0000,0000,0000,0000,0000, /*, B, */
-0000,0076,0101,0100,0100,0100,0100,0100,0100,0101,0076,0000,0000,0000,0000,0000, /*, C, */
-0000,0176,0101,0101,0101,0101,0101,0101,0101,0101,0176,0000,0000,0000,0000,0000, /*, D, */
-0000,0176,0100,0100,0100,0170,0100,0100,0100,0100,0177,0000,0000,0000,0000,0000, /*, E, */
-0000,0177,0100,0100,0100,0174,0100,0100,0100,0100,0100,0000,0000,0000,0000,0000, /*, F, */
-0000,0076,0101,0100,0100,0117,0101,0101,0101,0101,0076,0000,0000,0000,0000,0000, /*, G, */
-0000,0101,0101,0101,0101,0176,0101,0101,0101,0101,0101,0000,0000,0000,0000,0000, /*, H, */
-0000,0034,0010,0010,0010,0010,0010,0010,0010,0010,0034,0000,0000,0000,0000,0000, /*, I, */
-0000,0016,0004,0004,0004,0004,0004,0004,0104,0104,0070,0000,0000,0000,0000,0000, /*, J, */
-0000,0101,0102,0104,0110,0120,0160,0110,0104,0102,0101,0000,0000,0000,0000,0000, /*, K, */
-0000,0100,0100,0100,0100,0100,0100,0100,0100,0100,0177,0000,0000,0000,0000,0000, /*, L, */
-0000,0101,0143,0125,0111,0101,0101,0101,0101,0101,0101,0000,0000,0000,0000,0000, /*, M, */
-0000,0101,0141,0121,0111,0105,0103,0101,0101,0101,0101,0000,0000,0000,0000,0000, /*, N, */
-0000,0076,0101,0101,0101,0101,0101,0101,0101,0101,0076,0000,0000,0000,0000,0000, /*, O, */
-0000,0176,0101,0101,0101,0176,0100,0100,0100,0100,0100,0000,0000,0000,0000,0000, /*, P, */
-0000,0076,0101,0101,0101,0101,0101,0101,0131,0105,0076,0002,0001,0000,0000,0000, /*, Q, */
-0000,0176,0101,0101,0101,0176,0104,0102,0101,0101,0101,0000,0000,0000,0000,0000, /*, R, */
-0000,0076,0101,0100,0100,0076,0001,0001,0001,0101,0076,0000,0000,0000,0000,0000, /*, S, */
-0000,0177,0010,0010,0010,0010,0010,0010,0010,0010,0010,0000,0000,0000,0000,0000, /*, T, */
-0000,0101,0101,0101,0101,0101,0101,0101,0101,0101,0076,0000,0000,0000,0000,0000, /*, U, */
-0000,0101,0101,0101,0101,0101,0101,0101,0042,0024,0010,0000,0000,0000,0000,0000, /*, V, */
-0000,0101,0101,0101,0101,0111,0111,0125,0143,0101,0101,0000,0000,0000,0000,0000, /*, W, */
-0000,0101,0101,0042,0024,0010,0024,0042,0101,0101,0101,0000,0000,0000,0000,0000, /*, X, */
-0000,0101,0042,0024,0010,0010,0010,0010,0010,0010,0010,0000,0000,0000,0000,0000, /*, Y, */
-0000,0177,0001,0002,0004,0010,0020,0040,0100,0100,0177,0000,0000,0000,0000,0000, /*, Z, */
-0000,0034,0020,0020,0020,0020,0020,0020,0020,0020,0020,0034,0000,0000,0000,0000, /*, [, */
-0000,0000,0100,0040,0020,0010,0010,0010,0004,0002,0001,0000,0000,0000,0000,0000, /*, , \, */
-0000,0070,0010,0010,0010,0010,0010,0010,0010,0010,0010,0070,0000,0000,0000,0000, /*, ], */
-0010,0024,0042,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, ^, */
-0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0377,0000,0000, /*, _, */
-0040,0020,0010,0004,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, `, */
-0000,0000,0000,0000,0000,0074,0002,0076,0102,0102,0076,0000,0000,0000,0000,0000, /*, a, */
-0000,0100,0100,0100,0100,0174,0102,0102,0102,0102,0174,0000,0000,0000,0000,0000, /*, b, */
-0000,0000,0000,0000,0000,0074,0102,0100,0100,0102,0074,0000,0000,0000,0000,0000, /*, c, */
-0002,0002,0002,0002,0002,0076,0102,0102,0102,0102,0076,0000,0000,0000,0000,0000, /*, d, */
-0000,0000,0000,0000,0000,0074,0102,0174,0100,0102,0074,0000,0000,0000,0000,0000, /*, e, */
-0000,0016,0020,0020,0020,0176,0020,0020,0020,0020,0020,0000,0000,0000,0000,0000, /*, f, */
-0000,0000,0000,0000,0000,0076,0102,0102,0102,0102,0076,0002,0002,0102,0076,0000, /*, g, */
-0000,0100,0100,0100,0100,0174,0102,0102,0102,0102,0102,0000,0000,0000,0000,0000, /*, h, */
-0000,0000,0000,0010,0000,0030,0010,0010,0010,0010,0034,0000,0000,0000,0000,0000, /*, i, */
-0000,0000,0000,0010,0000,0030,0010,0010,0010,0010,0010,0010,0010,0050,0020,0000, /*, j, */
-0000,0100,0100,0100,0100,0106,0110,0120,0160,0110,0106,0000,0000,0000,0000,0000, /*, k, */
-0000,0030,0010,0010,0010,0010,0010,0010,0010,0010,0034,0000,0000,0000,0000,0000, /*, l, */
-0000,0000,0000,0000,0000,0166,0111,0111,0111,0111,0111,0000,0000,0000,0000,0000, /*, m, */
-0000,0000,0000,0000,0100,0174,0102,0102,0102,0102,0102,0000,0000,0000,0000,0000, /*, n, */
-0000,0000,0000,0000,0000,0074,0102,0102,0102,0102,0074,0000,0000,0000,0000,0000, /*, o, */
-0000,0000,0000,0000,0000,0174,0102,0102,0102,0102,0174,0100,0100,0100,0100,0000, /*, p, */
-0000,0000,0000,0000,0000,0076,0102,0102,0102,0102,0076,0002,0002,0002,0002,0000, /*, q, */
-0000,0000,0000,0000,0000,0134,0142,0100,0100,0100,0100,0000,0000,0000,0000,0000, /*, r, */
-0000,0000,0000,0000,0000,0076,0100,0074,0002,0102,0074,0000,0000,0000,0000,0000, /*, s, */
-0000,0020,0020,0020,0020,0176,0020,0020,0020,0020,0014,0000,0000,0000,0000,0000, /*, t, */
-0000,0000,0000,0000,0000,0102,0102,0102,0102,0102,0075,0000,0000,0000,0000,0000, /*, u, */
-0000,0000,0000,0000,0000,0101,0101,0101,0042,0024,0010,0000,0000,0000,0000,0000, /*, v, */
-0000,0000,0000,0000,0000,0111,0111,0111,0111,0111,0066,0000,0000,0000,0000,0000, /*, w, */
-0000,0000,0000,0000,0000,0102,0044,0030,0030,0044,0102,0000,0000,0000,0000,0000, /*, x, */
-0000,0000,0000,0000,0000,0102,0102,0102,0042,0024,0010,0020,0040,0100,0000,0000, /*, y, */
-0000,0000,0000,0000,0000,0176,0004,0010,0020,0040,0176,0000,0000,0000,0000,0000, /*, z, */
-0000,0014,0020,0020,0020,0020,0040,0020,0020,0020,0020,0014,0000,0000,0000,0000, /*, {, */
-0000,0010,0010,0010,0010,0000,0000,0010,0010,0010,0010,0000,0000,0000,0000,0000, /*, |, */
-0000,0030,0010,0010,0010,0010,0004,0010,0010,0010,0010,0030,0000,0000,0000,0000, /*, }, */
-0020,0052,0004,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, ~, */
-0000,0176,0176,0176,0176,0176,0176,0176,0176,0176,0176,0000,0000,0000,0000,0000, /*, del, */
-};
diff --git a/usr/src/cmd/lpr/daemon.c b/usr/src/cmd/lpr/daemon.c
deleted file mode 100644 (file)
index ce1d192..0000000
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- *  daemon.c -- main control routines for spider and phone dpd daemons,
- *                     and for line printer daemon.
- */
-
-long   snsum = 0;              /*number of characters written*/
-
-#include       "daemon0.c"
-
-#include       <setjmp.h>
-#include       <sys/dir.h>
-
-struct direct  dbuf;
-int    LDIRNAM = 0;            /*length of directory name. MRW*/
-int    LCHAR   = 0;            /*length of file name thru 'df'.*/
-int    LPID    = 0;            /*length of file name to process-id.*/
-int    retcode = 1;
-int    nwait   = 0;
-char   *fowner;                /*RBB*/
-char   baddf[30];              /*name for unsendable df-files.*/
-FILE   *popen();
-
-#if LPD
-int    waittm  = 10;
-#else
-int    waittm  = 60;
-#endif
-
-main()
-{
-       register char *p1, *p2;
-       FILE *df;
-
-       dem_setup();
-       LDIRNAM = 0;            /*calculate length of directory name. MRW*/
-       while(dfname[LDIRNAM])  LDIRNAM++;
-       LCHAR = LDIRNAM + 2;
-       LPID = LDIRNAM + 3;
-
-again:
-       snsum = 0;
-       if(access(lock, 0) < 0){
-               logerr("Lock has disappeared.");
-               dem_dis();
-               exit(1);
-       }
-       df = fopen(dpd, "r");
-       if (df) {
-               do {
-                       if(fread((char *)&dbuf, sizeof dbuf, 1, df) < 1){
-                               dem_dis();      /*disconnect phone line. MRW*/
-                               unlink(lock);
-                               exit(0);
-                       }
-               } while (dbuf.d_ino==0 || dbuf.d_name[0]!='d' || dbuf.d_name[1]!='f');
-               fclose(df);
-       }
-       p1 = dbuf.d_name;
-       p2 = &dfname[LDIRNAM];
-       while (p1 < &dbuf.d_name[DIRSIZ])
-               *p2++ = *p1++;
-       if (trysend() == 0) {
-               waittm = 60;
-               nwait = 0;
-               goto again;
-               }
-#if PHONE
-       if(nwait > 10){         /*after 3 hours try fresh daemon. MRW*/
-               unlink(lock);
-               execl("/usr/lib/dpd", "dpd", (char *)0);
-               execl("/etc/dpd", "dpd", (char *)0);
-               logerr("Can't find dpd.");
-               exit(1);
-       }
-#endif
-       sleep(waittm);
-#if PHONE || SPIDER
-#ifndef DEBUG
-       if (waittm <= 8*60)
-               waittm *= 2;
-       else
-               nwait++;
-#endif
-#endif
-       goto again;
-}
-
-/*
- * The remaining part is the device interface, to spider, the dataphone,
- *    or the line printer.
- */
-
-#define        MXLINE  128
-#define        MXMESS  500
-
-char   *snumb;
-char   line[MXLINE];
-char   message[MXMESS+1];
-char   *mesp;
-char   mailfname[64];
-int    linel;
-FILE   *dfb = NULL;
-jmp_buf        env;
-char   ff      = '\014';               /*formfeed*/
-char   *copline();
-
-trysend()
-{
-       if(retcode != 0)
-               if(retcode = dem_con())         /*connect phone line.*/
-                       return(retcode);
-       retcode = 1;
-       if(setjmp(env))
-               return(retcode);
-       xtrysend();
-       return(0);
-}
-
-xtrysend()
-{
-       int i;
-
-       dem_open(dfname);               /*open spider connection.*/
-       if((dfb = fopen(dfname, "r")) == NULL){
-               if(LDIRNAM < (i = sizeof(baddf)-1)){
-                       strncpy(baddf, dfname, i);
-                       baddf[i] = '\0';
-                       baddf[LDIRNAM] = 'b';
-                       link(dfname, baddf);
-               }
-               unlink(dfname);
-               retcode = 0;
-               trouble("Can't read %s.", dfname);
-       }
-       getowner(dfname);               /*RBB*/
-       mesp = message;
-       *mesp = 0;
-       while (getline()) switch (line[0]) {
-
-       case 'S':
-               get_snumb();            /*get snumb for GCOS.*/
-               continue;
-
-       case 'B':
-               if(sascii(0))
-                       trouble("Can't send %s.", &line[1]);
-               continue;
-
-       case 'F':
-               if(sascii(1))
-                       trouble("Can't send %s.", &line[1]);
-               continue;
-
-       case 'I':                       /*mail back $IDENT card. MRW*/
-               mesp = copline(&line[1], linel-1, mesp);
-
-       case 'L':
-               lwrite();               /*write a literal line.*/
-               continue;
-
-       case 'M':
-               continue;
-
-       case 'N':                       /*mail back file name. MRW*/
-               copline(&line[1], linel-1, mailfname);
-               continue;
-
-       case 'Q':                       /*additional text to mail back*/
-               if(mesp+linel <= message+MXMESS)
-                       mesp = copline(&line[1], linel-1, mesp);
-
-       case 'U':
-               continue;
-       }
-/*
- * Second pass.
- * Unlink files and send mail.
- */
-       alarm(0);
-       fseek(dfb, (long)0, 0);
-       while (getline()) switch (line[0]) {
-
-       default:
-               continue;
-
-       case 'U':
-               unlink(&line[1]);
-               continue;
-
-       case 'M':
-               sendmail();
-               continue;
-       }
-       FCLOSE(dfb);
-       dem_close();            /*close connection to spider.*/
-       unlink(dfname);
-       retcode = 0;
-       trouble("OK: %-5s %-7s %-8s", snumb, fowner, dfname+LDIRNAM);   /*RBB*/
-}
-
-#define        LUBM    30      /*length of mail command line.*/
-#define        IARG1   5       /*start of arg to mail command.*/
-char   mail[LUBM+1]    = "mail ";
-FILE   *pmail;
-
-sendmail()
-{
-       register i;
-
-       alarm(0);
-       i = 0;
-       while((mail[IARG1+i] = line[i+1]) && (++i < LUBM-IARG1));
-       mail[IARG1+i] = 0;
-       if((pmail = popen(mail, "w")) == NULL){
-               logerr("Can't mail: %-5s %-8s",snumb,dfname+LDIRNAM);  /*MRW*/
-               return;
-       }
-       maildname();
-       pclose(pmail);
-}
-
-#if LPD == 0
-
-maildname()            /*break up dfname into command name, and process-id
-                           to send back in the mail. MRW*/
-{
-       char c;
-       char *command;
-
-       fprintf(pmail,"Sent %-5s:  file  %s%s",snumb,mailfname,message);
-/*
-       c = dfname[LCHAR];
-       switch (c){
-       case 'A':
-       case 'a':
-               command = "dpr";
-               break;
-
-       case 'G':
-       case 'g':
-               command = "gcat";
-               break;
-
-       case 'J':
-       case 'j':
-               command = "ibm";
-               break;
-
-       case 'N':
-       case 'n':
-               command = "fsend";
-               break;
-
-       case 'T':
-       case 't':
-               command = "fget";
-               break;
-
-       default:
-               command = &dfname[LDIRNAM];
-               break;
-       }
-       fprintf(pmail, "%s process-id was %s\n", command, &dfname[LPID]);
-*/
-}
-
-#endif
-
-
-getline()
-{
-       register char *lp;
-       register c;
-
-       lp = line;
-       linel = 0;
-       while ((c = getc(dfb)) != '\n' && linel < MXLINE-2) {
-               if (c == EOF)
-                       return(0);
-               if (c=='\t') {
-                       do {
-                               *lp++ = ' ';
-                               linel++;
-                       } while ((linel & 07) != 0);
-                       continue;
-               }
-               *lp++ = c;
-               linel++;
-       }
-       *lp++ = 0;
-       return(1);
-}
-
-char *
-copline(ab, n, ml)
-char   *ab;
-int    n;
-char   ml[64];
-{
-       register char *b, *p, *eb;
-
-       b = ab;
-       eb = b+n;
-       p = ml;
-       while (b<eb && p < &ml[63])
-               *p++ = *b++;
-       *p++ = '\n';
-       *p = 0;                 /*RBB*/
-       return(p);
-}
-
-#if LPD == 0
-
-/*
- * the following code determines who the file's owner is.
- *                     /*RBB*/
-
-struct passwd *getpwuid();
-
-getowner(file)
-char   *file;
-{
-       struct passwd *f;
-
-       if(stat(file, &statbuf) < 0)
-               return;
-       if((f = getpwuid(statbuf.st_uid)) == NULL)
-               fowner = "";
-       else
-               fowner = f->pw_name;
-}
-
-#endif
diff --git a/usr/src/cmd/lpr/daemon0.c b/usr/src/cmd/lpr/daemon0.c
deleted file mode 100644 (file)
index 615972c..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- *  daemon0.c -- dem_setup() and logerr() routines for spider and
- *                     and dataphone dpd and fget daemons.
- */
-
-#include       <stdio.h>
-#include       <sys/types.h>
-#include       <sys/stat.h>
-#include       <pwd.h>
-#include       <signal.h>
-
-#define        WRMODE  2
-
-#define        FCLOSE(F)       if(F != NULL){ fclose(F);  F = NULL;}
-#define        DAEMUID 1
-#define        DAEMNAM "daemon\0\0"
-
-struct stat    statbuf;
-struct passwd *getpwuid();
-
-unlock()
-{
-       signal(SIGTERM, SIG_IGN);
-       dem_dis();
-       logerr("Daemon killed.");
-       unlink(lock);
-       exit(1);
-}
-
-
-dem_setup()
-{
-       int i;
-       int of;
-
-       setuid(DAEMUID);
-       signal(SIGHUP, SIG_IGN);
-       signal(SIGINT, SIG_IGN);
-       signal(SIGTERM, unlock);
-#ifndef        DEBUG
-       signal(SIGQUIT, SIG_IGN);
-/*
- * Close all files, open /dev/null as 0, 1, 2
- * to assure standard environment
- */
-       freopen("/dev/null", "r", stdin);
-       freopen("/dev/null", "w", stdout);
-       freopen("/dev/null", "w", stderr);
-       for (of=3; of<_NFILE; of++)
-               close(of);
-#endif
-       if ((of=creat(lock, 0)) < 0)
-               exit(0);
-       if(fstat(of, &statbuf) < 0 || statbuf.st_mode != 0100000){
-               logerr("Bad lock file %s.", lock);
-               exit(1);
-       }
-       close(of);
-#ifndef        DEBUG
-       if (i = fork()){
-               if(i == -1){
-                       logerr("Unable to fork.");
-                       unlink(lock);
-                       exit(1);
-               }
-               exit(0);
-       }
-#endif
-       chdir(dpd);
-}
-
-
-#if LPD == 0
-
-int    nlog    = 0;
-
-/* VARARGS */
-logerr(s, a1, a2, a3, a4)
-char   *s;
-int    a1, a2, a3, a4;
-{
-       long static tb;
-       register i;
-       FILE *f;
-       struct passwd *pwp;
-
-       if(access(error, WRMODE) != 0)
-               return;
-       if((f = fopen(error, "a")) == NULL)
-               return;
-       time(&tb);
-       fprintf(f, "%.19s:%s:", ctime(&tb), dname);
-       fprintf(f, s, a1, a2, a3, a4);
-#if FGET == 0
-       i = snsum/1000;
-       if(i <= 0){
-               i = snsum;
-               fprintf(f, "  %3d bytes", i);
-       }
-       else
-               fprintf(f, " %3dk bytes", i);
-#endif
-       if(!nlog++ && ((pwp = getpwuid(getuid())) != NULL)){
-               putc(' ', f);  putc(' ', f);
-               i = 0;
-               while(pwp->pw_name[i])
-                       putc(pwp->pw_name[i++], f);
-       }
-       putc('\n', f);
-       fclose(f);
-}
-
-#endif
diff --git a/usr/src/cmd/lpr/lpd.c b/usr/src/cmd/lpr/lpd.c
deleted file mode 100644 (file)
index 764c66a..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-#
-/*
- * lpd -- line printer daemon dispatcher
- *
- */
-
-#include       <ctype.h>
-
-#define        SPIDER  0
-#define        PHONE   0
-#define        LPD     1
-
-char   dpd[]   = "/usr/spool/lpd";
-char   dfname[30] = "/usr/spool/lpd/";
-char   lock[]  = "/usr/spool/lpd/lock";
-
-#include       "daemon.c"
-
-/*
- * The remaining part is the line printer interface.
- */
-
-char   lp[]    = "/dev/lp";
-char   chrtab[][16];
-FILE   *lpf = NULL;
-
-dem_con()
-{
-       if((lpf = fopen(lp, "w")) == NULL)
-               return(-1);
-       return(0);
-}
-
-dem_dis()
-{
-
-       FCLOSE(lpf);
-       FCLOSE(dfb);
-}
-
-dem_open(file)
-char   *file;
-{
-}
-
-dem_close()
-{
-}
-
-get_snumb()
-{
-}
-
-lwrite()
-{
-       banner(&line[1]);
-}
-
-
-FILE   *ibuf;
-
-sascii(fff)
-{
-       if((ibuf = fopen(&line[1], "r")) == NULL)
-               return(0);
-       if(fff)
-               putc(ff, lpf);
-       bsopt();
-       fflush(lpf);
-       fclose(ibuf);
-       return(0);
-}
-
-/*
- *     Copy file ibuf to lpf arranging that no
- *     backspaces will appear in the output.  Courtesy ARK
- */
-
-#define BSIZE 256
-
-char b1[BSIZE], b2[BSIZE];
-int size1, size2;
-
-bsopt()
-{
-       register int cp, c;
-
-       size1 = size2 = cp = 0;
-       while ((c = getc(ibuf)) != EOF) {
-               if (isprint (c)) {
-                       if (cp < BSIZE) {
-                               if (cp >= size1 || b1[cp] == ' ') {
-                                       while (cp >= size1)
-                                               b1[size1++] = ' ';
-                               } else {
-                                       if (cp < size2 && b2[cp] != ' ')
-                                               pr2();
-                                       while (cp >= size2)
-                                               b2[size2++] = ' ';
-                                       b2[cp] = b1[cp];
-                               }
-                               b1[cp++] = c;
-                       }
-               } else {
-                       switch (c) {
-
-                       case ' ':
-                               cp++;
-                               break;
-                       
-                       case '\b':
-                               if (cp)
-                                       cp--;
-                               break;
-
-                       case '\t':
-                               cp = (cp + 8) & -8;
-                               break;
-
-                       case '\r':
-                               cp = 0;
-                               break;
-
-                       case '\n':
-                       case '\f':
-                               pr2();
-                               pr1();
-                               putc(c, lpf);
-                               size1 = cp = 0;
-                               break;
-
-                       }
-               }
-       }
-       pr2();
-       pr1();
-}
-pr1()
-{
-       register char *p, *lim;
-
-       p = b1;
-       lim = p + size1;
-       while (p < lim)
-               putc(*p++, lpf);
-       size1 = 0;
-}
-
-pr2()
-{
-       register char *p, *lim;
-
-       p = b2;
-       lim = p + size2;
-       if (p < lim) {
-               do
-                       putc(*p++, lpf);
-               while (p < lim);
-               putc('\r', lpf);
-       }
-       size2 = 0;
-}
-
-/* VARARGS */
-trouble(s, a1, a2, a3, a4)
-char   *s;
-{
-       if(retcode != 0){
-               dem_dis();
-       }
-       longjmp(env, 1);
-}
-
-/* VARARGS */
-logerr()
-{
-}
-
-getowner()
-{
-}
-
-maildname()
-{
-       fprintf(pmail, "Your lpr printer job is done.\n");
-}
-
-banner(s)
-char *s;
-{
-       long timeb;
-       register char *sp;
-       int i, j, t, lsw;
-
-       for(lsw=0; s[lsw] && lsw<5; lsw++);
-       putc(ff, lpf);
-       fprintf(lpf, "\n\n\n\n\n\n\n\n");
-       for (i=0; i<16; i++) {
-               if(lsw < 5)
-                       fprintf(lpf, "                ");
-               for (sp=s; *sp; sp++) {
-                       if (*sp<=' '|| *sp >'}')
-                               continue;
-                       fprintf(lpf, "  ");
-                       t = chrtab[*sp - ' '][i];
-                       for (j=7; j>=0; j--)
-                               if ((t>>j) & 01)
-                                       putc('X', lpf);
-                               else
-                                       putc(' ', lpf);
-               }
-               putc('\n', lpf);
-       }
-       fprintf(lpf, "\n\n\n\n\n\n\n\n");
-       time(&timeb);
-       fprintf(lpf, "                ");
-       fprintf(lpf, ctime(&timeb));
-       putc(ff, lpf);
-}
diff --git a/usr/src/cmd/lpr/lpr.c b/usr/src/cmd/lpr/lpr.c
deleted file mode 100644 (file)
index 28eb6c9..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-#include       <stdio.h>
-
-/*
- *  lpr -- on line print to line printer
- */
-#ifdef VPR
-/*  if VPR defined, uses versatek printer via /usr/spool/vpd. */
-#endif
-
-#define        DPR     0
-#define        FGET    0
-#define        FSEND   0
-#define        GCAT    0
-#define        LPR     1
-
-#ifdef VPR
-#define        NAME    "vpr"
-#else
-#define        NAME    "lpr"
-#endif
-
-#define        BF      'F'
-#define        MAXCOPY 204800L
-#define FIRSTCHAR 'A'-1
-
-#ifdef VPR
-char   cfname[]        = "/usr/spool/vpd/cf@XXXXX";
-char   dfname[]        = "/usr/spool/vpd/df@XXXXX";
-char   lfname[]        = "/usr/spool/vpd/lf@XXXXX";
-char   tfname[]        = "/usr/spool/vpd/tf@XXXXX";
-char   zfname[]        = "/usr/spool/vpd/zf@XXXXX";
-#else
-char   cfname[]        = "/usr/spool/lpd/cf@XXXXX";
-char   dfname[]        = "/usr/spool/lpd/df@XXXXX";
-char   lfname[]        = "/usr/spool/lpd/lf@XXXXX";
-char   tfname[]        = "/usr/spool/lpd/tf@XXXXX";
-char   zfname[]        = "/usr/spool/lpd/zf@XXXXX";
-#endif
-
-#include       "spool.c"
-
-main(agc, agv)
-int agc;
-char *agv[];
-{
-       argc = agc;    argv = agv;
-       pidfn();
-
-       while (argc>1 && (arg = argv[1])[0]=='-') {
-           if(!comopt(arg[1]))
-               switch (arg[1]) {
-
-               default:
-                       fprintf(stderr, "%s: Unrecognized option: %s\n", NAME, arg);
-                       break;
-               }
-               argc--;
-               argv++;
-       }
-
-       if(debug)
-               tff = stdout;
-       else
-               if((tff = nfile(tfname)) == NULL){
-                       fprintf(stderr, "%s: Can't create %s.\n", NAME, tfname);
-                       out();
-               }
-       if(ident())
-               out();
-
-       filargs();              /*process file arguments.*/
-
-       if(debug)
-               out();
-       fclose(tff);
-       if(nact) {
-               dfname[INCHAR]++;
-               if(link(tfname, dfname) < 0){
-                       fprintf(stderr, "%s: Cannot rename %s\n", NAME, tfname);
-                       out();
-               }
-               unlink(tfname);
-#ifdef VPR
-               execl("/usr/lib/vpd", "vpd", 0);
-               execl("/etc/vpd", "vpd", 0);
-#else
-               execl("/usr/lib/lpd", "lpd", 0);
-               execl("/etc/lpd", "lpd", 0);
-#endif
-               fprintf(stderr, "%s: Can't find daemon.\nFiles left in spooling dir.\n", NAME);
-               exit(1);
-       }
-       out();
-}
-
-
-archive()
-{
-}
-
-
-nuact()
-{
-}
diff --git a/usr/src/cmd/lpr/makefile b/usr/src/cmd/lpr/makefile
deleted file mode 100644 (file)
index de5c503..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-lpr:   lpr.c spool.c
-       cc -n -s -O lpr.c -o lpr
-
-lpd:   lpd.c daemon.c daemon0.c
-       cc -n -s -O lpd.c -o lpd
-
-install:
-       cp lpr /bin/lpr
-       cp lpd /usr/lib/lpd
-       rm lpr
-       rm lpd
-       echo make sure /etc/rc contains
-       echo rm /usr/spool/lpd/lock; /usr/lib/lpd
-       mkdir /usr/spool
-       mkdir /usr/spool/lpd
diff --git a/usr/src/cmd/lpr/spool.c b/usr/src/cmd/lpr/spool.c
deleted file mode 100644 (file)
index 2aa9017..0000000
+++ /dev/null
@@ -1,436 +0,0 @@
-#include       <signal.h>
-#include       <sys/types.h>
-#include       <sys/stat.h>
-
-#define        ONL     0
-#define        TOSS    1
-int    INCHAR  = 0;            /*index of incremented character in
-                                       temporary file names. */
-
-char   version[] = "Version 2/6/79";
-
-char   grade;
-char   remote[]= "$    remote  **,onl";
-char   toss[]  = "$    sysout  toss";
-int    remotsw;                /*toss-output flag*/
-char   *mailfile = 0;
-char   wantmail = 0;
-char   *pp     = 0;            /*recipient of mail*/
-char   *identf = 0;            /*ident card info*/
-int    uidf    = 0;
-char   gcosid[13];             /*gcos userid*/
-char   cpflag = 'l';           /*copy/link flag*/
-int    rmflag  = 0;            /*remove flag*/
-int    debug   = 0;
-int    gcdebug = 0;            /*GCOS debug switch*/
-int    archsw = 0;             /*archive switch*/
-
-int    argc;
-char   **argv;
-char   *arg;
-char   buf[80];                /*used by card */
-int    nact = 0;               /*number of non-null files to process.*/
-int    gsize   = 20;           /*size of current file in GCOS blocks.*/
-long   usize   = 20*1200;      /*size of current file in bytes.*/
-FILE   *tff;           /*temporary control card file*/
-FILE   *nfile();
-char   *getarg();
-char   *sprintf();
-
-
-comopt(o)              /*routine to test for common options.*/
-char o;
-{
-       switch (o){
-
-       case 'c':
-               cpflag = 'c';
-               break;
-
-       case 'i':
-               identf = getarg('i');
-               break;
-
-       case 'm':
-               wantmail++;
-               if(arg[2])
-                       pp = &arg[2];
-               break;
-       
-       case 'n':               /*new option to suppress mail. MRW*/
-               wantmail = 0;
-               break;
-
-       case 'o':
-               remotsw = ONL;
-               break;
-
-       case 'r':
-               rmflag++;
-               break;
-
-       case 's':
-               if(arg[2] < '1' || arg[2] > '3')
-                       goto unknown;
-               grade = arg[2];
-               break;
-
-       case 't':
-               if(arg[2])
-                       goto unknown;
-               remotsw = TOSS;
-               break;
-
-       case '#':
-               debug = 1;
-               break;
-
-       case 'Z':                       /*GCOS debugging switch*/
-               gcdebug = 1;
-               break;
-
-unknown:
-       default:
-               return(0);
-       }
-       return(1);
-}
-
-
-#if LPR == 0
-
-spool1()               /*set up common initial GCOS control cards.*/
-{
-       if(debug)
-               tff = stdout;
-       else
-               if((tff = nfile(tfname)) == NULL){
-                       fprintf(stderr, "%s: Can't create %s.\n", NAME, tfname);
-                       out();
-               }
-       card('S', "");
-       card('L', sprintf(buf, "$       sgrade  %c   %s", grade, version ) );
-       if(ident())
-               out();
-       card('L', remote);
-       if(remotsw == TOSS)
-               card('L', toss);
-}
-
-
-spool2()                       /*add final control cards, and spool job.*/
-{
-       if(wantmail)
-               card('N', mailfile);
-       card('L', "$    endjob");
-       if(debug)
-               out();
-       fclose(tff);
-       if(nact) {
-               dfname[INCHAR]++;
-               if(link(tfname, dfname) < 0){
-                       fprintf(stderr, "%s: Cannot rename %s\n", NAME, tfname);
-                       out();
-               }
-               unlink(tfname);
-               execl("/usr/lib/dpd", "dpd", 0);
-               execl("/etc/dpd", "dpd", 0);
-               fprintf(stderr, "%s: Can't find dpd.\nFiles left in spooling dir.\n", NAME);
-               exit(1);
-       }
-}
-
-#endif
-
-
-#if FGET == 0
-
-filargs()              /*process file arguments for dpr, gcat, fsend, lpr.*/
-{
-       int i;
-       FILE *f;
-
-       if(argc == 1){
-               if(mailfile == 0)
-                       mailfile = "pipe.end";
-               if(copy(stdin, mailfile, GCAT) == -1)
-                       out();
-               if(archsw)
-                       archive();
-       }
-       while(--argc) {
-               arg = *++argv;
-               switch(cpflag){
-
-               case 'l':
-                       if(lfname[INCHAR]++ >= 'z')
-                               cpflag = rmflag ? 'c' : 'n';
-                       else if(link(arg, lfname) == 0){
-                               if(size(arg,arg) <= 0)
-                                       continue;
-                               nuact(arg);
-                               card(BF, lfname);
-                               card('U', lfname);
-                               break;
-                       }
-
-               case 'n':
-                       if(*arg == '/' && !rmflag){
-                               if(size(arg,arg) <= 0)
-                                       continue;
-                               nuact(arg);
-                               card(BF, arg);
-                               break;
-                       }
-
-               case 'c':
-                       f = fopen(arg, "r");
-                       if(f == NULL){
-                               fprintf(stderr, "%s: Cannot open %s\n", NAME, arg);
-                               continue;
-                       }
-                       i = copy(f, arg, GCAT);
-                       fclose(f);
-                       if(i == -1)
-                               continue;
-                       break;
-               }
-               if(archsw)
-                       archive();
-               if(rmflag){
-                       if(unlink(arg) < 0)
-                               fprintf(stderr, "%s: Cannot remove %s\n", NAME, arg);
-               }
-               if(mailfile == 0)
-                       mailfile = arg;
-       }
-}
-
-#endif
-
-
-FILE *nfile(name)              /*generate a new file name, and open file.*/
-char *name;
-{
-       FILE *f;
-
-       if(name[INCHAR] >= 'z')
-               return(NULL);
-       name[INCHAR]++;
-       if(!access(name, 0) || (f = fopen(name, "w")) == NULL)
-               return(NULL);
-       return(f);
-}
-
-#if FGET == 0
-copy(f, gname, gcatsw)
-FILE   *f;
-char   *gname;
-int    gcatsw;
-{
-       int c;
-       FILE *ff;
-       long cnt;
-
-       if((ff = nfile(cfname)) == NULL){
-               fprintf(stderr, "%s: Too many copy files; %s not copied\n", NAME, gname);
-               return(-1);
-       }
-       cnt = 0;
-       while((c = getc(f)) != EOF){
-               if(gcatsw)
-                   if(c != 0){
-                       fprintf(stderr, "%s: Bad input from %s.\n", NAME, gname);
-                       out();
-                   }else  gcatsw = 0;
-               if((putc(c, ff) == EOF) && ferror(ff)){
-                       fprintf(stderr, "%s: Write error on copy of %s.\n", NAME, gname);
-                       break;
-               }
-               cnt++;
-               if(cnt > MAXCOPY){
-                       fprintf(stderr, "%s: Copy file %s is too large\n", NAME, gname);
-                       break;
-               }
-       }
-       fclose(ff);
-       if(size(cfname,gname) <= 0)
-               return(-1);
-       nuact(gname);
-       card(BF, cfname);
-       card('U', cfname);
-       return(0);
-}
-
-#endif
-
-card(c, s)
-int c;
-char   *s;
-{
-       putc( c, tff );
-
-       while( (c = *s++) != '\0') putc( c, tff );
-
-       c = putc( '\n', tff );
-
-       if(c == EOF){
-               fprintf(stderr, "%s: Error writing control file.\n", NAME);
-               out();
-               }
-}
-
-size(file, name)
-char   *file, *name;
-{
-       struct stat stbuf;
-
-       if(stat(file,&stbuf) < 0){
-               fprintf(stderr, "%s: Cannot open %s\n", NAME, file);
-               return(-1);
-       }
-       if(!stbuf.st_size){
-               fprintf(stderr, "%s: File %s is empty.\n", NAME, name);
-               return(0);
-       }
-       usize = stbuf.st_size;
-       gsize = usize / 1200;
-       gsize++;
-       nact++;
-       return(gsize);
-}
-
-
-char *
-getarg(c)              /*get modifier for complex options --
-                           from either same or next argument. MRW
-                           e.g. either "-ffile" or "-f file"*/
-char   c;
-{
-
-       if(arg[2])
-               return(&arg[2]);
-       else if(--argc>1)
-               return(arg = (++argv)[1]);
-       fprintf(stderr, "%s: Incomplete -%c option\n", NAME,c);
-       out();
-}
-
-#include       <pwd.h>
-struct passwd *getpwuid();
-
-ident()
-{
-       int c, i, j, n, test, jsave;
-       struct passwd *b1;
-       static char b2[100];
-
-       if((b1 = getpwuid(getuid())) == NULL) {
-               fprintf(stderr, "%s: Invalid user id\n", NAME);
-               return(1);
-       }
-       j = 0;
-#if LPR == 0
-       while(c = "$    ident   "[j])
-               b2[j++] = c;
-
-       i = 0;
-       if(identf) 
-               while(c = identf[i++])
-                       b2[j++] = c;
-       else{
-               jsave = j;              /*use either usg or pwb-style passwd. MRW*/
-               while((c = b1->pw_gecos[i++]) && c != ':')
-                       if(c == ')')
-                               j = jsave;
-                       else
-                               b2[j++] = c;
-       }
-       b2[j++] = ',';
-#endif
-
-       i = 0;
-       if(!pp)
-               pp = &b2[j];
-       while(c = b1->pw_name[i++])
-               b2[j++] = c;
-       b2[j] = '\0';
-
-#if LPR == 0
-       i = 0;
-       n = 3;
-       while(--n) {
-               test = 0;
-               while((c=b2[i++]) && c != ',') {
-                       if('0' <= c && c <= '9') test += c -'0';
-                       else test = 0;
-               }
-               if(test == 0) {
-                       b2[j] = '\0';
-                       fprintf(stderr, "%s: Invalid IDENT information - %s\n", NAME, b2);
-                       return (1);
-               }
-       }
-
-       if(!uidf) {
-               n = 0;
-               while((c = b2[i++]) && c != ',') {
-                       if(n >= 12) break;
-                       gcosid[n++] = c;
-               }
-               gcosid[n++] = '\0';
-       }
-#endif
-       card('L', b2);
-       if(wantmail){
-               card('M',pp);
-               if(identf)
-                       card('Q', b2);  /*mail back $IDENT card.*/
-       }
-       return (0);
-}
-
-pidfn()                        /*rewrite using mktemp. MRW*/
-{
-       int out();
-
-       while(tfname[INCHAR] != 'X')
-               INCHAR++;
-       INCHAR--;
-       mktemp(cfname);
-       mktemp(dfname);
-       mktemp(lfname);
-       mktemp(tfname);
-       mktemp(zfname);
-       if(signal(SIGHUP, SIG_IGN) != SIG_IGN)
-               signal(SIGHUP, out);
-       if(signal(SIGINT, SIG_IGN) != SIG_IGN)
-               signal(SIGINT, out);
-       if(signal(SIGQUIT, SIG_IGN) != SIG_IGN)
-               signal(SIGQUIT, out);
-       if(signal(SIGTERM, SIG_IGN) != SIG_IGN)
-               signal(SIGTERM, out);
-}
-
-out()
-{
-       register i;
-
-       signal(SIGHUP, SIG_IGN);
-       signal(SIGINT, SIG_IGN);
-       signal(SIGQUIT, SIG_IGN);
-       signal(SIGTERM, SIG_IGN);
-       i = INCHAR;
-       for(; cfname[i] != FIRSTCHAR; cfname[i]--) 
-               unlink(cfname);
-       if(dfname[i] != FIRSTCHAR)
-               unlink(dfname);
-       for(; lfname[i] != FIRSTCHAR; lfname[i]--) 
-               unlink(lfname);
-       if(tfname[i] != FIRSTCHAR)
-               unlink(tfname);
-       for(; zfname[i] != FIRSTCHAR; zfname[i]--) 
-               unlink(zfname);
-       exit(1);
-}
index e3d2fae..b731b42 100644 (file)
@@ -172,7 +172,7 @@ struct lbuf *ap;
        if (p->lnum == -1)
                return;
        if (iflg)
        if (p->lnum == -1)
                return;
        if (iflg)
-               printf("%5u ", p->lnum);
+               printf("%5d ", p->lnum);
        if (sflg)
        printf("%4D ", nblock(p->lsize));
        if (lflg) {
        if (sflg)
        printf("%4D ", nblock(p->lsize));
        if (lflg) {
@@ -328,7 +328,6 @@ struct lbuf *
 gstat(file, argfl)
 char *file;
 {
 gstat(file, argfl)
 char *file;
 {
-       extern char *malloc();
        struct stat statb;
        register struct lbuf *rep;
        static int nomocore;
        struct stat statb;
        register struct lbuf *rep;
        static int nomocore;
diff --git a/usr/src/cmd/m4/Makefile b/usr/src/cmd/m4/Makefile
new file mode 100644 (file)
index 0000000..4ba2b56
--- /dev/null
@@ -0,0 +1,9 @@
+CFLAGS=-O
+m4:    m4.o m4y.o
+       $(CC) -o m4 m4.o m4y.o 
+
+install:
+       install -s m4 $(DESTDIR)/usr/bin
+
+clean:
+       rm -f *.o
diff --git a/usr/src/cmd/m4/makefile b/usr/src/cmd/m4/makefile
deleted file mode 100644 (file)
index e572734..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-CFLAGS = -n -O -s
-
-m4:    m4.o m4y.o
-       cc -n -s -o m4 m4.o m4y.o
-
-all:   m4
-
-cmp:   m4
-       cmp m4 /bin/m4
-       rm m4 *.o
-
-cp:    m4
-       cp m4 /bin/m4
-       rm m4 *.o
index b43f498..41bdafa 100644 (file)
@@ -5,7 +5,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <setjmp.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <setjmp.h>
-#include <whoami.h>
 
 /*copylet flags */
        /*remote mail, add rmtmsg */
 
 /*copylet flags */
        /*remote mail, add rmtmsg */
@@ -31,7 +30,8 @@ char  lettmp[] = "/tmp/maXXXXX";
 char   maildir[] = "/usr/spool/mail/";
 char   mailfile[] = "/usr/spool/mail/xxxxxxxxxxxxxxxxxxxxxxx";
 char   dead[] = "dead.letter";
 char   maildir[] = "/usr/spool/mail/";
 char   mailfile[] = "/usr/spool/mail/xxxxxxxxxxxxxxxxxxxxxxx";
 char   dead[] = "dead.letter";
-char   *thissys = sysname;
+char   *rmtmsg = " remote from vax135\n";              /*LOCAL*/
+char   *thissys = "vax135";            /*LOCAL*/
 char   forwmsg[] = " forwarded\n";
 char   *curlock;
 int    lockerror;
 char   forwmsg[] = " forwarded\n";
 char   *curlock;
 int    lockerror;
@@ -332,7 +332,7 @@ copylet(n, f, type) FILE *f;
        while(k-- > 1 && (ch=fgetc(tmpf))!='\n')
                if(type!=ZAP) fputc(ch,f);
        if(type==REMOTE)
        while(k-- > 1 && (ch=fgetc(tmpf))!='\n')
                if(type!=ZAP) fputc(ch,f);
        if(type==REMOTE)
-               fprintf(f, " remote from %s\n", thissys);
+               fprintf(f, rmtmsg);
        else if (type==FORWARD)
                fprintf(f, forwmsg);
        else if(type==ORDINARY)
        else if (type==FORWARD)
                fprintf(f, forwmsg);
        else if(type==ORDINARY)
diff --git a/usr/src/cmd/make/Makefile b/usr/src/cmd/make/Makefile
new file mode 100644 (file)
index 0000000..ee1bd65
--- /dev/null
@@ -0,0 +1,71 @@
+# Description file for the Make command
+
+P = und -3 | opr -r2
+T =
+FILES = Makefile ident.c defs main.c doname.c misc.c files.c dosys.c\
+       gram.y gcos.c
+OBJECTS = ident.o main.o doname.o misc.o files.o dosys.o gram.o 
+LIBES= 
+LINT = lint -ps
+CFLAGS = -O
+
+GCOSFILES = defs ident.c main.c doname.c misc.c gram.c gcos.c
+
+all:   make
+
+cmp:   make
+       cmp make /bin/make
+       rm *.o gram.c make
+
+cp:    make
+       cp make /bin/make
+       rm *.o gram.c make
+
+make:  $(OBJECTS)
+       $(CC) -n -s $(CFLAGS) $(OBJECTS) $(LIBES) -o make
+
+$(OBJECTS):  defs
+
+clean:
+       -rm -f *.o gram.c
+
+install:
+       install make $(DESTDIR)/bin/make
+
+printall: # Print files off line.
+       -pr $(FILES) | $P
+       touch print
+
+print:  $(FILES)       # print recently changed files
+       -pr $? | $P
+       touch print
+
+save: # Write files on Spider store.
+       -nfs -ucv make $(FILES)
+
+test: 1zap 2zap
+       diff 1zap 2zap
+       rm 1zap 2zap
+
+1zap:
+       ./make -dp | grep -v TIME >1zap
+
+2zap:
+       /bin/make -dp | grep -v TIME >2zap
+
+time:  time1 time2 ;
+
+time1 time2 :
+       time ./make $T
+       time /bin/make $T
+
+lint :  dosys.c doname.c files.c main.c misc.c ident.c gram.c
+       $(LINT) dosys.c doname.c files.c main.c misc.c ident.c gram.c
+       rm gram.c
+
+src:
+       cp $(FILES) /usr/src/cmd/make
+
+gcos: $(GCOSFILES)
+       fsend -c -u sif $?
+       touch gcos
index f0ef709..99075f4 100644 (file)
@@ -51,12 +51,11 @@ int intrupt();
 int status;
 register int pid;
 
 int status;
 register int pid;
 
-enbint(SIG_IGN);
+enbint(intrupt);
 while( (pid = wait(&status)) != waitpid)
        if(pid == -1)
                fatal("bad wait code");
 waitpid = 0;
 while( (pid = wait(&status)) != waitpid)
        if(pid == -1)
                fatal("bad wait code");
 waitpid = 0;
-enbint(intrupt);
 return(status);
 }
 
 return(status);
 }
 
@@ -106,7 +105,6 @@ if((waitpid = fork()) == 0)
        {
        enbint(SIG_DFL);
        doclose();
        {
        enbint(SIG_DFL);
        doclose();
-       enbint(intrupt);
        execvp(str, argv);
        fatal1("Cannot load %s",str);
        }
        execvp(str, argv);
        fatal1("Cannot load %s",str);
        }
index 97db54a..d432bae 100644 (file)
@@ -14,7 +14,7 @@ char *builtin[] =
        "LFLAGS=",
        "CC=cc",
 #ifdef vax
        "LFLAGS=",
        "CC=cc",
 #ifdef vax
-       "AS=as".
+       "AS=as",
 #else
        "AS=as -",
 #endif
 #else
        "AS=as -",
 #endif
@@ -373,7 +373,6 @@ while(getarch())
                        {
                        fread( (char *) &objentry, sizeof(objentry),1,arfd);
                        if( (objentry.n_type & N_EXT)
                        {
                        fread( (char *) &objentry, sizeof(objentry),1,arfd);
                        if( (objentry.n_type & N_EXT)
-                          && ((objentry.n_type & ~N_EXT) || objentry.n_value)
                           && eqstr(objentry.n_name,s,nc))
                                {
                                clarch();
                           && eqstr(objentry.n_name,s,nc))
                                {
                                clarch();
@@ -441,12 +440,9 @@ long int skip;
 fread( (char *) &objhead, sizeof(objhead), 1, arfd);
 if( objhead.a_magic != A_MAGIC1 &&
     objhead.a_magic != A_MAGIC2 &&
 fread( (char *) &objhead, sizeof(objhead), 1, arfd);
 if( objhead.a_magic != A_MAGIC1 &&
     objhead.a_magic != A_MAGIC2 &&
-    objhead.a_magic != A_MAGIC3 &&
-    objhead.a_magic != A_MAGIC4 )
+    objhead.a_magic != A_MAGIC3 )
                fatal1("%s is not an object module", arhead.ar_name);
                fatal1("%s is not an object module", arhead.ar_name);
-skip = objhead.a_text + objhead.a_data;
-if(! objhead.a_flag )
-       skip *= 2;
+skip = objhead.a_text + objhead.a_data + objhead.a_trsize + objhead.a_drsize;
 fseek(arfd, skip, 1);
 }
 
 fseek(arfd, skip, 1);
 }
 
index ae1ab0c..acae0e5 100644 (file)
@@ -1,4 +1,4 @@
-char *xxxvers =  "\nMAKE.  VERSION 2.58     14 MARCH 1979\n" ;
+char *xxxvers =  "\nMAKE.  VERSION 2.54     29 AUGUST 1978\n" ;
 
 /*
 2.1 4/24/76    Base version
 
 /*
 2.1 4/24/76    Base version
@@ -89,8 +89,4 @@ char *xxxvers =  "\nMAKE.  VERSION 2.58     14 MARCH 1979\n" ;
 2.52
 2.53   Changed handling of "touch"
 2.54   Fixed bug involving comments in lexical analyzer.
 2.52
 2.53   Changed handling of "touch"
 2.54   Fixed bug involving comments in lexical analyzer.
-2.55   Ignore commands that begin with a # are comments.
-2.56   Added = to list of META characters (to permit shell commands)
-2.57   Changed lookarch and getobj to fix bugs.
-2.58   Fixed interrupt handling.
 */
 */
index 12de0ea..88feef4 100644 (file)
@@ -66,7 +66,7 @@ meter(METERFILE);
 descset = 0;
 
 funny['\0'] = (META | TERMINAL);
 descset = 0;
 
 funny['\0'] = (META | TERMINAL);
-for(s = "=|^();&<>*?[]:$`'\"\\\n" ; *s ; ++s)
+for(s = "|^();&<>*?[]:$`'\"\\\n" ; *s ; ++s)
        funny[*s] |= META;
 for(s = "\n\t :;&>|" ; *s ; ++s)
        funny[*s] |= TERMINAL;
        funny[*s] |= META;
 for(s = "\n\t :;&>|" ; *s ; ++s)
        funny[*s] |= TERMINAL;
diff --git a/usr/src/cmd/make/makefile b/usr/src/cmd/make/makefile
deleted file mode 100644 (file)
index 77d0214..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-# Description file for the Make command
-
-P = und -3 | opr -r2
-T =
-FILES = makefile ident.c defs main.c doname.c misc.c files.c dosys.c\
-       gram.y gcos.c
-OBJECTS = ident.o main.o doname.o misc.o files.o dosys.o gram.o 
-LIBES= 
-LINT = lint -ps
-CFLAGS = -O
-
-GCOSFILES = defs ident.c main.c doname.c misc.c gram.c gcos.c
-
-all:   make
-
-cmp:   make
-       cmp make /bin/make
-       rm *.o gram.c make
-
-cp:    make
-       cp make /bin/make
-       rm *.o gram.c make
-
-make:  $(OBJECTS)
-       $(CC) -n -s $(CFLAGS) $(OBJECTS) $(LIBES) -o make
-
-$(OBJECTS):  defs
-
-cleanup:
-       -rm *.o gram.c
-       -du
-
-install:
-       cp make /bin/make
-
-printall: # Print files off line.
-       -pr $(FILES) | $P
-       touch print
-
-print:  $(FILES)       # print recently changed files
-       -pr $? | $P
-       touch print
-
-save: # Write files on Spider store.
-       -nfs -ucv make $(FILES)
-
-test: 1zap 2zap
-       diff 1zap 2zap
-       rm 1zap 2zap
-
-1zap:
-       ./make -dp | grep -v TIME >1zap
-
-2zap:
-       /bin/make -dp | grep -v TIME >2zap
-
-time:  time1 time2 ;
-
-time1 time2 :
-       time ./make $T
-       time /bin/make $T
-
-lint :  dosys.c doname.c files.c main.c misc.c ident.c gram.c
-       $(LINT) dosys.c doname.c files.c main.c misc.c ident.c gram.c
-       rm gram.c
-
-src:
-       cp $(FILES) /usr/src/cmd/make
-
-gcos: $(GCOSFILES)
-       fsend -c -u sif $?
-       touch gcos
index 3df4da0..e954919 100644 (file)
@@ -85,8 +85,7 @@ register char *s;
 char *calloc();
 register char *t, *t0;
 
 char *calloc();
 register char *t, *t0;
 
-if( (t = t0 = calloc( strlen(s)+1 , sizeof(char)) ) == NULL)
-       fatal("out of memory");
+t = t0 = calloc( strlen(s)+1 , sizeof(char) );
 while(*t++ = *s++)
        ;
 return(t0);
 while(*t++ = *s++)
        ;
 return(t0);
diff --git a/usr/src/cmd/makeall b/usr/src/cmd/makeall
deleted file mode 100755 (executable)
index 5b90239..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-arg=-cp
-case $1 in
-       -cmp)   arg=-cmp ;;
-esac
-
-for i in *.[csy]; do cmake $arg $i; done
-
-case $arg in
-       -cmp)   arg=cmp ;;
-       -cp)    arg=cp ;;
-esac
-(echo ==== adb =====; cd adb; make $arg)
-(echo ==== as =====; cd as; make $arg)
-(echo ==== awk =====; cd awk; make $arg)
-(echo ==== c =====; cd c; make $arg)
-(echo ==== cpp =====; cd cpp; make $arg)
-(echo ==== dc =====; cd dc; make $arg)
-(echo ==== eqn =====; cd eqn; make $arg)
-(echo ==== f77 =====; cd f77; make $arg)
-(echo ==== learn =====; cd learn; make $arg)
-(echo ==== lex =====; cd lex; make $arg)
-(echo ==== lint =====; cd lint; make $arg)
-(echo ==== m4 =====; cd m4; make $arg)
-(echo ==== make =====; cd make; make $arg)
-(echo ==== neqn =====; cd neqn; make $arg)
-(echo ==== pcc =====; cd pcc; make $arg)
-(echo ==== plot =====; cd plot; make $arg)
-(echo ==== prep =====; cd prep; make $arg)
-(echo ==== ratfor =====; cd ratfor; make $arg)
-(echo ==== refer =====; cd refer; make $arg)
-(echo ==== roff =====; cd roff; make $arg)
-(echo ==== sed =====; cd sed; make $arg)
-(echo ==== sh =====; cd sh; make $arg)
-(echo ==== spell =====; cd spell; make $arg)
-(echo ==== struct =====; cd struct; make $arg)
-(echo ==== tar =====; cd tar; make $arg)
-(echo ==== tbl =====; cd tbl; make $arg)
-(echo ==== tp =====; cd tp; make $arg)
-(echo ==== troff =====; cd troff; make $arg)
-(echo ==== uucp =====; cd uucp; make $arg)
-(echo ==== xsend =====; cd xsend; make $arg)
-(echo ==== yacc =====; cd yacc; make $arg)
diff --git a/usr/src/cmd/man.sh b/usr/src/cmd/man.sh
new file mode 100755 (executable)
index 0000000..28a4218
--- /dev/null
@@ -0,0 +1,62 @@
+cmd= sec= fil= opt= i= all=
+cmd=n sec=\?
+cd /usr/man
+for i
+do
+       case $i in
+
+       [1-8])
+               sec=$i ;;
+       -n)
+               cmd=n ;;
+       -t)
+               cmd=t ;;
+       -k)
+               cmd=k ;;
+       -e | -et | -te)
+               cmd=e ;;
+       -ek | -ke)
+               cmd=ek ;;
+       -ne | -en)
+               cmd=ne ;;
+
+       -w)
+               cmd=where ;;
+       -*)
+               opt="$opt $i" ;;
+
+       *)
+               fil=`echo man$sec/$i.*`
+               case $fil in
+               man7/eqnchar.7)
+                       all="$all /usr/pub/eqnchar $fil" ;;
+
+               *\*)
+                       echo $i not found 1>&2 ;;
+               *)
+                       all="$all $fil" ;;
+               esac
+       esac
+done
+case $all in
+       "")
+               exit ;;
+esac
+case $cmd in
+
+n)
+       nroff $opt -man $all ;;
+ne)
+       neqn $all | nroff $opt -man ;;
+t)
+       troff $opt -man $all ;;
+k)
+       troff -t $opt -man $all | tc ;;
+e)
+       eqn $all | troff $opt -man ;;
+ek)
+       eqn $all | troff -t $opt -man | tc ;;
+
+where)
+       echo $all ;;
+esac
index 58f111f..896445e 100644 (file)
@@ -154,12 +154,12 @@ usable( p, n, r ) NODE *p; {
                if( n & NBMASK ) return(0);
                }
        if( (n&NAMASK) && (szty(p->type) == 2) ){ /* only do the pairing for real regs */
                if( n & NBMASK ) return(0);
                }
        if( (n&NAMASK) && (szty(p->type) == 2) ){ /* only do the pairing for real regs */
-               if( r&01 ) return(0);
                if( !istreg(r+1) ) return( 0 );
                if( busy[r+1] > 1 ) return( 0 );
                if( busy[r] == 0 && busy[r+1] == 0  ||
                    busy[r+1] == 0 && shareit( p, r, n ) ||
                if( !istreg(r+1) ) return( 0 );
                if( busy[r+1] > 1 ) return( 0 );
                if( busy[r] == 0 && busy[r+1] == 0  ||
                    busy[r+1] == 0 && shareit( p, r, n ) ||
-                   busy[r] == 0 && shareit( p, r+1, n ) ){
+                   busy[r] == 0 && shareit( p, r+1, n ) ||
+                   shareit( p, r, n ) && shareit( p, r+1, n ) ){
                        busy[r] |= TBUSY;
                        busy[r+1] |= TBUSY;
                        return(1);
                        busy[r] |= TBUSY;
                        busy[r+1] |= TBUSY;
                        return(1);
@@ -206,7 +206,7 @@ recl2( p ) register NODE *p; {
        if( p->op == REG ) rfree( r, p->type );
        else if( p->op == OREG ) {
                if( R2TEST( r ) ) {
        if( p->op == REG ) rfree( r, p->type );
        else if( p->op == OREG ) {
                if( R2TEST( r ) ) {
-                       rfree( R2UPK1( r ), PTR+INT );
+                       if( R2UPK1( r ) != 100 ) rfree( R2UPK1( r ), PTR+INT );
                        rfree( R2UPK2( r ), INT );
                        }
                else {
                        rfree( R2UPK2( r ), INT );
                        }
                else {
@@ -228,7 +228,7 @@ rfree( r, t ) TWORD t; {
        if( istreg(r) ){
                if( --busy[r] < 0 ) cerror( "register overfreed");
                if( szty(t) == 2 ){
        if( istreg(r) ){
                if( --busy[r] < 0 ) cerror( "register overfreed");
                if( szty(t) == 2 ){
-                       if( (r&01) || (istreg(r)^istreg(r+1)) ) cerror( "illegal free" );
+                       if( (istreg(r)^istreg(r+1)) ) cerror( "illegal free" );
                        if( --busy[r+1] < 0 ) cerror( "register overfreed" );
                        }
                }
                        if( --busy[r+1] < 0 ) cerror( "register overfreed" );
                        }
                }
@@ -245,7 +245,7 @@ rbusy(r,t) TWORD t; {
        if( istreg(r) ) ++busy[r];
        if( szty(t) == 2 ){
                if( istreg(r+1) ) ++busy[r+1];
        if( istreg(r) ) ++busy[r];
        if( szty(t) == 2 ){
                if( istreg(r+1) ) ++busy[r+1];
-               if( (r&01) || (istreg(r)^istreg(r+1)) ) cerror( "illegal register pair freed" );
+               if( (istreg(r)^istreg(r+1)) ) cerror( "illegal register pair freed" );
                }
        }
 
                }
        }
 
@@ -304,7 +304,7 @@ reclaim( p, rw, cookie ) NODE *p; {
 
        if( callop(p->op) ){
                /* check that all scratch regs are free */
 
        if( callop(p->op) ){
                /* check that all scratch regs are free */
-               callchk(p);  /* ordinarily, this is the same as allchk() */
+               callchk(p);  /* ordinarily, this is the same as allchk */
                }
 
        if( rw == RNULL || (cookie&FOREFF) ){ /* totally clobber, leaving nothing */
                }
 
        if( rw == RNULL || (cookie&FOREFF) ){ /* totally clobber, leaving nothing */
@@ -327,8 +327,8 @@ reclaim( p, rw, cookie ) NODE *p; {
 
        qq = recres;
 
 
        qq = recres;
 
-       if( rw&RLEFT) *qq++ = getlr(p,'L');
-       if( rw&RRIGHT ) *qq++ = getlr(p,'R');
+       if( rw&RLEFT) *qq++ = p->left;
+       if( rw&RRIGHT ) *qq++ = p->right;
        if( rw&RESC1 ) *qq++ = &resc[0];
        if( rw&RESC2 ) *qq++ = &resc[1];
        if( rw&RESC3 ) *qq++ = &resc[2];
        if( rw&RESC1 ) *qq++ = &resc[0];
        if( rw&RESC2 ) *qq++ = &resc[1];
        if( rw&RESC3 ) *qq++ = &resc[2];
@@ -356,7 +356,8 @@ reclaim( p, rw, cookie ) NODE *p; {
 
        if( p->op == STARG ) p = p->left;  /* STARGs are still STARGS */
 
 
        if( p->op == STARG ) p = p->left;  /* STARGs are still STARGS */
 
-       q->type = p->type;  /* to make multi-register allocations work */
+/*     q->type = p->type;  /* to make multi-register allocations work */
+       q->type = p->type==FLOAT && q->op==REG ? DOUBLE : p->type;
                /* maybe there is a better way! */
        q = tcopy(q);
 
                /* maybe there is a better way! */
        q = tcopy(q);
 
@@ -375,14 +376,9 @@ reclaim( p, rw, cookie ) NODE *p; {
        switch( p->op ){
 
        case REG:
        switch( p->op ){
 
        case REG:
-               if( !rtyflg ){
-                       /* the C language requires intermediate results to change type */
-                       /* this is inefficient or impossible on some machines */
-                       /* the "T" command in match supresses this type changing */
-                       if( p->type == CHAR || p->type == SHORT ) p->type = INT;
-                       else if( p->type == UCHAR || p->type == USHORT ) p->type = UNSIGNED;
-                       else if( p->type == FLOAT ) p->type = DOUBLE;
-                       }
+               if( p->type == CHAR || p->type == SHORT ) p->type = INT;
+               else if( p->type == UCHAR || p->type == USHORT ) p->type = UNSIGNED;
+               else if( p->type == FLOAT ) p->type = DOUBLE;
                if( ! (p->rall & MUSTDO ) ) return;  /* unless necessary, ignore it */
                i = p->rall & ~MUSTDO;
                if( i & NOPREF ) return;
                if( ! (p->rall & MUSTDO ) ) return;  /* unless necessary, ignore it */
                i = p->rall & ~MUSTDO;
                if( i & NOPREF ) return;
@@ -397,15 +393,13 @@ reclaim( p, rw, cookie ) NODE *p; {
                        }
 
        case OREG:
                        }
 
        case OREG:
-               if( R2TEST(p->rval) ){
-                       int r1, r2;
-                       r1 = R2UPK1(p->rval);
-                       r2 = R2UPK2(p->rval);
-                       if( (busy[r1]>1 && istreg(r1)) || (busy[r2]>1 && istreg(r2)) ){
-                               cerror( "potential register overwrite" );
-                               }
+               if( p->op == REG || !R2TEST(p->rval) ) {
+                       if( busy[p->rval]>1 && istreg(p->rval) ) cerror( "potential register overwrite");
                        }
                        }
-               else if( (busy[p->rval]>1) && istreg(p->rval) ) cerror( "potential register overwrite");
+               else
+                       if( (R2UPK1(p->rval) != 100 && busy[R2UPK1(p->rval)]>1 && istreg(R2UPK1(p->rval)) )
+                               || (busy[R2UPK2(p->rval)]>1 && istreg(R2UPK2(p->rval)) ) )
+                          cerror( "potential register overwrite");
                }
 
        }
                }
 
        }
@@ -440,7 +434,7 @@ tcopy( p ) register NODE *p; {
        if( p->op == REG ) rbusy( r, p->type );
        else if( p->op == OREG ) {
                if( R2TEST(r) ){
        if( p->op == REG ) rbusy( r, p->type );
        else if( p->op == OREG ) {
                if( R2TEST(r) ){
-                       rbusy( R2UPK1(r), PTR+INT );
+                       if( R2UPK1(r) != 100 ) rbusy( R2UPK1(r), PTR+INT );
                        rbusy( R2UPK2(r), INT );
                        }
                else {
                        rbusy( R2UPK2(r), INT );
                        }
                else {
diff --git a/usr/src/cmd/mip/cgram.c b/usr/src/cmd/mip/cgram.c
new file mode 100644 (file)
index 0000000..f518135
--- /dev/null
@@ -0,0 +1,1065 @@
+# define NAME 2
+# define STRING 3
+# define ICON 4
+# define FCON 5
+# define PLUS 6
+# define MINUS 8
+# define MUL 11
+# define AND 14
+# define OR 17
+# define ER 19
+# define QUEST 21
+# define COLON 22
+# define ANDAND 23
+# define OROR 24
+# define ASOP 25
+# define RELOP 26
+# define EQUOP 27
+# define DIVOP 28
+# define SHIFTOP 29
+# define INCOP 30
+# define UNOP 31
+# define STROP 32
+# define TYPE 33
+# define CLASS 34
+# define STRUCT 35
+# define RETURN 36
+# define GOTO 37
+# define IF 38
+# define ELSE 39
+# define SWITCH 40
+# define BREAK 41
+# define CONTINUE 42
+# define WHILE 43
+# define DO 44
+# define FOR 45
+# define DEFAULT 46
+# define CASE 47
+# define SIZEOF 48
+# define ENUM 49
+# define LP 50
+# define RP 51
+# define LC 52
+# define RC 53
+# define LB 54
+# define RB 55
+# define CM 56
+# define SM 57
+# define ASSIGN 58
+
+# line 108 "/usr/src/cmd/mip/cgram.y"
+# include "mfile1"
+#define yyclearin yychar = -1
+#define yyerrok yyerrflag = 0
+extern int yychar;
+extern short yyerrflag;
+#ifndef YYMAXDEPTH
+#define YYMAXDEPTH 150
+#endif
+YYSTYPE yylval, yyval;
+
+# line 127 "/usr/src/cmd/mip/cgram.y"
+       static int fake = 0;
+       static char fakename[NCHNAM+1];
+# define YYERRCODE 256
+
+# line 814 "/usr/src/cmd/mip/cgram.y"
+
+
+NODE *
+mkty( t, d, s ) unsigned t; {
+       return( block( TYPE, NIL, NIL, t, d, s ) );
+       }
+
+NODE *
+bdty( op, p, v ) NODE *p; {
+       register NODE *q;
+
+       q = block( op, p, NIL, INT, 0, INT );
+
+       switch( op ){
+
+       case UNARY MUL:
+       case UNARY CALL:
+               break;
+
+       case LB:
+               q->right = bcon(v);
+               break;
+
+       case NAME:
+               q->rval = v;
+               break;
+
+       default:
+               cerror( "bad bdty" );
+               }
+
+       return( q );
+       }
+
+dstash( n ){ /* put n into the dimension table */
+       if( curdim >= DIMTABSZ-1 ){
+               cerror( "dimension table overflow");
+               }
+       dimtab[ curdim++ ] = n;
+       }
+
+savebc() {
+       if( psavbc > & asavbc[BCSZ-4 ] ){
+               cerror( "whiles, fors, etc. too deeply nested");
+               }
+       *psavbc++ = brklab;
+       *psavbc++ = contlab;
+       *psavbc++ = flostat;
+       *psavbc++ = swx;
+       flostat = 0;
+       }
+
+resetbc(mask){
+
+       swx = *--psavbc;
+       flostat = *--psavbc | (flostat&mask);
+       contlab = *--psavbc;
+       brklab = *--psavbc;
+
+       }
+
+addcase(p) NODE *p; { /* add case to switch */
+
+       p = optim( p );  /* change enum to ints */
+       if( p->op != ICON ){
+               uerror( "non-constant case expression");
+               return;
+               }
+       if( swp == swtab ){
+               uerror( "case not in switch");
+               return;
+               }
+       if( swp >= &swtab[SWITSZ] ){
+               cerror( "switch table overflow");
+               }
+       swp->sval = p->lval;
+       deflab( swp->slab = getlab() );
+       ++swp;
+       tfree(p);
+       }
+
+adddef(){ /* add default case to switch */
+       if( swtab[swx].slab >= 0 ){
+               uerror( "duplicate default in switch");
+               return;
+               }
+       if( swp == swtab ){
+               uerror( "default not inside switch");
+               return;
+               }
+       deflab( swtab[swx].slab = getlab() );
+       }
+
+swstart(){
+       /* begin a switch block */
+       if( swp >= &swtab[SWITSZ] ){
+               cerror( "switch table overflow");
+               }
+       swx = swp - swtab;
+       swp->slab = -1;
+       ++swp;
+       }
+
+swend(){ /* end a switch block */
+
+       register struct sw *swbeg, *p, *q, *r, *r1;
+       CONSZ temp;
+       int tempi;
+
+       swbeg = &swtab[swx+1];
+
+       /* sort */
+
+       r1 = swbeg;
+       r = swp-1;
+
+       while( swbeg < r ){
+               /* bubble largest to end */
+               for( q=swbeg; q<r; ++q ){
+                       if( q->sval > (q+1)->sval ){
+                               /* swap */
+                               r1 = q+1;
+                               temp = q->sval;
+                               q->sval = r1->sval;
+                               r1->sval = temp;
+                               tempi = q->slab;
+                               q->slab = r1->slab;
+                               r1->slab = tempi;
+                               }
+                       }
+               r = r1;
+               r1 = swbeg;
+               }
+
+       /* it is now sorted */
+
+       for( p = swbeg+1; p<swp; ++p ){
+               if( p->sval == (p-1)->sval ){
+                       uerror( "duplicate case in switch, %d", tempi=p->sval );
+                       return;
+                       }
+               }
+
+       genswitch( swbeg-1, swp-swbeg );
+       swp = swbeg-1;
+       }
+extern short  yyexca[];
+# define YYNPROD 184
+# define YYLAST 1232
+extern short  yyact[];
+extern short  yypact[];
+extern short  yypgo[];
+extern short  yyr1[];
+extern short  yyr2[];
+extern short  yychk[];
+extern short  yydef[];
+#
+# define YYFLAG -1000
+# define YYERROR goto yyerrlab
+# define YYACCEPT return(0)
+# define YYABORT return(1)
+
+/*     parser for yacc output  */
+
+#ifdef YYDEBUG
+int yydebug = 0; /* 1 for debugging */
+#endif
+YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
+int yychar = -1; /* current input token number */
+int yynerrs = 0;  /* number of errors */
+short yyerrflag = 0;  /* error recovery flag */
+
+yyparse() {
+
+       short yys[YYMAXDEPTH];
+       short yyj, yym;
+       register YYSTYPE *yypvt;
+       register short yystate, *yyps, yyn;
+       register YYSTYPE *yypv;
+       register short *yyxi;
+
+       yystate = 0;
+       yychar = -1;
+       yynerrs = 0;
+       yyerrflag = 0;
+       yyps= &yys[-1];
+       yypv= &yyv[-1];
+
+ yystack:    /* put a state and value onto the stack */
+
+#ifdef YYDEBUG
+       if( yydebug  ) printf( "state %d, char 0%o\n", yystate, yychar );
+#endif
+               if( ++yyps> &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
+               *yyps = yystate;
+               ++yypv;
+               *yypv = yyval;
+
+ yynewstate:
+
+       yyn = yypact[yystate];
+
+       if( yyn<= YYFLAG ) goto yydefault; /* simple state */
+
+       if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
+       if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;
+
+       if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
+               yychar = -1;
+               yyval = yylval;
+               yystate = yyn;
+               if( yyerrflag > 0 ) --yyerrflag;
+               goto yystack;
+               }
+
+ yydefault:
+       /* default state action */
+
+       if( (yyn=yydef[yystate]) == -2 ) {
+               if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
+               /* look through exception table */
+
+               for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
+
+               while( *(yyxi+=2) >= 0 ){
+                       if( *yyxi == yychar ) break;
+                       }
+               if( (yyn = yyxi[1]) < 0 ) return(0);   /* accept */
+               }
+
+       if( yyn == 0 ){ /* error */
+               /* error ... attempt to resume parsing */
+
+               switch( yyerrflag ){
+
+               case 0:   /* brand new error */
+
+                       yyerror( "syntax error" );
+               yyerrlab:
+                       ++yynerrs;
+
+               case 1:
+               case 2: /* incompletely recovered error ... try again */
+
+                       yyerrflag = 3;
+
+                       /* find a state where "error" is a legal shift action */
+
+                       while ( yyps >= yys ) {
+                          yyn = yypact[*yyps] + YYERRCODE;
+                          if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
+                             yystate = yyact[yyn];  /* simulate a shift of "error" */
+                             goto yystack;
+                             }
+                          yyn = yypact[*yyps];
+
+                          /* the current yyps has no shift onn "error", pop stack */
+
+#ifdef YYDEBUG
+                          if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
+#endif
+                          --yyps;
+                          --yypv;
+                          }
+
+                       /* there is no state on the stack with an error shift ... abort */
+
+       yyabort:
+                       return(1);
+
+
+               case 3:  /* no shift yet; clobber input char */
+
+#ifdef YYDEBUG
+                       if( yydebug ) printf( "error recovery discards char %d\n", yychar );
+#endif
+
+                       if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
+                       yychar = -1;
+                       goto yynewstate;   /* try again in the same state */
+
+                       }
+
+               }
+
+       /* reduction by production yyn */
+
+#ifdef YYDEBUG
+               if( yydebug ) printf("reduce %d\n",yyn);
+#endif
+               yyps -= yyr2[yyn];
+               yypvt = yypv;
+               yypv -= yyr2[yyn];
+               yyval = yypv[1];
+               yym=yyn;
+                       /* consult goto table to find next state */
+               yyn = yyr1[yyn];
+               yyj = yypgo[yyn] + *yyps + 1;
+               if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
+               switch(yym){
+                       
+case 2:
+# line 133 "/usr/src/cmd/mip/cgram.y"
+ftnend(); break;
+case 3:
+# line 136 "/usr/src/cmd/mip/cgram.y"
+{ curclass = SNULL;  blevel = 0; } break;
+case 4:
+# line 138 "/usr/src/cmd/mip/cgram.y"
+{ curclass = SNULL;  blevel = 0; } break;
+case 5:
+# line 142 "/usr/src/cmd/mip/cgram.y"
+{  yypvt[-1].nodep->op = FREE; } break;
+case 6:
+# line 144 "/usr/src/cmd/mip/cgram.y"
+{  yypvt[-2].nodep->op = FREE; } break;
+case 7:
+# line 145 "/usr/src/cmd/mip/cgram.y"
+{
+                               defid( tymerge(yypvt[-1].nodep,yypvt[-0].nodep), curclass==STATIC?STATIC:EXTDEF );
+#ifndef LINT
+                               pfstab(stab[yypvt[-0].nodep->rval].sname);
+#endif
+                               } break;
+case 8:
+# line 151 "/usr/src/cmd/mip/cgram.y"
+{  
+                           if( blevel ) cerror( "function level error" );
+                           if( reached ) retstat |= NRETVAL; 
+                           yypvt[-3].nodep->op = FREE;
+                           ftnend();
+                           } break;
+case 11:
+# line 162 "/usr/src/cmd/mip/cgram.y"
+{  blevel = 1; } break;
+case 13:
+# line 167 "/usr/src/cmd/mip/cgram.y"
+{  bccode();
+                           locctr(PROG);
+                           } break;
+case 14:
+# line 173 "/usr/src/cmd/mip/cgram.y"
+{  yypvt[-1].nodep->op = FREE; 
+#ifndef LINT
+                           plcstab(blevel);
+#endif
+                           } break;
+case 15:
+# line 179 "/usr/src/cmd/mip/cgram.y"
+{  yypvt[-2].nodep->op = FREE; 
+#ifndef LINT
+                           plcstab(blevel);
+#endif
+                           } break;
+case 16:
+# line 187 "/usr/src/cmd/mip/cgram.y"
+{  yypvt[-1].nodep->op = FREE; } break;
+case 17:
+# line 189 "/usr/src/cmd/mip/cgram.y"
+{  yypvt[-2].nodep->op = FREE; } break;
+case 19:
+# line 193 "/usr/src/cmd/mip/cgram.y"
+{ curclass = SNULL;  yypvt[-2].nodep->op = FREE; } break;
+case 20:
+# line 195 "/usr/src/cmd/mip/cgram.y"
+{ curclass = SNULL;  yypvt[-1].nodep->op = FREE; } break;
+case 21:
+# line 197 "/usr/src/cmd/mip/cgram.y"
+{  curclass = SNULL; } break;
+case 23:
+# line 201 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep = mkty(INT,0,INT);  curclass = SNULL; } break;
+case 24:
+# line 204 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep = yypvt[-0].nodep; } break;
+case 26:
+# line 207 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep = mkty(INT,0,INT); } break;
+case 27:
+# line 209 "/usr/src/cmd/mip/cgram.y"
+{ curclass = SNULL ; } break;
+case 28:
+# line 214 "/usr/src/cmd/mip/cgram.y"
+{  curclass = yypvt[-0].intval; } break;
+case 30:
+# line 219 "/usr/src/cmd/mip/cgram.y"
+{  yypvt[-1].nodep->type = types( yypvt[-1].nodep->type, yypvt[-0].nodep->type, UNDEF );
+                           yypvt[-0].nodep->op = FREE;
+                           } break;
+case 31:
+# line 223 "/usr/src/cmd/mip/cgram.y"
+{  yypvt[-2].nodep->type = types( yypvt[-2].nodep->type, yypvt[-1].nodep->type, yypvt[-0].nodep->type );
+                           yypvt[-1].nodep->op = yypvt[-0].nodep->op = FREE;
+                           } break;
+case 34:
+# line 231 "/usr/src/cmd/mip/cgram.y"
+{ yyval.nodep = dclstruct(yypvt[-4].intval); } break;
+case 35:
+# line 233 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep = rstruct(yypvt[-0].intval,0);  stwart = instruct; } break;
+case 36:
+# line 237 "/usr/src/cmd/mip/cgram.y"
+{  yyval.intval = bstruct(-1,0); } break;
+case 37:
+# line 239 "/usr/src/cmd/mip/cgram.y"
+{  yyval.intval = bstruct(yypvt[-0].intval,0); } break;
+case 40:
+# line 247 "/usr/src/cmd/mip/cgram.y"
+{  moedef( yypvt[-0].intval ); } break;
+case 41:
+# line 249 "/usr/src/cmd/mip/cgram.y"
+{  strucoff = yypvt[-0].intval;  moedef( yypvt[-2].intval ); } break;
+case 42:
+# line 253 "/usr/src/cmd/mip/cgram.y"
+{ yyval.nodep = dclstruct(yypvt[-4].intval);  } break;
+case 43:
+# line 255 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep = rstruct(yypvt[-0].intval,yypvt[-1].intval); } break;
+case 44:
+# line 259 "/usr/src/cmd/mip/cgram.y"
+{  yyval.intval = bstruct(-1,yypvt[-0].intval);  stwart=0; } break;
+case 45:
+# line 261 "/usr/src/cmd/mip/cgram.y"
+{  yyval.intval = bstruct(yypvt[-0].intval,yypvt[-1].intval);  stwart=0;  } break;
+case 48:
+# line 269 "/usr/src/cmd/mip/cgram.y"
+{ curclass = SNULL;  stwart=0; yypvt[-1].nodep->op = FREE; } break;
+case 49:
+# line 271 "/usr/src/cmd/mip/cgram.y"
+{  if( curclass != MOU ){
+                               curclass = SNULL;
+                               }
+                           else {
+                               sprintf( fakename, "$%dFAKE", fake++ );
+                               defid( tymerge(yypvt[-0].nodep, bdty(NAME,NIL,lookup( fakename, SMOS ))), curclass );
+                               }
+                           stwart = 0;
+                           yypvt[-0].nodep->op = FREE;
+                           } break;
+case 50:
+# line 285 "/usr/src/cmd/mip/cgram.y"
+{ defid( tymerge(yypvt[-1].nodep,yypvt[-0].nodep), curclass);  stwart = instruct; } break;
+case 51:
+# line 286 "/usr/src/cmd/mip/cgram.y"
+{yyval.nodep=yypvt[-2].nodep;} break;
+case 52:
+# line 287 "/usr/src/cmd/mip/cgram.y"
+{ defid( tymerge(yypvt[-4].nodep,yypvt[-0].nodep), curclass);  stwart = instruct; } break;
+case 55:
+# line 293 "/usr/src/cmd/mip/cgram.y"
+{  if( !(instruct&INSTRUCT) ) uerror( "field outside of structure" );
+                           if( yypvt[-0].intval<0 || yypvt[-0].intval >= FIELD ){
+                               uerror( "illegal field size" );
+                               yypvt[-0].intval = 1;
+                               }
+                           defid( tymerge(yypvt[-3].nodep,yypvt[-2].nodep), FIELD|yypvt[-0].intval );
+                           yyval.nodep = NIL;
+                           } break;
+case 56:
+# line 303 "/usr/src/cmd/mip/cgram.y"
+{  if( !(instruct&INSTRUCT) ) uerror( "field outside of structure" );
+                           falloc( stab, yypvt[-0].intval, -1, yypvt[-2].nodep );  /* alignment or hole */
+                           yyval.nodep = NIL;
+                           } break;
+case 57:
+# line 308 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep = NIL; } break;
+case 58:
+# line 313 "/usr/src/cmd/mip/cgram.y"
+{  umul:
+                               yyval.nodep = bdty( UNARY MUL, yypvt[-0].nodep, 0 ); } break;
+case 59:
+# line 316 "/usr/src/cmd/mip/cgram.y"
+{  uftn:
+                               yyval.nodep = bdty( UNARY CALL, yypvt[-2].nodep, 0 );  } break;
+case 60:
+# line 319 "/usr/src/cmd/mip/cgram.y"
+{  uary:
+                               yyval.nodep = bdty( LB, yypvt[-2].nodep, 0 );  } break;
+case 61:
+# line 322 "/usr/src/cmd/mip/cgram.y"
+{  bary:
+                               if( (int)yypvt[-1].intval <= 0 ) werror( "zero or negative subscript" );
+                               yyval.nodep = bdty( LB, yypvt[-3].nodep, yypvt[-1].intval );  } break;
+case 62:
+# line 326 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep = bdty( NAME, NIL, yypvt[-0].intval );  } break;
+case 63:
+# line 328 "/usr/src/cmd/mip/cgram.y"
+{ yyval.nodep=yypvt[-1].nodep; } break;
+case 64:
+# line 331 "/usr/src/cmd/mip/cgram.y"
+{  goto umul; } break;
+case 65:
+# line 333 "/usr/src/cmd/mip/cgram.y"
+{  goto uftn; } break;
+case 66:
+# line 335 "/usr/src/cmd/mip/cgram.y"
+{  goto uary; } break;
+case 67:
+# line 337 "/usr/src/cmd/mip/cgram.y"
+{  goto bary; } break;
+case 68:
+# line 339 "/usr/src/cmd/mip/cgram.y"
+{ yyval.nodep = yypvt[-1].nodep; } break;
+case 69:
+# line 341 "/usr/src/cmd/mip/cgram.y"
+{
+                               if( blevel!=0 ) uerror("function declaration in bad context");
+                               yyval.nodep = bdty( UNARY CALL, bdty(NAME,NIL,yypvt[-2].intval), 0 );
+                               stwart = 0;
+                               } break;
+case 70:
+# line 347 "/usr/src/cmd/mip/cgram.y"
+{
+                               yyval.nodep = bdty( UNARY CALL, bdty(NAME,NIL,yypvt[-1].intval), 0 );
+                               stwart = 0;
+                               } break;
+case 71:
+# line 354 "/usr/src/cmd/mip/cgram.y"
+{
+                               /* turn off typedefs for argument names */
+                               stwart = SEENAME;
+                               } break;
+case 72:
+# line 361 "/usr/src/cmd/mip/cgram.y"
+{ ftnarg( yypvt[-0].intval );  stwart = SEENAME; } break;
+case 73:
+# line 363 "/usr/src/cmd/mip/cgram.y"
+{ ftnarg( yypvt[-0].intval );  stwart = SEENAME; } break;
+case 75:
+# line 368 "/usr/src/cmd/mip/cgram.y"
+{yyval.nodep=yypvt[-2].nodep;} break;
+case 77:
+# line 372 "/usr/src/cmd/mip/cgram.y"
+{  defid( yypvt[-0].nodep = tymerge(yypvt[-1].nodep,yypvt[-0].nodep), curclass);
+                           beginit(yypvt[-0].nodep->rval);
+                           } break;
+case 79:
+# line 379 "/usr/src/cmd/mip/cgram.y"
+{  nidcl( tymerge(yypvt[-1].nodep,yypvt[-0].nodep) ); } break;
+case 80:
+# line 381 "/usr/src/cmd/mip/cgram.y"
+{  defid( tymerge(yypvt[-1].nodep,yypvt[-0].nodep), uclass(curclass) );
+                       } break;
+case 81:
+# line 385 "/usr/src/cmd/mip/cgram.y"
+{  doinit( yypvt[-0].nodep );
+                           endinit(); } break;
+case 82:
+# line 388 "/usr/src/cmd/mip/cgram.y"
+{  endinit(); } break;
+case 85:
+# line 397 "/usr/src/cmd/mip/cgram.y"
+{  doinit( yypvt[-0].nodep ); } break;
+case 86:
+# line 399 "/usr/src/cmd/mip/cgram.y"
+{  irbrace(); } break;
+case 91:
+# line 411 "/usr/src/cmd/mip/cgram.y"
+{  werror( "old-fashioned initialization: use =" ); } break;
+case 93:
+# line 416 "/usr/src/cmd/mip/cgram.y"
+{  ilbrace(); } break;
+case 96:
+# line 426 "/usr/src/cmd/mip/cgram.y"
+{  
+#ifndef LINT
+                           prcstab(blevel);
+#endif
+                           --blevel;
+                           if( blevel == 1 ) blevel = 0;
+                           clearst( blevel );
+                           checkst( blevel );
+                           autooff = *--psavbc;
+                           regvar = *--psavbc;
+                           } break;
+case 97:
+# line 440 "/usr/src/cmd/mip/cgram.y"
+{  --blevel;
+                           if( blevel == 1 ) blevel = 0;
+                           clearst( blevel );
+                           checkst( blevel );
+                           autooff = *--psavbc;
+                           regvar = *--psavbc;
+                           } break;
+case 98:
+# line 450 "/usr/src/cmd/mip/cgram.y"
+{  if( blevel == 1 ) dclargs();
+                           ++blevel;
+                           if( psavbc > &asavbc[BCSZ-2] ) cerror( "nesting too deep" );
+                           *psavbc++ = regvar;
+                           *psavbc++ = autooff;
+                           } break;
+case 99:
+# line 459 "/usr/src/cmd/mip/cgram.y"
+{ ecomp( yypvt[-1].nodep ); } break;
+case 101:
+# line 462 "/usr/src/cmd/mip/cgram.y"
+{ deflab(yypvt[-1].intval);
+                          reached = 1;
+                          } break;
+case 102:
+# line 466 "/usr/src/cmd/mip/cgram.y"
+{  if( yypvt[-1].intval != NOLAB ){
+                               deflab( yypvt[-1].intval );
+                               reached = 1;
+                               }
+                           } break;
+case 103:
+# line 472 "/usr/src/cmd/mip/cgram.y"
+{  branch(  contlab );
+                           deflab( brklab );
+                           if( (flostat&FBRK) || !(flostat&FLOOP)) reached = 1;
+                           else reached = 0;
+                           resetbc(0);
+                           } break;
+case 104:
+# line 479 "/usr/src/cmd/mip/cgram.y"
+{  deflab( contlab );
+                           if( flostat & FCONT ) reached = 1;
+                           ecomp( buildtree( CBRANCH, buildtree( NOT, yypvt[-2].nodep, NIL ), bcon( yypvt[-6].intval ) ) );
+                           deflab( brklab );
+                           reached = 1;
+                           resetbc(0);
+                           } break;
+case 105:
+# line 487 "/usr/src/cmd/mip/cgram.y"
+{  deflab( contlab );
+                           if( flostat&FCONT ) reached = 1;
+                           if( yypvt[-2].nodep ) ecomp( yypvt[-2].nodep );
+                           branch( yypvt[-3].intval );
+                           deflab( brklab );
+                           if( (flostat&FBRK) || !(flostat&FLOOP) ) reached = 1;
+                           else reached = 0;
+                           resetbc(0);
+                           } break;
+case 106:
+# line 497 "/usr/src/cmd/mip/cgram.y"
+{  if( reached ) branch( brklab );
+                           deflab( yypvt[-1].intval );
+                          swend();
+                           deflab(brklab);
+                           if( (flostat&FBRK) || !(flostat&FDEF) ) reached = 1;
+                           resetbc(FCONT);
+                           } break;
+case 107:
+# line 505 "/usr/src/cmd/mip/cgram.y"
+{  if( brklab == NOLAB ) uerror( "illegal break");
+                           else if(reached) branch( brklab );
+                           flostat |= FBRK;
+                           if( brkflag ) goto rch;
+                           reached = 0;
+                           } break;
+case 108:
+# line 512 "/usr/src/cmd/mip/cgram.y"
+{  if( contlab == NOLAB ) uerror( "illegal continue");
+                           else branch( contlab );
+                           flostat |= FCONT;
+                           goto rch;
+                           } break;
+case 109:
+# line 518 "/usr/src/cmd/mip/cgram.y"
+{  retstat |= NRETVAL;
+                           branch( retlab );
+                       rch:
+                           if( !reached ) werror( "statement not reached");
+                           reached = 0;
+                           } break;
+case 110:
+# line 525 "/usr/src/cmd/mip/cgram.y"
+{  register NODE *temp;
+                           idname = curftn;
+                           temp = buildtree( NAME, NIL, NIL );
+                           temp->type = DECREF( temp->type );
+                           temp = buildtree( RETURN, temp, yypvt[-1].nodep );
+                           /* now, we have the type of the RHS correct */
+                           temp->left->op = FREE;
+                           temp->op = FREE;
+                           ecomp( buildtree( FORCE, temp->right, NIL ) );
+                           retstat |= RETVAL;
+                           branch( retlab );
+                           reached = 0;
+                           } break;
+case 111:
+# line 539 "/usr/src/cmd/mip/cgram.y"
+{  register NODE *q;
+                           q = block( FREE, NIL, NIL, INT|ARY, 0, INT );
+                           q->rval = idname = yypvt[-1].intval;
+                           defid( q, ULABEL );
+                           stab[idname].suse = -lineno;
+                           branch( stab[idname].offset );
+                           goto rch;
+                           } break;
+case 116:
+# line 553 "/usr/src/cmd/mip/cgram.y"
+{  register NODE *q;
+                           q = block( FREE, NIL, NIL, INT|ARY, 0, LABEL );
+                           q->rval = yypvt[-1].intval;
+                           defid( q, LABEL );
+                           reached = 1;
+                           } break;
+case 117:
+# line 560 "/usr/src/cmd/mip/cgram.y"
+{  addcase(yypvt[-1].nodep);
+                           reached = 1;
+                           } break;
+case 118:
+# line 564 "/usr/src/cmd/mip/cgram.y"
+{  reached = 1;
+                           adddef();
+                           flostat |= FDEF;
+                           } break;
+case 119:
+# line 570 "/usr/src/cmd/mip/cgram.y"
+{  savebc();
+                           if( !reached ) werror( "loop not entered at top");
+                           brklab = getlab();
+                           contlab = getlab();
+                           deflab( yyval.intval = getlab() );
+                           reached = 1;
+                           } break;
+case 120:
+# line 579 "/usr/src/cmd/mip/cgram.y"
+{  ecomp( buildtree( CBRANCH, yypvt[-1].nodep, bcon( yyval.intval=getlab()) ) ) ;
+                           reached = 1;
+                           } break;
+case 121:
+# line 584 "/usr/src/cmd/mip/cgram.y"
+{  if( reached ) branch( yyval.intval = getlab() );
+                           else yyval.intval = NOLAB;
+                           deflab( yypvt[-2].intval );
+                           reached = 1;
+                           } break;
+case 122:
+# line 592 "/usr/src/cmd/mip/cgram.y"
+{  savebc();
+                           if( !reached ) werror( "loop not entered at top");
+                           if( yypvt[-1].nodep->op == ICON && yypvt[-1].nodep->lval != 0 ) flostat = FLOOP;
+                           deflab( contlab = getlab() );
+                           reached = 1;
+                           brklab = getlab();
+                           if( flostat == FLOOP ) tfree( yypvt[-1].nodep );
+                           else ecomp( buildtree( CBRANCH, yypvt[-1].nodep, bcon( brklab) ) );
+                           } break;
+case 123:
+# line 603 "/usr/src/cmd/mip/cgram.y"
+{  if( yypvt[-3].nodep ) ecomp( yypvt[-3].nodep );
+                           else if( !reached ) werror( "loop not entered at top");
+                           savebc();
+                           contlab = getlab();
+                           brklab = getlab();
+                           deflab( yyval.intval = getlab() );
+                           reached = 1;
+                           if( yypvt[-1].nodep ) ecomp( buildtree( CBRANCH, yypvt[-1].nodep, bcon( brklab) ) );
+                           else flostat |= FLOOP;
+                           } break;
+case 124:
+# line 615 "/usr/src/cmd/mip/cgram.y"
+{  savebc();
+                           brklab = getlab();
+                           ecomp( buildtree( FORCE, yypvt[-1].nodep, NIL ) );
+                           branch( yyval.intval = getlab() );
+                           swstart();
+                           reached = 0;
+                           } break;
+case 125:
+# line 624 "/usr/src/cmd/mip/cgram.y"
+{ yyval.intval=instruct; stwart=instruct=0; } break;
+case 126:
+# line 626 "/usr/src/cmd/mip/cgram.y"
+{  yyval.intval = icons( yypvt[-0].nodep );  instruct=yypvt[-1].intval; } break;
+case 128:
+# line 630 "/usr/src/cmd/mip/cgram.y"
+{ yyval.nodep=0; } break;
+case 130:
+# line 635 "/usr/src/cmd/mip/cgram.y"
+{  goto bop; } break;
+case 131:
+# line 639 "/usr/src/cmd/mip/cgram.y"
+{
+                       preconf:
+                           if( yychar==RELOP||yychar==EQUOP||yychar==AND||yychar==OR||yychar==ER ){
+                           precplaint:
+                               if( hflag ) werror( "precedence confusion possible: parenthesize!" );
+                               }
+                       bop:
+                           yyval.nodep = buildtree( yypvt[-1].intval, yypvt[-2].nodep, yypvt[-0].nodep );
+                           } break;
+case 132:
+# line 649 "/usr/src/cmd/mip/cgram.y"
+{  yypvt[-1].intval = COMOP;
+                           goto bop;
+                           } break;
+case 133:
+# line 653 "/usr/src/cmd/mip/cgram.y"
+{  goto bop; } break;
+case 134:
+# line 655 "/usr/src/cmd/mip/cgram.y"
+{  if(yychar==SHIFTOP) goto precplaint; else goto bop; } break;
+case 135:
+# line 657 "/usr/src/cmd/mip/cgram.y"
+{  if(yychar==SHIFTOP ) goto precplaint; else goto bop; } break;
+case 136:
+# line 659 "/usr/src/cmd/mip/cgram.y"
+{  if(yychar==PLUS||yychar==MINUS) goto precplaint; else goto bop; } break;
+case 137:
+# line 661 "/usr/src/cmd/mip/cgram.y"
+{  goto bop; } break;
+case 138:
+# line 663 "/usr/src/cmd/mip/cgram.y"
+{  goto preconf; } break;
+case 139:
+# line 665 "/usr/src/cmd/mip/cgram.y"
+{  if( yychar==RELOP||yychar==EQUOP ) goto preconf;  else goto bop; } break;
+case 140:
+# line 667 "/usr/src/cmd/mip/cgram.y"
+{  if(yychar==RELOP||yychar==EQUOP) goto preconf; else goto bop; } break;
+case 141:
+# line 669 "/usr/src/cmd/mip/cgram.y"
+{  if(yychar==RELOP||yychar==EQUOP) goto preconf; else goto bop; } break;
+case 142:
+# line 671 "/usr/src/cmd/mip/cgram.y"
+{  goto bop; } break;
+case 143:
+# line 673 "/usr/src/cmd/mip/cgram.y"
+{  goto bop; } break;
+case 144:
+# line 675 "/usr/src/cmd/mip/cgram.y"
+{  abop:
+                               yyval.nodep = buildtree( ASG yypvt[-2].intval, yypvt[-3].nodep, yypvt[-0].nodep );
+                               } break;
+case 145:
+# line 679 "/usr/src/cmd/mip/cgram.y"
+{  goto abop; } break;
+case 146:
+# line 681 "/usr/src/cmd/mip/cgram.y"
+{  goto abop; } break;
+case 147:
+# line 683 "/usr/src/cmd/mip/cgram.y"
+{  goto abop; } break;
+case 148:
+# line 685 "/usr/src/cmd/mip/cgram.y"
+{  goto abop; } break;
+case 149:
+# line 687 "/usr/src/cmd/mip/cgram.y"
+{  goto abop; } break;
+case 150:
+# line 689 "/usr/src/cmd/mip/cgram.y"
+{  goto abop; } break;
+case 151:
+# line 691 "/usr/src/cmd/mip/cgram.y"
+{  goto abop; } break;
+case 152:
+# line 693 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep=buildtree(QUEST, yypvt[-4].nodep, buildtree( COLON, yypvt[-2].nodep, yypvt[-0].nodep ) );
+                           } break;
+case 153:
+# line 696 "/usr/src/cmd/mip/cgram.y"
+{  werror( "old-fashioned assignment operator" );  goto bop; } break;
+case 154:
+# line 698 "/usr/src/cmd/mip/cgram.y"
+{  goto bop; } break;
+case 156:
+# line 702 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep = buildtree( yypvt[-0].intval, yypvt[-1].nodep, bcon(1) ); } break;
+case 157:
+# line 704 "/usr/src/cmd/mip/cgram.y"
+{ ubop:
+                           yyval.nodep = buildtree( UNARY yypvt[-1].intval, yypvt[-0].nodep, NIL );
+                           } break;
+case 158:
+# line 708 "/usr/src/cmd/mip/cgram.y"
+{  if( ISFTN(yypvt[-0].nodep->type) || ISARY(yypvt[-0].nodep->type) ){
+                               werror( "& before array or function: ignored" );
+                               yyval.nodep = yypvt[-0].nodep;
+                               }
+                           else goto ubop;
+                           } break;
+case 159:
+# line 715 "/usr/src/cmd/mip/cgram.y"
+{  goto ubop; } break;
+case 160:
+# line 717 "/usr/src/cmd/mip/cgram.y"
+{
+                           yyval.nodep = buildtree( yypvt[-1].intval, yypvt[-0].nodep, NIL );
+                           } break;
+case 161:
+# line 721 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep = buildtree( yypvt[-1].intval==INCR ? ASG PLUS : ASG MINUS,
+                                               yypvt[-0].nodep,
+                                               bcon(1)  );
+                           } break;
+case 162:
+# line 726 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep = doszof( yypvt[-0].nodep ); } break;
+case 163:
+# line 728 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep = buildtree( CAST, yypvt[-2].nodep, yypvt[-0].nodep );
+                           yyval.nodep->left->op = FREE;
+                           yyval.nodep->op = FREE;
+                           yyval.nodep = yyval.nodep->right;
+                           } break;
+case 164:
+# line 734 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep = doszof( yypvt[-1].nodep ); } break;
+case 165:
+# line 736 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep = buildtree( UNARY MUL, buildtree( PLUS, yypvt[-3].nodep, yypvt[-1].nodep ), NIL ); } break;
+case 166:
+# line 738 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep=buildtree(UNARY CALL,yypvt[-1].nodep,NIL); } break;
+case 167:
+# line 740 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep=buildtree(CALL,yypvt[-2].nodep,yypvt[-1].nodep); } break;
+case 168:
+# line 742 "/usr/src/cmd/mip/cgram.y"
+{  if( yypvt[-1].intval == DOT ){
+                               yypvt[-2].nodep = buildtree( UNARY AND, yypvt[-2].nodep, NIL );
+                               }
+                           idname = yypvt[-0].intval;
+                           yyval.nodep = buildtree( STREF, yypvt[-2].nodep, buildtree( NAME, NIL, NIL ) );
+                           } break;
+case 169:
+# line 749 "/usr/src/cmd/mip/cgram.y"
+{  idname = yypvt[-0].intval;
+                           /* recognize identifiers in initializations */
+                           if( blevel==0 && stab[idname].stype == UNDEF ) {
+                               register NODE *q;
+                               werror( "undeclared initializer name %.8s", stab[idname].sname );
+                               q = block( FREE, NIL, NIL, INT, 0, INT );
+                               q->rval = idname;
+                               defid( q, EXTERN );
+                               }
+                           yyval.nodep=buildtree(NAME,NIL,NIL);
+                           stab[yypvt[-0].intval].suse = -lineno;
+                       } break;
+case 170:
+# line 762 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep=bcon(0);
+                           yyval.nodep->lval = lastcon;
+                           yyval.nodep->rval = NONAME;
+                           if( yypvt[-0].intval ) yyval.nodep->csiz = yyval.nodep->type = ctype(LONG);
+                           } break;
+case 171:
+# line 768 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep=buildtree(FCON,NIL,NIL);
+                           yyval.nodep->dval = dcon;
+                           } break;
+case 172:
+# line 772 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep = getstr(); /* get string contents */ } break;
+case 173:
+# line 774 "/usr/src/cmd/mip/cgram.y"
+{ yyval.nodep=yypvt[-1].nodep; } break;
+case 174:
+# line 778 "/usr/src/cmd/mip/cgram.y"
+{
+                       yyval.nodep = tymerge( yypvt[-1].nodep, yypvt[-0].nodep );
+                       yyval.nodep->op = NAME;
+                       yypvt[-1].nodep->op = FREE;
+                       } break;
+case 175:
+# line 786 "/usr/src/cmd/mip/cgram.y"
+{ yyval.nodep = bdty( NAME, NIL, -1 ); } break;
+case 176:
+# line 788 "/usr/src/cmd/mip/cgram.y"
+{ yyval.nodep = bdty( UNARY CALL, bdty(NAME,NIL,-1),0); } break;
+case 177:
+# line 790 "/usr/src/cmd/mip/cgram.y"
+{  yyval.nodep = bdty( UNARY CALL, yypvt[-3].nodep, 0 ); } break;
+case 178:
+# line 792 "/usr/src/cmd/mip/cgram.y"
+{  goto umul; } break;
+case 179:
+# line 794 "/usr/src/cmd/mip/cgram.y"
+{  goto uary; } break;
+case 180:
+# line 796 "/usr/src/cmd/mip/cgram.y"
+{  goto bary;  } break;
+case 181:
+# line 798 "/usr/src/cmd/mip/cgram.y"
+{ yyval.nodep = yypvt[-1].nodep; } break;
+case 182:
+# line 802 "/usr/src/cmd/mip/cgram.y"
+{  if( stab[yypvt[-1].intval].stype == UNDEF ){
+                               register NODE *q;
+                               q = block( FREE, NIL, NIL, FTN|INT, 0, INT );
+                               q->rval = yypvt[-1].intval;
+                               defid( q, EXTERN );
+                               }
+                           idname = yypvt[-1].intval;
+                           yyval.nodep=buildtree(NAME,NIL,NIL);
+                           stab[idname].suse = -lineno;
+                       } break;
+               }
+               goto yystack;  /* stack new state and value */
+
+       }
index 94d6348..37ef85c 100644 (file)
@@ -144,6 +144,9 @@ data_def:
                        ={  $1->op = FREE; }
                |  oattributes fdeclarator {
                                defid( tymerge($1,$2), curclass==STATIC?STATIC:EXTDEF );
                        ={  $1->op = FREE; }
                |  oattributes fdeclarator {
                                defid( tymerge($1,$2), curclass==STATIC?STATIC:EXTDEF );
+#ifndef LINT
+                               pfstab(stab[$2->rval].sname);
+#endif
                                }  function_body
                        ={  
                            if( blevel ) cerror( "function level error" );
                                }  function_body
                        ={  
                            if( blevel ) cerror( "function level error" );
@@ -166,6 +169,20 @@ stmt_list:    stmt_list statement
                            }
                ;
 
                            }
                ;
 
+r_dcl_stat_list        :  dcl_stat_list attributes SM
+                       ={  $2->op = FREE; 
+#ifndef LINT
+                           plcstab(blevel);
+#endif
+                           }
+               |  dcl_stat_list attributes init_dcl_list SM
+                       ={  $2->op = FREE; 
+#ifndef LINT
+                           plcstab(blevel);
+#endif
+                           }
+               ;
+
 dcl_stat_list  :  dcl_stat_list attributes SM
                        ={  $2->op = FREE; }
                |  dcl_stat_list attributes init_dcl_list SM
 dcl_stat_list  :  dcl_stat_list attributes SM
                        ={  $2->op = FREE; }
                |  dcl_stat_list attributes init_dcl_list SM
@@ -401,7 +418,25 @@ ibrace             : LC
 
 /*     STATEMENTS      */
 
 
 /*     STATEMENTS      */
 
-compoundstmt:     begin dcl_stat_list stmt_list RC
+compoundstmt:     dcmpstmt
+               |  cmpstmt
+               ;
+
+dcmpstmt:         begin r_dcl_stat_list stmt_list RC
+                       ={  
+#ifndef LINT
+                           prcstab(blevel);
+#endif
+                           --blevel;
+                           if( blevel == 1 ) blevel = 0;
+                           clearst( blevel );
+                           checkst( blevel );
+                           autooff = *--psavbc;
+                           regvar = *--psavbc;
+                           }
+               ;
+
+cmpstmt:          begin stmt_list RC
                        ={  --blevel;
                            if( blevel == 1 ) blevel = 0;
                            clearst( blevel );
                        ={  --blevel;
                            if( blevel == 1 ) blevel = 0;
                            clearst( blevel );
diff --git a/usr/src/cmd/mip/g b/usr/src/cmd/mip/g
deleted file mode 100755 (executable)
index 1f7fa9d..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-grep -n "$1" macdefs code.c local.c mac2defs local2.c order.c table.c
-cd /usr/src/cmd/mip;grep -n "$1" manifest mfile1 cgram.y comm1.c scan.c xdefs.c pftn.c trees.c mfile2 reader.c allo.c match.c  common optim.c
diff --git a/usr/src/cmd/mip/makefile b/usr/src/cmd/mip/makefile
deleted file mode 100644 (file)
index f33460b..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-INSTALL=./ccom
-M=/usr/src/cmd/mip
-CFLAGS=-O
-head:  comp ;
-
-all cp cmp:
-       @echo "This makefile is just a prototype for a portable"
-       @echo "C compiler-- it isn't used for an existing command"
-
-comp: cgram.o xdefs.o scan.o pftn.o trees.o optim.o code.o local.o reader.o local2.o order.o match.o allo.o comm1.o table.o
-       cc $(CFLAGS) -i cgram.o xdefs.o scan.o pftn.o trees.o optim.o code.o local.o  reader.o local2.o order.o match.o allo.o comm1.o table.o
-       mv a.out comp
-trees.o: $M/manifest macdefs $M/mfile1 $M/trees.c
-       cc -c $(CFLAGS) -I$M -I. $M/trees.c
-optim.o: $M/manifest macdefs $M/mfile1 $M/optim.c
-       cc -c $(CFLAGS) -I$M -I. $M/optim.c
-pftn.o: $M/manifest macdefs $M/mfile1 $M/pftn.c
-       cc -c $(CFLAGS) -I$M -I. $M/pftn.c
-code.o: $M/manifest macdefs $M/mfile1
-       cc -c $(CFLAGS) -I$M -I. code.c
-local.o: $M/manifest macdefs $M/mfile1
-       cc -c $(CFLAGS) -I$M -I. local.c
-scan.o: $M/manifest macdefs $M/mfile1 $M/scan.c
-       cc -c $(CFLAGS) -I$M -I. $M/scan.c
-xdefs.o: $M/manifest $M/mfile1 macdefs $M/xdefs.c
-       cc -c $(CFLAGS) -I$M -I. $M/xdefs.c
-cgram.o: $M/manifest $M/mfile1 macdefs $M/cgram.c
-       cc -c $(CFLAGS) -I$M -I. $M/cgram.c
-$M/cgram.c: $M/cgram.y
-       yacc $M/cgram.y
-       mv y.tab.c $M/cgram.c
-comm1.o: $M/manifest $M/mfile1 $M/common macdefs $M/comm1.c
-       cc -c $(CFLAGS) -I. -I$M $M/comm1.c
-table.o: $M/manifest $M/mfile2 mac2defs macdefs table.c
-       cc -c $(CFLAGS) -I$M -I. table.c
-reader.o: $M/manifest $M/mfile2 mac2defs macdefs $M/reader.c
-       cc -c $(CFLAGS) -I$M -I. $M/reader.c
-local2.o: $M/manifest $M/mfile2 mac2defs macdefs
-       cc -c $(CFLAGS) -I$M -I. local2.c
-order.o: $M/manifest $M/mfile2 mac2defs macdefs
-       cc -c $(CFLAGS) -I$M -I. order.c
-match.o: $M/manifest $M/mfile2 mac2defs macdefs $M/match.c
-       cc -c $(CFLAGS) -I$M -I. $M/match.c
-allo.o: $M/manifest $M/mfile2 mac2defs macdefs $M/allo.c
-       cc -c $(CFLAGS) -I$M -I. $M/allo.c
-shrink:
-       rm *.o comp
-lintall:
-       lint -hpv -I. -I$M  $M/cgram.c $M/xdefs.c $M/scan.c $M/pftn.c $M/trees.c $M/optim.c code.c local.c $M/reader.c local2.c order.c $M/match.c $M/allo.c $M/comm1.c table.c
-fort: comp fort.o freader.o fallo.o fmatch.o ftable.o forder.o flocal2.o fcomm2.o
-       cc -i $(CFLAGS) fort.o freader.o fallo.o fmatch.o ftable.o forder.o flocal2.o fcomm2.o
-       mv a.out fort
-fort.o: fort.h $M/fort.c
-       cc -c $(CFLAGS) -I$M -I. $M/fort.c
-freader.o: reader.o
-       cc -c $(CFLAGS) -I$M -I. $M/freader.c
-fallo.o: allo.o
-       cc -c $(CFLAGS) -I$M -I. $M/fallo.c
-fmatch.o: match.o
-       cc -c $(CFLAGS) -I$M -I. $M/fmatch.c
-ftable.o: table.o
-       cc -c $(CFLAGS) -I$M -I. $M/ftable.c
-forder.o: order.o
-       cc -c $(CFLAGS) -I$M -I. $M/forder.c
-flocal2.o: local2.o
-       cc -c $(CFLAGS) -I$M -I. $M/flocal2.c
-fcomm2.o: $M/common
-       cc -c $(CFLAGS) -I$M -I. $M/fcomm2.c
-fort.o freader.o fallo.o fmatch.o ftable.o forder.o flocal2.o fcomm2.o: $M/mfile2 $M/manifest macdefs mac2defs
-install:
-       cp comp $(INSTALL)
index 7711a29..ecc14a2 100644 (file)
 # define BCSZ 100 /* size of the table to save break and continue labels */
 # define SYMTSZ 450 /* size of the symbol table */
 # define DIMTABSZ 750 /* size of the dimension/size table */
 # define BCSZ 100 /* size of the table to save break and continue labels */
 # define SYMTSZ 450 /* size of the symbol table */
 # define DIMTABSZ 750 /* size of the dimension/size table */
-# define PARAMSZ 150 /* size of the parameter stack */
+# define PARAMSZ 100 /* size of the parameter stack */
 # ifndef FORT
 # define TREESZ 350 /* space for building parse tree */
 # else
 # ifndef FORT
 # define TREESZ 350 /* space for building parse tree */
 # else
index 701bce0..53e8460 100644 (file)
@@ -17,7 +17,7 @@ static int mamask[] = { /* masks for matching dope with shapes */
        LTYPE,          /* OPLEAF */
        TYFLG,          /* ASG OPLEAF is senseless */
        0,              /* OPANY */
        LTYPE,          /* OPLEAF */
        TYFLG,          /* ASG OPLEAF is senseless */
        0,              /* OPANY */
-       ASGOPFLG|ASGFLG,        /* ASG OPANY */
+       ASGOPFLG|ASGFLG,        /* ASG OPANY */
        LOGFLG,         /* OPLOG */
        TYFLG,          /* ASG OPLOG is senseless */
        FLOFLG,         /* OPFLOAT */
        LOGFLG,         /* OPLOG */
        TYFLG,          /* ASG OPLOG is senseless */
        FLOFLG,         /* OPFLOAT */
@@ -48,10 +48,18 @@ tshape( p, shape ) NODE *p; {
                case SZERO:
                case SONE:
                case SMONE:
                case SZERO:
                case SONE:
                case SMONE:
+               case SSCON:
+               case SCCON:
                        if( o != ICON || p->name[0] ) return(0);
                        if( p->lval == 0 && shape == SZERO ) return(1);
                        else if( p->lval == 1 && shape == SONE ) return(1);
                        else if( p->lval == -1 && shape == SMONE ) return(1);
                        if( o != ICON || p->name[0] ) return(0);
                        if( p->lval == 0 && shape == SZERO ) return(1);
                        else if( p->lval == 1 && shape == SONE ) return(1);
                        else if( p->lval == -1 && shape == SMONE ) return(1);
+                       else if( p->lval > -257 && p->lval < 256 && shape == SCCON ) return(1);
+                       else if( p->lval > -32769 && p->lval < 32768 && shape == SSCON ) return(1);
+                       else return(0);
+
+               case SSOREG:    /* non-indexed OREG */
+                       if( o == OREG && !R2TEST(p->rval) ) return(1);
                        else return(0);
 
                default:
                        else return(0);
 
                default:
@@ -208,7 +216,7 @@ setrew(){
                                                if( i==NAME || i==ICON || i==OREG ) break;
                                                else if( shltype( i, NIL ) ) break;
                                                }
                                                if( i==NAME || i==ICON || i==OREG ) break;
                                                else if( shltype( i, NIL ) ) break;
                                                }
-                                       else if( (dope[i]&(opmtemp|ASGFLG)) == opmtemp ) break;
+                                       else if( (dope[i]&(opmtemp|ASGFLG)) == opmtemp ) break;
                                        }
                                }
                        opptr[i] = q;
                                        }
                                }
                        opptr[i] = q;
@@ -242,7 +250,7 @@ match( p, cookie ) NODE *p; {
                                if( p->op!=NAME && p->op!=ICON && p->op!= OREG &&
                                        ! shltype( p->op, p ) ) continue;
                                }
                                if( p->op!=NAME && p->op!=ICON && p->op!= OREG &&
                                        ! shltype( p->op, p ) ) continue;
                                }
-                       else if( (dope[p->op]&(opmtemp|ASGFLG)) != opmtemp ) continue;
+                       else if( (dope[p->op]&(opmtemp|ASGFLG)) != opmtemp ) continue;
                        }
 
                if( !(q->visit & cookie ) ) continue;
                        }
 
                if( !(q->visit & cookie ) ) continue;
@@ -270,15 +278,11 @@ match( p, cookie ) NODE *p; {
        return(MNOPE);
        }
 
        return(MNOPE);
        }
 
-int rtyflg = 0;
-
 expand( p, cookie, cp ) NODE *p;  register char *cp; {
        /* generate code by interpreting table entry */
 
        CONSZ val;
 
 expand( p, cookie, cp ) NODE *p;  register char *cp; {
        /* generate code by interpreting table entry */
 
        CONSZ val;
 
-       rtyflg = 0;
-
        for( ; *cp; ++cp ){
                switch( *cp ){
 
        for( ; *cp; ++cp ){
                switch( *cp ){
 
@@ -286,11 +290,6 @@ expand( p, cookie, cp ) NODE *p;  register char *cp; {
                        PUTCHAR( *cp );
                        continue;  /* this is the usual case... */
 
                        PUTCHAR( *cp );
                        continue;  /* this is the usual case... */
 
-               case 'T':
-                       /* rewrite register type is suppressed */
-                       rtyflg = 1;
-                       continue;
-
                case 'Z':  /* special machine dependent operations */
                        zzzcode( p, *++cp );
                        continue;
                case 'Z':  /* special machine dependent operations */
                        zzzcode( p, *++cp );
                        continue;
@@ -300,15 +299,15 @@ expand( p, cookie, cp ) NODE *p;  register char *cp; {
                        continue;
 
                case 'S':  /* field size */
                        continue;
 
                case 'S':  /* field size */
-                       printf( "%d", fldsz );
+                       printf( "$%d", fldsz );
                        continue;
 
                case 'H':  /* field shift */
                        continue;
 
                case 'H':  /* field shift */
-                       printf( "%d", fldshf );
+                       printf( "$%d", fldshf );
                        continue;
 
                case 'M':  /* field mask */
                        continue;
 
                case 'M':  /* field mask */
-               case 'N':  /* complement of field mask */
+               case 'N':       /* complement of field mask */
                        val = 1;
                        val <<= fldsz;
                        --val;
                        val = 1;
                        val <<= fldsz;
                        --val;
index 141a46f..e3cf21d 100644 (file)
@@ -43,6 +43,7 @@ extern char *scnames();
 # define SSET 010
 # define SREF 020
 
 # define SSET 010
 # define SREF 020
 
+# define FIXDEF(p) outstab(p)
 # ifndef FIXDEF
 # define FIXDEF(p)
 #endif
 # ifndef FIXDEF
 # define FIXDEF(p)
 #endif
@@ -127,6 +128,7 @@ extern CONSZ lastcon;
 extern double dcon;
 
 extern char ftitle[];
 extern double dcon;
 
 extern char ftitle[];
+extern char ititle[];
 extern struct symtab stab[];
 extern int curftn;
 extern int curclass;
 extern struct symtab stab[];
 extern int curftn;
 extern int curclass;
index d7884eb..06fa74d 100644 (file)
@@ -12,8 +12,8 @@
 # define deflab def2lab
 # define edebug e2debug
 # define eprint e2print
 # define deflab def2lab
 # define edebug e2debug
 # define eprint e2print
-# define getlab get2lab
 # define filename ftitle
 # define filename ftitle
+# define getlab get2lab
 # endif
 
 /*     cookies, used as arguments to codgen */
 # endif
 
 /*     cookies, used as arguments to codgen */
@@ -67,6 +67,9 @@
 # define SZERO SPECIAL
 # define SONE (SPECIAL|1)
 # define SMONE (SPECIAL|2)
 # define SZERO SPECIAL
 # define SONE (SPECIAL|1)
 # define SMONE (SPECIAL|2)
+# define SCCON (SPECIAL|3)     /* -256 <= constant < 256 */
+# define SSCON (SPECIAL|4)     /* -32768 <= constant < 32768 */
+# define SSOREG (SPECIAL|5)    /* non-indexed OREG */
 
        /* FORARG and INTEMP are carefully not conflicting with shapes */
 
 
        /* FORARG and INTEMP are carefully not conflicting with shapes */
 
@@ -208,7 +211,6 @@ extern OFFSZ baseoff;
 extern OFFSZ maxtemp;
 extern int maxtreg;
 extern int ftnno;
 extern OFFSZ maxtemp;
 extern int maxtreg;
 extern int ftnno;
-extern int rtyflg;
 
 extern int nrecur;  /* flag to keep track of recursions */
 
 
 extern int nrecur;  /* flag to keep track of recursions */
 
@@ -240,7 +242,8 @@ extern int lflag, xdebug, udebug, edebug, odebug, rdebug, radebug, tdebug, sdebu
 #endif
 
        /* macros for doing double indexing */
 #endif
 
        /* macros for doing double indexing */
-# define R2PACK(x,y) (0200*((x)+1)+y)
-# define R2UPK1(x) (((x)>>7)-1)
+# define R2PACK(x,y,z) (0200*((x)+1)+y+040000*z)
+# define R2UPK1(x) ((((x)>>7)-1)&0177)
 # define R2UPK2(x) ((x)&0177)
 # define R2UPK2(x) ((x)&0177)
+# define R2UPK3(x) (x>>14)
 # define R2TEST(x) ((x)>=0200)
 # define R2TEST(x) ((x)>=0200)
index 0a2dbc7..fbb9f2d 100644 (file)
@@ -1,4 +1,5 @@
 # include "mfile1"
 # include "mfile1"
+# include <a.out.h>
 
 struct instk {
        int in_sz;   /* size of array element */
 
 struct instk {
        int in_sz;   /* size of array element */
@@ -21,6 +22,7 @@ struct symtab *relook();
 
 
 int ddebug = 0;
 
 
 int ddebug = 0;
+int gdebug;
 
 defid( q, class )  NODE *q; {
        register struct symtab *p;
 
 defid( q, class )  NODE *q; {
        register struct symtab *p;
@@ -300,7 +302,9 @@ defid( q, class )  NODE *q; {
 
        /* user-supplied routine to fix up new definitions */
 
 
        /* user-supplied routine to fix up new definitions */
 
+#ifndef LINT
        FIXDEF(p);
        FIXDEF(p);
+#endif
 
        if( ddebug ) printf( "  dimoff, sizoff, offset: %d, %d, %d\n", p->dimoff, p->sizoff, p->offset );
 
 
        if( ddebug ) printf( "  dimoff, sizoff, offset: %d, %d, %d\n", p->dimoff, p->sizoff, p->offset );
 
@@ -351,6 +355,11 @@ dclargs(){
                        q->rval = j;
                        defid( q, PARAM );
                        }
                        q->rval = j;
                        defid( q, PARAM );
                        }
+#ifndef LINT
+               pstab(p->sname, N_PSYM);
+               if (gdebug) printf("0,%d,%d\n", p->stype, argoff/SZCHAR);
+               poffs(N_RSYM, p);
+#endif
                oalloc( p, &argoff );  /* always set aside space, even for register arguments */
                }
        cendarg();
                oalloc( p, &argoff );  /* always set aside space, even for register arguments */
                }
        cendarg();
index c1dec2f..eab921d 100644 (file)
@@ -312,6 +312,11 @@ delay2( p ) register NODE *p; {
                /* inside of a call */
                return;
 
                /* inside of a call */
                return;
 
+       case UNARY MUL:
+               /* if *p++, do not rewrite */
+               if( autoincr( p ) ) return;
+               break;
+
        case INCR:
        case DECR:
                if( deltest( p ) ){
        case INCR:
        case DECR:
                if( deltest( p ) ){
@@ -586,6 +591,8 @@ order(p,cook) NODE *p; {
                        return;
                        }
                offstar( p->left );
                        return;
                        }
                offstar( p->left );
+               canon(p);
+               if( canaddr(p) && cook != INTEMP ) goto cleanup;
                goto again;
 
        case INCR:  /* INCR and DECR */
                goto again;
 
        case INCR:  /* INCR and DECR */
@@ -1175,39 +1182,16 @@ oreg2( p ) register NODE *p; {
 
                /* look for doubly indexed expressions */
 
 
                /* look for doubly indexed expressions */
 
-               if( q->op==PLUS && qr->op==REG && ql->op==REG &&
-                               (szty(ql->type)==1||szty(qr->type)==1) ) {
-                       temp = 0;
-                       cp = ql->name;
-                       if( *cp ){
-                               if( *qr->name ) return;
-                               }
-                       else {
-                               cp = qr->name;
+               if( q->op == PLUS) {
+                       if( (r=base(ql))>=0 && (i=offset(qr, tlen(p)))>=0) {
+                               makeor2(p, ql, r, i);
+                               return;
+                       } else if( (r=base(qr))>=0 && (i=offset(ql, tlen(p)))>=0) {
+                               makeor2(p, qr, r, i);
+                               return;
                                }
                                }
-                       if( szty(qr->type)>1) r = R2PACK(qr->rval,ql->rval);
-                       else r = R2PACK(ql->rval,qr->rval);
-                       goto ormake;
                        }
 
                        }
 
-               if( (q->op==PLUS||q->op==MINUS) && qr->op==ICON && ql->op==PLUS &&
-                               ql->left->op==REG &&
-                               ql->right->op==REG ){
-                       temp = qr->lval;
-                       cp = qr->name;
-                       if( q->op == MINUS ){
-                               if( *cp ) return;
-                               temp = -temp;
-                               }
-                       if( *cp ){
-                               if( *ql->name ) return;
-                               }
-                       else {
-                               cp = ql->name;
-                               }
-                       r = R2PACK(ql->left->rval,ql->right->rval);
-                       goto ormake;
-                       }
 
 #endif
 
 
 #endif
 
index 9d51ffd..d174c87 100644 (file)
@@ -1,4 +1,5 @@
 # include "mfile1"
 # include "mfile1"
+#include <a.out.h>
 # include <ctype.h>
        /* temporarily */
 
 # include <ctype.h>
        /* temporarily */
 
 char yytext[LXTSZ];
 char * lxgcp;
 
 char yytext[LXTSZ];
 char * lxgcp;
 
+int proflg;
+int gdebug;
+#ifndef LINT
+extern int lastloc;
+#endif
 
        /* ARGSUSED */
 mainp1( argc, argv ) int argc; char *argv[]; {  /* control multiple files */
 
        register i;
        register char *cp;
 
        /* ARGSUSED */
 mainp1( argc, argv ) int argc; char *argv[]; {  /* control multiple files */
 
        register i;
        register char *cp;
-       extern int idebug, bdebug, tdebug, edebug, ddebug, xdebug;
+       extern int idebug, bdebug, tdebug, edebug, ddebug, xdebug, gdebug;
+       int fdef = 0;
 
        for( i=1; i<argc; ++i ){
                if( *(cp=argv[i]) == '-' && *++cp == 'X' ){
 
        for( i=1; i<argc; ++i ){
                if( *(cp=argv[i]) == '-' && *++cp == 'X' ){
@@ -79,9 +86,29 @@ mainp1( argc, argv ) int argc; char *argv[]; {  /* control multiple files */
                                case 'x':
                                        ++xdebug;
                                        break;
                                case 'x':
                                        ++xdebug;
                                        break;
+                               case 'P':       /* profiling */
+                                       ++proflg;
+                                       break;
+                               case 'g':
+                                       ++gdebug;
+                                       break;
                                        }
                                }
                        }
                                        }
                                }
                        }
+                       else {
+                       if( *(argv[i]) != '-' ) switch( fdef++ ) {
+                               case 0:
+                               case 1:
+                                       if( freopen(argv[i], fdef==1 ? "r" : "w", fdef==1 ? stdin : stdout) == NULL) {
+                                               fprintf(stderr, "ccom:can't open %s\n", argv[i]);
+                                               exit(1);
+                                       }
+                                       break;
+
+                               default:
+                                       ;
+                               }
+                       }
                }
 
 # ifdef ONEPASS
                }
 
 # ifdef ONEPASS
@@ -907,15 +934,25 @@ lxres() {
        return( -1 );
        }
 
        return( -1 );
        }
 
+int    labelno;
+
 lxtitle(){
        /* called after a newline; set linenumber and file name */
 
        register c, val;
 lxtitle(){
        /* called after a newline; set linenumber and file name */
 
        register c, val;
-       register char *cp;
+       register char *cp, *cq;
 
        for(;;){  /* might be several such lines in a row */
                if( (c=getchar()) != '#' ){
                        if( c != EOF ) ungetc(c,stdin);
 
        for(;;){  /* might be several such lines in a row */
                if( (c=getchar()) != '#' ){
                        if( c != EOF ) ungetc(c,stdin);
+#ifndef LINT
+                       if ( lastloc != PROG) return;
+                       cp = ftitle;
+                       cq = ititle;
+                       while ( *cp ) if (*cp++ != *cq++) return;
+                       if ( *cq ) return;
+                       psline();
+#endif
                        return;
                        }
 
                        return;
                        }
 
@@ -932,6 +969,22 @@ lxtitle(){
                                *cp = c;
                                }
                        *cp = '\0';
                                *cp = c;
                                }
                        *cp = '\0';
+#ifndef LINT
+                       if (ititle[0] == '\0') {
+                               cp = ftitle;
+                               cq = ititle;
+                               while ( *cp )  
+                                       *cq++ = *cp++;
+                               *cq = '\0';
+                               *--cq = '\0';
+                               for ( cp = ititle+1; *(cp-1); cp += 8 ) {
+                                       pstab(cp, N_SO);
+                                       if (gdebug) printf("0,0,LL%d\n", labelno);
+                                       }
+                               *cq = '"';
+                               printf("LL%d:\n", labelno++);
+                               }
+#endif
                        }
                }
        }
                        }
                }
        }
index 61caff7..a47172c 100644 (file)
@@ -3,6 +3,7 @@
 /*     communication between lexical routines  */
 
 char   ftitle[100] = "";       /* title of the file */
 /*     communication between lexical routines  */
 
 char   ftitle[100] = "";       /* title of the file */
+char   ititle[100] = "";       /* title of initial file */
 int    lineno;         /* line number of the input file */
 
 CONSZ lastcon;  /* the last constant read by the lexical analyzer */
 int    lineno;         /* line number of the input file */
 
 CONSZ lastcon;  /* the last constant read by the lexical analyzer */
diff --git a/usr/src/cmd/mtm.c b/usr/src/cmd/mtm.c
new file mode 100644 (file)
index 0000000..3697bb9
--- /dev/null
@@ -0,0 +1,146 @@
+#include <signal.h>
+/* Magnetic Tape Manipulation Program
+** mtm [-sn] [-lm] [-bp] [unit]
+**
+** skip n files
+** list m files
+** buffer size pK bytes
+** on unit 
+**
+** Assumes definition of raw magnetic tapes and the 
+** mapping of 4-7 into physical drives 0-3
+*/
+char *buf;
+int bcnt;
+int filecnt;
+int fd;
+int unit;
+char *file ;
+
+main(argc,argv)
+int argc;
+char *argv[];
+{
+       char *p;
+       int nskip, nlist, skip, list;
+       int finis();
+
+       signal(SIGINT,finis);
+       signal(SIGQUIT,finis);
+       unit = nskip = nlist = 0;
+       skip = 0;
+       list = 1;
+       bcnt = 2;
+       file = "/dev/rmt0 ";
+       filecnt=1;
+       argv++;
+
+       while(--argc) {
+               p = *argv++;
+               if(*p == '-'){
+                       ++p;
+                       switch(*p){
+
+                       case 's':
+                               skip++;
+                               list--;
+                               nskip = atoi(++p);
+                               break;
+       
+                       case 'l':
+                               list++;
+                               nlist = atoi(++p);
+                               break;
+       
+                       case 'b':
+                               bcnt = atoi(++p);
+                               if(bcnt < 30) break;
+                               printf("Requested buffer too big %dK\n",bcnt);
+                               exit(8);
+                       default:
+                               printf("Bad option\n");
+                               exit(8);
+                       }
+               }
+               else{
+
+                       if((*p < '0') || (*p> '9')){
+                               printf("Syntax Error\n");
+                               exit(8);
+                       }
+                       unit = atoi(p);
+               }
+       }
+
+       bcnt = bcnt<<10;
+       if (((int)(buf = sbrk(bcnt))) < 0) {
+               printf("requested buffer too big - %dK\n",bcnt);
+               exit(8);
+       }
+
+       unit = unit | 04;       /* force to no rewind unit number */
+       sprintf(&file[8],"%d",unit);
+       if((fd = open(file, 0)) < 0) {
+               printf("Tape Open Error %s\n",file);
+               exit(8);
+       }
+
+       if(skip)
+               files(nskip,0);
+       if(list){
+               if(nlist == 0)
+                       nlist = -1;
+               files(nlist,1);
+               finis();
+       }
+}
+
+files(nfiles,lflag)
+int nfiles, lflag;
+{
+       int cnt, prevcnt, reccnt, eof;
+       if(nfiles == 0)return;
+       eof=0;
+       for(; nfiles--; filecnt++){
+               cnt = reccnt = prevcnt = 0;
+               do{
+                       prevcnt = cnt;
+                       if((cnt = read(fd,buf,bcnt)) == 0){     /* EOF */
+                               if(eof){        /* double eof */
+                                       printf("Double EOF after file %d\n",
+                                               --filecnt);
+                                       finis();
+                               }
+                               else{
+                                       eof=1;
+                                       if(lflag)
+                                               printf("      %d Records\n",reccnt);
+                               }
+                       }
+                       else{
+                               eof = 0;
+                               if((++reccnt == 1) && lflag) printf("File %d:\n",filecnt);
+                               if(cnt<0){      /* error */
+                                       if(lflag) printf("      Record %d - ERROR\n",reccnt);
+                               }
+                               else{   /*data read*/
+                                       if(lflag && cnt != prevcnt)
+                                               printf("      Record %d - %d bytes\n",
+                                                       reccnt,cnt);
+                               }
+                       }
+               }while(eof==0);
+       }
+}
+
+
+finis()
+{
+       unit -= 4;
+       sprintf(&file[8],"%d",unit);
+       close(fd);
+       fd = open(file, 0);
+       close(fd);
+       printf("DONE\n");
+       exit(0);
+}
diff --git a/usr/src/cmd/mvall.c b/usr/src/cmd/mvall.c
new file mode 100644 (file)
index 0000000..24e6c8f
--- /dev/null
@@ -0,0 +1,64 @@
+# include <sys/param.h>
+# include <stat.h>
+int    status;
+
+main(argc, argv)
+int argc;
+char **argv;
+{
+register i;
+register char *c1, *c2;
+char dirname[100];
+
+if(argc < 3)
+       {
+       prs("arg count\n");
+       exit(1);
+       }
+argc--;
+c1 = dirname;
+c2 = argv[argc];
+while(*c1++ = *c2++);
+c1[-1] = '/';
+c1[0] = '.';
+c1[1] = '\0';
+if(filetype(dirname) !=  S_IFDIR)
+       {
+       prs(dirname);
+       prs(" is not a directory.\n");
+       exit(1);
+       }
+
+for(i=1; i<argc; i++) 
+       {
+       if(filetype(argv[i]) != S_IFREG)
+               {
+               prs(argv[i]);
+               prs(" is not an ordinary file.\n");
+               }
+       else if(fork() == 0)
+               {
+               execl("/bin/mv", "mv", argv[i], dirname,0);
+               exit(1);
+               }
+       else wait(&status);
+       }
+}
+
+filetype(filename)
+char *filename;
+{
+struct stat buf ;
+
+if(stat(filename,&buf) < 0) 
+       return(-1);
+else return(buf.st_mode&S_IFMT);
+}
+
+
+prs(s)
+register char *s;
+{
+while(*s)
+       write(2, s++, 1);
+}
diff --git a/usr/src/cmd/neqn/Makefile b/usr/src/cmd/neqn/Makefile
new file mode 100644 (file)
index 0000000..19b0b5c
--- /dev/null
@@ -0,0 +1,34 @@
+CFLAGS=-O -DNEQN -d2
+YFLAGS=-d
+
+SOURCE = e.y e.h diacrit.c eqnbox.c font.c fromto.c funny.c glob.c integral.c \
+ io.c lex.c lookup.c mark.c matrix.c move.c over.c paren.c \
+ pile.c shift.c size.c sqrt.c text.c
+
+FILES = e.o diacrit.o eqnbox.o font.o fromto.o funny.o glob.o integral.o \
+ io.o lex.o lookup.o mark.o matrix.o move.o over.o paren.o \
+ pile.o shift.o size.o sqrt.o text.o
+
+neqn:  $(FILES)
+       cc $(CFLAGS) $(FILES) -o neqn
+
+e.c:   e.def
+
+e.def: e.y
+       yacc -d e.y
+       mv y.tab.c e.c
+       mv y.tab.h e.def
+
+$(FILES):      e.h e.def
+install: neqn
+       install -s neqn $(DESTDIR)/usr/bin
+
+clean:
+       rm -f *.o e.c e.def
+
+
+list:
+       pr TODO $(SOURCE) makefile
+
+lint:  y.tab.c
+       lint -spb *.c
diff --git a/usr/src/cmd/neqn/makefile b/usr/src/cmd/neqn/makefile
deleted file mode 100644 (file)
index 1fe54e6..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-CFLAGS=-O -s -DNEQN
-YFLAGS=-d
-
-all:   neqn
-
-cp:    neqn
-       cp neqn /bin/neqn
-       rm *.o e.c e.def neqn
-
-cmp:   neqn
-       cmp neqn /bin/neqn
-       rm *.o e.c e.def neqn
-
-SOURCE = e.y e.h diacrit.c eqnbox.c font.c fromto.c funny.c glob.c integral.c \
- io.c lex.c lookup.c mark.c matrix.c move.c over.c paren.c \
- pile.c shift.c size.c sqrt.c text.c
-
-FILES = e.o diacrit.o eqnbox.o font.o fromto.o funny.o glob.o integral.o \
- io.o lex.o lookup.o mark.o matrix.o move.o over.o paren.o \
- pile.o shift.o size.o sqrt.o text.o
-
-neqn:  $(FILES)
-       cc -n $(CFLAGS) $(FILES) -o neqn
-
-e.c:   e.def
-
-e.def: e.y
-       yacc -d e.y
-       mv y.tab.c e.c
-       mv y.tab.h e.def
-
-$(FILES):      e.h e.def
-
-list:
-       pr TODO $(SOURCE) makefile
-
-gcos:  y.tab.c
-       fsend e.h e.y *.c
-
-src:   makefile $(SOURCE)
-       cp $? /usr/src/cmd/neqn
-       touch src
-
-lint:  y.tab.c
-       lint -spb *.c
index e236f0e..ea20bea 100644 (file)
@@ -6,7 +6,7 @@ sqrt(p2) int p2; {
        printf(".ds %d \\v'%du'\\e\\L'%du'\\l'\\n(%du'",
                p2, ebase[p2], -eht[p2], p2);
        printf("\\v'%du'\\h'-\\n(%du'\\*(%d\n", eht[p2]-ebase[p2], p2, p2);
        printf(".ds %d \\v'%du'\\e\\L'%du'\\l'\\n(%du'",
                p2, ebase[p2], -eht[p2], p2);
        printf("\\v'%du'\\h'-\\n(%du'\\*(%d\n", eht[p2]-ebase[p2], p2, p2);
-       eht[p2] =+ VERT(1);
+       eht[p2] += VERT(1);
        if(dbg)printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n", 
                p2, p2, ebase[p2], eht[p2]);
 }
        if(dbg)printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n", 
                p2, p2, ebase[p2], eht[p2]);
 }
diff --git a/usr/src/cmd/news.sh b/usr/src/cmd/news.sh
new file mode 100755 (executable)
index 0000000..d573c20
--- /dev/null
@@ -0,0 +1,18 @@
+NEWSDIR=/usr/news
+cd $NEWSDIR
+if [ $# = 0 ]
+then
+       echo News catalog :
+       ls -t
+else
+       for i in $*
+       do
+               if [ -f $i ]
+               then
+                       echo  ; echo $i news :
+                       cat $i
+               else 
+                       echo  ; echo \< News item \"$i\" not found \>
+               fi
+       done
+fi
index 2d3ee27..46ea4f8 100644 (file)
@@ -8,9 +8,9 @@
 
 
 #include       <ar.h>
 
 
 #include       <ar.h>
-#include       <a.out.h>
 #include       <stdio.h>
 #include       <ctype.h>
 #include       <stdio.h>
 #include       <ctype.h>
+#include       <a.out.h>
 #define        MAGIC   exp.a_magic
 #define        BADMAG  MAGIC!=A_MAGIC1 && MAGIC!=A_MAGIC2  \
                && MAGIC!=A_MAGIC3 && MAGIC!=A_MAGIC4
 #define        MAGIC   exp.a_magic
 #define        BADMAG  MAGIC!=A_MAGIC1 && MAGIC!=A_MAGIC2  \
                && MAGIC!=A_MAGIC3 && MAGIC!=A_MAGIC4
@@ -103,9 +103,7 @@ char **argv;
                        fread((char *)&exp, 1, sizeof(struct exec), fi);
                        if (BADMAG)             /* archive element not in  */
                                continue;       /* proper format - skip it */
                        fread((char *)&exp, 1, sizeof(struct exec), fi);
                        if (BADMAG)             /* archive element not in  */
                                continue;       /* proper format - skip it */
-                       o = (long)exp.a_text + exp.a_data;
-                       if ((exp.a_flag & 01) == 0)
-                               o *= 2;
+                       o = (long)exp.a_text + exp.a_data + exp.a_trsize + exp.a_drsize;
                        fseek(fi, o, 1);
                        n = exp.a_syms / sizeof(struct nlist);
                        if (n == 0) {
                        fseek(fi, o, 1);
                        n = exp.a_syms / sizeof(struct nlist);
                        if (n == 0) {
@@ -117,15 +115,46 @@ char **argv;
                                fread((char *)&sym, 1, sizeof(sym), fi);
                                if (globl_flg && (sym.n_type&N_EXT)==0)
                                        continue;
                                fread((char *)&sym, 1, sizeof(sym), fi);
                                if (globl_flg && (sym.n_type&N_EXT)==0)
                                        continue;
-                               switch (sym.n_type&N_TYPE) {
+                               if (symp==NULL)
+                                       symp = (struct nlist *)malloc(sizeof(struct nlist));
+                               else {
+                                       symp = (struct nlist *)realloc(symp, (i+1)*sizeof(struct nlist));
+                               }
+                               if (symp == NULL) {
+                                       fprintf(stderr, "nm: out of memory on %s\n", *argv);
+                                       exit(2);
+                               }
+                               symp[i++] = sym;
+                       }
+                       if (nosort_flg==0)
+                               qsort(symp, i, sizeof(struct nlist), compare);
+                       if ((arch_flg || narg>1) && prep_flg==0)
+                               printf("\n%s:\n", SELECT);
+                       for (n=0; n<i; n++) {
+                               if (prep_flg) {
+                                       if (arch_flg)
+                                               printf("%s:", *argv);
+                                       printf("%s:", SELECT);
+                               }
+                               c = symp[n].n_type;
+                               
+                               if (c & STABTYPE) {
+                                       printf("%08x - %-8.8s %02x %02x %04x\n",
+                                               symp[n].n_value,
+                                               symp[n].n_name,
+                                               symp[n].n_type & 0xff,
+                                               symp[n].n_other & 0xff,
+                                               symp[n].n_desc & 0xffff);
+                                       continue;
+                               }
+                               switch (c&(N_TYPE-N_EXT)) {
 
                                case N_UNDF:
                                        c = 'u';
 
                                case N_UNDF:
                                        c = 'u';
-                                       if (sym.n_value)
+                                       if (symp[n].n_value)
                                                c = 'c';
                                        break;
 
                                                c = 'c';
                                        break;
 
-                               default:
                                case N_ABS:
                                        c = 'a';
                                        break;
                                case N_ABS:
                                        c = 'a';
                                        break;
@@ -146,46 +175,25 @@ char **argv;
                                        c = 'f';
                                        break;
 
                                        c = 'f';
                                        break;
 
+/*
                                case N_REG:
                                        c = 'r';
                                        break;
                                case N_REG:
                                        c = 'r';
                                        break;
+ */
                                }
                                if (undef_flg && c!='u')
                                        continue;
                                }
                                if (undef_flg && c!='u')
                                        continue;
-                               if (sym.n_type&N_EXT)
+                               if (symp[n].n_type&N_EXT)
                                        c = toupper(c);
                                        c = toupper(c);
-                               sym.n_type = c;
-                               if (symp==NULL)
-                                       symp = (struct nlist *)malloc(sizeof(struct nlist));
-                               else {
-                                       symp = (struct nlist *)realloc(symp, (i+1)*sizeof(struct nlist));
-                               }
-                               if (symp == NULL) {
-                                       fprintf(stderr, "nm: out of memory on %s\n", *argv);
-                                       exit(2);
-                               }
-                               symp[i++] = sym;
-                       }
-                       if (nosort_flg==0)
-                               qsort(symp, i, sizeof(struct nlist), compare);
-                       if ((arch_flg || narg>1) && prep_flg==0)
-                               printf("\n%s:\n", SELECT);
-                       for (n=0; n<i; n++) {
-                               if (prep_flg) {
-                                       if (arch_flg)
-                                               printf("%s:", *argv);
-                                       printf("%s:", SELECT);
-                               }
-                               c = symp[n].n_type;
                                if (!undef_flg) {
                                        if (c=='u' || c=='U')
                                if (!undef_flg) {
                                        if (c=='u' || c=='U')
-                                               printf("      ");
+                                               printf("        ");
                                        else
                                                printf(FORMAT, symp[n].n_value);
                                        printf(" %c ", c);
                                }
                                printf("%.8s\n", symp[n].n_name);
                                        else
                                                printf(FORMAT, symp[n].n_value);
                                        printf(" %c ", c);
                                }
                                printf("%.8s\n", symp[n].n_name);
-                       }
+               l1:;    }
                        if (symp)
                                free((char *)symp);
                } while(arch_flg && nextel(fi));
                        if (symp)
                                free((char *)symp);
                } while(arch_flg && nextel(fi));
diff --git a/usr/src/cmd/nohup.sh b/usr/src/cmd/nohup.sh
new file mode 100755 (executable)
index 0000000..6b590e9
--- /dev/null
@@ -0,0 +1,7 @@
+trap "" 1 15
+if test -t 2>&1  ; then
+       echo "Sending output to 'nohup.out'"
+       exec nice -5 $* >>nohup.out 2>&1
+else
+       exec nice -5 $* 2>&1
+fi
diff --git a/usr/src/cmd/number.c b/usr/src/cmd/number.c
new file mode 100644 (file)
index 0000000..9b4d451
--- /dev/null
@@ -0,0 +1,199 @@
+int    flag;
+int max = 21;
+char   *card[] =
+{
+       "hundred",
+       "thousand",
+       "million",
+       "billion",
+       "trillion",
+       "quadrillion",
+       "quintillion",
+       "sextillion",
+       "septillion",
+       "octillion",
+       "nonillion",
+       "decillion",
+       "undecillion",
+       "duodecillion",
+       "tredecillion",
+       "quattuordecillion",
+       "quindecillion",
+       "sexdecillion",
+       "septendecillion",
+       "octodecillion",
+       "novemdecillion",
+       "vigintillion"
+};
+char *unit[] = {
+       "zero",
+       "one",
+       "two",
+       "three",
+       "four",
+       "five",
+       "six",
+       "seven",
+       "eight",
+       "nine"
+};
+char *teen[] = {
+       "ten",
+       "eleven",
+       "twelve",
+       "thirteen",
+       "fourteen",
+       "fifteen",
+       "sixteen",
+       "seventeen",
+       "eighteen",
+       "nineteen"
+};
+char *decade[] = {
+       "zero",
+       "ten",
+       "twenty",
+       "thirty",
+       "forty",
+       "fifty",
+       "sixty",
+       "seventy",
+       "eighty",
+       "ninety"
+};
+char   line[100];
+main()
+{
+       register c, i, fraction;
+       int r;
+
+
+       fraction = 0;
+       while(c = getchar()) {
+               if(!digit(c))  {
+                       fraction = (c == '.');
+                       putchar(c);
+                       continue;
+               }
+               if(fraction) {
+                       while(digit(c)) {
+                               putchar(' ');
+                               putchar(c);
+                               if(!(c=getchar()))
+                                       exit(1);
+                       }
+                       putchar(' ');
+                       goto out;
+               }
+
+               putchar(' ');
+               i = 0;
+               line[i++] = '0';
+               line[i++] = '0';
+               while(c == '0')
+                       if(!(c=getchar()))
+                               exit(1);
+               while(digit(c)) {
+                       if(i < 98)
+                               line[i++] = c;
+                       if(!(c=getchar()))
+                               exit(1);
+               }
+               line[i] = 0;
+               r = i/3;
+               if(r == 0) {
+                       print("zero");
+                       goto out;
+               }
+               conv(line+i-3*r, r);
+
+out:
+               fraction = (c == '.');
+               nline();
+               printf("...\n");
+               if(c != '\n')
+                       putchar(c);
+       }
+}
+
+conv(p, c)
+char *p;
+{
+
+       if(c > max) {
+               conv(p, c-max);
+               print(card[max]);
+               nline();
+               p += (c-max)*3;
+               c = max;
+       }
+       while(c > 1) {
+               c--;
+               conv(p, 1);
+               cprint(card[c]);
+               nline();
+               p += 3;
+       }
+       ones(p[0]);
+       cprint(card[0]);
+       tens(p);
+       ones(p[2]);
+}
+
+ones(d)
+{
+       if(d=='0')
+               return;
+       print(unit[d-'0']);
+}
+
+tens(p)
+char *p;
+{
+
+       switch(p[1]) {
+
+       case '0':
+               return;
+
+       case '1':
+               print(teen[p[2]-'0']);
+               p[2] = '0';
+               return;
+       }
+
+       print(decade[p[1]-'0']);
+}
+
+
+digit(c)
+{
+
+       if(c < '0' || c > '9')
+               return(0);
+       return(1);
+}
+
+nline()
+{
+
+       if(flag)
+               printf(".\n");
+       flag = 0;
+}
+
+cprint(s)
+{
+
+       if(flag)
+               print(s);
+}
+
+print(s)
+{
+
+       if(flag)
+               printf(" ");
+       printf(s);
+       flag = 1;
+}
diff --git a/usr/src/cmd/opr.c b/usr/src/cmd/opr.c
new file mode 100644 (file)
index 0000000..a57107a
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ *     opr -- off line print dispatcher
+ *             chooses spooling routine appropriate 
+ *             to destination
+ *
+ *     last entry in table isdefault
+ */
+
+char *code[] = {
+       "-sp",  "/usr/lib/npr", /* spider network printer */
+       "-lp",  "/usr/bin/lpr", /* line printer */
+       "-mh",  "/usr/lib/dpr", /* GCOS via 201 dataphone */
+       0
+};
+
+main(argc, argv)
+char **argv;
+{
+       int i, j;
+
+       argv[argc] = 0;
+       for(i=0; code[i+2]; i+=2)
+       if(argc > 1)
+               for(j=0; code[i][j]==argv[1][j]; j++)
+                       if(code[i][j] == 0)
+                               goto OK;
+OK:
+       execv(code[i+1]+4, &argv[0]);
+       execv(code[i+1], &argv[0]);
+       write(2, "can't start daemon\n", 19);
+}
diff --git a/usr/src/cmd/osh.c b/usr/src/cmd/osh.c
deleted file mode 100644 (file)
index 12b1c23..0000000
+++ /dev/null
@@ -1,844 +0,0 @@
-/*
- */
-
-#include <setjmp.h>
-#define        INTR    2
-#define        QUIT    3
-#define LINSIZ 1000
-#define ARGSIZ 50
-#define TRESIZ 100
-
-#define QUOTE 0200
-#define FAND 1
-#define FCAT 2
-#define FPIN 4
-#define FPOU 8
-#define FPAR 16
-#define FINT 32
-#define FPRS 64
-#define TCOM 1
-#define TPAR 2
-#define TFIL 3
-#define TLST 4
-#define DTYP 0
-#define DLEF 1
-#define DRIT 2
-#define DFLG 3
-#define DSPR 4
-#define DCOM 5
-#define        ENOMEM  12
-#define        ENOEXEC 8
-
-int errval;
-char   *dolp;
-char   pidp[6];
-char   **dolv;
-jmp_buf        jmpbuf;
-int    dolc;
-char   *promp;
-char   *linep;
-char   *elinep;
-char   **argp;
-char   **eargp;
-int    *treep;
-int    *treeend;
-char   peekc;
-char   gflg;
-char   error;
-char   uid;
-char   setintr;
-char   *arginp;
-int    onelflg;
-int    stoperr;
-
-#define        NSIG    16
-char   *mesg[NSIG] {
-       0,
-       "Hangup",
-       0,
-       "Quit",
-       "Illegal instruction",
-       "Trace/BPT trap",
-       "IOT trap",
-       "EMT trap",
-       "Floating exception",
-       "Killed",
-       "Bus error",
-       "Memory fault",
-       "Bad system call",
-       0,
-       "Alarm clock",
-       "Terminated",
-};
-
-char   line[LINSIZ];
-char   *args[ARGSIZ];
-int    trebuf[TRESIZ];
-
-main(c, av)
-int c;
-char **av;
-{
-       register f;
-       register char *acname, **v;
-
-       for(f=3; f<15; f++)
-               close(f);
-       dolc = getpid();
-       for(f=4; f>=0; f--) {
-               dolc = dolc/10;
-               pidp[f] = dolc%10 + '0';
-       }
-       v = av;
-       acname = "<none>";
-       promp = "% ";
-       if((uid = getuid()) == 0)
-               promp = "# ";
-       if(c>1 && v[1][0]=='-' && v[1][1]=='e') {
-               ++stoperr;
-               v[1] = v[0];
-               ++v;
-               --c;
-       }
-       if(c > 1) {
-               promp = 0;
-               if (*v[1]=='-') {
-                       **v = '-';
-                       if (v[1][1]=='c' && c>2)
-                               arginp = v[2];
-                       else if (v[1][1]=='t')
-                               onelflg = 2;
-               } else {
-                       close(0);
-                       f = open(v[1], 0);
-                       if(f < 0) {
-                               prs(v[1]);
-                               err(": cannot open",255);
-                       }
-               }
-       }
-       if(**v == '-') {
-               signal(QUIT, 1);
-               f = signal(INTR, 1);
-               if ((arginp==0&&onelflg==0) || (f&01)==0)
-                       setintr++;
-       }
-       dolv = v+1;
-       dolc = c-1;
-
-loop:
-       if(promp != 0)
-               prs(promp);
-       peekc = getc();
-       main1();
-       goto loop;
-}
-
-main1()
-{
-       register char  *cp;
-       register *t;
-
-       argp = args;
-       eargp = args+ARGSIZ-5;
-       linep = line;
-       elinep = line+LINSIZ-5;
-       error = 0;
-       gflg = 0;
-       do {
-               cp = linep;
-               word();
-       } while(*cp != '\n');
-       treep = trebuf;
-       treeend = &trebuf[TRESIZ];
-       if(gflg == 0) {
-               if(error == 0) {
-                       setjmp(jmpbuf);
-                       if (error)
-                               return;
-                       t = syntax(args, argp);
-               }
-               if(error != 0)
-                       err("syntax error",255); else
-                       execute(t);
-       }
-}
-
-word()
-{
-       register char c, c1;
-
-       *argp++ = linep;
-
-loop:
-       switch(c = getc()) {
-
-       case ' ':
-       case '\t':
-               goto loop;
-
-       case '\'':
-       case '"':
-               c1 = c;
-               while((c=readc()) != c1) {
-                       if(c == '\n') {
-                               error++;
-                               peekc = c;
-                               return;
-                       }
-                       *linep++ = c|QUOTE;
-               }
-               goto pack;
-
-       case '&':
-       case ';':
-       case '<':
-       case '>':
-       case '(':
-       case ')':
-       case '|':
-       case '^':
-       case '\n':
-               *linep++ = c;
-               *linep++ = '\0';
-               return;
-       }
-
-       peekc = c;
-
-pack:
-       for(;;) {
-               c = getc();
-               if(any(c, " '\"\t;&<>()|^\n")) {
-                       peekc = c;
-                       if(any(c, "\"'"))
-                               goto loop;
-                       *linep++ = '\0';
-                       return;
-               }
-               *linep++ = c;
-       }
-}
-
-tree(n)
-int n;
-{
-       register *t;
-
-       t = treep;
-       treep =+ n;
-       if (treep>treeend) {
-               prs("Command line overflow\n");
-               error++;
-               longjmp(jmpbuf, 1);
-       }
-       return(t);
-}
-
-getc()
-{
-       register char c;
-
-       if(peekc) {
-               c = peekc;
-               peekc = 0;
-               return(c);
-       }
-       if(argp > eargp) {
-               argp =- 10;
-               while((c=getc()) != '\n');
-               argp =+ 10;
-               err("Too many args",255);
-               gflg++;
-               return(c);
-       }
-       if(linep > elinep) {
-               linep =- 10;
-               while((c=getc()) != '\n');
-               linep =+ 10;
-               err("Too many characters",255);
-               gflg++;
-               return(c);
-       }
-getd:
-       if(dolp) {
-               c = *dolp++;
-               if(c != '\0')
-                       return(c);
-               dolp = 0;
-       }
-       c = readc();
-       if(c == '\\') {
-               c = readc();
-               if(c == '\n')
-                       return(' ');
-               return(c|QUOTE);
-       }
-       if(c == '$') {
-               c = readc();
-               if(c>='0' && c<='9') {
-                       if(c-'0' < dolc)
-                               dolp = dolv[c-'0'];
-                       goto getd;
-               }
-               if(c == '$') {
-                       dolp = pidp;
-                       goto getd;
-               }
-       }
-       return(c&0177);
-}
-
-readc()
-{
-       int rdstat;
-       char cc;
-       register c;
-
-       if (arginp) {
-               if (arginp == 1)
-                       exit(errval);
-               if ((c = *arginp++) == 0) {
-                       arginp = 1;
-                       c = '\n';
-               }
-               return(c);
-       }
-       if (onelflg==1)
-               exit(255);
-       if((rdstat = read(0, &cc, 1)) != 1)
-               if(rdstat==0) exit(errval); /* end of file*/
-               else exit(255); /* error */
-       if (cc=='\n' && onelflg)
-               onelflg--;
-       return(cc);
-}
-
-/*
- * syntax
- *     empty
- *     syn1
- */
-
-syntax(p1, p2)
-char **p1, **p2;
-{
-
-       while(p1 != p2) {
-               if(any(**p1, ";&\n"))
-                       p1++; else
-                       return(syn1(p1, p2));
-       }
-       return(0);
-}
-
-/*
- * syn1
- *     syn2
- *     syn2 & syntax
- *     syn2 ; syntax
- */
-
-syn1(p1, p2)
-char **p1, **p2;
-{
-       register char **p;
-       register *t, *t1;
-       int l;
-
-       l = 0;
-       for(p=p1; p!=p2; p++)
-       switch(**p) {
-
-       case '(':
-               l++;
-               continue;
-
-       case ')':
-               l--;
-               if(l < 0)
-                       error++;
-               continue;
-
-       case '&':
-       case ';':
-       case '\n':
-               if(l == 0) {
-                       l = **p;
-                       t = tree(4);
-                       t[DTYP] = TLST;
-                       t[DLEF] = syn2(p1, p);
-                       t[DFLG] = 0;
-                       if(l == '&') {
-                               t1 = t[DLEF];
-                               t1[DFLG] =| FAND|FPRS|FINT;
-                       }
-                       t[DRIT] = syntax(p+1, p2);
-                       return(t);
-               }
-       }
-       if(l == 0)
-               return(syn2(p1, p2));
-       error++;
-       return(0);
-}
-
-/*
- * syn2
- *     syn3
- *     syn3 | syn2
- */
-
-syn2(p1, p2)
-char **p1, **p2;
-{
-       register char **p;
-       register int l, *t;
-
-       l = 0;
-       for(p=p1; p!=p2; p++)
-       switch(**p) {
-
-       case '(':
-               l++;
-               continue;
-
-       case ')':
-               l--;
-               continue;
-
-       case '|':
-       case '^':
-               if(l == 0) {
-                       t = tree(4);
-                       t[DTYP] = TFIL;
-                       t[DLEF] = syn3(p1, p);
-                       t[DRIT] = syn2(p+1, p2);
-                       t[DFLG] = 0;
-                       return(t);
-               }
-       }
-       return(syn3(p1, p2));
-}
-
-/*
- * syn3
- *     ( syn1 ) [ < in  ] [ > out ]
- *     word word* [ < in ] [ > out ]
- */
-
-syn3(p1, p2)
-char **p1, **p2;
-{
-       register char **p;
-       char **lp, **rp;
-       register *t;
-       int n, l, i, o, c, flg;
-
-       flg = 0;
-       if(**p2 == ')')
-               flg =| FPAR;
-       lp = 0;
-       rp = 0;
-       i = 0;
-       o = 0;
-       n = 0;
-       l = 0;
-       for(p=p1; p!=p2; p++)
-       switch(c = **p) {
-
-       case '(':
-               if(l == 0) {
-                       if(lp != 0)
-                               error++;
-                       lp = p+1;
-               }
-               l++;
-               continue;
-
-       case ')':
-               l--;
-               if(l == 0)
-                       rp = p;
-               continue;
-
-       case '>':
-               p++;
-               if(p!=p2 && **p=='>')
-                       flg =| FCAT; else
-                       p--;
-
-       case '<':
-               if(l == 0) {
-                       p++;
-                       if(p == p2) {
-                               error++;
-                               p--;
-                       }
-                       if(any(**p, "<>("))
-                               error++;
-                       if(c == '<') {
-                               if(i != 0)
-                                       error++;
-                               i = *p;
-                               continue;
-                       }
-                       if(o != 0)
-                               error++;
-                       o = *p;
-               }
-               continue;
-
-       default:
-               if(l == 0)
-                       p1[n++] = *p;
-       }
-       if(lp != 0) {
-               if(n != 0)
-                       error++;
-               t = tree(5);
-               t[DTYP] = TPAR;
-               t[DSPR] = syn1(lp, rp);
-               goto out;
-       }
-       if(n == 0)
-               error++;
-       p1[n++] = 0;
-       t = tree(n+5);
-       t[DTYP] = TCOM;
-       for(l=0; l<n; l++)
-               t[l+DCOM] = p1[l];
-out:
-       t[DFLG] = flg;
-       t[DLEF] = i;
-       t[DRIT] = o;
-       return(t);
-}
-
-scan(at, f)
-int *at;
-int (*f)();
-{
-       register char *p, c;
-       register *t;
-
-       t = at+DCOM;
-       while(p = *t++)
-               while(c = *p)
-                       *p++ = (*f)(c);
-}
-
-tglob(c)
-int c;
-{
-
-       if(any(c, "[?*"))
-               gflg = 1;
-       return(c);
-}
-
-trim(c)
-int c;
-{
-
-       return(c&0177);
-}
-
-execute(t, pf1, pf2)
-int *t, *pf1, *pf2;
-{
-       int i, f, pv[2];
-       register *t1;
-       register char *cp1, *cp2;
-       extern errno;
-
-       if(t != 0)
-       switch(t[DTYP]) {
-
-       case TCOM:
-               cp1 = t[DCOM];
-               if(equal(cp1, "chdir")) {
-                       if(t[DCOM+1] != 0) {
-                               if(chdir(t[DCOM+1]) < 0)
-                                       err("chdir: bad directory",255);
-                       } else
-                               err("chdir: arg count",255);
-                       return;
-               }
-               if(equal(cp1, "shift")) {
-                       if(dolc < 1) {
-                               prs("shift: no args\n");
-                               return;
-                       }
-                       dolv[1] = dolv[0];
-                       dolv++;
-                       dolc--;
-                       return;
-               }
-               if(equal(cp1, "login")) {
-                       if(promp != 0) {
-                               execv("/bin/login", t+DCOM);
-                       }
-                       prs("login: cannot execute\n");
-                       return;
-               }
-               if(equal(cp1, "newgrp")) {
-                       if(promp != 0) {
-                               execv("/bin/newgrp", t+DCOM);
-                       }
-                       prs("newgrp: cannot execute\n");
-                       return;
-               }
-               if(equal(cp1, "wait")) {
-                       pwait(-1, 0);
-                       return;
-               }
-               if(equal(cp1, ":"))
-                       return;
-
-       case TPAR:
-               f = t[DFLG];
-               i = 0;
-               if((f&FPAR) == 0)
-                       i = fork();
-               if(i == -1) {
-                       err("try again",255);
-                       return;
-               }
-               if(i != 0) {
-                       if((f&FPIN) != 0) {
-                               close(pf1[0]);
-                               close(pf1[1]);
-                       }
-                       if((f&FPRS) != 0) {
-                               prn(i);
-                               prs("\n");
-                       }
-                       if((f&FAND) != 0)
-                               return;
-                       if((f&FPOU) == 0)
-                               pwait(i, t);
-                       return;
-               }
-               if(t[DLEF] != 0) {
-                       close(0);
-                       i = open(t[DLEF], 0);
-                       if(i < 0) {
-                               prs(t[DLEF]);
-                               err(": cannot open",255);
-                               exit(255);
-                       }
-               }
-               if(t[DRIT] != 0) {
-                       if((f&FCAT) != 0) {
-                               i = open(t[DRIT], 1);
-                               if(i >= 0) {
-                                       lseek(i, 0L, 2);
-                                       goto f1;
-                               }
-                       }
-                       i = creat(t[DRIT], 0666);
-                       if(i < 0) {
-                               prs(t[DRIT]);
-                               err(": cannot create",255);
-                               exit(255);
-                       }
-               f1:
-                       close(1);
-                       dup(i);
-                       close(i);
-               }
-               if((f&FPIN) != 0) {
-                       close(0);
-                       dup(pf1[0]);
-                       close(pf1[0]);
-                       close(pf1[1]);
-               }
-               if((f&FPOU) != 0) {
-                       close(1);
-                       dup(pf2[1]);
-                       close(pf2[0]);
-                       close(pf2[1]);
-               }
-               if((f&FINT)!=0 && t[DLEF]==0 && (f&FPIN)==0) {
-                       close(0);
-                       open("/dev/null", 0);
-               }
-               if((f&FINT) == 0 && setintr) {
-                       signal(INTR, 0);
-                       signal(QUIT, 0);
-               }
-               if(t[DTYP] == TPAR) {
-                       if(t1 = t[DSPR])
-                               t1[DFLG] =| f&FINT;
-                       execute(t1);
-                       exit(255);
-               }
-               gflg = 0;
-               scan(t, tglob);
-               if(gflg) {
-                       t[DSPR] = "/etc/glob";
-                       execv(t[DSPR], t+DSPR);
-                       prs("glob: cannot execute\n");
-                       exit(255);
-               }
-               scan(t, trim);
-               *linep = 0;
-               texec(t[DCOM], t);
-               cp1 = linep;
-               cp2 = "/usr/bin/";
-               while(*cp1 = *cp2++)
-                       cp1++;
-               cp2 = t[DCOM];
-               while(*cp1++ = *cp2++);
-               texec(linep+4, t);
-               texec(linep, t);
-               prs(t[DCOM]);
-               err(": not found",255);
-               exit(255);
-
-       case TFIL:
-               f = t[DFLG];
-               pipe(pv);
-               t1 = t[DLEF];
-               t1[DFLG] =| FPOU | (f&(FPIN|FINT|FPRS));
-               execute(t1, pf1, pv);
-               t1 = t[DRIT];
-               t1[DFLG] =| FPIN | (f&(FPOU|FINT|FAND|FPRS));
-               execute(t1, pv, pf2);
-               return;
-
-       case TLST:
-               f = t[DFLG]&FINT;
-               if(t1 = t[DLEF])
-                       t1[DFLG] =| f;
-               execute(t1);
-               if(t1 = t[DRIT])
-                       t1[DFLG] =| f;
-               execute(t1);
-               return;
-
-       }
-}
-
-texec(f, at)
-int *at;
-{
-       extern errno;
-       register int *t;
-
-       t = at;
-       execv(f, t+DCOM);
-       if (errno==ENOEXEC) {
-               if (*linep)
-                       t[DCOM] = linep;
-               t[DSPR] = "/usr/bin/osh";
-               execv(t[DSPR], t+DSPR);
-               prs("No shell!\n");
-               exit(255);
-       }
-       if (errno==ENOMEM) {
-               prs(t[DCOM]);
-               err(": too large",255);
-               exit(255);
-       }
-}
-
-err(s, exitno)
-char *s;
-int exitno;
-{
-
-       prs(s);
-       prs("\n");
-       if(promp == 0) {
-               lseek(0, 0L, 2);
-               exit(exitno);
-       }
-}
-
-prs(as)
-char *as;
-{
-       register char *s;
-
-       s = as;
-       while(*s)
-               putc(*s++);
-}
-
-putc(c)
-{
-       char cc;
-
-       cc = c;
-       write(2, &cc, 1);
-}
-
-prn(n)
-int n;
-{
-       register a;
-
-       if (a = n/10)
-               prn(a);
-       putc(n%10 + '0');
-}
-
-any(c, as)
-int c;
-char *as;
-{
-       register char *s;
-
-       s = as;
-       while(*s)
-               if(*s++ == c)
-                       return(1);
-       return(0);
-}
-
-equal(as1, as2)
-char *as1, *as2;
-{
-       register char *s1, *s2;
-
-       s1 = as1;
-       s2 = as2;
-       while(*s1++ == *s2)
-               if(*s2++ == '\0')
-                       return(1);
-       return(0);
-}
-
-pwait(i, t)
-int i, *t;
-{
-       register p, e;
-       int s;
-
-       if(i != 0)
-       for(;;) {
-               p = wait(&s);
-               if(p == -1)
-                       break;
-               e = s&0177;
-               if (e>=NSIG || mesg[e]) {
-                       if(p != i) {
-                               prn(p);
-                               prs(": ");
-                       }
-                       if (e < NSIG)
-                               prs(mesg[e]);
-                       else {
-                               prs("Signal ");
-                               prn(e);
-                       }
-                       if(s&0200)
-                               prs(" -- Core dumped");
-               }
-               if (e || s&&stoperr)
-                       err("", (s>>8)|e );
-               errval =| (s>>8);
-       }
-}
diff --git a/usr/src/cmd/paste.c b/usr/src/cmd/paste.c
new file mode 100644 (file)
index 0000000..534add3
--- /dev/null
@@ -0,0 +1,137 @@
+#
+/* paste: concatenate corresponding lines of each file in parallel(GWRL) */
+/*     (-s option: serial concatenation like old (127's) paste command */
+/* make :  cc paste.c -lS */
+# include <stdio.h>
+# define MAXOPNF 12    /* maximal no. of open files (not with -s option) */
+# define MAXLINE 512   /* maximal line length */
+#define RUB  '\177'
+       char del[MAXLINE] = {"\t"};
+  
+main(argc, argv)
+int argc;
+char ** argv;
+{
+       int i, j, k, eofcount, nfiles;
+       int delcount = { 1 } ;
+       int onefile  = { 0 } ;
+       char outbuf[MAXLINE], c, l ;
+       register char *p;
+       FILE *inptr[MAXOPNF];
+  
+       while (argc > 1 && argv[1][0] == '-' && (c = argv[1][1]) != '\0'){
+               switch (c) {
+                       case 's' :  onefile++;
+                               c = argv[1][2];
+                               argv[1]++;
+                               break ;
+                       case 'd' : argv[1] += 2;
+                               if((delcount = move(argv[1], &del[0])) == 0) diag("no delimiters\n",1);;
+                               break;
+                       default :
+                               diag("Usage: paste [-s] [-d<delimiterstring>] file1 file2 ...", 1);
+                               break;
+               }
+               --argc;
+               ++argv;
+       } /* end options */
+       --argc;
+       if ( ! onefile) {       /* not -s option: parallel line merging */
+               for (i = 0; argc >0 && i < MAXOPNF; i++) {
+                       if (argv[i + 1][0] == '-') {
+                               inptr[i] = stdin;
+                       } else inptr[i] = fopen(argv[i + 1], "r");
+                       if (inptr[i] == NULL) {
+                               diag(argv[i + 1], 0);
+                               diag(" : cannot open\n", 1);
+                       }
+               argc--;
+               }
+               if (argc > 0) diag("too many files\n",1);
+               nfiles = i;
+  
+               do {
+                       p = &outbuf[0];
+                       eofcount = 0;
+                       j = k = 0;
+                       for (i = 0; i < nfiles; i++) {
+                               while((c = getc(inptr[i])) != '\n' && c != EOF)   {
+                                       if (++j <= MAXLINE - 2) *p++ = c ;
+                                       else {
+                                       diag("line too long\n",1);
+                                       }
+                               }
+                               if ( (l = del[k]) != RUB) *p++ = l;
+                               k = (k + 1) % delcount;
+                               if( c == EOF) eofcount++;
+                       }
+                       if (l != RUB) *--p = '\n'; else  *p = '\n';
+                       *++p = 0;
+                       if (eofcount < nfiles) fputs(outbuf, stdout);
+               }while (eofcount < nfiles);
+  
+       } else {        /* -s option: serial file pasting (old 127 paste command) */
+               p = &outbuf[0];
+               j = 0;
+               k = 0;
+               for (i = 1; i <= argc; i++) {
+                       if (argv[i][0] == '-') {
+                               inptr[0] = stdin;
+                       } else inptr[0] = fopen(argv[i], "r");
+                       if (inptr[0] == NULL) {
+                               diag(argv[i], 0);
+                               diag(" : cannot open\n", 1);
+                       }
+         
+                       while((c = getc(inptr[0])) != EOF)   {
+                               if(c != '\n') {
+                                       if (++j <= MAXLINE - 2) *p++ = c ;
+                                       else diag("line too long\n",1);
+                               } else {
+                                       l = del[k];
+                                       if (l != RUB) *p++ = l ;
+                                       k = (k + 1) % delcount;
+                                       *p = 0;
+                                       fputs(outbuf, stdout);
+                                       p = &outbuf[0];
+                                       j = 0;
+                               }
+                       }
+               }
+               if (l != '\n') fputs("\n", stdout);
+       }
+}
+diag(s,r)
+char *s;
+int r;
+{
+       write(2, "paste : ", 8);
+       while(*s)write(2,s++,1);
+       if(r != 0) exit(r);
+}
+  
+move(from, to)
+char *from, *to;
+{
+int c, i;
+       i = 0;
+       do {
+               c = *from++;
+               i++;
+               if (c != '\\') *to++ = c;
+               else { c = *from++;
+                       switch (c) {
+                               case '0' : *to++ = RUB;
+                                               break;
+                               case 't' : *to++ = '\t';
+                                               break;
+                               case 'n' : *to++ = '\n';
+                                               break;
+                               default  : *to++ = c;
+                                               break;
+                       }
+               }
+       } while (c) ;
+return(--i);
+}
diff --git a/usr/src/cmd/pcat.c b/usr/src/cmd/pcat.c
new file mode 100644 (file)
index 0000000..a6566c2
--- /dev/null
@@ -0,0 +1,924 @@
+#include <signal.h>
+#define X 0
+/*
+C version of tcatsim
+*/
+
+#define OBSZ 512
+#define MAXY 3071
+#define US 037
+#define GS 035
+#define ESC 033
+#define FF 014
+#define SO 016
+#define SI 017
+#define DBL 0200
+
+int pl = 11*144;
+int mpy = 1;
+int div = 1;
+char *ap;
+int ch;
+int nonumb;
+int psize = 10;
+int dfact = 1;
+int ibuf[259];
+char obuf[OBSZ];
+char *obufp = obuf;
+int esc;
+int escd;
+int verd;
+int esct;
+int osize = 02;
+int size = 02;
+int rx;
+int xx = 0;
+int yy = MAXY+62+48;
+int leadtot = -31;
+int ohy = -1;
+int ohx = -1;
+int oxb = -1;
+int oly = -1;
+int olx = -1;
+int tflag;
+int railmag;
+int lead;
+int skip;
+int pgskip;
+int ksize = ';';
+int mcase;
+int stab[] = {010,0,01,07,02,03,04,05,0211,06,0212,0213,0214,0215,0216,0217};
+int rtab[] = {6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 28, 26, 18};
+int ktab[] = {';',';',';',';',';',';',':',':','9','9','9','9','8','8','8','9'};
+int od = 1;
+int first = 1;
+int alpha;
+int xxx;
+extern int *drawtab[], *moretab[];
+
+main(argc,argv)
+int argc;
+char **argv;
+{
+       register i, j;
+       extern ex();
+       extern char asctab[];
+       extern char spectab[];
+
+       openpl();
+       space(0,0,4095,3071);
+       while((--argc > 0) && ((++argv)[0][0]=='-')){
+               switch(argv[0][1]){
+                       case 'p':
+                               ap = &argv[0][2];
+                               dfact = 72;
+                               if(i = atoi())pl = i/3;
+                               continue;
+                       case 't':
+                               tflag++;
+                               continue;
+                       case 's':
+                               ap = &argv[0][2];
+                               dfact = 1;
+                               pgskip = atoi();
+                               continue;
+                       default:
+                               dfact = 1;
+                               ap = &argv[0][1];
+                               if(i = atoi())mpy = i;
+                               if(i = atoi())div = i;
+                               continue;
+               }
+       }
+       if(argc){
+               if(fopen(argv[0], ibuf) < 0){
+                       prstr("Cannot open: ");
+                       prstr(argv[0]);
+                       prstr("\n");
+                       exit(1);
+               }
+       }
+       signal(SIGINT, ex);
+       while((i = getc(ibuf)) >= 0){
+               if(!i)continue;
+               if(i & 0200){
+                       esc += (~i) & 0177;
+                       continue;
+               }
+               if(esc){
+                       if(escd)esc = -esc;
+                       esct += esc;
+                       xx += (esc*mpy + rx)/div;
+                       rx = (esc*mpy + rx)%div;
+                       sendpt();
+                       esc = 0;
+               }
+               switch(i){
+                       case 0100:      /*init*/
+                               escd = verd = mcase = railmag = xx = 0;
+                               yy = MAXY + 48;
+                                       if(first){
+                                               first = 0;
+                                               yy += 62;
+                                       }
+                               leadtot = -31;
+                               ohy = oxb = oly = ohx = olx = -1;
+                               init();
+                               continue;
+                       case 0101:      /*lower rail*/
+                               railmag &= ~01;
+                               continue;
+                       case 0102:      /*upper rail*/
+                               railmag |= 01;
+                               continue;
+                       case 0103:      /*upper mag*/
+                               railmag |= 02;
+                               continue;
+                       case 0104:      /*lower mag*/
+                               railmag &= ~02;
+                               continue;
+                       case 0105:      /*lower case*/
+                               mcase = 0;
+                               continue;
+                       case 0106:      /*upper case*/
+                               mcase = 0100;
+                               continue;
+                       case 0107:      /*escape forward*/
+                               escd = 0;
+                               continue;
+                       case 0110:      /*escape backward*/
+                               escd = 1;
+                               continue;
+                       case 0111:      /*stop*/
+                               continue;
+                       case 0112:      /*lead forward*/
+                               verd = 0;
+                               continue;
+                       case 0113:      /*undefined*/
+                               continue;
+                       case 0114:      /*lead backward*/
+                               verd = 1;
+                               continue;
+                       case 0115:      /*undefined*/
+                       case 0116:
+                       case 0117:
+                               continue;
+               }
+               if((i & 0340) == 0140){ /*leading*/
+                       lead = (~i) & 037;
+                       if(verd)lead = -lead;
+                       if((leadtot += lead) > pl){
+                               leadtot = lead;
+                               flusho();
+                               if(!tflag)kwait();
+                               yy = MAXY;
+                               if(pgskip)--pgskip;
+                               init();
+                               continue;
+                       }
+                       if(skip)continue;
+                       if((yy -= (lead<<1)) < 0){
+                               skip++;
+                               yy = 0;
+                       }else sendpt();
+                       continue;
+               }
+               if((i & 0360) == 0120){ /*size change*/
+                       i &= 017;
+                       for(j = 0; i != (stab[j] & 017); j++);
+                       osize = size;
+                       size = stab[j];
+                       psize = rtab[j];
+                       ksize = ktab[j];
+                       i = 0;
+                       if(!(osize & DBL) && (size & DBL))i = -55;
+                       else if((osize & DBL) && !(size & DBL))i = 55;
+                       if(escd)i = -i;
+                       esc += i;
+                       continue;
+               }
+               if(i & 0300)continue;
+               i = (i & 077) | mcase;
+               if(railmag != 03)j = asctab[i];
+               else j = spectab[i];
+               if(alpha)sendpt();
+               if (j== 0) { /* see if we can draw this character */
+                       trace( railmag == 03 ? drawtab[i] : moretab[i]);
+                       continue;
+               }else if(j){
+                       oput(j);
+                       alpha++;
+               }
+       }
+       ex();
+}
+
+# define SCL(x) (psize*x/10)
+# define PT(x,y) xx-10+SCL(x), yy-20+SCL(y)
+trace (p)
+       int *p;
+{
+if (p==0) return;
+while (*p)
+       {
+       switch (*p)
+               {
+               case 'l':
+/*
+                       line(xx-10+SCL(p[1]),yy-20+SCL(p[2]),xx-10+SCL(p[3]),yy-20+SCL(p[4]));
+ */ line(PT(p[1], p[2]), PT(p[3], p[4]));
+                       p+=5;
+                       break;
+               case 't':
+                       move (xx+p[2], yy+p[3]);
+                       label(p+1);
+                       p+=4;
+                       break;
+               case 'c':
+                       circle(PT(p[1],p[2]), SCL(p[3]));
+                       p+=4;
+                       break;
+               case 'a':
+                       arc (PT(p[1],p[2]), PT(p[3],p[4]), PT(p[5],p[6]));
+                       p+=7;
+                       break;
+               }
+       }
+}
+
+init(){
+       register i;
+
+       erase();
+       flusho();
+       skip = 0;
+       sendpt();
+}
+ex(){
+       yy = MAXY;
+       xx = 0;
+       sendpt();
+       closepl();
+       exit(0);
+}
+kwait(){
+       ;
+}
+oput(i)
+char i;
+{
+       if(pgskip)return;
+       label(&i);
+}
+flusho(){
+       ;
+}
+sendpt(){
+       move(xx,yy);
+       alpha = 0;
+       return;
+}
+prstr(s)
+char *s;
+{
+       register i;
+
+       for(i=0;*s;i++)s++;
+       write(2,s-i,i);
+}
+atoi()
+{
+       register i, j, acc;
+       int field, digits, *dd, *tscale();
+
+       field = digits = acc = 0;
+a1:
+       while(((j = (i = getch()) - '0') >= 0) && (j <= 9)){
+               field++;
+               digits++;
+               acc = 10*acc + j;
+       }
+       if(i == '.'){
+               field++;
+               digits = 0;
+               goto a1;
+       }
+       if(!(ch = i))ch = 'x';
+       dd = tscale(acc);
+       acc = dd[0];
+       if((field != digits) && (digits > 0)){
+               j = 1;
+               while(digits--)j *= 10;
+               acc = ldiv(dd[1],dd[0],j);
+       }
+       nonumb = !field;
+       ch = 0;
+       return(acc);
+}
+int *tscale(n)
+int n;
+{
+       register i, j;
+       static int aa[2];
+
+       switch(i = getch()){
+               case 'u':
+                       j = 1;
+                       break;
+               case 'p':       /*Points*/
+                       j = 6;
+                       break;
+               case 'i':       /*Inches*/
+                       j = 432;
+                       break;
+               case 'c':       /*Centimeters; should be 170.0787*/
+                       j = 170;
+                       break;
+               case 'P':       /*Picas*/
+                       j = 72;
+                       break;
+               default:
+                       j = dfact;
+                       ch = i;
+       }
+       aa[0] = n * j;
+       aa[1] = hmul(n,j);
+       return(aa);
+}
+getch(){
+       register i;
+
+       if(ch){
+               i = ch;
+               ch = 0;
+               return(i);
+       }
+       return(*ap++);
+}
+/* the way this program decides what to do is:
+  (1) If the character is on a standard font (0-2)
+   
+       (a) look in "asctab"; if an entry, print that character.
+          else
+       (b) look in "moretab"; if an entry, it points to a vector
+           description, which draw.
+  (2) If the character is on the special font (railmag=3)
+       (a) look in "spectab"; if an entry >0,
+           print that character.
+       (b) if a -1, that requests the apl font; not used.
+       (c) if zero, look in "drawtab"; if an entry, it pooints
+           to a vector description, which draw.
+   (3) Vector descriptions are calls to the "plot" type routines.
+       the possible routines are 'c' (circle), 'l' (line), 't' (label,
+       only one character used), and 'a' (arc).
+ */
+char asctab[128] = {
+  0,   /*blank*/
+'h',   /*h*/
+'t',   /*t*/
+'n',   /*n*/
+'m',   /*m*/
+'l',   /*l*/
+'i',   /*i*/
+'z',   /*z*/
+'s',   /*s*/
+'d',   /*d*/
+'b',   /*b*/
+'x',   /*x*/
+'f',   /*f*/
+'j',   /*j*/
+'u',   /*u*/
+'k',   /*k*/
+  0,   /*blank*/
+'p',   /*p*/
+'-',   /*_ 3/4 em dash*/
+';',   /*;*/
+  0,   /*blank*/
+'a',   /*a*/
+'_',   /*rule*/
+'c',   /*c*/
+'`',   /*` open*/
+'e',   /*e*/
+'\'',  /*' close*/
+'o',   /*o*/
+  0,   /*1/4*/
+'r',   /*r*/
+  0,   /*1/2*/
+'v',   /*v*/
+'-',   /*- hyphen*/
+'w',   /*w*/
+'q',   /*q*/
+'/',   /*/*/
+'.',   /*.*/
+'g',   /*g*/
+  0,   /*3/4*/
+',',   /*,*/
+'&',   /*&*/
+'y',   /*y*/
+  0,   /*blank*/
+'%',   /*%*/
+  0,   /*blank*/
+'Q',   /*Q*/
+'T',   /*T*/
+'O',   /*O*/
+'H',   /*H*/
+'N',   /*N*/
+'M',   /*M*/
+'L',   /*L*/
+'R',   /*R*/
+'G',   /*G*/
+'I',   /*I*/
+'P',   /*P*/
+'C',   /*C*/
+'V',   /*V*/
+'E',   /*E*/
+'Z',   /*Z*/
+'D',   /*D*/
+'B',   /*B*/
+'S',   /*S*/
+'Y',   /*Y*/
+  0,   /*blank*/
+'F',   /*F*/
+'X',   /*X*/
+'A',   /*A*/
+'W',   /*W*/
+'J',   /*J*/
+'U',   /*U*/
+'K',   /*K*/
+'0',   /*0*/
+'1',   /*1*/
+'2',   /*2*/
+'3',   /*3*/
+'4',   /*4*/
+'5',   /*5*/
+'6',   /*6*/
+'7',   /*7*/
+'8',   /*8*/
+'9',   /*9*/
+'*',   /***/
+'-',   /*minus*/
+   0,  /*fi*/
+  0,   /*fl*/
+  0,   /*ff*/
+  0,   /*cent mark*/
+  0,   /*ffl*/
+  0,   /* ffi */
+'(',   /*(*/
+')',   /*)*/
+'[',   /*[*/
+']',   /*]*/
+  0,   /*degree*/
+  0,   /*dagger*/
+'=',   /*=*/
+  0,   /*registered*/
+':',   /*:*/
+'+',   /*+*/
+  0,   /*blank*/
+'!',   /*!*/
+  0,   /*bullet*/
+'?',   /*?*/
+'\'',  /*foot mark*/
+'|',   /*|*/
+  0,   /*blank*/
+  0,   /*copyright*/
+  0,   /*square*/
+'$' }; /*$*/
+
+char spectab[128] = {
+  0,   /*blank*/
+  0,   /*psi*/
+  0,   /*theta*/
+  0,   /*nu*/
+  0,   /*mu*/
+  0,   /*lambda*/
+  0,   /*iota*/
+  0,   /*zeta*/
+  0,   /*sigma*/
+  0,   /*delta*/
+  0,   /*beta*/
+  0,   /*xi*/
+  0,   /*eta*/
+  0,   /*phi*/
+  'u', /*upsilon*/
+  0,   /*kappa*/
+  0,   /*blank*/
+  0,   /*pi*/
+  '@', /*at sign @*/
+  0,   /*down arrow*/
+  0,   /*blank*/
+  0,   /*alpha*/
+'|',   /*or*/
+  0,   /*chi*/
+'"',   /*"*/
+  0,   /*epsilon*/
+  '=', /*equals*/
+  'o', /*omicron*/
+  0,   /*left arrow*/
+  0,   /*rho*/
+  0,   /*up arrow*/
+  0,   /*tau*/
+'_',   /*underrule*/
+'\\',  /*\*/
+  0,   /*Psi*/
+  0,   /*bell system sign*/
+  0,   /*infinity*/
+  0,   /*gamma*/
+  0,   /*improper superset*/
+  0,   /*proportional to*/
+  0,   /*right hand*/
+  0,   /*omega*/
+  0,   /*blank*/
+  0,   /*gradient*/
+  0,   /*blank*/
+  0,   /*Phi*/
+  0,   /*Theta*/
+  0,   /*Omega*/
+  0,   /*cup (union)*/
+  0,   /*root en*/
+  0,   /*terminal sigma*/
+  0,   /*Lambda*/
+  '-', /*some horizontal line*/
+  0,   /*Gamma*/
+  0,   /*integral sign*/
+  0,   /*Pi*/
+  0,   /*subset of*/
+  0,   /*superset of*/
+  0,   /*approximates*/
+  0,   /*partial derivative*/
+  0,   /*Delta*/
+  0,   /*square root*/
+  0,   /*Sigma*/
+  0,   /*approx =*/
+  0,   /*blank*/
+'>',   /*>*/
+  0,   /*Xi*/
+'<',   /*<*/
+'/',   /*slash (longer)*/
+  0,   /*cap (intersection)*/
+  'Y', /*Upsilon*/
+  0,   /*not*/
+'|',   /*right ceiling (rt of ")*/
+'|',   /*left top (of big curly)*/
+'|',   /*bold vertical*/
+'|',   /*left center of big curly bracket*/
+'|',   /*left bottom*/
+'|',   /*right top*/
+'|',   /*right center of big curly bracket*/
+'|',   /*right bot*/
+'|',   /*right floor (rb of ")*/
+'|',   /*left floor (left bot of big sq bract)*/
+'|',   /*left ceiling (lt of ")*/
+'x',   /*multiply*/
+  0,   /*divide*/
+  0,   /*plus-minus*/
+  0,   /*<=*/
+  0,   /*>=*/
+  0,   /*identically equal*/
+  0,   /*not equal*/
+'{',   /*{*/
+'}',   /*}*/
+'\'',  /*' acute accent*/
+'`',   /*` grave accent*/
+'^',   /*^*/
+  '#', /*sharp*/
+  0,   /*left hand*/
+  0,   /*member of*/
+'~',   /*~*/
+  0,   /*empty set*/
+  0,   /*blank*/
+  0,   /*dbl dagger*/
+'|',   /*box rule*/
+  '*', /*telephone asterisk?*/
+  0,   /*improper subset*/
+  0,   /*circle*/
+  0,   /*blank*/
+  '+', /*eqn plus sign*/
+  0,   /*right arrow*/
+  0 }; /*section mark*/
+# define STOP 0
+int dnot[] = { 'l', 0, 15, 25, 15, 'l', 25, 15, 25, 5, STOP};
+int dlambda[] = {'l', 0, 40, 6, 40, 'l', 6, 40, 30, 0, 'l', 6, 0, 18, 20, STOP};
+int dSigma[] = {'l', 0, 0, 30, 0, 'l', 0, 40, 30, 40, 'l', 0, 0, 10, 20, 'l', 10, 20, 0, 40, STOP};
+int dsquare[] = {'l', 0, 0, 30, 0, 'l', 0, 0, 0, 30, 'l', 0, 30, 30, 30, 'l', 30, 0, 30, 30, STOP};
+int dDelta[] = {'l', 0,0, 30, 0, 'l', 0, 0, 15, 40, 'l', 15,40, 30, 0, STOP};
+int dintsign[] = { 'a', 25,30, 30,32, 20,32, 'l', 20, 32, 10, 8, 'a',5, 10, 0, 8, 10, 8, STOP};
+int dtheta[] = {'a', 25, 15, 10, 30, 10, 0, 'a', -5, 15, 10, 0, 10, 30, 'l', 5, 15, 12, 15, STOP};
+int dcopyr[] = {'c', 20, 20, 20, 't', 'c', 7,3, STOP};
+int dregist[] = {'c', 20, 20, 20, 't', 'R', 7,3, STOP};
+int dpi[] = { 'l', 0, 25, 30, 25, 'l', 5, 0, 8, 25, 'l', 17, 0, 20, 25, STOP};
+int dPi[] = { 'l', 0, 40, 30, 40, 'l', 5, 0, 5, 40, 'l', 25, 0, 25, 40, STOP};
+int dsqroot[] = { 'l', 0,10,5,10, 'l', 8, 10, 15, 0, 'l', 15, 0, 30, 40, STOP};
+int dgradient[] = { 'l', 0,40, 30, 40, 'l', 0, 40, 15, 0, 'l', 15, 0, 30, 40, STOP};
+int dbeta[] = {'t', 'B', 0, 5, 'l', 0, 20, 0, -10, STOP};
+int ddagger[] = {'l', 0, 30, 20, 30, 'l', 10, 0, 10, 40, STOP};
+int dpsi[] = { 'a', 15,25, 0, 27, 30, 23, 'l', 0, 0, 30, 40, STOP};
+int dmu[] = { 't',  'u', 0,5, 'l', 0,10, 0, -10, STOP};
+int dnu[] = { 'l',0,0,0,30, 'l', 0,0,20,30, STOP};
+int diota[] = { 'l', 0, 0, 4, 24, 'l', 6, 32, 6, 36, 'l', 0, 0, 5, 0, STOP};
+int dsigma[] = { 'c', 15,15,15, 'l', 15, 30, 35, 30, STOP};
+int ddelta[] = { 'c', 10, 10, 10, 'a', 16, 28, 18, 37, 14, 19, STOP};
+int depsilon[] = { 'a', 15, 15, 15, 30, 15, 0, 'l', 0, 15, 15, 15, STOP};
+int dchi[] = { 'l', 0, 30, 4, 30, 'l', 4, 30, 16, 0, 'l', 16, 0, 20, 0, 'l', 0, 0, 20, 30, STOP};
+int dtau[] = { 'l', 0, 30, 30, 30, 'l', 10, 0, 15, 30 , 'l', 10, 0, 15, 0, STOP};
+int dlesseq[] = { 'l', 0, 20, 30, 30, 'l', 0, 20, 30, 10, 'l', 0, 15, 30, 5, STOP};
+int dgreateq[] = { 'l', 0, 30, 30, 20, 'l', 0, 10, 30, 20, 'l', 0, 5, 30, 15, STOP};
+int dinfinity[] = { 'c', 10, 10, 10, 'c', 30 , 10, 10, STOP};
+int dalpha[] = { 'c', 15, 15, 15, 'a', 52, 15, 35, 30, 35, 0, STOP};
+int dphi[] = { 'c', 10, 15, 10, 'l', 5, 0, 15, 30, STOP};
+int dgamma[] = { 'l', 10, -10, 30, 30, 'a', 10, 15, 20, 10, 0, 20, STOP};
+int dkappa[] = { 'l', 0, 0, 6, 25, 'l', 3, 12, 20, 25, 'l', 6, 15, 20, 0, STOP};
+int drho[] = {'c', 15, 15, 10, 'l', 0, -5, 5, 20, STOP};
+int dGamma[] = {'l', 0, 0, 0, 35, 'l', 0, 35, 25, 35, 'l', 25, 35, 25, 25, STOP};
+int ddownar[]= {'l', 10, 0, 10, 30, 'l', 0, 10, 10, 0, 'l', 10, 0, 20, 10, STOP};
+int dupar[] = { 'l', 10, 0, 10, 30, 'l', 0, 20, 10, 30, 'l', 10, 30, 20, 20,STOP};
+int dleftar[] = { 'l', 0, 15, 25, 15, 'l', 10, 5, 0, 15, 'l', 10, 25, 0, 15, STOP};
+int drightar[] = { 'l', 0, 15, 25, 15, 'l', 15, 5, 25, 15, 'l', 15, 25, 25, 15, STOP};
+int ddivide[]= { 'l', 0, 15, 25, 15, 'l', 12, 20, 14, 20, 'l', 12, 10, 14, 10, STOP};
+int dcap[] = { 'a', 15, 10, 30, 10, 0, 10, 'l', 0, 0, 0, 10, 'l', 30, 0, 30, 10, STOP};
+int dcup[] = {'a', 15, 15, 0, 15, 30, 15, 'l', 0, 15, 0, 25, 'l', 30, 15, 30, 25, STOP};
+int dsubset[] = {'l', 0, 0, 10, 0, 'l', 0, 30, 10, 30, 'a', 10, 15, 10, 0, 10, 30,STOP};
+int dsupset[] = {'a', 15, 15, 15, 30, 15, 0, 'l', 15, 30, 25, 30, 'l', 15, 0, 25, 0, STOP};
+int dimpsubset[] = {'l', 0, 10, 10, 10,  'l', 0, 40, 10, 40, 'a', 10, 25, 10, 10, 10, 40, 'l', 0, 0, 30, 0, STOP};
+int dimpsupset[] = {'a', 15, 25, 15, 40, 15, 10, 'l', 15, 40, 25, 40, 'l', 15, 10, 25, 10, 'l', 0, 0, 30, 0, STOP};
+int dxi[] = {'l', 0, 30, 25, 30, 'a', 5, 25, 5, 30, 5, 20, 'l', 5, 20, 25, 20, 'a', 5, 15, 5, 20, 5, 10, 'l', 5, 10, 20, 10, 'a', 20, 5, 20, 0, 20, 10, STOP};
+int deta[] = {'a', 5,20,10,20,0,20, 'l', 10, 25, 10, 10, 'a', 15, 20, 20, 20, 10, 20, 'l', 20, 20, 20, 0, STOP};
+int dzeta[] = {'l', 0, 30, 25, 30, 'a', 20, 20, 20, 30, 20, 10, 'a', 20, 5, 20, 0, 20, 10, STOP};
+int dPsi[] = {'l', 0, 0, 30, 0, 'l', 0, 35, 30, 35, 'l', 15, 0, 15, 35, 'a', 15, 25, 0, 25, 30, 25, STOP};
+int dPhi[] = { 'l', 0, 0, 30, 0, 'l', 0, 40, 30, 40, 'l', 15, 0, 15, 40, 'c', 15, 20, 10, STOP};
+int domega[] = { 'a', 8, 18, 8, 26, 16, 18, 'a', 24, 18, 16, 18, 24, 26, STOP};
+int dtsigma[] = {'a', 10, 20, 17, 27, 10, 10, 'a', 10, 5, 10, 0, 10, 10, STOP};
+int dpartial[] = { 'c', 10, 10, 10, 'a', 0, 20, 10, 0, 0, 40, STOP};
+int dprop[] = {'c', 10,10,10, 'a', 30, 10, 30, 20, 30, 0, STOP};
+int dTheta[]= { 'c', 15, 15, 15, 'l', 5,15,25,15, 'l', 5, 13, 5, 17, 'l', 25, 13, 25, 17, STOP};
+int dXi[] = { 'l', 0, 40 , 30, 40, 'l' , 0, 0, 30, 0, 'l', 7, 20, 23, 20, STOP};
+int dLambda[] = { 'l', 0, 0, 15, 40, 'l', 15, 40, 30, 0, STOP};
+int drighth[]= { 'l', 0,0,20,0, 'l', 0, 10, 20, 10, 'l',0,20,20,20, 'l',0,30,35,30, 'l',0,40,35,40,
+       'a',20,5,20,0,20,10, 'a', 20,15,20,10,20,20, 'a',20,25,20,20,20,30, 'a',35,35,35,30,35,30,STOP};
+int dlefth[] = {'l', 20, 0, 40,0, 'l',20,10,40,10, 'l',20,20,40,20, 'l',5,30,40,30, 'l',5,40,40,40, 
+       'a', 20, 5, 20,10,20,0, 'a', 20,15,20,20,20,10, 'a', 20, 25, 20,30,20,20, 'a', 5,35,5,40,5,30, STOP};
+int dcircle[] = {'c',15,15,15,STOP};
+int dapprox[] = {'a', 7, 0, 14, 15, 0, 15, 'a', 21, 30, 14,15,28,15, STOP};
+int dappreq[] = {'a', 7, 0, 14, 15, 0, 15, 'a', 21, 30, 14,15,28,15, 'l', 0, 0, 28, 0, STOP};
+int dOmega[] = {'a', 15,25,30,25,0,25, 'l',10,0,0,25, 'l',20,0,30,25, 'l',0,0,10,0, 'l',20,0,30,0, STOP};
+int dplmn[] = {'l', 0, 0, 30, 0, 'l', 0, 25, 30, 25, 'l', 15,10, 15, 40, STOP};
+int dmultiply[] = {'l',0,0,30,30, 'l', 0,30,30,0, STOP};
+int dident[]= {'l', 0,0,30,0, 'l',0,10,30,10, 'l',0,20,30,20, STOP};
+int dnoteq[] = {'l',0,10,30,10, 'l',0,25,30,25, 'l', 0,0,30,40, STOP};
+int ddbldag[] = {'l',10,0,10,30, 'l',0,5,20,5, 'l',0,25,20,25, STOP};
+int dbullet[] = { 'c',10,10,10, 'c',10,10,8, 'c', 10,10,6, 'c', 10, 10, 4, 'c', 10, 10, 2, STOP};
+int drooten[] = {'l', 0,30,25,30, STOP};
+int dempty[] = { 'c', 15, 15, 15, 'l', 0, 0, 30, 30, STOP};
+int dsection [] = {'a', 7,7, 7, 0, 7, 14, 'c', 7,21, 7, 'a', 7, 35, 7, 42, 7, 28, STOP};
+int dff[] = { 't', 'f', 0, 0, 't', 'f', 15, 0, STOP};
+int dfi[] = { 't', 'f', 0, 0, 't', 'i', 15, 0, STOP};
+int dfl[] = { 't', 'f', 0, 0, 't', 'l', 15, 0, STOP};
+int dffi[] = { 't', 'f', 0, 0, 't', 'f', 15, 0, 't', 'i', 30, 0, STOP};
+int dffl[] = { 't', 'f', 0, 0, 't', 'f', 15, 0, 't', 'l', 30, 0, STOP};
+int dcent[] = {'a', 15, 20, 25, 17, 25, 13, 'l', 15, 0, 15, 35, STOP};
+int ddegree[] = {'t', 'o', 0, 20, STOP};
+int dhalf[] = {'t', '1', 0, 20, 'l', 0, 0, 30, 40, 't', '2', 15, 0, STOP};
+int dquarter[] = {'t', '1', 0, 20, 'l', 0, 0, 30, 40, 't', '4', 15, 0, STOP};
+int dthreequarter[] = {'t', '3', 0, 20, 'l', 0, 0, 30, 40, 't', '4', 15, 0, STOP};
+int dbell[] = {'l', 0, 10, 40, 10, 'a', 0, 15, 0, 10, 5, 15, 'a', 40, 15, 35, 15, 40, 10,
+'a', 20, 15, 35, 15, 15, 15, 'l', 20, 35, 20, 40, 'l', 20, 0, 20, 10, 'c', 20, 20, 22, STOP};
+int *drawtab[128] = {
+  0,   /*blank*/
+  dpsi,        /*psi*/
+  dtheta,      /*theta*/
+  dnu, /*nu*/
+  dmu, /*mu*/
+  dlambda,     /*lambda*/
+  diota,       /*iota*/
+  dzeta,       /*zeta*/
+  dsigma,      /*sigma*/
+  ddelta,      /*delta*/
+  dbeta,       /*beta*/
+  dxi, /*xi*/
+  deta,        /*eta*/
+  dphi,        /*phi*/
+  0,   /*upsilon ASCII*/
+  dkappa,      /*kappa*/
+  0,   /*blank*/
+  dpi, /*pi*/
+  0,   /* at sign (ASCII) */
+  ddownar,     /*down arrow*/
+  0,   /*blank*/
+  dalpha,      /*alpha*/
+  0,   /*or (ASCII)*/
+  dchi,        /*chi*/
+  0,   /*" (ASCII)*/
+  depsilon,    /*epsilon*/
+  0,   /*= (ASCII)*/
+  0,   /*omicron (ASCII)*/
+  dleftar,     /*left arrow*/
+  drho,        /*rho*/
+  dupar,       /*up arrow*/
+  dtau,        /*tau*/
+  0,   /*underrule (ASCII)*/
+  0,   /*\ (ASCII)*/
+  dPsi,        /*Psi*/
+  dbell,       /*bell system sign*/
+  dinfinity,   /*infinity*/
+  dgamma,      /*gamma*/
+  dimpsupset,  /*improper superset*/
+  dprop,       /*proportional to*/
+  drighth,     /*right hand*/
+  domega,      /*omega*/
+  0,   /*blank*/
+  dgradient,   /*gradient*/
+  0,   /*blank*/
+  dPhi,        /*Phi*/
+  dTheta,      /*Theta*/
+  dOmega,      /*Omega */
+  dcup,        /*cup (union)*/
+  drooten,     /*root en*/
+  dtsigma,     /*terminal sigma*/
+  dLambda,     /*Lambda*/
+  0,           /* some kind of horizontal line (ASCII) */
+  dGamma,      /*Gamma*/
+  dintsign,    /*integral sign*/
+  dPi, /*Pi*/
+  dsubset,     /*subset of*/
+  dsupset,     /*superset of*/
+  dapprox,     /*approximates*/
+  dpartial,    /*partial derivative*/
+  dDelta,      /*Delta*/
+  dsqroot,     /*square root*/
+  dSigma,      /*Sigma*/
+  dappreq,     /* approx equal */
+  0,   /*blank*/
+  0,   /*> (ASCII)*/
+  dXi, /*Xi*/
+  0,   /*< (ASCII)*/
+  0,   /*slash (longer)*/
+  dcap,        /*cap (intersection)*/
+  0,   /*Upsilon (ASCII Y)*/
+  dnot,        /*not*/
+  0,   /*right ceiling (rt of ")*/
+  0,   /*left top (of big curly)*/
+  0,   /*bold vertical*/
+  0,   /*left center of big curly bracket*/
+  0,   /*left bottom*/
+  0,   /*right top*/
+  0,   /*right center of big curly bracket*/
+  0,   /*right bot*/
+  0,   /*right floor (rb of ")*/
+  0,   /*left floor (left bot of big sq bract)*/
+  0,   /*left ceiling (lt of ")*/
+  dmultiply,   /*multiply*/
+  ddivide,     /*divide*/
+  dplmn,       /*plus-minus*/
+  dlesseq,     /*<=*/
+  dgreateq,    /*>=*/
+  dident,      /*identically equal*/
+  dnoteq,      /*not equal*/
+  0,   /*{ (ASCII)*/
+  0,   /*} (ASCII)*/
+  0,   /*' acute accent (ASCII)*/
+  0,   /*` grave accent (ASCII)*/
+  0,   /*^ (ASCII)*/
+  0,   /* sharp (ASCII)*/
+  dlefth,      /*left hand*/
+  depsilon,    /*member of*/
+  0,   /* ~ ASCII*/
+  dempty,      /*empty set*/
+  0,   /*blank*/
+  ddbldag,     /*dbl dagger*/
+  0,   /*box rule ASCII*/
+  0,   /*asterisk (ASCII)*/
+  dimpsubset,  /*improper subset*/
+  dcircle,     /*circle*/
+  0,   /*blank*/
+  0,   /*plus (ASCII)*/
+  drightar,    /*right arrow*/
+  dsection };  /*section mark*/
+int *moretab[128] = {
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       dquarter, /* one quarter 1/4 */
+       0,
+       dhalf, /* one half 1/2 */
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       dthreequarter, /* 3 /4 */
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       dfi,    /* fi */
+       dfl,    /* fl */
+       dff,    /* ff */
+       dcent,  /* cent mark */
+       dffl,   /* ffl */
+       dffi,   /* ffi */
+       0,
+       0,
+       0,
+       0,
+       0,
+       ddagger, /* dagger */
+       0,
+       dregist, /* registered */
+       0,
+       0,
+       0,
+       0,
+       dbullet, /* bullet */
+       0,
+       0,
+       0,
+       0,
+       dcopyr, /* copyright */
+       dsquare, /* square */
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0,
+       0
+       };
diff --git a/usr/src/cmd/pcc/:rofix b/usr/src/cmd/pcc/:rofix
new file mode 100755 (executable)
index 0000000..38e6a92
--- /dev/null
@@ -0,0 +1,5 @@
+ed $1 <<!
+g/^[   ]*\.data/s//.text/
+w
+q
+!
diff --git a/usr/src/cmd/pcc/:yyfix b/usr/src/cmd/pcc/:yyfix
new file mode 100755 (executable)
index 0000000..ba93187
--- /dev/null
@@ -0,0 +1,12 @@
+for i in $*
+do ed y.tab.c <<!
+/^\(.*\)$i[    ]*\[]/s//extern \1 $i[];\\
+\1 $i []/
+.ka
+/}/kb
+'a,'b W rodata.c
+'a,'bd
+w
+q
+!
+done
index e629a37..2d73d51 100644 (file)
@@ -1,28 +1,31 @@
-# include <stdio.h>
-# include <signal.h>
-
 # include "mfile1"
 # include "mfile1"
+#include <a.out.h>
 
 
-int proflag;
-int strftn = 0;        /* is the current function one which returns a value */
-FILE *tmpfile;
-FILE *outfile = stdout;
+int proflg = 0;        /* are we generating profiling code? */
+int strftn = 0;  /* is the current function one which returns a value */
+int gdebug;
+int fdefflag;  /* are we within a function definition ? */
+char NULLNAME[8];
+int labelno;
 
 branch( n ){
        /* output a branch to label n */
        /* exception is an ordinary function branching to retlab: then, return */
        if( n == retlab && !strftn ){
 
 branch( n ){
        /* output a branch to label n */
        /* exception is an ordinary function branching to retlab: then, return */
        if( n == retlab && !strftn ){
-               printf( "       jmp     cret\n" );
+               printf( "       ret\n" );
                }
                }
-       else printf( "  jbr     L%d\n", n );
+       else printf( "  jbr     L%d\n", n );
        }
 
        }
 
-int lastloc = PROG;
+int lastloc = { -1 };
+
+short log2tab[] = {0, 0, 1, 2, 2, 3, 3, 3, 3};
+#define LOG2SZ 9
 
 defalign(n) {
        /* cause the alignment to become a multiple of n */
        n /= SZCHAR;
 
 defalign(n) {
        /* cause the alignment to become a multiple of n */
        n /= SZCHAR;
-       if( lastloc != PROG && n > 1 ) printf( "        .even\n" );
+       if( lastloc != PROG && n > 1 ) printf( "        .align  %d\n", n >= 0 && n < LOG2SZ ? log2tab[n] : 0 );
        }
 
 locctr( l ){
        }
 
 locctr( l ){
@@ -35,24 +38,25 @@ locctr( l ){
        switch( l ){
 
        case PROG:
        switch( l ){
 
        case PROG:
-               outfile = stdout;
                printf( "       .text\n" );
                printf( "       .text\n" );
+               psline();
                break;
 
        case DATA:
        case ADATA:
                break;
 
        case DATA:
        case ADATA:
-               outfile = stdout;
-               if( temp != DATA && temp != ADATA )
-                       printf( "       .data\n" );
+               printf( "       .data\n" );
                break;
 
        case STRNG:
                break;
 
        case STRNG:
+               printf( "       .data   1\n" );
+               break;
+
        case ISTRNG:
        case ISTRNG:
-               outfile = tmpfile;
+               printf( "       .data   2\n" );
                break;
 
        case STAB:
                break;
 
        case STAB:
-               cerror( "locctr: STAB unused" );
+               printf( "       .stab\n" );
                break;
 
        default:
                break;
 
        default:
@@ -64,7 +68,7 @@ locctr( l ){
 
 deflab( n ){
        /* output something to define the current position as label n */
 
 deflab( n ){
        /* output something to define the current position as label n */
-       fprintf( outfile, "L%d:\n", n );
+       printf( "L%d:\n", n );
        }
 
 int crslab = 10;
        }
 
 int crslab = 10;
@@ -74,33 +78,57 @@ getlab(){
        return( ++crslab );
        }
 
        return( ++crslab );
        }
 
+
+int ent_mask[] = {
+       0,0,0,0,0, 0xfc0, 0xf80, 0xf00, 0xe00, 0xc00, 0x800, 0};
+
+int reg_use = 11;
+
 efcode(){
        /* code for the end of a function */
 
 efcode(){
        /* code for the end of a function */
 
-       if( strftn ){  /* copy output (in r0) to caller */
+       if( strftn ){  /* copy output (in R2) to caller */
+               register NODE *l, *r;
                register struct symtab *p;
                register struct symtab *p;
-               register int stlab;
-               register int count;
-               int size;
+               register TWORD t;
+               register int j;
+               int i;
 
                p = &stab[curftn];
 
                p = &stab[curftn];
+               t = p->stype;
+               t = DECREF(t);
 
                deflab( retlab );
 
 
                deflab( retlab );
 
-               stlab = getlab();
-               printf( "       mov     $L%d,r1\n", stlab );
-               size = tsize( DECREF(p->stype), p->dimoff, p->sizoff ) / SZCHAR;
-               count = size/2;
-               while( count-- ) {
-                       printf( "       mov     (r0)+,(r1)+\n" );
-                       }
-               printf( "       mov     $L%d,r0\n", stlab );
-               printf( "       .bss\nL%d:      .=.+%d.\n       .text\n", stlab, size );
+               i = getlab();   /* label for return area */
+               printf("        .data\n" );
+               printf("        .align  2\n" );
+               printf("L%d:    .space  %d\n", i, tsize(t, p->dimoff, p->sizoff)/SZCHAR );
+               printf("        .text\n" );
+               psline();
+               printf("        movab   L%d,r1\n", i);
+
+               reached = 1;
+               l = block( REG, NIL, NIL, PTR|t, p->dimoff, p->sizoff );
+               l->rval = 1;  /* R1 */
+               l->lval = 0;  /* no offset */
+               r = block( REG, NIL, NIL, PTR|t, p->dimoff, p->sizoff );
+               r->rval = 0;  /* R0 */
+               r->lval = 0;
+               l = buildtree( UNARY MUL, l, NIL );
+               r = buildtree( UNARY MUL, r, NIL );
+               l = buildtree( ASSIGN, l, r );
+               l->op = FREE;
+               ecomp( l->left );
+               printf( "       movab   L%d,r0\n", i );
                /* turn off strftn flag, so return sequence will be generated */
                strftn = 0;
                }
        branch( retlab );
                /* turn off strftn flag, so return sequence will be generated */
                strftn = 0;
                }
        branch( retlab );
+       printf( "       .set    .R%d,0x%x\n", ftnno, ent_mask[reg_use] );
+       reg_use = 11;
        p2bend();
        p2bend();
+       fdefflag = 0;
        }
 
 bfcode( a, n ) int a[]; {
        }
 
 bfcode( a, n ) int a[]; {
@@ -110,28 +138,37 @@ bfcode( a, n ) int a[]; {
        register temp;
        register struct symtab *p;
        int off;
        register temp;
        register struct symtab *p;
        int off;
+       char *toreg();
 
        locctr( PROG );
        p = &stab[curftn];
 
        locctr( PROG );
        p = &stab[curftn];
+       printf( "       .align  1\n");
        defnam( p );
        temp = p->stype;
        temp = DECREF(temp);
        strftn = (temp==STRTY) || (temp==UNIONTY);
 
        retlab = getlab();
        defnam( p );
        temp = p->stype;
        temp = DECREF(temp);
        strftn = (temp==STRTY) || (temp==UNIONTY);
 
        retlab = getlab();
-       if( proflag ){
-               int plab;
-               plab = getlab();
-               printf( "       mov     $L%d,r0\n", plab );
-               printf( "       jsr     pc,mcount\n" );
-               printf( "       .bss\nL%d:      .=.+2\n .text\n", plab );
-               }
 
        /* routine prolog */
 
 
        /* routine prolog */
 
-       printf( "       jsr     r5,csv\n" );
-       /* adjust stack for autos */
-       printf( "       sub     $.F%d,sp\n", ftnno );
+       printf( "       .word   .R%d\n", ftnno);
+       if (gdebug) {
+               pstab(NULLNAME, N_SLINE);
+               printf("0,%d,LL%d\n", lineno, labelno);
+               printf("LL%d:\n", labelno++);
+       }
+       printf( "       subl2   $.F%d,sp\n", ftnno);
+       if( proflg ) {  /* profile code */
+               i = getlab();
+               printf("        movab   L%d,r0\n", i);
+               printf("        jsb     mcount\n");
+               printf("        .data\n");
+               printf("        .align  2\n");
+               printf("L%d:    .long   0\n", i);
+               printf("        .text\n");
+               psline();
+               }
 
        off = ARGINIT;
 
 
        off = ARGINIT;
 
@@ -142,7 +179,7 @@ bfcode( a, n ) int a[]; {
                        p->sclass = PARAM;  /* forget that it is a register */
                        p->offset = NOOFFSET;
                        oalloc( p, &off );
                        p->sclass = PARAM;  /* forget that it is a register */
                        p->offset = NOOFFSET;
                        oalloc( p, &off );
-                       printf( "       mov     %d.(r5),r%d\n", p->offset/SZCHAR, temp );
+/*tbl*/                printf( "       %s      %d(ap),r%d\n", toreg(p->stype), p->offset/SZCHAR, temp );
                        p->offset = temp;  /* remember register number */
                        p->sclass = REGISTER;   /* remember that it is a register */
                        }
                        p->offset = temp;  /* remember register number */
                        p->sclass = REGISTER;   /* remember that it is a register */
                        }
@@ -151,6 +188,7 @@ bfcode( a, n ) int a[]; {
                        }
 
                }
                        }
 
                }
+       fdefflag = 1;
        }
 
 bccode(){ /* called just before the first executable statment */
        }
 
 bccode(){ /* called just before the first executable statment */
@@ -158,6 +196,7 @@ bccode(){ /* called just before the first executable statment */
        SETOFF( autooff, SZINT );
        /* set aside store area offset */
        p2bbeg( autooff, regvar );
        SETOFF( autooff, SZINT );
        /* set aside store area offset */
        p2bbeg( autooff, regvar );
+       reg_use = (reg_use > regvar ? regvar : reg_use);
        }
 
 ejobcode( flag ){
        }
 
 ejobcode( flag ){
@@ -193,30 +232,22 @@ bycode( t, i ){
 
        i &= 07;
        if( t < 0 ){ /* end of the string */
 
        i &= 07;
        if( t < 0 ){ /* end of the string */
-               if( i != 0 ) fprintf( outfile, "\n" );
+               if( i != 0 ) printf( "\n" );
                }
 
        else { /* stash byte t into string */
                }
 
        else { /* stash byte t into string */
-               if( i == 0 ) fprintf( outfile, "        .byte   " );
-               else fprintf( outfile, "," );
-               fprintf( outfile, "%o", t );
-               if( i == 07 ) fprintf( outfile, "\n" );
+               if( i == 0 ) printf( "  .byte   " );
+               else printf( "," );
+               printf( "0x%x", t );
+               if( i == 07 ) printf( "\n" );
                }
        }
 
 zecode( n ){
        /* n integer words of zeros */
        OFFSZ temp;
                }
        }
 
 zecode( n ){
        /* n integer words of zeros */
        OFFSZ temp;
-       register i;
-
        if( n <= 0 ) return;
        if( n <= 0 ) return;
-       printf( "       " );
-       for( i=1; i<n; i++ ) {
-               if( i%8 == 0 )
-                       printf( "\n     " );
-               printf( "0; " );
-               }
-       printf( "0\n" );
+       printf( "       .space  %d\n", (SZINT/SZCHAR)*n );
        temp = n;
        inoff += temp*SZINT;
        }
        temp = n;
        inoff += temp*SZINT;
        }
@@ -232,44 +263,50 @@ fldty( p ) struct symtab *p; { /* fix up type of field p */
 
 where(c){ /* print location of error  */
        /* c is either 'u', 'c', or 'w' */
 
 where(c){ /* print location of error  */
        /* c is either 'u', 'c', or 'w' */
+       /* GCOS version */
        fprintf( stderr, "%s, line %d: ", ftitle, lineno );
        }
 
        fprintf( stderr, "%s, line %d: ", ftitle, lineno );
        }
 
-char *tmpname = "/tmp/pcXXXXXX";
 
 
-main( argc, argv ) char *argv[]; {
-       int dexit();
-       register int c;
-       register int i;
-       int r;
-
-       for( i=1; i<argc; ++i )
-               if( argv[i][0] == '-' && argv[i][1] == 'X' && argv[i][2] == 'p' ) {
-                       proflag = 1;
-                       }
+/* tbl - toreg() returns a pointer to a char string
+                 which is the correct  "register move" for the passed type 
+ */
+struct type_move {TWORD fromtype; char tostrng[8];} toreg_strs[] =
+       {
+       CHAR, "cvtbl",
+       SHORT, "cvtwl",
+       INT, "movl",
+       LONG, "movl",
+       FLOAT, "movf",
+       DOUBLE, "movd",
+       UCHAR,  "movzbl",
+       USHORT, "movzwl",
+       UNSIGNED,       "movl",
+       ULONG,  "movl",
+       -1, ""
+       };
+
+char
+*toreg(type)
+       TWORD type;
+{
+       struct type_move *p;
+
+       for ( p=toreg_strs; p->fromtype > 0; p++)
+               if (p->fromtype == type) return(p->tostrng);
+
+       /* type not found, must be a pointer type */
+       return("movl");
+}
+/* tbl */
 
 
-       mktemp(tmpname);
-       if(signal( SIGHUP, SIG_IGN) != SIG_IGN) signal(SIGHUP, dexit);
-       if(signal( SIGINT, SIG_IGN) != SIG_IGN) signal(SIGINT, dexit);
-       if(signal( SIGTERM, SIG_IGN) != SIG_IGN) signal(SIGTERM, dexit);
-       tmpfile = fopen( tmpname, "w" );
-
-       r = mainp1( argc, argv );
-
-       tmpfile = freopen( tmpname, "r", tmpfile );
-       if( tmpfile != NULL )
-               while((c=getc(tmpfile)) != EOF )
-                       putchar(c);
-       else cerror( "Lost temp file" );
-       unlink(tmpname);
-       return( r );
-       }
 
 
-dexit( v ) {
-       unlink(tmpname);
-       exit(1);
+main( argc, argv ) char *argv[]; {
+       return(mainp1( argc, argv ));
        }
 
        }
 
+struct sw heapsw[SWITSZ];      /* heap for switches */
+
 genswitch(p,n) register struct sw *p;{
        /*      p points to an array of structures, each consisting
                of a constant value and a label.
 genswitch(p,n) register struct sw *p;{
        /*      p points to an array of structures, each consisting
                of a constant value and a label.
@@ -285,41 +322,36 @@ genswitch(p,n) register struct sw *p;{
 
        if( range>0 && range <= 3*n && n>=4 ){ /* implement a direct switch */
 
 
        if( range>0 && range <= 3*n && n>=4 ){ /* implement a direct switch */
 
+               swlab = getlab();
                dlab = p->slab >= 0 ? p->slab : getlab();
 
                dlab = p->slab >= 0 ? p->slab : getlab();
 
-               if( p[1].sval ){
-                       printf( "       sub     $" );
-                       printf( CONFMT, p[1].sval );
-                       printf( ".,r0\n" );
+               /* already in r0 */
+               printf("        casel   r0,$%ld,$%ld\n", p[1].sval, range);
+               printf("L%d:\n", swlab);
+               for( i=1,j=p[1].sval; i<=n; j++) {
+                       printf("        .word   L%d-L%d\n", (j == p[i].sval ? ((j=p[i++].sval), p[i-1].slab) : dlab),
+                               swlab);
                        }
 
                        }
 
-               /* note that this is a cl; it thus checks
-                  for numbers below range as well as out of range.
-                  */
-               printf( "       cmp     r0,$%ld.\n", range );
-               printf( "       jhi     L%d\n", dlab );
-
-               printf( "       asl     r0\n" );
-               printf( "       jmp     *L%d(r0)\n", swlab = getlab() );
-
-               /* output table */
+               if( p->slab >= 0 ) branch( dlab );
+               else printf("L%d:\n", dlab);
+               return;
 
 
-               locctr( ADATA );
-               defalign( ALPOINT );
-               deflab( swlab );
+               }
 
 
-               for( i=1,j=p[1].sval; i<=n; ++j ){
+       if( n>8 ) {     /* heap switch */
 
 
-                       printf( "       L%d\n", ( j == p[i].sval ) ?
-                               p[i++].slab : dlab );
-                       }
+               heapsw[0].slab = dlab = p->slab >= 0 ? p->slab : getlab();
+               makeheap(p, n, 1);      /* build heap */
 
 
-               locctr( PROG );
+               walkheap(1, n); /* produce code */
 
 
-               if( p->slab< 0 ) deflab( dlab );
+               if( p->slab >= 0 )
+                       branch( dlab );
+               else
+                       printf("L%d:\n", dlab);
                return;
                return;
-
-               }
+       }
 
        /* debugging code */
 
 
        /* debugging code */
 
@@ -332,10 +364,54 @@ genswitch(p,n) register struct sw *p;{
        for( i=1; i<=n; ++i ){
                /* already in r0 */
 
        for( i=1; i<=n; ++i ){
                /* already in r0 */
 
-               printf( "       cmp     r0,$" );
+               printf( "       cmpl    r0,$" );
                printf( CONFMT, p[i].sval );
                printf( CONFMT, p[i].sval );
-               printf( ".\n    jeq     L%d\n", p[i].slab );
+               printf( "\n     jeql    L%d\n", p[i].slab );
                }
 
        if( p->slab>=0 ) branch( p->slab );
        }
                }
 
        if( p->slab>=0 ) branch( p->slab );
        }
+
+makeheap(p, m, n)
+register struct sw *p;
+{
+       register int q;
+
+       q = select(m);
+       heapsw[n] = p[q];
+       if( q>1 ) makeheap(p, q-1, 2*n);
+       if( q<m ) makeheap(p+q, m-q, 2*n+1);
+}
+
+select(m) {
+       register int l,i,k;
+
+       for(i=1; ; i*=2)
+               if( (i-1) > m ) break;
+       l = ((k = i/2 - 1) + 1)/2;
+       return( l + (m-k < l ? m-k : l));
+}
+
+walkheap(start, limit)
+{
+       int label;
+
+
+       if( start > limit ) return;
+       printf("        cmpl    r0,$%d\n",  heapsw[start].sval);
+       printf("        jeql    L%d\n", heapsw[start].slab);
+       if( (2*start) > limit ) {
+               printf("        jbr     L%d\n", heapsw[0].slab);
+               return;
+       }
+       if( (2*start+1) <= limit ) {
+               label = getlab();
+               printf("        jgtr    L%d\n", label);
+       } else
+               printf("        jgtr    L%d\n", heapsw[0].slab);
+       walkheap( 2*start, limit);
+       if( (2*start+1) <= limit ) {
+               printf("L%d:\n", label);
+               walkheap( 2*start+1, limit);
+       }
+}
diff --git a/usr/src/cmd/pcc/err b/usr/src/cmd/pcc/err
new file mode 100644 (file)
index 0000000..f95dfea
--- /dev/null
@@ -0,0 +1,58 @@
+yacc /usr/vaxv7/usr/src/cmd/mip/cgram.y
+
+conflicts: 7 shift/reduce
+rm -f rodata.c
+:yyfix yyexca yyact yypact yypgo yyr1 yyr2 yychk yydef
+43220
+365
+42881
+42881
+6305
+36601
+36601
+1716
+34911
+34911
+333
+34603
+34603
+959
+33668
+33668
+959
+32733
+32733
+1603
+31155
+31155
+1602
+29578
+mv y.tab.c /usr/vaxv7/usr/src/cmd/mip/cgram.c
+cc -O -S rodata.c
+:rofix rodata.s
+32882
+32882
+as -o rodata.o rodata.s
+rm -f rodata.s rodata.c
+cc -c -O -I/usr/vaxv7/usr/src/cmd/mip -I. /usr/vaxv7/usr/src/cmd/mip/cgram.c
+cc -c -O -I/usr/vaxv7/usr/src/cmd/mip -I. /usr/vaxv7/usr/src/cmd/mip/xdefs.c
+cc -c -O -I/usr/vaxv7/usr/src/cmd/mip -I. /usr/vaxv7/usr/src/cmd/mip/scan.c
+cc -c -O -I/usr/vaxv7/usr/src/cmd/mip -I. /usr/vaxv7/usr/src/cmd/mip/pftn.c
+cc -c -O -I/usr/vaxv7/usr/src/cmd/mip -I. /usr/vaxv7/usr/src/cmd/mip/trees.c
+cc -c -O -I/usr/vaxv7/usr/src/cmd/mip -I. /usr/vaxv7/usr/src/cmd/mip/optim.c
+cc -c -O -I/usr/vaxv7/usr/src/cmd/mip -I. code.c
+cc -c -O -I/usr/vaxv7/usr/src/cmd/mip -I. local.c
+cc -c -O -I/usr/vaxv7/usr/src/cmd/mip -I. /usr/vaxv7/usr/src/cmd/mip/reader.c
+cc -c -O -I/usr/vaxv7/usr/src/cmd/mip -I. local2.c
+cc -c -O -I/usr/vaxv7/usr/src/cmd/mip -I. order.c
+cc -c -O -I/usr/vaxv7/usr/src/cmd/mip -I. /usr/vaxv7/usr/src/cmd/mip/match.c
+cc -c -O -I/usr/vaxv7/usr/src/cmd/mip -I. /usr/vaxv7/usr/src/cmd/mip/allo.c
+cc -c -O -I. -I/usr/vaxv7/usr/src/cmd/mip /usr/vaxv7/usr/src/cmd/mip/comm1.c
+cc -O -S -I/usr/vaxv7/usr/src/cmd/mip -I. table.c
+:rofix table.s
+20034
+20034
+as -o table.o table.s
+rm -f table.s
+cc -O -i rodata.o cgram.o xdefs.o scan.o pftn.o trees.o optim.o code.o local.o  reader.o local2.o order.o match.o allo.o comm1.o table.o
+mv a.out comp
diff --git a/usr/src/cmd/pcc/fort.h b/usr/src/cmd/pcc/fort.h
new file mode 100644 (file)
index 0000000..826f036
--- /dev/null
@@ -0,0 +1,11 @@
+
+/*     machine dependent file  */
+
+label( n ){
+       printf( "L%d:\n", n );
+       }
+
+tlabel(){
+       lccopy( 2 );
+       printf( ":\n" );
+       }
index c9fe72f..7d4aaa7 100644 (file)
@@ -1,6 +1,5 @@
 # include "mfile1"
 
 # include "mfile1"
 
-
 /*     this file contains code which is dependent on the target machine */
 
 NODE *
 /*     this file contains code which is dependent on the target machine */
 
 NODE *
@@ -67,21 +66,15 @@ clocal(p) NODE *p; {
 
                        }
                break;
 
                        }
                break;
-       case LT:
-       case LE:
-       case GT:
-       case GE:
-               if( ISPTR( p->left->type ) || ISPTR( p->right->type ) ){
-                       p->op += (ULT-LT);
-                       }
-               break;
 
        case PCONV:
                /* do pointer conversions for char and longs */
                ml = p->left->type;
 
        case PCONV:
                /* do pointer conversions for char and longs */
                ml = p->left->type;
-               if( ( ml==CHAR || ml==UCHAR || ml==LONG || ml==ULONG ) && p->left->op != ICON ) break;
+               if( ( ml==CHAR || ml==UCHAR || ml==SHORT || ml==USHORT ) && p->left->op != ICON ) break;
 
                /* pointers all have the same representation; the type is inherited */
 
                /* pointers all have the same representation; the type is inherited */
+
+       inherit:
                p->left->type = p->type;
                p->left->cdim = p->cdim;
                p->left->csiz = p->csiz;
                p->left->type = p->type;
                p->left->cdim = p->cdim;
                p->left->csiz = p->csiz;
@@ -107,9 +100,15 @@ clocal(p) NODE *p; {
                        case UCHAR:
                                p->left->lval = val & 0XFF;
                                break;
                        case UCHAR:
                                p->left->lval = val & 0XFF;
                                break;
-                       case UNSIGNED:
+                       case USHORT:
                                p->left->lval = val & 0XFFFFL;
                                break;
                                p->left->lval = val & 0XFFFFL;
                                break;
+                       case SHORT:
+                               p->left->lval = (short)val;
+                               break;
+                       case UNSIGNED:
+                               p->left->lval = val & 0xFFFFFFFFL;
+                               break;
                        case INT:
                                p->left->lval = (int)val;
                                break;
                        case INT:
                                p->left->lval = (int)val;
                                break;
@@ -120,51 +119,32 @@ clocal(p) NODE *p; {
                        /* meaningful ones are conversion of int to char, int to short,
                           and short to char, and unsigned version of them */
                        if( m==CHAR || m==UCHAR ){
                        /* meaningful ones are conversion of int to char, int to short,
                           and short to char, and unsigned version of them */
                        if( m==CHAR || m==UCHAR ){
-                               if( ml==LONG || ml==ULONG ) break;
+                               if( ml!=CHAR && ml!= UCHAR ) break;
                                }
                                }
-                       else if( m==INT || m==UNSIGNED ){
-                               if( ml==LONG || ml==ULONG ) break;
-                               }
-                       else if( m==LONG || m==ULONG ){
-                               if( ml!=LONG && ml!= ULONG ) break;
+                       else if( m==SHORT || m==USHORT ){
+                               if( ml!=CHAR && ml!=UCHAR && ml!=SHORT && ml!=USHORT ) break;
                                }
                        }
 
                /* clobber conversion */
                                }
                        }
 
                /* clobber conversion */
+               if( tlen(p) == tlen(p->left) ) goto inherit;
                p->op = FREE;
                return( p->left );  /* conversion gets clobbered */
 
                p->op = FREE;
                return( p->left );  /* conversion gets clobbered */
 
-       case ASSIGN:
-               /* get rid of SCONV for assignments
-                  from LONG -> CHAR|INT        */
-               if( p->right->op == SCONV ) {
-                       m = p->right->type;
-                       ml = p->right->left->type;
-                       if( ( m==LONG || m==ULONG ) &&
-                           ml!=FLOAT && ml!=DOUBLE ) {
-                               p->right->op = FREE;
-                               p->right = p->right->left;
-                               }
-                       }
-               break;
-
        case PVCONV:
        case PMCONV:
                if( p->right->op != ICON ) cerror( "bad conversion", 0);
                p->op = FREE;
                return( buildtree( o==PMCONV?MUL:DIV, p->left, p->right ) );
 
        case PVCONV:
        case PMCONV:
                if( p->right->op != ICON ) cerror( "bad conversion", 0);
                p->op = FREE;
                return( buildtree( o==PMCONV?MUL:DIV, p->left, p->right ) );
 
-       case PLUS:
-       case MINUS:
-       case LS:
-       case MUL:
-               /* optimize address calculations with long indexes */
-               if( ISPTR( p->type ) || ISARY( p->type ) ) {
-                       if( p->left->type==LONG || p->left->type==ULONG )
-                               p->left = cast( p->left, INT );
-                       if( p->right->type==LONG || p->right->type==ULONG )
-                               p->right = cast( p->right, INT );
-                       }
+       case RS:
+       case ASG RS:
+               /* convert >> to << with negative shift count */
+               /* only if type of left operand is not unsigned */
+               if( ISUNSIGNED(p->left->type) ) break;
+               p->right = buildtree( UNARY MINUS, p->right, NIL );
+               if( p->op == RS ) p->op = LS;
+               else p->op = ASG LS;
                break;
 
                }
                break;
 
                }
@@ -182,7 +162,9 @@ cendarg(){ /* at the end of the arguments of a ftn, set the automatic offset */
 
 cisreg( t ) TWORD t; { /* is an automatic variable of type t OK for a register variable */
 
 
 cisreg( t ) TWORD t; { /* is an automatic variable of type t OK for a register variable */
 
-       if( t==INT || t==UNSIGNED || ISPTR(t) ) return(1);
+       if( t==INT || t==UNSIGNED || t==LONG || t==ULONG        /* tbl */
+               || t==CHAR || t==UCHAR || t==SHORT || t==USHORT /* tbl */
+               || ISPTR(t)) return(1);                 /* tbl */
        return(0);
        }
 
        return(0);
        }
 
@@ -204,8 +186,6 @@ offcon( off, t, d, s ) OFFSZ off; TWORD t; {
 
        }
 
 
        }
 
-static inwd    /* current bit offsed in word */;
-static word    /* word being built from fields */;
 
 incode( p, sz ) register NODE *p; {
 
 
 incode( p, sz ) register NODE *p; {
 
@@ -215,14 +195,13 @@ incode( p, sz ) register NODE *p; {
        /* inoff is updated to have the proper final value */
        /* we also assume sz  < SZINT */
 
        /* inoff is updated to have the proper final value */
        /* we also assume sz  < SZINT */
 
-       if((sz+inwd) > SZINT) cerror("incode: field > int");
-       word |= p->lval<<inwd;
-       inwd += sz;
        inoff += sz;
        inoff += sz;
-       if(inoff%SZINT == 0) {
-               printf( "       %o\n", word);
-               word = inwd = 0;
-               }
+       if (sz>SZSHORT) 
+               printf("        .long   %d:%d\n", sz, p->lval);
+       else if (sz>SZCHAR)
+               printf("        .word   %d:%d\n", sz, p->lval);
+       else
+               printf("        .byte   %d:%d\n", sz, p->lval);
        }
 
 fincode( d, sz ) double d; {
        }
 
 fincode( d, sz ) double d; {
@@ -231,12 +210,9 @@ fincode( d, sz ) double d; {
        /* inoff is updated to have the proper final value */
        /* on the target machine, write it out in octal! */
 
        /* inoff is updated to have the proper final value */
        /* on the target machine, write it out in octal! */
 
-       register int *mi = (int *)&d;
 
 
-       if( sz==SZDOUBLE )
-               printf( "       %o; %o; %o; %o\n", mi[0], mi[1], mi[2], mi[3] );
-       else
-               printf( "       %o; %o\n", mi[0], mi[1] );
+       printf("        %s      0%c%.20e\n", sz == SZDOUBLE ? ".double" : ".float",
+               sz == SZDOUBLE ? 'd' : 'f', d);
        inoff += sz;
        }
 
        inoff += sz;
        }
 
@@ -250,15 +226,17 @@ cinit( p, sz ) NODE *p; {
        }
 
 vfdzero( n ){ /* define n bits of zeros in a vfd */
        }
 
 vfdzero( n ){ /* define n bits of zeros in a vfd */
+       register i;
 
        if( n <= 0 ) return;
 
 
        if( n <= 0 ) return;
 
-       inwd += n;
        inoff += n;
        inoff += n;
-       if( inoff%ALINT ==0 ) {
-               printf( "       %o\n", word );
-               word = inwd = 0;
-               }
+       i = n;
+       while (i>=SZCHAR) {
+               printf("        .byte   0\n");
+               i -= SZCHAR;
+       }
+       if (i) printf(" .byte   %d:0\n", i);
        }
 
 
        }
 
 
@@ -281,18 +259,20 @@ exname( p ) char *p; {
        return( text );
        }
 
        return( text );
        }
 
-ctype( type ) TWORD type; { /* map types which are not defined on the local machine */
+ctype( type ){ /* map types which are not defined on the local machine */
        switch( BTYPE(type) ){
        switch( BTYPE(type) ){
-       case SHORT:
+
+       case LONG:
                MODTYPE(type,INT);
                break;
                MODTYPE(type,INT);
                break;
-       case USHORT:
+
+       case ULONG:
                MODTYPE(type,UNSIGNED);
                }
        return( type );
        }
 
                MODTYPE(type,UNSIGNED);
                }
        return( type );
        }
 
-noinit() { /* curid is a variable which is defined but
+noinit( t ) { /* curid is a variable which is defined but
        is not initialized (and not a function );
        This routine returns the stroage class for an uninitialized declaration */
 
        is not initialized (and not a function );
        This routine returns the stroage class for an uninitialized declaration */
 
@@ -302,13 +282,13 @@ noinit() { /* curid is a variable which is defined but
 
 commdec( id ){ /* make a common declaration for id, if reasonable */
        register struct symtab *q;
 
 commdec( id ){ /* make a common declaration for id, if reasonable */
        register struct symtab *q;
-       OFFSZ off;
+       OFFSZ off, tsize();
 
        q = &stab[id];
        printf( "       .comm   %s,", exname( q->sname ) );
        off = tsize( q->stype, q->dimoff, q->sizoff );
        printf( CONFMT, off/SZCHAR );
 
        q = &stab[id];
        printf( "       .comm   %s,", exname( q->sname ) );
        off = tsize( q->stype, q->dimoff, q->sizoff );
        printf( CONFMT, off/SZCHAR );
-       printf( ".\n" );
+       printf( "\n" );
        }
 
 isitlong( cb, ce ){ /* is lastcon to be long or short */
        }
 
 isitlong( cb, ce ){ /* is lastcon to be long or short */
@@ -334,4 +314,180 @@ ecode( p ) NODE *p; {
        p2tree( p );
        p2compile( p );
        }
        p2tree( p );
        p2compile( p );
        }
+       
+#include "a.out.h"
+int ddebug;
+int gdebug;
+
+
+outstab(p)
+struct symtab *p; {
+       register TWORD ptype;
+       register char *pname;
+       register char pclass;
+       register int poffset;
+
+       if (!gdebug) return;
 
 
+       ptype = p->stype;
+       pname = p->sname;
+       pclass = p->sclass;
+       poffset = p->offset;
+
+       if (ISFTN(ptype)) {
+               return;
+       }
+       
+       switch (pclass) {
+       
+       case AUTO:
+               pstab(pname, N_LSYM);
+               printf("0,%d,%d\n", ptype, (-poffset)/SZCHAR);
+               poffs(p);
+               return;
+       
+       case EXTDEF:
+       case EXTERN:
+               pstab(pname, N_GSYM);
+               printf("0,%d,0\n", ptype);
+               poffs(p);
+               return;
+                       
+       case STATIC:
+               pstab(pname, N_STSYM);
+               if (p->slevel > 1) {
+                       printf("0,%d,L%d\n", ptype, poffset);
+               } else {
+                       printf("0,%d,%s\n", ptype, exname(pname));
+               }
+               poffs(p);
+               return;
+       
+       case REGISTER:
+               pstab(pname, N_RSYM);
+               printf("0,%d,%d\n", ptype, poffset);
+               poffs(p);
+               return;
+       
+       case MOS:
+       case MOU:
+               pstab(pname, N_SSYM);
+               printf("0,%d,%d\n", ptype, poffset/SZCHAR);
+               poffs(p);
+               return;
+       
+       case PARAM:
+               /* parameter stab entries are processed in dclargs() */
+               return;
+       
+       default:
+               if (ddebug) printf("    No .stab for %.8s\n", pname);
+       }
+}
+
+pstab(name, type)
+char *name;
+int type; {
+       register int i;
+       register char c;
+       if (!gdebug) return;
+       printf("        .stab   ");
+       for(i=0; i<8; i++) 
+               if (c = name[i]) printf("'%c,", c);
+               else printf("0,");
+       printf("0%o,", type);
+}
+
+poffs(p)
+register struct symtab *p; {
+       int s;
+       if (!gdebug) return;
+       if ((s = dimtab[p->sizoff]/SZCHAR) > 1) {
+               pstab(p->sname, N_LENG);
+               printf("1,0,%d\n", s);
+       }
+}
+
+char NULLNAME[8];
+int  labelno;
+int  fdefflag;
+
+psline() {
+       static int lastlineno;
+       register char *cp, *cq;
+       register int i;
+       
+       if (!gdebug) return;
+
+       cq = ititle;
+       cp = ftitle;
+
+       while ( *cq ) if ( *cp++ != *cq++ ) goto neq;
+       if ( *cp == '\0' ) goto eq;
+       
+neq:   for (i=0; i<100; i++)
+               ititle[i] = '\0';
+       cp = ftitle;
+       cq = ititle;
+       while ( *cp )  
+               *cq++ = *cp++;
+       *cq = '\0';
+       *--cq = '\0';
+       for ( cp = ititle+1; *(cp-1); cp += 8 ) {
+               pstab(cp, N_SOL);
+               if (gdebug) printf("0,0,LL%d\n", labelno);
+               }
+       *cq = '"';
+       printf("LL%d:\n", labelno++);
+
+eq:    if (lineno == lastlineno) return;
+       lastlineno = lineno;
+
+       if (fdefflag) {
+               pstab(NULLNAME, N_SLINE);
+               printf("0,%d,LL%d\n", lineno, labelno);
+               printf("LL%d:\n", labelno++);
+               }
+       }
+       
+plcstab(level) {
+       if (!gdebug) return;
+       pstab(NULLNAME, N_LBRAC);
+       printf("0,%d,LL%d\n", level, labelno);
+       printf("LL%d:\n", labelno++);
+       }
+       
+prcstab(level) {
+       if (!gdebug) return;
+       pstab(NULLNAME, N_RBRAC);
+       printf("0,%d,LL%d\n", level, labelno);
+       printf("LL%d:\n", labelno++);
+       }
+       
+pfstab(sname) 
+char *sname; {
+       if (!gdebug) return;
+       pstab(sname, N_FUN);
+       printf("0,%d,_%.7s\n", lineno, sname);
+}
+
+#ifndef ONEPASS
+tlen(p) NODE *p; 
+{
+       switch(p->type) {
+               case CHAR:
+               case UCHAR:
+                       return(1);
+                       
+               case SHORT:
+               case USHORT:
+                       return(2);
+                       
+               case DOUBLE:
+                       return(8);
+                       
+               default:
+                       return(4);
+               }
+       }
+#endif
index bd5de34..45b8abd 100644 (file)
@@ -1,11 +1,16 @@
 # include "mfile2"
 # include "mfile2"
+# include "ctype.h"
 /* a lot of the machine dependent parts of the second pass */
 
 # define BITMASK(n) ((1L<<n)-1)
 
 /* a lot of the machine dependent parts of the second pass */
 
 # define BITMASK(n) ((1L<<n)-1)
 
+where(c){
+       fprintf( stderr, "%s, line %d: ", filename, lineno );
+       }
+
 lineid( l, fn ) char *fn; {
        /* identify line l and file fn */
 lineid( l, fn ) char *fn; {
        /* identify line l and file fn */
-       printf( "/      line %d, file %s\n", l, fn );
+       printf( "#      line %d, file %s\n", l, fn );
        }
 
 eobl2(){
        }
 
 eobl2(){
@@ -14,27 +19,27 @@ eobl2(){
        spoff = maxoff;
        if( spoff >= AUTOINIT ) spoff -= AUTOINIT;
        spoff /= SZCHAR;
        spoff = maxoff;
        if( spoff >= AUTOINIT ) spoff -= AUTOINIT;
        spoff /= SZCHAR;
-       SETOFF(spoff,2);
-       printf( "       .F%d = %Ld.\n", ftnno, spoff );
-       if( fltused ) {
-               fltused = 0;
-               printf( "       .globl  fltused\n" );
-               }
+       SETOFF(spoff,4);
+       printf( "       .set    .F%d,%Ld\n", ftnno, spoff );
+       maxargs = -1;
        }
 
        }
 
-struct hoptab { int opmask; char * opstring; } ioptab[]= {
+struct hoptab { int opmask; char * opstring; } ioptab[] = {
 
        ASG PLUS, "add",
        ASG MINUS, "sub",
 
        ASG PLUS, "add",
        ASG MINUS, "sub",
-       ASG OR, "bis",
-       ASG AND,        "bic",
-       ASG ER, "xor",
        ASG MUL, "mul",
        ASG DIV, "div",
        ASG MUL, "mul",
        ASG DIV, "div",
-       ASG MOD, "div",
-       ASG LS, "asl",
-       ASG RS, "asr",
-
+       ASG OR, "bis",
+       ASG ER, "xor",
+       ASG AND, "bic",
+       PLUS,   "add",
+       MINUS,  "sub",
+       MUL,    "mul",
+       DIV,    "div",
+       OR,     "bis",
+       ER,     "xor",
+       AND,    "bic",
        -1, ""    };
 
 hopcode( f, o ){
        -1, ""    };
 
 hopcode( f, o ){
@@ -45,7 +50,22 @@ hopcode( f, o ){
        for( q = ioptab;  q->opmask>=0; ++q ){
                if( q->opmask == o ){
                        printf( "%s", q->opstring );
        for( q = ioptab;  q->opmask>=0; ++q ){
                if( q->opmask == o ){
                        printf( "%s", q->opstring );
-                       if( f == 'F' ) printf( "f" );
+/* tbl
+                       if( f == 'F' ) printf( "e" );
+                       else if( f == 'D' ) printf( "d" );
+   tbl */
+/* tbl */
+                       switch( f ) {
+                               case 'L':
+                               case 'W':
+                               case 'B':
+                               case 'D':
+                               case 'F':
+                                       printf("%c", tolower(f));
+                                       break;
+
+                               }
+/* tbl */
                        return;
                        }
                }
                        return;
                        }
                }
@@ -53,236 +73,276 @@ hopcode( f, o ){
        }
 
 char *
        }
 
 char *
-rnames[]= {  /* keyed to register number tokens */
+rnames[] = {  /* keyed to register number tokens */
 
        "r0", "r1",
 
        "r0", "r1",
-       "r2", "r3", "r4",
-       "r5", "sp", "pc",
+       "r2", "r3", "r4", "r5",
+       "r6", "r7", "r8", "r9", "r10", "r11",
+       "ap", "fp", "sp", "pc",
 
 
-       "fr0", "fr1", "fr2", "fr3",
-       "fr4", "fr5",   /* not accumulators - used for temps */
        };
 
 int rstatus[] = {
        SAREG|STAREG, SAREG|STAREG,
        };
 
 int rstatus[] = {
        SAREG|STAREG, SAREG|STAREG,
-       SAREG|STAREG, SAREG|STAREG, SAREG|STAREG,       /* use as scratch if not reg var */
-       SAREG, SAREG, SAREG,
+       SAREG|STAREG, SAREG|STAREG, SAREG|STAREG, SAREG|STAREG,
+       SAREG, SAREG, SAREG, SAREG, SAREG, SAREG,
+       SAREG, SAREG, SAREG, SAREG,
 
 
-       SBREG|STBREG, SBREG|STBREG, SBREG|STBREG, SBREG|STBREG,
-       SBREG, SBREG,
        };
 
        };
 
-NODE *brnode;
-int brcase;
+tlen(p) NODE *p;
+{
+       switch(p->type) {
+               case CHAR:
+               case UCHAR:
+                       return(1);
+
+               case SHORT:
+               case USHORT:
+                       return(2);
+
+               case DOUBLE:
+                       return(8);
+
+               default:
+                       return(4);
+               }
+}
+
+mixtypes(p, q) NODE *p, *q;
+{
+       register tp, tq;
+
+       tp = p->type;
+       tq = q->type;
+
+       return( (tp==FLOAT || tp==DOUBLE) !=
+               (tq==FLOAT || tq==DOUBLE) );
+}
 
 
-int toff = 0; /* number of stack locations used for args */
+prtype(n) NODE *n;
+{
+       switch (n->type)
+               {
+               case DOUBLE:
+                       printf("d");
+                       return;
+
+               case FLOAT:
+                       printf("f");
+                       return;
+
+               case LONG:
+               case ULONG:
+               case INT:
+               case UNSIGNED:
+                       printf("l");
+                       return;
+
+               case SHORT:
+               case USHORT:
+                       printf("w");
+                       return;
+
+               case CHAR:
+               case UCHAR:
+                       printf("b");
+                       return;
+
+               default:
+                       if ( !ISPTR( n->type ) ) cerror("zzzcode- bad type");
+                       else {
+                               printf("l");
+                               return;
+                               }
+               }
+}
 
 
-zzzcode( p, c ) NODE *p; {
+zzzcode( p, c ) register NODE *p; {
        register m;
        register m;
+       CONSZ val;
        switch( c ){
 
        switch( c ){
 
-       case 'B':       /* output b if type is byte */
-               if( p->type == CHAR || p->type == UCHAR ) printf( "b" );
-               return;
-
        case 'N':  /* logical ops, turned into 0-1 */
                /* use register given by register 1 */
                cbgen( 0, m=getlab(), 'I' );
                deflab( p->label );
        case 'N':  /* logical ops, turned into 0-1 */
                /* use register given by register 1 */
                cbgen( 0, m=getlab(), 'I' );
                deflab( p->label );
-               printf( "       clr     %s\n", rnames[getlr( p, '1' )->rval] );
-               if( p->type == LONG || p->type == ULONG )
-                       printf( "       clr     %s\n", rnames[getlr( p, '1' )->rval + 1] );
+               printf( "       clrl    %s\n", rnames[getlr( p, '1' )->rval] );
                deflab( m );
                return;
 
        case 'I':
                deflab( m );
                return;
 
        case 'I':
-       case 'F':
+       case 'P':
                cbgen( p->op, p->label, c );
                return;
 
        case 'A':
                cbgen( p->op, p->label, c );
                return;
 
        case 'A':
-       case 'C':
-               /* logical operators for longs
-                  defer comparisons until branch occurs */
-
-               brnode = tcopy( p );
-               brcase = c;
-               return;
-
-       case 'H':  /* fix up unsigned shifts */
-               {       register NODE *q;
-                       register r, l;
-                       TWORD t;
-
-                       if( p->op == ASG LS ) return;
-                       if( p->op != ASG RS ) cerror( "ZH bad" );
-                       if( p->left->op != REG ) cerror( "SH left bad" );
-
-                       r = p->left->rval;
-                       t = p->left->type;
-                       l = (t==LONG || t == ULONG );
-
-                       if( t != UNSIGNED && t != UCHAR && t != ULONG ) return;  /* signed is ok */
-
-                       /* there are three cases:  right side is a constant,
-                               and has the shift value; right side is
-                               a temporary reg, and has the - shift value,
-                               and right side is something else: A1 has the
-                               - shift value then */
-
-                       /* in the case where the value is known (rhs a constant),
-                               the mask is just computed and put out... */
-
-                       if( p->right->op == ICON ){
-                               int s;
-                               s = p->right->lval;
-                               if( l ){
-                                       if( s >= 16 ){
-                                               printf( "       clr     r%d\n", r );
-                                               s -= 16;
-                                               ++r;
-                                               }
-                                       }
-                               if( s >= 16 ) printf( " clr     r%d\n", r );
-                               else {
-                                       m = 0100000;
-                                       m >>= s;  /* sign extends... */
-                                       m <<= 1;
-                                       printf( "       bic     $%o,r%d\n", m, r );
-                                       }
+               {
+               register NODE *l, *r;
+
+               if (xdebug) eprint(p, 0, &val, &val);
+               r = getlr(p, 'R');
+               if (optype(p->op) == LTYPE || p->op == UNARY MUL)
+                       {
+                       l = resc;
+                       l->type = (r->type==FLOAT || r->type==DOUBLE ? DOUBLE : INT);
+                       }
+               else
+                       l = getlr(p, 'L');
+               if (r->op == ICON  && r->name[0] == '\0')
+                       {
+                       if (r->lval == 0)
+                               {
+                               printf("clr");
+                               prtype(l);
+                               printf("        ");
+                               adrput(l);
                                return;
                                }
                                return;
                                }
+                       if (r->lval < 0 && r->lval >= -63)
+                               {
+                               printf("mneg");
+                               prtype(l);
+                               r->lval = -r->lval;
+                               goto ops;
+                               }
+                       r->type = (r->lval < 0 ?
+                                       (r->lval >= -128 ? CHAR
+                                       : (r->lval >= -32768 ? SHORT
+                                       : INT )) : r->type);
+                       r->type = (r->lval >= 0 ?
+                                       (r->lval <= 63 ? INT
+                                       : ( r->lval <= 127 ? CHAR
+                                       : (r->lval <= 255 ? UCHAR
+                                       : (r->lval <= 32767 ? SHORT
+                                       : (r->lval <= 65535 ? USHORT
+                                       : INT ))))) : r->type );
+                       }
+               if (l->op == REG && l->type != FLOAT && l->type != DOUBLE)
+                       l->type = INT;
+               if (!mixtypes(l,r))
+                       {
+                       if (tlen(l) == tlen(r))
+                               {
+                               printf("mov");
+                               prtype(l);
+                               goto ops;
+                               }
+                       else if (tlen(l) > tlen(r) && ISUNSIGNED(r->type))
+                               {
+                               printf("movz");
+                               }
+                       else
+                               {
+                               printf("cvt");
+                               }
+                       }
+               else
+                       {
+                       printf("cvt");
+                       }
+               prtype(r);
+               prtype(l);
+       ops:
+               printf("        ");
+               adrput(r);
+               printf(",");
+               adrput(l);
+               return;
+               }
 
 
-                       /* general case */
-
-                       if( istnode( p->right ) ) q = p->right;
-                       else q = getlr( p, '1' );  /* where -shift is stored */
-
-                       /* first, we store the shifted value on the stack */
-                       printf( "       mov     r%d,-(sp)\n", r );
-                       if( l ) printf( "       mov     r%d,-(sp)\n", r+1 );
-
-                       /* now, make a mask */
-
-                       printf( "       mov     $100000,r%d\n", r );
-                       if( l ) printf( "       clr     r%d\n", r+1 );
-                       
-                       /* shift (arithmetically ) */
-                       if( l ) expand( q, RNOP, "      ashc    AR" );
-                       else expand( q, RNOP, " ash     AR" );
-                       printf( ",r%d\n", r );
+       case 'C':       /* num words pushed on arg stack */
+               {
+               extern int gc_numbytes;
+               extern int xdebug;
 
 
-                       if( l ) printf( "       ashc    $1,r%d\n", r );
-                       else printf( "  asl     r%d\n", r );
+               if (xdebug) printf("->%d<-",gc_numbytes);
 
 
-                       /* now, we have a mask: use it to clear sp, and reload */
+               printf("$%d", gc_numbytes/(SZLONG/SZCHAR) );
+               return;
+               }
 
 
-                       if( l ){
-                               printf( "\tbic\tr%d,(sp)\n\tmov\t(sp)+,r%d\n", r+1, r+1 );
-                               }
-                       printf( "\tbic\tr%d,(sp)\n\tmov\t(sp)+,r%d\n", r, r );
-                       /* whew! */
+       case 'D':       /* INCR and DECR */
+               zzzcode(p->left, 'A');
+               printf("\n      ");
+
+       case 'E':       /* INCR and DECR, FOREFF */
+               if (p->right->lval == 1)
+                       {
+                       printf("%s", (p->op == INCR ? "inc" : "dec") );
+                       prtype(p->left);
+                       printf("        ");
+                       adrput(p->left);
                        return;
                        }
                        return;
                        }
+               printf("%s", (p->op == INCR ? "add" : "sub") );
+               prtype(p->left);
+               printf("2       ");
+               adrput(p->right);
+               printf(",");
+               adrput(p->left);
+               return;
 
 
-       case 'V':
-               /* sign extend or not -- register is one less than the
-                  left descendent */
+       case 'F':       /* register type of right operand */
+               {
+               register NODE *n;
+               extern int xdebug;
+               register int ty;
 
 
-               m = p->left->rval - 1;
+               n = getlr( p, 'R' );
+               ty = n->type;
 
 
-               if( ISUNSIGNED(p->type) ){
-                       printf( "       clr     r%d\n", m );
-                       }
-               else {
-                       printf( "       sxt     r%d\n", m );
-                       }
-               return;
+               if (xdebug) printf("->%d<-", ty);
 
 
-               /* stack management macros */
-       case '-':
-               if( toff ++ ) printf( "-" );
-               printf( "(sp)" );
+               if ( ty==DOUBLE) printf("d");
+               else if ( ty==FLOAT ) printf("f");
+               else printf("l");
                return;
                return;
+               }
 
 
-       case '4':
-               if( toff == 0 ) ++toff;  /* can't push doubles that way */
-               printf( "-(sp)" );
-               toff += 4;
-               return;
+       case 'L':       /* type of left operand */
+       case 'R':       /* type of right operand */
+               {
+               register NODE *n;
+               extern int xdebug;
 
 
-       case '~':
-               /* complimented CR */
-               p->right->lval = ~p->right->lval;
-               conput( getlr( p, 'R' ) );
-               p->right->lval = ~p->right->lval;
-               return;
+               n = getlr ( p, c);
+               if (xdebug) printf("->%d<-", n->type);
 
 
-       case 'M':
-               /* negated CR */
-               p->right->lval = -p->right->lval;
-               conput( getlr( p, 'R' ) );
-               p->right->lval = -p->right->lval;
+               prtype(n);
                return;
                return;
-
-       case 'L':  /* INIT for long constants */
-               {
-                       unsigned hi, lo;
-                       lo = p->left->lval & BITMASK(SZINT);
-                       hi = ( p->left->lval >> SZINT ) & BITMASK(SZINT);
-                       printf( "       %o; %o\n", hi, lo );
-                       return;
                }
 
                }
 
-       case 'T':
-               /* Truncate longs for type conversions:
-                   LONG|ULONG -> CHAR|UCHAR|INT|UNSIGNED
-                  increment offset to second word */
-
-               m = p->type;
-               p = p->left;
-               switch( p->op ){
-               case NAME:
-               case OREG:
-                       p->lval += SZINT/SZCHAR;
-                       return;
-               case REG:
-                       rfree( p->rval, p->type );
-                       p->rval += 1;
-                       p->type = m;
-                       rbusy( p->rval, p->type );
-                       return;
-               default:
-                       cerror( "Illegal ZT type conversion" );
-                       return;
+       case 'Z':       /* complement mask for bit instr */
+               printf("$%Ld", ~p->right->lval);
+               return;
 
 
-                       }
+       case 'U':       /* 32 - n, for unsigned right shifts */
+               printf("$%d", 32 - p->right->lval );
+               return;
 
 
-       case 'U':
-               /* same as AL for exp under U* */
-               if( p->left->op == UNARY MUL ) {
-                       adrput( getlr( p->left, 'L' ) );
-                       return;
-                       }
-               cerror( "Illegal ZU" );
-               /* NO RETURN */
+       case 'T':       /* rounded structure length for arguments */
+               {
+               int size;
 
 
-       case 'W':       /* structure size */
-               if( p->op == STASG )
-                       printf( "%d", p->stsize);
-               else    cerror( "Not a structure" );
+               size = p->stsize;
+               SETOFF( size, 4);
+               printf("$%d", size);
                return;
                return;
+               }
 
        case 'S':  /* structure assignment */
                {
                        register NODE *l, *r;
 
        case 'S':  /* structure assignment */
                {
                        register NODE *l, *r;
-                       register size, count;
+                       register size;
 
                        if( p->op == STASG ){
                                l = p->left;
                                r = p->right;
 
                        if( p->op == STASG ){
                                l = p->left;
                                r = p->right;
+
                                }
                                }
-                       else if( p->op == STARG ){  /* store an arg onto the stack */
+                       else if( p->op == STARG ){  /* store an arg into a temporary */
+                               l = getlr( p, '3' );
                                r = p->left;
                                }
                        else cerror( "STASG bad" );
                                r = p->left;
                                }
                        else cerror( "STASG bad" );
@@ -292,23 +352,31 @@ zzzcode( p, c ) NODE *p; {
                        else if( r->op != OREG ) cerror( "STASG-r" );
 
                        size = p->stsize;
                        else if( r->op != OREG ) cerror( "STASG-r" );
 
                        size = p->stsize;
-                       count = size / 2;
-
-                       r->lval += size;
-                       if( p->op == STASG ) l->lval += size;
 
 
-                       while( count-- ){ /* simple load/store loop */
-                               r->lval -= 2;
-                               expand( r, FOREFF, "    mov     AR," );
-                               if( p->op == STASG ){
-                                       l->lval -= 2;
-                                       expand( l, FOREFF, "AR\n" );
-                                       }
-                               else {
-                                       printf( "-(sp)\n" );
-                                       }
-
-                               }
+                       if( size <= 0 || size > 65535 )
+                               cerror("structure size <0=0 or >65535");
+
+                       switch(size) {
+                               case 1:
+                                       printf("        movb    ");
+                                       break;
+                               case 2:
+                                       printf("        movw    ");
+                                       break;
+                               case 4:
+                                       printf("        movl    ");
+                                       break;
+                               case 8:
+                                       printf("        movq    ");
+                                       break;
+                               default:
+                                       printf("        movc3   $%d,", size);
+                                       break;
+                       }
+                       adrput(r);
+                       printf(",");
+                       adrput(l);
+                       printf("\n");
 
                        if( r->op == NAME ) r->op = ICON;
                        else if( r->op == OREG ) r->op = REG;
 
                        if( r->op == NAME ) r->op = ICON;
                        else if( r->op == OREG ) r->op = REG;
@@ -321,46 +389,28 @@ zzzcode( p, c ) NODE *p; {
                }
        }
 
                }
        }
 
-rmove( rt, rs, t ) TWORD t; {
-       printf( "       %s      %s,%s\n", (t==FLOAT||t==DOUBLE)?"movf":"mov", rnames[rs], rnames[rt] );
+rmove( rt, rs, t ){
+       printf( "       %s      %s,%s\n",
+               (t==FLOAT ? "movf" : (t==DOUBLE ? "movd" : "movl")),
+               rnames[rs], rnames[rt] );
        }
 
 struct respref
 respref[] = {
        INTAREG|INTBREG,        INTAREG|INTBREG,
        }
 
 struct respref
 respref[] = {
        INTAREG|INTBREG,        INTAREG|INTBREG,
-       INAREG|INBREG,  INAREG|INBREG|SOREG|STARREG|SNAME|STARNM|SCON,
+       INAREG|INBREG,  INAREG|INBREG|SOREG|STARREG|STARNM|SNAME|SCON,
        INTEMP, INTEMP,
        FORARG, FORARG,
        INTEMP, INTEMP,
        FORARG, FORARG,
-       INTAREG,        SOREG|SNAME,
+       INTEMP, INTAREG|INAREG|INTBREG|INBREG|SOREG|STARREG|STARNM,
        0,      0 };
 
 setregs(){ /* set up temporary registers */
        0,      0 };
 
 setregs(){ /* set up temporary registers */
-       register i;
-
-       /* use any unused variable registers as scratch registers */
-       fregs = maxtreg>=MINRVAR ? maxtreg + 1 : MINRVAR;
-       if( xdebug ){
-               /* -x changes number of free regs to 2, -xx to 3, etc. */
-               if( (xdebug+1) < fregs ) fregs = xdebug+1;
-               }
-       /* NOTE: for pdp11 fregs <= 4 for float regs */
-       if( fregs > 4 ) fregs = 4;
-       for( i=MINRVAR; i<=MAXRVAR; i++ )
-               rstatus[i] = i<fregs ? SAREG|STAREG : SAREG;
+       fregs = 6;      /* tbl- 6 free regs on VAX (0-5) */
+       ;
        }
 
        }
 
-szty(t) TWORD t; { /* size, in words, needed to hold thing of type t */
-       /* really is the number of registers to hold type t */
-       switch( t ) {
-
-       case LONG:
-       case ULONG:
-               return( SZLONG/SZINT );
-
-       default:
-               return(1);
-
-               }
+szty(t){ /* size, in registers, needed to hold thing of type t */
+       return( (t==DOUBLE||t==FLOAT) ? 2 : 1 );
        }
 
 rewfld( p ) NODE *p; {
        }
 
 rewfld( p ) NODE *p; {
@@ -368,71 +418,159 @@ rewfld( p ) NODE *p; {
        }
 
 callreg(p) NODE *p; {
        }
 
 callreg(p) NODE *p; {
-       return( (p->type==DOUBLE||p->type==FLOAT) ? FR0 : R0 );
+       return( R0 );
        }
 
        }
 
-shltype( o, p ) NODE *p; {
-       if( o == NAME|| o==REG || o == ICON || o == OREG ) return( 1 );
-       return( o==UNARY MUL && shumul(p->left) );
+base( p ) register NODE *p; {
+       register int o = p->op;
+
+       if( (o==ICON && p->name[0] != '\0')) return( 100 ); /* ie no base reg */
+       if( o==REG ) return( p->rval );
+    if( (o==PLUS || o==MINUS) && p->left->op == REG && p->right->op==ICON)
+               return( p->left->rval );
+    if( o==OREG && !R2TEST(p->rval) && (p->type==INT || p->type==UNSIGNED || ISPTR(p->type)) )
+               return( p->rval + 0200*1 );
+       if( o==INCR && p->left->op==REG ) return( p->left->rval + 0200*2 );
+       if( o==ASG MINUS && p->left->op==REG) return( p->left->rval + 0200*4 );
+       if( o==UNARY MUL && p->left->op==INCR && p->left->left->op==REG
+         && (p->type==INT || p->type==UNSIGNED || ISPTR(p->type)) )
+               return( p->left->left->rval + 0200*(1+2) );
+       return( -1 );
        }
 
        }
 
-flshape( p ) register NODE *p; {
-       register o = p->op;
-       if( o==NAME || o==REG || o==ICON || o==OREG ) return( 1 );
-       return( o==UNARY MUL && shumul(p->left)==STARNM );
-       }
+offset( p, tyl ) register NODE *p; int tyl; {
 
 
-shtemp( p ) register NODE *p; {
-       if( p->op == UNARY MUL ) p = p->left;
-       if( p->op == REG || p->op == OREG ) return( !istreg( p->rval ) );
-       return( p->op == NAME || p->op == ICON );
+       if( tyl==1 && p->op==REG && (p->type==INT || p->type==UNSIGNED) ) return( p->rval );
+       if( (p->op==LS && p->left->op==REG && (p->left->type==INT || p->left->type==UNSIGNED) &&
+             (p->right->op==ICON && p->right->name[0]=='\0')
+             && (1<<p->right->lval)==tyl))
+               return( p->left->rval );
+       return( -1 );
        }
 
        }
 
-spsz( t, v ) TWORD t; CONSZ v; {
+makeor2( p, q, b, o) register NODE *p, *q; register int b, o; {
+       register NODE *t;
+       register int i;
+       NODE *f;
+
+       p->op = OREG;
+       f = p->left;    /* have to free this subtree later */
+
+       /* init base */
+       switch (q->op) {
+               case ICON:
+               case REG:
+               case OREG:
+                       t = q;
+                       break;
+
+               case MINUS:
+                       q->right->lval = -q->right->lval;
+               case PLUS:
+                       t = q->right;
+                       break;
 
 
-       /* is v the size to increment something of type t */
+               case INCR:
+               case ASG MINUS:
+                       t = q->left;
+                       break;
 
 
-       if( !ISPTR(t) ) return( 0 );
-       t = DECREF(t);
+               case UNARY MUL:
+                       t = q->left->left;
+                       break;
 
 
-       if( ISPTR(t) ) return( v == 2 );
+               default:
+                       cerror("illegal makeor2");
+       }
 
 
-       switch( t ){
+       p->lval = t->lval;
+       for(i=0; i<NCHNAM; ++i)
+               p->name[i] = t->name[i];
 
 
-       case UCHAR:
-       case CHAR:
-               return( v == 1 );
+       /* init offset */
+       p->rval = R2PACK( (b & 0177), o, (b>>7) );
 
 
-       case INT:
-       case UNSIGNED:
-               return( v == 2 );
+       tfree(f);
+       return;
+       }
 
 
-       case FLOAT:
-               return( v == 4 );
+canaddr( p ) NODE *p; {
+       register int o = p->op;
 
 
-       case DOUBLE:
-               return( v == 8 );
-               }
+       if( o==NAME || o==REG || o==ICON || o==OREG || (o==UNARY MUL && shumul(p->left)) ) return(1);
+       return(0);
+       }
 
 
-       return( 0 );
+shltype( o, p ) register NODE *p; {
+       return( o== REG || o == NAME || o == ICON || o == OREG || ( o==UNARY MUL && shumul(p->left)) );
+       }
+
+flshape( p ) register NODE *p; {
+       return( p->op == REG || p->op == NAME || p->op == ICON ||
+               (p->op == OREG && (!R2TEST(p->rval) || tlen(p) == 1)) );
+       }
+
+shtemp( p ) register NODE *p; {
+       if( p->op == STARG ) p = p->left;
+       return( p->op==NAME || p->op ==ICON || p->op == OREG || (p->op==UNARY MUL && shumul(p->left)) );
        }
 
 shumul( p ) register NODE *p; {
        register o;
        }
 
 shumul( p ) register NODE *p; {
        register o;
+       extern int xdebug;
+
+       if (xdebug) {
+                printf("\nshumul:op=%d,lop=%d,rop=%d", p->op, p->left->op, p->right->op);
+               printf(" prname=%s,plty=%d, prlval=%D\n", p->right->name, p->left->type, p->right->lval);
+               }
+
 
        o = p->op;
 
        o = p->op;
-       if( o == NAME || o == OREG || o == ICON ) return( STARNM );
+       if( o == NAME || (o == OREG && !R2TEST(p->rval)) || o == ICON ) return( STARNM );
 
        if( ( o == INCR || o == ASG MINUS ) &&
            ( p->left->op == REG && p->right->op == ICON ) &&
 
        if( ( o == INCR || o == ASG MINUS ) &&
            ( p->left->op == REG && p->right->op == ICON ) &&
-           p->right->name[0] == '\0' &&
-           spsz( p->left->type, p->right->lval ) )
-               return( STARREG );
+           p->right->name[0] == '\0' )
+               {
+               switch (p->left->type)
+                       {
+                       case CHAR|PTR:
+                       case UCHAR|PTR:
+                               o = 1;
+                               break;
+
+                       case SHORT|PTR:
+                       case USHORT|PTR:
+                               o = 2;
+                               break;
+
+                       case INT|PTR:
+                       case UNSIGNED|PTR:
+                       case LONG|PTR:
+                       case ULONG|PTR:
+                       case FLOAT|PTR:
+                               o = 4;
+                               break;
+
+                       case DOUBLE|PTR:
+                               o = 8;
+                               break;
+
+                       default:
+                               if ( ISPTR(p->left->type) ) {
+                                       o = 4;
+                                       break;
+                                       }
+                               else return(0);
+                       }
+               return( p->right->lval == o ? STARREG : 0);
+               }
 
        return( 0 );
        }
 
 adrcon( val ) CONSZ val; {
 
        return( 0 );
        }
 
 adrcon( val ) CONSZ val; {
+       printf( "$" );
        printf( CONFMT, val );
        }
 
        printf( CONFMT, val );
        }
 
@@ -452,57 +590,16 @@ conput( p ) register NODE *p; {
                }
        }
 
                }
        }
 
-insput( p ) NODE *p; {
+insput( p ) register NODE *p; {
        cerror( "insput" );
        }
 
        cerror( "insput" );
        }
 
-upput( p ) NODE *p; {
-       /* output the address of the second word in the
-          pair pointed to by p (for LONGs)*/
-       CONSZ save;
-
-       if( p->op == FLD ){
-               p = p->left;
-               }
-
-       save = p->lval;
-       switch( p->op ){
-
-       case NAME:
-               p->lval += SZINT/SZCHAR;
-               acon( p );
-               break;
-
-       case ICON:
-               /* addressable value of the constant */
-               p->lval &= BITMASK(SZINT);
-               printf( "$" );
-               acon( p );
-               break;
-
-       case REG:
-               printf( "%s", rnames[p->rval+1] );
-               break;
-
-       case OREG:
-               p->lval += SZINT/SZCHAR;
-               if( p->rval == R5 ){  /* in the argument region */
-                       if( p->name[0] != '\0' ) werror( "bad arg temp" );
-                       }
-               if( p->lval != 0 || p->name[0] != '\0' ) acon( p );
-               printf( "(%s)", rnames[p->rval] );
-               break;
-
-       default:
-               cerror( "illegal upper address" );
-               break;
-
-               }
-       p->lval = save;
-
+upput( p ) register NODE *p; {
+       cerror( "upput" );
        }
 
 adrput( p ) register NODE *p; {
        }
 
 adrput( p ) register NODE *p; {
+       register int r;
        /* output an address, with offsets, from p */
 
        if( p->op == FLD ){
        /* output an address, with offsets, from p */
 
        if( p->op == FLD ){
@@ -516,16 +613,6 @@ adrput( p ) register NODE *p; {
 
        case ICON:
                /* addressable value of the constant */
 
        case ICON:
                /* addressable value of the constant */
-               if( szty( p->type ) == 2 ) {
-                       /* print the high order value */
-                       CONSZ save;
-                       save = p->lval;
-                       p->lval = ( p->lval >> SZINT ) & BITMASK(SZINT);
-                       printf( "$" );
-                       acon( p );
-                       p->lval = save;
-                       return;
-                       }
                printf( "$" );
                acon( p );
                return;
                printf( "$" );
                acon( p );
                return;
@@ -535,13 +622,26 @@ adrput( p ) register NODE *p; {
                return;
 
        case OREG:
                return;
 
        case OREG:
-               if( p->rval == R5 ){  /* in the argument region */
-                       if( p->name[0] != '\0' ) werror( "bad arg temp" );
+               r = p->rval;
+               if( R2TEST(r) ){ /* double indexing */
+                       register int flags;
+
+                       flags = R2UPK3(r);
+                       if( flags & 1 ) printf("*");
+                       if( flags & 4 ) printf("-");
+                       if( p->lval != 0 || p->name[0] != '\0' ) acon(p);
+                       if( R2UPK1(r) != 100) printf( "(%s)", rnames[R2UPK1(r)] );
+                       if( flags & 2 ) printf("+");
+                       printf( "[%s]", rnames[R2UPK2(r)] );
+                       return;
+                       }
+               if( r == AP ){  /* in the argument region */
+                       if( p->lval <= 0 || p->name[0] != '\0' ) werror( "bad arg temp" );
                        printf( CONFMT, p->lval );
                        printf( CONFMT, p->lval );
-                       printf( ".(r5)" );
+                       printf( "(ap)" );
                        return;
                        }
                        return;
                        }
-               if( p->lval != 0 || p->name[0] != '\0' ) acon( p );
+               if( p->lval != 0 || p->name[0] != '\0') acon( p );
                printf( "(%s)", rnames[p->rval] );
                return;
 
                printf( "(%s)", rnames[p->rval] );
                return;
 
@@ -552,29 +652,29 @@ adrput( p ) register NODE *p; {
                        adrput( p->left);
                        }
                else {  /* STARREG - really auto inc or dec */
                        adrput( p->left);
                        }
                else {  /* STARREG - really auto inc or dec */
-                       /* turn into OREG so replacement node will
-                          reflect the value of the expression */
-                       register i;
-                       register NODE *q, *l;
+                       register NODE *q;
 
 
-                       l = p->left;
-                       q = l->left;
-                       p->op = OREG;
-                       p->rall = q->rall;
-                       p->lval = q->lval;
-                       p->rval = q->rval;
-                       for( i=0; i<NCHNAM; i++ )
-                               p->name[i] = q->name[i];
-                       if( l->op == INCR ) {
-                               adrput( p );
+/* tbl
+                       p = p->left;
+                       p->left->op = OREG;
+                       if( p->op == INCR ) {
+                               adrput( p->left );
                                printf( "+" );
                                printf( "+" );
-                               p->lval -= l->right->lval;
                                }
                                }
-                       else {  /* l->op == ASG MINUS */
+                       else {
                                printf( "-" );
                                printf( "-" );
-                               adrput( p );
+                               adrput( p->left );
                                }
                                }
-                       tfree( l );
+   tbl */
+                       printf("%c(%s)%c", (p->left->op==INCR ? '\0' : '-'),
+                               rnames[p->left->left->rval], 
+                               (p->left->op==INCR ? '+' : '\0') );
+                       p->op = OREG;
+                       p->rval = p->left->left->rval;
+                       q = p->left;
+                       p->lval = (p->left->op == INCR ? -p->left->right->lval : 0);
+                       p->name[0] = '\0';
+                       tfree(q);
                }
                return;
 
                }
                return;
 
@@ -588,53 +688,106 @@ adrput( p ) register NODE *p; {
 
 acon( p ) register NODE *p; { /* print out a constant */
 
 
 acon( p ) register NODE *p; { /* print out a constant */
 
-       if( p->name[0] == '\0' ){       /* constant only */
+       if( p->name[0] == '\0' ){
                printf( CONFMT, p->lval);
                printf( CONFMT, p->lval);
-               printf( "." );
                }
                }
-       else if( p->lval == 0 ) {       /* name only */
+       else if( p->lval == 0 ) {
                printf( "%.8s", p->name );
                }
                printf( "%.8s", p->name );
                }
-       else {                          /* name + offset */
+       else {
                printf( "%.8s+", p->name );
                printf( CONFMT, p->lval );
                printf( "%.8s+", p->name );
                printf( CONFMT, p->lval );
-               printf( "." );
                }
        }
 
                }
        }
 
+/*
+aacon( p ) register NODE *p; { /* print out a constant */
+/*
+
+       if( p->name[0] == '\0' ){
+               printf( CONFMT, p->lval);
+               return( 0 );
+               }
+       else if( p->lval == 0 ) {
+               printf( "$%.8s", p->name );
+               return( 1 );
+               }
+       else {
+               printf( "$(" );
+               printf( CONFMT, p->lval );
+               printf( "+" );
+               printf( "%.8s)", p->name );
+               return(1);
+               }
+       }
+ */
+
 genscall( p, cookie ) register NODE *p; {
        /* structure valued call */
        return( gencall( p, cookie ) );
        }
 
 genscall( p, cookie ) register NODE *p; {
        /* structure valued call */
        return( gencall( p, cookie ) );
        }
 
+/* tbl */
+int gc_numbytes;
+/* tbl */
+
 gencall( p, cookie ) register NODE *p; {
        /* generate the call given by p */
 gencall( p, cookie ) register NODE *p; {
        /* generate the call given by p */
-       register temp;
+       register NODE *p1, *ptemp;
+       register temp, temp1;
        register m;
 
        if( p->right ) temp = argsize( p->right );
        else temp = 0;
 
        register m;
 
        if( p->right ) temp = argsize( p->right );
        else temp = 0;
 
-       if( p->right ){ /* generate args */
-               genargs( p->right );
+       if( p->op == STCALL || p->op == UNARY STCALL ){
+               /* set aside room for structure return */
+
+               if( p->stsize > temp ) temp1 = p->stsize;
+               else temp1 = temp;
                }
 
                }
 
-       if( !shltype( p->left->op, p->left ) ) {
-               order( p->left, INAREG|SOREG );
+       if( temp > maxargs ) maxargs = temp;
+       SETOFF(temp1,4);
+
+       if( p->right ){ /* make temp node, put offset in, and generate args */
+               ptemp = talloc();
+               ptemp->op = OREG;
+               ptemp->lval = -1;
+               ptemp->rval = SP;
+               ptemp->name[0] = '\0';
+               ptemp->rall = NOPREF;
+               ptemp->su = 0;
+               genargs( p->right, ptemp );
+               ptemp->op = FREE;
                }
 
                }
 
-       p->op = UNARY CALL;
-       m = match( p, INTAREG|INTBREG );
-       popargs( temp );
-       return(m != MDONE);
-       }
+       p1 = p->left;
+       if( p1->op != ICON ){
+               if( p1->op != REG ){
+                       if( p1->op != OREG || R2TEST(p1->rval) ){
+                               if( p1->op != NAME ){
+                                       order( p1, INAREG );
+                                       }
+                               }
+                       }
+               }
+
+/*
+       if( p1->op == REG && p->rval == R5 ){
+               cerror( "call register overwrite" );
+               }
+ */
+/* tbl
+       setup gc_numbytes so reference to ZC works */
 
 
-popargs( size ) register size; {
-       /* pop arguments from stack */
+       gc_numbytes = temp;
+/* tbl */
 
 
-       toff -= size/2;
-       if( toff == 0 && size >= 2 ) size -= 2;
-       switch( size ) {
+       p->op = UNARY CALL;
+       m = match( p, INTAREG|INTBREG );
+/* tbl
+       switch( temp ) {
        case 0:
                break;
        case 2:
        case 0:
                break;
        case 2:
@@ -644,87 +797,36 @@ popargs( size ) register size; {
                printf( "       cmp     (sp)+,(sp)+\n" );
                break;
        default:
                printf( "       cmp     (sp)+,(sp)+\n" );
                break;
        default:
-               printf( "       add     $%d.,sp\n", size);
+               printf( "       add     $%d,sp\n", temp);
                }
                }
+   tbl */
+       return(m != MDONE);
        }
 
        }
 
+/* tbl */
 char *
 ccbranches[] = {
 char *
 ccbranches[] = {
-       "       jeq     L%d\n",
-       "       jne     L%d\n",
-       "       jle     L%d\n",
-       "       jlt     L%d\n",
-       "       jge     L%d\n",
-       "       jgt     L%d\n",
-       "       jlos    L%d\n",
-       "       jlo     L%d\n",
-       "       jhis    L%d\n",
-       "       jhi     L%d\n",
-       };
-
-/*     long branch table
-
-   This table, when indexed by a logical operator,
-   selects a set of three logical conditions required
-   to generate long comparisons and branches.  A zero
-   entry indicates that no branch is required.
-   E.G.:  The <= operator would generate:
-       cmp     AL,AR
-       jlt     lable   / 1st entry LT -> lable
-       jgt     1f      / 2nd entry GT -> 1f
-       cmp     UL,UR
-       jlos    lable   / 3rd entry ULE -> lable
-   1:
- */
-
-int lbranches[][3] = {
-       /*EQ*/  0,      NE,     EQ,
-       /*NE*/  NE,     0,      NE,
-       /*LE*/  LT,     GT,     ULE,
-       /*LT*/  LT,     GT,     ULT,
-       /*GE*/  GT,     LT,     UGE,
-       /*GT*/  GT,     LT,     UGT,
-       /*ULE*/ ULT,    UGT,    ULE,
-       /*ULT*/ ULT,    UGT,    ULT,
-       /*UGE*/ UGT,    ULT,    UGE,
-       /*UGT*/ UGT,    ULT,    UGT,
+       "       jeql    L%d\n",
+       "       jneq    L%d\n",
+       "       jleq    L%d\n",
+       "       jlss    L%d\n",
+       "       jgeq    L%d\n",
+       "       jgtr    L%d\n",
+       "       jlequ   L%d\n",
+       "       jlssu   L%d\n",
+       "       jgequ   L%d\n",
+       "       jgtru   L%d\n",
        };
        };
-
-/* logical relations when compared in reverse order (cmp R,L) */
-extern short revrel[] ;
+/* tbl */
 
 cbgen( o, lab, mode ) { /*   printf conditional and unconditional branches */
 
 cbgen( o, lab, mode ) { /*   printf conditional and unconditional branches */
-       register *plb;
-       int lab1f;
 
 
-       if( o == 0 ) printf( "  jbr     L%d\n", lab );
-       else    if( o > UGT ) cerror( "bad conditional branch: %s", opst[o] );
+/* tbl */
+       if( o == 0 ) printf( "  jbr     L%d\n", lab );
+/* tbl */
        else {
        else {
-               switch( brcase ) {
-
-               case 'A':
-               case 'C':
-                       plb = lbranches[ o-EQ ];
-                       lab1f = getlab();
-                       expand( brnode, FORCC, brcase=='C' ? "\tcmp\tAL,AR\n" : "\ttst\tAR\n" );
-                       if( *plb != 0 )
-                               printf( ccbranches[*plb-EQ], lab);
-                       if( *++plb != 0 )
-                               printf( ccbranches[*plb-EQ], lab1f);
-                       expand( brnode, FORCC, brcase=='C' ? "\tcmp\tUL,UR\n" : "\ttst\tUR\n" );
-                       printf( ccbranches[*++plb-EQ], lab);
-                       deflab( lab1f );
-                       reclaim( brnode, RNULL, 0 );
-                       break;
-
-               default:
-                       if( mode=='F' ) o = revrel[ o-EQ ];
-                       printf( ccbranches[o-EQ], lab );
-                       break;
-                       }
-
-               brcase = 0;
-               brnode = 0;
+               if( o > UGT ) cerror( "bad conditional branch: %s", opst[o] );
+               printf( ccbranches[o-EQ], lab );
                }
        }
 
                }
        }
 
@@ -741,111 +843,6 @@ lastchance( p, cook ) NODE *p; {
        return(0);
        }
 
        return(0);
        }
 
-struct functbl {
-       int fop;
-       TWORD ftype;
-       char *func;
-       } opfunc[] = {
-       MUL,            LONG,   "lmul",
-       DIV,            LONG,   "ldiv",
-       MOD,            LONG,   "lrem",
-       ASG MUL,        LONG,   "almul",
-       ASG DIV,        LONG,   "aldiv",
-       ASG MOD,        LONG,   "alrem",
-       MUL,            ULONG,  "lmul",
-       DIV,            ULONG,  "uldiv",
-       MOD,            ULONG,  "ulrem",
-       ASG MUL,        ULONG,  "almul",
-       ASG DIV,        ULONG,  "auldiv",
-       ASG MOD,        ULONG,  "aulrem",
-       0,      0,      0 };
-
-hardops(p)  register NODE *p; {
-       /* change hard to do operators into function calls.
-          for pdp11 do long * / %      */
-       register NODE *q;
-       register struct functbl *f;
-       register o;
-       register TWORD t;
-
-       o = p->op;
-       t = p->type;
-       if( t!=LONG && t!=ULONG ) return;
-
-       for( f=opfunc; f->fop; f++ ) {
-               if( o==f->fop && t==f->ftype ) goto convert;
-               }
-       return;
-
-       /* need address of left node for ASG OP */
-       /* WARNING - this won't work for long in a REG */
-       convert:
-       if( asgop( o ) ) {
-               switch( p->left->op ) {
-
-               case UNARY MUL: /* convert to address */
-                       p->left->op = FREE;
-                       p->left = p->left->left;
-                       break;
-
-               case NAME:      /* convert to ICON pointer */
-                       p->left->op = ICON;
-                       p->left->type = INCREF( p->left->type );
-                       break;
-
-               case OREG:      /* convert OREG to address */
-                       p->left->op = REG;
-                       p->left->type = INCREF( p->left->type );
-                       if( p->left->lval != 0 ) {
-                               q = talloc();
-                               q->op = PLUS;
-                               q->rall = NOPREF;
-                               q->type = p->left->type;
-                               q->left = p->left;
-                               q->right = talloc();
-
-                               q->right->op = ICON;
-                               q->right->rall = NOPREF;
-                               q->right->type = INT;
-                               q->right->name[0] = '\0';
-                               q->right->lval = p->left->lval;
-                               q->right->rval = 0;
-
-                               p->left->lval = 0;
-                               p->left = q;
-                               }
-                       break;
-
-               default:
-                       cerror( "Bad address for hard ops" );
-                       /* NO RETURN */
-
-                       }
-               }
-
-       /* build comma op for args to function */
-       q = talloc();
-       q->op = CM;
-       q->rall = NOPREF;
-       q->type = INT;
-       q->left = p->left;
-       q->right = p->right;
-       p->op = CALL;
-       p->right = q;
-
-       /* put function name in left node of call */
-       p->left = q = talloc();
-       q->op = ICON;
-       q->rall = NOPREF;
-       q->type = INCREF( FTN + p->type );
-       strcpy( q->name, f->func );
-       q->lval = 0;
-       q->rval = 0;
-
-       return;
-
-       }
-
 optim2( p ) register NODE *p; {
        /* do local tree transformations and optimizations */
 
 optim2( p ) register NODE *p; {
        /* do local tree transformations and optimizations */
 
@@ -855,7 +852,7 @@ optim2( p ) register NODE *p; {
 
        case AND:
                /* commute L and R to eliminate compliments and constants */
 
        case AND:
                /* commute L and R to eliminate compliments and constants */
-               if( p->left->op==ICON || p->left->op==COMPL ) {
+               if( (p->left->op==ICON&&p->left->name[0]==0) || p->left->op==COMPL ) {
                        r = p->left;
                        p->left = p->right;
                        p->right = r;
                        r = p->left;
                        p->left = p->right;
                        p->right = r;
@@ -863,7 +860,7 @@ optim2( p ) register NODE *p; {
        case ASG AND:
                /* change meaning of AND to ~R&L - bic on pdp11 */
                r = p->right;
        case ASG AND:
                /* change meaning of AND to ~R&L - bic on pdp11 */
                r = p->right;
-               if( r->op==ICON ) { /* compliment constant */
+               if( r->op==ICON && r->name[0]==0 ) { /* compliment constant */
                        r->lval = ~r->lval;
                        }
                else if( r->op==COMPL ) { /* ~~A => A */
                        r->lval = ~r->lval;
                        }
                else if( r->op==COMPL ) { /* ~~A => A */
@@ -883,33 +880,6 @@ optim2( p ) register NODE *p; {
                }
        }
 
                }
        }
 
-myreader(p) register NODE *p; {
-       walkf( p, hardops );    /* convert ops to function calls */
-       canon( p );             /* expands r-vals for fileds */
-       walkf( p, optim2 );
-       toff = 0;  /* stack offset swindle */
-       }
-
-special( p, shape ) register NODE *p; {
-       /* special shape matching routine */
-
-       switch( shape ) {
-
-       case SCCON:
-               if( p->op == ICON && p->name[0]=='\0' && p->lval>= -128 && p->lval <=127 ) return( 1 );
-               break;
-
-       case SICON:
-               if( p->op == ICON && p->name[0]=='\0' && p->lval>= 0 && p->lval <=32767 ) return( 1 );
-               break;
-
-       default:
-               cerror( "bad special shape" );
-
-               }
-
-       return( 0 );
-       }
 
 # ifndef ONEPASS
 main( argc, argv ) char *argv[]; {
 
 # ifndef ONEPASS
 main( argc, argv ) char *argv[]; {
index 59476ee..6b75d71 100644 (file)
@@ -1,51 +1,51 @@
-/*     PDP11 Registers */
+/*     VAX-11/780 Registers */
 
        /* scratch registers */
 # define R0 0
 # define R1 1
 
        /* scratch registers */
 # define R0 0
 # define R1 1
-
-       /* register variables */
 # define R2 2
 # define R3 3
 # define R4 4
 # define R2 2
 # define R3 3
 # define R4 4
+# define R5 5
+
+       /* register variables */
+# define R6 6
+# define R7 7
+# define R8 8
+# define R9 9
+# define R10 10
+# define R11 11
 
        /* special purpose */
 
        /* special purpose */
-# define R5 5  /* frame pointer */
-# define SP 6  /* stack pointer */
-# define PC 7  /* program counter */
+# define AP 12         /* argument pointer */
+# define FP 13         /* frame pointer */
+# define SP 14 /* stack pointer */
+# define PC 15 /* program counter */
 
        /* floating registers */
 
 
        /* floating registers */
 
-# define FR0 8
-# define FR1 9
-# define FR2 10
-# define FR3 11
-# define FR4 12
-# define FR5 13
+       /* there are no floating point registers on the VAX */
 
 
-# define SAVEREGION 8 /* number of bytes for save area */
+extern int fregs;
+extern int maxargs;
 
 
-# define BYTEOFF(x) ((x)&01)
+# define BYTEOFF(x) ((x)&03)
 # define wdal(k) (BYTEOFF(k)==0)
 # define BITOOR(x) ((x)>>3)  /* bit offset to oreg offset */
 
 # define wdal(k) (BYTEOFF(k)==0)
 # define BITOOR(x) ((x)>>3)  /* bit offset to oreg offset */
 
-# define REGSZ 14
+# define REGSZ 16
 
 
-# define TMPREG R5
+# define TMPREG FP
 
 
+# define R2REGS   /* permit double indexing */
 
 # define STOARG(p)     /* just evaluate the arguments, and be done with it... */
 # define STOFARG(p)
 # define STOSTARG(p)
 # define genfcall(a,b) gencall(a,b)
 
 
 # define STOARG(p)     /* just evaluate the arguments, and be done with it... */
 # define STOFARG(p)
 # define STOSTARG(p)
 # define genfcall(a,b) gencall(a,b)
 
+# define NESTCALL
 
 
-       /* shape for constants between -128 and 127 */
-# define SCCON (SPECIAL+100)
-       /* shape for constants between 0 and 32767 */
-# define SICON (SPECIAL+101)
-
-# define MYREADER(p) myreader(p)
-extern int fltused;
-       /* calls can be nested on the PDP-11 */
-# define NESTCALLS
+# define MYREADER(p) walkf(p, optim2)
+int optim2();
+# define special(a, b) 0
index 07289e9..2f6308e 100644 (file)
@@ -1,23 +1,23 @@
-# define makecc(val,i)  lastcon = i ? (val<<8)|lastcon : val  
+# define makecc(val,i)  lastcon = (lastcon<<8)|((val<<24)>>24);  
 
 # define  ARGINIT 32 
 
 # define  ARGINIT 32 
-# define  AUTOINIT 48 
+# define  AUTOINIT 0 
 # define  SZCHAR 8
 # define  SZCHAR 8
-# define  SZINT 16
+# define  SZINT 32
 # define  SZFLOAT 32
 # define  SZDOUBLE 64
 # define  SZLONG 32
 # define  SZSHORT 16
 # define  SZFLOAT 32
 # define  SZDOUBLE 64
 # define  SZLONG 32
 # define  SZSHORT 16
-# define SZPOINT 16
+# define SZPOINT 32
 # define ALCHAR 8
 # define ALCHAR 8
-# define ALINT 16
-# define ALFLOAT 16
-# define ALDOUBLE 16
-# define ALLONG 16
+# define ALINT 32
+# define ALFLOAT 32
+# define ALDOUBLE 32
+# define ALLONG 32
 # define ALSHORT 16
 # define ALSHORT 16
-# define ALPOINT 16
-# define ALSTRUCT 16
-# define  ALSTACK 16 
+# define ALPOINT 32
+# define ALSTRUCT 8
+# define  ALSTACK 32 
 
 /*     size in which constants are converted */
 /*     should be long if feasable */
 
 /*     size in which constants are converted */
 /*     should be long if feasable */
 
 /* register cookie for stack poINTer */
 
 
 /* register cookie for stack poINTer */
 
-# define  STKREG 5
-# define ARGREG 5
+# define  STKREG 13
+# define ARGREG 12
 
 /*     maximum and minimum register variables */
 
 
 /*     maximum and minimum register variables */
 
-# define MAXRVAR 4
-# define MINRVAR 2
+# define MAXRVAR 11
+# define MINRVAR 6
 
        /* various standard pieces of code are used */
 # define STDPRTREE
 # define LABFMT "L%d"
 
 
        /* various standard pieces of code are used */
 # define STDPRTREE
 # define LABFMT "L%d"
 
-/* definition indicates automatics and/or temporaries
-   are on a negative growing stack */
+/* show stack grows negatively */
+#define BACKAUTO
+#define BACKTEMP
 
 
-# define BACKAUTO
-# define BACKTEMP
+/* show field hardware support on VAX */
+#define FIELDOPS
 
 
-# define RTOLBYTES
-# ifndef FORT
-# define ONEPASS
-# endif
+/* bytes are numbered from right to left */
+#define RTOLBYTES
 
 
+/* we want prtree included */
+# define STDPRTREE
 # ifndef FORT
 # ifndef FORT
-# define EXIT dexit
-# endif
+# define ONEPASS
+#endif
 
 # define ENUMSIZE(high,low) INT
 
 # define ENUMSIZE(high,low) INT
+
index c10af76..1ca8e9a 100644 (file)
@@ -1,20 +1,11 @@
-INSTALL=/usr/lib/ccom
+INSTALL=ccom
+FINSTALL=f1
 M=/usr/src/cmd/mip
 M=/usr/src/cmd/mip
-CFLAGS=-O
-head:  ccom ;
-
-all:   ccom
-
-cp:    ccom
-       cp ccom /usr/lib/ccom
-       rm *.o cgram.c ccom
-
-cmp:   ccom
-       cmp ccom /usr/lib/ccom
-       rm *.o cgram.c ccom
-
-ccom: cgram.o xdefs.o scan.o pftn.o trees.o optim.o code.o local.o reader.o local2.o order.o match.o allo.o comm1.o table.o
-       cc $(CFLAGS) -s -o ccom -i cgram.o xdefs.o scan.o pftn.o trees.o optim.o code.o local.o reader.o local2.o order.o match.o allo.o comm1.o table.o
+CFLAGS=-O 
+head:  comp ;
+comp: rodata.o cgram.o xdefs.o scan.o pftn.o trees.o optim.o code.o local.o reader.o local2.o order.o match.o allo.o comm1.o table.o
+       cc $(CFLAGS) -i rodata.o cgram.o xdefs.o scan.o pftn.o trees.o optim.o code.o local.o  reader.o local2.o order.o match.o allo.o comm1.o table.o
+       mv a.out comp
 trees.o: $M/manifest macdefs $M/mfile1 $M/trees.c
        cc -c $(CFLAGS) -I$M -I. $M/trees.c
 optim.o: $M/manifest macdefs $M/mfile1 $M/optim.c
 trees.o: $M/manifest macdefs $M/mfile1 $M/trees.c
        cc -c $(CFLAGS) -I$M -I. $M/trees.c
 optim.o: $M/manifest macdefs $M/mfile1 $M/optim.c
@@ -29,15 +20,24 @@ scan.o: $M/manifest macdefs $M/mfile1 $M/scan.c
        cc -c $(CFLAGS) -I$M -I. $M/scan.c
 xdefs.o: $M/manifest $M/mfile1 macdefs $M/xdefs.c
        cc -c $(CFLAGS) -I$M -I. $M/xdefs.c
        cc -c $(CFLAGS) -I$M -I. $M/scan.c
 xdefs.o: $M/manifest $M/mfile1 macdefs $M/xdefs.c
        cc -c $(CFLAGS) -I$M -I. $M/xdefs.c
-cgram.o: $M/manifest $M/mfile1 macdefs cgram.c
-       cc -c $(CFLAGS) -I$M -I. cgram.c
-cgram.c: $M/cgram.y
+cgram.o: $M/manifest $M/mfile1 macdefs $M/cgram.c
+       cc -c $(CFLAGS) -I$M -I. $M/cgram.c
+rodata.o $M/cgram.c: $M/cgram.y
        yacc $M/cgram.y
        yacc $M/cgram.y
-       mv y.tab.c cgram.c
+       rm -f rodata.c
+       :yyfix yyexca yyact yypact yypgo yyr1 yyr2 yychk yydef
+       mv y.tab.c $M/cgram.c
+       cc $(CFLAGS) -S rodata.c
+       :rofix rodata.s
+       as -o rodata.o rodata.s
+       rm -f rodata.s rodata.c
 comm1.o: $M/manifest $M/mfile1 $M/common macdefs $M/comm1.c
        cc -c $(CFLAGS) -I. -I$M $M/comm1.c
 table.o: $M/manifest $M/mfile2 mac2defs macdefs table.c
 comm1.o: $M/manifest $M/mfile1 $M/common macdefs $M/comm1.c
        cc -c $(CFLAGS) -I. -I$M $M/comm1.c
 table.o: $M/manifest $M/mfile2 mac2defs macdefs table.c
-       cc -c $(CFLAGS) -I$M -I. table.c
+       cc $(CFLAGS) -S -I$M -I. table.c
+       :rofix table.s
+       as -o table.o table.s
+       rm -f table.s
 reader.o: $M/manifest $M/mfile2 mac2defs macdefs $M/reader.c
        cc -c $(CFLAGS) -I$M -I. $M/reader.c
 local2.o: $M/manifest $M/mfile2 mac2defs macdefs
 reader.o: $M/manifest $M/mfile2 mac2defs macdefs $M/reader.c
        cc -c $(CFLAGS) -I$M -I. $M/reader.c
 local2.o: $M/manifest $M/mfile2 mac2defs macdefs
@@ -49,10 +49,12 @@ match.o: $M/manifest $M/mfile2 mac2defs macdefs $M/match.c
 allo.o: $M/manifest $M/mfile2 mac2defs macdefs $M/allo.c
        cc -c $(CFLAGS) -I$M -I. $M/allo.c
 shrink:
 allo.o: $M/manifest $M/mfile2 mac2defs macdefs $M/allo.c
        cc -c $(CFLAGS) -I$M -I. $M/allo.c
 shrink:
-       rm *.o ccom
+       rm *.o comp
+clean:
+       rm *.o comp
 lintall:
 lintall:
-       lint -hpv -I. -I$M  cgram.c xdefs.c $M/scan.c $M/pftn.c $M/trees.c $M/optim.c code.c local.c $M/reader.c local2.c order.c $M/match.c $M/allo.c $M/comm1.c table.c
-fort: ccom fort.o freader.o fallo.o fmatch.o ftable.o forder.o flocal2.o fcomm2.o
+       lint -hpv -I. -I$M  $M/cgram.c $M/xdefs.c $M/scan.c $M/pftn.c $M/trees.c $M/optim.c code.c local.c $M/reader.c local2.c order.c $M/match.c $M/allo.c $M/comm1.c table.c
+fort: comp fort.o freader.o fallo.o fmatch.o ftable.o forder.o flocal2.o fcomm2.o
        cc -i $(CFLAGS) fort.o freader.o fallo.o fmatch.o ftable.o forder.o flocal2.o fcomm2.o
        mv a.out fort
 fort.o: fort.h $M/fort.c
        cc -i $(CFLAGS) fort.o freader.o fallo.o fmatch.o ftable.o forder.o flocal2.o fcomm2.o
        mv a.out fort
 fort.o: fort.h $M/fort.c
@@ -64,7 +66,10 @@ fallo.o: allo.o
 fmatch.o: match.o
        cc -c $(CFLAGS) -I$M -I. $M/fmatch.c
 ftable.o: table.o
 fmatch.o: match.o
        cc -c $(CFLAGS) -I$M -I. $M/fmatch.c
 ftable.o: table.o
-       cc -c $(CFLAGS) -I$M -I. $M/ftable.c
+       cc -S $(CFLAGS) -I$M -I. $M/ftable.c
+       :rofix ftable.s
+       as -o ftable.o ftable.s
+       rm -f ftable.s
 forder.o: order.o
        cc -c $(CFLAGS) -I$M -I. $M/forder.c
 flocal2.o: local2.o
 forder.o: order.o
        cc -c $(CFLAGS) -I$M -I. $M/forder.c
 flocal2.o: local2.o
@@ -72,6 +77,6 @@ flocal2.o: local2.o
 fcomm2.o: $M/common
        cc -c $(CFLAGS) -I$M -I. $M/fcomm2.c
 fort.o freader.o fallo.o fmatch.o ftable.o forder.o flocal2.o fcomm2.o: $M/mfile2 $M/manifest macdefs mac2defs
 fcomm2.o: $M/common
        cc -c $(CFLAGS) -I$M -I. $M/fcomm2.c
 fort.o freader.o fallo.o fmatch.o ftable.o forder.o flocal2.o fcomm2.o: $M/mfile2 $M/manifest macdefs mac2defs
-install:
-       cp ccom $(INSTALL)
-       cp macdefs mac2defs local.c code.c local2.c order.c table.c /usr/src/cmd/pcc
+install: comp fort
+       install -s comp $(DESTDIR)/lib/$(INSTALL)
+       install -s fort $(DESTDIR)/lib/$(FINSTALL)
index e21f334..d94353f 100644 (file)
@@ -1,25 +1,31 @@
 # include "mfile2"
 
 # include "mfile2"
 
-int fltused = 0;
+int maxargs = { -1 };
 
 stoasg( p, o ) register NODE *p; {
        /* should the assignment op p be stored,
           given that it lies as the right operand of o
           (or the left, if o==UNARY MUL) */
 
 stoasg( p, o ) register NODE *p; {
        /* should the assignment op p be stored,
           given that it lies as the right operand of o
           (or the left, if o==UNARY MUL) */
-       return( shltype(p->left->op, p->left ) );
-
+/*
+       if( p->op == INCR || p->op == DECR ) return;
+       if( o==UNARY MUL && p->left->op == REG && !isbreg(p->left->rval) ) SETSTO(p,INAREG);
+ */
        }
 
 deltest( p ) register NODE *p; {
        /* should we delay the INCR or DECR operation p */
        }
 
 deltest( p ) register NODE *p; {
        /* should we delay the INCR or DECR operation p */
-       if( p->op == INCR && p->left->op == REG && spsz( p->left->type, p->right->lval ) ){
-               /* STARREG */
-               return( 0 );
-               }
-
        p = p->left;
        p = p->left;
-       if( p->op == UNARY MUL ) p = p->left;
-       return( p->op == NAME || p->op == OREG || p->op == REG );
+       return( p->op == REG || p->op == NAME || p->op == OREG );
+       }
+
+autoincr( p ) NODE *p; {
+       register NODE *q = p->left, *r;
+
+       if( q->op == INCR && (r=q->left)->op == REG &&
+           ISPTR(q->type) && p->type == DECREF(q->type) &&
+           tlen(p) == q->right->lval ) return(1);
+
+       return(0);
        }
 
 mkadrs(p) register NODE *p; {
        }
 
 mkadrs(p) register NODE *p; {
@@ -30,12 +36,7 @@ mkadrs(p) register NODE *p; {
        if( asgop(o) ){
                if( p->left->su >= p->right->su ){
                        if( p->left->op == UNARY MUL ){
        if( asgop(o) ){
                if( p->left->su >= p->right->su ){
                        if( p->left->op == UNARY MUL ){
-                               if( p->left->su > 0 )
-                                       SETSTO( p->left->left, INTEMP );
-                               else {
-                                       if( p->right->su > 0 ) SETSTO( p->right, INTEMP );
-                                       else cerror( "store finds both sides trivial" );
-                                       }
+                               SETSTO( p->left->left, INTEMP );
                                }
                        else if( p->left->op == FLD && p->left->left->op == UNARY MUL ){
                                SETSTO( p->left->left->left, INTEMP );
                                }
                        else if( p->left->op == FLD && p->left->left->op == UNARY MUL ){
                                SETSTO( p->left->left->left, INTEMP );
@@ -56,71 +57,47 @@ mkadrs(p) register NODE *p; {
                }
        }
 
                }
        }
 
-notoff( t, r, off, cp) TWORD t; CONSZ off; char *cp; {
+notoff( t, r, off, cp) CONSZ off; char *cp; {
        /* is it legal to make an OREG or NAME entry which has an
        /* offset of off, (from a register of r), if the
        /* resulting thing had type t */
 
        /* is it legal to make an OREG or NAME entry which has an
        /* offset of off, (from a register of r), if the
        /* resulting thing had type t */
 
-       /* return( 1 );  /* NO */
+/*     if( r == R0 ) return( 1 );  /* NO */
        return(0);  /* YES */
        }
 
 # define max(x,y) ((x)<(y)?(y):(x))
        return(0);  /* YES */
        }
 
 # define max(x,y) ((x)<(y)?(y):(x))
-# define min(x,y) ((x)<(y)?(x):(y))
-
-
-# define ZCHAR 01
-# define ZLONG 02
-# define ZFLOAT 04
-
-zum( p, zap ) register NODE *p; {
-       /* zap Sethi-Ullman number for chars, longs, floats */
-       /* in the case of longs, only STARNM's are zapped */
-       /* ZCHAR, ZLONG, ZFLOAT are used to select the zapping */
-
-       register su;
-
-       su = p->su;
-
-       switch( p->type ){
-
-       case CHAR:
-       case UCHAR:
-               if( !(zap&ZCHAR) ) break;
-               if( su == 0 ) p->su = su = 1;
-               break;
-
-       case LONG:
-       case ULONG:
-               if( !(zap&ZLONG) ) break;
-               if( p->op == UNARY MUL && su == 0 ) p->su = su = 2;
-               break;
-
-       case FLOAT:
-               if( !(zap&ZFLOAT) ) break;
-               if( su == 0 ) p->su = su = 1;
-
-               }
-
-       return( su );
-       }
 
 sucomp( p ) register NODE *p; {
 
        /* set the su field in the node to the sethi-ullman
           number, or local equivalent */
 
 
 sucomp( p ) register NODE *p; {
 
        /* set the su field in the node to the sethi-ullman
           number, or local equivalent */
 
-       register o, ty, sul, sur;
-       register nr;
-
-       ty = optype( o=p->op);
-       nr = szty( p->type );
-       p->su = 0;
+       register o, ty, sul, sur, r;
 
 
-       if( ty == LTYPE ) {
-               if( p->type==FLOAT ) p->su = 1;
+       o = p->op;
+       ty = optype( o );
+       p->su = szty( p->type );   /* 2 for float or double, else 1 */;
+
+       if( ty == LTYPE ){
+               if( o == OREG ){
+                       r = p->rval;
+                       /* oreg cost is (worst case) 1 + number of temp registers used */
+                       if( R2TEST(r) ){
+                               if( R2UPK1(r)!=100 && istreg(R2UPK1(r)) ) ++p->su;
+                               if( istreg(R2UPK2(r)) ) ++p->su;
+                               }
+                       else {
+                               if( istreg( r ) ) ++p->su;
+                               }
+                       }
+               if( p->su == szty(p->type) &&
+                  (p->op!=REG || !istreg(p->rval)) &&
+                  (p->type==INT || p->type==UNSIGNED || p->type==DOUBLE) )
+                       p->su = 0;
                return;
                }
                return;
                }
+
        else if( ty == UTYPE ){
                switch( o ) {
                case UNARY CALL:
        else if( ty == UTYPE ){
                switch( o ) {
                case UNARY CALL:
@@ -128,11 +105,8 @@ sucomp( p ) register NODE *p; {
                        p->su = fregs;  /* all regs needed */
                        return;
 
                        p->su = fregs;  /* all regs needed */
                        return;
 
-               case UNARY MUL:
-                       if( shumul( p->left ) ) return;
-
                default:
                default:
-                       p->su = max( p->left->su, nr);
+                       p->su =  p->left->su + (szty( p->type ) > 1 ? 2 : 0) ;
                        return;
                        }
                }
                        return;
                        }
                }
@@ -144,23 +118,8 @@ sucomp( p ) register NODE *p; {
        sur = p->right->su;
 
        if( o == ASSIGN ){
        sur = p->right->su;
 
        if( o == ASSIGN ){
-               asop:  /* also used for +=, etc., to memory */
-               if( sul==0 ){
-                       /* don't need to worry about the left side */
-                       p->su = max( sur, nr );
-                       }
-               else {
-                       /* right, left address, op */
-                       if( sur == 0 ){
-                               /* just get the lhs address into a register, and mov */
-                               /* the `nr' covers the case where value is in reg afterwards */
-                               p->su = max( sul, nr );
-                               }
-                       else {
-                               /* right, left address, op */
-                               p->su = max( sur, nr+sul );
-                               }
-                       }
+               /* computed by doing right, then left (if not in mem), then doing it */
+               p->su = max(sur,sul+1);
                return;
                }
 
                return;
                }
 
@@ -172,61 +131,17 @@ sucomp( p ) register NODE *p; {
 
        if( o == STASG ){
                /* right, then left */
 
        if( o == STASG ){
                /* right, then left */
-               p->su = max( max( sul+nr, sur), fregs );
-               return;
-               }
-
-       if( logop(o) ){
-               /* do the harder side, then the easier side, into registers */
-               /* left then right, max(sul,sur+nr) */
-               /* right then left, max(sur,sul+nr) */
-               /* to hold both sides in regs: nr+nr */
-               nr = szty( p->left->type );
-               sul = zum( p->left, ZLONG|ZCHAR|ZFLOAT );
-               sur = zum( p->right, ZLONG|ZCHAR|ZFLOAT );
-               p->su = min( max(sul,sur+nr), max(sur,sul+nr) );
+               p->su = max( max( 1+sul, sur), fregs );
                return;
                }
 
        if( asgop(o) ){
                /* computed by doing right, doing left address, doing left, op, and store */
                return;
                }
 
        if( asgop(o) ){
                /* computed by doing right, doing left address, doing left, op, and store */
-               switch( o ) {
-               case INCR:
-               case DECR:
-                       /* do as binary op */
-                       break;
-
-               case ASG DIV:
-               case ASG MOD:
-               case ASG MUL:
-                       if( p->type!=FLOAT && p->type!=DOUBLE ) nr = fregs;
-                       goto gencase;
-
-               case ASG PLUS:
-               case ASG MINUS:
-               case ASG AND:  /* really bic */
-               case ASG OR:
-                       if( p->type == INT || p->type == UNSIGNED || ISPTR(p->type) ) goto asop;
-
-               gencase:
-               default:
-                       sur = zum( p->right, ZCHAR|ZLONG|ZFLOAT );
-                       if( sur == 0 ){ /* easy case: if addressable,
-                               do left value, op, store */
-                               if( sul == 0 ) p->su = nr;
-                               /* harder: left adr, val, op, store */
-                               else p->su = max( sul, nr+1 );
-                               }
-                       else { /* do right, left adr, left value, op, store */
-                               if( sul == 0 ){  /* right, left value, op, store */
-                                       p->su = max( sur, nr+nr );
-                                       }
-                               else {
-                                       p->su = max( sur, max( sul+nr, 1+nr+nr ) );
-                                       }
-                               }
-                       return;
-                       }
+               p->su = max(sur,sul+2);
+/*
+               if( o==ASG MUL || o==ASG DIV || o==ASG MOD) p->su = max(p->su,fregs);
+ */
+               return;
                }
 
        switch( o ){
                }
 
        switch( o ){
@@ -235,95 +150,37 @@ sucomp( p ) register NODE *p; {
        case QUEST:
        case COLON:
        case COMOP:
        case QUEST:
        case COLON:
        case COMOP:
-               p->su = max( max(sul,sur), nr);
+               p->su = max( max(sul,sur), 1);
                return;
                return;
-               }
-
-       if( ( o==DIV || o==MOD || o==MUL )
-           && p->type!=FLOAT && p->type!=DOUBLE ) nr = fregs;
-       if( o==PLUS || o==MUL || o==OR || o==ER ){
-               /* AND is ruined by the hardware */
-               /* permute: get the harder on the left */
 
 
-               register rt, lt;
-
-               if( istnode( p->left ) || sul > sur ) goto noswap;  /* don't do it! */
-
-               /* look for a funny type on the left, one on the right */
-
-
-               lt = p->left->type;
-               rt = p->right->type;
-
-               if( rt == FLOAT && lt == DOUBLE ) goto swap;
-
-               if( (rt==CHAR||rt==UCHAR) && (lt==INT||lt==UNSIGNED||ISPTR(lt)) ) goto swap;
-
-               if( lt==LONG || lt==ULONG ){
-                       if( rt==LONG || rt==ULONG ){
-                               /* if one is a STARNM, swap */
-                               if( p->left->op == UNARY MUL && sul==0 ) goto noswap;
-                               if( p->right->op == UNARY MUL && p->left->op != UNARY MUL ) goto swap;
-                               goto noswap;
-                               }
-                       else if( p->left->op == UNARY MUL && sul == 0 ) goto noswap;
-                       else goto swap;  /* put long on right, unless STARNM */
-                       }
-
-               /* we are finished with the type stuff now; if one is addressable,
-                       put it on the right */
-               if( sul == 0 && sur != 0 ){
-
-                       NODE *s;
-                       int ssu;
-
-               swap:
-                       ssu = sul;  sul = sur; sur = ssu;
-                       s = p->left;  p->left = p->right; p->right = s;
+       case PLUS:
+       case OR:
+       case ER:
+               /* commutative ops; put harder on left */
+               if( p->right->su > p->left->su && !istnode(p->left) ){
+                       register NODE *temp;
+                       temp = p->left;
+                       p->left = p->right;
+                       p->right = temp;
                        }
                        }
+               break;
                }
                }
-       noswap:
 
 
-       sur = zum( p->right, ZCHAR|ZLONG|ZFLOAT );
-       if( sur == 0 ){
-               /* get left value into a register, do op */
-               p->su = max( nr, sul );
-               }
-       else {
-               /* do harder into a register, then easier */
-               p->su = max( nr+nr, min( max( sul, nr+sur ), max( sur, nr+sul ) ) );
-               }
+       /* binary op, computed by left, then right, then do op */
+       p->su = max(sul,szty(p->right->type)+sur);
+/*
+       if( o==MUL||o==DIV||o==MOD) p->su = max(p->su,fregs);
+ */
+
        }
 
 int radebug = 0;
 
        }
 
 int radebug = 0;
 
-mkrall( p, r ) register NODE *p; {
-       /* insure that the use of p gets done with register r; in effect, */
-       /* simulate offstar */
-
-       if( p->op == FLD ){
-               p->left->rall = p->rall;
-               p = p->left;
-               }
-
-       if( p->op != UNARY MUL ) return;  /* no more to do */
-       p = p->left;
-       if( p->op == UNARY MUL ){
-               p->rall = r;
-               p = p->left;
-               }
-       if( p->op == PLUS && p->right->op == ICON ){
-               p->rall = r;
-               p = p->left;
-               }
-       rallo( p, r );
-       }
-
-rallo( p, down ) register NODE *p; {
+rallo( p, down ) NODE *p; {
        /* do register allocation */
        register o, type, down1, down2, ty;
 
        /* do register allocation */
        register o, type, down1, down2, ty;
 
-       if( radebug ) printf( "rallo( %o, %o )\n", p, down );
+       if( radebug ) printf( "rallo( %o, %d )\n", p, down );
 
        down2 = NOPREF;
        p->rall = down;
 
        down2 = NOPREF;
        p->rall = down;
@@ -334,8 +191,7 @@ rallo( p, down ) register NODE *p; {
 
 
        if( type == DOUBLE || type == FLOAT ){
 
 
        if( type == DOUBLE || type == FLOAT ){
-               if( o == FORCE ) down1 = FR0|MUSTDO;
-               ++fltused;
+               if( o == FORCE ) down1 = R0|MUSTDO;
                }
        else switch( o ) {
        case ASSIGN:    
                }
        else switch( o ) {
        case ASSIGN:    
@@ -343,43 +199,28 @@ rallo( p, down ) register NODE *p; {
                down2 = down;
                break;
 
                down2 = down;
                break;
 
-       case ASG MUL:
-       case ASG DIV:
-       case ASG MOD:
-               /* keep the addresses out of the hair of (r0,r1) */
-               if(fregs == 2 ){
-                       /* lhs in (r0,r1), nothing else matters */
-                       down1 = R1|MUSTDO;
-                       down2 = NOPREF;
-                       break;
-                       }
-               /* at least 3 regs free */
-               /* compute lhs in (r0,r1), address of left in r2 */
-               p->left->rall = R1|MUSTDO;
-               mkrall( p->left, R2|MUSTDO );
-               /* now, deal with right */
-               if( fregs == 3 ) rallo( p->right, NOPREF );
-               else {
-                       /* put address of long or value here */
-                       p->right->rall = R3|MUSTDO;
-                       mkrall( p->right, R3|MUSTDO );
-                       }
-               return;
-
+/*
        case MUL:
        case DIV:
        case MOD:
        case MUL:
        case DIV:
        case MOD:
-               rallo( p->left, R1|MUSTDO );
+               down1 = R3|MUSTDO;
+               down2 = R5|MUSTDO;
+               break;
 
 
-               if( fregs == 2 ){
-                       rallo( p->right, NOPREF );
-                       return;
+       case ASG MUL:
+       case ASG DIV:
+       case ASG MOD:
+               p->left->rall = down1 = R3|MUSTDO;
+               if( p->left->op == UNARY MUL ){
+                       rallo( p->left->left, R4|MUSTDO );
                        }
                        }
-               /* compute addresses, stay away from (r0,r1) */
-
-               p->right->rall = (fregs==3) ? R2|MUSTDO : R3|MUSTDO ;
-               mkrall( p->right, R2|MUSTDO );
+               else if( p->left->op == FLD  && p->left->left->op == UNARY MUL ){
+                       rallo( p->left->left->left, R4|MUSTDO );
+                       }
+               else rallo( p->left, R3|MUSTDO );
+               rallo( p->right, R5|MUSTDO );
                return;
                return;
+ */
 
        case CALL:
        case STASG:
 
        case CALL:
        case STASG:
@@ -407,103 +248,92 @@ rallo( p, down ) register NODE *p; {
        }
 
 offstar( p ) register NODE *p; {
        }
 
 offstar( p ) register NODE *p; {
-       /* handle indirections */
-
-       if( p->op == UNARY MUL ) p = p->left;
-
+       if( p->op == PLUS ) {
+               if( p->left->su == fregs ) {
+                       order( p->left, INTAREG|INAREG );
+                       return;
+               } else if( p->right->su == fregs ) {
+                       order( p->right, INTAREG|INAREG );
+                       return;
+               }
+               if( p->left->op==LS && 
+                 (p->left->left->op!=REG || tlen(p->left->left)!=sizeof(int) ) ) {
+                       order( p->left->left, INTAREG|INAREG );
+                       return;
+               }
+               if( p->right->op==LS &&
+                 (p->right->left->op!=REG || tlen(p->right->left)!=sizeof(int) ) ) {
+                       order( p->right->left, INTAREG|INAREG );
+                       return;
+               }
+               if( p->type == (PTR|CHAR) || p->type == (PTR|UCHAR) ) {
+                       if( p->left->op!=REG || tlen(p->left)!=sizeof(int) ) {
+                               order( p->left, INTAREG|INAREG );
+                               return;
+                       }
+                       else if( p->right->op!=REG || tlen(p->right)!=sizeof(int) ) {
+                               order(p->right, INTAREG|INAREG);
+                               return;
+                       }
+               }
+       }
        if( p->op == PLUS || p->op == MINUS ){
                if( p->right->op == ICON ){
        if( p->op == PLUS || p->op == MINUS ){
                if( p->right->op == ICON ){
-                       order( p->left , INTAREG|INAREG );
+                       p = p->left;
+                       order( p , INTAREG|INAREG);
                        return;
                        }
                }
                        return;
                        }
                }
+
+       if( p->op == UNARY MUL && !canaddr(p) ) {
+               offstar( p->left );
+               return;
+       }
+
        order( p, INTAREG|INAREG );
        }
 
 setincr( p ) NODE *p; {
        order( p, INTAREG|INAREG );
        }
 
 setincr( p ) NODE *p; {
-       return( 0 );    /* for the moment, don't bother */
+       return( 0 );  /* for the moment, don't bother */
        }
 
        }
 
-niceuty( p ) register NODE *p; {
-       register TWORD t;
-
-       return( p->op == UNARY MUL && (t=p->type)!=CHAR &&
-               t!= UCHAR && t!= FLOAT &&
-               shumul( p->left) != STARREG );
-       }
 setbin( p ) register NODE *p; {
 setbin( p ) register NODE *p; {
-       register NODE *r, *l;
+       register ro, rt;
 
 
-       r = p->right;
-       l = p->left;
+       rt = p->right->type;
+       ro = p->right->op;
 
 
-       if( p->right->su == 0 ){ /* rhs is addressable */
-               if( logop( p->op ) ){
-                       if( l->op == UNARY MUL && l->type != FLOAT && shumul( l->left ) != STARREG ) offstar( l->left );
-                       else order( l, INAREG|INTAREG|INBREG|INTBREG|INTEMP );
-                       return( 1 );
-                       }
-               if( !istnode( l ) ){
-                       order( l, INTAREG|INTBREG );
-                       return( 1 );
-                       }
-               /* rewrite */
-               return( 0 );
+       if( canaddr( p->left ) && !canaddr( p->right ) ) { /* address rhs */
+               if( ro == UNARY MUL ) {
+                       offstar( p->right->left );
+                       return(1);
+               } else {
+                       order( p->right, INAREG|INTAREG|SOREG );
+                       return(1);
                }
                }
-       /* now, rhs is complicated: must do both sides into registers */
-       /* do the harder side first */
-
-       if( logop( p->op ) ){
-               /* relational: do both sides into regs if need be */
-
-               if( r->su > l->su ){
-                       if( niceuty(r) ){
-                               offstar( r->left );
-                               return( 1 );
-                               }
-                       else if( !istnode( r ) ){
-                               order( r, INTAREG|INAREG|INTBREG|INBREG|INTEMP );
-                               return( 1 );
-                               }
-                       }
-               if( niceuty(l) ){
-                       offstar( l->left );
-                       return( 1 );
-                       }
-               else if( niceuty(r) ){
-                       offstar( r->left );
-                       return( 1 );
-                       }
-               else if( !istnode( l ) ){
-                       order( l, INTAREG|INAREG|INTBREG|INBREG|INTEMP );
-                       return( 1 );
-                       }
-               if( !istnode( r ) ){
-                       order( r, INTAREG|INAREG|INTBREG|INBREG|INTEMP );
-                       return( 1 );
-                       }
-               cerror( "setbin can't deal with %s", opst[p->op] );
+       }
+       if( !istnode( p->left) ) { /* try putting LHS into a reg */
+/*             order( p->left, logop(p->op)?(INAREG|INBREG|INTAREG|INTBREG|SOREG):(INTAREG|INTBREG|SOREG) );*/
+               order( p->left, INAREG|INTAREG|INBREG|INTBREG|SOREG );
+               return(1);
                }
                }
-
-       /* ordinary operator */
-
-       if( !istnode(r) && r->su > l->su ){
-               /* if there is a chance of making it addressable, try it... */
-               if( niceuty(r) ){
-                       offstar( r->left );
-                       return( 1 );  /* hopefully, it is addressable by now */
-                       }
-               order( r, INTAREG|INAREG|INTBREG|INBREG|INTEMP );  /* anything goes on rhs */
-               return( 1 );
+       else if( ro == UNARY MUL && rt != CHAR && rt != UCHAR ){
+               offstar( p->right->left );
+               return(1);
                }
                }
-       else {
-               if( !istnode( l ) ){
-                       order( l, INTAREG|INTBREG );
-                       return( 1 );
-                       }
-               /* rewrite */
-               return( 0 );
+       else if( rt == CHAR || rt == UCHAR || rt == SHORT || rt == USHORT || (ro != REG &&
+                       ro != NAME && ro != OREG && ro != ICON ) ){
+               order( p->right, INAREG|INBREG );
+               return(1);
                }
                }
+/*
+       else if( logop(p->op) && rt==USHORT ){  /* must get rhs into register */
+/*
+               order( p->right, INAREG );
+               return( 1 );
+               }
+ */
+       return(0);
        }
 
 setstr( p ) register NODE *p; { /* structure assignment */
        }
 
 setstr( p ) register NODE *p; { /* structure assignment */
@@ -523,18 +353,14 @@ setstr( p ) register NODE *p; { /* structure assignment */
 setasg( p ) register NODE *p; {
        /* setup for assignment operator */
 
 setasg( p ) register NODE *p; {
        /* setup for assignment operator */
 
-       if( p->right->su != 0 && p->right->op != REG ) {
+       if( !canaddr(p->right) ) {
                if( p->right->op == UNARY MUL )
                if( p->right->op == UNARY MUL )
-                       offstar( p->right->left );
+                       offstar(p->right->left);
                else
                else
-                       order( p->right, INAREG|INBREG|SOREG|SNAME|SCON );
-               return(1);
-               }
-       if( p->right->op != REG && ( p->type == FLOAT || p->type == DOUBLE ) ) {
-               order( p->right, INBREG );
+                       order( p->right, INAREG|INBREG|SOREG );
                return(1);
                }
                return(1);
                }
-       if( p->left->op == UNARY MUL && !tshape( p->left, STARREG|STARNM ) ){
+       if( p->left->op == UNARY MUL {
                offstar( p->left->left );
                return(1);
                }
                offstar( p->left->left );
                return(1);
                }
@@ -542,124 +368,82 @@ setasg( p ) register NODE *p; {
                offstar( p->left->left->left );
                return(1);
                }
                offstar( p->left->left->left );
                return(1);
                }
-       /* if things are really strange, get rhs into a register */
-       if( p->right->op != REG ){
-               order( p->right, INAREG|INBREG );
-               return( 1 );
+/* FLD patch */
+       if( p->left->op == FLD && !(p->right->type==INT || p->right->type==UNSIGNED)) {
+               order( p->right, INAREG);
+               return(1);
                }
                }
+/* end of FLD patch */
        return(0);
        }
 
 setasop( p ) register NODE *p; {
        /* setup for =ops */
        return(0);
        }
 
 setasop( p ) register NODE *p; {
        /* setup for =ops */
-       register sul, sur;
-       register NODE *q, *p2;
-
-       sul = p->left->su;
-       sur = p->right->su;
-
-       switch( p->op ){
+       register rt, ro;
 
 
-       case ASG PLUS:
-       case ASG OR:
-       case ASG MINUS:
-               if( p->type != INT && p->type != UNSIGNED && !ISPTR(p->type) ) break;
-               if( p->right->type == CHAR || p->right->type == UCHAR ){
-                       order( p->right, INAREG );
-                       return( 1 );
-                       }
-               break;
+       rt = p->right->type;
+       ro = p->right->op;
 
 
-       case ASG ER:
-               if( sul == 0 || p->left->op == REG ){
-                       if( p->left->type == CHAR || p->left->type == UCHAR ) goto rew;  /* rewrite */
-                       order( p->right, INAREG|INBREG );
-                       return( 1 );
-                       }
-               goto leftadr;
+       if( ro == UNARY MUL && rt != CHAR ){
+               offstar( p->right->left );
+               return(1);
                }
                }
+       if( ( rt == CHAR || rt == SHORT || rt == UCHAR || rt == USHORT ||
+                       ( ro != REG && ro != ICON && ro != NAME && ro != OREG ) ) ){
+               order( p->right, INAREG|INBREG );
+               return(1);
+               }
+/*
+       if( (p->op == ASG LS || p->op == ASG RS) && ro != ICON && ro != REG ){
+               order( p->right, INAREG );
+               return(1);
+               }
+ */
 
 
-       if( sur == 0 ){
-
-       leftadr:
-               /* easy case: if addressable, do left value, op, store */
-               if( sul == 0 ) goto rew;  /* rewrite */
-
-               /* harder; make aleft address, val, op, and store */
-
-               if( p->left->op == UNARY MUL ){
-                       offstar( p->left->left );
-                       return( 1 );
-                       }
-               if( p->left->op == FLD && p->left->left->op == UNARY MUL ){
-                       offstar( p->left->left->left );
-                       return( 1 );
-                       }
-       rew:    /* rewrite, accounting for autoincrement and autodecrement */
-
-               q = p->left;
-               if( q->op == FLD ) q = q->left;
-               if( q->op != UNARY MUL || shumul(q->left) != STARREG ) return(0); /* let reader.c do it */
-
-               /* mimic code from reader.c */
-
-               p2 = tcopy( p );
-               p->op = ASSIGN;
-               reclaim( p->right, RNULL, 0 );
-               p->right = p2;
-
-               /* now, zap INCR on right, ASG MINUS on left */
-
-               if( q->left->op == INCR ){
-                       q = p2->left;
-                       if( q->op == FLD ) q = q->left;
-                       if( q->left->op != INCR ) cerror( "bad incr rewrite" );
-                       }
-               else if( q->left->op != ASG MINUS )  cerror( " bad -= rewrite" );
 
 
-               q->left->right->op = FREE;
-               q->left->op = FREE;
-               q->left = q->left->left;
+       p = p->left;
+       if( p->op == FLD ) p = p->left;
 
 
-               /* now, resume reader.c rewriting code */
+       switch( p->op ){
 
 
-               canon(p);
-               rallo( p, p->rall );
-               order( p2->left, INTBREG|INTAREG );
-               order( p2, INTBREG|INTAREG );
-               return( 1 );
-               }
+       case REG:
+       case ICON:
+       case NAME:
+       case OREG:
+               return(0);
 
 
-       /* harder case: do right, left address, left value, op, store */
+       case UNARY MUL:
+               if( p->left->op==OREG )
+                       return(0);
+               else
+                       offstar( p->left );
+               return(1);
 
 
-       if( p->right->op == UNARY MUL ){
-               offstar( p->right->left );
-               return( 1 );
                }
                }
-       /* sur> 0, since otherwise, done above */
-       if( p->right->op == REG ) goto leftadr;  /* make lhs addressable */
-       order( p->right, INAREG|INBREG );
-       return( 1 );
+       cerror( "illegal setasop" );
        }
 
        }
 
-int crslab = 10000;
+int crslab = 9999;  /* Honeywell */
 
 getlab(){
 
 getlab(){
-       return( crslab++ );
+       return( crslab-- );
        }
 
 deflab( l ){
        printf( "L%d:\n", l );
        }
 
        }
 
 deflab( l ){
        printf( "L%d:\n", l );
        }
 
-genargs( p) register NODE *p; {
+genargs( p, ptemp ) register NODE *p, *ptemp; {
+       register NODE *pasg;
+       register align;
        register size;
        register size;
+       register TWORD type;
 
        /* generate code for the arguments */
 
 
        /* generate code for the arguments */
 
-       /*  first, do the arguments on the right (last->first) */
+       /*  first, do the arguments on the right */
        while( p->op == CM ){
        while( p->op == CM ){
-               genargs( p->right );
+               genargs( p->right, ptemp );
                p->op = FREE;
                p = p->left;
                }
                p->op = FREE;
                p = p->left;
                }
@@ -667,30 +451,23 @@ genargs( p) register NODE *p; {
        if( p->op == STARG ){ /* structure valued argument */
 
                size = p->stsize;
        if( p->op == STARG ){ /* structure valued argument */
 
                size = p->stsize;
-               if( p->left->op == ICON ){
-                       /* make into a name node */
-                       p->op = FREE;
-                       p= p->left;
-                       p->op = NAME;
-                       }
-               else {
-                       /* make it look beautiful... */
-                       p->op = UNARY MUL;
-                       canon( p );  /* turn it into an oreg */
-                       if( p->op != OREG ){
-                               offstar( p->left );
-                               canon( p );
-                               if( p->op != OREG ) cerror( "stuck starg" );
-                               }
-                       }
+               align = p->stalign;
 
 
-               p->lval += size;  /* end of structure */
-               /* put on stack backwards */
-               for( ; size>0; size -= 2 ){
-                       p->lval -= 2;
-                       expand( p, RNOP, "      mov     AR,Z-\n" );
-                       }
-               reclaim( p, RNULL, 0 );
+ /*            ptemp->lval = (ptemp->lval/align)*align;  /* SETOFF for negative numbers */
+               ptemp->lval = 0;        /* all moves to (sp) */
+
+               p->op = STASG;
+               p->right = p->left;
+               p->left = tcopy( ptemp );
+
+               /* the following line is done only with the knowledge
+               that it will be undone by the STASG node, with the
+               offset (lval) field retained */
+
+               if( p->right->op == OREG ) p->right->op = REG;  /* only for temporaries */
+
+               order( p, FORARG );
+               ptemp->lval += size;
                return;
                }
 
                return;
                }
 
@@ -707,19 +484,15 @@ argsize( p ) register NODE *p; {
                p = p->right;
                }
        if( p->type == DOUBLE || p->type == FLOAT ){
                p = p->right;
                }
        if( p->type == DOUBLE || p->type == FLOAT ){
-               SETOFF( t, 2 );
+               SETOFF( t, 4 );
                return( t+8 );
                }
                return( t+8 );
                }
-       else if( p->type == LONG || p->type == ULONG ) {
-               SETOFF( t, 2);
-               return( t+4 );
-               }
        else if( p->op == STARG ){
        else if( p->op == STARG ){
-               SETOFF( t, p->stalign );  /* alignment */
-               return( t + p->stsize );  /* size */
+               SETOFF( t, 4 );  /* alignment */
+               return( t + ((p->stsize+3)/4)*4 );  /* size */
                }
        else {
                }
        else {
-               SETOFF( t, 2 );
-               return( t+2 );
+               SETOFF( t, 4 );
+               return( t+4 );
                }
        }
                }
        }
index 47e07c8..59b83ff 100644 (file)
 # include "mfile2"
 
 # include "mfile2"
 
-# define AWD SNAME|SOREG|SCON|STARNM|STARREG|SAREG
-# define LWD SNAME|SOREG|SCON|SAREG
+# define WPTR TPTRTO|TINT|TLONG|TFLOAT|TDOUBLE|TPOINT|TUNSIGNED|TULONG
+# define AWD SNAME|SOREG|SCON|STARNM|STARREG
+/* tbl */
+# define ANYSIGNED TPOINT|TINT|TLONG|TSHORT|TCHAR
+# define ANYUSIGNED TUNSIGNED|TULONG|TUSHORT|TUCHAR
+# define ANYFIXED ANYSIGNED|ANYUSIGNED
+# define TWORD TINT|TUNSIGNED|TPOINT|TLONG|TULONG
+/* tbl */
 
 struct optab  table[] = {
 
 
 struct optab  table[] = {
 
-ASSIGN,        INAREG|FOREFF|FORCC,
-       AWD,    TPOINT|TINT|TUNSIGNED|TCHAR|TUCHAR,
-       SZERO,  TANY,
-               0,      RLEFT|RRIGHT|RESCC,
-               "       clrZB   AL\n",
-
-ASSIGN,        INAREG|FOREFF|FORCC,
-       AWD,    TINT|TUNSIGNED,
-       AWD,    TCHAR,
-               NAREG|NASR,     RLEFT|RESC1|RESCC,
-               "       movb    AR,A1\n mov     A1,AL\n",
-
-ASSIGN,        INAREG|FOREFF|FORCC,
-       AWD,    TINT|TUNSIGNED,
-       AWD,    TUCHAR,
-               0,      RLEFT|RESCC,
-               "       movb    AR,AL\n bic     $!377,AL\n",
-
-ASSIGN,        INAREG|FOREFF|FORCC,
-       AWD,    TPOINT|TINT|TUNSIGNED|TCHAR|TUCHAR,
-       AWD,    TPOINT|TINT|TUNSIGNED|TCHAR|TUCHAR,
-               0,      RLEFT|RRIGHT|RESCC,
-               "       movZB   AR,AL\n",
-
-ASSIGN,        INAREG|FOREFF,
-       LWD,    TLONG|TULONG,
-       SZERO,  TANY,
-               0,      RLEFT|RRIGHT,
-               "       clr     AL\n    clr     UL\n",
-
-ASSIGN,        INAREG|FOREFF,
-       LWD,    TLONG|TULONG,
-       LWD,    TLONG|TULONG,
-               0,      RLEFT|RRIGHT,
-               "       mov     AR,AL\n mov     UR,UL\n",
-
-ASSIGN,        FOREFF|INAREG,
-       STARNM,         TLONG|TULONG,
-       LWD,    TLONG|TULONG,
-               NAREG|NASL,     RRIGHT,
-               "       mov     ZU,A1\n mov     AR,(A1)+\n      mov     UR,(A1)\n",
-
-ASSIGN,        FOREFF,
-       STARNM, TLONG|TULONG,
-       AWD,    TUNSIGNED|TPOINT,
-               NAREG|NASL,     RRIGHT,
-               "       mov     ZU,A1\n clr     (A1)+\n mov     AR,(A1)\n",
-
-ASSIGN,        FOREFF,
-       STARNM, TLONG|TULONG,
-       AWD,    TINT,
-               NAREG|NASL,     RRIGHT,
-               "       mov     ZU,A1\n mov     AR,2(A1)\n      sxt     (A1)\n",
-
-       /* PANIC! */
-ASSIGN,        FOREFF|INAREG,
-       STARNM, TLONG|TULONG,
-       AWD,    TUNSIGNED|TPOINT,
-               NAREG|NASL|NASR,        RESC1,
-               "\tmov\tAR,-(sp)\n\tmov\tZU,A1\n\tclr\t(A1)+\n\tmov\t(sp)+,(A1)\
-               \nF\tmov\t(A1),U1\nF\tclr\tA1\n",
-
-ASSIGN,        FOREFF|INAREG,
-       STARNM, TLONG|TULONG,
-       AWD,    TINT,
-               NAREG|NASL|NASR,        RESC1,
-               "\tmov\tAR,-(sp)\n\tmov\tZU,A1\n\tmov\t(sp)+,2(A1)\nF\tmov\t2(A1),U1\
-               \n\tsxt\t(A1)\nF\tsxt\tA1\n",
-
-ASSIGN,        FOREFF|INAREG,
-       STARNM, TLONG|TULONG,
-       SAREG,  TLONG|TULONG,
-               0,      RRIGHT,
-               "       mov     AR,AL\n mov     ZU,AR\n mov     UR,2(AR)\nF     mov     (AR),AR\n",
+PCONV, INAREG|INTAREG,
+       SAREG|AWD,      TCHAR|TSHORT,
+       SANY,   TPOINT,
+               NAREG|NASL,     RESC1,
+               "       cvtZLl  AL,A1\n",
 
 
-ASSIGN,        INAREG|FOREFF,
-       LWD,    TLONG|TULONG,
-       AWD,    TCHAR,
-               NAREG,  RESC1,
-               "       movb    AR,U1\n mov     U1,UL\n sxt     AL\nF   sxt     A1\n",
+PCONV, INAREG|INTAREG,
+       SAREG|AWD,      TUCHAR|TUSHORT,
+       SANY,   TPOINT,
+               NAREG|NASL,     RESC1,
+               "       movzZLl AL,A1\n",
 
 
-ASSIGN,        INAREG|FOREFF,
-       LWD,    TLONG|TULONG,
-       AWD,    TUCHAR,
+SCONV, INTAREG|FORCC,
+       SAREG,  TDOUBLE,
+       SANY,   TDOUBLE,
                0,      RLEFT,
                0,      RLEFT,
-               "       movb    AR,UL\n bic     $!377,UL\n      clr     AL\n",
+               "",
 
 
-ASSIGN,        INAREG|FOREFF,
-       LWD,    TLONG|TULONG,
-       AWD,    TINT,
-               0,      RLEFT,
-               "       mov     AR,UL\n sxt     AL\n",
+SCONV, INTAREG|FORCC,
+       SAREG|AWD,      TANY,
+       SANY,   TFLOAT|TDOUBLE,
+               NAREG|NASL,     RESC1|RESCC,
+               "       cvtZLd  AL,A1\n",
 
 
-ASSIGN,        INAREG|FOREFF,
-       LWD,    TLONG|TULONG,
-       AWD,    TUNSIGNED|TPOINT,
-               0,      RLEFT,
-               "       mov     AR,UL\n clr     AL\n",
+SCONV, INTAREG|FORCC,
+       SAREG|AWD,      TFLOAT|TDOUBLE,
+       SANY,   ANYFIXED,
+               NAREG|NASL,     RESC1|RESCC,
+               "       cvtZLZF AL,A1\n",
 
 
-ASSIGN,        INBREG|INTBREG|FOREFF,
-       AWD,    TDOUBLE,
-       SBREG,  TDOUBLE,
-               0,      RRIGHT,
-               "       movf    AR,AL\n",
+SCONV, INTAREG|FORCC,
+       SAREG|SNAME|SCON|STARNM,        TANY,
+       SANY,   ANYUSIGNED,
+               NAREG|NASL,     RESC1|RESCC,
+               "       movzZRl AL,A1\n",
 
 
-ASSIGN,        INBREG|INTBREG|FOREFF,
-       AWD,    TFLOAT,
-       SBREG,  TDOUBLE,
-               0,      RRIGHT,
-               "       movfo   AR,AL\n",
+SCONV, INTAREG|FORCC,
+       SSOREG, TANY,
+       SANY,   ANYUSIGNED,
+               NAREG|NASL,     RESC1|RESCC,
+               "       movzZRl AL,A1\n",
 
 
-ASSIGN, INAREG|FOREFF,
-       SFLD,   TANY,
-       SZERO,  TANY,
-               0,      RRIGHT,
-               "       bic     $M.,AL\n",
+SCONV, INTAREG|FORCC,
+       SAREG|SNAME|SCON|STARNM,        TANY,
+       SANY,   TANY,
+               NAREG|NASL,     RESC1|RESCC,
+               "       cvtZRl  AL,A1\n",
 
 
-ASSIGN, INTAREG|INAREG|FOREFF,
-       SFLD,   TANY,
-       STAREG, TANY,
-               0,      RRIGHT,
-               "F\tmov\tAR,-(sp)\n\tash\t$H.,AR\n\tbic\t$!M.,AR\n\tbic\t$M.,AL\n\tbis\tAR,AL\nF\tmov\t(sp)+,AR\n",
+SCONV, INTAREG|FORCC,
+       SSOREG, TANY,
+       SANY,   TANY,
+               NAREG|NASL,     RESC1|RESCC,
+               "       cvtZRl  AL,A1\n",
 
 
-ASSIGN, INAREG|FOREFF,
-       SFLD,   TANY,
-       AWD,    TANY,
-               NAREG,  RRIGHT,
-               "\tmov\tAR,A1\n\tash\t$H.,A1\n\tbic\t$!M.,A1\n\tbic\t$M.,AL\n\tbis\tA1,AL\n",
 
 
-ASSIGN,        FOREFF,
-       AWD,    TFLOAT,
-       AWD,    TFLOAT,
-               NBREG,  RESC1,
-               "       movof   AR,A1\n movfo   A1,AL\n",
+INIT,  FOREFF,
+       SCON,   TANY,
+       SANY,   TWORD,
+               0,      RNOP,
+               "       .long   CL\n",
 
 
-/* put this here so UNARY MUL nodes match OPLTYPE when appropriate */
-UNARY MUL,     INTAREG|INAREG,
-       SANY,   TANY,
-       STARNM, TLONG|TULONG,
-               NAREG|NASR,     RESC1,
-               "       mov     AL,U1\n mov     (U1)+,A1\n      mov     (U1),U1\n",
+INIT,  FOREFF,
+       SCON,   TANY,
+       SANY,   TSHORT|TUSHORT,
+               0,      RNOP,
+               "       .word   CL\n",
 
 
-OPLTYPE,       FOREFF,
-       SANY,   TANY,
-       LWD,    TANY,
-               0,      RRIGHT,
-               "",   /* this entry throws away computations which don't do anything */
-OPLTYPE,       INTAREG|INAREG,
-       SANY,   TANY,
-       SZERO,  TINT|TUNSIGNED|TPOINT|TCHAR|TUCHAR,
-               NAREG|NASR,     RESC1,
-               "       clr     A1\n",
+INIT,  FOREFF,
+       SCON,   TANY,
+       SANY,   TCHAR|TUCHAR,
+               0,      RNOP,
+               "       .byte   CL\n",
 
 
-OPLTYPE,       INTAREG|INAREG,
-       SANY,   TANY,
-       SZERO,  TLONG|TULONG,
-               NAREG|NASR,     RESC1,
-               "       clr     A1\n    clr     U1\n",
+       /* for the use of fortran only */
 
 
-OPLTYPE,       INTAREG|INAREG,
+GOTO,  FOREFF,
+       SCON,   TANY,
        SANY,   TANY,
        SANY,   TANY,
-       SANY,   TINT|TUNSIGNED|TPOINT|TCHAR,
-               NAREG|NASR,     RESC1,
-               "       movZB   AR,A1\n",
+               0,      RNOP,
+               "       jbr     CL\n",
 
 
-OPLTYPE,       INTEMP,
+GOTO,  FOREFF,
+       SAREG,  TANY,
        SANY,   TANY,
        SANY,   TANY,
-       SANY,   TINT|TUNSIGNED|TPOINT,
-               NTEMP,  RESC1,
-               "       mov     AR,A1\n",
+               0,      RNOP,
+               "       jmp     (AL)\n",
 
 
-OPLTYPE,       FORCC,
+STARG, INTEMP,
+       SCON|SAREG,     TANY,
        SANY,   TANY,
        SANY,   TANY,
-       SANY,   TINT|TUNSIGNED|TPOINT|TCHAR|TUCHAR,
-               0,      RESCC,
-               "       tstZB   AR\n",
-
+               NTEMP+2*NAREG,  RESC3,
+               "ZS",
 
 
-OPLTYPE,       FORARG,
-       SANY,   TANY,
-       SANY,   TINT|TUNSIGNED|TPOINT,
+STASG, FORARG,
+       SNAME|SOREG,    TANY,
+       SCON|SAREG,     TANY,
                0,      RNULL,
                0,      RNULL,
-               "       mov     AR,Z-\n",
+               "       subl2   ZT,sp\nZS",
 
 
-OPLTYPE,       INTAREG|INAREG,
-       SANY,   TANY,
-       AWD,    TUCHAR,
-               NAREG|NASR,     RESC1,
-               "       movb    AR,A1\n bic     $!377,A1\n",
+STASG, FOREFF,
+       SNAME|SOREG,    TANY,
+       SCON|SAREG,     TANY,
+               0,      RNOP,
+               "ZS",
 
 
-OPLTYPE,       INTAREG|INAREG,
-       SANY,   TANY,
-       LWD,    TLONG|TULONG,
+STASG, INAREG,
+       SNAME|SOREG,    TANY,
+       SCON,   TANY,
                NAREG,  RESC1,
                NAREG,  RESC1,
-               "       mov     UR,U1\n mov     AR,A1\n",
+               "ZS     movl    AR,A1\n",
 
 
-OPLTYPE,       INTAREG|INAREG,  /* for use when there are no free regs */
-       SANY,   TANY,
-       LWD,    TLONG|TULONG,
-               NAREG|NASR,     RESC1,
-               "       mov     AR,-(sp)\n      mov     UR,U1\n mov     (sp)+,A1\n",
+STASG, INAREG,
+       SNAME|SOREG,    TANY,
+       SAREG,  TANY,
+               0,      RRIGHT,
+               "       pushl   AR\nZS  movl    (sp)+,AR\n",
 
 
-OPLTYPE,       INTEMP,
+FLD,   INAREG|INTAREG,
        SANY,   TANY,
        SANY,   TANY,
-       LWD,    TLONG|TULONG,
-               2*NTEMP,        RESC1,
-               "       mov     AR,A1\n mov     UR,U1\n",
+       SFLD,   ANYSIGNED,
+               NAREG|NASR,     RESC1,
+               "       extv    H,S,AR,A1\n",
 
 
-OPLTYPE,       FORCC,
+FLD,   INAREG|INTAREG,
        SANY,   TANY,
        SANY,   TANY,
-       LWD,    TLONG|TULONG,
-               0,      RESCC,
-               "ZA",
+       SFLD,   ANYUSIGNED,
+               NAREG|NASR,     RESC1,
+               "       extzv   H,S,AR,A1\n",
 
 
-OPLTYPE, FORARG,
+FLD,   FORARG,
        SANY,   TANY,
        SANY,   TANY,
-       LWD,    TLONG|TULONG,
+       SFLD,   ANYSIGNED,
                0,      RNULL,
                0,      RNULL,
-               "       mov     UR,Z-\n mov     AR,Z-\n",
-
-UNARY MUL,     FORARG,
-       STARNM, TANY,
-       SANY,   TLONG|TULONG,
-               NAREG|NASR,     RNULL,
-               "       mov     AL,A1\n mov     2(A1),Z-\n      mov     (A1),Z-\n",
+               "       extv    H,S,AR,-(sp)\n",
 
 
-OPLTYPE, FORARG,
+FLD,   FORARG,
        SANY,   TANY,
        SANY,   TANY,
-       SBREG,  TDOUBLE,
+       SFLD,   ANYUSIGNED,
                0,      RNULL,
                0,      RNULL,
-               "       movf    AR,Z4\n",
-
-OPLTYPE,       INTBREG|INBREG,
-       SANY,   TANY,
-       AWD,    TDOUBLE,
-               NBREG,  RESC1,
-               "       movf    AR,A1\n",
-
-OPLTYPE,       INTEMP,
-       SANY,   TANY,
-       SBREG,  TDOUBLE,
-               4*NTEMP,        RESC1,
-               "       movf    AR,A1\n",
+               "       extzv   H,S,AR,-(sp)\n",
 
 
-OPLTYPE,       FORCC,
-       SANY,   TANY,
-       AWD,    TDOUBLE,
+OPLOG, FORCC,
+       SAREG|AWD,      TWORD,
+       SAREG|AWD,      TWORD,
                0,      RESCC,
                0,      RESCC,
-               "       tstf    AR\n    cfcc\n",
-
-OPLTYPE,       INTBREG|INBREG,
-       SANY,   TANY,
-       AWD,    TFLOAT,
-               NBREG,  RESC1,
-               "       movof   AR,A1\n",
-
-OPLTYPE,       FORCC,
-       SANY,   TANY,
-       AWD,    TFLOAT,
-               NBREG,  RESCC,
-               "       movof   AR,A1\n cfcc\n",
-
+               "       cmpl    AL,AR\nZP",
 
 OPLOG, FORCC,
 
 OPLOG, FORCC,
-       AWD,    TPOINT|TINT|TUNSIGNED,
-       AWD,    TPOINT|TINT|TUNSIGNED,
+       SAREG|AWD,      TSHORT|TUSHORT,
+       SAREG|AWD,      TSHORT|TUSHORT,
                0,      RESCC,
                0,      RESCC,
-               "       cmp     AL,AR\nZI",
+               "       cmpw    AL,AR\nZP",
 
 OPLOG, FORCC,
 
 OPLOG, FORCC,
-       AWD,    TCHAR|TUCHAR,
-       AWD,    TCHAR|TUCHAR,
+       SAREG|AWD,      TCHAR|TUCHAR,
+       SAREG|AWD,      TCHAR|TUCHAR,
                0,      RESCC,
                0,      RESCC,
-               "       cmpb    AL,AR\nZI",
+               "       cmpb    AL,AR\nZP",
 
 OPLOG, FORCC,
 
 OPLOG, FORCC,
-       AWD,    TCHAR|TUCHAR,
-       SCCON,  TINT,                           /* look for constants between -128 and 127 */
+       SAREG|AWD,      TSHORT|TUSHORT,
+       SSCON,  TANY,
                0,      RESCC,
                0,      RESCC,
-               "       cmpb    AL,AR\nZI",
+               "       cmpw    AL,AR\nZP",
 
 OPLOG, FORCC,
 
 OPLOG, FORCC,
-       LWD,    TLONG|TULONG,
-       LWD,    TLONG|TULONG,
+       SAREG|AWD,      TCHAR|TUCHAR,
+       SCCON,  TANY,
                0,      RESCC,
                0,      RESCC,
-               "ZCZI",
+               "       cmpb    AL,AR\nZP",
 
 OPLOG, FORCC,
 
 OPLOG, FORCC,
-       SBREG,  TDOUBLE,
-       AWD,    TFLOAT,
-               NBREG,  RESCC,
-               "       movof   AR,A1\n cmpf    A1,AL\n cfcc\nZF",
+       SAREG|AWD,      TDOUBLE,
+       SAREG|AWD,      TDOUBLE,
+               0,      RESCC,
+               "       cmpd    AL,AR\nZP",
 
 OPLOG, FORCC,
 
 OPLOG, FORCC,
-       SBREG,  TDOUBLE,
-       SBREG|AWD,      TDOUBLE,
+       SAREG|AWD,      TFLOAT|TDOUBLE,
+       SAREG|AWD,      TFLOAT|TDOUBLE,
                0,      RESCC,
                0,      RESCC,
-               "       cmpf    AR,AL\n cfcc\nZF",
-
-CCODES,        INTAREG|INAREG,
-       SANY,   TANY,
-       SANY,   TINT|TUNSIGNED|TPOINT|TCHAR|TUCHAR,
-               NAREG,  RESC1,
-               "       mov     $1,A1\nZN",
-
-CCODES,        INTAREG|INAREG,
-       SANY,   TANY,
-       SANY,   TLONG|TULONG,
-               NAREG,  RESC1,
-               "       clr     A1\n    mov     $1,U1\nZN",
+               "       cmpf    AL,AR\nZP",
 
 
-UNARY MINUS,   INTAREG|INAREG,
-       STAREG, TINT|TUNSIGNED,
+CCODES,        INAREG|INTAREG,
        SANY,   TANY,
        SANY,   TANY,
-               0,      RLEFT,
-               "       neg     AL\n",
-
-UNARY MINUS,   INTAREG|INAREG,
-       STAREG, TLONG|TULONG,
-       SANY,   TANY,
-               0,      RLEFT,
-               "       neg     AL\n    neg     UL\n    sbc     AL\n",
-
-UNARY MINUS,   INTBREG|INBREG,
-       STBREG, TDOUBLE,
        SANY,   TANY,
        SANY,   TANY,
-               0,      RLEFT,
-               "       negf    AL\n",
-
-COMPL, INTAREG|INAREG,
-       STAREG, TINT|TUNSIGNED,
-       SANY,   TANY,
-               0,      RLEFT,
-               "       com     AL\n",
-
-INCR,  INTAREG|INAREG|FOREFF,
-       AWD,    TINT|TUNSIGNED|TPOINT|TCHAR|TUCHAR,
-       SONE,   TANY,
                NAREG,  RESC1,
                NAREG,  RESC1,
-               "F      movZB   AL,A1\n incZB   AL\n",
+               "       movl    $1,A1\nZN",
 
 
-DECR,  INTAREG|INAREG|FOREFF,
-       AWD,    TINT|TUNSIGNED|TPOINT|TCHAR|TUCHAR,
-       SONE,   TANY,
-               NAREG,  RESC1,
-               "F      movZB   AL,A1\n decZB   AL\n",
-
-INCR,  INTAREG|INAREG|FOREFF,
-       AWD,    TINT|TUNSIGNED|TPOINT,
-       SCON,   TANY,
-               NAREG,  RESC1,
-               "F      mov     AL,A1\n add     AR,AL\n",
-
-DECR,  INTAREG|INAREG|FOREFF,
-       AWD,    TINT|TUNSIGNED|TPOINT,
-       SCON,   TANY,
-               NAREG,  RESC1,
-               "F      mov     AL,A1\n sub     AR,AL\n",
-
-INCR,  INTAREG|INAREG|FOREFF,
-       LWD,    TLONG|TULONG,
+UNARY CALL,    INTAREG,
        SCON,   TANY,
        SCON,   TANY,
-               NAREG,  RESC1,
-               "F      mov     AL,A1\nF        mov     UL,U1\n add     AR,AL\n add     UR,UL\n adc     AL\n",
+       SANY,   TWORD|TCHAR|TUCHAR|TSHORT|TUSHORT|TFLOAT|TDOUBLE,
+               NAREG|NASL,     RESC1, /* should be register 0 */
+               "       calls   ZC,CL\n",
 
 
-DECR,  INTAREG|INAREG|FOREFF,
-       LWD,    TLONG|TULONG,
-       SCON,   TANY,
-               NAREG,  RESC1,
-               "F      mov     AL,A1\nF        mov     UL,U1\n sub     AR,AL\n sub     UR,UL\n sbc     AL\n",
+UNARY CALL,    INTAREG,
+       SAREG,  TANY,
+       SANY,   TWORD|TCHAR|TUCHAR|TSHORT|TUSHORT|TFLOAT|TDOUBLE,
+               NAREG|NASL,     RESC1,  /* should be 0 */
+               "       calls   ZC,(AL)\n",
 
 
-COMPL, INTAREG|INAREG,
-       STAREG, TLONG|TULONG,
+UNARY CALL,    INAREG|INTAREG,
+       SNAME,  TANY,
        SANY,   TANY,
        SANY,   TANY,
-               0,      RLEFT,
-               "       com     AL\n    com     UL\n",
-
-AND,   FORCC,
-       AWD,    TINT|TUNSIGNED|TPOINT,
-       SCON,   TANY,
-               0,      RESCC,
-               "       bit     AL,$Z~\n",
-
-ASG MUL,       INAREG,
-       STAREG, TINT|TUNSIGNED|TPOINT,
-       AWD,    TINT|TUNSIGNED|TPOINT,
-               NAREG,  RLEFT,
-               "       mul     AR,AL\n",
+               NAREG|NASL,     RESC1,  /* really reg 0 */
+               "       calls   ZC,*AL\n",
 
 
-ASG DIV,       INAREG,
-       STAREG, TINT|TUNSIGNED|TPOINT,
-       AWD,    TINT|TUNSIGNED|TPOINT,
-               NAREG,  RESC1,
-               "ZV     div     AR,r0\n",  /* since lhs must be in r1 */
-
-ASG MOD,       INAREG,
-       STAREG, TINT|TUNSIGNED|TPOINT,
-       AWD,    TINT|TUNSIGNED|TPOINT,
-               NAREG,  RLEFT,
-               "ZV     div     AR,r0\n",  /* since lhs must be in r1 */
-
-ASG PLUS,      INAREG|FORCC,
-       AWD,    TINT|TUNSIGNED|TPOINT|TCHAR|TUCHAR,
-       SONE,   TINT,
-               0,      RLEFT|RESCC,
-               "       incZB   AL\n",
-
-ASG PLUS,      INAREG|FORCC,
-       AWD,    TINT|TUNSIGNED|TPOINT,
-       AWD,    TINT|TUNSIGNED|TPOINT,
-               0,      RLEFT|RESCC,
-               "       add     AR,AL\n",
-
-ASG MINUS,     INAREG|FORCC,
-       AWD,    TINT|TUNSIGNED|TPOINT|TCHAR|TUCHAR,
-       SONE,   TINT,
-               0,      RLEFT|RESCC,
-               "       decZB   AL\n",
-
-ASG MINUS,     INAREG|FORCC,
-       AWD,    TINT|TUNSIGNED|TPOINT,
-       AWD,    TINT|TUNSIGNED|TPOINT,
-               0,      RLEFT|RESCC,
-               "       sub     AR,AL\n",
+UNARY CALL,    INAREG|INTAREG,
+       SSOREG, TANY,
+       SANY,   TANY,
+               NAREG|NASL,     RESC1,  /* really reg 0 */
+               "       calls   ZC,*AL\n",
 
 
-ASG OR,        INAREG|FORCC,
-       AWD,    TINT|TUNSIGNED|TPOINT,
-       AWD,    TINT|TUNSIGNED|TPOINT,
+ASG RS,        INAREG|FOREFF|FORCC,
+       SAREG,  TWORD,
+       SCON,   TINT,
                0,      RLEFT|RESCC,
                0,      RLEFT|RESCC,
-               "       bis     AR,AL\n",
-
-/* AND transformed to "pdp11 bic" in first pass. */
-ASG AND,       INAREG|FORCC,
-       AWD,    TINT|TUNSIGNED|TPOINT,
-       AWD,    TINT|TUNSIGNED|TPOINT,
+               "       extzv   AR,ZU,AL,AL\n",
+
+ASG RS,        INAREG|FOREFF|FORCC,
+       SAREG,  TWORD,
+       SAREG,  ANYFIXED,
+               NAREG,  RLEFT|RESCC,
+               "       subl3   AR,$32,A1\n     extzv   AR,A1,AL,AL\n",
+
+ASG RS,        INAREG|FOREFF|FORCC,
+       SAREG,  TWORD,
+       SAREG|AWD,      TWORD,
+               NAREG,  RLEFT|RESCC,
+               "       subl3   AR,$32,A1\n     extzv   AR,A1,AL,AL\n",
+
+RS,    INAREG|INTAREG|FORCC,
+       SAREG,  TWORD,
+       SCON,   TINT,
+               NAREG|NASL,     RESC1|RESCC,
+               "       extzv   AR,ZU,AL,A1\n",
+
+ASG LS,        INAREG|FOREFF|FORCC,
+       SAREG|AWD,      TWORD,
+       SAREG|AWD,      ANYSIGNED|ANYUSIGNED,
                0,      RLEFT|RESCC,
                0,      RLEFT|RESCC,
-               "       bic     AR,AL\n",
+               "       ashl    AR,AL,AL\n",
 
 
-ASG ER,        INAREG|FORCC,
-       AWD,    TINT|TUNSIGNED|TPOINT,
-       SAREG,  TINT|TUNSIGNED|TPOINT,
-               0,      RLEFT|RESCC,
-               "       xor     AR,AL\n",
-
-ASG OPSHFT,    INAREG,
-       SAREG,  TINT|TUNSIGNED|TPOINT,
-       SONE,   TINT,
-               0,      RLEFT,
-               "       OI      AL\nZH",
+LS,    INAREG|INTAREG|FORCC,
+       SAREG|AWD,      TWORD,
+       SAREG|AWD,      ANYSIGNED|ANYUSIGNED,
+               NAREG|NASL|NASR,        RESC1|RESCC,
+               "       ashl    AR,AL,A1\n",
 
 
-ASG LS,        INAREG,
-       SAREG,  TINT|TUNSIGNED|TPOINT,
-       AWD,    TINT|TUNSIGNED|TPOINT,
+INCR,  FOREFF,
+       SAREG|AWD,      TANY,
+       SANY,   TANY,
                0,      RLEFT,
                0,      RLEFT,
-               "       ash     AR,AL\n",
+               "       ZE\n",
 
 
-ASG RS,        INAREG,
-       SAREG,  TINT|TUNSIGNED|TPOINT,
+DECR,  FOREFF,
+       SAREG|AWD,      TANY,
        SCON,   TANY,
                0,      RLEFT,
        SCON,   TANY,
                0,      RLEFT,
-               "       ash     $ZM,AL\nZH",
+               "       ZE\n",
 
 
-ASG RS,        INAREG,
-       SAREG,  TINT|TUNSIGNED|TPOINT,
-       STAREG, TINT|TUNSIGNED|TPOINT,
-               0,      RLEFT,
-               "       neg     AR\n    ash     AR,AL\nZH",
+INCR,  INAREG|INTAREG,
+       SAREG|AWD,      TANY,
+       SCON,   TANY,
+               NAREG,  RESC1,
+               "       ZD\n",
 
 
-ASG RS,        INAREG,
-       SAREG,  TINT|TUNSIGNED|TPOINT,
-       AWD,    TINT|TUNSIGNED|TPOINT,
-               NAREG|NASR,     RLEFT,
-               "       mov     AR,A1\n neg     A1\n    ash     A1,AL\nZH",
+DECR,  INAREG|INTAREG,
+       SAREG|AWD,      TANY,
+       SCON,   TANY,
+               NAREG,  RESC1,
+               "       ZD\n",
 
 
-ASG RS,        INAREG,
-       SAREG,  TINT,
-       AWD,    TINT,
-               0,      RLEFT,
-               "       mov     AR,-(sp)\n      neg     (sp)\n  ash     (sp)+,AL\nZH",
+ASSIGN,        INAREG|FOREFF|FORCC,
+       SAREG|AWD,      TANY,
+       SAREG|AWD,      TANY,
+               0,      RLEFT|RRIGHT|RESCC,
+               "       ZA\n",
 
 
-ASG RS,        INAREG,
-       SAREG,  TINT|TUNSIGNED|TPOINT,
-       AWD,    TINT|TUNSIGNED|TPOINT,
-               NTEMP,  RLEFT,
-               "       mov     AR,A1\n neg     A1\n    ash     A1,AL\nZH",
+ASSIGN,        INAREG|FOREFF|FORCC,
+       SFLD,   TANY,
+       SAREG|AWD,      TWORD,
+               0,      RRIGHT|RESCC,
+               "       insv    AR,H,S,AL\n",
 
 
-ASG OR,        INAREG|FORCC,
-       AWD,    TCHAR|TUCHAR,
-       AWD,    TCHAR|TUCHAR,
+ASSIGN,        INAREG|FOREFF|FORCC,
+       SAREG|AWD,      TWORD,
+       SFLD,   ANYSIGNED,
                0,      RLEFT|RESCC,
                0,      RLEFT|RESCC,
-               "       bisb    AR,AL\n",
+               "       extv    H,S,AR,AL\n",
 
 
-/* AND transformed to "pdp11 bic" in first pass. */
-ASG AND,       INAREG|FORCC,
-       AWD,    TCHAR|TUCHAR,
-       AWD,    TINT|TUNSIGNED|TPOINT|TCHAR|TUCHAR,
+ASSIGN,        INAREG|FOREFF|FORCC,
+       SAREG|AWD,      TWORD,
+       SFLD,   ANYUSIGNED,
                0,      RLEFT|RESCC,
                0,      RLEFT|RESCC,
-               "       bicb    AR,AL\n",
-
-ASG PLUS,      INAREG,
-       LWD,    TLONG|TULONG,
-       SICON,  TINT|TLONG|TULONG,
-               0,      RLEFT,
-               "       add     UR,UL\n adc     AL\n",
-
-ASG PLUS,      INAREG,
-       STARNM, TLONG|TULONG,
-       LWD,    TLONG|TULONG,
-               NAREG,  RLEFT,
-               "       mov     ZU,A1\n add     AR,(A1)+\n      add     UR,(A1)\n       adc     -(A1)\n",
-
-ASG PLUS,      INAREG,
-       LWD,    TLONG|TULONG,
-       LWD,    TLONG|TULONG,
-               0,      RLEFT,
-               "       add     AR,AL\n add     UR,UL\n adc     AL\n",
-
-ASG PLUS,      INAREG,
-       AWD,    TPOINT,
-       LWD,    TLONG|TULONG,
-               0,      RLEFT,
-               "       add     UR,AL\n",
-
-ASG MINUS,     INAREG,
-       LWD,    TLONG|TULONG,
-       SICON,  TINT|TLONG|TULONG,
-               0,      RLEFT,
-               "       sub     UR,UL\n sbc     AL\n",
-
-ASG MINUS,     INAREG,
-       STARNM, TLONG|TULONG,
-       LWD,    TLONG|TULONG,
-               NAREG,  RLEFT,
-               "       mov     ZU,A1\n sub     AR,(A1)+\n      sub     UR,(A1)\n       sbc     -(A1)\n",
-
-ASG MINUS,     INAREG,
-       LWD,    TLONG|TULONG,
-       LWD,    TLONG|TULONG,
-               0,      RLEFT,
-               "       sub     AR,AL\n sub     UR,UL\n sbc     AL\n",
-
-ASG MINUS,     INAREG,
-       AWD,    TPOINT,
-       LWD,    TLONG|TULONG,
-               0,      RLEFT,
-               "       sub     UR,AL\n",
-
-ASG OR,        INAREG,
-       LWD,    TLONG|TULONG,
-       LWD,    TLONG|TULONG,
-               0,      RLEFT,
-               "       bis     AR,AL\n bis     UR,UL\n",
-
-/* AND transformed to "pdp11 bic" in first pass. */
-ASG AND,       INAREG,
-       LWD,    TLONG|TULONG,
-       LWD,    TLONG|TULONG,
-               0,      RLEFT,
-               "       bic     AR,AL\n bic     UR,UL\n",
+               "       extzv   H,S,AR,AL\n",
 
 
-ASG ER,        INAREG,
-       LWD,    TLONG|TULONG,
-       SAREG,  TLONG|TULONG,
-               0,      RLEFT,
-               "       xor     AR,AL\n xor     UR,UL\n",
-
-       /* table entries for ^ which correspond to the usual way of doing busingess
-               (rhs in a temp register */
+/* dummy UNARY MUL entry to get U* to possibly match OPLTYPE */
+UNARY MUL,     FOREFF,
+       SCC,    TANY,
+       SCC,    TANY,
+               0,      RNULL,
+               "       HELP HELP HELP\n",
 
 
-ASG ER,        INAREG|INTAREG,
-       STAREG, TLONG|TULONG,
-       LWD,    TLONG|TULONG,
-               0,      RLEFT,
-               "\tmov\tAL,-(sp)\n\tmov\tUR,AL\n\txor\tAL,UL\n\tmov\tAR,AL\n\txor\tAL,(sp)\n\tmov\t(sp)+,AL\n",
+REG,   FORARG,
+       SANY,   TANY,
+       SAREG,  TDOUBLE|TFLOAT,
+               0,      RNULL,
+               "       movZR   AR,-(sp)\n",
 
 
-ASG ER,        INAREG|INTAREG,
-       STAREG, TINT|TUNSIGNED|TPOINT,
-       AWD,    TINT|TUNSIGNED|TPOINT,
-               0,      RLEFT,
-               "\tmov\tAL,-(sp)\n\tmov\tAR,AL\n\txor\tAL,(sp)\n\tmov\t(sp)+,AL\n",
+REG,   INTEMP,
+       SANY,   TANY,
+       SAREG,  TDOUBLE,
+               2*NTEMP,        RESC1,
+               "       movd    AR,A1\n",
 
 
-ASG LS,        INAREG,
-       SAREG,  TLONG|TULONG,
-       AWD,    TINT|TUNSIGNED|TPOINT,
-               0,      RLEFT,
-               "       ashc    AR,AL\n",
+REG,   INTEMP,
+       SANY,   TANY,
+       SAREG,  TANY,
+               NTEMP,  RESC1,
+               "       movZF   AR,A1\n",
 
 
-ASG RS,        INAREG,
-       SAREG,  TLONG|TULONG,
-       SCON,   TANY,
+OPLEAF,        FOREFF,
+       SANY,   TANY,
+       SAREG|AWD,      TANY,
                0,      RLEFT,
                0,      RLEFT,
-               "       ashc    $ZM,AL\nZH",
+               "",
 
 
-ASG RS,        INAREG,
-       SAREG,  TLONG|TULONG,
-       STAREG, TINT|TUNSIGNED|TPOINT,
-               0,      RLEFT,
-               "       neg     AR\n    ashc    AR,AL\nZH",
-
-ASG RS,        INAREG,
-       SAREG,  TLONG|TULONG,
-       AWD,    TINT|TUNSIGNED|TPOINT,
-               NAREG|NASR,     RLEFT,
-               "       mov     AR,A1\n neg     A1\n    ashc    A1,AL\nZH",
-
-ASG RS,        INAREG,
-       SAREG,  TLONG|TULONG,
-       AWD,    TINT|TUNSIGNED|TPOINT,
-               NTEMP,  RLEFT,
-               "       mov     AR,A1\n neg     A1\n    ashc    A1,AL\nZH",
-
-ASG OPFLOAT,   INBREG|INTBREG,
-       STBREG, TDOUBLE,
-       SBREG|AWD,      TDOUBLE,
-               0,      RLEFT|RESCC,
-               "       OF      AR,AL\n",
+OPLTYPE,       INAREG|INTAREG,
+       SANY,   TANY,
+       SANY,   TFLOAT|TDOUBLE,
+               2*NAREG|NASR,   RESC1,
+               "       ZA\n",
 
 
-ASG OPFLOAT,   INBREG|INTBREG,
-       STBREG, TDOUBLE,
-       AWD,    TFLOAT,
-               NBREG|NBSR,     RLEFT|RESCC,
-               "       movof   AR,A1\n OF      A1,AL\n",
+OPLTYPE,       INAREG|INTAREG,
+       SANY,   TANY,
+       SANY,   TANY,
+               NAREG|NASR,     RESC1,
+               "       ZA\n",
 
 
-ASG OPFLOAT,   FORCC,
-       STBREG, TDOUBLE,
-       SBREG|AWD,      TDOUBLE,
+OPLTYPE,       FORCC,
+       SANY,   TANY,
+       SANY,   TANY,
                0,      RESCC,
                0,      RESCC,
-               "       OF      AR,AL\n cfcc\n",
-
-ASG OPFLOAT,   FORCC,
-       STBREG, TDOUBLE,
-       AWD,    TFLOAT,
-               NBREG|NBSR,     RESCC,
-               "       movof   AR,A1\n OF      A1,AL\n cfcc\n",
+               "       tstZR   AR\n",
 
 
-UNARY CALL,    INTAREG,
-       SAREG|SNAME|SOREG|SCON, TANY,
-       SANY,   TINT|TUNSIGNED|TPOINT|TCHAR|TUCHAR|TLONG|TULONG,
-               NAREG|NASL,     RESC1, /* should be register 0 */
-               "       jsr     pc,*AL\n",
-
-UNARY CALL,    INTBREG,
-       SAREG|SNAME|SOREG|SCON, TANY,
-       SANY,   TDOUBLE|TFLOAT,
-               NBREG,  RESC1, /* should be register FR0 */
-               "       jsr     pc,*AL\n",
-
-SCONV, INTAREG,
-       STAREG, TINT|TUNSIGNED|TPOINT|TCHAR|TUCHAR,
-       SANY,   TUCHAR,
-               0,      RLEFT,
-               "       bic     $!377,AL\n",
-
-SCONV, INTAREG,
-       AWD,    TINT|TUNSIGNED|TPOINT|TCHAR|TUCHAR,
-       SANY,   TCHAR|TINT,
-               NAREG|NASL,     RESC1,
-               "       movZB   AL,A1\n",
-
-SCONV, INAREG|INTAREG,
-       LWD,    TLONG|TULONG,
-       SANY,   TINT|TUNSIGNED|TPOINT|TCHAR|TUCHAR,
-               0,      RLEFT,
-               "ZT",
-
-SCONV, INTAREG,
-       AWD,    TUCHAR,
-       SANY,   TLONG|TULONG,
-               NAREG|NASL,     RESC1,
-               "       movb    AL,U1\n bic     $!377,U1\n      clr     A1\n",
-
-SCONV, INTAREG,
-       AWD,    TINT,
-       SANY,   TLONG|TULONG,
-               NAREG|NASL,     RESC1,
-               "       mov     AL,U1\n sxt     A1\n",
-
-SCONV, INTAREG,
-       AWD,    TUNSIGNED|TPOINT,
-       SANY,   TLONG|TULONG,
-               NAREG|NASL,     RESC1,
-               "       mov     AL,U1\n clr     A1\n",
-
-SCONV, INTAREG,
-       SBREG,  TDOUBLE,
-       SANY,   TINT|TUNSIGNED|TPOINT|TCHAR|TUCHAR,
-               NAREG,  RESC1,
-               "       movfi   AL,A1\n",
-
-SCONV, INTAREG,
-       STBREG, TDOUBLE,
-       SANY,   TLONG|TULONG,
-               NAREG,  RESC1,
-               "       setl\n  movfi   AL,-(sp)\n      seti\n  mov     (sp)+,A1\n      mov     (sp)+,U1\n",
+OPLTYPE,       FORARG,
+       SANY,   TANY,
+       SANY,   TWORD,
+               0,      RNULL,
+               "       pushl   AR\n",
 
 
-SCONV, FORARG,
-       STBREG, TDOUBLE,
-       SANY,   TLONG|TULONG,
+OPLTYPE,       FORARG,
+       SANY,   TANY,
+       SANY,   TCHAR|TSHORT,
                0,      RNULL,
                0,      RNULL,
-               "       setl\n  movfi   AL,Z4\n seti\n",
+               "       cvtZRl  AR,-(sp)\n",
 
 
-SCONV, INTBREG,
-       SAREG,  TLONG,
+OPLTYPE,       FORARG,
        SANY,   TANY,
        SANY,   TANY,
-               NBREG,  RESC1,
-               "\tmov\tUL,-(sp)\n\tmov\tAL,-(sp)\n\tsetl\n\tmovif\t(sp)+,A1\n\tseti\n",
+       SANY,   TUCHAR|TUSHORT,
+               0,      RNULL,
+               "       movzZRl AR,-(sp)\n",
 
 
-SCONV, INTBREG,
-       LWD,    TLONG,
+OPLTYPE,       FORARG,
        SANY,   TANY,
        SANY,   TANY,
-               NBREG,  RESC1,
-               "\tsetl\n\tmovif\tAL,A1\n\tseti\n",
+       SANY,   TDOUBLE,
+               0,      RNULL,
+               "       movd    AR,-(sp)\n",
 
 
-SCONV, INTBREG,
-       AWD,    TINT,
+OPLTYPE,       FORARG,
        SANY,   TANY,
        SANY,   TANY,
-               NBREG,  RESC1,
-               "       movif   AL,A1\n",
+       SANY,   TFLOAT,
+               0,      RNULL,
+               "       cvtfd   AR,-(sp)\n",
 
 
-SCONV, INTBREG,
-       SAREG,  TULONG,
+UNARY MINUS,   INTAREG|FORCC,
+       SAREG|AWD,      TINT|TUNSIGNED|TLONG|TULONG|TDOUBLE,
        SANY,   TANY,
        SANY,   TANY,
-               NBREG,  RESC1,
-               "\tmov\tUL,-(sp)\n\tmov\tAL,-(sp)\n\tsetl\n\tmovif\t(sp)+,A1\n\tseti\n\tcfcc\n\tbpl\t1f\n\taddf\t$050200,A1\n1:\n",
+               NAREG|NASL,     RESC1|RESCC,
+               "       mnegZL  AL,A1\n",
 
 
-SCONV, INTBREG,
-       LWD,    TULONG,
+COMPL, INTAREG|FORCC,
+       SAREG|AWD,      TINT|TUNSIGNED,
        SANY,   TANY,
        SANY,   TANY,
-               NBREG,  RESC1,
-               "\tsetl\n\tmovif\tAL,A1\n\tseti\n\tcfcc\n\tbpl\t1f\n\taddf\t$050200,A1\n1:\n",
+               NAREG|NASL,     RESC1|RESCC,
+               "       mcomZL  AL,A1\n",
 
 
-SCONV, INTBREG,
-       STAREG, TUNSIGNED|TPOINT,
+COMPL, INTAREG|FORCC,
+       SAREG|AWD,      ANYSIGNED|ANYUSIGNED,
        SANY,   TANY,
        SANY,   TANY,
-               NBREG,  RESC1,
-               "\tmovif\tAL,A1\n\tcfcc\n\tbpl\t1f\n\taddf\t$044200,A1\n1:\n",
+               NAREG|NASL,     RESC1|RESCC,
+               "       cvtZLl  AL,A1\n mcoml   A1,A1\n",
 
 
-PCONV, INTAREG,
-       AWD,    TCHAR|TUCHAR,
-       SANY,   TPOINT,
-               NAREG|NASL,     RESC1,
-               "       movb    AL,A1\n",
+AND,   FORCC,
+       SAREG|AWD,      TWORD,
+       SCON,   TWORD,
+               0,      RESCC,
+               "       bitl    ZZ,AL\n",
 
 
-PCONV, INAREG|INTAREG,
-       LWD,    TLONG|TULONG,
-       SANY,   TPOINT,
-               0,      RLEFT,
-               "ZT",
+AND,   FORCC,
+       SAREG|AWD,      TSHORT|TUSHORT,
+       SSCON,  TWORD,
+               0,      RESCC,
+               "       bitw    ZZ,AL\n",
 
 
-STARG, FORARG,
-       SNAME|SOREG,    TANY,
-       SANY,   TANY,
-               0,      RNULL,
-               "ZS",
+AND,   FORCC,
+       SAREG|AWD,      TCHAR|TUCHAR,
+       SCCON,  TWORD,
+               0,      RESCC,
+               "       bitb    ZZ,AL\n",
 
 
-STASG, FOREFF,
-       SNAME|SOREG,    TANY,
-       SCON|SAREG,     TANY,
-               0,      RNOP,
-               "ZS",
+ASG AND,       INAREG|FOREFF|FORCC,
+       SAREG,  ANYFIXED,
+       SCON,   TWORD,
+               0,      RLEFT|RESCC,
+               "       bicl2   AR,AL\n",
 
 
-STASG, INTAREG|INAREG,
-       SNAME|SOREG,    TANY,
-       STAREG, TANY,
-               0,      RRIGHT,
-               "ZS",
+ASG OPMUL,     INAREG|FOREFF|FORCC,
+       SAREG|AWD,      TINT|TUNSIGNED|TLONG|TULONG,
+       SAREG|AWD,      TINT|TUNSIGNED|TLONG|TULONG,
+               0,      RLEFT|RESCC,
+               "       OL2     AR,AL\n",
 
 
-STASG, INAREG|INTAREG,
-       SNAME|SOREG,    TANY,
-       SCON|SAREG,     TANY,
+OPMUL, INAREG|INTAREG|FORCC,
+       STAREG, TINT|TUNSIGNED|TLONG|TULONG,
+       SAREG|AWD,      TINT|TUNSIGNED|TLONG|TULONG,
+               0,      RLEFT|RESCC,
+               "       OL2     AR,AL\n",
+
+OPMUL, INAREG|INTAREG|FORCC,
+       SAREG|AWD,      TINT|TUNSIGNED|TLONG|TULONG,
+       SAREG|AWD,      TINT|TUNSIGNED|TLONG|TULONG,
+               NAREG|NASL|NASR,        RESC1|RESCC,
+               "       OL3     AR,AL,A1\n",
+
+ASG MOD,       INAREG|INTAREG|FOREFF|FORCC,
+       SAREG,  TINT|TUNSIGNED|TLONG|TULONG,
+       SAREG|AWD,      TINT|TUNSIGNED|TLONG|TULONG,
+               NAREG,  RLEFT|RESCC,
+               "       divl3   AR,AL,A1\n      mull2   AR,A1\n subl2   A1,AL\n",
+
+MOD,   INAREG|INTAREG,
+       SAREG|AWD,      TINT|TUNSIGNED|TLONG|TULONG,
+       SAREG|AWD,      TINT|TUNSIGNED|TLONG|TULONG,
                NAREG,  RESC1,
                NAREG,  RESC1,
-               "ZS     mov     AR,A1\n",
+               "       divl3   AR,AL,A1\n      mull2   AR,A1\n subl3   A1,AL,A1\n",
 
 
-INIT,  FOREFF,
-       SCON,   TANY,
-       SANY,   TINT|TUNSIGNED|TPOINT,
-               0,      RNOP,
-               "       CL\n",
+ASG PLUS,      INAREG|FOREFF|FORCC,
+       SAREG|AWD,      ANYSIGNED|ANYUSIGNED,
+       SONE,   TINT|TLONG,
+               0,      RLEFT|RESCC,
+               "       incZL   AL\n",
 
 
-INIT,  FOREFF,
-       SCON,   TANY,
-       SANY,   TLONG|TULONG,
-               0,      RNOP,
-               "ZL",
+ASG MINUS,     INAREG|FOREFF|FORCC,
+       SAREG|AWD,      ANYSIGNED|ANYUSIGNED,
+       SONE,   TINT|TLONG,
+               0,      RLEFT|RESCC,
+               "       decZL   AL\n",
 
 
-INIT,  FOREFF,
-       SCON,   TANY,
-       SANY,   TCHAR|TUCHAR,
-               0,      RNOP,
-               "       .byte   CL\n",
+PLUS,  INAREG|INTAREG|FORCC,
+       STAREG, ANYFIXED,
+       SONE,   TWORD,
+               0,      RLEFT|RESCC,
+               "       incZL   AL\n",
 
 
-       /* for the use of fortran only */
+MINUS, INAREG|INTAREG|FORCC,
+       STAREG, ANYFIXED,
+       SONE,   TWORD,
+               0,      RLEFT|RESCC,
+               "       decZL   AL\n",
 
 
-GOTO,  FOREFF,
-       SCON,   TANY,
-       SANY,   TANY,
-               0,      RNOP,
-               "       jbr     CL\n",
+ASG OPSIMP,    INAREG|FOREFF|FORCC,
+       SAREG|AWD,      TWORD,
+       SAREG|AWD,      TWORD,
+               0,      RLEFT|RESCC,
+               "       OL2     AR,AL\n",
 
 
-GOTO,  FOREFF,
-       SNAME,  TLONG|TULONG,
-       SANY,   TANY,
-               0,      RNOP,
-               "       jmp     *UL\n",
+ASG OPSIMP,    INAREG|FOREFF|FORCC,
+       AWD,    TSHORT|TUSHORT,
+       SAREG|AWD,      TSHORT|TUSHORT,
+               0,      RLEFT|RESCC,
+               "       OW2     AR,AL\n",
 
 
-GOTO,  FOREFF,
-       SNAME,  TINT|TUNSIGNED|TCHAR|TUCHAR|TPOINT,
-       SANY,   TANY,
-               0,      RNOP,
-               "       jmp     *AL\n",
+ASG OPSIMP,    INAREG|FOREFF|FORCC,
+       AWD,    TSHORT|TUSHORT,
+       SSCON,  TWORD,
+               0,      RLEFT|RESCC,
+               "       OW2     AR,AL\n",
+
+ASG OPSIMP,    INAREG|FOREFF|FORCC,
+       AWD,    TCHAR|TUCHAR,
+       SAREG|AWD,      TCHAR|TUCHAR,
+               0,      RLEFT|RESCC,
+               "       OB2     AR,AL\n",
+
+ASG OPSIMP,    INAREG|FOREFF|FORCC,
+       AWD,    TCHAR|TUCHAR,
+       SCCON,  TWORD,
+               0,      RLEFT|RESCC,
+               "       OB2     AR,AL\n",
+
+OPSIMP,        INAREG|INTAREG|FORCC,
+       STAREG, ANYFIXED,
+       SAREG|AWD,      TWORD,
+               0,      RLEFT|RESCC,
+               "       OL2     AR,AL\n",
+
+OPSIMP,        INAREG|INTAREG|FORCC,
+       SAREG|AWD,      TWORD,
+       SAREG|AWD,      TWORD,
+               NAREG|NASL|NASR,        RESC1|RESCC,
+               "       OL3     AR,AL,A1\n",
+
+ASG OPFLOAT,   INAREG|FOREFF|FORCC,
+       SAREG|AWD,      TDOUBLE,
+       SAREG|AWD,      TDOUBLE,
+               0,      RLEFT|RESCC,
+               "       OD2     AR,AL\n",
+
+ASG OPFLOAT,   INAREG|FOREFF|FORCC,
+       SAREG|AWD,      TFLOAT,
+       SAREG|AWD,      TFLOAT,
+               0,      RLEFT|RESCC,
+               "       OF2     AR,AL\n",
+
+ASG OPFLOAT,   INAREG|FOREFF|FORCC,
+       SAREG|AWD,      TDOUBLE,
+       SAREG|AWD,      TFLOAT,
+               NAREG|NASR,     RLEFT|RESCC,
+               "       cvtfd   AR,A1\n OD2     A1,AL\n",
+
+ASG OPFLOAT,   INAREG|INTAREG|FOREFF|FORCC,
+       SAREG|AWD,      TFLOAT,
+       SAREG|AWD,      TDOUBLE,
+               NAREG,  RLEFT|RESC1|RESCC,
+               "       cvtfd   AL,A1\n OD2     AR,A1\n cvtdf   A1,AL\n",
+
+OPFLOAT,       INAREG|INTAREG|FORCC,
+       STAREG, TDOUBLE,
+       SAREG|AWD,      TDOUBLE,
+               0,      RLEFT|RESCC,
+               "       OD2     AR,AL\n",
+
+OPFLOAT,       INAREG|INTAREG|FORCC,
+       SAREG|AWD,      TDOUBLE,
+       SAREG|AWD,      TDOUBLE,
+               NAREG|NASL|NASR,        RESC1|RESCC,
+               "       OD3     AR,AL,A1\n",
+
+OPFLOAT,       INAREG|INTAREG|FORCC,
+       SAREG|AWD,      TFLOAT,
+       SAREG|AWD,      TDOUBLE,
+               NAREG|NASL,     RESC1|RESCC,
+               "       cvtfd   AL,A1\n OD2     AR,A1\n",
+
+OPFLOAT,       INAREG|INTAREG|FORCC,
+       SAREG|AWD,      TDOUBLE,
+       SAREG|AWD,      TFLOAT,
+               NAREG|NASR,     RESC1|RESCC,
+               "       cvtfd   AR,A1\n OD3     A1,AL,A1\n",
+
+OPFLOAT,       INAREG|INTAREG|FORCC,
+       SAREG|AWD,      TFLOAT,
+       SAREG|AWD,      TFLOAT,
+               NAREG|NASL|NASR,        RESC1|RESCC,
+               "       OF3     AR,AL,A1\n      cvtfd   A1,A1\n",
 
        /* Default actions for hard trees ... */
 
 
        /* Default actions for hard trees ... */
 
diff --git a/usr/src/cmd/pcs.c b/usr/src/cmd/pcs.c
new file mode 100644 (file)
index 0000000..b23bee1
--- /dev/null
@@ -0,0 +1,23 @@
+#include <sys/param.h>
+#include <sys/stat.h>
+struct stat buf;
+
+fault(a)
+{      signal(a,fault);
+}
+
+main()
+{
+       int i; char ch;
+       while (read(0,&ch,1)==1) write(1,&ch,1);
+       printf("PID=%d\n",getpid());
+       printf("signals\n");
+       for(i=1;i<NSIG;i++) {
+               printf("%d ",signal(i,1));
+       }
+       printf("\nfiles\n");
+       for(i=0;i<NOFILE;i++) {
+               printf("%c ",(fstat(i,&buf) != -1 ? 't' : '-'));
+       }
+       printf("\n");
+}
diff --git a/usr/src/cmd/pg.c b/usr/src/cmd/pg.c
new file mode 100644 (file)
index 0000000..ce724aa
--- /dev/null
@@ -0,0 +1,159 @@
+#include <stdio.h>
+
+#define NL '\n'
+#define CLEAR 014
+#define HOME 031
+#define BACK 037
+#define BUFMAX 16384
+#define PAGMAX 64
+
+int file;
+int cp, hp;
+int page[PAGMAX];
+int eof;
+
+char buf[BUFMAX];
+int bptr, bnxt, bend;
+
+
+#define incr(a,b) (a++, a&=b-1)
+#define decr(a,b) (a--, a&=b-1)
+
+
+main(argc,argv)
+char *argv[];
+{
+       int n=1;
+       if(argc<2)
+               print();
+       else {
+               while(argv[n]!=-1) {
+                       if((file=open(argv[n],0))>=0) {
+                               print();
+                               close(file);
+                       } else  printf("dk: `%s' cannot open\n",argv[n]);
+                       n++;
+               }
+       }
+}
+
+print()
+{
+       register int nlc;
+       char buf[2];
+
+       hp=0; cp=0;
+       bptr=bnxt=bend=0;
+       putchar(CLEAR);
+       for(;;) {
+               setpage();
+               nlc=0;
+               putchar(BACK);
+               while(nlc<20) {
+                       char c;
+                       c = readchar();
+                       if(eof)
+                               return;
+                       if(c==NL) nlc++;
+                       putchar(c);
+               }
+               while(read(2,buf,1)==1 && buf[0]!=NL) {
+                       switch(buf[0]) {
+                               case '/':
+                               case HOME:
+                                       putchar(CLEAR);
+                                       getpage(0);
+                                       break;
+                               case '-':
+                               case BACK:
+                                       getpage(-1);
+                                       putchar(CLEAR);
+                                       break;
+                               case '!':
+                                       shell(); buf[0]=NL; break;
+                       }
+               }
+       }
+}
+
+
+#include <signal.h>
+#define EOR '\n'
+shell()
+{
+       int rc, status, unixpid;
+       if( (unixpid=fork())==0 ) {
+               close(0); dup(2);
+               execl("/bin/sh", "sh", "-t", 0);
+               exit(255);
+       }
+       else if(unixpid == -1)
+               return(0);
+       else{   signal(SIGINT,SIG_IGN); signal(SIGQUIT,SIG_IGN);
+               while( (rc = wait(&status)) != unixpid && rc != -1 ) ;
+               signal(SIGINT,SIG_DFL); signal(SIGQUIT,SIG_DFL);
+               return(1);
+       }
+}
+
+readchar()
+{
+       register char c;
+       if(bnxt==bend)
+               fillbuf();
+       if(eof)
+               return(-1);
+       c=buf[bnxt];
+       incr(bnxt,BUFMAX);
+       return(c);
+}
+
+fillbuf()
+{
+       register int r;
+       register int len;
+       ensure();
+       if(eof)
+               return;
+       r=read(file,&buf[bend],512);
+       if(r==-1)
+               return;
+       bend += r; bend &= BUFMAX-1;
+       if(r==0)
+               eof++;
+       return;
+}
+
+ensure()
+{
+       for(;;) {
+               if(bptr<=bend)
+                       return(BUFMAX-bend-1);
+               if(bptr-bend>=512)
+                       return(512);
+               losepage();
+       }
+}
+
+losepage()
+{
+       if(hp<cp)
+               bptr=page[incr(hp,PAGMAX)];
+}
+
+setpage()
+{
+       incr(cp,PAGMAX);
+       if(cp==hp)
+               incr(hp,PAGMAX);
+       page[cp]=bnxt;
+}
+
+getpage(i)
+{
+       if(i==0)
+               cp=hp;
+       else    if(cp!=hp)
+                       decr(cp,PAGMAX);
+       bnxt=page[cp];
+}
diff --git a/usr/src/cmd/plot/Makefile b/usr/src/cmd/plot/Makefile
new file mode 100644 (file)
index 0000000..b3ba894
--- /dev/null
@@ -0,0 +1,22 @@
+all: tek t300 t300s t450 vplot
+
+tek:   driver.o
+       cc -o tek  driver.o -l4014 -lm
+t300:  driver.o 
+       cc -o t300 driver.o -l300 -lm
+t300s: driver.o 
+       cc -o t300s driver.o -l300s -lm
+t450:  driver.o 
+       cc -o t450 driver.o -l450 -lm
+vplot: chrtab.o vplot.o
+       cc -o vplot vplot.o chrtab.o
+
+install:
+       install -s tek $(DESTDIR)/usr/bin
+       install -s t300 $(DESTDIR)/usr/bin
+       install -s t300s $(DESTDIR)/usr/bin
+       install -s t450 $(DESTDIR)/usr/bin
+       install -s vplot $(DESTDIR)/usr/bin
+       install -c plot.sh $(DESTDIR)/usr/bin/plot
+clean:
+       rm -f *.o tek t300 t300s t450
diff --git a/usr/src/cmd/plot/makefile b/usr/src/cmd/plot/makefile
deleted file mode 100644 (file)
index ff7c70b..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-CFLAGS = -n -O -s
-
-all:   tek t300 t300s t450 vplot
-       :
-
-cp:    all
-       cp tek t300 t300s t450 vplot /bin
-       rm tek t300 t300s t450 vplot driver.o
-
-cmp:   all
-       cmp tek /bin/tek
-       rm tek
-       cmp t300 /bin/t300
-       rm t300
-       cmp t300s /bin/t300s
-       rm t300s
-       cmp t450 /bin/t450
-       rm t450
-       cmp vplot /bin/vplot
-       rm vplot
-       rm -f driver.o
-
-tek:   driver.o
-       cc -n -s -o tek  driver.o -lt4014 -lm
-t300:  driver.o 
-       cc -n -s -o t300 driver.o -lt300 -lm
-t300s: driver.o 
-       cc -n -s -o t300s driver.o -lt300s -lm
-t450:  driver.o 
-       cc -n -s -o t450 driver.o -lt450 -lm
-
-vplot: chrtab.o vplot.o
-       cc -n -s -o vplot vplot.o chrtab.o
-       rm vplot.o chrtab.o
diff --git a/usr/src/cmd/plot/plot.sh b/usr/src/cmd/plot/plot.sh
new file mode 100755 (executable)
index 0000000..c7ee671
--- /dev/null
@@ -0,0 +1,14 @@
+PATH=/bin:/usr/bin
+case $1 in
+-T*)   t=$1
+       shift ;;
+*)     t=-T$TERM
+esac
+case $t in
+-T450) exec t450 $*;;
+-T300) exec t300 $*;;
+-T300S|-T300s) exec t300s $*;;
+-Tver) exec vplot $*;;
+-Ttek|-T4014|-T)       exec tek $* ;;
+*)  echo plot: terminal type $t not known 1>&2; exit 1
+esac
index 5a96cc6..8fbaed0 100644 (file)
@@ -24,8 +24,8 @@ int   linmod  = SOLID;
 int    again;
 int    done1;
 char   chrtab[][16];
 int    again;
 int    done1;
 char   chrtab[][16];
-int    plotcom[]       { 0200, 0, 0};
-int    eotcom[]                { 0210, 0, 0};
+int    plotcom[]       { 0200, 0, 0};
+int    eotcom[]                { 0210, 0, 0};
 char   blocks  [NB][BSIZ];
 int    obuf[264];
 int    lastx;
 char   blocks  [NB][BSIZ];
 int    obuf[264];
 int    lastx;
index ced0dc8..880661e 100644 (file)
@@ -159,7 +159,7 @@ char **argp;
                mopen(argp);
                ncol = nofile;
        }
                mopen(argp);
                ncol = nofile;
        }
-       colw = width/ncol;
+       colw = width/(ncol==0? 1 : ncol);
        sncol = ncol;
        sheader = header;
        plength = length-5;
        sncol = ncol;
        sheader = header;
        plength = length-5;
@@ -288,8 +288,7 @@ nexbuf()
        n = &buffer[BUFS] - rbufp;
        if (n>512)
                n = 512;
        n = &buffer[BUFS] - rbufp;
        if (n>512)
                n = 512;
-       if(feof(file) ||
-          (n=fread(rbufp,1,n,file)) <= 0){
+       if((n=fread(rbufp,1,n,file)) <= 0){
                fclose(file);
                *rbufp = 0376;
        }
                fclose(file);
                *rbufp = 0376;
        }
diff --git a/usr/src/cmd/prep.h b/usr/src/cmd/prep.h
deleted file mode 100644 (file)
index b7b0da2..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-# define NUMC 128
-# define NUMS 3
-# define       NUMA    8
-# define PTRI 1600
-# define CHARI 16000
-# define OUT   3
-
-# define SKIP  0
-# define COLLECT       1
-# define SKIP2 2
-# define WIDTH 6
-struct {
-               char    *beg;
-               int     ct;
-               long    wdno;
-       } temp[30];
-
-int    lflag;
-int    puncfl;
-int    hsw;
-int    san;
-int    t1;
-
-
-
-char   tab[NUMS][NUMC];
-
-int    coll();
-int    save();
-int    hyphen();
-int    hyp1();
-int    hyp2();
-int    error();
-int    ctout();
-int    bsp();
-int    bsp1();
-int    gobble2();
-int    bslash();
-int    punc();
-
-char   line[300];
-int    l;
-int    lno;
-int    c;
-
-int    only;
-int    cs;
-int    (*flag[8])();
-int    fl;
-int    wdflg;
-long   wdnum;
-char   num[WIDTH + 1];
-int    igflg;
-
-struct htab    {
-               int     hsiz;
-               int     ssiz;
-               int     nsym;
-               int     curb;
-               int     *hptr;
-               char    *symt;
-               };
-
-struct htab    itab;
-
-int    ipsp[PTRI];
-char   issp[CHARI];
-
-
-
-FILE   *fi;
diff --git a/usr/src/cmd/prep/makefile b/usr/src/cmd/prep/makefile
deleted file mode 100644 (file)
index 5d1d5d3..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-CFLAGS = -n -O
-
-all:   prep
-       :
-
-cp:    all
-       cp prep /bin
-       rm prep *.o
-
-cmp:   all
-       cmp prep /bin/prep
-       rm prep *.o
-
-prep:  prep0.o prep1.o prep2.o; cc -s -o prep -n *.o
-
-prep0.o: prep0.c prep.h
-prep1.o: prep1.c prep.h
-prep2.o: prep2.c
diff --git a/usr/src/cmd/prep/prep.h b/usr/src/cmd/prep/prep.h
deleted file mode 100644 (file)
index b7b0da2..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-# define NUMC 128
-# define NUMS 3
-# define       NUMA    8
-# define PTRI 1600
-# define CHARI 16000
-# define OUT   3
-
-# define SKIP  0
-# define COLLECT       1
-# define SKIP2 2
-# define WIDTH 6
-struct {
-               char    *beg;
-               int     ct;
-               long    wdno;
-       } temp[30];
-
-int    lflag;
-int    puncfl;
-int    hsw;
-int    san;
-int    t1;
-
-
-
-char   tab[NUMS][NUMC];
-
-int    coll();
-int    save();
-int    hyphen();
-int    hyp1();
-int    hyp2();
-int    error();
-int    ctout();
-int    bsp();
-int    bsp1();
-int    gobble2();
-int    bslash();
-int    punc();
-
-char   line[300];
-int    l;
-int    lno;
-int    c;
-
-int    only;
-int    cs;
-int    (*flag[8])();
-int    fl;
-int    wdflg;
-long   wdnum;
-char   num[WIDTH + 1];
-int    igflg;
-
-struct htab    {
-               int     hsiz;
-               int     ssiz;
-               int     nsym;
-               int     curb;
-               int     *hptr;
-               char    *symt;
-               };
-
-struct htab    itab;
-
-int    ipsp[PTRI];
-char   issp[CHARI];
-
-
-
-FILE   *fi;
diff --git a/usr/src/cmd/prep/prep0.c b/usr/src/cmd/prep/prep0.c
deleted file mode 100644 (file)
index 7395b84..0000000
+++ /dev/null
@@ -1,253 +0,0 @@
-# include <stdio.h>
-# include "prep.h"
-
-int    (*acts[])() =   {0,
-                       coll,
-                       save,
-                       ctout,
-                       gobble2,
-                       hyphen,
-                       bsp,
-                       bslash,
-                       punc
-                       };
-
-
-char   *ignonl = "/usr/lib/eign";
-
-char tab[NUMS][NUMC] = {
-
-/*SKIP*/
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 3, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 8, 0, 0, 0, 0, 0, 0,
-       8, 8, 0, 0, 8, 0, 8, 0,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 8, 8, 0, 0, 0, 8,
-       0, 1, 1, 1, 1, 1, 1, 1,
-       1, 1, 1, 1, 1, 1, 1, 1,
-       1, 1, 1, 1, 1, 1, 1, 1,
-       1, 1, 1, 0, 7, 0, 0, 0,
-       0, 1, 1, 1, 1, 1, 1, 1,
-       1, 1, 1, 1, 1, 1, 1, 1,
-       1, 1, 1, 1, 1, 1, 1, 1,
-       1, 1, 1, 0, 0, 0, 0, 0,
-/*COLLECT*/
-       2, 2, 2, 2, 2, 2, 2, 2,
-       6, 2, 3, 2, 2, 2, 2, 2,
-       2, 2, 2, 2, 2, 2, 2, 2,
-       2, 2, 2, 2, 2, 2, 2, 2,
-       2, 8, 2, 2, 2, 2, 2, 0,
-       8, 8, 2, 2, 8, 5, 8, 2,
-       2, 2, 2, 2, 2, 2, 2, 2,
-       2, 2, 8, 8, 2, 2, 2, 8,
-       2, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 2, 7, 2, 2, 2,
-       2, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 2, 2, 2, 2, 2,
-/*SKIP2*/
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 3, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 8, 0, 0, 0, 0, 0, 0,
-       8, 8, 0, 0, 8, 0, 8, 0,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 8, 8, 0, 0, 0, 8,
-       0, 1, 1, 1, 1, 1, 1, 1,
-       1, 1, 1, 1, 1, 1, 1, 1,
-       1, 1, 1, 1, 1, 1, 1, 1,
-       1, 1, 1, 0, 0, 0, 0, 0,
-       0, 1, 1, 1, 1, 1, 1, 1,
-       1, 1, 1, 1, 1, 1, 1, 1,
-       1, 1, 1, 1, 1, 1, 1, 1,
-       1, 1, 1, 0, 0, 0, 0, 0
-};
-
-main(argc,argv)
-       char    *argv[];
-{
-       auto    i,j;
-
-       if(argc > 1 && *argv[1] == '-') {
-               j = flags(argv);
-               argv += j;
-               argc -= j;
-       }
-
-       init();
-
-       i = 0;
-       if(argc == 1) {
-               fi = stdin;
-               goto pipe;
-       }
-       while(++i < argc) {
-
-               if((fi = fopen(argv[i], "r")) == NULL) {
-                       fprintf(stderr, "Can't open %s\n",argv[i]);
-                       exit(1);
-               }
-
-pipe:
-               lno = 1;
-
-               driver(argv[i]);
-
-               fclose(fi);
-       }
-       flsh();
-
-       exit(0);
-}
-
-driver(arg)
-char   *arg;
-{
-       auto    p;
-
-       l = -1;
-       while((c = line[++l] = getc(fi)) != -1) {
-/*     fprintf(stderr, "driver: c = %o l = %d\n",c,l); /*DEBUG*/
-               if(l >= 299) {
-                       lflag++;
-                       l--;
-               }
-
-               if(c & 0200) {
-                       fprintf(stderr, "Illegal character: %o line %d file %s\n",
-                               c, lno, arg);
-                       exit(1);
-               }
-
-               if(l == 0 && (c == '.' || c == '\'')) {
-                       while((c = getc(fi)) != '\n' )
-                               if(c == -1)     return;
-                       lno++;
-                       l = -1;
-                       continue;
-               }
-
-               if(fl) {
-                       if((*flag[fl])())
-                               continue;
-               }
-
-/*fprintf(stderr, "cs = %d cc = %c ca = %d\n",cs,c,tab[cs][c]);        /*DEBUG*/
-
-               if(p = tab[cs][c])
-                       (*acts[p])();
-               continue;
-       }
-       return;
-
-}
-
-init()
-{
-       FILE    *fio, *fopen();
-       extern  coll(),save(),ctout(),asym(),asw(),csym(),csw();
-       extern  incl(),decl(),sk(),sk2();
-
-
-       if(!igflg)return;
-
-       itab.hptr = ipsp;
-       itab.symt = issp;
-       itab.hsiz = PTRI;
-       itab.ssiz = CHARI;
-       itab.nsym = 0;
-       itab.curb = 1;
-
-       if((fio = fopen(ignonl, "r")) == NULL) {
-               fprintf(stderr, "Cannot open ignore/only file.\n");
-               exit(1);
-       }
-       compile(fio);
-       return;
-}
-
-
-flags(argv)
-       char    *argv[];
-{
-       int     j;
-       char    *ap;
-
-       j = 1;
-       ap = argv[1];
-       while(*++ap != '\0') {
-               switch(*ap) {
-
-                       default:
-                               fprintf(stderr, "Unrecognized flag: %c\n",*ap);
-                               exit(1);
-
-
-                       case 'i':       /* Ignore file */
-                               if(!igflg) {
-                                       igflg = 1;
-                                       only = 0;
-                                       ignonl = argv[++j];
-                               }
-                               continue;
-
-                       case 'o':       /*only file*/
-                               if(!igflg) {
-                                       igflg = 1;
-                                       only = 1;
-                                       ignonl = argv[++j];
-                               }
-                               continue;
-                       case 'd':       /*word number*/
-                               wdflg = 1;
-                               wdnum = 0;
-                               num[WIDTH] = ' ';
-                               continue;
-
-                       case 'p':
-                               puncfl = 1;
-                               continue;
-               }
-
-       }
-       return(j);
-}
-compile(fio)
-FILE   *fio;
-{
-       char    buf[40],*b;
-       int     i,v;
-
-
-       b = buf - 1;
-       while((i = *++b = getc(fio)) != EOF) {
-               if(*b == '\n') {
-                       *b = '\0';
-                       search(buf,b - buf,&itab,1);
-                       b = buf - 1;
-               } else {
-                       if(*b == '\t') {
-                               v = 0;
-                               while((i = getc(fio)) != -1) {
-                                       if(i == '\n')   break;
-                                       v = v*10 + (i - '0');
-                               }
-                               search(buf,b - buf,&itab,v);
-                               b = buf - 1;
-                       } else {
-                               if((b - buf) > 39) {
-                                       fprintf(stderr, "Ignore/only symbol too long.\n");
-                                       exit(1);
-                               }
-                       }
-               }
-       }
-       return;
-}
diff --git a/usr/src/cmd/prep/prep1.c b/usr/src/cmd/prep/prep1.c
deleted file mode 100644 (file)
index fd1aa54..0000000
+++ /dev/null
@@ -1,283 +0,0 @@
-# include <stdio.h>
-# include "prep.h"
-# define SKIP 0
-# define COLLECT 1
-# define SKIP2 2
-
-int    tlno = 1;
-
-coll()
-{
-       cs = COLLECT;
-       temp[t1].beg = &line[l];
-       return;
-}
-
-save()
-{
-       extern  only;
-       char    *pt1,*pt2,cbuf[30];
-       int     val;
-
-       if(cs != COLLECT) {
-               cs = SKIP;
-               return;
-       }
-       cs = SKIP;
-       line[l] = '\0';
-       temp[t1].ct = &line[l] - temp[t1].beg;
-       pt1 = temp[t1].beg-1;
-       pt2 = cbuf-1;
-
-       wdnum++;
-       while(*++pt2 = *++pt1)
-               if(*pt2 >= 'A' && *pt2 <= 'Z')
-                       *pt2 |= 040;
-
-       if(igflg){
-               val = search(cbuf,temp[t1].ct,&itab,0);
-               if(!val == !only) goto yes;
-
-               line[l] = c;
-               return;
-       }
-yes:
-       temp[t1++].wdno = wdnum;
-       line[l] = c;
-       return;
-}
-
-ctout()
-{
-       register int    ct;
-       register char   *t2;
-       int     t3;
-       long    xxx;
-
-       if(lflag) {
-               fprintf(stderr, "line too long:  line %d\n",lno);
-               lflag = 0;
-       }
-       if(cs == COLLECT)       save();
-
-       t3 = t1;
-       t1 = -1;
-       while(++t1 < t3) {
-               if(wdflg){
-                       xxx = temp[t1].wdno;
-                       conf(xxx, WIDTH, num);
-                       put(num,WIDTH+1);
-               }
-               ct = temp[t1].ct;
-               t2 = temp[t1].beg - 1;
-/*             fprintf(stderr, "out: %s        %d\n", temp[t1].beg, ct);       /*DEBUG*/
-               while(ct--)
-                       if(*++t2 >= 'A' && *t2 <= 'Z')
-                               *t2 |= 040;
-
-               ct = temp[t1].ct;
-               while(*--t2 == '\'' && san == 0)
-                       ct--;
-
-               put(temp[t1].beg, ct);
-               put("\n", 1);
-       }
-       t1 = 0;
-       l = -1;
-       lno += tlno;
-       tlno = 1;
-       cs = SKIP;
-       return;
-}
-
-conf(n,width,buf) 
-       long n;
-       char    *buf;
-{
-       long    a;
-       auto i;
-
-       i = width;
-       while(i--)      buf[i] = ' ';
-
-       a = n/10;
-       if(a)
-               width = conf(a, --width, buf);
-       else
-               width--;
-       buf[width] = n%10 + '0';
-
-       return(++width);
-}
-
-hyphen()
-{
-/*     fprintf(stderr, "hyphen\n");    /*DEBUG*/
-       flag[++fl] = hyp1;
-       return(1);
-}
-
-hyp1()
-{
-/*     fprintf(stderr, "hyp1 c = %o\n",c);     /*DEBUG*/
-       if(c !=  '\n') {
-               fl--;
-               l--;
-               save();
-               l++;
-               punc();
-               return(0);
-       } else {
-               l -= 2;
-               flag[fl] = hyp2;
-               hsw = 1;
-               return(1);
-       }
-}
-
-hyp2()
-{
-       extern  (*acts[])();
-/*     fprintf(stderr, "hyp2 c = %o l = %d\n",c,l);    /*DEBUG*/
-       if(hsw && (tab[2][c] == 0)) {
-               l--;
-               if(c == '\n')   tlno++;
-               return(1);
-       }
-       hsw = 0;
-       if(c == '\n'){
-               l--;
-               return(1);
-       }
-       if(tab[cs][c]) {
-               line[l] = '\n';
-               (*acts[OUT])();
-               fl--;
-               return(0);
-       }
-       return(1);
-}
-
-gobble2()
-{
-       static  ct2;
-
-       if(cs == COLLECT)       save();
-
-       if(flag[fl] != gobble2) {
-               ct2 = 1;
-               flag[++fl] = gobble2;
-               return(1);
-       }
-       if(ct2--)       return(1);
-
-       fl--;
-       cs = SKIP;
-       return(1);
-}
-
-bslash()
-{
-       if(cs == COLLECT)       save();
-       cs = SKIP2;
-       return(1);
-}
-
-bsp()
-{
-       flag[++fl] = bsp1;
-       return(1);
-}
-
-bsp1()
-{
-       fl--;
-       if(c == '"')    return(1);
-
-       line[--l] = c;
-       return(0);
-}
-
-punc()
-{
-
-       if(cs == COLLECT)
-               save();
-       if(puncfl) {
-               temp[t1].beg = &line[l];
-               temp[t1].ct = 1;
-               temp[t1++].wdno = 0;
-       }
-}
-
-search(symbol,length,params,install)
-       char    *symbol;
-       int     length;
-       struct  htab    *params;
-       int     install;
-{
-       char    *sp,*p;
-       static  int     *hptr,hsiz,nsym;
-       static  int     ssiz;
-       static  int     curb;
-       static  char    *symt;
-       auto    h,i,j;
-
-       if(hptr != params->hptr) {
-               hptr = params->hptr;
-               hsiz = params->hsiz;
-               symt = params->symt;
-               ssiz = params->ssiz;
-               curb = params->curb;
-               nsym = params->nsym;
-       }
-
-       symbol[length] = '\0';
-/*fprintf(stderr, "ssiz = %d; nsym = %d; %s\n", ssiz, nsym, symbol);/*DEBUG*/
-       sp = symbol;
-
-       i = length;
-       h = 1;
-       while(i--)
-               h *= *sp++;
-
-       if(h == 0100000) {
-               h = 1;
-       } else {
-               h = h<0?(-h)%hsiz:h%hsiz;
-       }
-       if(h == 0)      h++;
-/*             fprintf(stderr, "%s %d\n",symbol,h);    /*DEBUG*/
-
-       while((p = &symt[hptr[h]]) > symt) {
-               j = length + 2;
-               sp = symbol;
-               while(--j) {
-                       if(*p++ != *sp++)       goto no;
-               }
-               return(*p);
-no:
-               h++;
-               if(h >= hsiz)   h -= hsiz;
-       }
-       if(install) {
-               if(++nsym >= hsiz) {
-                       fprintf(stderr, "Too many symbols in ignore/only file.\n");
-                       exit(1);
-               }
-
-               hptr[h] = curb;
-               length++;
-               if((curb + length) >= ssiz) {
-                       fprintf(stderr, "i/o file too big; ssiz = %d\n", ssiz);
-                       exit(1);
-               }
-
-               while(length--)
-                       symt[curb++] = *symbol++;
-               symt[curb++] = install;
-               params->curb = curb;
-               params->nsym = nsym;
-       }
-       return(0);
-}
diff --git a/usr/src/cmd/prep/prep2.c b/usr/src/cmd/prep/prep2.c
deleted file mode 100644 (file)
index 6eaf72b..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-int    optr;
-
-char   obuf[512];
-
-int    nflush;
-
-put(string,n)
-       char    *string;
-{
-       int     i;
-       char    *o;
-
-/*printf("%c %d\n",*string,n);/*DEBUG*/
-
-       string--;
-
-       if((i = optr + n - 512) >= 0) {
-               n -= i;
-               o = &obuf[optr] -1;
-               while(--n >= 0)
-                       *++o = *++string;
-               optr = 512;
-               flsh();
-               n = i;
-       }
-
-       o = &obuf[optr] - 1;
-       optr += n;
-
-       while(--n >= 0) {
-               *++o = *++string;
-       }
-       return(0);
-}
-
-flsh()
-{
-
-       if(optr <= 0)   return(optr);
-
-       nflush++;
-       if(write(1,obuf,optr) != optr)
-               return(-1);
-       optr = 0;
-       return(0);
-}
-
diff --git a/usr/src/cmd/primes.s b/usr/src/cmd/primes.s
deleted file mode 100644 (file)
index ad80946..0000000
+++ /dev/null
@@ -1,355 +0,0 @@
-ldfps = 170100^tst
-/
-       ldfps   $240
-
-       clr     argflg
-       cmp     (sp)+,$2
-       blt     begin
-       tst     (sp)+
-       mov     (sp),r2
-       jsr     r5,atof; getch1
-       inc     argflg
-       br      begin1
-begin:
-       tst     argflg
-       beq 9f; sys exit; 9:
-       jsr     r5,atof; getch
-begin1:
-       tstf    fr0
-       cfcc
-       bpl 9f; jmp ouch; 9:
-       bne 9f; sys exit; 9:
-       cmpf    big,fr0
-       cfcc
-       bgt 9f; jmp ouch; 9:
-/
-       movf    $f100,fr1
-       cmpf    fr0,fr1
-       cfcc
-       bge     1f
-       mov     $pt,r3
-3:
-       cmp     r3,$ptend
-       bhis    1f
-       movif   (r3)+,fr1
-       cmpf    fr1,fr0
-       cfcc
-       blt     3b
-       tst     -(r3)
-3:
-       movif   (r3),fr0
-       jsr     r5,ftoa; wrchar
-       mov     $'\n,r0
-       jsr     r5,wrchar
-       tst     (r3)+
-       cmp     r3,$ptend
-       blo     3b
-       movf    $f100,fr0
-/
-1:
-       divf    $two,fr0
-       modf    $one,fr0
-       movf    fr1,fr0
-       mulf    $two,fr0
-       addf    $one,fr0
-       movif   $tsiz8,fr1
-       movf    fr1,fr5
-       movf    fr0,nn
-/
-/
-/
-/      clear the sieve table
-/
-2:
-       mov     $table,r3
-3:
-       cmp     r3,$table+tabsiz
-       bhis    3f
-       clrb    (r3)+
-       br      3b
-/
-/      run the sieve
-/
-3:
-       movf    nn,fr0
-       addf    fr5,fr0
-       jsr     r5,sqrt
-       movf    fr0,v
-/
-       movf    nn,fr0
-       movif   $3.,fr1
-       jsr     pc,5f
-       movif   $5.,fr1
-       jsr     pc,5f
-       movif   $7.,fr1
-       jsr     pc,5f
-       movif   $11.,fr1
-       mov     $factab+2,r4
-4:
-       jsr     pc,5f
-       mov     (r4)+,kazoo
-kazoo  =.+2
-       addf    $kazoo,fr1
-       cmp     r4,$ftabend
-       blo     3f
-       mov     $factab,r4
-3:
-       cmpf    v,fr1
-       cfcc
-       bge     4b
-       br      1f
-/
-/
-5:
-       movf    fr0,fr2
-       divf    fr1,fr2
-       modf    $one,fr2
-       mulf    fr1,fr3
-       subf    fr0,fr3
-       cfcc
-       bpl     3f
-       addf    fr1,fr3
-3:
-       cmpf    fr5,fr3
-       cfcc
-       ble     3f
-       movfi   fr3,r0
-       ashc    $-3.,r0
-       ash     $-13.,r1
-       bic     $177770,r1
-       bisb    bittab(r1),table(r0)
-       addf    fr1,fr3
-       br      3b
-3:
-       rts     pc
-/
-/
-/      get one character form the argument string.
-getch1:
-       movb    (r2)+,r0
-       rts     r5
-/
-/      now get the primes from the table
-/      and print them.
-/
-1:
-/
-       movf    nn,fr0
-       clr     r3
-       br      4f
-/
-1:
-       inc     r3
-       inc     r3
-       cmp     r3,$tsiz8
-       bge     2b
-/
-4:
-/
-       jsr     pc,prime
-       bec     3f
-       movf    nn,fr0
-       jsr     r5,ftoa; wrchar
-       mov     $'\n,r0
-       jsr     r5,wrchar
-3:
-       movf    nn,fr0
-       addf    $two,fr0
-       movf    fr0,nn
-       br      1b
-/
-/
-/
-/
-prime:
-       mov     r3,r4
-       ashc    $-3.,r4
-       ash     $-13.,r5
-       bic     $177770,r5
-       bitb    bittab(r5),table(r4)
-       bne     1f
-       sec
-1:
-       rts     pc
-/
-/
-/
-/
-one    = 40200
-half   = 40000
-opower = 34400
-power  = 44000
-f100   = 41710
-/
-/      get one character from the console.
-/      called from atof.
-/
-getch:
-       clr     r0
-       sys     read; ch; 1
-       bec 9f; sys exit; 9:
-       tst r0; bne 9f; sys exit; 9:
-       mov     ch,r0
-       rts     r5
-/
-/
-/      write one character on the console
-/      called from ftoa.
-/
-wrchar:
-       tst     iobuf
-       bne     1f
-       mov     $iobuf+2,iobuf
-1:
-       movb    r0,*iobuf
-       inc     iobuf
-       cmp     iobuf,$iobuf+514.
-       blo     1f
-       mov     $1,r0
-       sys     write; iobuf+2; 512.
-       mov     $iobuf+2,iobuf
-1:
-       rts     r5
-/
-       .bss
-iobuf: .=.+518.
-       .text
-/
-/
-/      read and convert a line from the console into fr0.
-/
-atof:
-       mov     r1,-(sp)
-       movif   $10.,r3
-       clrf    r0
-1:
-       jsr     r5,*(r5)
-       sub     $'0,r0
-       cmp     r0,$9.
-       bhi     2f
-       mulf    r3,r0
-       movif   r0,r1
-       addf    r1,r0
-       br      1b
-2:
-       cmp     r0,$' -'0
-       beq     1b
-/
-       mov     (sp)+,r1
-       tst     (r5)+
-       rts     r5
-/
-/
-ftoa:
-       mov     $ebuf,r2
-1:
-       movf    fr0,fr1
-       divf    $ten,fr1
-       movf    fr1,fr2
-       modf    $one,fr2
-       movf    fr3,-(sp)
-       mulf    $ten,fr3
-       negf    fr3
-       addf    fr0,fr3
-       movfi   fr3,-(r2)
-       movf    (sp)+,fr0
-       tstf    fr0
-       cfcc
-       bne     1b
-1:
-       mov     (r2)+,r0
-       add     $60,r0
-       jsr     r5,*(r5)
-       cmp     r2,$ebuf
-       blo     1b
-       tst     (r5)+
-       rts     r5
-/
-/
-/
-/      replace the f.p. number in fr0 by its square root
-/
-sqrt:
-       movf    r0,r1           / a
-       tstf    fr0
-       cfcc
-       beq     2f
-       bgt     1f
-       sec
-       rts     r5              / sqrt(-a)
-1:
-       seti
-       movf    fr0,-(sp)
-       asr     (sp)
-       add     $20100,(sp)
-       movf    (sp)+,fr0
-       movif   $2,r3           / constant 2
-       mov     $4,r0
-1:
-       movf    r1,r2
-       divf    r0,r2
-       addf    r2,r0
-       divf    r3,r0           / x = (x+a/x)/2
-       dec     r0
-       bgt     1b
-2:
-       clc
-       rts     r5
-/
-/
-buf:   .=.+38.
-ebuf:
-/
-/
-/
-/      complain about a number which the program
-/      is unable to digest
-ouch:
-       mov     $2,r0
-       sys     write; 1f; 2f-1f
-       jmp     begin
-/
-1:     <Ouch.\n>
-2:     .even
-/
-/
-one    = 40200
-two    = 40400
-four   = 40600
-six    = 40700
-ten    = 41040
-/
-       .data
-bittab:        .byte   1, 2, 4, 10, 20, 40, 100, 200
-big:   056177; 177777; 177777; 177777
-/
-pt:    2.; 3.; 5.; 7.; 11.; 13.; 17.; 19.; 23.; 29.; 31.; 37.; 41.; 43.
-       47.; 53.; 59.; 61.; 67.; 71.; 73.; 79.; 83.; 89.; 97.
-ptend:
-nl:    <\n>
-sp5:   <     >
-       .even
-/
-/
-factab:
-       41040; 40400; 40600; 40400; 40600; 40700; 40400; 40700
-       40600; 40400; 40600; 40700; 40700; 40400; 40700; 40600
-       40400; 40700; 40600; 40700; 41000; 40600; 40400; 40600
-       40400; 40600; 41000; 40700; 40600; 40700; 40400; 40600
-       40700; 40400; 40700; 40700; 40600; 40400; 40600; 40700
-       40400; 40700; 40600; 40400; 40600; 40400; 41040; 40400
-ftabend:
-/
-       .bss
-ch:    .=.+2
-t:     .=.+8
-n:     .=.+8
-v:     .=.+8
-nn:    .=.+8
-place: .=.+8
-/
-tabsiz = 1000.
-tsiz8  = 8000.
-table: .=.+tabsiz
-argflg:        .=.+2
-       .text
diff --git a/usr/src/cmd/prof.c b/usr/src/cmd/prof.c
deleted file mode 100644 (file)
index 696e8bb..0000000
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- *  Print execution profile
- */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <a.out.h>
-
-typedef        short UNIT;             /* unit of profiling */
-
-struct stat stbuf;
-struct nl {
-       char    name[8];
-       unsigned value;
-       float   time;
-       long    ncall;
-};
-
-struct hdr {
-       UNIT    *lowpc;
-       UNIT    *highpc;
-       int     ncount;
-};
-
-struct nl nl[1200];
-
-struct cnt {
-       unsigned cvalue;
-       long    cncall;
-} cbuf[350];
-
-FILE   *pfile, *nfile;
-unsigned highpc;
-unsigned lowpc;
-double ransca;
-double ranoff;
-unsigned pcl;
-unsigned pch;
-unsigned bufs;
-int    nname;
-double ftime;
-double actime;
-double totime;
-double maxtime;
-double scale;
-double lastx;
-double lasty;
-struct nl *np;
-struct nl *npe;
-int    aflg;
-int    vflg;
-int    lflg;
-long   symoff;
-
-main(argc, argv)
-char **argv;
-{
-       char *namfil;
-       int timcmp(), valcmp();
-       int i, overlap;
-       long pfpos;
-       double lastsx;
-       struct cnt *cp;
-       double tx, ty;
-       struct exec xbuf;
-       struct hdr h;
-
-       lowpc = -1;
-       highpc = -1;
-       argv++;
-       namfil = "a.out";
-       while (argc>1) {
-               if (**argv == '-') {
-                       if (*++*argv == 'l')
-                               lflg++;
-                       if (**argv == 'a')
-                               aflg = 040;
-                       if(**argv == 'v')
-                               vflg++;
-                       if(**argv >= '0' && **argv <= '9') {
-                               i = atoi(*argv);
-                               if(lowpc == -1)
-                                       lowpc = i;
-                               else
-                                       highpc = i;
-                       }
-               } else
-                       namfil = *argv;
-               argc--;
-               argv++;
-       }
-       if (lowpc >= 100)
-               lowpc = 0;
-       if(highpc <= lowpc || highpc > 100)
-               highpc = 100;
-       ransca = 100./(highpc-lowpc);
-       ranoff = 2040. + 40.8*lowpc*ransca;
-       if((nfile=fopen(namfil,"r"))==NULL) {
-               fprintf(stderr, "%s: not found\n", namfil);
-               done();
-       }
-       fread((char *)&xbuf, 1, sizeof(xbuf), nfile);
-       if (xbuf.a_magic!=A_MAGIC1 && xbuf.a_magic!=A_MAGIC2 && xbuf.a_magic!=A_MAGIC3) {
-               fprintf(stderr, "%s: bad format\n", namfil);
-               done();
-       }
-       symoff = (long)xbuf.a_text + xbuf.a_data;
-       if ((xbuf.a_flag&01) == 0)
-               symoff *= 2;
-       fseek(nfile, symoff+sizeof(xbuf), 0);
-       if((pfile = fopen("mon.out","r")) == NULL) {
-               fprintf(stderr, "No mon.out\n");
-               done();
-       }
-       fstat(fileno(pfile), &stbuf);
-       fread((char *)&h, sizeof(struct hdr), 1, pfile);
-       lowpc = h.lowpc - (UNIT *)0;
-       highpc = h.highpc - (UNIT *)0;
-       bufs = stbuf.st_size - sizeof(struct hdr) - h.ncount*sizeof(struct cnt);
-       fread((char *)cbuf, sizeof(struct cnt), h.ncount, pfile);
-       pfpos = ftell(pfile);
-       npe = nl;
-       for (nname = 0; xbuf.a_syms > 0; xbuf.a_syms -= sizeof(struct nlist)) {
-               struct nlist nbuf;
-               fread((char *)&nbuf, sizeof(nbuf), 1, nfile);
-               if (nbuf.n_type!=N_TEXT && nbuf.n_type!=N_TEXT+N_EXT)
-                       continue;
-               if (aflg==0 && nbuf.n_type!=N_TEXT+N_EXT)
-                       continue;
-               npe->value = nbuf.n_value/sizeof(UNIT);
-               for (i=0; i<8; i++)
-                       npe->name[i] = nbuf.n_name[i];
-               npe++;
-               nname++;
-       }
-       if (nname == 0) {
-               fprintf(stderr, "%s: no symbols\n", namfil);
-               done();
-       }
-       npe->value = -1;
-       npe++;
-       for (cp = cbuf; cp < &cbuf[h.ncount]; cp++)
-               for (np = nl; np < npe; np++)
-                       if ((unsigned)(cp->cvalue/sizeof(UNIT) - np->value) <=10) {
-                               np->ncall = cp->cncall;
-                               break;
-                       }
-       qsort(nl, nname, sizeof(struct nl), valcmp);
-       scale = highpc - lowpc;
-       scale /= bufs/sizeof(UNIT);
-       for(i=0;;i++) {
-               register j;
-               unsigned UNIT ccnt;
-               fread((char *)&ccnt, sizeof(ccnt), 1, pfile);
-               if(feof(pfile))
-                       break;
-               if (ccnt == 0)
-                       continue;
-               pcl = lowpc + scale*i;
-               pch = lowpc + scale*(i+1);
-               ftime = ccnt;
-               totime += ftime;
-               if(ftime > maxtime)
-                       maxtime = ftime;
-               for (j=0; j<nname; j++) {
-                       if (pch < nl[j].value)
-                               break;
-                       if (pcl >= nl[j+1].value)
-                               continue;
-                       overlap=(min(pch,nl[j+1].value)-max(pcl,nl[j].value));
-                       nl[j].time += overlap*ftime/scale;
-               }
-       }
-       if (totime==0.0) {
-               fprintf(stderr, "No time accumulated\n");
-               done();
-       }
-#ifdef plot
-       if(!vflg)
-               goto print;
-       openpl();
-       erase();
-       space(-2048, -2048, 2048, 2048);
-       line(-2040, -2040, -2040, 2040);
-       line(0, 2040, 0, -2040);
-       for(i=0; i<11; i++)
-               line(-2040, 2040-i*408, 0, 2040-i*408);
-       lastx = 0.;
-       lasty = ranoff;
-       scale = (4080.*ransca)/(bufs/sizeof(UNIT));
-       fclose(pfile);  /*to turn off eof*/
-       pfile = fopen("mon.out", "r");
-       fseek(pfile, pfpos, 0);
-       lastsx = 0.0;
-       for(;;) {
-               unsigned UNIT ccnt;
-               fread((char *)&ccnt, sizeof(ccnt), 1, pfile);
-               if(feof(pfile))
-                       break;
-               ftime = ccnt;
-               tx = lastsx;
-               ty = lasty;
-               lastsx -= 2000.*ftime/totime;
-               lasty -= scale;
-               if(lasty >= -2040. && ty <= 2040.) {
-                       line((int)tx, (int)ty, (int)lastsx, (int)lasty);
-                       if (ccnt!=0 || lastx!=0.0) {
-                               tx = lastx;
-                               lastx = -ftime*2000./maxtime;
-                               ty += scale/2;
-                               line(0, (int)ty, (int)tx, (int)ty);
-                       }
-               }
-       }
-       scale = (4080.*ransca)/(highpc-lowpc);
-       lastx = 50.;
-       for(np = nl; np<npe;  np++) {
-               if(np->value < lowpc)
-                       continue;
-               if(np->value >= highpc)
-                       continue;
-               ftime = np->time/totime;
-               lasty = ranoff - (np->value - lowpc)*scale;
-               if(lasty >= -2040. && lasty <= 2040.) {
-                       char bufl[8+3], *namp;
-                       register j;
-                       line(0, (int)lasty, 50, (int)lasty);
-                       line((int)(lastx-50),(int)lasty,(int)lastx,(int)lasty);
-                       point((int)(lastx+30), (int)(lasty+10));
-                       namp = bufl;
-                       for(j=0; j<8; j++)
-                               if(np->name[j] != '_')
-                                       *namp++ = np->name[j];
-                       *namp++ = '\n';
-                       *namp++ = 0;
-                       label(bufl);
-               }
-               lastx += 500.;
-               if(lastx > 2000.)
-                       lastx = 50.;
-       }
-       done();
-
-print:
-#endif
-       actime = 0;
-       printf("    name %%time  cumsecs  #call  ms/call\n");
-       if (!lflg)
-               qsort(nl, nname, sizeof(struct nl), timcmp);
-       for (np = nl; np<npe-1; np++) {
-               ftime = np->time/totime;
-               actime += np->time;
-               printf("%8.8s%6.1f%9.2f", np->name, 100*ftime, actime/60);
-               if(np->ncall!=0) {
-                       printf("%6ld", np->ncall);
-                       printf(" %7.2f\n", np->time/(np->ncall*.06));
-               } else
-                       printf("\n");
-       }
-       done();
-}
-
-min(a, b)
-unsigned a, b;
-{
-       if (a<b)
-               return(a);
-       return(b);
-}
-
-max(a, b)
-unsigned a, b;
-{
-       if (a>b)
-               return(a);
-       return(b);
-}
-
-valcmp(p1, p2)
-struct nl *p1, *p2;
-{
-       return(p1->value - p2->value);
-}
-
-timcmp(p1, p2)
-struct nl *p1, *p2;
-{
-       float d;
-
-       d = p2->time - p1->time;
-       if (d > 0.0)
-               return(1);
-       if (d < 0.0)
-               return(-1);
-       return(0);
-}
-
-done()
-{
-
-#ifdef plot
-       if(vflg) {
-               point(0, -2040);
-               closepl();
-       }
-#endif
-       exit(0);
-}
diff --git a/usr/src/cmd/prof/Makefile b/usr/src/cmd/prof/Makefile
new file mode 100644 (file)
index 0000000..a646ad4
--- /dev/null
@@ -0,0 +1,11 @@
+# If you don't want to plot, take out the -Dplot and the ref. to plot.a
+PLOT = /usr/lib/libplot.a -Dplot
+CFLAGS=-O
+prof:  prof.o
+       $(CC) -o prof prof.o $(PLOT)
+
+install:
+       install -s prof $(DESTDIR)/usr/bin
+
+clean :
+       rm -f *.o
diff --git a/usr/src/cmd/prof/prof.c b/usr/src/cmd/prof/prof.c
new file mode 100644 (file)
index 0000000..519c1ec
--- /dev/null
@@ -0,0 +1,321 @@
+/*
+ *  Print execution profile
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <a.out.h>
+
+typedef        short UNIT;             /* unit of profiling */
+
+struct stat stbuf;
+struct nl {
+       char    name[8];
+       unsigned value;
+       float   time;
+       long    ncall;
+};
+
+struct hdr {
+       short   *lowpc;
+       short   *highpc;
+       int     ncount;
+};
+
+struct nl nl[600];
+
+struct cnt {
+       unsigned cvalue;
+       long    cncall;
+} cbuf[350];
+
+FILE   *pfile, *nfile;
+unsigned highpc;
+unsigned lowpc;
+double ransca;
+double ranoff;
+int    pcl;
+int    pch;
+unsigned       bufs;
+int    nname;
+double time;
+double actime;
+double totime;
+double maxtime;
+double scale;
+double lastx;
+double lasty;
+struct nl *np;
+struct nl *npe;
+int    aflg;
+int    vflg;
+int    lflg;
+long   symoff;
+
+main(argc, argv)
+char **argv;
+{
+       char *namfil;
+       int timcmp(), valcmp(), cntcmp();
+       int i, overlap;
+       long pfpos;
+       double lastsx;
+       struct cnt *cp;
+       double tx, ty;
+       struct exec xbuf;
+       struct hdr {
+               UNIT    *lowpc;
+               UNIT    *highpc;
+               int     ncount;
+       } h;
+
+       lowpc = -1;
+       highpc = -1;
+       argv++;
+       namfil = "a.out";
+       while (argc>1) {
+               if (**argv == '-') {
+                       if (*++*argv == 'l')
+                               lflg++;
+                       if (**argv == 'a')
+                               aflg = 040;
+                       if(**argv == 'v')
+                               vflg++;
+                       if(**argv >= '0' && **argv <= '9') {
+                               i = atoi(*argv);
+                               if(lowpc == -1)
+                                       lowpc = i;
+                               else
+                                       highpc = i;
+                       }
+               } else
+                       namfil = *argv;
+               argc--;
+               argv++;
+       }
+       if (lowpc >= 100)
+               lowpc = 0;
+       if(highpc <= lowpc || highpc > 100)
+               highpc = 100;
+       ransca = 100./(highpc-lowpc);
+       ranoff = 2040. + 40.8*lowpc*ransca;
+       if((nfile=fopen(namfil,"r"))==NULL) {
+               fprintf(stderr, "%s: not found\n", namfil);
+               done();
+       }
+       fread(&xbuf, 1, sizeof(xbuf), nfile);
+       if (xbuf.a_magic!=A_MAGIC1 && xbuf.a_magic!=A_MAGIC2 && xbuf.a_magic!=A_MAGIC3) {
+               fprintf(stderr, "%s: bad format\n", namfil);
+               done();
+       }
+       symoff = (long)xbuf.a_text + xbuf.a_data + xbuf.a_trsize + xbuf.a_drsize;
+       fseek(nfile, symoff+sizeof(xbuf), 0);
+       if((pfile = fopen("mon.out","r")) == NULL) {
+               fprintf(stderr, "No mon.out\n");
+               done();
+       }
+       fstat(fileno(pfile), &stbuf);
+       fread(&h, sizeof(struct hdr), 1, pfile);
+       lowpc = h.lowpc - (UNIT *)0;
+       highpc = h.highpc - (UNIT *)0;
+       bufs = stbuf.st_size - sizeof(struct hdr) - h.ncount*sizeof(struct cnt);
+       fread(cbuf, sizeof(struct cnt), h.ncount, pfile);
+       pfpos = ftell(pfile);
+       npe = nl;
+       for (nname = 0; xbuf.a_syms > 0; xbuf.a_syms -= sizeof(struct nlist)) {
+               struct nlist nbuf;
+               fread(&nbuf, sizeof(nbuf), 1, nfile);
+               if (nbuf.n_type!=N_TEXT && nbuf.n_type!=N_TEXT+N_EXT)
+                       continue;
+               if (aflg==0 && nbuf.n_type!=N_TEXT+N_EXT)
+                       continue;
+               npe->value = nbuf.n_value/sizeof(UNIT);
+               for (i=8; --i>=0;)
+                       npe->name[i] = nbuf.n_name[i];
+               npe++;
+               nname++;
+       }
+       if (nname == 0) {
+               fprintf(stderr, "%s: no symbols\n", namfil);
+               done();
+       }
+       npe->value = -1;
+       npe++;
+       cp = &cbuf[h.ncount]; while ((--cp)->cvalue==0); ++cp; h.ncount=cp-cbuf;
+       for (;--cp>=cbuf;) cp->cvalue /= sizeof(UNIT);
+       qsort(cbuf, h.ncount, sizeof(struct cnt), cntcmp);
+       qsort(nl, nname, sizeof(struct nl), valcmp);
+       cp = &cbuf[h.ncount-1]; np = npe;
+       while (--np>=nl) {
+               if (cp<cbuf || np->value > cp->cvalue) continue;
+               while (cp>=cbuf && cp->cvalue - np->value >11) --cp;
+               if (cp->cvalue >= np->value) {np->ncall = cp->cncall; --cp;}
+       }
+       scale = highpc - lowpc;
+       scale /= bufs/sizeof(UNIT);
+       for(i=0;;i++) {
+               register j;
+               unsigned UNIT ccnt;
+               fread(&ccnt, sizeof(ccnt), 1, pfile);
+               if(feof(pfile))
+                       break;
+               if (ccnt == 0)
+                       continue;
+               pcl = lowpc + scale*i;
+               pch = lowpc + scale*(i+1);
+               time = ccnt;
+               totime += time;
+               if(time > maxtime)
+                       maxtime = time;
+               for (j=0; j<nname; j++) {
+                       if (pch < nl[j].value)
+                               break;
+                       if (pcl >= nl[j+1].value)
+                               continue;
+                       overlap=(min(pch,nl[j+1].value)-max(pcl,nl[j].value));
+                       if (overlap>0) nl[j].time += overlap*time/scale;
+               }
+       }
+       if (totime==0.0) {
+               fprintf(stderr, "No time accumulated\n");
+/*
+               done();
+ */
+               totime=1.0;
+       }
+#ifdef plot
+       if(!vflg)
+               goto print;
+       openpl();
+       erase();
+       space(-2048, -2048, 2048, 2048);
+       line(-2040, -2040, -2040, 2040);
+       line(0, 2040, 0, -2040);
+       for(i=0; i<11; i++)
+               line(-2040, 2040-i*408, 0, 2040-i*408);
+       lastx = 0.;
+       lasty = ranoff;
+       scale = (4080.*ransca)/(bufs/sizeof(UNIT));
+       fclose(pfile);  /*to turn off eof*/
+       pfile = fopen("mon.out", "r");
+       fseek(pfile, pfpos, 0);
+       lastsx = 0.0;
+       for(;;) {
+               unsigned UNIT ccnt;
+               fread(&ccnt, sizeof(ccnt), 1, pfile);
+               if(feof(pfile))
+                       break;
+               time = ccnt;
+               tx = lastsx;
+               ty = lasty;
+               lastsx =- 2000.*time/totime;
+               lasty =- scale;
+               if(lasty >= -2040. && ty <= 2040.) {
+                       line((int)tx, (int)ty, (int)lastsx, (int)lasty);
+                       if (ccnt!=0 || lastx!=0.0) {
+                               tx = lastx;
+                               lastx = -time*2000./maxtime;
+                               ty =+ scale/2;
+                               line(0, (int)ty, (int)tx, (int)ty);
+                       }
+               }
+       }
+       scale = (4080.*ransca)/(highpc-lowpc);
+       lastx = 50.;
+       for(np = nl; np<npe;  np++) {
+               if(np->value < lowpc)
+                       continue;
+               if(np->value >= highpc)
+                       continue;
+               time = np->time/totime;
+               lasty = ranoff - (np->value - lowpc)*scale;
+               if(lasty >= -2040. && lasty <= 2040.) {
+                       char bufl[8+3], *namp;
+                       register j;
+                       line(0, (int)lasty, 50, (int)lasty);
+                       line((int)(lastx-50),(int)lasty,(int)lastx,(int)lasty);
+                       point((int)(lastx+30), (int)(lasty+10));
+                       namp = bufl;
+                       for(j=0; j<8; j++)
+                               if(np->name[j] != '_')
+                                       *namp++ = np->name[j];
+                       *namp++ = '\n';
+                       *namp++ = 0;
+                       label(bufl);
+               }
+               lastx =+ 500.;
+               if(lastx > 2000.)
+                       lastx = 50.;
+       }
+       done();
+
+print:
+#endif
+       actime = 0;
+       printf("    name %%time  cumsecs  #call  ms/call\n");
+       if (!lflg)
+               qsort(nl, nname, sizeof(struct nl), timcmp);
+       for (np = nl; np<npe-1; np++) {
+               time = np->time/totime;
+               actime += np->time;
+               printf("%8.8s%6.1f%9.2f", np->name, 100*time, actime/60);
+               if(np->ncall!=0) {
+                       printf("%7ld", np->ncall);
+                       printf(" %8.2f\n", np->time/(np->ncall*.06));
+               } else
+                       printf("\n");
+       }
+       done();
+}
+
+min(a, b)
+{
+       if (a<b)
+               return(a);
+       return(b);
+}
+
+max(a, b)
+{
+       if (a>b)
+               return(a);
+       return(b);
+}
+
+valcmp(p1, p2)
+struct nl *p1, *p2;
+{
+       return(p1->value - p2->value);
+}
+
+timcmp(p1, p2)
+struct nl *p1, *p2;
+{
+       float d;
+
+       d = p2->time - p1->time;
+       if (d > 0.0)
+               return(1);
+       if (d < 0.0)
+               return(-1);
+       return(0);
+}
+
+cntcmp(p1, p2)
+struct cnt *p1, *p2;
+{
+       return(p1->cvalue - p2->cvalue);
+}
+
+done()
+{
+
+#ifdef plot
+       if(vflg) {
+               point(0, -2040);
+               closepl();
+       }
+#endif
+       exit(0);
+}
index a5e2bb7..815eff2 100644 (file)
@@ -5,7 +5,6 @@
 
 #include <stdio.h>
 #include <a.out.h>
 
 #include <stdio.h>
 #include <a.out.h>
-#include <core.h>
 #include <sys/param.h>
 #include <sys/proc.h>
 #include <sys/tty.h>
 #include <sys/param.h>
 #include <sys/proc.h>
 #include <sys/tty.h>
@@ -16,24 +15,25 @@ struct nlist nl[] = {
        { "_proc" },
        { "_swapdev" },
        { "_swplo" },
        { "_proc" },
        { "_swapdev" },
        { "_swplo" },
-       { "" },
+       { 0 },
 };
 
 struct proc mproc;
 
 };
 
 struct proc mproc;
 
-struct user u;
+union {
+       struct user yy;
+       int xx[128][UPAGES];
+      } zz;
+#define u zz.yy
 int    chkpid;
 int    retcode=1;
 int    lflg;
 int    chkpid;
 int    retcode=1;
 int    lflg;
-int    vflg;
 int    kflg;
 int    xflg;
 char   *tptr;
 int    kflg;
 int    xflg;
 char   *tptr;
-long   lseek();
 char   *gettty();
 char   *gettty();
-char   *getptr();
-char   *strncmp();
 int    aflg;
 int    aflg;
+int    pagetbl[128];
 int    mem;
 int    swmem;
 int    swap;
 int    mem;
 int    swmem;
 int    swap;
@@ -45,7 +45,7 @@ struct devl {
        dev_t   dev;
 } devl[256];
 
        dev_t   dev;
 } devl[256];
 
-char   *coref;
+char   *coref, *memf;
 
 main(argc, argv)
 char **argv;
 
 main(argc, argv)
 char **argv;
@@ -57,11 +57,6 @@ char **argv;
        if (argc>1) {
                ap = argv[1];
                while (*ap) switch (*ap++) {
        if (argc>1) {
                ap = argv[1];
                while (*ap) switch (*ap++) {
-
-               case 'v':
-                       vflg++;
-                       break;
-
                case 'a':
                        aflg++;
                        break;
                case 'a':
                        aflg++;
                        break;
@@ -72,7 +67,7 @@ char **argv;
                        aflg++;
                        if (*tptr == '?')
                                xflg++;
                        aflg++;
                        if (*tptr == '?')
                                xflg++;
-                       goto bbreak;
+                       break;
 
                case 'x':
                        xflg++;
 
                case 'x':
                        xflg++;
@@ -90,40 +85,48 @@ char **argv;
                        break;
 
                default:
                        break;
 
                default:
-                       chkpid = atoi(ap-1);
-                       goto bbreak;
+                       chkpid=atoi(--ap);
+                       *ap = '\0';
                        break;
                }
        }
 
                        break;
                }
        }
 
-bbreak:
        if(chdir("/dev") < 0) {
                fprintf(stderr, "Can't change to /dev\n");
        if(chdir("/dev") < 0) {
                fprintf(stderr, "Can't change to /dev\n");
-               exit(1);
+               done(1);
        }
        nlist(argc>2? argv[2]:"/unix", nl);
        if (nl[0].n_type==0) {
                fprintf(stderr, "No namelist\n");
        }
        nlist(argc>2? argv[2]:"/unix", nl);
        if (nl[0].n_type==0) {
                fprintf(stderr, "No namelist\n");
-               exit(1);
+               done(1);
        }
        }
-       coref = "/dev/mem";
-       if(kflg)
+       coref = "/dev/kmem";
+       memf = "/dev/mem";
+       if(kflg) {
                coref = "/usr/sys/core";
                coref = "/usr/sys/core";
+               memf = coref;
+               nl[0].n_value = (char *)((int)nl[0].n_value & 0x7fffffff);
+               nl[1].n_value = (char *)((int)nl[1].n_value & 0x7fffffff);
+               nl[2].n_value = (char *)((int)nl[2].n_value & 0x7fffffff);
+       }
        if ((mem = open(coref, 0)) < 0) {
        if ((mem = open(coref, 0)) < 0) {
+               fprintf(stderr, "No kmem\n");
+               done(1);
+       }
+       if((swmem = open(memf, 0)) < 0) {
                fprintf(stderr, "No mem\n");
                fprintf(stderr, "No mem\n");
-               exit(1);
+               done(1);
        }
        }
-       swmem = open(coref, 0);
        /*
         * read mem to find swap dev.
         */
        lseek(mem, (long)nl[1].n_value, 0);
        /*
         * read mem to find swap dev.
         */
        lseek(mem, (long)nl[1].n_value, 0);
-       read(mem, (char *)&nl[1].n_value, sizeof(nl[1].n_value));
+       read(mem, &nl[1].n_value, sizeof(nl[1].n_value));
        /*
         * Find base of swap
         */
        lseek(mem, (long)nl[2].n_value, 0);
        /*
         * Find base of swap
         */
        lseek(mem, (long)nl[2].n_value, 0);
-       read(mem, (char *)&swplo, sizeof(swplo));
+       read(mem, &swplo, sizeof(swplo));
        /*
         * Locate proc table
         */
        /*
         * Locate proc table
         */
@@ -131,10 +134,10 @@ bbreak:
        getdev();
        uid = getuid();
        if (lflg)
        getdev();
        uid = getuid();
        if (lflg)
-       printf(" F S UID   PID  PPID CPU PRI NICE  ADDR  SZ  WCHAN TTY TIME CMD\n"); else
-               if (chkpid==0) printf("   PID TTY TIME CMD\n");
+       printf("  F S UID   PID  PPID CPU PRI NICE   ADDR   SZ   WCHAN  TTY TIME COMMAND\n"); else
+               if (chkpid==0) printf("   PID TTY TIME COMMAND\n");
        for (i=0; i<NPROC; i++) {
        for (i=0; i<NPROC; i++) {
-               read(mem, (char *)&mproc, sizeof mproc);
+               read(mem, &mproc, sizeof mproc);
                if (mproc.p_stat==0)
                        continue;
                if (mproc.p_pgrp==0 && xflg==0 && mproc.p_uid==0)
                if (mproc.p_stat==0)
                        continue;
                if (mproc.p_pgrp==0 && xflg==0 && mproc.p_uid==0)
@@ -148,7 +151,7 @@ bbreak:
                        retcode=0;
                }
        }
                        retcode=0;
                }
        }
-       exit(retcode);
+       done(retcode);
 }
 
 getdev()
 }
 
 getdev()
@@ -160,10 +163,10 @@ getdev()
 
        if ((df = fopen("/dev", "r")) == NULL) {
                fprintf(stderr, "Can't open /dev\n");
 
        if ((df = fopen("/dev", "r")) == NULL) {
                fprintf(stderr, "Can't open /dev\n");
-               exit(1);
+               done(1);
        }
        ndev = 0;
        }
        ndev = 0;
-       while (fread((char *)&dbuf, sizeof(dbuf), 1, df) == 1) {
+       while (fread(&dbuf, sizeof(dbuf), 1, df) == 1) {
                if(dbuf.d_ino == 0)
                        continue;
                if(stat(dbuf.d_name, &sbuf) < 0)
                if(dbuf.d_ino == 0)
                        continue;
                if(stat(dbuf.d_name, &sbuf) < 0)
@@ -177,79 +180,50 @@ getdev()
        fclose(df);
        if ((swap = open("/dev/swap", 0)) < 0) {
                fprintf(stderr, "Can't open /dev/swap\n");
        fclose(df);
        if ((swap = open("/dev/swap", 0)) < 0) {
                fprintf(stderr, "Can't open /dev/swap\n");
-               exit(1);
+               done(1);
        }
 }
 
        }
 }
 
-long
-round(a, b)
-       long            a, b;
-{
-       long            w = ((a+b-1)/b)*b;
-
-       return(w);
-}
-
-struct map {
-       long    b1, e1; long f1;
-       long    b2, e2; long f2;
-};
-struct map datmap;
-int    file;
 prcom(puid)
 {
 prcom(puid)
 {
-       char abuf[512];
+       int abuf[128];
        long addr;
        long addr;
+       int mf;
        register int *ip;
        register char *cp, *cp1;
        long tm;
        int c, nbad;
        register char *tp;
        register int *ip;
        register char *cp, *cp1;
        long tm;
        int c, nbad;
        register char *tp;
-       long txtsiz, datsiz, stksiz;
-       int septxt;
-       int lw=(lflg?35:80);
-       char **ap;
 
 
-       if (mproc.p_flag&SLOAD) {
-               addr = ctob((long)mproc.p_addr);
-               file = swmem;
+       if ((mproc.p_flag& (SLOAD | SSPART)) == 0) {
+               addr = (mproc.p_swaddr+swplo)<<9;
+               mf = swap;
+               lseek(mf, addr, 0);
+               if (read(mf, &u, sizeof(u)) != sizeof(u))
+                       return(0);
        } else {
        } else {
-               addr = (mproc.p_addr+swplo)<<9;
-               file = swap;
+               for(c=0; c<UPAGES; c++) {
+                       lseek(swmem,mproc.p_addr[c]<<9,0);
+                       if (read(swmem,((int *)&u)+128*c,512) != 512)   /* get u page */
+                               return(0);
+               }
        }
        }
-       lseek(file, addr, 0);
-       if (read(file, (char *)&u, sizeof(u)) != sizeof(u))
-               return(0);
-
-       /* set up address maps for user pcs */
-       txtsiz = ctob(u.u_tsize);
-       datsiz = ctob(u.u_dsize);
-       stksiz = ctob(u.u_ssize);
-       septxt = u.u_sep;
-       datmap.b1 = (septxt ? 0 : round(txtsiz,TXTRNDSIZ));
-       datmap.e1 = datmap.b1+datsiz;
-       datmap.f1 = ctob(USIZE)+addr;
-       datmap.b2 = stackbas(stksiz);
-       datmap.e2 = stacktop(stksiz);
-       datmap.f2 = ctob(USIZE)+(datmap.e1-datmap.b1)+addr;
-
        tp = gettty();
        tp = gettty();
-       if (tptr && strncmp(tptr, tp, 2))
+       if (tptr && strcmpn(tptr, tp, 2))
                return(0);
        if (lflg) {
                return(0);
        if (lflg) {
-               printf("%2o %c%4d", mproc.p_flag,
+               printf("%3o %c%4d", 0377 & mproc.p_flag,
                        "0SWRIZT"[mproc.p_stat], puid);
        }
        printf("%6u", mproc.p_pid);
        if (lflg) {
                        "0SWRIZT"[mproc.p_stat], puid);
        }
        printf("%6u", mproc.p_pid);
        if (lflg) {
-               printf("%6u%4d%4d%5d%6o%4d", mproc.p_ppid, mproc.p_cpu&0377,
+               printf("%6u%4d%4d%5d%8x%4d", mproc.p_ppid, mproc.p_cpu&0377,
                        mproc.p_pri,
                        mproc.p_nice,
                        mproc.p_pri,
                        mproc.p_nice,
-                       mproc.p_addr, (mproc.p_size+7)>>3);
+                       mproc.p_addr[0], mproc.p_size);
                if (mproc.p_wchan)
                if (mproc.p_wchan)
-                       printf("%7o", mproc.p_wchan);
-               else
-                       printf("       ");
+                       printf("%9x", mproc.p_wchan); else
+                       printf("         ");
        }
        printf(" %-2.2s", tp);
        if (mproc.p_stat==SZOMB) {
        }
        printf(" %-2.2s", tp);
        if (mproc.p_stat==SZOMB) {
@@ -260,7 +234,7 @@ prcom(puid)
        printf(" %2ld:", tm/60);
        tm %= 60;
        printf(tm<10?"0%ld":"%ld", tm);
        printf(" %2ld:", tm/60);
        tm %= 60;
        printf(tm<10?"0%ld":"%ld", tm);
-       if (vflg && lflg==0) {  /* 0 == old tflg (print long times) */
+       if (0 && lflg==0) {     /* 0 == old tflg (print long times) */
                tm = (u.u_cstime + 30)/60;
                printf(" %2ld:", tm/60);
                tm %= 60;
                tm = (u.u_cstime + 30)/60;
                printf(" %2ld:", tm/60);
                tm %= 60;
@@ -274,42 +248,31 @@ prcom(puid)
                printf(" swapper");
                return(1);
        }
                printf(" swapper");
                return(1);
        }
-       addr += ctob((long)mproc.p_size) - 512;
-
-       /* look for sh special */
-       lseek(file, addr+512-sizeof(char **), 0);
-       if (read(file, (char *)&ap, sizeof(char *)) != sizeof(char *))
-               return(1);
-       if (ap) {
-               char b[82];
-               char *bp = b;
-               while((cp=getptr(ap++)) && cp && (bp<b+lw) ) {
-                       nbad = 0;
-                       while((c=getbyte(cp++)) && (bp<b+lw)) {
-                               if (c<' ' || c>'~') {
-                                       if (nbad++>3)
-                                               break;
-                                       continue;
-                               }
-                               *bp++ = c;
-                       }
-                       *bp++ = ' ';
-               }
-               *bp++ = 0;
-               printf(lflg?" %.30s":" %.60s", b);
-               return(1);
+       c = mproc.p_size - btoc(512);
+       if ((mproc.p_flag & SLOAD) == 0) {
+               addr += ctob(c);
+               lseek(mf, addr, 0);
+               if (read(mf, abuf, sizeof(abuf)) != sizeof(abuf))
+                       return(1);
+       } else {
+               if (u.u_pcb.pcb_szpt<1 || u.u_pcb.pcb_szpt>20)
+                       return(1);
+               c = ctob((u.u_ptable[u.u_pcb.pcb_szpt-1] & 0x1fffff));
+               lseek(swmem,c,0);
+               if (read(swmem,pagetbl,512) != 512)     /* get last page table */
+                       return(1);
+               lseek(swmem,ctob((pagetbl[127] & 0x1fffff)),0);
+               if (read(swmem,abuf,sizeof(abuf)) != sizeof(abuf))
+                       return(1);
        }
        }
-
-       lseek(file, addr, 0);
-       if (read(file, abuf, sizeof(abuf)) != sizeof(abuf))
-               return(1);
-       for (ip = (int *)&abuf[512]-2; ip > (int *)abuf; ) {
-               if (*--ip == -1 || *ip==0) {
+       abuf[128] = 0;
+       for (ip = &abuf[126]; ip > abuf;) {
+               if (*--ip == -1 || *ip == 0) {
                        cp = (char *)(ip+1);
                        if (*cp==0)
                                cp++;
                        nbad = 0;
                        cp = (char *)(ip+1);
                        if (*cp==0)
                                cp++;
                        nbad = 0;
-                       for (cp1 = cp; cp1 < &abuf[512]; cp1++) {
+                       for (cp1 = cp; cp1 < (char *)&abuf[128]; cp1++) {
                                c = *cp1&0177;
                                if (c==0)
                                        *cp1 = ' ';
                                c = *cp1&0177;
                                if (c==0)
                                        *cp1 = ' ';
@@ -354,47 +317,7 @@ gettty()
        return("?");
 }
 
        return("?");
 }
 
-char *
-getptr(adr)
-char **adr;
-{
-       char *ptr;
-       register char *p, *pa;
-       register i;
-
-       ptr = 0;
-       pa = (char *)adr;
-       p = (char *)&ptr;
-       for (i=0; i<sizeof(ptr); i++)
-               *p++ = getbyte(pa++);
-       return(ptr);
-}
-
-getbyte(adr)
-char *adr;
-{
-       register struct map *amap = &datmap;
-       char b;
-       long saddr;
-
-       if(!within(adr, amap->b1, amap->e1)) {
-               if(within(adr, amap->b2, amap->e2)) {
-                       saddr = (unsigned)adr + amap->f2 - amap->b2;
-               } else
-                       return(0);
-       } else
-               saddr = (unsigned)adr + amap->f1 - amap->b1;
-       if(lseek(file, saddr, 0)==-1
-                  || read(file, &b, 1)<1) {
-               return(0);
-       }
-       return((unsigned)b);
-}
-
-
-within(adr,lbd,ubd)
-char *adr;
-long lbd, ubd;
+done(exitno)
 {
 {
-       return((unsigned)adr>=lbd && (unsigned)adr<ubd);
+       exit(exitno);
 }
 }
diff --git a/usr/src/cmd/ps.slow.c b/usr/src/cmd/ps.slow.c
new file mode 100644 (file)
index 0000000..1d6bc77
--- /dev/null
@@ -0,0 +1,401 @@
+/*
+ *     ps - process status
+ *     examine and print certain things about processes
+ */
+
+#include <stdio.h>
+#include <a.out.h>
+#include <core.h>
+#include <sys/param.h>
+#include <sys/proc.h>
+#include <sys/tty.h>
+#include <sys/dir.h>
+#include <sys/user.h>
+
+struct nlist nl[] = {
+       { "_proc" },
+       { "_swapdev" },
+       { "_swplo" },
+       { 0 },
+};
+
+struct proc mproc;
+
+struct user u;
+int    chkpid;
+int    retcode=1;
+int    lflg;
+int    vflg;
+int    kflg;
+int    xflg;
+char   *tptr;
+long   lseek();
+char   *gettty();
+char   *getptr();
+char   *strcmpn();
+int    aflg;
+int    mem;
+int    swmem;
+int    swap;
+daddr_t        swplo;
+
+int    ndev;
+struct devl {
+       char    dname[DIRSIZ];
+       dev_t   dev;
+} devl[256];
+
+char   *coref;
+
+main(argc, argv)
+char **argv;
+{
+       int i;
+       char *ap;
+       int uid, puid;
+
+       if (argc>1) {
+               ap = argv[1];
+               while (*ap) switch (*ap++) {
+
+               case 'v':
+                       vflg++;
+                       break;
+
+               case 'a':
+                       aflg++;
+                       break;
+
+               case 't':
+                       if(*ap)
+                               tptr = ap;
+                       aflg++;
+                       if (*tptr == '?')
+                               xflg++;
+                       goto bbreak;
+
+               case 'x':
+                       xflg++;
+                       break;
+
+               case '-':
+                       break;
+
+               case 'l':
+                       lflg++;
+                       break;
+
+               case 'k':
+                       kflg++;
+                       break;
+
+               default:
+                       chkpid = atoi(ap-1);
+                       goto bbreak;
+                       break;
+               }
+       }
+
+bbreak:
+       if(chdir("/dev") < 0) {
+               fprintf(stderr, "Can't change to /dev\n");
+               exit(1);
+       }
+       nlist(argc>2? argv[2]:"/unix", nl);
+       if (nl[0].n_type==0) {
+               fprintf(stderr, "No namelist\n");
+               exit(1);
+       }
+       coref = "/dev/kmem";
+       if(kflg)
+               coref = "/usr/sys/core";
+       if ((mem = open(coref, 0)) < 0) {
+               fprintf(stderr, "No kmem\n");
+               exit(1);
+       }
+       if ((swmem = open("/dev/mem", 0)) < 0) {
+               fprintf(stderr, "No mem\n");
+               exit(1);
+       }
+       /*
+        * read mem to find swap dev.
+        */
+       lseek(mem, (long)nl[1].n_value, 0);
+       read(mem, (char *)&nl[1].n_value, sizeof(nl[1].n_value));
+       /*
+        * Find base of swap
+        */
+       lseek(mem, (long)nl[2].n_value, 0);
+       read(mem, (char *)&swplo, sizeof(swplo));
+       /*
+        * Locate proc table
+        */
+       lseek(mem, (long)nl[0].n_value, 0);
+       getdev();
+       uid = getuid();
+       if (lflg)
+       printf(" F S UID   PID  PPID CPU PRI NICE  ADDR  SZ  WCHAN   TTY TIME CMD\n"); else
+               if (chkpid==0) printf("   PID TTY TIME CMD\n");
+       for (i=0; i<NPROC; i++) {
+               read(mem, (char *)&mproc, sizeof mproc);
+               if (mproc.p_stat==0)
+                       continue;
+               if (mproc.p_pgrp==0 && xflg==0 && mproc.p_uid==0)
+                       continue;
+               puid = mproc.p_uid;
+               if ((uid != puid && aflg==0) ||
+                   (chkpid!=0 && chkpid!=mproc.p_pid))
+                       continue;
+               if(prcom(puid)) {
+                       printf("\n");
+                       retcode=0;
+               }
+       }
+       exit(retcode);
+}
+
+getdev()
+{
+#include <sys/stat.h>
+       register FILE *df;
+       struct stat sbuf;
+       struct direct dbuf;
+
+       if ((df = fopen("/dev", "r")) == NULL) {
+               fprintf(stderr, "Can't open /dev\n");
+               exit(1);
+       }
+       ndev = 0;
+       while (fread((char *)&dbuf, sizeof(dbuf), 1, df) == 1) {
+               if(dbuf.d_ino == 0)
+                       continue;
+               if(stat(dbuf.d_name, &sbuf) < 0)
+                       continue;
+               if ((sbuf.st_mode&S_IFMT) != S_IFCHR)
+                       continue;
+               strcpy(devl[ndev].dname, dbuf.d_name);
+               devl[ndev].dev = sbuf.st_rdev;
+               ndev++;
+       }
+       fclose(df);
+       if ((swap = open("/dev/swap", 0)) < 0) {
+               fprintf(stderr, "Can't open /dev/swap\n");
+               exit(1);
+       }
+}
+
+long
+round(a, b)
+       long            a, b;
+{
+       long            w = ((a+b-1)/b)*b;
+
+       return(w);
+}
+
+struct map {
+       long    b1, e1; long f1;
+       long    b2, e2; long f2;
+};
+struct map datmap;
+int    file;
+prcom(puid)
+{
+       char abuf[512];
+       long addr;
+       register int *ip;
+       register char *cp, *cp1;
+       long tm;
+       int c, nbad;
+       register char *tp;
+       long txtsiz, datsiz, stksiz;
+       int lw=(lflg?35:80);
+       char **ap;
+
+       if (mproc.p_flag&SLOAD) {
+               addr = ctob((long)mproc.p_addr);
+               file = swmem;
+       } else {
+               addr = (mproc.p_addr+swplo)<<9;
+               file = swap;
+       }
+       lseek(file, addr, 0);
+       if (read(file, (char *)&u, sizeof(u)) != sizeof(u))
+               return(0);
+
+       /* set up address maps for user pcs */
+       txtsiz = ctob(u.u_tsize);
+       datsiz = ctob(u.u_dsize);
+       stksiz = ctob(u.u_ssize);
+       datmap.b1 = round(txtsiz,TXTRNDSIZ);
+       datmap.e1 = datmap.b1+datsiz;
+       datmap.f1 = ctob(USIZE)+addr;
+       datmap.b2 = stackbas(stksiz);
+       datmap.e2 = stacktop(stksiz);
+       datmap.f2 = ctob(USIZE)+(datmap.e1-datmap.b1)+addr;
+
+       tp = gettty();
+       if (tptr && strcmpn(tptr, tp, 2))
+               return(0);
+       if (lflg) {
+               printf("%2o %c%4d", mproc.p_flag,
+                       "0SWRIZT"[mproc.p_stat], puid);
+       }
+       printf("%6u", mproc.p_pid);
+       if (lflg) {
+               printf("%6u%4d%4d%5d%6x%4d", mproc.p_ppid, mproc.p_cpu&0377,
+                       mproc.p_pri,
+                       mproc.p_nice,
+                       mproc.p_addr, mproc.p_size);
+               if (mproc.p_wchan)
+                       printf("%9x", mproc.p_wchan);
+               else
+                       printf("         ");
+       }
+       printf(" %-2.2s", tp);
+       if (mproc.p_stat==SZOMB) {
+               printf("  <defunct>");
+               return(1);
+       }
+       tm = (u.u_utime + u.u_stime + 30)/60;
+       printf(" %2ld:", tm/60);
+       tm %= 60;
+       printf(tm<10?"0%ld":"%ld", tm);
+       if (vflg && lflg==0) {  /* 0 == old tflg (print long times) */
+               tm = (u.u_cstime + 30)/60;
+               printf(" %2ld:", tm/60);
+               tm %= 60;
+               printf(tm<10?"0%ld":"%ld", tm);
+               tm = (u.u_cutime + 30)/60;
+               printf(" %2ld:", tm/60);
+               tm %= 60;
+               printf(tm<10?"0%ld":"%ld", tm);
+       }
+       if (mproc.p_pid == 0) {
+               printf(" swapper");
+               return(1);
+       }
+       addr += ctob((long)mproc.p_size) - 512;
+
+       /* look for sh special */
+       lseek(file, addr+512-sizeof(char **), 0);
+       if (read(file, (char *)&ap, sizeof(char *)) != sizeof(char *))
+               return(1);
+       if (ap) {
+               char b[82];
+               char *bp = b;
+               while((cp=getptr(ap++)) && cp && (bp<b+lw) ) {
+                       nbad = 0;
+                       while((c=getbyte(cp++)) && (bp<b+lw)) {
+                               if (c<' ' || c>'~') {
+                                       if (nbad++>3)
+                                               break;
+                                       continue;
+                               }
+                               *bp++ = c;
+                       }
+                       *bp++ = ' ';
+               }
+               *bp++ = 0;
+               printf(lflg?" %.30s":" %.60s", b);
+               return(1);
+       }
+
+       lseek(file, addr, 0);
+       if (read(file, abuf, sizeof(abuf)) != sizeof(abuf))
+               return(1);
+       for (ip = (int *)&abuf[512]-2; ip > (int *)abuf; ) {
+               if (*--ip == -1 || *ip==0) {
+                       cp = (char *)(ip+1);
+                       if (*cp==0)
+                               cp++;
+                       nbad = 0;
+                       for (cp1 = cp; cp1 < &abuf[512]; cp1++) {
+                               c = *cp1&0177;
+                               if (c==0)
+                                       *cp1 = ' ';
+                               else if (c < ' ' || c > 0176) {
+                                       if (++nbad >= 5) {
+                                               *cp1++ = ' ';
+                                               break;
+                                       }
+                                       *cp1 = '?';
+                               } else if (c=='=') {
+                                       *cp1 = 0;
+                                       while (cp1>cp && *--cp1!=' ')
+                                               *cp1 = 0;
+                                       break;
+                               }
+                       }
+                       while (*--cp1==' ')
+                               *cp1 = 0;
+                       printf(lflg?" %.30s":" %.60s", cp);
+                       return(1);
+               }
+       }
+       return(1);
+}
+
+char *
+gettty()
+{
+       register i;
+       register char *p;
+
+       if (u.u_ttyp==0)
+               return("?");
+       for (i=0; i<ndev; i++) {
+               if (devl[i].dev == u.u_ttyd) {
+                       p = devl[i].dname;
+                       if (p[0]=='t' && p[1]=='t' && p[2]=='y')
+                               p += 3;
+                       return(p);
+               }
+       }
+       return("?");
+}
+
+char *
+getptr(adr)
+char **adr;
+{
+       char *ptr;
+       register char *p, *pa;
+       register i;
+
+       ptr = 0;
+       pa = (char *)adr;
+       p = (char *)&ptr;
+       for (i=0; i<sizeof(ptr); i++)
+               *p++ = getbyte(pa++);
+       return(ptr);
+}
+
+getbyte(adr)
+char *adr;
+{
+       register struct map *amap = &datmap;
+       char b;
+       long saddr;
+
+       if(!within(adr, amap->b1, amap->e1)) {
+               if(within(adr, amap->b2, amap->e2)) {
+                       saddr = (unsigned)adr + amap->f2 - amap->b2;
+               } else
+                       return(0);
+       } else
+               saddr = (unsigned)adr + amap->f1 - amap->b1;
+       if(lseek(file, saddr, 0)==-1
+                  || read(file, &b, 1)<1) {
+               return(0);
+       }
+       return((unsigned)b);
+}
+
+
+within(adr,lbd,ubd)
+char *adr;
+long lbd, ubd;
+{
+       return((unsigned)adr>=lbd && (unsigned)adr<ubd);
+}
index 17a7474..4a65cb9 100644 (file)
@@ -7,7 +7,7 @@
 #include <sys/conf.h>
 #include <sys/tty.h>
 
 #include <sys/conf.h>
 #include <sys/tty.h>
 
-char   *fcore  = "/dev/mem";
+char   *fcore  = "/dev/kmem";
 char   *fnlist = "/unix";
 int    fc;
 
 char   *fnlist = "/unix";
 int    fc;
 
@@ -22,14 +22,24 @@ struct setup {
        "_text", 0, 0,
 #define        SPROC   2
        "_proc", 0, 0,
        "_text", 0, 0,
 #define        SPROC   2
        "_proc", 0, 0,
-#define        SDH     3
-       "_dh11", 0, 0,
-#define        SNDH    4
-       "_ndh11", 0, 0,
+#define        SDZ     3
+       "_dz_tty", 0, 0,
+#define        SNDZ    4
+       "_dz_cnt", 0, 0,
 #define        SKL     5
 #define        SKL     5
-       "_kl11", 0, 0,
+       "_cons", 0, 0,
 #define        SFIL    6
        "_file", 0, 0,
 #define        SFIL    6
        "_file", 0, 0,
+#define        SMPXC   7
+       "_mpx_chan", 0, 0,
+#define        SMPXM   8
+       "_mpx_mach", 0, 0,
+#define        SMPXB1  9
+       "_mptbc", 0, 0,
+#define        SMPXB2  10
+       "_mptbuf", 0, 0,
+#define        SMPSM   11
+       "_mpsm", 0, 0,
        0,
 };
 
        0,
 };
 
@@ -37,10 +47,15 @@ int inof;
 int    txtf;
 int    prcf;
 int    ttyf;
 int    txtf;
 int    prcf;
 int    ttyf;
+int    mpxf;
 int    usrf;
 long   ubase;
 int    filf;
 int    usrf;
 long   ubase;
 int    filf;
+char   partab[1];
+struct cdevsw  cdevsw[1];
+struct bdevsw  bdevsw[1];
 int    allflg;
 int    allflg;
+int    kflg;
 
 main(argc, argv)
 char **argv;
 
 main(argc, argv)
 char **argv;
@@ -58,6 +73,10 @@ char **argv;
                        inof++;
                        break;
 
                        inof++;
                        break;
 
+               case 'k':
+                       kflg++;
+                       break;
+
                case 'x':
                        txtf++;
                        break;
                case 'x':
                        txtf++;
                        break;
@@ -69,11 +88,16 @@ char **argv;
                        ttyf++;
                        break;
 
                        ttyf++;
                        break;
 
+               case 'm':
+                       mpxf++;
+                       break;
+
                case 'u':
                case 'u':
+                       printf("pstat: -u not implemented\n");
                        if (--argc == 0)
                                break;
                        usrf++;
                        if (--argc == 0)
                                break;
                        usrf++;
-                       ubase = oatoi(*++argv);
+                       sscanf( *++argv, "%x", &ubase);
                        break;
 
                case 'f':
                        break;
 
                case 'f':
@@ -90,6 +114,12 @@ char **argv;
        if (argc>1)
                fnlist = argv[1];
        nlist(fnlist, setup);
        if (argc>1)
                fnlist = argv[1];
        nlist(fnlist, setup);
+       if (kflg) {
+               register struct setup *sp;
+
+               for (sp=setup; sp->value; sp++)
+                       sp->value &= 0x7fffffff;
+       }
        if (setup[SINODE].type == -1) {
                printf("no namelist\n");
                exit(1);
        if (setup[SINODE].type == -1) {
                printf("no namelist\n");
                exit(1);
@@ -102,10 +132,16 @@ char **argv;
                dotty();
        if (prcf)
                doproc();
                dotty();
        if (prcf)
                doproc();
+/*
        if (usrf)
                dousr();
        if (usrf)
                dousr();
+ */
        if (filf)
                dofil();
        if (filf)
                dofil();
+/*
+       if(mpxf)
+               dompx();
+*/
 }
 
 doinode()
 }
 
 doinode()
@@ -117,17 +153,17 @@ doinode()
 
        nin = 0;
        lseek(fc, (long)setup[SINODE].value, 0);
 
        nin = 0;
        lseek(fc, (long)setup[SINODE].value, 0);
-       read(fc, (char *)xinode, sizeof(xinode));
+       read(fc, xinode, sizeof(xinode));
        for (ip = xinode; ip < &xinode[NINODE]; ip++)
                if (ip->i_count)
                        nin++;
        for (ip = xinode; ip < &xinode[NINODE]; ip++)
                if (ip->i_count)
                        nin++;
-       printf("%d active inodes\n", nin);
-       printf("   LOC  FLAGS  CNT DEVICE   INO   MODE NLK UID  SIZE/DEV\n");
+       printf("%d active xinodes\n", nin);
+       printf("   LOC    FLAGS  CNT DEVICE  INO  MODE  NLK UID   SIZE/DEV\n");
        loc = setup[SINODE].value;
        for (ip = xinode; ip < &xinode[NINODE]; ip++, loc += sizeof(xinode[0])) {
                if (ip->i_count == 0)
                        continue;
        loc = setup[SINODE].value;
        for (ip = xinode; ip < &xinode[NINODE]; ip++, loc += sizeof(xinode[0])) {
                if (ip->i_count == 0)
                        continue;
-               printf("%7.1o ", loc);
+               printf("%8.1x ", loc);
                putf(ip->i_flag&ILOCK, 'L');
                putf(ip->i_flag&IUPD, 'U');
                putf(ip->i_flag&IACC, 'A');
                putf(ip->i_flag&ILOCK, 'L');
                putf(ip->i_flag&IUPD, 'U');
                putf(ip->i_flag&IACC, 'A');
@@ -135,9 +171,9 @@ doinode()
                putf(ip->i_flag&IWANT, 'W');
                putf(ip->i_flag&ITEXT, 'T');
                printf("%4d", ip->i_count&0377);
                putf(ip->i_flag&IWANT, 'W');
                putf(ip->i_flag&ITEXT, 'T');
                printf("%4d", ip->i_count&0377);
-               printf("%3d,%3d", major(ip->i_dev), minor(ip->i_dev));
-               printf("%6l", ip->i_number);
-               printf("%7o", ip->i_mode);
+               printf("%4d,%3d", major(ip->i_dev), minor(ip->i_dev));
+               printf("%5l", ip->i_number);
+               printf("%6x", ip->i_mode & 0xffff);
                printf("%4d", ip->i_nlink);
                printf("%4d", ip->i_uid);
                if ((ip->i_mode&IFMT)==IFBLK || (ip->i_mode&IFMT)==IFCHR)
                printf("%4d", ip->i_nlink);
                printf("%4d", ip->i_uid);
                if ((ip->i_mode&IFMT)==IFBLK || (ip->i_mode&IFMT)==IFCHR)
@@ -159,24 +195,23 @@ putf(v, n)
 dotext()
 {
 #include <sys/text.h>
 dotext()
 {
 #include <sys/text.h>
-       register struct text *xp;
-       struct text xtext[NTEXT];
+       struct text xtext[NTEXT], *xp;
        register loc;
        int ntx;
 
        ntx = 0;
        lseek(fc, (long)setup[STEXT].value, 0);
        register loc;
        int ntx;
 
        ntx = 0;
        lseek(fc, (long)setup[STEXT].value, 0);
-       read(fc, (char *)xtext, sizeof(xtext));
+       read(fc, xtext, sizeof(xtext));
        for (xp = xtext; xp < &xtext[NTEXT]; xp++)
                if (xp->x_iptr!=NULL)
                        ntx++;
        printf("%d text segments\n", ntx);
        for (xp = xtext; xp < &xtext[NTEXT]; xp++)
                if (xp->x_iptr!=NULL)
                        ntx++;
        printf("%d text segments\n", ntx);
-       printf("   LOC FLAGS DADDR  CADDR SIZE   IPTR  CNT CCNT\n");
+       printf("   LOC   FLAGS  DADDR   CADDR   SIZE   ITPR    CNT CCNT\n");
        loc = setup[STEXT].value;
        for (xp = xtext; xp < &xtext[NTEXT]; xp++, loc+=sizeof(xtext[0])) {
                if (xp->x_iptr == NULL)
                        continue;
        loc = setup[STEXT].value;
        for (xp = xtext; xp < &xtext[NTEXT]; xp++, loc+=sizeof(xtext[0])) {
                if (xp->x_iptr == NULL)
                        continue;
-               printf("%7.1o", loc);
+               printf("%8.1x", loc);
                printf(" ");
                putf(xp->x_flag&XTRC, 'T');
                putf(xp->x_flag&XWRIT, 'W');
                printf(" ");
                putf(xp->x_flag&XTRC, 'T');
                putf(xp->x_flag&XWRIT, 'W');
@@ -184,10 +219,10 @@ dotext()
                putf(xp->x_flag&XLOCK, 'K');
                putf(xp->x_flag&XWANT, 'w');
                printf("%5u", xp->x_daddr);
                putf(xp->x_flag&XLOCK, 'K');
                putf(xp->x_flag&XWANT, 'w');
                printf("%5u", xp->x_daddr);
-               printf("%7.1o", xp->x_caddr);
+               printf("%11x", xp->x_caddr);
                printf("%5d", xp->x_size);
                printf("%5d", xp->x_size);
-               printf("%8.1o", xp->x_iptr);
-               printf("%4d", xp->x_count&0377);
+               printf("%10.1x", xp->x_iptr);
+               printf("%5d", xp->x_count&0377);
                printf("%4d", xp->x_ccount);
                printf("\n");
        }
                printf("%4d", xp->x_ccount);
                printf("\n");
        }
@@ -201,74 +236,73 @@ doproc()
        register loc, np;
 
        lseek(fc, (long)setup[SPROC].value, 0);
        register loc, np;
 
        lseek(fc, (long)setup[SPROC].value, 0);
-       read(fc, (char *)xproc, sizeof(xproc));
+       read(fc, xproc, sizeof(xproc));
        np = 0;
        for (pp=xproc; pp < &xproc[NPROC]; pp++)
                if (pp->p_stat)
                        np++;
        printf("%d processes\n", np);
        np = 0;
        for (pp=xproc; pp < &xproc[NPROC]; pp++)
                if (pp->p_stat)
                        np++;
        printf("%d processes\n", np);
-       printf("   LOC S  F  PRI SIGNAL UID TIM CPU NI  PGRP   PID  PPID ADDR SIZE  WCHAN   LINK  TEXTP  CLKT\n");
+       printf("   LOC   S  F   PRI SIGNAL UID TIM CPU NI   PGRP  PID  PPID   ADDR  SIZE  WCHAN      LINK    TEXTP  CLKT\n");
        for (loc=setup[SPROC].value,pp=xproc; pp<&xproc[NPROC]; pp++,loc+=sizeof(xproc[0])) {
                if (pp->p_stat==0 && allflg==0)
                        continue;
        for (loc=setup[SPROC].value,pp=xproc; pp<&xproc[NPROC]; pp++,loc+=sizeof(xproc[0])) {
                if (pp->p_stat==0 && allflg==0)
                        continue;
-               printf("%6o", loc);
+               printf("%8x", loc);
                printf("%2d", pp->p_stat);
                printf("%2d", pp->p_stat);
-               printf("%3o", pp->p_flag);
+               printf("%3o", pp->p_flag&0377);
                printf("%5d", pp->p_pri);
                printf("%7o", pp->p_sig);
                printf("%4d", pp->p_uid&0377);
                printf("%5d", pp->p_pri);
                printf("%7o", pp->p_sig);
                printf("%4d", pp->p_uid&0377);
-               printf("%4d", pp->p_time&0377);
+               printf("%5d", pp->p_time&0377);
                printf("%4d", pp->p_cpu&0377);
                printf("%3d", pp->p_nice);
                printf("%6d", pp->p_pgrp);
                printf("%6d", pp->p_pid);
                printf("%6d", pp->p_ppid);
                printf("%4d", pp->p_cpu&0377);
                printf("%3d", pp->p_nice);
                printf("%6d", pp->p_pgrp);
                printf("%6d", pp->p_pid);
                printf("%6d", pp->p_ppid);
-               printf("%5o", pp->p_addr);
-               printf("%5o", pp->p_size);
-               printf("%7o", pp->p_wchan);
-               printf("%7o", pp->p_link);
-               printf("%7o", pp->p_textp);
-               printf(" %u", pp->p_clktim);
+               printf("%8x", pp->p_addr[0]);
+               printf("%5x", pp->p_size);
+               printf("%9x", pp->p_wchan);
+               printf("%9x", pp->p_link);
+               printf("%9x", pp->p_textp);
+               printf("   %u", pp->p_clktim);
                printf("\n");
        }
 }
 
 dotty()
 {
                printf("\n");
        }
 }
 
 dotty()
 {
-       struct tty dh11[48];
-       int ndh;
+       struct tty dz_tty[32];
+       int ndz;
        register struct tty *tp;
        register char *mesg;
 
        register struct tty *tp;
        register char *mesg;
 
-       printf("1 kl11\n");
+       printf("1 cons\n");
        lseek(fc, (long)setup[SKL].value, 0);
        lseek(fc, (long)setup[SKL].value, 0);
-       read(fc, (char *)dh11, sizeof(dh11[0]));
-       mesg = " # RAW CAN OUT   MODE   ADDR   DEL COL  STATE   PGRP\n";
+       read(fc, dz_tty, sizeof(dz_tty[0]));
+       mesg = " RAW CAN OUT   MODE    ADDR   DEL COL  STATE   PGRP\n";
        printf(mesg);
        printf(mesg);
-       ttyprt(0, &dh11[0]);
-       if (setup[SNDH].type == -1)
+       ttyprt(&dz_tty[0]);
+       if (setup[SNDZ].type == -1)
                return;
                return;
-       lseek(fc, (long)setup[SNDH].value, 0);
-       read(fc, (char *)&ndh, sizeof(ndh));
-       printf("%d dh lines\n", ndh);
-       lseek(fc, (long)setup[SDH].value, 0);
-       read(fc, (char *)dh11, sizeof(dh11));
-       for (tp = dh11; tp < &dh11[ndh]; tp++)
-               ttyprt(tp-dh11, tp);
+       lseek(fc, (long)setup[SNDZ].value, 0);
+       read(fc, &ndz, sizeof(ndz));
+       printf("%d dz lines\n", ndz);
+       lseek(fc, (long)setup[SDZ].value, 0);
+       read(fc, dz_tty, sizeof(dz_tty));
+       for (tp = dz_tty; tp < &dz_tty[ndz]; tp++)
+               ttyprt(tp);
 }
 
 }
 
-ttyprt(n, atp)
+ttyprt(atp)
 struct tty *atp;
 {
        register struct tty *tp;
 
        tp = atp;
 struct tty *atp;
 {
        register struct tty *tp;
 
        tp = atp;
-       printf("%2d", n);
        printf("%4d", tp->t_rawq.c_cc);
        printf("%4d", tp->t_canq.c_cc);
        printf("%4d", tp->t_outq.c_cc);
        printf("%8.1o", tp->t_flags);
        printf("%4d", tp->t_rawq.c_cc);
        printf("%4d", tp->t_canq.c_cc);
        printf("%4d", tp->t_outq.c_cc);
        printf("%8.1o", tp->t_flags);
-       printf("%8.1o", tp->t_addr);
+       printf(" %8.1x", tp->t_addr);
        printf("%3d", tp->t_delct);
        printf("%4d ", tp->t_col);
        putf(tp->t_state&TIMEOUT, 'T');
        printf("%3d", tp->t_delct);
        printf("%4d ", tp->t_col);
        putf(tp->t_state&TIMEOUT, 'T');
@@ -278,7 +312,9 @@ struct tty *atp;
        putf(tp->t_state&BUSY, 'B');
        putf(tp->t_state&ASLEEP, 'A');
        putf(tp->t_state&XCLUDE, 'X');
        putf(tp->t_state&BUSY, 'B');
        putf(tp->t_state&ASLEEP, 'A');
        putf(tp->t_state&XCLUDE, 'X');
+/*
        putf(tp->t_state&HUPCLS, 'H');
        putf(tp->t_state&HUPCLS, 'H');
+ */
        printf("%6d", tp->t_pgrp);
        printf("\n");
 }
        printf("%6d", tp->t_pgrp);
        printf("\n");
 }
@@ -287,69 +323,79 @@ dousr()
 {
 #include <sys/dir.h>
 #include <sys/user.h>
 {
 #include <sys/dir.h>
 #include <sys/user.h>
-       union {
-               struct  user rxu;
-               char    fxu[ctob(USIZE)];
-       } xu;
-       register struct user *up;
-       register i;
-
-       lseek(fc, ubase<<6, 0);
-       read(fc, (char *)&xu, sizeof(xu));
-       up = &xu.rxu;
-       printf("rsav %.1o %.1o\n", up->u_rsav[0], up->u_rsav[1]);
-       printf("segflg, error %d, %d\n", up->u_segflg, up->u_error);
-       printf("uids %d,%d,%d,%d\n", up->u_uid,up->u_gid,up->u_ruid,up->u_rgid);
-       printf("procp %.1o\n", up->u_procp);
-       printf("base, count, offset %.1o %.1o %ld\n", up->u_base,
-               up->u_count, up->u_offset);
-       printf("cdir %.1o\n", up->u_cdir);
-       printf("dbuf %.14s\n", up->u_dbuf);
-       printf("dirp %.1o\n", up->u_dirp);
-       printf("dent %d %.14s\n", up->u_dent.d_ino, up->u_dent.d_name);
-       printf("pdir %.1o\n", up->u_pdir);
+       struct user U;
+       register i, j, *ip;
+
+       lseek(fc, ubase, 0);
+       read(fc, &U, sizeof(U));
+/*
+       printf("rsav %.1o %.1o\n", U.u_rsav[0], U.u_rsav[1]);
+ */
+       printf("segflg, error %d, %d\n", U.u_segflg, U.u_error);
+       printf("uids %d,%d,%d,%d\n", U.u_uid,U.u_gid,U.u_ruid,U.u_rgid);
+       printf("procp %.1x\n", U.u_procp);
+       printf("base, count, offset %.1x %.1x %ld\n", U.u_base,
+               U.u_count, U.u_offset);
+       printf("cdir %.1x\n", U.u_cdir);
+       printf("dbuf %.14s\n", U.u_dbuf);
+       printf("dirp %.1x\n", U.u_dirp);
+       printf("dent %d %.14s\n", U.u_dent.d_ino, U.u_dent.d_name);
+       printf("pdir %.1o\n", U.u_pdir);
+/*
        printf("dseg");
        for (i=0; i<8; i++)
        printf("dseg");
        for (i=0; i<8; i++)
-               printf("%8.1o", up->u_uisa[i]);
+               printf("%8.1o", U.u_uisa[i]);
        printf("\n    ");
        for (i=0; i<8; i++)
        printf("\n    ");
        for (i=0; i<8; i++)
-               printf("%8.1o", up->u_uisd[i]);
-       if (up->u_sep) {
+               printf("%8.1o", U.u_uisd[i]);
+       if (U.u_sep) {
                printf("\ntseg");
                for (i=8; i<16; i++)
                printf("\ntseg");
                for (i=8; i<16; i++)
-                       printf("%8.1o", up->u_uisa[i]);
+                       printf("%8.1o", U.u_uisa[i]);
                printf("\n    ");
                for (i=8; i<16; i++)
                printf("\n    ");
                for (i=8; i<16; i++)
-                       printf("%8.1o", up->u_uisd[i]);
+                       printf("%8.1o", U.u_uisd[i]);
        }
        }
+ */
        printf("\nfile");
        for (i=0; i<10; i++)
        printf("\nfile");
        for (i=0; i<10; i++)
-               printf("%8.1o", up->u_ofile[i]);
+               printf("%9.1x", U.u_ofile[i]);
        printf("\n    ");
        for (i=10; i<NOFILE; i++)
        printf("\n    ");
        for (i=10; i<NOFILE; i++)
-               printf("%8.1o", up->u_ofile[i]);
+               printf("%9.1x", U.u_ofile[i]);
        printf("\nargs");
        for (i=0; i<5; i++)
        printf("\nargs");
        for (i=0; i<5; i++)
-               printf(" %.1o", up->u_arg[i]);
-       printf("\nsizes %.1o %.1o %.1o\n", up->u_tsize, up->u_dsize, up->u_ssize);
-       printf("sep %d\n", up->u_sep);
-       printf("qsav %.1o %.1o\n", up->u_qsav[0], up->u_qsav[1]);
-       printf("ssav %.1o %.1o\n", up->u_ssav[0], up->u_ssav[1]);
+               printf(" %.1x", U.u_arg[i]);
+       printf("\nsizes %.1x %.1x %.1x\n", U.u_tsize, U.u_dsize, U.u_ssize);
+       printf("sep %d\n", U.u_sep);
+       printf("qsav %.1x %.1x\n", U.u_qsav[0], U.u_qsav[1]);
+       printf("ssav %.1x %.1x\n", U.u_ssav[0], U.u_ssav[1]);
        printf("sigs");
        for (i=0; i<NSIG; i++)
        printf("sigs");
        for (i=0; i<NSIG; i++)
-               printf(" %.1o", up->u_signal[i]);
-       printf("\ntimes %ld %ld\n", up->u_utime/60, up->u_stime/60);
-       printf("ctimes %ld %ld\n", up->u_cutime/60, up->u_cstime/60);
-       printf("ar0 %.1o\n", up->u_ar0);
+               printf(" %.1x", U.u_signal[i]);
+       printf("\ntimes %ld %ld\n", U.u_utime/60, U.u_stime/60);
+       printf("ctimes %ld %ld\n", U.u_cutime/60, U.u_cstime/60);
+       printf("ar0 %.1x\n", U.u_ar0);
 /*
        printf("prof");
        for (i=0; i<4; i++)
 /*
        printf("prof");
        for (i=0; i<4; i++)
-               printf(" %.1o", up->u_prof[i]);
+               printf(" %.1o", U.u_prof[i]);
+*/
+       printf("\nintflg %d\n", U.u_intflg);
+       printf("ttyp %.1x\n", U.u_ttyp);
+       printf("ttydev %d,%d\n", major(U.u_ttyd), minor(U.u_ttyd));
+       printf("comm %.14s\n", U.u_comm);
+/*
+       i =  U.u_stack - &U;
+       while (U[++i] == 0);
+       i &= ~07;
+       while (i < 512) {
+               printf("%x ", 0140000+2*i);
+               for (j=0; j<8; j++)
+                       printf("%9x", U[i++]);
+               printf("\n");
+       }
 */
 */
-       printf("\nintflg %d\n", up->u_intflg);
-       printf("ttyp %.1o\n", up->u_ttyp);
-       printf("ttydev %d,%d\n", major(up->u_ttyd), minor(up->u_ttyd));
-       printf("comm %.14s\n", up->u_comm);
 }
 
 oatoi(s)
 }
 
 oatoi(s)
@@ -373,21 +419,125 @@ dofil()
 
        nf = 0;
        lseek(fc, (long)setup[SFIL].value, 0);
 
        nf = 0;
        lseek(fc, (long)setup[SFIL].value, 0);
-       read(fc, (char *)xfile, sizeof(xfile));
+       read(fc, xfile, sizeof(xfile));
        for (fp=xfile; fp < &xfile[NFILE]; fp++)
                if (fp->f_count)
                        nf++;
        printf("%d open files\n", nf);
        for (fp=xfile; fp < &xfile[NFILE]; fp++)
                if (fp->f_count)
                        nf++;
        printf("%d open files\n", nf);
-       printf("  LOC   FLG CNT   INO    OFFS\n");
+       printf("   LOC   FLG  CNT   INO    OFFS\n");
        for (fp=xfile,loc=setup[SFIL].value; fp < &xfile[NFILE]; fp++,loc+=sizeof(xfile[0])) {
                if (fp->f_count==0)
                        continue;
        for (fp=xfile,loc=setup[SFIL].value; fp < &xfile[NFILE]; fp++,loc+=sizeof(xfile[0])) {
                if (fp->f_count==0)
                        continue;
-               printf("%7.1o ", loc);
+               printf("%8x ", loc);
                putf(fp->f_flag&FREAD, 'R');
                putf(fp->f_flag&FWRITE, 'W');
                putf(fp->f_flag&FPIPE, 'P');
                printf("%4d", mask(fp->f_count));
                putf(fp->f_flag&FREAD, 'R');
                putf(fp->f_flag&FWRITE, 'W');
                putf(fp->f_flag&FPIPE, 'P');
                printf("%4d", mask(fp->f_count));
-               printf("%8.1o", fp->f_inode);
-               printf(" %ld\n", fp->f_un.f_offset);
+               printf("%9.1x", fp->f_inode);
+               printf("  %ld\n", fp->f_un.f_offset);
+       }
+}
+
+/*********
+dompx()
+{
+#include <sys/mpx.h>
+       struct chan chan[C];
+       struct mach mach[M];
+       struct line line[M-1];
+       int mptbc;
+       char mptbuf[TBSIZ];
+       register struct chan *cp;
+       register struct mach *mp;
+       register struct line *lp;
+       int loc, nc;
+
+       lseek(fc, (long)setup[SMPXC].value, 0);
+       read(fc, chan, sizeof(chan));
+       lseek(fc, (long)setup[SMPXM].value, 0);
+       read(fc, mach, sizeof(mach));
+       lseek(fc, (long)setup[SMPXB1].value, 0);
+       read(fc, &mptbc, sizeof(mptbc));
+       lseek(fc, (long)setup[SMPXB2].value, 0);
+       read(fc, mptbuf, sizeof(mptbuf));
+       lseek(fc, (long)setup[SMPSM].value, 0);
+       read(fc, line, sizeof(line));
+       nc = 0;
+       for(cp=chan; cp < &chan[C]; cp++)
+               if(cp->cflag&ALLOC)
+                       nc++;
+       printf("%d mpx channels\n", nc);
+       printf("   LOC      FLG M   C    DEST\n");
+       for(cp=chan,loc=setup[SMPXC].value; cp < &chan[C]; cp++,loc=+sizeof(chan[0])) {
+               if((cp->cflag&ALLOC) == 0)
+                       continue;
+               printf("%7.1o ", loc);
+               putf(cp->cflag&BLOCK, 'B');
+               putf(cp->cflag&WWAIT, 'B');
+               putf(cp->cflag&CRUN, 'R');
+               putf(cp->cflag&RWAIT, 'W');
+               putf(cp->cflag&ALLOC, 'A');
+               putf(cp->cflag&DIS, 'D');
+               putf(cp->cflag&DLY, 'D');
+               printf(" %1d %3d ", mask(cp->m), mask(cp->c));
+               printf("%7.1o ", cp->dest);
+               printf("\n");
+       }
+
+       printf("%d mpx machines\n", M);
+       printf("   LOC  FLG RCH RCN XCH XCN\n");
+       for(mp=mach,loc=setup[SMPXM].value; mp < &mach[M]; mp++,loc=+sizeof(mach[0])) {
+               printf("%7.1o ", loc);
+               putf(mp->mflag&RNEXT, 'N');
+               putf(mp->mflag&MRUN, 'R');
+               putf(mp->mflag&XNEXT, 'N');
+               printf(" %3d", mask(mp->rchan));
+               printf(" %3d", mask(mp->rcount));
+               printf(" %3d", mask(mp->xchan));
+               printf(" %3d", mask(mp->xcount));
+               for(nc=0; nc<128; nc++) {
+                       cp = mp->chanp[nc];
+                       if(cp == 0)
+                               continue;
+                       printf(" %d-%o", nc, cp);
+               }
+               printf("\n");
+       }
+       printf("%d mpx lines\n", M-1);
+       printf("   LOC  RSQ XSQ AKF XMF STE TIM SUM\n");
+       for(lp=line,loc=setup[SMPSM].value; lp < &line[M-1]; lp++, loc =+ sizeof(line[0])) {
+               printf("%7.1o ", loc);
+               printf("%3o ", lp->rseq);
+               printf("%3o ", lp->xseq);
+               printf("%3o ", lp->ackf);
+               printf("%3o ", lp->xflag);
+               printf("%3d ", lp->state);
+               printf("%3d ", lp->time);
+               printf("%7o\n", lp->sum);
+       }
+       printf("last characters recieved\n");
+       nc = -1;
+       loc = mptbc;
+       for(;;) {
+               if(nc != mptbuf[loc]) {
+                       if(nc >= 0)
+                               printf(")\n");
+                       nc = mptbuf[loc];
+                       printf("%d(", nc);
+               } else
+                       printf(",");
+               loc++;
+               if(loc >= TBSIZ)
+                       loc = 0;
+               if(loc == mptbc)
+                       break;
+               printf("%o", mask(mptbuf[loc]));
+               loc++;
+               if(loc >= TBSIZ)
+                       loc = 0;
+               if(loc == mptbc)
+                       break;
        }
        }
+       printf(")\n");
 }
 }
+*********/
index 712911d..5edbdf4 100644 (file)
@@ -21,7 +21,7 @@
 #include <signal.h>
 #define DEFLTX "/usr/lib/eign"
 #define TILDE 0177
 #include <signal.h>
 #define DEFLTX "/usr/lib/eign"
 #define TILDE 0177
-#define SORT "/bin/sort"
+#define SORT "/usr/bin/sort"
 #define        N 30
 #define        MAX     N*BUFSIZ
 #define LMAX   200
 #define        N 30
 #define        MAX     N*BUFSIZ
 #define LMAX   200
diff --git a/usr/src/cmd/quiz.c b/usr/src/cmd/quiz.c
new file mode 100644 (file)
index 0000000..a7f16ce
--- /dev/null
@@ -0,0 +1,472 @@
+#include <stdio.h>
+#include <signal.h>
+#define NF 10
+#define NL 300
+#define NC 200
+#define SL 100
+#define NA 10
+
+int tflag;
+int xx[NL];
+char score[NL];
+int rights;
+int wrongs;
+int guesses;
+FILE *input;
+int nl = 0;
+int na = NA;
+int inc;
+int ptr = 0;
+int nc = 0;
+char line[150];
+char response[100];
+char *tmp[NF];
+int select[NF];
+
+readline()
+{
+       char *t;
+loop:
+       for(t=line;(*t=getc(input))!=-1;t++) {
+               nc++;
+               if(*t==' '&&(t==line||t[-1]==' '))
+                       t--;
+               if(*t=='\n') {
+                       if(t[-1]=='\\')         /*inexact test*/
+                               continue;
+                       while(t>line&&t[-1]==' ')
+                               *--t = '\n';
+                       *++t = 0;
+                       return(1);
+               }
+               if(t-line>=NC) {
+                       printf("Too hard for me\n");
+                       do {
+                               *line = getc(input);
+                               if(*line==0377)
+                                       return(0);
+                       } while(*line!='\n');
+                       goto loop;
+               }
+       }
+       return(0);
+}
+
+char *eu;
+char *ev;
+cmp(u,v)
+char *u,*v;
+{
+       int x;
+       eu = u;
+       ev = v;
+       x = disj(1);
+       if(x!=1)
+               return(x);
+       return(eat(1,0));
+}
+
+disj(s)
+{
+       int t, x;
+       char *u;
+       u = eu;
+       t = 0;
+       for(;;) {
+               x = string(s);
+               if(x>1)
+                       return(x);
+               switch(*ev) {
+               case 0:
+               case ']':
+               case '}':
+                       return(t|x&s);
+               case '|':
+                       ev++;
+                       t |= s;
+                       s = 0;
+                       continue;
+               }
+               if(s) eu = u;
+               if(string(0)>1)
+                       return(2);
+               switch(*ev) {
+               case 0:
+               case ']':
+                       return(0);
+               case '}':
+                       return(1);
+               case '|':
+                       ev++;
+                       continue;
+               default:
+                       return(2);
+               }
+       }
+}
+
+string(s)
+{
+       int x;
+       for(;;) {
+               switch(*ev) {
+               case 0:
+               case '|':
+               case ']':
+               case '}':
+                       return(1);
+               case '\\':
+                       ev++;
+                       if(*ev==0)
+                               return(2);
+                       if(*ev=='\n') {
+                               ev++;
+                               continue;
+                       }
+               default:
+                       if(eat(s,*ev)==1)
+                               continue;
+                       return(0);
+               case '[':
+                       ev++;
+                       x = disj(s);
+                       if(*ev!=']' || x>1)
+                               return(2);
+                       ev++;
+                       if(s==0)
+                               continue;
+                       if(x==0)
+                               return(0);
+                       continue;
+               case '{':
+                       ev++;
+                       x = disj(s);
+                       if(*ev!='}'||x>1)
+                               return(2);
+                       ev++;
+                       continue;
+               }
+       }
+}
+
+eat(s,c)
+char c;
+{
+       if(*ev!=c)
+               return(2);
+       if(s==0) {
+               ev++;
+               return(1);
+       }
+       if(fold(*eu)!=fold(c))
+               return(0);
+       eu++;
+       ev++;
+       return(1);
+}
+
+fold(c)
+char c;
+{
+       if(c<'A'||c>'Z')
+               return(c);
+       return(c|040);
+}
+
+publish(t)
+char *t;
+{
+       ev = t;
+       pub1(1);
+}
+
+pub1(s)
+{
+       for(;;ev++){
+               switch(*ev) {
+               case '|':
+                       s = 0;
+                       ev;
+                       continue;
+               case ']':
+               case '}':
+               case 0:
+                       return;
+               case '[':
+               case '{':
+                       ev++;
+                       pub1(s);
+                       ev;
+                       continue;
+               case '\\':
+                       if(*++ev=='\n')
+                               continue;
+               default:
+                       if(s)
+                               putchar(*ev);
+               }
+       }
+}
+
+segment(u,w)
+char *u, *w[];
+{
+       char *s;
+       int i;
+       char *t;
+       s = u;
+       for(i=0;i<NF;i++) {
+               u = s;
+               t = w[i];
+               while(*s!=':'&&*s!='\n'&&s-u<SL) {
+                       if(*s=='\\')  {
+                               if(s[1] == '\n') {
+                                       s += 2;
+                                       continue;
+                               }
+                               *t++ = *s++;
+                       }
+                       *t++ = *s++;
+               }
+
+               while(*s!=':'&&*s!='\n')
+                       s++;
+               *t = 0;
+               if(*s++=='\n') {
+                       return(i+1);
+               }
+       }
+       printf("Too many facts about one thing\n");
+}
+
+perm(u,m,v,n,p)
+int p[];
+char *u[], *v[];
+{
+       int i, j;
+       int x;
+       for(i=0;i<m;i++) {
+               for(j=0;j<n;j++) {
+                       x = cmp(u[i],v[j]);
+                       if(x>1) badinfo();
+                       if(x==0)
+                               continue;
+                       p[i] = j;
+                       goto uloop;
+               }
+               return(0);
+uloop:         ;
+       }
+       return(1);
+}
+
+find(u,m)
+char *u[];
+{
+       int n;
+       while(readline()){
+               n = segment(line,tmp);
+               if(perm(u,m,tmp+1,n-1,select))
+                       return(1);
+       }
+       return(0);
+}
+
+readindex()
+{
+       xx[0] = nc = 0;
+       while(readline()) {
+               xx[++nl] = nc;
+               if(nl>=NL) {
+                       printf("I've forgotten some of it;\n");
+                       printf("I remember %d items.\n", nl);
+                       break;
+               }
+       }
+}
+
+talloc()
+{
+       int i;
+       for(i=0;i<NF;i++)
+               tmp[i] = malloc(SL);
+}
+
+main(argc,argv)
+char *argv[];
+{
+       register j;
+       int i;
+       int x;
+       int z;
+       char *info;
+       int tvec[2];
+       char *t;
+       extern done();
+       int count;
+       info = "/usr/lib/quiz/index";
+       time(tvec);
+       inc = tvec[1]&077774|01;
+loop:
+       if(argc>1&&*argv[1]=='-') {
+               switch(argv[1][1]) {
+               case 'i':
+                       if(argc>2) 
+                               info = argv[2];
+                       argc -= 2;
+                       argv += 2;
+                       goto loop;
+               case 't':
+                       tflag = 1;
+                       argc--;
+                       argv++;
+                       goto loop;
+               }
+       }
+       input = fopen(info,"r");
+       if(input==NULL) {
+               printf("No info\n");
+               exit(0);
+       }
+       talloc();
+       if(argc<=2)
+               instruct(info);
+       signal(SIGINT,done);
+       argv[argc] = 0;
+       if(find(&argv[1],argc-1)==0)
+               dunno();
+       fclose(input);
+       input = fopen(tmp[0],"r");
+       if(input==NULL)
+               dunno();
+       readindex();
+       if(!tflag || na>nl)
+               na = nl;
+       stdout->_flag |= _IONBF;
+       for(;;) {
+               i = next();
+               fseek(input,xx[i]+0L,0);
+               z = xx[i+1]-xx[i];
+               for(j=0;j<z;j++)
+                       line[j] = getc(input);
+               segment(line,tmp);
+               if(*tmp[select[0]] == '\0' || *tmp[select[1]] == '\0') {
+                       score[i] = 1;
+                       continue;
+               }
+               publish(tmp[select[0]]);
+               printf("\n");
+               for(count=0;;count++) {
+                       if(query(response)==0) {
+                               publish(tmp[select[1]]);
+                               printf("\n");
+                               if(count==0) wrongs++;
+                               score[i] = tflag?-1:1;
+                               break;
+                       }
+                       x = cmp(response,tmp[select[1]]);
+                       if(x>1) badinfo();
+                       if(x==1) {
+                               printf("Right!\n");
+                               if(count==0) rights++;
+                               if(++score[i]>=1 && na<nl)
+                                       na++;
+                               break;
+                       }
+                       printf("What?\n");
+                       if(count==0) wrongs++;
+                       score[i] = tflag?-1:1;
+               }
+               guesses += count;
+       }
+}
+
+query(r)
+char *r;
+{
+       char *t;
+       for(t=r;;t++) {
+               if(read(0,t,1)==0)
+                       done();
+               if(*t==' '&&(t==r||t[-1]==' '))
+                       t--;
+               if(*t=='\n') {
+                       while(t>r&&t[-1]==' ')
+                               *--t = '\n';
+                       break;
+               }
+       }
+       *t = 0;
+       return(t-r);
+}
+
+next()
+{
+       int flag;
+       inc = inc*3125&077777;
+       ptr = (inc>>2)%na;
+       flag = 0;
+       while(score[ptr]>0)
+               if(++ptr>=na) {
+                       ptr = 0;
+                       if(flag) done();
+                       flag = 1;
+               }
+       return(ptr);
+}
+
+done()
+{
+       printf("\nRights %d, wrongs %d, ", rights, wrongs);
+       if(guesses)
+               printf("extra guesses %d, ", guesses);
+       printf("score %d%%\n",100*rights/(rights+wrongs));
+       exit(0);
+}
+instruct(info)
+{
+       char *t;
+       int i, n;
+       printf("Subjects:\n\n");
+       while(readline()) {
+               printf("-");
+               n = segment(line,tmp);
+               for(i=1;i<n;i++) {
+                       printf(" ");
+                       publish(tmp[i]);
+               }
+               printf("\n");
+       }
+       printf("\n");
+       input = fopen(info,"r");
+       if(input==NULL)
+               abort();
+       readline();
+       segment(line,tmp);
+       printf("For example,\n");
+       printf("    quiz ");
+       publish(tmp[1]);
+       printf(" ");
+       publish(tmp[2]);
+       printf("\nasks you a ");
+       publish(tmp[1]);
+       printf(" and you answer the ");
+       publish(tmp[2]);
+       printf("\n    quiz ");
+       publish(tmp[2]);
+       printf(" ");
+       publish(tmp[1]);
+       printf("\nworks the other way around\n");
+       printf("\nType empty line to get correct answer.\n");
+       exit(0);
+}
+
+badinfo(){
+       printf("Bad info %s\n",line);
+}
+
+dunno()
+{
+       printf("I don't know about that\n");
+       exit(0);
+}
index 8242d8b..042aa81 100644 (file)
@@ -1,7 +1,6 @@
 #include <stdio.h>
 #define MAXINT 32768.
 #include <stdio.h>
 #define MAXINT 32768.
-float fract = 2;
-double atof();
+float fract = 2,atof();
 char rflag,eflag,c;
 char ibuf[BUFSIZ],obuf[BUFSIZ],line[BUFSIZ];
 main(argc,argv) char **argv;
 char rflag,eflag,c;
 char ibuf[BUFSIZ],obuf[BUFSIZ],line[BUFSIZ];
 main(argc,argv) char **argv;
diff --git a/usr/src/cmd/ranlib.c b/usr/src/cmd/ranlib.c
deleted file mode 100644 (file)
index a0b6e91..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-#include       <ar.h>
-#include       <a.out.h>
-#include       <stdio.h>
-#define        MAGIC   exp.a_magic
-#define        BADMAG  MAGIC!=A_MAGIC1 && MAGIC!=A_MAGIC2  \
-               && MAGIC!=A_MAGIC3 && MAGIC!=A_MAGIC4
-struct ar_hdr  arp;
-struct exec    exp;
-FILE   *fi, *fo;
-long   off, oldoff;
-long   ftell();
-#define TABSZ  700
-struct tab
-{      char cname[8];
-       long cloc;
-} tab[TABSZ];
-int tnum;
-int new;
-char   tempnm[] = "__.SYMDEF";
-char   firstname[17];
-long   offdelta;
-
-main(argc, argv)
-char **argv;
-{
-       char buf[256];
-
-       --argc;
-       while(argc--) {
-               fi = fopen(*++argv,"r");
-               if (fi == NULL) {
-                       fprintf(stderr, "nm: cannot open %s\n", *argv);
-                       continue;
-               }
-               off = sizeof(exp.a_magic);
-               fread((char *)&exp, 1, sizeof(MAGIC), fi);      /* get magic no. */
-               if (MAGIC != ARMAG)
-               {       fprintf(stderr, "not archive: %s\n", *argv);
-                       continue;
-               }
-               fseek(fi, 0L, 0);
-               new = tnum = 0;
-               if(nextel(fi) == 0)
-               {       fclose(fi);
-                       continue;
-               }
-               do {
-                       long o;
-                       register n;
-                       struct nlist sym;
-
-                       fread((char *)&exp, 1, sizeof(struct exec), fi);
-                       if (BADMAG)             /* archive element not in  */
-                               continue;       /* proper format - skip it */
-                       o = (long)exp.a_text + exp.a_data;
-                       if ((exp.a_flag & 01) == 0)
-                               o *= 2;
-                       fseek(fi, o, 1);
-                       n = exp.a_syms / sizeof(struct nlist);
-                       if (n == 0) {
-                               fprintf(stderr, "nm: %s-- no name list\n", arp.ar_name);
-                               continue;
-                       }
-                       while (--n >= 0) {
-                               fread((char *)&sym, 1, sizeof(sym), fi);
-                               if ((sym.n_type&N_EXT)==0)
-                                       continue;
-                               switch (sym.n_type&N_TYPE) {
-
-                               case N_UNDF:
-                                       continue;
-
-                               default:
-                                       stash(&sym);
-                                       continue;
-                               }
-                       }
-               } while(nextel(fi));
-               new = fixsize();
-               fclose(fi);
-               fo = fopen(tempnm, "w");
-               if(fo == NULL)
-               {       fprintf(stderr, "can't create temporary\n");
-                       exit(1);
-               }
-               fwrite((char *)tab, tnum, sizeof(struct tab), fo);
-               fclose(fo);
-               if(new)
-                       sprintf(buf, "ar rlb %s %s %s\n", firstname, *argv, tempnm);
-               else    sprintf(buf, "ar rl %s %s\n", *argv, tempnm);
-               if(system(buf))
-                       fprintf(stderr, "can't execute %s\n", buf);
-               else fixdate(*argv);
-               unlink(tempnm);
-       }
-       exit(0);
-}
-
-nextel(af)
-FILE *af;
-{
-       register r;
-
-       oldoff = off;
-       fseek(af, off, 0);
-       r = fread((char *)&arp, 1, sizeof(struct ar_hdr), af);  /* read archive header */
-       if (r <= 0)
-               return(0);
-       if (arp.ar_size & 1)
-               ++arp.ar_size;
-       off = ftell(af) + arp.ar_size;  /* offset to next element */
-       return(1);
-}
-
-stash(s) struct nlist *s;
-{      int i;
-       if(tnum >= TABSZ)
-       {       fprintf(stderr, "symbol table overflow\n");
-               exit(1);
-       }
-       for(i=0; i<8; i++)
-               tab[tnum].cname[i] = s->n_name[i];
-       tab[tnum].cloc = oldoff;
-       tnum++;
-}
-
-fixsize()
-{      int i;
-       offdelta = tnum * sizeof(struct tab) + sizeof(arp);
-       off = sizeof(MAGIC);
-       nextel(fi);
-       if(strncmp(arp.ar_name, tempnm, 14) == 0)
-       {       new = 0;
-               offdelta -= sizeof(arp) + arp.ar_size;
-       }
-       else
-       {       new = 1;
-               strncpy(firstname, arp.ar_name, 14);
-       }
-       for(i=0; i<tnum; i++)
-               tab[i].cloc += offdelta;
-       return(new);
-}
-
-/* patch time */
-fixdate(s) char *s;
-{      long timex, time();
-       int fd;
-       fd = open(s, 1);
-       if(fd < 0)
-       {       fprintf(stderr, "can't reopen %s\n", s);
-               return;
-       }
-       timex = time(NULL) + 5; /* should be enough time */
-       lseek(fd, (long)sizeof(exp.a_magic) + ((char *)&arp.ar_date-(char *)&arp), 0);
-       write(fd, (char *)&timex, sizeof(timex));
-       close(fd);
-}
diff --git a/usr/src/cmd/ratfor/Makefile b/usr/src/cmd/ratfor/Makefile
new file mode 100644 (file)
index 0000000..56b08f7
--- /dev/null
@@ -0,0 +1,20 @@
+CFLAGS = -O
+
+ratfor:        r0.o r1.o r2.o rio.o rlook.o rlex.o y.tab.o
+       cc r*.o y.tab.o -o ratfor
+
+r0.o:  r.h y.tab.h r0.c
+r1.o:  r.h y.tab.h r1.c
+r2.o:  r.h y.tab.h r2.c
+rio.o: r.h y.tab.h rio.c
+rlook.o:       r.h y.tab.h rlook.c
+rlex.o:        r.h y.tab.h rlex.c
+y.tab.c:       r.g
+       yacc -d r.g
+y.tab.h:       r.g
+       yacc -d r.g
+install: ratfor
+       install -s ratfor $(DESTDIR)/usr/bin
+clean:
+       rm -f y.tab.c *.o ratfor y.tab.h
+
diff --git a/usr/src/cmd/ratfor/makefile b/usr/src/cmd/ratfor/makefile
deleted file mode 100644 (file)
index 01f2151..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-CFLAGS = -n -O -s
-
-all:   ratfor
-
-cp:    ratfor
-       cp ratfor /bin
-       rm y.tab.c *.o ratfor y.tab.h
-
-cmp:   ratfor
-       cmp ratfor /bin/ratfor
-       rm y.tab.c *.o ratfor y.tab.h
-
-ratfor:        r0.o r1.o r2.o rio.o rlook.o rlex.o y.tab.o
-       cc $(CFLAGS) r*.o y.tab.o -o ratfor
-
-r0.o:  r.h y.tab.h r0.c
-r1.o:  r.h y.tab.h r1.c
-r2.o:  r.h y.tab.h r2.c
-rio.o: r.h y.tab.h rio.c
-rlook.o:       r.h y.tab.h rlook.c
-rlex.o:        r.h y.tab.h rlex.c
-y.tab.c:       r.g
-       yacc -d r.g
-y.tab.h:       r.g
-       yacc -d r.g
index 2f1d7a5..b43b8c0 100644 (file)
@@ -251,7 +251,6 @@ forstat(p1) int p1; {
                outcode(bp);
                outdon();
        }
                outcode(bp);
                outdon();
        }
-       transfer = 0;
        outgoto(p1);
        indent--;
        putcom("endfor");
        outgoto(p1);
        indent--;
        putcom("endfor");
index 0855ccf..89eb6f6 100644 (file)
@@ -3,7 +3,7 @@
 char   ibuf[BUFSIZE];
 char   *ip = ibuf;
 
 char   ibuf[BUFSIZE];
 char   *ip = ibuf;
 
-char   type[] {
+char   type[] {
        0,      CRAP,   CRAP,   CRAP,   CRAP,   CRAP,   CRAP,   CRAP,
        CRAP,   '\t',   '\n',   CRAP,   CRAP,   CRAP,   CRAP,   CRAP,
        CRAP,   CRAP,   CRAP,   CRAP,   CRAP,   CRAP,   CRAP,   CRAP,
        0,      CRAP,   CRAP,   CRAP,   CRAP,   CRAP,   CRAP,   CRAP,
        CRAP,   '\t',   '\n',   CRAP,   CRAP,   CRAP,   CRAP,   CRAP,
        CRAP,   CRAP,   CRAP,   CRAP,   CRAP,   CRAP,   CRAP,   CRAP,
diff --git a/usr/src/cmd/rc.c b/usr/src/cmd/rc.c
new file mode 100644 (file)
index 0000000..5a72053
--- /dev/null
@@ -0,0 +1,523 @@
+#include <signal.h>
+/* EFL-Ratfor-Fortran command */
+
+char *setsuf(),*copy();
+extern int fin, fout;
+char   ts[4000];
+char   *tsp    = ts;
+char   *av[500];
+char   *rlist[500];
+int    nr      = 0;
+char   *llist[500];
+int    nl      = 0;
+int    nxo     = 0;
+int    bdcount = 0;    /* count block data files generated */
+int    rflag   = 0;    /* Ratfor or EFL ony, no compile */
+int    dflag   = 0;    /* Compile EFL DEBUG statements if set */
+int    tflag   = 0;    /* Trace operation of command if set */
+int    vflag   = 1;    /* Verify files compiled if set */
+int    mflag   = 0;    /* Ratfor macro pre-pass if set */
+int    fflag   = 0;    /* Save Fortran intermediate files if set */
+int    cflag   = 0;    /* Compile only if set */
+int    Uflag   = 0;    /* Add IMPLICIT UNDEFINED to generated fortran */
+int    Cflag   = 0;    /* Copy Ratfor comments if set */
+int    errcnt;
+char   *arg0;
+char   *complr = "/usr/fort/fc1";
+char   *ratfor = "/usr/bin/ratfor";
+char   *ratout = "ratjunk";
+char   *rattmp = "ratjunk.r";
+char   *ratopt = "-1&";
+char   *efl    = "/usr/bin/efl";
+char   *eflout = "efljunk";
+char   *eflopt = "-u         ";
+char   *macro  = "/usr/bin/m4";
+char   *undecl = "implicit undefined /a-z,A-Z/\n";
+
+# define BADOPEN 127
+main(argc, argv)
+char *argv[]; {
+       char *t;
+       int i, j, c;
+       int dexit();
+
+       arg0 = argv[0];
+       for(i=0; ++i < argc; ) {
+               if(*argv[i] == '-')
+                       for(j=1; argv[i][j]; j++) {
+                               switch (argv[i][j]) {
+                               default:
+                                       if(j == 1) goto passa;
+                                       else continue;
+                               case 'm':
+                                       mflag = 1;
+                                       break;
+                               case 't':
+                                       tflag = 1;
+                                       break;
+                               case 'v':
+                                       vflag = 0;
+                                       break;
+                               case 'd':
+                                       eflopt[7] = 'd';
+                                       break;
+                               case 'g':
+                                       eflopt[2] = 'g';
+                                       eflopt[3] = argv[i][j+1];
+                                       rflag = cflag = fflag = 1;
+                                       break;
+                               case 'e':
+                               case 'r':
+                                       rflag = fflag = cflag = 1;
+                                       break;
+                               case 'f':
+                                       fflag = 1;
+                                       break;
+                               case 'c':
+                                       cflag = 1;
+                                       break;
+                               case 'U':
+                                       Uflag = 1;
+                                       break;
+                               case 'C':
+                                       Cflag = 1;
+                                       break;
+                               case '2':
+                                       complr = "/usr/fort/fc2";
+                                       break;
+                               case '6':
+                                       ratopt[1] = '6';
+                                       ratopt[2] = argv[i][j+1];
+                                       rflag = cflag = fflag = 1;
+                                       break;
+                               case '9':
+                                       eflopt[4] = '9';
+                                       break;
+                               case '#':
+                                       eflopt[5] = '#';
+                                       break;
+                               case 'w':
+                                       eflopt[6] = 'w';
+                                       break;
+                               }
+                       }
+               else {
+          passa:
+                       t = argv[i];
+                       switch( getsuf(t) ) {
+
+                               case 'e':
+                                       eflcomp(t);
+                                       break;
+
+                               case 'r':
+                                       ratcomp(t);
+                                       break;
+
+                               case 'f':
+                                       fortcomp(t);
+                                       llenter(setsuf(copy(t),'o'));
+                                       break;
+
+                               default:
+                                       llenter(copy(t));
+                                       break;
+                               }
+               }
+       }
+       if(rflag)
+               dexit(0);
+       if (signal(SIGINT, SIG_IGN) != SIG_IGN)
+               signal(SIGINT, dexit);
+       if(tflag)
+               printf("errcnt=%d, nl=%d\n", errcnt, nl);
+       if (errcnt==0 & cflag==0 && nl!=0) {
+               i = 0;
+               av[0] = "ld";
+               av[1] = "-x";
+               av[2] = "/lib/fr0.o";
+               j = 3;
+               while(i<nl)
+                       av[j++] = llist[i++];
+               av[j++] = "-lf";
+               av[j++] = "/usr/lib/filib.a";
+               av[j++] = "-l";
+               av[j++] = 0;
+               callsys("/bin/ld", av);
+       }
+       dexit(errcnt);
+}
+
+dexit(n)
+int n;
+{
+       cunlink(ratout);
+       cunlink(rattmp);
+       cunlink(eflout);
+       cunlink("f.tmp1");
+       if(tflag)
+               printf("%s status=%d\n", arg0, n);
+       exit(n);
+}
+
+eflcomp(s) char *s; {
+       nr = 0;
+       if(vflag)
+               printf("%s:\n",s);
+       if( callprep( efl, s, eflout, eflopt, 0, 0 ) == 0 ) {
+               splitup(eflout);
+               dorlist(s);
+               }
+}
+
+
+
+ratcomp(s) char *s; {
+       int i, j, t;
+       nr = 0;
+       if(vflag)
+               printf("%s:\n",s);
+       if (mflag) {
+               if( ( t = callprep( macro, s, rattmp, 0, 0, 0 ) ) < BADOPEN )
+                       t = callprep( ratfor, rattmp, ratout, ratopt, Cflag?"-C":0, 0 );
+       } else
+               t = callprep( ratfor, s, ratout, ratopt, Cflag?"-C":0, 0 );
+       if( t < BADOPEN ) {
+               splitup(ratout);
+               dorlist(s);
+               }
+}
+
+callprep( prep, file, output, opt1, opt2, opt3 )
+char *prep, *file, *output, *opt1, *opt2, *opt3;
+{
+       int t, status, i, j;
+
+       av[0] = prep;
+       j = 1;
+       if (opt1) av[j++] = opt1;
+       if (opt2) av[j++] = opt2;
+       if (opt3) av[j++] = opt3;
+       av[j] = 0;
+       if( tflag ) {
+               printf("%s <%s ", av[0], file);
+               for (i=1; av[i]; i++)
+                       printf("%s ", av[i]);
+               printf("\n");
+       }
+       if( (t=fork())==0 ){
+               close(1);
+               if( (fout=creat(output, 0666)) < 0) {
+                       error( "can't open %s", output );
+                       dexit(BADOPEN);
+                       }
+               close(0);
+               if( (fin=open(file, 0)) < 0) {
+                       error( "can't open %s", file );
+                       dexit(BADOPEN);
+                       }
+               execv(prep, av);
+               error("can't execute %s", prep);
+               dexit(1);
+       }
+       while( t!=wait(&status) );
+       if( (t=(status&0377)) != 0 && t!=14 )
+               dexit(1);
+       t = (status>>8) & 0377;
+       if( tflag )
+               printf("status = %d\n", t);
+       if( t ) ++errcnt;
+       return ( t );
+}
+
+dorlist(s) char *s; {
+
+       int i, j, t;
+       int fstat;
+
+       if( rflag ) return;
+       fstat = 0;
+       for(i=0; i<nr; i++){
+               if( vflag ) printf("   ");
+               if( fortcomp(rlist[i]) )
+                       fstat++;
+               }
+       if( fstat ) {
+               for(i=0; i<nr; i++) {
+                       cunlink( setsuf( rlist[i], 'o' ) );
+                       if( fflag==0 ) cunlink( setsuf( rlist[i], 'f' ) );
+                       }
+               return;
+               }
+       av[0] = "ld";
+       av[1] = "-r";
+       av[2] = "-x";
+       j = 3;
+       for(i=0; i<nr; i++)
+               av[j++] = rlist[i];
+       av[j] = 0;
+       callsys("/bin/ld", av);
+       t = setsuf(copy(s),'o');
+       if( move( "a.out", t) )
+               errcnt++;
+       llenter(t);
+       for(i=0; i<nr; i++) {
+               if( nodup(llist,rlist[i]) )
+                       cunlink(rlist[i]);
+               if( fflag==0 )
+                       cunlink(setsuf(rlist[i],'f'));
+       }
+}
+
+fortcomp(s) char *s; {
+       int t;
+       if( vflag ) printf("%s:\n", s);
+       av[0] = complr;
+       av[1] = s;
+       av[2] = 0;
+       if( callsys(complr, av) )
+               return(++errcnt);
+       av[0] = "as";
+       av[1] = "-";
+       av[2] = "-o";
+       av[3] = setsuf(s, 'o');
+       av[4] = "f.tmp1";
+       av[5] = 0;
+       callsys("/bin/as", av);
+       return(0);
+}
+
+getsuf(s)
+char s[];
+{
+       int c;
+       char t, *os;
+
+       c = 0;
+       os = s;
+       while(t = *s++)
+               if (t=='/')
+                       c = 0;
+               else
+                       c++;
+       s -= 3;
+       if (c<=14 && c>2 && *s++=='.')
+               return(*s);
+       return(0);
+}
+
+char *
+setsuf(s, ch)
+char s[];
+{
+       char *os;
+
+       os = s;
+       while( *s )
+               if( *s++ == '/' )
+                       os = s;
+       s[-1] = ch;
+       return(os);
+}
+
+move(s,t) char *s, *t; {
+       cunlink(t);
+       if(link(s, t) || cunlink(s)) {
+               printf("move failed: %s\n", t);
+               return(1);
+       }
+       return(0);
+}
+
+callsys(f, v)
+char f[], *v[]; {
+       int i, t, status;
+
+       if(tflag){
+               printf("%s ", f);
+               for(i=0; v[i]; i++)
+                       printf("%s ", v[i]);
+               putchar('\n');
+       }
+       if ((t=fork())==0) {
+               execv(f, v);
+               printf("Can't find %s\n", f);
+               dexit(1);
+       } else
+               if (t == -1) {
+                       printf("Try again\n");
+                       return(1);
+               }
+       while(t!=wait(&status));
+       if ((t=(status&0377)) != 0 && t!=14) {
+               if (t!=2)               /* interrupt */
+                       printf("Fatal error in %s\n", f);
+               dexit(1);
+       }
+       t = (status>>8) & 0377;
+       if( tflag )
+               printf("status = %d\n", t);
+       return(t);
+}
+
+char *
+copy(s)
+char s[]; {
+       char *otsp;
+
+       otsp = tsp;
+       while(*tsp++ = *s++);
+       return(otsp);
+}
+
+nodup(l, s)
+char **l, s[]; {
+       char *t, *os, c;
+
+       if (getsuf(s) != 'o')
+               return(1);
+       os = s;
+       while(t = *l++) {
+               s = os;
+               while(c = *s++)
+                       if (c != *t++)
+                               break;
+               if (*t++ == '\0')
+                       return(0);
+       }
+       return(1);
+}
+
+llenter(t) char *t; {
+       if (nodup(llist, t)) {
+               llist[nl++] = t;
+               if (getsuf(t)=='o')
+                       nxo++;
+       }
+}
+
+cunlink(f)
+char *f;
+{
+       if( tflag )
+               printf("unlink %s\n", f);
+       if (f==0)
+               return(0);
+       return(unlink(f));
+}
+
+splitup(file) char *file; {
+       char in[1500], fname[20];
+       int buf[259];
+       int i,fd,mainsw,c;
+       if( (fin=open(file, 0)) < 0)
+               error("can't open %s", file);
+       while( gets(in) ){
+               if( *in == 'c' || *in == 'C' ) continue;
+               mainsw = getname(in, fname);
+               savename(fname);
+               if( (fd = fcreat(fname, buf)) < 0)
+                       error("can't open %s", fname);
+               if(mainsw && Uflag) {
+                       puts(undecl,buf);
+                       puts(in,buf);
+               } else {
+                       puts(in,buf);
+                       if( Uflag )
+                               puts(undecl,buf);
+               }
+               while( ! endcard(in) ){
+                       gets(in);
+                       puts(in,buf);
+               }
+               fflush(buf);
+               close(fd);
+       }
+       close(fin);
+}
+
+gets(s) char *s; {
+       int c;
+       while( (*s++=c=getchar()) != '\n' && c != '\0' );
+       *s = '\0';
+       return(c);
+}
+
+puts(s,b) char *s; int *b; {
+       while( *s )
+               putc(*s++, b);
+}
+
+savename(s) char *s; {
+       rlist[nr++] = copy(s);
+}
+
+getname(s,f) char *s,*f; {
+       int i,j,c;
+   loop:
+       while( *s == ' ' || *s == '\t' )
+               s++;
+       if( compar(s,"subroutine") ){ s += 10; goto bot; }
+       else if( compar( s,"function") ){ s += 8; goto bot; }
+       else if( compar(s,"real") ){ s += 4; goto loop; }
+       else if( compar(s,"integer") ){ s += 7; goto loop; }
+       else if( compar(s,"logical") ){ s += 7; goto loop; }
+       else if( compar(s,"double") ){ s += 6; goto loop; }
+       else if( compar(s,"precision") ){ s += 9; goto loop; }
+       else if( compar(s,"complex") ){ s += 7; goto loop; }
+       else if( compar(s,"*") ){       /* integer *16 */
+               ++s;
+               while( (*s >= '0' && *s <= '9') || *s == ' ' || *s == '\t' )
+                       s++;
+               goto loop;
+       }
+       else if( compar(s,"block") ){
+               s = "BLOCKDATA ";
+               s[9] = (bdcount++) + '0';
+               goto bot;
+       }
+       else {
+               for(i=0; f[i]="MAIN.f"[i]; i++);
+               return(1);
+       }
+   bot:
+       while( *s == ' ' || *s == '\t' )
+               s++;
+       for(i=0; alphanum(s[i]); i++)
+               f[i] = s[i];
+       f[i++] = '.';
+       f[i++] = 'f';
+       f[i++] = '\0';
+       return(0);
+}
+
+compar(s,t) char *s,*t; {
+       while( *t )
+               if( *s++ != *t++ )
+                       return(0);
+       return(1);
+}
+
+alphanum(c) int c; {
+       return( (c>='a' && c<='z')
+               || (c>='A' && c<='Z')
+               || (c>='0' && c<='9') );
+}
+
+endcard(s) char *s; {
+       if( *s==0 )
+               return(1);
+       while( *s==' ' || *s=='\t' )
+               s++;
+       if( *s!='e' || *(s+1)!='n' || *(s+2)!='d' || *(s+3)!='\n' )
+               return(0);
+       return(1);
+}
+
+error(s1, s2){
+       fout = 2;
+       printf(s1,s2);
+       putchar('\n');
+       flush(1);
+       errcnt++;
+}
diff --git a/usr/src/cmd/refer/Makefile b/usr/src/cmd/refer/Makefile
new file mode 100644 (file)
index 0000000..f593d26
--- /dev/null
@@ -0,0 +1,51 @@
+CFLAGS = -O
+
+all:   mkey inv hunt refer
+
+mkey: mkey1.o mkey2.o mkey3.o deliv2.o
+       cc mkey?.o deliv2.o -o mkey
+inv: inv1.o inv2.o inv3.o inv5.o inv6.o deliv2.o
+       cc inv?.o deliv2.o -o inv
+hunt: hunt1.o hunt2.o hunt3.o hunt5.o hunt6.o hunt7.o glue5.o
+hunt: refer3.o hunt9.o shell.o deliv2.o hunt8.o glue4.o
+       cc hunt?.o refer3.o glue5.o glue4.o shell.o deliv2.o -o hunt
+deliv: deliv1.o deliv2.o
+       cc deliv?.o  -o deliv
+refpart: refer0.o refer1.o refer2.o refer3.o refer4.o refer5.o
+refpart: refer6.o refer7.o refer8.o deliv2.o glue4.o
+       cc refer?.o deliv2.o glue4.o  -o refpart
+refer0.o: refer..c
+refer1.o: refer..c
+refer2.o: refer..c
+refer3.o: refer..c
+refer4.o: refer..c
+refer6.o: refer..c
+refer: glue1.o refer1.o refer2.o refer4.o refer5.o refer6.o mkey3.o
+refer: refer7.o refer8.o hunt2.o hunt3.o deliv2.o hunt5.o hunt6.o hunt8.o
+refer: glue3.o hunt7.o hunt9.o glue2.o glue4.o glue5.o refer0.o shell.o
+       cc glue?.o refer[01245678].o hunt[2356789].o mkey3.o shell.o deliv2.o -o refer
+refer-test:
+       /usr/bin/refer test >junk1a
+       refer test >junk1b
+       if cmp -s junk1a junk1b; then echo ok; else echo bad; fi
+       /usr/bin/refer -e test >junk1a
+       refer -e test >junk1b
+       if cmp -s junk1a junk1b; then echo ok; else echo bad; fi
+       /usr/bin/refer -s test >junk1a
+       refer -s test >junk1b
+       if cmp -s junk1a junk1b; then echo ok; else echo bad; fi
+       /usr/bin/refer -s -l test >junk1a
+       refer -s -l test >junk1b
+       if cmp -s junk1a junk1b; then echo ok; else echo bad; fi
+       rm junk1a junk1b
+whatabout: what1.o what2.o what3.o what4.o shell.o mkey3.o
+       cc what?.o shell.o mkey3.o  -o whatabout
+
+install: all
+       install -s refer $(DESTDIR)/usr/bin
+       install -s inv $(DESTDIR)/usr/lib/refer
+       install -s hunt $(DESTDIR)/usr/lib/refer
+       install -s mkey $(DESTDIR)/usr/lib/refer
+clean:
+       rm -f refer inv hunt mkey *.o
+
index e64ae77..2405991 100644 (file)
@@ -23,6 +23,7 @@ while ( (c= *t++) == *s++)
        if (c==0) return(1);
 return(c==0 ? 1: 0);
 }
        if (c==0) return(1);
 return(c==0 ? 1: 0);
 }
+char *
 mindex(s, c)
        char *s;
 {
 mindex(s, c)
        char *s;
 {
index 1b2f013..076fbbe 100644 (file)
@@ -1,36 +1,38 @@
 # include "stdio.h"
 # define unopen(fil) {if (fil!=NULL) {fclose(fil); fil=NULL;}}
 extern char refdir[];
 # include "stdio.h"
 # define unopen(fil) {if (fil!=NULL) {fclose(fil); fil=NULL;}}
 extern char refdir[];
-int lmaster 1000;
-int reached 0;
-FILE *fd 0;
+int lmaster 1000;
+int reached 0;
+FILE *fd 0;
 int *hfreq, hfrflg;
 int *hfreq, hfrflg;
-int colevel 0;
-static union {unsigned *a; long *b;} master NULL;
+int colevel 0;
+static union firetruck {unsigned *a; long *b;} master;
 int iflong;
 extern char *fgnames[], **fgnamp;
 int iflong;
 extern char *fgnames[], **fgnamp;
-int prfreqs 0;
-int typeindex 0;
+extern FILE *iopen();
+char *todir();
+int prfreqs = 0;
+int typeindex = 0;
 char usedir[100];
 char usedir[100];
-static int full 1000;
-static int tags 0;
+static int full 1000;
+static int tags 0;
 char *sinput, *soutput, *tagout;
 char *sinput, *soutput, *tagout;
-long indexdate 0, gdate();
-int soutlen 1000;
-int taglen 1000;
+long indexdate 0, gdate();
+int soutlen 1000;
+int taglen 1000;
 
 huntmain(argc,argv)
        char *argv[];
 {
 /* read query from stdin, expect name of indexes in argv[1] */
 static FILE *fa, *fb, *fc;
 
 huntmain(argc,argv)
        char *argv[];
 {
 /* read query from stdin, expect name of indexes in argv[1] */
 static FILE *fa, *fb, *fc;
-char indexname[100], *qitem[100], *rprog 0;
+char indexname[100], *qitem[100], *rprog 0;
 char grepquery[200];
 static char oldname[30] ;
 char grepquery[200];
 static char oldname[30] ;
-static int nhash 0;
-static int maxhash 0;
-int falseflg 0, nitem, nfound, frtbl;
-static long *hpt 0;
+static int nhash 0;
+static int maxhash 0;
+int falseflg 0, nitem, nfound, frtbl;
+static long *hpt 0;
 # if D1
 fprintf(stderr, "in glue1 argc %d argv %o %o\n", argc, argv[0],argv[1]);
 # endif
 # if D1
 fprintf(stderr, "in glue1 argc %d argv %o %o\n", argc, argv[0],argv[1]);
 # endif
@@ -225,6 +227,7 @@ if (fgnamp>fgnames)
 restodir();
 }
 
 restodir();
 }
 
+char *
 todir(t)
        char *t;
 {
 todir(t)
        char *t;
 {
index 160f0c4..53cfaac 100644 (file)
@@ -8,7 +8,7 @@ char line[200], *s, argig[100], *cv[50];
 char *inp, inb[500];
 extern char gfile[];
 FILE *qf, *gf;
 char *inp, inb[500];
 extern char gfile[];
 FILE *qf, *gf;
-int c, oldc 0, alph 0, nv 0;
+int c, oldc = 0, alph = 0, nv = 0;
 int sv0, sv1;
 strcpy (argig, arg); strcat(argig, ".ig");
 strcpy (inp=inb, in);
 int sv0, sv1;
 strcpy (argig, arg); strcat(argig, ".ig");
 strcpy (inp=inb, in);
index ced751a..134da95 100644 (file)
@@ -29,7 +29,7 @@ int   xargc;
 char   **xargv;
 int    numwords;
 int    nfound;
 char   **xargv;
 int    numwords;
 int    nfound;
-static int flag 0;
+static int flag 0;
 
 
 fgrep(argc, argv)
 
 
 fgrep(argc, argv)
@@ -41,8 +41,9 @@ char **argv;
                www = zalloc(MAXSIZ, sizeof (*www));
        if (www==NULL)
                err("Can't get space for machines", 0);
                www = zalloc(MAXSIZ, sizeof (*www));
        if (www==NULL)
                err("Can't get space for machines", 0);
-       for (q=www; q<www+MAXSIZ; q++)
-               q->inp = q->out = q->nst = q->link = q->fail =0;
+       for (q=www; q<www+MAXSIZ; q++) {
+               q->inp =0; q->out =0; q->nst =0; q->link =0; q->fail =0;
+       }
        xargc = argc-1;
        xargv = argv+1;
        while (xargc>0 && xargv[0][0]=='-')
        xargc = argc-1;
        xargv = argv+1;
        while (xargc>0 && xargv[0][0]=='-')
@@ -96,7 +97,7 @@ fprintf(stderr,"inct %d xargv.2. %o %d\n",inct, xargv[2],xargv[2]);
 execute()
 {
        register char *p;
 execute()
 {
        register char *p;
-       register c;
+       register struct words *c;
        register ch;
        register ccount;
        int f;
        register ch;
        register ccount;
        int f;
@@ -233,7 +234,7 @@ fprintf(stderr, "nr end loop p %o\n",p);
 
 cgotofn() {
        register c;
 
 cgotofn() {
        register c;
-       register s;
+       register struct words *s;
        s = smax = www;
 nword: 
        for(;;) {
        s = smax = www;
 nword: 
        for(;;) {
@@ -306,7 +307,7 @@ cfail() {
        struct words **front, **rear;
        struct words *state;
        register char c;
        struct words **front, **rear;
        struct words *state;
        register char c;
-       register s;
+       register struct words *s;
        s = www;
        front = rear = queue;
 init:  
        s = www;
        front = rear = queue;
 init:  
index c240299..6c6ddc9 100644 (file)
@@ -4,33 +4,34 @@ extern char refdir[];
 extern int keepold;
 extern char *fgnames[];
 extern char **fgnamp;
 extern int keepold;
 extern char *fgnames[];
 extern char **fgnamp;
-FILE *fd 0;
-int lmaster 500;
+FILE *fd 0;
+int lmaster 500;
 int *hfreq, hfrflg;
 int *hfreq, hfrflg;
-int colevel 0;
-int soutlen 1000;
-int reached 0;
-int iflong 0;
-int prfreqs 0;
+int colevel 0;
+int soutlen 1000;
+int reached 0;
+int iflong 0;
+int prfreqs 0;
 char usedir[100];
 char gfile[50];
 char usedir[100];
 char gfile[50];
-static int full 1000;
-static int tags 0;
+static int full 1000;
+static int tags 0;
 char *sinput, *soutput, *tagout;
 char *sinput, *soutput, *tagout;
-long indexdate 0, gdate();
+long indexdate = 0, gdate();
+extern char *todir();
 
 main(argc,argv)
        char *argv[];
 {
 /* read query from stdin, expect name of indexes in argv[1] */
 static FILE *fa, *fb, *fc;
 
 main(argc,argv)
        char *argv[];
 {
 /* read query from stdin, expect name of indexes in argv[1] */
 static FILE *fa, *fb, *fc;
-char nma[100], nmb[100], nmc[100], *qitem[100], *rprog 0;
+char nma[100], nmb[100], nmc[100], *qitem[100], *rprog 0;
 char nmd[100], grepquery[256];
 static char oldname[30] ;
 char nmd[100], grepquery[256];
 static char oldname[30] ;
-static int was 0;
+static int was 0;
 /* these pointers are unions of pointer to int and pointer to long */
 long *hpt;
 /* these pointers are unions of pointer to int and pointer to long */
 long *hpt;
-unsigned *master 0;
+unsigned *master 0;
 int falseflg, nhash, nitem, nfound, frtbl, kk;
 
        /* special wart for refpart: default is tags only */
 int falseflg, nhash, nitem, nfound, frtbl, kk;
 
        /* special wart for refpart: default is tags only */
@@ -120,7 +121,7 @@ fseek (fa, 0L, 0);
 fread (&nhash, sizeof(nhash), 1, fa);
 fread (&iflong, sizeof(iflong), 1, fa);
 if(master==0)
 fread (&nhash, sizeof(nhash), 1, fa);
 fread (&iflong, sizeof(iflong), 1, fa);
 if(master==0)
-master = calloc (lmaster, iflong? 4: 2);
+master = calloc (lmaster, iflong? sizeof(long): sizeof(int));
 hpt = calloc(nhash, sizeof(*hpt));
 kk=fread( hpt, sizeof(*hpt), nhash, fa);
 # if D1
 hpt = calloc(nhash, sizeof(*hpt));
 kk=fread( hpt, sizeof(*hpt), nhash, fa);
 # if D1
@@ -194,6 +195,7 @@ while (1)
        }
 }
 
        }
 }
 
+char *
 todir(t)
        char *t;
 {
 todir(t)
        char *t;
 {
index ae6adc1..eece98b 100644 (file)
@@ -1,5 +1,5 @@
 # include "refer..c"
 # include "refer..c"
-static int *coord 0;
+static int *coord 0;
 int hh[50]; extern int *hfreq, hfrflg, hcomp(), hexch();
 extern int prfreqs;
 
 int hh[50]; extern int *hfreq, hfrflg, hcomp(), hexch();
 extern int prfreqs;
 
@@ -11,7 +11,7 @@ doquery(hpt, nhash, fb, nitem, qitem, master)
 {
 long k;
 union ptr prevdrop;
 {
 long k;
 union ptr prevdrop;
-int nf 0, best 0, nterm 0, i, g, j;
+int nf = 0, best = 0, nterm = 0, i, g, j;
 int *prevcoord;
 long lp;
 extern int lmaster, colevel, reached;
 int *prevcoord;
 long lp;
 extern int lmaster, colevel, reached;
@@ -27,7 +27,7 @@ if (coord==0)
        coord = zalloc(lmaster, sizeof(lmaster));
 if (colevel>0)
        {
        coord = zalloc(lmaster, sizeof(lmaster));
 if (colevel>0)
        {
-       prevdrop.a=zalloc(lmaster,iflong?4:2);
+       prevdrop.a=zalloc(lmaster,iflong?sizeof(long): sizeof(int));
        prevcoord = zalloc(lmaster, sizeof(lmaster));
        }
 else
        prevcoord = zalloc(lmaster, sizeof(lmaster));
        }
 else
@@ -229,7 +229,7 @@ if (colevel>0)
 # endif
 if (colevel)
        {
 # endif
 if (colevel)
        {
-       free(prevdrop, lmaster, iflong?4:2);
+       free(prevdrop, lmaster, iflong?sizeof(long): sizeof(int));
        free(prevcoord, lmaster, sizeof (lmaster));
        }
 # if D3
        free(prevcoord, lmaster, sizeof (lmaster));
        }
 # if D3
@@ -245,21 +245,14 @@ long
 getl(fb)
        FILE *fb;
 {
 getl(fb)
        FILE *fb;
 {
-int x[2];
-long *lp;
-x[0] = getw(fb);
-x[1] = getw(fb);
-lp= x;
-return(*lp);
+return(getw(fb));
 }
 }
+
 putl(ll, f)
        long ll;
        FILE *f;
 {
 putl(ll, f)
        long ll;
        FILE *f;
 {
-int *x;
-x = &ll;
-putw(x[0], f);
-putw(x[1], f);
+putw(ll, f);
 }
 hcomp( n1, n2)
 {
 }
 hcomp( n1, n2)
 {
index a3bdc85..e89f4fb 100644 (file)
@@ -4,10 +4,10 @@ getq(v)
 {
 # define BSIZ 250
 static char buff[BSIZ];
 {
 # define BSIZ 250
 static char buff[BSIZ];
-static int eof 0;
+static int eof 0;
 extern char *sinput;
 char *p;
 extern char *sinput;
 char *p;
-int c, n 0, las 0;
+int c, n = 0, las = 0;
 if (eof) return(-1);
 p = buff;
 while ( (c = (sinput ? *sinput++ : getchar()) ) > 0)
 if (eof) return(-1);
 p = buff;
 while ( (c = (sinput ? *sinput++ : getchar()) ) > 0)
index 6deeec5..589f6c3 100644 (file)
@@ -1,7 +1,7 @@
 # include "stdio.h"
 # include "assert.h"
 # define TXTLEN 1000
 # include "stdio.h"
 # include "assert.h"
 # define TXTLEN 1000
-char *outbuf 0;
+char *outbuf 0;
 extern char *soutput;
 extern int soutlen, iflong;
 extern long indexdate;
 extern char *soutput;
 extern int soutlen, iflong;
 extern long indexdate;
index d1c0627..6a74308 100644 (file)
@@ -3,19 +3,19 @@
 # include "assert.h"
 # define FGCT 10
 # define FGSIZE 150
 # include "assert.h"
 # define FGCT 10
 # define FGSIZE 150
-int keepold 1; /* keep old things for fgrep search */
+int keepold 1; /* keep old things for fgrep search */
 char fgspace[FGSIZE];
 char fgspace[FGSIZE];
-char *fgp fgspace;
+char *fgp fgspace;
 char *fgnames[FGCT];
 char *fgnames[FGCT];
-char **fgnamp fgnames;
+char **fgnamp fgnames;
 findline(in, out, outlen, indexdate)
        long indexdate;
        char *in, *out;
 {
 findline(in, out, outlen, indexdate)
        long indexdate;
        char *in, *out;
 {
-static char name[100] "";
+static char name[100] "";
 char *p, **ftp;
 extern long gdate();
 char *p, **ftp;
 extern long gdate();
-static FILE *fa NULL;
+static FILE *fa NULL;
 long lp, llen;
 int len, k, nofil;
 
 long lp, llen;
 int len, k, nofil;
 
index d33d708..c9e9e51 100644 (file)
@@ -2,6 +2,7 @@
 # include "assert.h"
 # define unopen(fil) {if (fil!=NULL) {fclose(fil); fil=NULL;}}
 extern long indexdate, gdate();
 # include "assert.h"
 # define unopen(fil) {if (fil!=NULL) {fclose(fil); fil=NULL;}}
 extern long indexdate, gdate();
+extern FILE *iopen();
 runbib (s)
        char *s;
 {
 runbib (s)
        char *s;
 {
@@ -13,7 +14,7 @@ system(tmp);
 makefgrep(indexname)
        char *indexname;
 {
 makefgrep(indexname)
        char *indexname;
 {
-       FILE *fa =NULL, *fb =NULL;
+       FILE *fa, *fb;
        if (ckexist(indexname, ".ig"))
                {
                /* existing gfrep -type index */
        if (ckexist(indexname, ".ig"))
                {
                /* existing gfrep -type index */
@@ -24,8 +25,7 @@ makefgrep(indexname)
                fb = iopen(indexname, "");
                if (gdate(fb)>gdate(fa))
                        {
                fb = iopen(indexname, "");
                if (gdate(fb)>gdate(fa))
                        {
-                       if (fa!=NULL)
-                               fclose(fa);
+                       fclose(fa);
                        runbib(indexname);
                        fa= iopen(indexname, ".ig");
                        }
                        runbib(indexname);
                        fa= iopen(indexname, ".ig");
                        }
@@ -55,6 +55,7 @@ strcpy (fnam, s);
 strcat (fnam, t);
 return (access(fnam, 04) != -1);
 }
 strcat (fnam, t);
 return (access(fnam, 04) != -1);
 }
+FILE *
 iopen (s, t)
        char *s, *t;
 {
 iopen (s, t)
        char *s, *t;
 {
index 234a8f3..a253420 100644 (file)
@@ -16,13 +16,13 @@ main(argc, argv)
 */
 
 FILE *fa, *fb, *fc, *fta, *ftb, *ftc, *fd;
 */
 
 FILE *fa, *fb, *fc, *fta, *ftb, *ftc, *fd;
-int nhash 256;
-int appflg 1;
-int keepkey 0, pipein 0;
+int nhash 256;
+int appflg 1;
+int keepkey = 0, pipein = 0;
 char nma[100], nmb[100], nmc[100], com[100], nmd[100];
 char tmpa[20], tmpb[20], tmpc[20];
 char nma[100], nmb[100], nmc[100], com[100], nmd[100];
 char tmpa[20], tmpb[20], tmpc[20];
-char *remove NULL;
-int chatty 0, docs, hashes, fp[2], fr, fw, pfork, pwait, status;
+char *remove NULL;
+int chatty 0, docs, hashes, fp[2], fr, fw, pfork, pwait, status;
 int i,j,k;
 long keys;
 int iflong =0;
 int i,j,k;
 long keys;
 int iflong =0;
index 3c366ea..a3f9e41 100644 (file)
@@ -11,12 +11,12 @@ newkeys (outf, inf, recf, nhash, fd, iflong)
 
 # define LINESIZ 1250
 long lp, ftell();
 
 # define LINESIZ 1250
 long lp, ftell();
-long ld 0; int ll 0, lt 0;
+long ld = 0; int ll = 0, lt = 0;
 char line[LINESIZ];
 char key[30], bkeys[40];
 char *p, *s;
 char *keyv[500];
 char line[LINESIZ];
 char key[30], bkeys[40];
 char *p, *s;
 char *keyv[500];
-int i, nk, ndoc 0, more 0, c;
+int i, nk, ndoc = 0, more = 0, c;
 
 lp = ftell (recf);
 while (fgets(line, LINESIZ, inf))
 
 lp = ftell (recf);
 while (fgets(line, LINESIZ, inf))
@@ -77,6 +77,7 @@ while (fgets(line, LINESIZ, inf))
        ndoc++;
        }
 *iflong = (lp>=65536L);
        ndoc++;
        }
 *iflong = (lp>=65536L);
+if (sizeof(int)>2) *iflong=1; /* force long on VAX */
 fclose(recf);
 return(ndoc);
 }
 fclose(recf);
 return(ndoc);
 }
index ddb3893..7aa5886 100644 (file)
@@ -32,9 +32,9 @@ if (n!= nhash)
        fprintf(stderr, "Changing hash value to old %d\n",n);
 fclose(fa);
 if (iflong)
        fprintf(stderr, "Changing hash value to old %d\n",n);
 fclose(fa);
 if (iflong)
-       getfun = &getl;
+       getfun = getl;
 else
 else
-       getfun = &getw;
+       getfun = getw;
 for(i=0; i<n; i++)
        {
        if (iflong)
 for(i=0; i<n; i++)
        {
        if (iflong)
index 1d48b28..99dd21f 100644 (file)
@@ -6,15 +6,15 @@ whash(ft, fa, fb, nhash, iflong, ptotct, phused)
        long *ptotct;
 {
 char line[100];
        long *ptotct;
 {
 char line[100];
-int hash 0, hused 0;
-long totct 0L;
-int ct 0;
+int hash = 0, hused = 0;
+long totct 0L;
+int ct 0;
 long point;
 long point;
-long opoint -1;
+long opoint -1;
 int m;
 int k; long lp;
 long *hpt;
 int m;
 int k; long lp;
 long *hpt;
-int *hfreq NULL;
+int *hfreq NULL;
 
 hpt = calloc (nhash+1, sizeof(*hpt));
 _assert (hpt != NULL);
 
 hpt = calloc (nhash+1, sizeof(*hpt));
 _assert (hpt != NULL);
@@ -64,18 +64,10 @@ putl(ll, f)
        long ll;
        FILE *f;
 {
        long ll;
        FILE *f;
 {
-int *x;
-x = &ll;
-putw(x[0], f);
-putw(x[1], f);
+putw(ll, f);
 }
 long getl(f)
        FILE *f;
 {
 }
 long getl(f)
        FILE *f;
 {
-int x[2];
-int *ll;
-x[0] = getw(f);
-x[1] = getw(f);
-ll = x;
-return (*ll);
+return(getw(f));
 }
 }
diff --git a/usr/src/cmd/refer/makefile b/usr/src/cmd/refer/makefile
deleted file mode 100644 (file)
index 25575b5..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-CFLAGS = -O -s
-
-all:   mkey inv hunt refer
-       :
-
-cp:    all
-       cp refer /bin
-       cp inv hunt mkey /usr/lib/refer
-       rm mkey inv hunt refer *.o
-
-cmp:   all
-       cmp refer /bin/refer
-       cmp inv /usr/lib/refer/inv
-       cmp hunt /usr/lib/refer/hunt
-       cmp mkey /usr/lib/refer/mkey
-       rm mkey inv hunt refer *.o
-
-mkey: mkey1.o mkey2.o mkey3.o deliv2.o
-       cc -s -n mkey?.o deliv2.o -o mkey
-inv: inv1.o inv2.o inv3.o inv5.o inv6.o deliv2.o
-       cc -s -n inv?.o deliv2.o -o inv
-hunt: hunt1.o hunt2.o hunt3.o hunt5.o hunt6.o hunt7.o glue5.o
-hunt: refer3.o hunt9.o shell.o deliv2.o hunt8.o glue4.o
-       cc -s -i hunt?.o refer3.o glue5.o glue4.o shell.o deliv2.o -o hunt
-deliv: deliv1.o deliv2.o
-       cc -s -n deliv?.o  -o deliv
-refpart: refer0.o refer1.o refer2.o refer3.o refer4.o refer5.o
-refpart: refer6.o refer7.o refer8.o deliv2.o glue4.o
-       cc -s -n refer?.o deliv2.o glue4.o  -o refpart
-refer0.o: refer..c
-refer1.o: refer..c
-refer2.o: refer..c
-refer3.o: refer..c
-refer4.o: refer..c
-refer6.o: refer..c
-refer: glue1.o refer1.o refer2.o refer4.o refer5.o refer6.o mkey3.o
-refer: refer7.o refer8.o hunt2.o hunt3.o deliv2.o hunt5.o hunt6.o hunt8.o
-refer: glue3.o hunt7.o hunt9.o glue2.o glue4.o glue5.o refer0.o shell.o
-       cc -s -i glue?.o refer[01245678].o hunt[2356789].o mkey3.o shell.o deliv2.o -o refer
-whatabout: what1.o what2.o what3.o what4.o shell.o mkey3.o
-       cc -s -n what?.o shell.o mkey3.o  -o whatabout
index 29a7efd..8fd266f 100644 (file)
@@ -5,7 +5,7 @@ int keycount = 100;
 int labels = 1;
 int minlen = 3;
 extern int comcount;
 int labels = 1;
 int minlen = 3;
 extern int comcount;
-char *iglist "XYZ#";
+char *iglist = "XYZ";
 
 main (argc,argv)
        char *argv[];
 
 main (argc,argv)
        char *argv[];
@@ -20,7 +20,7 @@ main (argc,argv)
 
 int i;
 char *name, qn[200];
 
 int i;
 char *name, qn[200];
-char *inlist 0;
+char *inlist 0;
 
 FILE *f, *ff;
 
 
 FILE *f, *ff;
 
index bda2005..94949b1 100644 (file)
@@ -1,7 +1,7 @@
 # include "stdio.h"
 # include "ctype.h"
 
 # include "stdio.h"
 # include "ctype.h"
 
-       static int eof 0;
+       static int eof 0;
        static long lp, lim;
        static int alph, used, prevc;
        static char *p, key[20];
        static long lp, lim;
        static int alph, used, prevc;
        static char *p, key[20];
@@ -68,8 +68,8 @@ long grec (s, f)
        FILE *f;
 {
        char tm[200];
        FILE *f;
 {
        char tm[200];
-       int curtype 0;
-       long len 0L, tlen 0L;
+       int curtype 0;
+       long len = 0L, tlen = 0L;
        extern int wholefile;
        if (eof) return(0);
        *s = 0;
        extern int wholefile;
        if (eof) return(0);
        *s = 0;
@@ -92,10 +92,11 @@ long grec (s, f)
        eof=1;
        return(s[0] ? len : 0L);
 }
        eof=1;
        return(s[0] ? len : 0L);
 }
+char *
 trimnl(ln)
        char *ln;
 {
 trimnl(ln)
        char *ln;
 {
-register char *p ln;
+register char *p ln;
 while (*p) p++;
 p--;
 if (*p == '\n') *p=0;
 while (*p) p++;
 p--;
 if (*p == '\n') *p=0;
index a608531..0787400 100644 (file)
@@ -1,10 +1,10 @@
 # include "stdio.h"
 # include "stdio.h"
-char *comname "/usr/lib/eign";
-static int cgate 0;
+char *comname "/usr/lib/eign";
+static int cgate 0;
 extern char *comname;
 # define COMNUM 500
 # define COMTSIZE 997
 extern char *comname;
 # define COMNUM 500
 # define COMTSIZE 997
-int comcount 100;
+int comcount 100;
 static char cbuf[COMNUM*9];
 static char *cwds[COMTSIZE];
 static char *cbp;
 static char cbuf[COMNUM*9];
 static char *cwds[COMTSIZE];
 static char *cbp;
index 1629ed7..d5cd565 100644 (file)
@@ -8,7 +8,7 @@ extern char comname;
 extern char *keystr;
 extern int authrev;
 extern int nmlen, dtlen;
 extern char *keystr;
 extern int authrev;
 extern int nmlen, dtlen;
-extern char *data[], **search;
+extern char *rdata[], **search;
 extern int refnum;
 extern char *reftable[];
 extern char *rtp, reftext[];
 extern int refnum;
 extern char *reftable[];
 extern char *rtp, reftext[];
@@ -19,6 +19,10 @@ extern char ofile[];
 extern char hidenam[];
 extern char *Ifile; extern int Iline;
 extern FILE *fo, *ftemp;
 extern char hidenam[];
 extern char *Ifile; extern int Iline;
 extern FILE *fo, *ftemp;
+extern char *input(),*lookat();
+extern char *class(),*caps(),*revauth();
+extern char *artskp(),*fpar();
+extern char *trimnl();
 # define FLAG 003
 # define NRFTXT 2000
 # define NTFILE 20
 # define FLAG 003
 # define NRFTXT 2000
 # define NTFILE 20
index e9a1bbd..caaa6a8 100644 (file)
@@ -1,27 +1,27 @@
 # include "stdio.h"
 # include "refer..c"
 FILE *in = stdin;
 # include "stdio.h"
 # include "refer..c"
 FILE *in = stdin;
-int endpush 0;
-int labels 0;
-int keywant 0;
-int sort 0;
-int bare 0;
-int authrev 0;
-char *smallcaps "";
-char *keystr "AD";
-int nmlen 0, dtlen 0;
-char *data[NSERCH];
-char **search data;
-int refnum 0;
+int endpush 0;
+int labels 0;
+int keywant 0;
+int sort 0;
+int bare 0;
+int authrev 0;
+char *smallcaps "";
+char *keystr "AD";
+int nmlen = 0, dtlen = 0;
+char *rdata[NSERCH];
+char **search = rdata;
+int refnum 0;
 char reftext[NRFTXT];
 char *reftable[NRFTBL];
 char reftext[NRFTXT];
 char *reftable[NRFTBL];
-char *rtp reftext;
-int sep '\n';
+char *rtp reftext;
+int sep '\n';
 char tfile[NTFILE];
 FILE *fo = stdout;
 FILE *ftemp = stdout;
 char ofile[NTFILE];
 char gfile[NTFILE];
 char hidenam[NTFILE];
 char tfile[NTFILE];
 FILE *fo = stdout;
 FILE *ftemp = stdout;
 char ofile[NTFILE];
 char gfile[NTFILE];
 char hidenam[NTFILE];
-char *Ifile "standard input";
-int Iline 0;
+char *Ifile "standard input";
+int Iline 0;
index a63c834..8aa8603 100644 (file)
@@ -34,7 +34,7 @@ while (argv[1][0] == '-')
                case 'p':
                        argc--; argv++;
                        *search++ = argv[1];
                case 'p':
                        argc--; argv++;
                        *search++ = argv[1];
-                       if (search-data>NSERCH)
+                       if (search-rdata>NSERCH)
                                err("too many -p options (%d)", NSERCH);
                        break;
                case 'n':
                                err("too many -p options (%d)", NSERCH);
                        break;
                case 'n':
index b323717..ccec3da 100644 (file)
@@ -3,15 +3,15 @@ extern FILE *in;
 # define NFLD 30
 # define TLEN 400
 char one[ANSLEN];
 # define NFLD 30
 # define TLEN 400
 char one[ANSLEN];
-int onelen ANSLEN;
-static char dr [100] "";
+int onelen ANSLEN;
+static char dr [100] "";
 doref(firline)
        char *firline;
 {
 char buff[QLEN], dbuff[3*QLEN], answer[ANSLEN], temp[TLEN];
 char line[LLINE];
 char *p, **sr, *flds[NFLD], *r;
 doref(firline)
        char *firline;
 {
 char buff[QLEN], dbuff[3*QLEN], answer[ANSLEN], temp[TLEN];
 char line[LLINE];
 char *p, **sr, *flds[NFLD], *r;
-int nf, nr, alph, query 0, chp, digs;
+int nf, nr, alph, query 0, chp, digs;
 
 /* get query */
 buff[0] = dbuff[0] = 0;
 
 /* get query */
 buff[0] = dbuff[0] = 0;
@@ -78,7 +78,7 @@ fprintf(stderr, "number, %d long, text is %s\n",digs,r);
 # endif
 one[0]=0;
 if (buff[0]) /* do not search if no query */
 # endif
 one[0]=0;
 if (buff[0]) /* do not search if no query */
-for( sr= data; sr < search; sr++)
+for( sr= rdata; sr < search; sr++)
        {
 # ifdef D1
        fprintf(stderr, "now searching %s\n", *sr);
        {
 # ifdef D1
        fprintf(stderr, "now searching %s\n", *sr);
@@ -156,7 +156,7 @@ fprintf(stderr, "put ref\n");
 newline(s)
        char *s;
 {
 newline(s)
        char *s;
 {
-int k 0, c;
+int k 0, c;
 while (c = *s++)
        if (c == '\n')
                k++;
 while (c = *s++)
        if (c == '\n')
                k++;
index e76fcc9..476d7c9 100644 (file)
@@ -1,5 +1,5 @@
 # include "refer..c"
 # include "refer..c"
-static gate 0;
+static gate 0;
 static char buff[LLINE];
 output (s)
        char *s;
 static char buff[LLINE];
 output (s)
        char *s;
@@ -53,10 +53,11 @@ if (gate)
 gate=0;
 }
 
 gate=0;
 }
 
+char *
 trimnl(ln)
        char *ln;
 {
 trimnl(ln)
        char *ln;
 {
-register char *p ln;
+register char *p ln;
 while (*p) p++;
 p--;
 if (*p == '\n') *p=0;
 while (*p) p++;
 p--;
 if (*p == '\n') *p=0;
index 1add422..748fe91 100644 (file)
@@ -6,7 +6,7 @@ static char sig[NLABC];
 
 static char bflab[NFLAB];
 static char *labtab[NLABC];
 
 static char bflab[NFLAB];
 static char *labtab[NLABC];
-static char *lbp bflab;
+static char *lbp bflab;
 static char labc[NLABC];
 static char stbuff[50];
 static int  prevsig;
 static char labc[NLABC];
 static char stbuff[50];
 static int  prevsig;
@@ -16,10 +16,10 @@ putsig (nf, flds, nref, nstline, endline)
 {
 /* choose signal style */
 char t[100], t1[100], t2[100], format[10], *sd;
 {
 /* choose signal style */
 char t[100], t1[100], t2[100], format[10], *sd;
-int another 0;
+int another 0;
 int addon;
 char *stline;
 int addon;
 char *stline;
-static FILE *fhide 0;
+static FILE *fhide 0;
 if (labels)
        {
        if (nf==0) /* old */
 if (labels)
        {
        if (nf==0) /* old */
@@ -133,11 +133,12 @@ if (bare>0)
 fprintf(stderr, "sig is now %s\n",sig);
 # endif
 }
 fprintf(stderr, "sig is now %s\n",sig);
 # endif
 }
+char *
 fpar (nf, flds, out, c, seq, prepend)
        char *flds[], *out;
 {
 char *p, *s;
 fpar (nf, flds, out, c, seq, prepend)
        char *flds[], *out;
 {
 char *p, *s;
-int i, fnd 0;
+int i, fnd 0;
 for(i=0; i<nf; i++)
        if (flds[i][1]==c && ++fnd >= seq)
                {
 for(i=0; i<nf; i++)
        if (flds[i][1]==c && ++fnd >= seq)
                {
@@ -198,7 +199,7 @@ keylet(t, nref)
        char *t;
 {
 int i;
        char *t;
 {
 int i;
-int x 'a'-1;
+int x 'a'-1;
 for(i=1; i<nref;i++)
        {
        if (strcmp(labtab[i], t) == 0)
 for(i=1; i<nref;i++)
        {
        if (strcmp(labtab[i], t) == 0)
@@ -236,7 +237,7 @@ while (n-- && (c= *t++)>0)
 initadd(to, from, stop)
        char *to, *from, *stop;
 {
 initadd(to, from, stop)
        char *to, *from, *stop;
 {
-       int c, nalph 1;
+       int c, nalph 1;
 while (*to) to++;
 while (from<stop)
        {
 while (*to) to++;
 while (from<stop)
        {
@@ -254,7 +255,8 @@ while (from<stop)
 *to=0;
 }
 
 *to=0;
 }
 
-static char *articles[] {"the ", "an ", "a ", 0};
+static char *articles[] = {"the ", "an ", "a ", 0};
+char *
 artskp(s)
        char *s;
 {
 artskp(s)
        char *s;
 {
index 21bdb65..56340ef 100644 (file)
@@ -4,8 +4,8 @@ putref (n, tvec)
 {
 char *s, *tx;
 char buf1[LLINE], buf2[50];
 {
 char *s, *tx;
 char buf1[LLINE], buf2[50];
-int nauth 0, i, lastype 0, cch, macro 0, la;
-int lauth =0, ltitle =0, lother =0;
+int nauth = 0, i, lastype = 0, cch, macro = 0, la;
+int lauth = 0, ltitle = 0;
 
 fprintf(fo, ".]-%c", sep);
 # define dsde (macro? "de" : "ds")
 
 fprintf(fo, ".]-%c", sep);
 # define dsde (macro? "de" : "ds")
@@ -97,21 +97,18 @@ fprintf(stderr, " s %o tx %o %s\n",s,tx,tx);
        lastype = cch;
        if (cch == 'T')
                ltitle = (mindex(".;,?", last(tx)) != 0);
        lastype = cch;
        if (cch == 'T')
                ltitle = (mindex(".;,?", last(tx)) != 0);
-       if (cch == 'O')
-               lother = (mindex(".;,?", last(tx)) != 0);
        }
 if (lastype && macro)
        fprintf(fo, "..%c", sep);
 fprintf(fo, ".nr [T %d%c", ltitle, sep);
 fprintf(fo, ".nr [A %d%c", lauth, sep);
        }
 if (lastype && macro)
        fprintf(fo, "..%c", sep);
 fprintf(fo, ".nr [T %d%c", ltitle, sep);
 fprintf(fo, ".nr [A %d%c", lauth, sep);
-fprintf(fo, ".nr [O %d%c", lother, sep);
 fprintf (fo, ".][ %s%c", class(n, tvec), '\n');
 }
 tabs (sv, line)
        char *sv[], *line;
 {
 char *p;
 fprintf (fo, ".][ %s%c", class(n, tvec), '\n');
 }
 tabs (sv, line)
        char *sv[], *line;
 {
 char *p;
-int n 0;
+int n 0;
 sv[n++] = line;
 for( p= line; *p; p++)
        {
 sv[n++] = line;
 for( p= line; *p; p++)
        {
@@ -123,6 +120,7 @@ for( p= line; *p; p++)
        }
 return(n-1);
 }
        }
 return(n-1);
 }
+char *
 class (nt, tv)
        char *tv[];
 {
 class (nt, tv)
        char *tv[];
 {
@@ -149,6 +147,7 @@ for(i=0; i<nt; i++)
                return(1);
 return(0);
 }
                return(1);
 return(0);
 }
+char *
 caps(a, b)
        char *a, *b;
 {
 caps(a, b)
        char *a, *b;
 {
@@ -188,6 +187,7 @@ if (alph>1)
 *b=0;
 return (p);
 }
 *b=0;
 return (p);
 }
+char *
 revauth(s, b)
        char *s, *b;
 {
 revauth(s, b)
        char *s, *b;
 {
index 71e0fa7..af8e05c 100644 (file)
@@ -21,10 +21,9 @@ return(0);
 dumpold()
 {
 FILE *fi;
 dumpold()
 {
 FILE *fi;
-int c, g1 0, nr 1;
+int c, g1 = 0, nr = 1;
 if (!endpush) return;
 fclose(fo);
 if (!endpush) return;
 fclose(fo);
-fo=NULL;
 if (sort)
        {
        char comm[100];
 if (sort)
        {
        char comm[100];
@@ -48,7 +47,7 @@ while ( (c = getc(fi)) >0)
                {
                /* make old-new ref number table */
                char tb[20];
                {
                /* make old-new ref number table */
                char tb[20];
-               char *s tb;
+               char *s tb;
                while ( (c=getc(fi)) != FLAG)
                        *s++ = c;
                *s=0;
                while ( (c=getc(fi)) != FLAG)
                        *s++ = c;
                *s=0;
@@ -86,7 +85,7 @@ while ( (c = getc(ftemp)) != EOF)
        if (c == FLAG)
                {
                char tb[10];
        if (c == FLAG)
                {
                char tb[10];
-               char *s tb;
+               char *s tb;
                while ( (c = getc(ftemp)) != FLAG)
                        *s++ = c;
                *s=0;
                while ( (c = getc(ftemp)) != FLAG)
                        *s++ = c;
                *s=0;
index 59e3580..6ea018a 100644 (file)
@@ -1,7 +1,8 @@
 # include "refer..c"
 static char ahead[1000];
 # include "refer..c"
 static char ahead[1000];
-static int peeked 0;
-static int noteof 1;
+static int peeked = 0;
+static int noteof = 1;
+char *
 input (s)
        char *s;
 {
 input (s)
        char *s;
 {
@@ -14,6 +15,7 @@ if (peeked)
        }
 return(fgets(s, 1000, in));
 }
        }
 return(fgets(s, 1000, in));
 }
+char *
 lookat()
 {
 if (peeked) return(ahead);
 lookat()
 {
 if (peeked) return(ahead);
diff --git a/usr/src/cmd/refer/sample b/usr/src/cmd/refer/sample
new file mode 100644 (file)
index 0000000..9fd5757
--- /dev/null
@@ -0,0 +1,1737 @@
+%A A. V. Aho
+%A C. Beeri
+%A J. D. Ullman
+%T The  Theory of Joins in Relational Databases
+%J Proc. 18th IEEE Symp. on Foundations of Computer Science
+%D 1977
+
+%A A. V. Aho
+%A Y. Sagiv
+%A J. D. Ullman
+%T Equivalence of Relational Expressions
+%O unpublished
+%D 1977
+
+%A W. W. Armstrong
+%T Dependency Structures of Data Base Relationships
+%J Proc. IFIP 74
+%I North Holland
+%D 1974
+%P 580-583
+
+%A P. A. Bernstein
+%A C. Beeri
+%T An Algorithmic Approach to Normalization of Relational Database Schemes
+%R TR CSRG-7B
+%I Computer Science Research Group, University of Toronto
+%D September 1976
+
+%A C. Beeri
+%A R. Fagin
+%A J. H. Howard
+%T A Complete Axiomatization for Functional and Multivalued Dependencies
+%R RJ1977
+%I IBM, San Jose, California
+%D 1977
+
+%A A. K. Chandra
+%A P. M. Merlin
+%T Optimal Implementation of Conjunctive Queries in Relational Data Bases
+%J Proc. 9th ACM Symp. on Theory of Computing
+%D 1976
+%P 77-90
+
+%A E. F. Codd
+%T A Relational Model for Large Shared Data Bases
+%J Comm. Assoc. Comp. Mach.
+%K acm cacm
+%V 13
+%N 6
+%D June 1970
+%P 377-387
+
+%A E. F. Codd
+%T Further Normalization of the Data Base Relational Model
+%B Data Base Systems
+%E R. Rustin
+%I Prentice Hall
+%C Englewood Cliffs, N. J
+%D 1972
+%P 33-64
+
+%A E. F. Codd
+%T Relational Completeness of Data Base Sublanguages
+%B Data Base Systems
+%E R. Rustin
+%I Prentice-Hall
+%C Englewood Cliffs, N. J
+%D May 1971
+%P 65-98
+
+%A S. A. Cook
+%T The Complexity of Theorem Proving Procedures
+%J Proc. 3rd ACM Symp. on Theory of Computing
+%D May 1971
+%P 151-158
+
+%A C. J. Date
+%T An Introduction to Database Systems
+%I Addison-Wesley
+%C Reading, Mass
+%D 1975
+
+%A C. Delobel
+%T Contributions Theoretiques a la Conception d'un Systeme d'informations
+%O Ph. D. thesis, Univ. of Grenoble, Oct
+%D 1973
+
+%A R. Fagin
+%T Multivalued Dependencies and a New Normal Form for Relational Databases
+%J ACM Trans. Data Base Systems
+%V 2
+%N 3
+%D September 1977
+%P 262-278
+
+%A P. A. V. Hall
+%T Optimization of a Single Relational Expression in a Relational
+Database System
+%J IBM J. Research and Development
+%D May 1976
+%P 244-257
+
+%A R. M. Karp
+%T Reducibility Among Combinatorial Problems
+%B Complexity of Computer Computations
+%E R. E. Miller and J. W. Thatcher
+%I Plenum Press
+%C New York
+%D 1972
+%P 85-104
+
+%A C. L. Lucchesi
+%A S. L. Osborn
+%T Candidate Keys for Relations
+%J J. Comp. Sys. Sci.
+%O (To appear; available from Department of Computer Science, University of Waterloo).
+%D 1976
+
+%A J. Minker
+%T Performing Inferences over Relational Databases
+%R TR363, Department of Computer Science
+%I University of Maryland
+%D March 1975
+
+%A R. M. Pecherer
+%T Efficient Evaluation of Expressions in a Relational Algebra
+%J Proc. ACM Pacific Conf.
+%D April 1975
+%P 44-49
+
+%A F. P. Palermo
+%T A Database Search Problem
+%B Information Systems COINS IV
+%E J. T. Tou
+%I Plenum Press
+%C New York
+%D 1974
+
+%A J. Rissanen
+%T Independent Components of Relations
+%R RJ1899, IBM, San Jose, California
+%D 1977
+
+%A Y. Sagiv
+%A M. Yannakakis
+%T unpublished
+
+%A J. M. Smith
+%A P. Y.\(hyT. Chang
+%T Optimizing the Performance of a Relational Algebra Database Interface
+%J Comm. Assoc. Comp. Mach.
+%K acm cacm
+%V 18
+%N 10
+%D October 1975
+
+%A M. Stonebraker
+%A L. A. Rowe
+%T Observations on Data Manipulation Languages and their
+Embedding in General Purpose Programming Languages
+%R TR UCB/ERL M77-53
+%D July 1977
+%I University of California, Berkeley
+
+%A E. Wong
+%A K. Youssefi
+%T Decomposition \(em a Strategy for Query Processing
+%J ACM Trans. Data Base Systems
+%V 1
+%N 3
+%D September 1976
+%P 223-241
+
+%A C. Zaniolo
+%T Analysis and Design of Relational Schemata for Database Systems
+%R Tech. Rept. UCLA-ENG-7769
+%I Department of Computer Science, UCLA
+%D July 1976
+
+%A M. M. Zloof
+%T Query-by-Example: the Invocation and Definition of Tables and Forms
+%J Proc. ACM International Conf. on Very Large Data Bases
+%D September 1975
+%P 1-24
+
+%A S. K. Abdali
+%T A lambda calculus model of programming languages \(em I. simple constructs
+%J J. Comp. Languages
+%V 1
+%D 1976
+%P 287-301
+
+%A S. K. Abdali
+%T A lambda calculus model of programming languages \(em II. jumps and procedures
+%J J. Comp. Languages
+%V 1
+%D 1976
+%P 303-320
+
+%A ADJ (J. A. Goguen, J. W. Thatcher, E. G. Wagner and J. B Wright)
+%T A junction between category theory and computer science, I: basic concepts and examples (Part 1)
+%R Report RC 4526
+%I IBM Research
+%C Yorktown Heights, N. Y.
+%K part1
+%D September 1973
+
+%A ADJ (J. A. Goguen, J. W. Thatcher, E. G. Wagner and J. B Wright)
+%T A junction between category theory and computer science, I: basic concepts and examples (Part 2)
+%R Report RC 5908
+%I IBM Research
+%K part2
+%C Yorktown Heights, N. Y.
+%D March 1976
+
+%A L. Ammeraal
+%T How program statements transform predicates
+%R Report IW 39/75
+%I Mathematisch Centrum
+%C Amsterdam
+%D December 1975
+
+%A L. Ammeraal
+%T On forward and backward proof rules for program verification
+%R Report IW 65/76
+%I Mathematisch Centrum
+%C Amsterdam
+%D November 1976
+
+%A E. R. Anderson
+%A F. C. Belz
+%A E. K. Blum
+%T Semanol (73) A metalanguage for programming the semantics of programming languages
+%J Acta Informatica
+%V 6
+%D 1976
+%P 109-131
+
+%A K. R. Apt
+%T Equivalence of operational and denotational semantics for a fragment of Pascal
+%R Report IW 71/76
+%I Mathematisch Centrum
+%C Amsterdam
+%D December 1976
+
+%A K. R. Apt
+%A J. W. de Bakker
+%T Exercises in denotational semantics
+%J Lecture Notes in Computer Science
+%V 45
+%D 1976
+%P 1-11
+
+%A K. R. Apt
+%A J. W. de Bakker
+%T Semantics and proof theory of Pascal procedures
+%J Lecture Notes in Computer Science
+%V 52
+%D 1977
+%P 30-44
+
+%A K. R. Apt
+%A L. G. L. T. Meertens
+%T Completeness with finite systems of intermediate assertions for recursive program schemas
+%R Report IW 84/77
+%I Mathematisch Centrum
+%C Amsterdam
+%D September 1977
+
+%A A. Arnold
+%A M. Nivat
+%T Non deterministic recursive program schemes
+%D 1977
+
+%A A. Arnold
+%A M. Nivat
+%T On nondeterministic program schemes
+%D 1977
+
+%A E. A. Ashcroft
+%A Maurice Clint
+%A C. A. R. Hoare
+%T Remarks on ``Program proving: jumps and functions by M. Clint and C. A. R. Hoare''
+%J Acta Informatica
+%V 6
+%D 1976
+%P 317-318
+
+%A J. W. Backus
+%A R. J. Beeber
+%A S. Best
+%A R. Goldberg
+%A L. M. Haibt
+%A H. L. Herrick
+%A R. A. Nelson
+%A D. Sayre
+%A P. B. Sheridan
+%A H. Stern
+%A I. Ziller
+%A R. A. Hughes
+%A R. Nutt
+%T The Fortran automatic coding system
+%J Western Computer Proceedings
+%D 1957
+%P 188-198
+
+%A J. P. Banatre
+%T Producing optimised code for coercions
+%J Information Processing Letters
+%V 6
+%N 2
+%D April 1977
+%P 56-59
+
+%A Henk Barendregt
+%T A global representation of the recursive functions in the $lambda -$claculus
+%J Theor. Comp. Sci.
+%V 3
+%D 1976
+%P 225-242
+
+%A H. Bekic
+%T Towards a mathematical theory of processes
+%R TR 25.125
+%I IBM Laboratory
+%C Vienna
+%D December 1971
+
+%A G. Berry
+%T Bottom-up computation of recursive programs
+%R Rapport de Recherche No 133
+%I IRIA
+%C Rocquencourt, France
+%D September 1975
+
+%A Gerard Berry
+%A Bruno Courcelle
+%T Program equivalence and canonical forms in stable discrete interpretations
+%E S. Michaelson and R. Milner
+%B Automata Languages and Programming , Third International Colloquium
+%I Edinburgh University Press
+%D July 1976
+%P 168-188
+
+%A Gerard Berry
+%A J. J. Levy
+%T Minimal and optimal computations of recursive programs
+%J J. Assoc. Comp. Mach.
+%K acm jacm
+%D to appear
+
+%A Richard Bird
+%T Programs and Machines
+%I John Wiley
+%C New York, N. Y.
+%D 1976
+
+%A A. Blikle
+%T Programs with subscripted variables
+%J Bulletin de L'Academie Polonaise des Sciences, Serie des sciences math., astr. et phys.
+%V XIX
+%N 9
+%D 1971
+%P 853-857
+
+%A C. Bohm
+%T The CUCH as a formal and description language
+%E T. B. Steel, Jr.
+%B Formal language description languages for computer programming
+%I North-Holland
+%C Amsterdam
+%D 1966
+%P 179-197
+
+%A H. J. Boom
+%T Extended type checking
+%R Report IW 60/76
+%I Mathematisch Centrum
+%C Amsterdam
+%D September 1976
+
+%A S. R. Bourne
+%A A. D. Birrell
+%A I. Walker
+%T Algol 68C Reference Manual
+%I Computer Laboratory, Cambridge University
+%C Cambridge, England
+%D 1975
+
+%A R. S. Boyer
+%A J. S. Moore
+%T A computer proof of the correctness of a simple optimizing compiler for expressions
+%R Tech. Rep. 5
+%I SRI
+%C Menlo Park, Ca.
+%D January 1977
+
+%A J. M. Boyle
+%A A. A. Grau
+%T An algorithmic semantics for Algol 60 identifier denotation
+%J J. Assoc. Comp. Mach.
+%K acm jacm
+%V 17
+%N 2
+%D April 1970
+%P 361-382
+
+%A R. M. Burstall
+%T Semantics of assignment
+%E Ella Dale and Donald Michie
+%B Machine Intelligence 2
+%I American Elsevier
+%C New York
+%D 1968
+%P 3-20
+
+%A R. M. Burstall
+%T Proving properties of programs by structural induction
+%J Comp. J.
+%P 41-48
+
+%A R. M. Burstall
+%T Some techniques for proving properties of programs which alter data structures
+%B Machine Intelligence
+
+%A E. M. Clarke, Jr.
+%T Program invariants as fixed points
+%J Proc. 18th IEEE Symp. on Foundations of Computer Science
+%D October 1977
+%P 18-29
+
+%A Maurice Clint
+%T Program proving: coroutines
+%J Acta Informatica
+%V 2
+%N 1
+%D 1973
+%P 50-63
+
+%A Maurice Clint
+%A C. A. R. Hoare
+%T Program proving:jumps and functions
+%J Acta Informatica
+%V 1
+%D 1972
+%P 214-224
+%O see also Ashcroft, Clint and Hoare (1976)
+
+%A S. A. Cook
+%T Soundness and completeness of an axiom system for program verification
+%J SIAM J. Computing
+%D to appear
+
+%A S. A. Cook
+%A D. C. Oppen
+%T An assertion language for data structures
+%J Proc. 2nd ACM Symp. on Principles of Programming Languages
+%D January 1975
+%P 160-166
+
+%A D. C. Cooper
+%T Program scheme equivalences and second-order logic
+%B Machine Intelligence
+%P 3-15
+
+%A Bruno Courcelle
+%T On the definition of classes of interpretations
+%R Rapport de Recherche No 231
+%I IRIA
+%C Rocquencourt, France
+%D May 1977
+
+%A B. Courcelle
+%A I. Guessarian
+%T On some classes of interpretations
+%R Rapport de Recherche No 253
+%I IRIA
+%C Rocquencourt, France
+%D September 1977
+
+%A Bruno Courcelle
+%A Jean Vuillemin
+%T Completeness results for the equivalence of recursive schema
+%J J. Comp. Sys. Sci.
+%V 12
+%D 1976
+%P 179-197
+
+%A Karel Culik II
+%T A model for the formal definition of programming languages
+%J Int. J. Comp. Math.
+%V 3
+%D 1973
+%P 315-345
+
+%A R. J. Cunningham
+%A M. E. J. Guilford
+%T A note on the semantic definition of side effects
+%J Information Processing Letters
+%V 4
+%N 5
+%D February 1976
+%P 118-120
+
+%A Ole-Johan Dahl
+%A Bjorn Myhrhaug
+%A Kristen Nygaard
+%T Simula 67: common base language
+%R Publication S-22
+%I Norwegian Computing Centre
+%C Oslo, Norway
+%D October 1970
+
+%A J. W. de Bakker
+%T Semantics of programming languages
+%E J. T. Tou
+%B Advances in Information Systems Science, Vol. 2
+%I Plenum Press
+%C New York, N. Y.
+%D 1969
+%P 173-227
+
+%A J. W. de Bakker
+%T Recursive Procedures
+%I Mathem\ 1atical Centre Tracts 24, Mathematisch Centrum
+%C Amsterdam
+%D 1971
+
+%A J. W. de Bakker
+%T Recursion, induction and symbol manipulation
+%B Informatica Symposium 1971
+%I Mathematisch Centre Tracts 25, Mathematisch Centrum
+%D 1971
+
+%A J. W. de Bakker
+%T Axiom systems for simple assignment statements
+%J Lecture Notes in Mathematics
+%V 188
+%D 1971
+%P 1-22
+
+%A J. W. de Bakker
+%T A property of linear conditionals
+%J Lecture Notes in Mathematics
+%V 188
+%D 1971
+%P 23-27
+
+%A J. W. de Bakker
+%T The fixpoint approach in semantics: theory and applications
+%E J. W. de Bakker
+%B Foundations of Computer Science
+%I Mathematical Centre Tracts 63
+%C Amsterdam
+%D 1975
+%P 3-53
+
+%A J. W. de Bakker
+%T Least fixed points revisited
+%J Theor. Comp. Sci.
+%V 2
+%D 1976
+%P 155-181
+
+%A J. W. de Bakker
+%A J. W. de Bakker
+%T Fixed point semantics and Dijkstra's fundamental invariance theorem
+%R Report IW 29/76
+%I Mathematisch centrum
+%C Amsterdam
+%D January 1976
+
+%A J. W. de Bakker
+%T Correctness proofs for assignment statements
+%R Report IW 55/76
+%I Mathematisch Centrum
+%C Amsterdam
+%D 1976
+
+%A J. W. de Bakker
+%T Semantics and the foundations of program proving
+%E B. Gilchrist
+%B Information Processing 77
+%I North-Holland
+%C Amsterdam
+%D 1977
+%P 279-284
+
+%A J. W. de Bakker
+%T Recursive programs as predicate transformers
+%E E. Neuhold
+%B IFIP Working Conference on the Formal Description of Programming Concepts
+%I North-Holland
+%C Amsterdam
+%D to appear
+
+%A J. W. de Bakker
+%A L. G. L. T. Meertens
+%T On the completeness of the inductive assertion method
+%J J. Comp. Sys. Sci.
+%V 11
+%D 1975
+%P 323-357
+
+%A J. W. de Bakker
+%A Dana Scott
+%T A theory of programs
+%R unpublished
+%D August 1969
+
+%A Mariangiola Dezani-Ciancaglini
+%A Maddalena Zacchi
+%T Application of Church-Rosser properties to increase the parallelism and efficiency of algorithms
+%J Lecture Notes in Computer Science
+%V 14
+%D 1974
+
+%A E. W. Dijkstra
+%T A Discipline of Programming
+%I Prentice Hall
+%C Englewood Cliffs, N. J.
+%D 1976
+
+%A J. E. Donahue
+%T The mathematical semantics of axiomatically defined programming language constructs
+%E G. Huet and G. Kahn
+%B Proving and Improving Programs
+%I IRIA
+%C Rocquencourt, France
+%D July 1975
+%P 353-367
+
+%A J. E. Donahue
+%T Complementary Definitions of Programming Language Semantics
+%J Lecture Notes in Computer Science
+%V 42
+%D 1976
+
+%A J. E. Donahue
+%T Locations considered unnecessary
+%J Acta Informatica
+%V 8
+%D 1977
+%P 221-242
+
+%A H. Egli
+%T A mathematical model for non-deterministic computations
+%D September 1975
+
+%A Herbert Egli
+%A Robert L. Constable
+%T Computability concepts for programming language semantics
+%J Theor. Comp. Sci.
+%V 2
+%D 1976
+%P 133-145
+
+%A G. W. Ernst
+%T Rules of inference for procedure calls
+%J Acta Informatica
+%V 8
+%D 1977
+%P 145-152
+
+%A R. W. Floyd
+%T Assigning meanings to programs
+%E J. T. Schwartz
+%B Mathematical Aspects of Computer Science, Proceedings of a Symposium in Applied Mathematics, Vol. 19
+%I American Math. Soc.
+%C Providence, R. I.
+%D 1967
+%P 19-32
+
+%A Nissim Francez
+%A Boris Klebansky
+%A Amir Pnueli
+%T Backtracking in recursive computations
+%J Acta Informatica
+%V 8
+%D 1977
+%P 125-144
+
+%A Jan V. Garwick
+%T The definition of programming languages by their compilers
+%E T. B. Steel, Jr.
+%B Formal Language Description Languages for Computer Programming
+%I North-Holland
+%C Amsterdam
+%D 1966
+%P 139-147
+
+%A Michael Gordon
+%T Operational reasoning and denotational semantics
+%E G. Huet and G. Kahn
+%B Proving and Improving Programs
+%I IRIA
+%C Rocquencourt, France
+%D July 1975
+%P 83-98
+
+%A G. A. Gorelick
+%T A complete axiomatic system for proving assertions about recursive and nonrecursive programs
+%R Tech. Rep. 75
+%I Department of Computer Science, University of Toronto
+%D January 1975
+
+%A David Gries
+%T Assignment to subscripted variables
+%R TR 77-305
+%I Department of Computer Science, Cornell University
+%D September 1976
+
+%A David Gries
+%T An illustration of current ideas on the derivation of correctness proofs and correct programs
+%J IEEE Trans. on Software Engineering
+%V SE-2
+%N 4
+%D December 1976
+%P 238-244
+
+%A David Gries
+%A Narain Gehani
+%T Some ideas on data types in high level languages
+%J Comm. Assoc. Comp. Mach.
+%K acm cacm
+%V 20
+%N 6
+%D July 1976
+%P 414-420
+
+%A D. Grune
+%T A view of coroutines
+%R Report IW 63/76
+%I Mathematisch Centrum
+%C Amsterdam
+%D November 1976
+
+%A Irene Guessarian
+%T Semantic equivalence of program schemes and its syntactic characterization
+%E S. Michaelson and R. Milner
+%B Automata, Languages and Programming, Third International Colloquium
+%I Edinburgh University Press
+%D July 1976
+%P 189-200
+
+%A I. Guessarian
+%T Sur quelques applications de la semantique algebrique des schemas recursifs polyadiques
+%D 1977
+
+%A John Guttag
+%T Abstract data types and the development of data structures
+%J Comm. Assoc. Comp. Mach.
+%K acm cacm
+%V 20
+%N 6
+%D July 1976
+%P 396-404
+
+%A J. V. Guttag
+%A Ellis Horowitz
+%A D. R. Musser
+%T Abstract data types and software validation
+%R Report ISI/RR-76-48
+%I Information Sciences Institute, University of Southern California
+%C Los Angeles, Ca.
+%D August 1976
+
+%A J. V. Guttag
+%A Ellis Horowitz
+%A D. R. Musser
+%T The design of data type specifications
+%R Report ISI/RR-76-49
+%I Information Sciences Institute, Univeristy of Southern California
+%C Los Angeles, Ca.
+%D November 1976
+
+%A D. Harel
+%T Arithmetical completeness in logics of programs
+%D September 1977
+
+%A David Harel
+%T On the correctness of regular deterministic programs; a unifying survey
+%D November 1977
+
+%A D. Harel
+%T Complete axiomatization of properties of recursive programs (extended abstract)
+%D November 1977
+
+%A David Harel
+%A Amir Pnueli
+%A Jonathan Stavi
+%T A complete axiomatic system for proving deductions about recursive programs
+%J Ninth ACM Symp. Theory of Computing
+%D May 1977
+%P 249-260
+
+%A D. Harel
+%A V. R. Pratt
+%T Nondeterminism in logics of programs
+%J Proc. 5th ACM Symp. on Principles of Programming Languages
+%D January 1978
+
+%A William Harrison
+%T Formal semantics of a schematic intermediate language
+%R Report RC 6271
+%I IBM Research
+%C Yorktown Heights, N. Y.
+%D November 1976
+
+%A R. Haskell
+%T Efficient implementation of a class of recursively defined functions
+%J Comp. J.
+%V 18
+%N 1
+%D 1975
+%P 23-29
+
+%A Peter Henderson
+%A J. H. Morris, Jr.
+%T A lazy evaluator
+%J Proc. 3rd ACM Symp. on Principles of Programming Languages
+%D January 1976
+%P 95-103
+
+%A M. C. B. Hennessy
+%T Parameter passing mechanisms and non-determinism
+
+%A M. C. B. Hennessy
+%A E. A. Ashcroft
+%T The semantics of nondeterminism
+%R Report CS-76-17
+%I Department of Computer Science, University of Waterloo
+%D April 1976
+
+%A C. A. R. Hoare
+%T An axiomatic basis for computer programming
+%J Comm. Assoc. Comp. Mach.
+%K acm cacm
+%V 12
+%N 10
+%D October 1969
+%P 576-580,583
+
+%A C. A. R. Hoare
+%T Procedures and parameters: an axiomatic approach
+%J Lecture Notes in Mathematics
+%V 188
+%D 1971
+%P 102-116
+
+%A C. A. R. Hoare
+%T Proof of correctness of data representations
+%J Acta Informatica
+%V 1
+%D 1972
+%P 271-281
+
+%A C. A. R. Hoare
+%T Hints on programming language design
+%O Invited address at ACM Symposium on Principles of Programming Languages.
+%D October 1973
+
+%A C. A. R. Hoare
+%T Some properties of non-deterministic computations
+
+%A C. A. R. Hoare
+%A P. E. Lauer
+%T Consistent and complementary formal theories of the semantics of programming languages
+%J Acta Informatica
+%V 3
+%D 1974
+%P 135-153
+
+%A C. M. Hoffman
+%T Design and correctness of a compiler for Lucid
+%R Research Report CS-76-20
+%I Computer Science Department, University of Waterloo
+%D May 1976
+
+%A C. M. Hoffman
+%A L. H. landweber
+%T A completeness theorem for straight-line programs with structured variables
+%J J. Assoc. Comp. Mach.
+%K acm jacm
+%V 23
+%N 1
+%D January 1976
+%P 203-220
+
+%A Chiharu Hosono
+%A Masahiko Sato
+%T The retracts in $P omega$ do not form a continuous lattice \(em a solution to Scott's problem
+%J Theor. Comp. Sci.
+%V 4
+%D 1977
+%P 137-142
+
+%A Gerard Huet
+%T Confluent Reductions: Abstract Properties and Applications to Term Rewriting Systems
+%J Proc. 18th IEEE Symp. on Foundations of Computer Science
+%D October 1977
+%P 30-45
+
+%A Gerard Huet
+%A Bernard Lang
+%T Program transformations in classes of interpretations
+%O Lecture Notes
+%D May 1976
+
+%A Shigeru Igarashi
+%T Semantics of Algol-like statements
+%J Lecture Notes in Mathematics
+%V 188
+%D 1971
+%P 117-177
+
+%A Shigeru Igarashi
+%A R. L. London
+%A D. C. Luckham
+%T Automatic program verification I: a logical basis and its implementation
+%J Acta Informatica
+%V 4
+%D 1975
+%P 145-182
+
+%A Kurt Jensen
+%T An investigation into different semantic approaches
+%R Report DAIMI PB-61
+%I Department of Computer Science, University of Aarhus
+%D June 1976
+
+%A Gilles Kahn
+%T An approach to systems correctness
+
+%A Gilles Kahn
+%T The semantics of a simple language for parallel programming
+%E J. L. Rosenfeld
+%B Information Processing 74
+%I North-Holland
+%C Amsterdam
+%D 1974
+%P 471-475
+
+%A Gilles Kahn
+%A D. B. MacQueen
+%T Coroutines and networks of parallel processes
+%E B. Gilchrist
+%B Information Processing 77
+%I North-Holland
+%C Amsterdam
+%D 1977
+%P 993-998
+
+%A D. M. Kaplan
+%T Some completeness results in the mathematical theory of computation
+%J J. Assoc. Comp. Mach.
+%K acm jacm
+%V 15
+%N 1
+%D January 1968
+%P 124-134
+
+%A R. M. Keller
+%T Denotational models for parallel programs with indeterminate operators
+%E E. Neuhold
+%B IFIP Working Conference on the Formal Description of Programming Concepts
+%I North-Holland
+%C Amsterdam
+%D to appear
+
+%A D. E. Knuth
+%A P. B. Bendix
+%T Simple word problems in universal algebras
+%E J. Leech
+%B Computational Problems in Abstract Algebra
+%I Pergamon Press
+%C Oxford
+%D 1970
+%P 263-297
+
+%A D. E. Knuth
+%A L. Trabb Pardo
+%T Early development of programming languages
+%B Encyclopedia of Computer Science and Technology, Vol. 7
+%I Marcel Dekker
+%C New York, N. Y.
+%D 1977
+%P 419-493
+%R STAN-CS-76-562
+
+%A J. Kral
+%T On the equivalence of modes and the equivalence of finite automata
+%J ALGOL Bulletin
+%N 35
+%D March 1973
+%P 34-35
+
+%A P. J. Landin
+%T The mechanical evaluation of expressions
+%J Comp. J.
+%V 6
+%N 4
+%D January 1964
+%P 308-320
+
+%A P. J. Landin
+%T A correspondence between Algol 60 and Church's lambda-notation
+%J Comm. Assoc. Comp. Mach.
+%K acm cacm
+%V 8
+%N 2,3
+%D February and March 1965
+%P 89-101 and 158-165
+
+%A P. J. Landin
+%T A formal description of Algol 60
+%E T. B. Steel, Jr.
+%B Formal Language Description Languages for Computer Programming
+%I North-Holland
+%C Amsterdam
+%D 1966
+%P 266-294
+
+%A P. J. Landin
+%T The next 700 programming languages
+%J Comm. Assoc. Comp. Mach.
+%K acm cacm
+%V 9
+%N 3
+%D March 1966
+%P 157-166
+
+%A P. J. Landin
+%T A $lambda -$calculus approach
+%E L. Fox
+%B Advances in Programming and Non-numerical Computation
+%I Pergammon Press
+%C Oxford
+%D 1966
+%P 97-141
+
+%A Hans Langmaack
+%T On correct procedure parameter transmission in higher programming languages
+%J Acta Informatica
+%V 2
+%D 1973
+%P 110-142
+
+%A D. Lankford
+%T On deciding word problems by rewrite rule simplifiers
+%D September 1977
+
+%A H. F. Ledgard
+%T A model for type checking \(em with an application to Algol 60
+%J Comm. Assoc. Comp. Mach.
+%K acm cacm
+%V 15
+%N 11
+%D November 1972
+%P 956-
+
+%A J. A. N. Lee
+%T The formal definition of the Basic language
+%J Comp. J.
+%V 15
+%N 1
+%D February 1972
+%P 37-41
+
+%A D. J. Lehmann
+%A M. B. Smyth
+%T Data types
+%J Proc. 18th IEEE Symp. on Foundations of Computer Science
+%D October 1977
+%P 7-12
+
+%A G. T. Ligler
+%T Proof rules, mathematical semantics and programming language design
+%D 1975
+
+%A G. T. Ligler
+%T Surface properties of programming language constructs
+%J Theor. Comp. Sci.
+%D to appear
+
+%A R. J. Lipton
+%T A necessary and sufficient condition for the existence of Hoare logics
+%J Proc. 18th IEEE Symp. on Foundations of Computer Science
+%D October 1977
+%P 1-6
+
+%A R. L. London
+%T A bibliography on proving the correctness of programs
+%E B. Meltzer
+%E D. Michie
+%B Machine Intelligence 5
+%I Edinburgh University Press, Edinburgh, and American Elsevier, New York, N. Y.
+%D 1970
+%P 569-580
+
+%A R. L. London
+%A M. Shaw
+%A W. A. Wulf
+%T Abstraction and verification in Alphard: a symbol table example
+%D December 1976
+
+%A Peter Lucas
+%T On the semantics of programming languages and software devices
+%E R. Rustin
+%B Formal Semantics of Programming Languages
+%I Prentice-Hall
+%C Englewood Cliffs, N. J.
+%D 1972
+%P 41-57
+
+%A P. Lucas
+%T Formal definition of programming languages and systems
+%B Information Processing 71
+%I North-Holland
+%C Amsterdam
+%D 1971
+%P 291-297
+
+%A Peter Lucas
+%A Kurt Walk
+%T On the formal definition of PL/I
+%J Annual Review of Automatic Programming
+%V 6
+%N 3
+%D 1970
+%P 105-182
+
+%A D. C. Luckham
+%A D. M. R. Park
+%A M. S. Paterson
+%T On formalized computer programs
+%J J. Comp. Sys. Sci.
+%V 4
+%D 1970
+%P 220-249
+
+%A D. C. Luckham
+%A Norihisa Suzuki
+%T Automatic program verification V: verification oriented proof rules for arrays, records and pointers
+%R Report STAN-CS-76-549
+%D March 1976
+
+%A D. C. Luckham
+%A Norihisa Suzuki
+%T Proof of termination within a weak logic of programs
+%J Acta Informatica
+%V 8
+%D 1977
+%P 21-36
+
+%A M. E. Majster
+%T Extended data graphs, a formalism for structured data and data structures
+%J Acta Informatica
+%V 8
+%D 1977
+%P 37-59
+
+%A Zohar Manna
+%A Stephen Ness
+%A Jean Vuillemin
+%T Inductive methods for proving properties of programs
+%J Comm. Assoc. Comp. Mach.
+%K acm cacm
+%V 16
+%N 8
+%D August 1973
+%P 491-502
+
+%A Zohar Manna
+%A Jean Vuillemin
+%T Fixpoint approach to the theory of computation
+%J Comm. Assoc. Comp. Mach.
+%K acm cacm
+%V 15
+%N 7
+%D July 1972
+%P 528-536
+
+%A George Markowsky
+%T categories of chain-complete posets
+%J Theor. Comp. Sci.
+%V 4
+%D 1977
+%P 125-135
+
+%A G Markowsky
+%A B. K. Rosen
+%T Bases for chain-complete posets
+%J IBM J. Research and Development
+%V 20
+%N 2
+%D March 1976
+%P 138-147
+
+%A W. D. Maurer
+%T Induction principles for context-free languages
+%J Lecture Notes in Computer Science
+%V 1
+%D 1973
+%P 134-143
+
+%A John McCarthy
+%T Recursive functions of symbolic expressions and their computation by machine, part I
+%J Comm. Assoc. Comp. Mach.
+%K acm cacm
+%V 3
+%N 4
+%D April 1960
+%P 184-195
+
+%A John McCarthy
+%T Towards a mathematical science of computation
+%E C. M. Popplewell
+%B Information Processing 1962
+%I North-Holland
+%C Amsterdam
+%D 1963
+%P 21-28
+
+%A John McCarthy
+%T A basis for a mathematical theory of computation
+%E P. Braffort and D. Hirschberg
+%B Computer Programming and Formal Systems
+%I North-Holland
+%C Amsterdam
+%D 1963
+%P 33-70
+
+%A John McCarthy
+%T A formal description of a subset of Algol
+%E T. B. Steel, Jr.
+%B Formal Language Description Languages for Computer Programming
+%I North-Holland
+%C Amsterdam
+%D 1966
+%P 1-12
+
+%A John McCarthy
+%A James Painter
+%T Correctness of a compiler for arithmetic expressions
+%E J. T. Schwartz
+%B Proceedings of Symposia in Applied Mathematics, Volume XIX
+%I American Math. Society
+%C Providence, R. I.
+%D 1967
+%P 33-41
+
+%A M. D. McIlroy
+%T Coroutines
+%D 1968
+
+%A Robert Milne
+%T Verifying the correctness of implementations
+%D 1977
+
+%A R. E. Milne
+%T Transforming predicate transformers
+%E E. Neuhold
+%B IFIP Working Conference on the Formal Description of Programming Concepts
+%I North-Holland
+%C Amsterdam
+%D to appear
+
+%A Robin Milner
+%T Models in LCF
+%R Report STAN-CS-73-332
+%I Computer Science Department, Stanford University
+%D January 1973
+
+%A R. Milner
+%T Processes; a model of computing agents
+
+%A R. Milner
+%T Program semantics and mechanized proof
+%I Mathematical Centre Tracts 82
+%D 1976
+%P 3-44
+
+%A R. Milner
+%T LCF; a methodology for performing rigorous proofs about programs
+%B First IBM Symposium on Mathematical Foundations of Computer Science
+%I Academic and Scientific Programs, IBM Japan
+%C Tokyo
+%D October 1976
+
+%A J. H. Morris, Jr.
+%T Another recursion induction principle
+%J Comm. Assoc. Comp. Mach.
+%K acm cacm
+%V 14
+%N 5
+%D May 1971
+%P 351-354
+
+%A P. D. Mosses
+%T The mathematical semantics of Algol 60
+%R Technical Monograph PRG-12
+%I Programming Research Group, Oxford University
+%D 1974
+
+%A P. D. Mosses
+%T The semantics of semantic equations
+%J Lecture Notes in Computer Science
+%V 28
+%D 1975
+%P 409-422
+
+%A P. D. Mosses
+%T Compiler generation using denotational semantics
+%J Lecture Notes in Computer Science
+%V 45
+%D 1976
+%P 436-441
+
+%A P. D. Mosses
+%T Making denotational semantics less concrete
+%D 1977
+
+%A Maurice Nivat
+%T On some families of languages related to the Dyck language
+%J Proc. 2nd ACM Symp. on Theory of Computing
+%D May 1970
+%P 221-225
+
+%A M. Nivat
+%T On the interpretation of recursive program schemes
+%R Rapport de Recherche No 84
+%I IRIA
+%C Rocquencourt, France
+%D October 1974
+
+%A Mike O'Donnell
+%T Subtree replacement systems: a unifying theory for recursive equations, Lisp, Lucid and combinatory logic
+%J Ninth ACM Symp. Theory of Computing
+%D May 1977
+%P 295-305
+
+%A D. C. Oppen
+%A S. A. Cook
+%T Proving assertions about programs that manipulate data structures
+%J Proc. 7th ACM Symp. on Theory of Computing
+%D May 1975
+%P 107-116
+
+%A B. A. Othmer
+%T Programming language data structures: a comparative study
+%R Tech. Rep. No. 30
+%I Department of Computer Science, Rutgers University
+%D March 1974
+
+%A G. Pacini
+%T An optimal fix-point computation rule for a simple recursive language
+%R Nota Interna B73-10
+%I Consiglio Nazionale delle Ricerche, Istituto di Elaborazione della Informazione
+%C Pisa
+%D October 1973
+
+%A G. Pacini
+%A C. Montangero
+%A F. Turini
+%T Graph representation and computation rules for typeless recursive languages
+%J Lecture Notes in Computer Science
+%V 14
+%D 1974
+%P 158-169
+
+%A F. G. Pagan
+%T On interpreter oriented definitions of programming languages
+%J Comp. J.
+%V 19
+%N 2
+%D 1976
+%P 151-155
+
+%A David Park
+%T Some semantics for data structures
+%E D. Michie
+%B Machine Intelligence 3
+%I American Elsevier
+%C New York, N. Y.
+%D 1968
+%P 351-371
+
+%A David Park
+%T Fixpoint induction and proofs of program properties
+%B Machine Intelligence 5
+%D 1970
+%P 59-78
+
+%A David Park
+%T Finiteness is mu-ineffable
+%J Theor. Comp. Sci.
+%V 3
+%D 1976
+%P 173-181
+
+%A Helmut Partsch
+%A Peter Pepper
+%T A family of rules for recursion removal
+%J Information Processing Letters
+%V 5
+%N 6
+%D December 1976
+%P 174-177
+
+%A G. D. Plotkin
+%T A set-theoretical definition of application
+%R Memorandum MIP-R-95
+%I School of Artificial Intelligence, University of Edinburgh
+%D March 1972
+
+%A G. D. Plotkin
+%T Lambda-definability and logical relations
+%R Memorandum SAI-RM-4
+%I School of Artificial Intelligence, University of Edinburgh
+%D October 1973
+
+%A G. D. Plotkin
+%T Call-by-name, call-by-value and the $lambda -$calculus
+%J Theor. Comp. Sci.
+%V 1
+%D 1975
+%P 125-159
+
+%A A. Pnueli
+%T The temporal logic of programs
+%J Proc. 18th IEEE Symp. on Foundations of Computer Science
+%D October 1977
+%P 46-57
+
+%A V. R. Pratt
+%T Semantical considerations in Floyd-Hoare logic
+%J Proc. 17th IEEE Symp. on Foundations of Computer Science
+%D October 1976
+%P 109-121
+
+%A J. C. Raoult
+%A J. Vuillemin
+%T Operational and semantic equivalence between recursive programs
+%D 1977
+
+%A J. C. Reynolds
+%T Relational and continuation semantics for a simple imperative language
+%B Seminaires IRIA: theorie des algorithmes, des langages et de la programmation
+%D 1974
+%P 51-58
+
+%A J. C. Reynolds
+%T On the relation between direct and continuation semantics
+%J Lecture Notes in Computer Science
+%V 14
+%D 1974
+%P 141-156
+
+%A J. C. Reynolds
+%T Formal semantics
+%O preliminary draft for Cosers
+%D June 1976
+
+%A J. C. Reynolds
+%T Semantics of the domain of flow diagrams
+%J J. Assoc. Comp. Mach.
+%K acm jacm
+%V 24
+%N 3
+%D July 1977
+%P 484-503
+
+%A H. G. Rice
+%T Recursion and iteration
+%J Comm. Assoc. Comp. Mach.
+%K acm cacm
+%V 8
+%N 2
+%D February 1965
+%P 114-115
+
+%A J. S. Rohl
+%T Converting a class of recursive procedures into non-recursive ones
+%J Software \(em Practice and Experience
+%V 7
+%D 1977
+%P 231-238
+
+%A B. D. Russell
+%T Implementation correctness involving a language with goto statements
+%J SIAM J. Computing
+%V 6
+%N 3
+%D September 1977
+%P 403-415
+
+%A Bruce Russell
+%T On an equivalence between continuation and stack semantics
+%J Acta Informatica
+%V 8
+%D 1977
+%P 113-123
+
+%A Andrzej Salwicki
+%T Procedures, formal computations and models
+%J Lecture Notes in Computer Science
+%V 28
+%D 1975
+%P 464-484
+
+%A J. G. Sanderson
+%T The lambda calculus, lattice theory and reflexive domains
+%D 1973
+
+%A E. Sciore
+%A A. Tang
+%T Computability theory in admissible domains
+%D 1977
+
+%A Dana Scott
+%T Outline of a mathematical theory of computation
+%J Proc. 4th Princeton Conf. on Information Sciences and Systems
+%D March 1970
+%P 169-176
+
+%A Dana Scott
+%T The lattice of flow diagrams
+%J Lecture Notes in Mathematics
+%V 188
+%D 1971
+%P 311-366
+
+%A Dana Scott
+%T Continuous lattices
+%E F. W. Lawvere
+%B Toposes, Algebraic Geometry and Logic
+%I Lecture Notes in Mathematics 274, Springer Verlag
+%C Berlin
+%D 1972
+%P 97-136
+
+%A Dana Scott
+%T Mathematical concepts in programming language semantics
+%J Proc. AFIPS SJCC
+%D 1972
+%P 225-234
+
+%A Dana Scott
+%T A simplified construction for $lambda -$calculus models
+%C Uppsala
+%D April 1973
+
+%A Dana Scott
+%T Data types as lattices
+%J SIAM J. Computing
+%V 5
+%N 3
+%D September 1976
+%P 522-587
+
+%A Dana Scott
+%T Logic and programming languages
+%J Comm. Assoc. Comp. Mach.
+%K acm cacm
+%V 20
+%N 9
+%D September 1977
+%P 634-640
+
+%A Dana Scott
+%A Christopher Strachey
+%T Towards a mathematical semantics for computer languages
+%B Proceedings of the Symposium on Computers and Automata
+%I Polytechnic Press
+%C Brooklyn, N. Y.
+%D April 1971
+%P 19-46
+
+%A Adi Shamir
+%A W. W. Wadge
+%T Data types as objects
+%J Lecture Notes in Computer Science
+%V 52
+%D 1977
+%P 465-479
+
+%A M. Shaw
+%A W. A. Wulf
+%A R. L. London
+%T Abstraction and verification in Alphard: iteration and generators
+%R Report ISI/RR-76-47
+%I Information Sciences Institute, University of Southern California
+%C Los Angeles
+%D August 1976
+
+%A M. B. Smyth
+%T Powerdomains
+%D 1977
+
+%A M. B. Smyth
+%A G. D. Plotkin
+%T The category-theoretic solution of recursive domain equations
+%J Proc. 18th IEEE Symp. on Foundations of Computer Science
+%D October 1977
+%P 13-17
+
+%A J. E. Stoy
+%T The congruence of two programming language definitions
+%J Theor. Comp. Sci.
+%D to appear
+
+%A Christopher Strachey
+%T Towards a formal semantics
+%E T. B. Steel, Jr.
+%B Formal Language Description Languages for Computer Programming
+%I North-Holland
+%C Amsterdam
+%D 1966
+%P 198-220
+
+%A Christopher Strachey
+%T Varieties of programming language
+%B International Computing Symposium Proceedings
+%I Cini Foundation
+%C Venice
+%D April 1972
+%P 222-233
+
+%A Christopher Strachey
+%A Christopher Wadsworth
+%T Continuations: a mathematical semantics which can deal with full jumps
+%R Technical Monograph PRG-11
+%I Programming Research Group, Oxford University
+%D 1974
+
+%A A. Tang
+%T Chain properties in P$omega$
+%D 1977
+
+%A Alfred Tarski
+%T A lattice-theoretical fixpoint theorem and its applications
+%J Pacific J. Math.
+%V 5
+%N 2
+%D June 1955
+%P 285-309
+
+%A R. D. Tennent
+%T Mathematical semantics of Snobol 4
+%J Proc. ACM Symp. on Principles of Programming Languages
+%D October 1973
+%P 95-107
+
+%A R. D. Tennent
+%T The denotational semantics of programming languages
+%J Comm. Assoc. Comp. Mach.
+%K acm cacm
+%V 19
+%N 8
+%D August 1976
+%P 437-453
+
+%A R. D. Tennent
+%T Language design methods based on semantic principles
+%J Acta Informatica
+%V 8
+%D 1977
+%P 97-112
+
+%A R. D. Tennent
+%T A denotational definition of the programming language Pascal
+%R Tech. Rep. 77-47
+%I Department of Computing and Information Science, Queen's University
+%C Kingston, Ontario
+%D July 1977
+
+%A A. van Wijngaarden
+%T Recursive definition of syntax and semantics
+%E T. B. Steel, Jr.
+%B Formal Language Description Languages for Computer Programming
+%I North-Holland
+%C Amsterdam
+%D 1966
+%P 13-24
+
+%A S. A. Walker
+%A H. R. Strong, Jr.
+%T Characterizations of flowchartable recursions
+%J J. Comp. Sys. Sci.
+%V 7
+%N 4
+%D August 1973
+%P 404-447
+
+%A Mitchell Wand
+%T A characterization of weakest preconditions
+%J J. Comp. Sys. Sci.
+%V 15
+%D 1977
+%P 209-212
+
+%A Ben Wegbreit
+%T Procedure closure in EL1
+%J Comp. J.
+%V 17
+%N 1
+%D February 1974
+%P 38-43
+
+%A Ben Wegbreit
+%T The treatment of data types in EL1
+%J Comm. Assoc. Comp. Mach.
+%K acm cacm
+%V 17
+%N 5
+%D May 1974
+%P 251-264
+
+%A Ben Wegbreit
+%T Constructive methods in program verification
+%J IEEE Trans. on Software Engineering
+%V SE-3
+%N 3
+%D May 1977
+%P 193-209
+
+%A W. A. Wulf
+%A R. L. London
+%A Mary Shaw
+%T An introduction to the construction and verification of Alphard programs
+%J IEEE Trans. on Software Engineering
+%V SE-2
+%N 4
+%D December 1976
+%P 253-265
+
index 9dc1b40..2b6db17 100644 (file)
@@ -380,7 +380,7 @@ ragain:
                        for (i = 0; i < NADDR; i++)
                                taddr[i] = 0;
                        l3tol(taddr, dino.di_addr, 1);
                        for (i = 0; i < NADDR; i++)
                                taddr[i] = 0;
                        l3tol(taddr, dino.di_addr, 1);
-                       getfile(ino, rstrfile, rstrskip, dino.di_size);
+                       getfile(d, rstrfile, rstrskip, dino.di_size);
                        ip = &tino;
                        ltol3(ip->di_addr, taddr, NADDR);
                        ip1 = &dino;
                        ip = &tino;
                        ltol3(ip->di_addr, taddr, NADDR);
                        ip1 = &dino;
@@ -463,6 +463,7 @@ long        size;
                if (checktype(&addrblock, TS_ADDR) == 0) {
                        spcl = addrblock;
                        curino = 0;
                if (checktype(&addrblock, TS_ADDR) == 0) {
                        spcl = addrblock;
                        curino = 0;
+                       curino = 0;
                        return;
                }
 start:
                        return;
                }
 start:
@@ -505,8 +506,7 @@ char *b;
                if ((i = read(mt, tbf, NTREC*BSIZE)) < 0) {
                        printf("Tape read error: inode %u\n", curino);
                        eflag++;
                if ((i = read(mt, tbf, NTREC*BSIZE)) < 0) {
                        printf("Tape read error: inode %u\n", curino);
                        eflag++;
-                       for (i = 0; i < NTREC; i++)
-                               clearbuf(&tbf[i*BSIZE]);
+                       exit(1);
                }
                if (i == 0) {
                        bct = NTREC + 1;
                }
                if (i == 0) {
                        bct = NTREC + 1;
@@ -1140,8 +1140,6 @@ short     *m;
 
 done()
 {
 
 done()
 {
-#ifndef STANDALONE
        unlink(dirfile);
        unlink(dirfile);
-#endif
        exit(0);
 }
        exit(0);
 }
diff --git a/usr/src/cmd/rew.c b/usr/src/cmd/rew.c
new file mode 100644 (file)
index 0000000..8197254
--- /dev/null
@@ -0,0 +1,26 @@
+main(argc,args)
+char **args ;
+{
+register char *tape ;
+int i , j ;
+if (argc > 2) {
+       usage :
+               printf("usage : rew [[m]digit]\n") ;
+               exit(1) ;
+       }
+tape = "/dev/tap0" ;
+if (argc > 1) {
+       j = 0 ;
+       if (args[1][j] == 'm') {
+               tape = "/dev/mt0" ;
+               i = 7 ;
+               j++ ;
+               }
+       else i = 8 ;
+       if (args[1][j] != '\0') tape[i] = args[1][j] ;
+       }
+i = open(tape,0) ;
+read(i,&j,sizeof(j)) ;
+close(i) ;
+}
diff --git a/usr/src/cmd/roff/makefile b/usr/src/cmd/roff/makefile
deleted file mode 100644 (file)
index 2541bf4..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-all:   roff
-
-cp:    roff
-       cp roff /bin
-       rm roff roff.o
-
-cmp:   roff
-       cmp roff /bin/roff
-       rm roff roff.o
-
-roff:  *.s
-       as -o roff.o /usr/include/sys.s *.s
-       ld -s roff.o -lc -o roff
diff --git a/usr/src/cmd/roff/roff1.s b/usr/src/cmd/roff/roff1.s
deleted file mode 100644 (file)
index 05e12af..0000000
+++ /dev/null
@@ -1,570 +0,0 @@
-/
-/
-
-/ roff1 -- text formatter
-
-       .globl _ttyname
-       nop = 000240
-       signal = 48.
-
-ibuf: /init code in ibuf+obuf
-       cmp     sp,$end
-       bhi     1f
-       jsr     r5,string; emes1
-       sys     exit
-1:
-       clr     r0
-       jsr     pc,mesg
-       sys     signal; 1; place
-       sys     signal; 2; place
-       jsr     pc,makebf
-       sys     open; suffil; 0
-       bes     1f
-       mov     r0,suff
-       sys     lseek; 0;20; 0  /actually lseek
-       bes     1f
-       mov     suff,r0
-       sys     read; suftab; 2*26.
-1:
-       clr     r0
-       mov     (sp)+,argc
-       dec     argc
-       bne     1f
-       jmp     place
-1:
-       tst     (sp)+
-       mov     (sp),r4
-       cmpb    (r4)+,$'+
-       bne     2f
-       jsr     r5,pnum; pfrom
-       br      3f
-2:
-       cmpb    -1(r4),$'-
-       bne     2f
-       cmpb    (r4),$'s
-       bne     0f
-       inc     stop
-       br      3f
-0:
-       cmpb    (r4),$'h
-       bne     0f
-       clr     slow
-       br      3f
-0:
-       jsr     r5,pnum; pto
-3:
-       dec     argc
-       bgt     1b
-2:
-       mov     $nop,get1a
-       mov     $ibuf,ibufp
-       mov     $ibuf,eibuf
-       mov     sp,argp
-       jsr     pc,topbot
-       clr     r0
-1:
-       movb    r0,trtab(r0)
-       inc     r0
-       cmp     r0,$128.
-       bne     1b
-       jsr     pc,rbreak
-       jsr     pc,istop
-       jmp     loop
-makebf:
-       sys     stat; bfn; stbuf
-       bec     2f
-       sys     creat; bfn; 400
-       bec     1f
-2:
-       incb    bfn+8
-       cmpb    bfn+8,$'z
-       blos    makebf
-       jmp     place
-1:
-       mov     r0,ibf
-       sys     write; sufbuf;128.
-       sys     open; bfn;0
-       mov     r0,ibf1
-       rts     pc
-
-string:
-       mov     (r5)+,r1
-       mov     r1,r2
-       mov     r1,0f
-1:
-       tstb    (r1)+
-       bne     1b
-       sub     r2,r1
-       mov     r1,1f
-       mov     $1,r0
-       sys     write; 0:..; 1:..
-       rts     r5
-
-emes1: <Too many files.\n\0>
-xxx:
-.even
-obuf=ibuf+512.
-.=ibuf+1024.
-loop:
-       clr     nlflg
-       jsr     pc,getchar
-       cmpb    r0,cc
-       beq     2f
-       movb    r0,ch
-       jsr     pc,text
-       br      loop
-2:
-       jsr     pc,control
-       jsr     pc,flushi
-       br      loop
-
-mesg:
-       tst     r0
-       bne     setsame
-       clr     -(sp)
-       jsr     pc,_ttyname
-       tst     (sp)+
-       mov     r0,9f
-       mov     r0,8f
-       mov     r0,7f
-       sys     stat; 9:..; stbuf
-       mov     stbuf+4,0f
-       mov     0f,1f
-       bic     $22,0f
-       sys     chmod; 8:..; 0:..
-       rts     pc
-setsame:
-       sys     chmod; 7:..; 1:..
-       rts     pc
-
-pnum:
-       mov     r4,ibufp
-       mov     $37777,eibuf
-       jsr     r5,number1; 0
-       mov     r0,*(r5)+
-       clr     ch
-       rts     r5
-
-flushi:
-       clr     ch
-       tst     nlflg
-       bne     1f
-       jsr     pc,getchar
-       br      flushi
-1:
-       rts     pc
-
-gettchar:
-       tst     ul
-       ble     getchar
-       tst     ulstate
-       beq     3f
-       tst     bsc
-       bgt     1f
-       tst     ulc
-       bgt     2f
-       clr     ulstate
-       br      3f
-1:
-       dec     bsc
-       mov     $010,r0
-       rts     pc
-2:
-       dec     ulc
-       mov     $'_,r0
-       rts     pc
-3:
-       jsr     pc,getchar
-       cmp     r0,$'0
-       blt     1f
-       cmp     r0,$'9
-       ble     2f
-       cmp     r0,$'A
-       blt     1f
-       cmp     r0,$'Z
-       ble     2f
-       cmp     r0,$'a
-       blt     1f
-       cmp     r0,$'z
-       ble     2f
-1:
-       tst     ulc
-       bgt     3f
-       rts     pc
-3:
-       mov     $1,ulstate
-       mov     r0,ch
-       br      gettchar
-2:
-       inc     bsc
-       inc     ulc
-       rts     pc
-
-getchar:
-       mov     ch,r0
-       beq     1f
-       clr     ch
-       rts     pc
-1:
-       tst     nlflg
-       beq     1f
-       mov     $'\n,r0
-       rts     pc
-1:
-       jsr     pc,get1
-       cmp     r0,$'\\
-       bne     2f
-       jsr     pc,get1
-       jsr     r5,switch; esctab
-       br      3f
-2:
-       cmp     r0,$033  /prefix
-       bne     3f
-       jsr     pc,get1
-       jsr     r5,switch; pfxtab
-3:
-       cmp     r0,$'\n
-       bne     3f
-       inc     nlflg
-       clr     column
-3:
-       mov     r1,-(sp)
-       jsr     pc,width
-       add     r1,column
-       mov     (sp)+,r1
-       rts     pc
-
-esctab:
-   .byte 'd, 032  /hlf (down)
-   .byte 'u, 035  /hlr (up)
-   .byte 'r, 036  /flr (reverse)
-   .byte 'x, 016  /SO (extra chars)
-   .byte 'y, 017  /SI (normal characters)
-   .byte 'l, 0177 /delete
-   .byte 't, 011  /hor tab
-   .byte 'a, 0100 /at sign
-   .byte 'n, 043  /number sign
-   .byte '\\, 134 /backslash
-   .byte 0, 0
-
-pfxtab:
-   .byte '7, 036  /flr
-   .byte '8, 035  /hlr
-   .byte '9, 032  /hlf
-   .byte '4, 030  /brs
-   .byte '3, 031  /rrs
-   .byte '1, 026  /set hor tabs
-   .byte '2, 027  /clr hor tabs
-   .byte 0,0
-pfxtab1:
-
-switch:
-       mov     r1,-(sp)
-       mov     (r5)+,r1
-1:
-       cmpb    (r1)+,r0
-       beq     1f
-       tstb    (r1)+
-       bne     1b
-       cmp     r1,$pfxtab
-       ble     0f
-       cmp     r1,$pfxtab1
-       bgt     0f
-       mov     $037,r0
-0:
-       mov     (sp)+,r1
-       rts     r5
-1:
-       movb    (r1)+,r0
-       mov     (sp)+,r1
-       rts     r5
-
-get1:
-       tst     nspace
-       ble     1f
-       dec     nspace
-       mov     tabc,r0
-       rts     pc
-1:
-       mov     r1,-(sp)
-4:
-       tst     ip
-       beq     5f
-       jsr     pc,rbf
-       br      6f
-5:
-       tst     nx
-       bne     0f
-       mov     ibufp,r1
-       cmp     r1,eibuf
-       bne     3f
-0:
-       mov     ifile,r0
-       bne     2f
-1:
-       jsr     pc,nextfile
-2:
-       clr     nx
-       sys     read; ibuf; 512.
-       bes     done
-       tst     r0
-       beq     1b
-       mov     $ibuf,r1
-       add     r1,r0
-       mov     r0,eibuf
-3:
-       movb    (r1)+,r0
-       mov     r1,ibufp
-1:
-       cmp     r0,$011 /tab
-       bne     6f
-       mov     (sp)+,r1
-       mov     $tabtab,r0
-       inc     nspace
-1:
-       tstb    (r0)
-       beq     get1
-       cmpb    column,(r0)+
-       bge     1b
-       movb    -(r0),nspace
-       sub     column,nspace
-       br      get1
-6:
-get1a: br      7f
-       tst     r0
-       beq     4b
-7:
-       mov     (sp)+,r1
-       rts     pc
-
-nextfile:
-       mov     ifile,r0
-       beq     1f
-       sys     close
-1:
-       tst     nx
-       beq     2f
-       mov     $nextf,0f
-       br      3f
-2:
-       dec     argc
-       blt     done
-       mov     *argp,0f
-       add     $2,argp
-3:
-       sys     open; 0:..; 0
-       bes     done
-       mov     r0,ifile
-       rts     pc
-
-done:
-       jsr     pc,rbreak
-       jsr     pc,eject
-       jsr     pc,flush
-place:
-       sys     signal; 2; 1
-       mov     $1,r0
-       jsr     pc,mesg
-       sys     unlink; bfn
-       sys     exit
-
-       rts     pc
-
-putchar:
-       cmp     pn,pfrom
-       blt     2f
-       clr     pfrom
-       bic     $!177,r0
-       beq     2f
-       movb    trtab(r0),r0
-       cmp     r0,$' 
-       bne     1f
-       inc     nsp
-2:
-       rts     pc
-1:
-       cmp     r0,$'\n
-       bne     1f
-       clr     nsp
-       clr     ocol
-       br      2f
-1:
-       tst     nsp
-       beq     2f
-       tst     slow
-       bne     4f
-       jsr     pc,dsp
-       cmp     nsp,r1
-       blt     4f
-       mov     $011,3f+2
-       cmp     r1,$1
-       bgt     8f
-       mov     $040,3f+2
-       dec     nsp
-       br      9f
-8:
-       sub     r1,nsp
-9:
-       mov     r0,-(sp)
-3:
-       mov     $011,r0
-       jsr     pc,pchar1
-       mov     (sp)+,r0
-       br      1b
-4:
-       mov     r0,-(sp)
-       mov     $' ,r0
-       jsr     pc,pchar1
-       mov     (sp)+,r0
-       dec     nsp
-       bne     4b
-2:
-       cmp     r0,$026
-       blt     2f
-       cmp     r0,$037
-       beq     3f
-       bgt     2f
-       mov     r0,-(sp)
-       jsr     r5, switch; unpfx
-       cmp     (sp)+,r0
-       beq     2f
-       mov     r0,-(sp)
-       mov     $033,r0  /prefix
-       jsr     pc,pchar1
-       dec     ocol
-       mov     (sp)+,r0
-2:
-pchar1:
-       cmp     r0,$011
-       bne     1f
-       jsr     pc,dsp
-       br      2f
-1:
-       jsr     pc,width
-2:
-       add     r1,ocol
-       movb    r0,*obufp
-       inc     obufp
-       cmp     obufp,$obuf+128.
-       beq     flush
-3:
-       rts     pc
-
-dsp:
-       clr     r1
-1:
-       add     $8.,r1
-       cmp     ocol,r1
-       bgt     1b
-       sub     ocol,r1
-       bne     2f
-       mov     $8.,r1
-2:
-       rts     pc
-
-
-unpfx:
-   .byte 032, '9
-   .byte 035, '8
-   .byte 036, '7
-   .byte 031, '3
-   .byte 030, '4
-   .byte 026, '1
-   .byte 027, '2
-   .byte 0,0
-
-flush:
-       mov     obufp,r0
-       sub     $obuf,r0
-       mov     r0,0f
-       mov     $1,r0
-       sys     write; obuf; 0:0
-       mov     $obuf,obufp
-       rts     pc
-
-control:
-       jsr     pc,getchar
-       mov     r0,-(sp)
-       jsr     pc,getchar
-       swab    r0
-       bis     (sp),r0
-       mov     $contab,r1
-1:
-       mov     (r1)+,(sp)
-       bic     $100000,(sp)
-       cmp     r0,(sp)
-       bne     4f
-       mov     (r1),(sp)
-       tst     -(r1)
-       bpl     3f
-       jsr     pc,flushi
-       cmp     ilistp,$iliste
-       bgt     5f
-       mov     ip,*ilistp
-       add     $2,ilistp
-       mov     (sp),ip
-       br      5f
-3:
-       jmp     *(sp)+
-4:
-       cmp     (r1)+,$-1
-       bne     1b
-5:
-       tst     (sp)+
-       rts     pc
-
-contab:
-   <ad>; casead
-   <bp>; casebp
-   <br>; casebr
-   <cc>; casecc
-   <ce>; casece
-   <ds>; caseds
-   <fi>; casefi
-   <in>; casein
-   <ix>; caseix
-   <li>; caseli
-   <ll>; casell
-   <ls>; casels
-   <na>; casena
-   <ne>; casene
-   <nf>; casenf
-   <pa>; casepa
-   <bl>; casebl
-   <pl>; casepl
-   <sk>; casesk
-   <sp>; casesp
-   <ss>; casess
-   <ta>; caseta
-   <ti>; caseti
-   <tr>; casetr
-   <ul>; caseul
-   <un>; caseun
-   <he>; casehe
-   <hx>; casehx
-   <fo>; casefo
-   <eh>; caseeh
-   <oh>; caseoh
-   <ef>; caseef
-   <of>; caseof
-   <m1>; casem1
-   <m2>; casem2
-   <m3>; casem3
-   <m4>; casem4
-   <hc>; casehc
-   <hy>; casehy
-   <n1>; casen1
-   <n2>; casen2
-   <nn>; casenn
-   <ni>; caseni
-   <jo>; casejo
-   <ar>; casear
-   <ro>; casero
-   <nx>; casenx
-   <po>; casepo
-   <de>; casede
-   <ig>; caseig
-   <tc>; casetc
-   <mk>; casemk
-bnames: .=.+100.
-    -1; -1
diff --git a/usr/src/cmd/roff/roff2.s b/usr/src/cmd/roff/roff2.s
deleted file mode 100644 (file)
index 3823c86..0000000
+++ /dev/null
@@ -1,406 +0,0 @@
-/
-/
-
-/ roff2 -- runoff
-
-casead:
-       jsr     pc,rbreak
-       inc     ad
-       rts     pc
-
-       rts     pc
-
-casebr:
-       jsr     pc,rbreak
-       rts     pc
-
-casecc:
-       jsr     pc,skipcont
-       jsr     pc,getchar
-       cmp     r0,$'\n
-       beq     1f
-       movb    r0,cc
-1:
-       mov     r0,ch
-       rts     pc
-
-casece:
-       jsr     pc,rbreak
-       jsr     r5,number; 0
-       jsr     pc,min
-       mov     r0,ce
-       jsr     pc,need
-       rts     pc
-
-caseds:
-       jsr     pc,rbreak
-       mov     $2,ls
-       rts     pc
-
-casefi:
-       jsr     pc,rbreak
-       inc     fi
-       rts     pc
-
-casein:
-       jsr     pc,rbreak
-       jsr     r5,number; in
-       jsr     pc,min
-       mov     r0,in
-       mov     r0,un
-       rts     pc
-
-caseix:
-       jsr     r5,number; in
-       jsr     pc,min
-       mov     r0,in
-       rts     pc
-
-caseli:
-       jsr     r5,number; 0
-       mov     r0,-(sp)
-1:
-       dec     (sp)
-       blt     1f
-       jsr     pc,flushi
-       clr     nlflg
-       jsr     pc,text
-       br      1b
-1:
-       tst     (sp)+
-       rts     pc
-
-casell:
-       jsr     r5,number; ll
-       jsr     pc,min
-       mov     r0,ll
-       rts     pc
-
-casels:
-       jsr     pc,rbreak
-       jsr     pc,skipcont
-       jsr     pc,getchar
-       cmp     r0,$'\n
-       bne     1f
-       mov     ls1,ls
-       rts     pc
-1:
-       mov     r0,ch
-       jsr     r5,number1; ls
-       dec     r0
-       jsr     pc,min
-       inc     r0
-       mov     r0,ls
-       mov     r0,ls1
-       rts     pc
-
-casena:
-       jsr     pc,rbreak
-       clr     ad
-       rts     pc
-
-casene:
-       jsr     r5,number; 0
-       jsr     pc,min
-       jsr     pc,need
-       rts     pc
-
-casenf:
-       jsr     pc,rbreak
-       clr     fi
-       rts     pc
-
-casepa:
-casebp:
-       jsr     pc,rbreak
-       jsr     pc,eject
-       jsr     pc,skipcont
-       tst     nlflg
-       bne     1f
-       jsr     r5,number; pn
-       jsr     pc,min
-       mov     r0,pn
-1:
-       rts     pc
-
-casebl:
-       jsr     pc,rbreak
-       jsr     r5,number; 0
-       jsr     pc,min
-       mov     r0,-(sp)
-       jsr     pc,need2
-1:
-       dec     (sp)
-       blt     1f
-       mov     $' ,r0
-       jsr     pc,storeline
-       jsr     pc,rbreak
-       br      1b
-1:
-       tst     (sp)+
-       rts     pc
-
-casepl:
-       jsr     r5,number; pl
-       mov     r0,pl
-       jsr     pc,topbot
-       rts     pc
-
-casesk:
-       jsr     r5,number; 0
-       jsr     pc,min
-       mov     r0,skip
-       rts     pc
-
-casesp:
-       jsr     pc,rbreak
-       jsr     r5,number; 0
-       jsr     r5,nlines; nline
-       rts     pc
-
-casess:
-       jsr     pc,rbreak
-       mov     $1,ls
-       rts     pc
-
-casetr:
-       jsr     pc,skipcont
-1:
-       jsr     pc,getchar
-       cmp     r0,$'\n
-       beq     1f
-       mov     r0,r1
-       jsr     pc,getchar
-       cmp     r0,$'\n
-       bne     2f
-       mov     $' ,r0
-2:
-       movb    r0,trtab(r1)
-       br      1b
-1:
-       rts     pc
-
-caseta:
-       mov     $tabtab,r1
-1:
-       cmp     r1,$etabtab
-       bhis    1f
-       jsr     r5,number; 0
-       jsr     pc,min
-       dec     r0
-       ble     1f
-       movb    r0,(r1)+
-       br      1b
-1:
-       clrb    (r1)
-       rts     pc
-
-caseti:
-       jsr     pc,rbreak
-       jsr     r5,number; in
-       jsr     pc,min
-       mov     r0,un
-       rts     pc
-
-caseul:
-       jsr     r5,number; 0
-       jsr     pc,min
-       mov     r0,ul
-       rts     pc
-
-caseun:
-       jsr     r5,number; 0
-       sub     in,r0
-       neg     r0
-       jsr     pc,min
-       mov     r0,un
-       rts     pc
-
-casehx:
-       tst     hx
-       beq     1f
-       clr     hx
-       br      2f
-1:
-       inc     hx
-2:
-       jsr     pc,topbot
-       rts     pc
-
-casehe:
-       jsr     r5,headin; ehead
-       mov     ehead,ohead
-       rts     pc
-casefo:
-       jsr     r5,headin; efoot
-       mov     efoot,ofoot
-       rts     pc
-
-caseeh:
-       jsr     r5,headin; ehead
-       rts     pc
-
-caseoh:
-       jsr     r5,headin; ohead
-       rts     pc
-
-caseef:
-       jsr     r5,headin; efoot
-       rts     pc
-
-caseof:
-       jsr     r5,headin; ofoot
-       rts     pc
-
-casem1:
-       jsr     r5,number; ma1
-       jsr     pc,min
-       mov     r0,ma1
-       br      1f
-
-casem2:
-       jsr     r5,number; ma2
-       jsr     pc,min
-       mov     r0,ma2
-       br      1f
-
-casem3:
-       jsr     r5,number; ma3
-       jsr     pc,min
-       mov     r0,ma3
-       br      1f
-
-casem4:
-       jsr     r5,number; ma4
-       jsr     pc,min
-       mov     r0,ma4
-1:
-       jsr     pc,topbot
-       rts     pc
-
-casehc:
-       jsr     pc,skipcont
-       jsr     pc,getchar
-       cmp     r0,$'\n
-       bne     1f
-       movb    $200,r0
-1:
-       mov     r0,ohc
-       rts     pc
-
-casetc:
-       jsr     pc,skipcont
-       jsr     pc,getchar
-       cmp     r0,$'\n
-       bne     1f
-       mov     $' ,r0
-1:
-       mov     r0,tabc
-       rts     pc
-
-casehy:
-       jsr     r5,number; 0
-       mov     r0,hyf
-       rts     pc
-
-casen1:
-       jsr     pc,rbreak
-       mov     $1,numbmod
-       br      1f
-casen2:
-       jsr     pc,rbreak
-       mov     $2,numbmod
-1:
-       clr     nn
-       jsr     r5,number; 0
-       tst     r0
-       ble     1f
-       mov     r0,lnumber
-       rts     pc
-1:
-       clr     numbmod
-       rts     pc
-
-casenn:
-       jsr     r5,number; 0
-       jsr     pc,min
-       mov     r0,nn
-       rts     pc
-
-caseni:
-       jsr     r5,number; ni
-       jsr     pc,min
-       mov     r0,ni
-       rts     pc
-
-casejo:
-       jsr     r5,number; 0
-       mov     r0,jfomod
-       rts     pc
-
-casear:
-       clr     ro
-       rts     pc
-
-casero:
-       inc     ro
-       rts     pc
-
-casenx:
-       jsr     pc,skipcont
-       jsr     r5,getname; nextf
-       inc     nx
-       jsr     pc,nextfile
-       inc     nlflg
-       clr     ip
-       mov     $ilist,ilistp
-       rts     pc
-
-casepo:
-       jsr     pc,rbreak
-       jsr     r5,number; po
-       jsr     pc,min
-       mov     r0,po
-       rts     pc
-
-casede:
-       tst     ip
-       bne     5f
-       jsr     pc,skipcont
-       jsr     r5,getname; bname
-       clr     skp
-       mov     $contab,r1
-       clr     -(sp)
-1:
-       mov     (r1)+,(sp)
-       beq     2f
-       bic     $100000,(sp)
-       cmp     bname,(sp)
-       bne     3f
-2:
-       bis     $100000,bname
-       mov     nextb,(r1)
-       mov     bname,-(r1)
-       br      4f
-3:
-       cmp     (r1)+,$-1
-       bne     1b
-       inc     skp
-4:
-       tst     (r1)+
-       jsr     pc,copyb
-       tst     (sp)+
-5:
-       rts     pc
-
-caseig:
-       inc     skp
-       jsr     pc,copyb
-       rts     pc
-
-casemk:
-       jsr     pc,rbreak
-       mov     $002,r0 /stx
-       jsr     pc,putchar
-       rts     pc
-
diff --git a/usr/src/cmd/roff/roff3.s b/usr/src/cmd/roff/roff3.s
deleted file mode 100644 (file)
index aeed595..0000000
+++ /dev/null
@@ -1,485 +0,0 @@
-/
-/
-
-/roff3 -- runoff
-
-skipcont:
-       jsr     pc,getchar
-       mov     r0,r2
-       jsr     pc,alph2
-       beq     skipcont
-1:
-       cmp     $' ,r0
-       bne     1f
-       jsr     pc,getchar
-       br      1b
-1:
-       mov     r0,ch
-       rts     pc
-
-rbreak:
-       tst     nc
-       ble     4f
-       clrb    *linep
-       inc     totout
-       mov     ls,r0
-       dec     r0
-       jsr     r5,nlines; nline
-       tst     pl
-       beq     4f
-       cmp     nl,bl
-       bne     1f
-3:
-       jsr     pc,eject
-1:
-       tst     nl
-       bne     3f
-       mov     ma1,r0
-       jsr     r5,nlines; newline
-       bit     $1,pn
-       bne     1f
-       jsr     r5,headout; ehead
-       br      2f
-1:
-       jsr     r5,headout; ohead
-2:
-       mov     ma2,r0
-       jsr     r5,nlines; newline
-       dec     skip
-       bge     3b
-3:
-       mov     po,r0
-       jsr     pc,space
-       jsr     pc,donum
-       mov     un,r0
-       jsr     pc,space
-       jsr     pc,jfo
-       mov     $line,r2
-1:
-       movb    (r2)+,r0
-       cmp     $' ,r0
-       bne     2f
-       jsr     pc,fill
-       tst     nc
-       bne     1b
-       br      3f
-2:
-       jsr     pc,putchar
-       dec     nc
-       bgt     1b
-3:
-       jsr     pc,newline
-       clr     nwd
-       clr     ne
-       mov     in,un
-4:
-       jsr     pc,setnel
-       rts     pc
-
-jfo:
-       tst     jfomod
-       beq     1f
-       mov     fac,r0
-       add     fmq,r0
-       beq     1f
-       clr     fac
-       clr     fmq
-       mov     nel,r0
-       cmp     jfomod,$1
-       bne     2f
-       asr     r0
-2:
-       jsr     pc,space
-1:
-       rts     pc
-
-donum:
-       tst     numbmod
-       beq     2f
-       dec     nn
-       blt     1f
-       mov     $5,r0
-       add     ni,r0
-       jsr     pc,space
-       rts     pc
-1:
-       clr     r0
-       cmp     lnumber,$100.
-       bge     1f
-       inc     r0
-       cmp     lnumber,$10.
-       bge     1f
-       inc     r0
-1:
-       add     ni,r0
-       jsr     pc,space
-       mov     lnumber,r0
-       jsr     r5,decimal; putchar
-       mov     $2,r0
-       jsr     pc,space
-       inc     lnumber
-2:
-       rts     pc
-
-
-newline:
-       mov     $'\n,r0
-       jsr     pc,putchar
-       inc     nl
-       rts     pc
-
-nline:
-       mov     nl,r0
-       beq     1f
-       cmp     r0,bl
-       beq     1f
-       jsr     pc,newline
-1:
-       rts     pc
-
-number:
-       jsr     pc,skipcont
-number1:
-       mov     r1,-(sp)
-       mov     r3,-(sp)
-       clr     r3
-       clr     -(sp)
-       clr     -(sp)
-1:
-       jsr     pc,getchar
-       cmp     r0,$'+
-       beq     2f
-       cmp     r0,$'-
-       beq     2f
-       sub     $'0,r0
-       cmp     r0,$9.
-       bhi     3f
-       inc     (sp)
-       mpy     $10.,r3
-       add     r0,r3
-       br      1b
-2:
-       mov     r0,2(sp)
-       br      1b
-3:
-       add     $'0,r0
-       mov     r0,ch
-       mov     (sp)+,r0
-       bne     1f
-       mov     $1,r3
-       mov     r3,r0
-1:
-       mov     (r5)+,r0
-       beq     1f
-       mov     (r0),r0
-1:
-       mov     (sp)+,r1
-       cmp     r1,$'-
-       bne     1f
-       sub     r3,r0
-       br      2f
-1:
-       cmp     r1,$'+
-       bne     1f
-       add     r3,r0
-       br      2f
-1:
-       mov     r3,r0
-2:
-       mov     (sp)+,r3
-       mov     (sp)+,r1
-       rts     r5
-
-eject:
-       tst     pl
-       beq     1f
-       tst     nl
-       beq     1f
-       mov     pl,r0
-       sub     nl,r0
-       sub     ma4,r0
-       sub     hx,r0
-       jsr     r5,nlines; newline
-       bit     $1,pn
-       bne     2f
-       jsr     r5,headout; efoot
-       br      3f
-2:
-       jsr     r5,headout; ofoot
-3:
-       cmp     numbmod,$1
-       bne     3f
-       mov     $1,lnumber
-3:
-       mov     ma4,r0
-       jsr     r5,nlines; newline
-       clr     nl
-       inc     pn
-1:
-       cmp     pn,pto
-       ble     1f
-       jsr     pc,flush
-       jmp     place
-1:
-istop:
-       tst     stop
-       beq     2f
-       cmp     pn,pfrom
-       blo     2f
-       jsr     pc,flush
-/      mov     sp,r1
-/      sys     signal; 2; 1f
-       clr     r0
-       sys     read; garb; 1
-1:
-/      mov     r1,sp
-/      sys     signal; 2; place
-2:
-       rts     pc
-
-
-storeline:
-       cmp     linep,$line+linsiz
-       bhis    1f
-       movb    r0,*linep
-       inc     linep
-       jsr     pc,width
-       add     r1,ne
-       sub     r1,nel
-       inc     nc
-1:
-       rts     pc
-
-getword:
-       mov     $word,r2
-       clr     wne
-       clr     wch
-       clr     nhyph
-       clr     hypedf
-       mov     $word,wordp
-       clr     -(sp)
-1:
-       jsr     pc,gettchar
-       cmp     r0,$'\n
-       beq     3f
-       cmp     r0,ohc
-       bne     2f
-       inc     hypedf
-       br      1b
-2:
-       cmp     $' ,r0
-       bne     2f
-       jsr     pc,storeword
-       br      1b
-2:
-       mov     r0,-(sp)
-       mov     $' ,r0
-       jsr     pc,storeword
-       tst     spaceflg
-       beq     2f
-       jsr     pc,storeword
-       clr     spaceflg
-2:
-       mov     (sp)+,r0
-2:
-       jsr     pc,storeword
-       bisb    (sp),-1(r2)     /add in hyphen
-       clr     (sp)
-       jsr     pc,gettchar
-       cmp     r0,ohc
-       bne     1f
-       inc     hypedf
-       jsr     pc,gettchar
-       mov     $200,(sp)
-1:
-       cmp     $' ,r0
-       beq     1f
-       cmp     $'\n,r0
-       bne     2b
-       cmpb    -1(r2),$'.
-       bne     1f
-       inc     spaceflg
-1:
-       add     $2,2(sp)
-1:
-       clrb    (r2)+
-3:
-       tst     (sp)+
-       mov     $word,wordp
-       tst     nc
-       bne     1f
-       jsr     pc,setnel
-1:
-       rts     pc
-
-setnel:
-       mov     $line,linep
-       mov     ll,nel
-       sub     un,nel
-       clr     ne
-       clr     fac
-       clr     fmq
-       rts     pc
-
-storeword:
-       jsr     pc,width
-       add     r1,wne
-       inc     wch
-       movb    r0,(r2)+
-       rts     pc
-
-need:
-       mov     r0,r3
-       mpy     ls,r3
-       mov     r3,r0
-need2:
-       add     nl,r0
-       cmp     r0,bl
-       ble     1f
-       jsr     pc,eject
-1:
-       rts     pc
-
-min:
-       tst     r0
-       bge     1f
-       clr     r0
-1:
-       rts     pc
-
-getname:
-       mov     r1,-(sp)
-       mov     r2,-(sp)
-       mov     (r5)+,r1
-       mov     $18.,r2
-1:
-       jsr     pc,getchar
-       cmp     r0,$041
-       blt     2f
-       cmp     r0,$0176
-       ble     4f
-2:
-       mov     r0,ch
-3:
-       clrb    (r1)+
-       mov     (sp)+,r2
-       mov     (sp)+,r1
-       rts     r5
-4:
-       movb    r0,(r1)+
-       dec     r2
-       beq     3b
-       br      1b
-
-copyb:
-       mov     (r1),r1
-       jsr     pc,flushi
-       clr     nlflg
-       mov     $1,-(sp)
-1:
-       jsr     pc,getchar
-       cmp     r0,$'\n
-       bne     2f
-       mov     $1,(sp)
-       clr     nlflg
-       br      4f
-2:
-       cmp     r0,$'.
-       bne     9f
-       cmp     (sp),$1
-       bgt     3f
-       blt     9f
-       inc     (sp)
-       br      4f
-3:
-       dec     r1
-       clr     r0
-       inc     (sp)
-       br      4f
-9:
-       clr     (sp)
-4:
-       tst     skp
-       bne     5f
-       jsr     pc,wbf
-5:
-       cmp     (sp),$3
-       bne     1b
-       tst     (sp)+
-       tst     skp
-       bne     6f
-       mov     r1,nextb
-6:
-       rts     pc
-
-popi:
-       cmp     ilistp,$ilist
-       beq     1f
-       sub     $2,ilistp
-       mov     *ilistp,ip
-1:
-       rts     pc
-
-wbf:
-       mov     r0,char
-       mov     r1,offb
-       mov     ibf,r0
-       sys     lseek;0; offb:..;0      /actually lseek
-       mov     ibf,r0
-       sys     write; char;1
-       inc     r1
-       cmp     ibf1,ofile
-       bne     1f
-       mov     $-1,ofile
-1:
-       rts     pc
-rbf:
-       mov     ip,r1
-       mov     ibf1,nfile
-       jsr     pc,rdsufb
-       tstb    r0
-       bne     2f
-       jsr     pc,popi
-       rts     pc
-2:
-       inc     ip
-       rts     pc
-
-alph:
-       movb    (r0),r2
-alph2:
-       cmp     r2,$'A
-       blo     1f
-       cmp     r2,$'Z
-       blos    2f
-       cmp     r2,$'a
-       blo     1f
-       cmp     r2,$'z
-       bhi     1f
-2:
-       sez
-       rts     pc
-1:
-       clz
-       rts     pc
-
-rdsufb:
-       mov     r1,-(sp)
-       bic     $77,r1
-       cmp     r1,sufoff
-       bne     1f
-       cmp     nfile,ofile
-       beq     2f
-1:
-       mov     r1,sufoff
-       mov     nfile,ofile
-       mov     nfile,r0
-       sys     lseek;0; sufoff: -1; 0  /actually lseek
-       mov     nfile,r0
-       sys     read; sufbuf; 512.
-2:
-       mov     (sp),r0
-       bic     $!77,r0
-       movb    sufbuf(r0),r0
-       mov     (sp)+,r1
-       rts     pc
diff --git a/usr/src/cmd/roff/roff4.s b/usr/src/cmd/roff/roff4.s
deleted file mode 100644 (file)
index 2972597..0000000
+++ /dev/null
@@ -1,516 +0,0 @@
-/
-/
-
-/ roff4 -- runoff
-
-text:
-/      inc     tottext
-       clr     ulstate
-       clr     wch
-       clr     wne
-       tst     ce
-       bne     nofill
-       tst     fi
-       beq     nofill
-       jsr     pc,getchar
-2:
-       mov     r0,ch
-       cmp     $' ,r0
-       bne     2f
-       jsr     pc,rbreak
-1:
-       jsr     pc,getchar
-       cmp     $' ,r0
-       bne     2b
-       inc     un
-       br      1b
-2:
-       cmp     r0,$'\n
-       bne     2f
-       jsr     pc,rbreak
-       clr     ch
-       jsr     pc,nline
-       br      4f
-2:
-       tst     wch
-       bne     3f
-       jsr     pc,getword
-               br 4f
-3:
-       jsr     pc,movword
-       bne     2b
-       jsr     pc,adjust
-       br      2b
-4:
-       dec     ul
-       bge     1f
-       clr     ul
-1:
-       rts     pc
-
-nofill:
-       jsr     pc,rbreak
-1:
-       jsr     pc,gettchar
-       cmp     r0,$'\n
-       beq     1f
-       jsr     pc,width
-       add     r1,ne
-       jsr     pc,storeline
-       br      1b
-1:
-       tst     ce
-       ble     2f
-       dec     ce
-       mov     nel,r0
-       asr     r0
-       bpl     1f
-       clr     r0
-1:
-       add     r0,un
-       tst     numbmod
-       beq     2f
-       add     $2,un
-2:
-       clr     fac
-       clr     fmq
-       mov     $1000,nwd
-       mov     $' ,r0
-       jsr     pc,storeline
-       jsr     pc,rbreak
-       dec     ul
-       bpl     2f
-       clr     ul
-2:
-       rts     pc
-
-adjust:
-       mov     r2,-(sp)
-       mov     r3,-(sp)
-       clr     r2
-       clr     r3
-       tst     ad
-       beq     1f
-       mov     nwd,r0
-       dec     r0
-       ble     1f
-       mov     nel,r3
-       ble     1f
-       dvd     r0,r2
-1:
-       mov     r3,fac
-       mov     r2,fmq
-       mov     (sp)+,r3
-       mov     (sp)+,r2
-       jsr     pc,rbreak
-       rts     pc
-
-fill:
-       mov     fmq,r0
-1:
-       inc     r0
-       dec     nc
-       cmpb    (r2)+,$' 
-       beq     1b
-       dec     r2
-       bit     $1,totout
-       beq     2f
-       inc     fac
-       cmp     fac,nwd
-       blt     1f
-       inc     r0
-       br      1f
-2:
-       dec     fac
-       bmi     1f
-       inc     r0
-1:
-       jsr     pc,space
-       movb    (r2),r0
-       rts     pc
-
-movword:
-       mov     wch,wordend
-       mov     wordp,r4
-       add     r4,wordend
-       tst     nwd
-       bne     2f
-1:
-       movb    (r4)+,r0
-       cmp     r0,$' 
-       bne     1f
-       dec     wch
-       jsr     pc,width
-       sub     r1,wne
-       br      1b
-1:
-       dec     r4
-2:
-       cmp     wne,nel
-       ble     1f
-       cmp     nel,$4
-       ble     1f
-       mov     ls,r0
-       add     nl,r0
-       cmp     r0,bl
-       bgt     2f
-       mov     ls,r0
-       asl     r0
-       add     nl,r0
-       cmp     r0,bl
-       bgt     1f
-2:
-       jsr     pc,hyphen
-1:
-       clr     nhyph
-       mov     wch,-(sp)
-1:
-       movb    (r4)+,r0
-       cmp     r0,$'-
-       bne     2f
-       movb    (r4),r2
-       jsr     pc,alph2
-       bne     2f
-       bisb    $200,(r4)
-2:
-       tst     r0
-       bpl     2f
-       bic     $!177,r0
-       mov     r4,r3
-       sub     $4,r3
-       cmp     r3,$word
-       blo     2f
-       movb    (r3),r2
-       bic     $!177,r2
-       jsr     pc,alph2
-       beq     3f
-       cmp     nel,$2
-       ble     2f
-3:
-       mov     r0,-(sp)
-       clr     r0
-       jsr     pc,storeline
-       mov     (sp)+,r0
-       inc     nhyph
-2:
-       jsr     pc,width
-       sub     r1,wne
-       jsr     pc,storeline
-       dec     wch
-       bne     1b
-       tst     nel
-       blt     1f
-       inc     nwd
-       tst     (sp)+
-       clz
-       rts     pc
-1:
-       mov     linep,r3
-1:
-       tst     nhyph
-       bne     2f
-       tst     nwd
-       beq     3f
-       cmp     wch,(sp)
-       beq     4f
-2:
-       movb    -(r3),r0
-       bne     2f
-       dec     nhyph
-       bne     5f
-       tst     nwd
-       beq     6f
-5:
-       tst     nel
-       ble     2f
-6:
-       cmpb    -1(r3),$'-
-       beq     3f
-       movb    $'-,(r3)
-       dec     nel
-       inc     ne
-       br      3f
-2:
-       dec     nc
-       tstb    (r3)
-       beq     1b
-       jsr     pc,width
-       sub     r1,ne
-       add     r1,nel
-       inc     wch
-       dec     r4
-       add     r1,wne
-       br      1b
-3:
-       inc     nwd
-4:
-       mov     r4,wordp
-       bicb    $!177,(r4)
-       cmp     r4,$word
-       bge     4f
-       4
-4:
-       tst     (sp)+
-       sez
-       rts     pc
-
-topbot:
-       mov     pl,r0
-       bne     1f
-       clr     bl
-       rts     pc
-1:
-       sub     ma3,r0
-       sub     ma4,r0
-       sub     hx,r0
-       mov     r0,bl
-       mov     ma1,r0
-       add     ma2,r0
-       add     hx,r0
-       cmp     r0,bl
-       blt     1f
-       mov     $2,r0
-       mov     r0,ma1
-       mov     r0,ma2
-       mov     r0,ma3
-       mov     r0,ma4
-       mov     $66.,pl
-       br      topbot
-1:
-       cmp     nl,bl
-       ble     1f
-       mov     bl,nl
-1:
-       rts     pc
-
-width:
-       cmp     r0,ohc
-       beq     2f
-       tst     r0
-       beq     2f
-       cmp     r0,$0177
-       beq     2f
-       cmp     r0,$010
-       bne     1f
-       mov     $-1,r1
-       rts     pc
-1:
-       cmp     $' ,r0
-       bgt     2f
-       mov     $1,r1
-       rts     pc
-2:
-       clr     r1
-       rts     pc
-
-headin:
-       jsr     pc,skipcont
-       mov     nextb,r1
-       mov     r1,*(r5)+
-       jsr     pc,gettchar
-       cmp     r0,$'\n
-       beq     2f
-       mov     r0,r2
-1:
-       jsr     pc,gettchar
-       cmp     r0,$'\n
-       beq     2f
-       cmp     r0,r2
-       bne     3f
-       clr     r0
-3:
-       jsr     pc,wbf
-       br      1b
-2:
-       clr     r0
-       jsr     pc,wbf
-       mov     r1,nextb
-       mov     ll,llh
-       rts     r5
-
-headout:
-       tst     hx
-       bne     0f
-       tst     (r5)+
-       rts     r5
-0:
-       clr     -(sp)
-       mov     *(r5),r2
-       mov     ibf1,nfile
-       jsr     r5,headseg; width
-       mov     r0,-(sp)
-       jsr     r5,headseg; width
-       mov     r0,-(sp)
-       jsr     r5,headseg; width
-       mov     r0,-(sp)
-       mov     po,r0
-       jsr     pc,space
-       tst     numbmod
-       beq     1f
-       mov     $5,r0
-       add     ni,r0
-       mov     r0,6(sp)
-1:
-       mov     *(r5)+,r2
-       jsr     r5,headseg; putchar
-       mov     llh,r0
-       add     6(sp),r0
-       sub     2(sp),r0
-       asr     r0
-       sub     4(sp),r0
-       bge     1f
-       clr     r0
-1:
-       mov     r0,-(sp)
-       jsr     pc,space
-       jsr     r5,headseg; putchar
-       mov     llh,r0
-       sub     (sp)+,r0
-       sub     (sp)+,r0
-       sub     (sp)+,r0
-       sub     (sp)+,r0
-       add     (sp)+,r0
-       jsr     pc,space
-       jsr     r5,headseg; putchar
-       jsr     pc,newline
-       rts     r5
-
-headseg:
-       clr     -(sp)
-1:
-       mov     r1,-(sp)
-       mov     r2,r1
-       inc     r2
-       jsr     pc,rdsufb
-       mov     (sp)+,r1
-       tstb    r0
-       beq     1f
-       cmp     r0,$'%
-       beq     2f
-       jsr     pc,*(r5)
-       add     r1,(sp)
-       br      1b
-2:
-       mov     pn,r0
-       clr     r1
-       tst     ro
-       beq     2f
-       mov     $ones,onesp
-       mov     $fives,fivesp
-       jsr     pc,roman
-       add     r1,(sp)
-       br      1b
-2:
-       jsr     pc,decml
-       add     r1,(sp)
-       br      1b
-1:
-       mov     (sp)+,r0
-       tst     (r5)+
-       rts     r5
-
-space:
-       jsr     r5,nlines; putchar
-       rts     pc
-
-nlines:
-       mov     r0,-(sp)
-1:
-       dec     (sp)
-       blt     1f
-       mov     $' ,r0
-       jsr     pc,*(r5)
-       br      1b
-1:
-       cmp     (r5)+,(sp)+
-       rts     r5
-
-decimal:
-       jsr     pc,decml
-       tst     (r5)+
-       rts     r5
-
-decml:
-       mov     r2,-(sp)
-       mov     r3,-(sp)
-       jsr     pc,decml1
-       mov     (sp)+,r3
-       mov     (sp)+,r2
-       rts     pc
-
-decml1:
-       mov     r1,-(sp)
-       clr     r2
-       mov     r0,r3
-       dvd     $10.,r2
-       mov     r3,-(sp)
-       mov     r2,r0
-       beq     1f
-       jsr     pc,decml
-       mov     r1,2(sp)
-1:
-       mov     (sp)+,r0
-       add     $'0,r0
-       jsr     pc,*(r5)
-       add     (sp)+,r1
-       rts     pc
-
-roman:
-       mov     r2,-(sp)
-       mov     r3,-(sp)
-       jsr     pc,roman1
-       mov     (sp)+,r3
-       mov     (sp)+,r2
-       rts     pc
-roman1:
-       clr     r2
-       mov     r0,r3
-       bne     .+4
-       rts     pc
-       mov     r1,-(sp)
-       dvd     $10.,r2
-       mov     r3,-(sp)
-       mov     r2,r0
-       inc     onesp
-       inc     fivesp
-       jsr     pc,roman
-       mov     r1,2(sp)
-       dec     onesp
-       dec     fivesp
-       clr     r2
-       mov     (sp)+,r3
-       dvd     $5.,r2
-       cmp     r3,$4
-       bne     1f
-       movb    *onesp,r0
-       jsr     pc,*(r5)
-       add     r1,(sp)
-       tst     r2
-       beq     2f
-       inc     onesp
-       movb    *onesp,r0
-       dec     onesp
-       br      3f
-2:
-       movb    *fivesp,r0
-3:
-       jsr     pc,*(r5)
-       add     (sp)+,r1
-       rts     pc
-1:
-       tst     r2
-       beq     2f
-       movb    *fivesp,r0
-       jsr     pc,*(r5)
-       add     r1,(sp)
-2:
-       dec     r3
-       blt     1f
-       movb    *onesp,r0
-       jsr     pc,*(r5)
-       add     r1,(sp)
-       br      2b
-1:
-       mov     (sp)+,r1
-       rts     pc
-
diff --git a/usr/src/cmd/roff/roff5.s b/usr/src/cmd/roff/roff5.s
deleted file mode 100644 (file)
index 790a990..0000000
+++ /dev/null
@@ -1,294 +0,0 @@
-/
-/
-
-/ hyp1 -- driver
-
-hyphen:
-       tst     hypedf
-       bne     3f
-       tst     hyf
-       beq     3f
-       inc     hypedf
-       mov     wordp,r0
-       clr     nhyph
-1:
-       jsr     pc,punct
-       bne     1f
-       inc     r0
-       br      1b
-1:
-       jsr     pc,alph
-       bne     3f
-1:
-       inc     r0
-       jsr     pc,alph
-       beq     1b
-       dec     r0
-       mov     r0,hstart
-1:
-       inc     r0
-       tstb    (r0)
-       beq     2f
-       jsr     pc,punct
-       bne     3f
-       br      1b
-2:
-       jsr     r5,suffix
-       jsr     r5,digram
-3:
-       rts     pc
-
-
-punct:
-       tst     old
-       bne 4f
-       cmpb    (r0),$010
-       beq     0f
-       movb    (r0),r2
-       jsr     pc,alph2
-       beq     0f
-       sez
-       rts      pc
-0:
-       clz
-       rts     pc
-4:
-       mov      $3f,r2
-1:
-       cmpb    (r0),(r2)+
-       beq     2f
-       tstb    (r2)
-       bne     1b
-       clz
-2:
-       rts     pc
-3: < .,()"\'`\0>       /should be more
-.even
-maplow:
-       cmp     r2,$'a
-       bhis    1f
-       add     $'a-'A,r2
-1:
-       rts     pc
-
-vowel:
-       cmp     r2,$'a
-       beq     1f
-       cmp     r2,$'e
-       beq     1f
-       cmp     r2,$'i
-       beq     1f
-       cmp     r2,$'o
-       beq     1f
-       cmp     r2,$'u
-       beq     1f
-       cmp     r2,$'y
-1:
-       rts     pc
-
-checkvow:
-       mov     r0,-(sp)
-1:
-       movb    -(r0),r2
-       jsr     pc,vowel
-       beq     1f
-       jsr     pc,alph
-       beq     1b
-       mov     (sp)+,r0
-       clz
-       rts     r5
-1:
-       mov     (sp)+,r0
-       sez
-       rts     r5
-
-/ hyp2 -- suffix and digram
-
-digram:
-       mov     hstart,r0
-1:
-       jsr     pc,alph
-       bne     3f
-       jsr     pc,vowel
-       beq     1f
-       dec     r0
-       br      1b
-1:
-       mov     r0,hstart
-1:
-       movb    -(r0),r2
-       jsr     pc,alph2
-       bne     3f
-       jsr     pc,vowel
-       bne     1b
-       clr     maxdig
-       mov     r0,nhstart
-1:
-       mov     $1,r3
-       movb    -1(r0),r2
-       jsr     pc,alph2
-       beq     2f
-       movb    (r0),r2
-       mov     $'a,r1
-       jsr     r5,dilook; bxh
-       br      4f
-2:
-       movb    -2(r0),r2
-       mov     $xxh,0f
-       jsr     pc,alph2
-       beq     2f
-       mov     $bxxh,0f
-2:
-       movb    -1(r0),r1
-       movb    (r0),r2
-       jsr     r5,dilook; 0:xxh
-4:
-       movb    (r0)+,r1
-       movb    (r0),r2
-       jsr     r5,dilook; xhx
-       movb    (r0),r1
-       movb    1(r0),r2
-       jsr     r5,dilook; hxx
-       cmp     r3,maxdig
-       blos    2f
-       mov     r3,maxdig
-       mov     r0,maxloc
-2:
-       cmp     r0,hstart
-       blo     1b
-       mov     nhstart,hstart
-       cmp     maxdig,thresh
-       blo     digram
-       bisb    $200,*maxloc
-       inc     nhyph
-/      mov     maxdig,*octbufp
-/      inc     octcnt
-/      add     $2,octbufp
-       br      digram
-3:
-       rts     r5
-
-dilook:
-       mov     r4,-(sp)
-       bic     $!177,r2
-       bic     $!177,r1
-       jsr     pc,maplow
-       sub     $'a,r2
-       cmp     r2,$'z-'a
-       bhi     3f
-       mov     r2,r4
-       mov     r1,r2
-       jsr     pc,maplow
-       sub     $'a,r2
-       cmp     r2,$'z-'a
-       bhi     3f
-       mov     r3,-(sp)
-       mov     r2,r3
-       mpy     $13.,r3
-       clr     r2
-       clc
-       ror     r4
-       adc     r2
-       add     r3,r4
-       add     (r5)+,r4
-       movb    (r4),r4
-       tst     r2
-       bne     1f
-       asr     r4
-       asr     r4
-       asr     r4
-       asr     r4
-1:
-       bic     $!17,r4
-       mov     r4,r3
-       mpy     (sp)+,r3
-       br      4f
-3:
-       clr     r3
-       tst     (r5)+
-4:
-       mov     (sp)+,r4
-       rts     r5
-
-suffix:
-       mov     hstart,r0
-       jsr     pc,alph
-       bne     4f
-       jsr     pc,maplow
-       sub     $'a,r2
-       asl     r2
-       mov     suftab(r2),-(sp)
-       bic     $!37777,(sp)
-       beq     3f
-1:
-       mov     hstart,r0
-       mov     (sp),r1
-       jsr     pc,rdsuf
-       movb    (r1),r3
-       beq     3f
-       bic     $!17,r3
-       add     r3,(sp)
-       add     r1,r3
-2:
-       movb    -(r3),r2
-       cmp     r3,r1
-       ble     2f
-       bic     $!177,r2
-       mov     r2,-(sp)
-       movb    -(r0),r2
-       jsr     pc,maplow
-       cmp     r2,(sp)+
-       bne     1b
-       br      2b
-2:
-       mov     hstart,r0
-       tst     (sp)+
-       movb    (r1),r3
-       bic     $!17,r3
-       add     r1,r3
-       bitb    $200,(r1)+
-       bne     1f
-2:
-       dec     r0
-       cmp     r3,r1
-       ble     2f
-       tstb    -(r3)
-       bpl     2b
-1:
-       mov     r0,hstart
-       dec     hstart
-       bitb    $100,-1(r1)
-       bne     2b
-       jsr     r5,checkvow
-       bne     4f
-       bisb    $200,(r0)
-       br      2b
-2:
-       bitb    $40,-(r1)
-       beq     suffix
-       br      4f
-3:
-       tst     (sp)+
-4:
-       rts     r5
-
-rdsuf:
-       mov     r0,-(sp)
-       mov     suff,nfile
-       mov     4(sp),r1
-       jsr     pc,rdsufb
-       mov     $sufb,r2
-       movb    r0,(r2)+
-       mov     r0,r3
-       bic     $!17,r3
-1:
-       dec     r3
-       blt     1f
-       inc     r1
-       jsr     pc,rdsufb
-       movb    r0,(r2)+
-       br      1b
-1:
-       mov     $sufb,r1
-       mov     (sp)+,r0
-       rts     pc
diff --git a/usr/src/cmd/roff/roff7.s b/usr/src/cmd/roff/roff7.s
deleted file mode 100644 (file)
index 8b52a04..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/
-/
-
-/ hyp4 -- digram tables
-
-bxh:
-.byte 060,000,040,000,040,000,000,040,000,000,040,000,040
-
-hxx:
-.byte 006,042,041,123,021,024,063,042,002,043,021,001,022
-.byte 140,000,200,003,260,006,000,160,007,000,140,000,320
-.byte 220,000,160,005,240,010,000,100,006,000,200,000,320
-.byte 240,000,120,003,140,000,000,240,010,000,220,000,160
-.byte 042,023,041,040,040,022,043,041,030,064,021,000,041
-.byte 100,000,140,000,220,006,000,140,003,000,200,000,000
-.byte 200,000,120,002,220,010,000,160,006,000,140,000,320
-.byte 020,000,020,000,020,000,000,020,000,000,020,000,000
-.byte 043,163,065,044,022,043,104,042,061,146,061,000,007
-.byte 100,000,140,000,040,000,000,100,000,000,120,000,000
-.byte 140,000,040,011,060,004,001,120,003,000,140,000,040
-.byte 200,000,100,000,140,000,000,140,000,000,140,000,240
-.byte 200,000,140,000,160,000,000,220,000,000,140,000,240
-.byte 200,000,140,000,160,000,000,220,000,000,060,000,240
-.byte 021,043,041,121,040,023,042,003,142,042,061,001,022
-.byte 120,000,140,010,140,010,000,140,002,000,120,000,120
-.byte 000,000,000,000,360,000,000,000,000,000,160,000,000
-.byte 100,000,040,005,120,000,000,100,000,000,060,000,140
-.byte 140,040,100,001,240,041,000,242,000,002,140,000,100
-.byte 240,000,120,002,200,000,000,320,007,000,240,000,340
-.byte 101,021,041,020,040,005,042,121,002,021,201,000,020
-.byte 160,000,100,000,140,000,000,160,006,000,220,000,140
-.byte 140,000,020,001,020,000,000,100,001,000,300,000,000
-.byte 000,000,000,000,000,000,000,000,000,000,000,000,000
-.byte 106,041,040,147,040,000,063,041,001,102,160,002,002
-.byte 300,000,040,017,140,017,000,240,000,000,140,000,120
-
-bxxh:
-.byte 005,150,153,062,062,246,152,127,146,203,310,017,206
-.byte 100,000,120,000,140,000,000,100,000,000,120,000,060
-.byte 100,000,040,000,060,000,000,060,000,000,220,000,040
-.byte 100,000,120,000,200,000,000,100,000,000,140,000,060
-.byte 043,142,046,140,062,147,210,131,046,106,246,017,111
-.byte 060,000,020,000,060,000,000,040,000,000,100,000,000
-.byte 060,000,040,000,040,000,000,040,000,000,100,000,040
-.byte 100,000,100,000,100,000,000,040,000,000,100,000,140
-.byte 066,045,145,140,000,070,377,030,130,103,003,017,006
-.byte 040,000,040,000,020,000,000,040,000,000,100,000,000
-.byte 200,000,020,000,140,000,000,120,000,000,120,000,040
-.byte 120,000,040,000,060,000,000,060,000,000,160,000,040
-.byte 120,000,040,000,120,000,000,040,000,000,160,000,040
-.byte 120,000,020,000,140,000,000,120,000,000,140,000,040
-.byte 051,126,150,140,060,210,146,006,006,165,003,017,244
-.byte 120,000,040,000,160,000,000,140,000,000,060,000,140
-.byte 000,000,000,000,000,000,000,000,000,000,000,000,000
-.byte 140,000,140,000,060,000,000,100,000,000,140,000,020
-.byte 120,000,020,000,060,000,000,060,000,000,060,000,040
-.byte 140,000,020,000,100,000,000,140,000,000,140,000,020
-.byte 070,125,051,162,120,105,126,104,006,044,000,017,052
-.byte 140,000,020,000,140,000,000,060,000,000,060,000,040
-.byte 020,000,000,000,020,000,000,000,000,000,000,000,060
-.byte 140,000,160,000,200,000,000,140,000,000,000,000,240
-.byte 065,042,060,200,000,210,222,146,006,204,220,012,003
-.byte 240,000,020,000,120,000,000,200,000,000,200,000,240
-
-xhx:
-.byte 032,146,042,107,076,102,042,146,202,050,006,000,051
-.byte 036,377,057,013,057,366,377,057,001,377,057,000,040
-.byte 037,377,020,000,100,022,377,057,362,116,100,000,017
-.byte 057,377,057,031,137,363,377,037,362,270,077,000,117
-.byte 074,142,012,236,076,125,063,165,341,046,047,000,024
-.byte 020,017,075,377,040,001,377,017,001,204,020,000,040
-.byte 057,017,057,340,140,362,314,117,003,302,100,000,057
-.byte 057,357,077,017,100,366,314,057,342,346,037,000,060
-.byte 252,145,072,157,377,165,063,066,164,050,363,000,362
-.byte 000,000,020,000,020,000,000,017,000,000,020,000,000
-.byte 117,017,237,377,200,354,125,110,004,257,000,000,300
-.byte 057,367,054,357,157,216,314,114,217,353,053,000,057
-.byte 077,213,077,077,177,317,377,114,377,352,077,000,076
-.byte 077,213,077,077,157,177,377,054,377,352,117,000,075
-.byte 125,230,065,216,057,066,063,047,345,126,011,000,033
-.byte 057,377,051,360,120,361,273,056,001,256,057,000,060
-.byte 000,000,000,000,000,000,000,000,000,000,000,000,000
-.byte 076,310,056,310,137,174,273,055,335,266,033,000,155
-.byte 077,157,057,360,057,063,042,024,077,206,020,000,040
-.byte 057,037,077,360,100,365,377,037,362,176,050,000,026
-.byte 167,146,042,112,077,110,062,254,366,052,377,000,163
-.byte 060,000,040,000,120,000,377,060,012,000,037,000,257
-.byte 037,232,157,361,040,003,125,010,001,256,000,000,340
-.byte 377,377,377,377,377,377,377,377,377,377,377,017,277
-.byte 253,315,257,216,377,206,146,306,371,126,232,000,004
-.byte 057,012,100,360,160,360,000,040,000,017,157,000,176
-
-xxh:
-.byte 045,150,154,162,042,246,210,147,152,103,230,017,206
-.byte 100,000,040,000,140,000,000,100,000,021,120,017,060
-.byte 100,000,040,002,140,320,000,060,000,001,220,017,040
-.byte 100,001,120,001,241,000,000,100,000,020,140,017,060
-.byte 023,162,046,142,022,207,210,131,052,106,250,017,110
-.byte 060,000,042,000,160,000,000,040,000,212,100,017,000
-.byte 140,000,040,002,140,000,000,120,000,040,120,017,040
-.byte 100,000,100,000,140,001,021,140,000,046,100,017,140
-.byte 066,045,025,201,020,130,146,030,130,103,025,017,006
-.byte 100,000,040,000,020,000,000,040,000,000,200,017,000
-.byte 200,000,020,001,140,000,000,140,000,000,120,017,040
-.byte 120,026,042,020,140,161,042,143,000,022,162,017,040
-.byte 121,042,060,020,140,200,000,123,000,021,220,017,041
-.byte 121,042,060,120,140,200,000,123,000,021,160,017,041
-.byte 051,126,150,141,060,210,146,066,026,165,026,017,247
-.byte 120,000,040,003,160,000,000,140,000,021,100,017,140
-.byte 000,000,000,000,200,000,000,000,000,000,000,017,000
-.byte 141,023,122,040,160,143,042,142,000,047,143,017,020
-.byte 120,000,040,006,140,060,000,141,000,026,100,017,040
-.byte 140,000,020,007,100,000,000,140,000,001,140,017,020
-.byte 110,125,051,162,120,125,127,104,006,104,000,017,052
-.byte 140,000,040,000,160,000,000,140,000,000,060,017,000
-.byte 040,005,020,000,040,313,231,030,000,140,000,017,056
-.byte 140,000,160,000,200,000,000,140,000,000,000,017,240
-.byte 065,042,060,040,000,206,231,146,006,224,220,017,004
-.byte 240,000,020,000,140,000,000,220,000,000,200,017,141
-
-.even
diff --git a/usr/src/cmd/roff/roff8.s b/usr/src/cmd/roff/roff8.s
deleted file mode 100644 (file)
index 0a94bdd..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/
-/
-
-/ roff5 -- runoff
-
-slow:  1
-pto:   9999.
-po:    0
-ls:    1
-ls1:   1
-pn:    1
-ma1:   2
-ma2:   2
-ma3:   1
-ma4:   3
-ll:    65.
-llh:   65.
-hx:    1
-pl:    66.
-ad:    1
-fi:    1
-cc:    '.
-ohc:   200
-hyf:   1
-hypedf:        0
-obufp: obuf
-thresh:        240
-tabc:  ' 
-tabtab:
-       .byte 8.,16.,24.,32.,40.,48.,56.,64.,72.,80.
-       .byte 88.,96.,104.,112.,120.,128.,136.,144.,152.,160.
-       .byte 0,0,0,0,0,0,0,0,0,0
-etabtab: 0
-suffil:
-       </usr/lib/suftab\0>
-ones:
-       <ixcm>
-fives:
-       <vld>
-bfn:   </tmp/rtma\0>
-       .even
-ofile: -1
-nextb: 4
-ilistp:        ilist
-
-.bss
-old:   .=.+2
-stop:  .=.+2
-garb:  .=.+2
-bname:
-nextf: .=.+20.
-nx:    .=.+2
-ibf:   .=.+2
-ibf1:  .=.+2
-skp:   .=.+2
-ip:    .=.+2
-ilist: .=.+8.
-iliste:        .=.+2
-column:        .=.+2
-ocol:  .=.+2
-nspace:        .=.+2
-fac:   .=.+2
-fmq:   .=.+2
-nhl:   .=.+2
-nel:   .=.+2
-jfomod:        .=.+2
-wordp: .=.+2
-nlflg: .=.+2
-/tottext: .=.+2
-/totcon: .=.+2
-spaceflg: .=.+2
-ch:    .=.+2
-linep: .=.+2
-undflg:        .=.+2
-wordend:       .=.+2
-maxdig:        .=.+2
-maxloc:        .=.+2
-totout:        .=.+2
-hstart:        .=.+2
-nhstart: .=.+2
-nhyph: .=.+2
-argc:  .=.+2
-argp:  .=.+2
-ibufp: .=.+2
-eibuf: .=.+2
-wne:   .=.+2
-nl:    .=.+2
-bl:    .=.+2
-nc:    .=.+2
-ne:    .=.+2
-lnumber:       .=.+2
-numbmod:       .=.+2
-skip:  .=.+2
-nwd:   .=.+2
-ulstate:       .=.+2
-ulc:   .=.+2
-bsc:   .=.+2
-nsp:   .=.+2
-nn:    .=.+2
-ro:    .=.+2
-pfrom: .=.+2
-ni:    .=.+2
-onesp: .=.+2
-fivesp:        .=.+2
-ul:    .=.+2
-ce:    .=.+2
-in:    .=.+2
-un:    .=.+2
-wch:   .=.+2
-suff:  .=.+2
-sufb:  .=.+20.
-sufbuf:        .=.+512.
-suftab:        .=.+[2*26.]
-ifile: .=.+2
-char:  .=.+2
-nfile: .=.+2
-ehead: .=.+2
-ohead: .=.+2
-efoot: .=.+2
-ofoot: .=.+2
-trtab: .=.+128.
-word:  .=.+200.
-
-stbuf:
-linsiz = 500.
-line:  .=.+linsiz
-end:
-
index a24e40c..e1f2c97 100644 (file)
@@ -206,7 +206,7 @@ char **argv;
        if (tab[i].name[0]) {
                ft = tab[i].count;
                column(ft, tab[i].realt, tab[i].cput, tab[i].syst);
        if (tab[i].name[0]) {
                ft = tab[i].count;
                column(ft, tab[i].realt, tab[i].cput, tab[i].syst);
-               printf("   %.10s\n", tab[i].name);
+               printf("   %.14s\n", tab[i].name);
        }
 }
 
        }
 }
 
@@ -308,7 +308,7 @@ char *f;
                }
                x = expand(fbuf.ac_utime) + expand(fbuf.ac_stime);
                if (uflg) {
                }
                x = expand(fbuf.ac_utime) + expand(fbuf.ac_stime);
                if (uflg) {
-                       printf("%3d%6.1f %.10s\n", fbuf.ac_uid&0377, x/60.0,
+                       printf("%3d%6.1f %.14s\n", fbuf.ac_uid&0377, x/60.0,
                           fbuf.ac_comm);
                        continue;
                }
                           fbuf.ac_comm);
                        continue;
                }
@@ -457,7 +457,7 @@ strip()
        j = enter("**junk**");
        for (i = 0; i<size; i++) {
                if (tab[i].name[0] && tab[i].count<=thres) {
        j = enter("**junk**");
        for (i = 0; i<size; i++) {
                if (tab[i].name[0] && tab[i].count<=thres) {
-                       printf("%.10s--", tab[i].name);
+                       printf("%.14s--", tab[i].name);
                        if ((c=getchar())=='y') {
                                tab[i].name[0] = '\0';
                                tab[j].count += tab[i].count;
                        if ((c=getchar())=='y') {
                                tab[i].name[0] = '\0';
                                tab[j].count += tab[i].count;
diff --git a/usr/src/cmd/sdb/Makefile b/usr/src/cmd/sdb/Makefile
new file mode 100644 (file)
index 0000000..17120b0
--- /dev/null
@@ -0,0 +1,35 @@
+sdb:   a.out
+
+decode.o:      head.h decode.c
+docomm.o:      head.h docomm.c
+main.o:                head.h main.c
+sub.o:         head.h sub.c
+re.o:          head.h re.c
+fio.o:         head.h fio.c
+bio.o:         bio.h bio.c
+access.o:      defs.h mac.h machine.h mode.h access.c
+pcs.o:         head.h defs.h mac.h machine.h mode.h pcs.c
+runpcs.o:      head.h defs.h mac.h machine.h mode.h runpcs.c
+xeq.o:         head.h xeq.c
+setup.o:       head.h defs.h mac.h machine.h mode.h setup.c
+message.o:     defs.h mac.h machine.h mode.h message.c
+udef.o:                udef.c
+symt.o:                bio.h head.h defs.h symt.c
+display.o:     bio.h head.h defs.h cdefs.h display.c
+
+.c.o:; cc -c -g $*.c
+
+a.out: main.o re.o fio.o bio.o decode.o docomm.o sub.o head.h \
+       access.o pcs.o runpcs.o setup.o message.o udef.o \
+       symt.o display.o xeq.o
+       cc -g -o sdb *.o
+       echo DONE
+
+install :
+       install -s sdb $(DESTDIR)/usr/bin
+
+clean :
+       rm *.o  sdb
+
+print:
+       pr *.h *.c
diff --git a/usr/src/cmd/sdb/a.out.h b/usr/src/cmd/sdb/a.out.h
new file mode 100644 (file)
index 0000000..538c822
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Format of an a.out header
+ */
+struct exec {  /* a.out header */
+       int             a_magic;        /* magic number */
+       unsigned        a_text;         /* size of text segment */
+       unsigned        a_data;         /* size of initialized data */
+       unsigned        a_bss;          /* size of uninitialized data */
+       unsigned        a_syms;         /* size of symbol table */
+       unsigned        a_entry;        /* entry point */
+       unsigned        a_trsize;       /* size of text relocation */
+       unsigned        a_drsize;       /* size of data relocation */
+};
+
+#define        A_MAGIC1        0407            /* normal */
+#define        A_MAGIC2        0410            /* read-only text */
+#define        A_MAGIC3        0411            /* separated I&D */
+#define        A_MAGIC4        0405            /* overlay */
+
+struct nlist { /* symbol table entry */
+       char    n_name[8];      /* symbol name */
+       char    n_type;         /* type flag */
+       char    n_other;
+       short   n_desc;
+       unsigned n_value;       /* value */
+};
+
+       /* values for type flag */
+#define        N_UNDF  0               /* undefined */
+#define        N_ABS   02              /* absolute */
+#define        N_TEXT  04              /* text */
+#define        N_DATA  06              /* data */
+#define        N_BSS   08
+#define        N_TYPE  037
+#define        N_FN    037             /* file name symbol */
+
+#define        N_GSYM  0040            /* global sym: name,,type,0 */
+#define        N_FUN   0044            /* function: name,,linenumber,address */
+#define        N_STSYM 0046            /* static symbol: name,,type,address */
+#define        N_RSYM  0100            /* register sym: name,,register,offset */
+#define        N_SLINE 0104            /* src line: ,,linenumber,address */
+#define        N_SSYM  0140            /* structure elt: name,,type,struct_offset */
+#define        N_SO    0144            /* source file name: name,,,address */
+#define        N_LSYM  0200            /* local sym: name,,type,offset */
+#define        N_SOL   0204            /* #line source filename: name,,,address */
+#define        N_PSYM  0240            /* parameter: name,,type,offset */
+#define        N_LBRAC 0300            /* left bracket: ,,nesting level,address */
+#define        N_RBRAC 0340            /* right bracket: ,,nesting level,address */
+#define        N_LENG  0376            /* second stab entry with length information */
+
+#define        N_EXT   01              /* external bit, or'ed in */
+
+#define        FORMAT  "%08x"
+
+#define        STABTYPES       0340
diff --git a/usr/src/cmd/sdb/access.c b/usr/src/cmd/sdb/access.c
new file mode 100644 (file)
index 0000000..875928d
--- /dev/null
@@ -0,0 +1,143 @@
+#
+/*
+ *
+ *     UNIX debugger
+ *
+ */
+
+#include "head.h"
+struct user u;
+
+
+MSG            BADDAT;
+MSG            BADTXT;
+MAP            txtmap;
+MAP            datmap;
+STRING         errflg;
+int            errno;
+
+INT            pid;
+
+
+
+
+/* file handling and access routines */
+
+int dmask[5] = {0, 0xff, 0xffff, 0xffffff, 0xffffffff};
+
+/* get data at loc using descriptor format d */
+long
+getval(loc, d)
+ADDR loc;
+char d; {
+       register int val;
+       
+       val = get(loc, DSP);
+       val &= dmask[dtol(d)];
+       return(val);
+}
+
+/* put value at loc using descriptor format d */
+putval(loc, d, value)
+ADDR loc; char d; long value; {
+       register long val;
+       
+       val = get(loc, DSP);
+       val = (val & !dmask[dtol(d)]) | (value & dmask[dtol(d)]);
+       put(loc, DSP, val);
+}
+
+/* put value in named register using descriptor format d */
+putreg(reg, d, value)
+ADDR reg; char d; long value; {
+       register long val;
+       
+       val = *(ADDR *)(((ADDR)&u)+R0+WORDSIZE*reg);
+       val = (val & !dmask[dtol(d)]) | (value & dmask[dtol(d)]);
+       *(ADDR *)(((ADDR)&u)+R0+WORDSIZE*reg) = val;
+}
+
+put(adr,space,value)
+#ifndef EDDT
+L_INT  adr;
+{
+       access(WT,adr,space,value);
+}
+#else
+       L_INT *adr; {*adr=value;}
+#endif
+
+POS    get(adr, space)
+#ifndef EDDT
+L_INT          adr;
+{
+       return(access(RD,adr,space,0));
+}
+#else
+       L_INT *adr; {return(*adr);}
+#endif
+
+
+#ifndef EDDT
+access(mode,adr,space,value)
+L_INT  adr;
+{
+       INT     pmode,rd,file;
+       ADDR    w;
+       rd = mode==RD;
+
+       IF space == NSP THEN return(0); FI
+
+       IF pid          /* tracing on? */
+       THEN
+#ifndef vax
+               IF adr&01 ANDF !rd THEN error(ODDADR); FI
+#endif
+            pmode = (space&DSP?(rd?RDUSER:WDUSER):(rd?RIUSER:WIUSER));
+            w = ptrace(pmode, pid, adr, value);
+#ifndef vax
+            IF adr&01
+            THEN w1 = ptrace(pmode, pid, shorten(adr+1), value);
+                 w = (w>>8)&LOBYTE | (w1<<8);
+            FI
+#endif
+            IF errno
+            THEN errflg = (space&DSP ? BADDAT : BADTXT);
+            FI
+            return(w);
+       FI
+       w = 0;
+       IF !chkmap(&adr,space)
+       THEN return(0);
+       FI
+       file=(space&DSP?datmap.ufd:txtmap.ufd);
+       IF longseek(file,adr)==0 ORF
+          (rd ? read(file,&w,sizeof(w)) : write(file,&value,sizeof(w))) < 1
+       THEN    errflg=(space&DSP?BADDAT:BADTXT);
+       FI
+       return(w);
+
+}
+#endif
+
+chkmap(adr,space)
+       REG L_INT       *adr;
+       REG INT         space;
+{
+       REG MAPPTR amap;
+       amap=((space&DSP?&datmap:&txtmap));
+       IF space&STAR ORF !within(*adr,amap->b1,amap->e1)
+       THEN IF within(*adr,amap->b2,amap->e2)
+            THEN *adr += (amap->f2)-(amap->b2);
+            ELSE errflg=(space&DSP?BADDAT:BADTXT); return(0);
+            FI
+       ELSE *adr += (amap->f1)-(amap->b1);
+       FI
+       return(1);
+}
+
+within(adr,lbd,ubd)
+POS    adr, lbd, ubd;
+{
+       return(adr>=lbd && adr<ubd);
+}
diff --git a/usr/src/cmd/sdb/bio.c b/usr/src/cmd/sdb/bio.c
new file mode 100644 (file)
index 0000000..c5050f7
--- /dev/null
@@ -0,0 +1,70 @@
+#include "bio.h"
+
+/*
+ * NAMES:  bread(), brseek(), blseek()
+ *
+ * DESCRIPTION:
+ *      This is a buffered read package.
+ *
+ *       Bread may be called with a negative nbytes which causes it to
+ *      read backwards.  In this case, buffer should point to the first
+ *      byte following the buffer.  If only a partial read is possible
+ *      (due to beginning of file), only the last bytes of the buffer
+ *      will be filled.
+ */
+
+
+bread(brs, buff, nbytes)
+struct brbuf *brs; char *buff; {
+       register int k, nb;
+
+       if (nbytes > 0) {
+               for (nb=nbytes; nb>0; nb--) {
+                       if (brs->nr == 0) {
+                               brs->nr = read(brs->fd, brs->next=brs->b, 512);
+                               brs->nl = 0;
+                               if (brs->nr < 0) return(-1);
+                               if (brs->nr == 0) return(nbytes-nb);
+                               }
+                       *buff++ = *brs->next++;
+                       brs->nr--;
+                       brs->nl++;
+                       }
+               }
+       else {
+               nbytes = -nbytes;
+               for (nb=nbytes; nb>0; nb--) {
+                       if (brs->nl == 0) {
+                               lseek(brs->fd, (long) -(512 + brs->nr), 1);
+                               brs->nl = read(brs->fd, brs->b, 512);
+                               if (brs->nl < 0) {
+                                       for (k=511; k>0; k--) {
+                                               lseek(brs->fd, 1, 1);
+                                               brs->nl = read(brs->fd, brs->b, k);
+                                               if (brs->nl >= 0) break;
+                                               }
+                                       if (brs->nl < 0) return(nbytes-nb);
+                                       }
+                               if (brs->nl == 0) return(nbytes-nb);
+                               brs->next = brs->b + brs->nl;
+                               brs->nr = 0;
+                               }
+                       *--buff = *--brs->next;
+                       brs->nr++;
+                       brs->nl--;
+                       }
+               }
+       return(nbytes);
+       }
+
+blseek(brs, offset, flag) 
+struct brbuf *brs; long offset; {
+       brs->nl = 0;
+       brs->nr = 0;
+       return(lseek(brs->fd,offset,flag));
+       }
+
+binit(brs)
+struct brbuf *brs; {
+       brs->nl = brs->nr = 0;
+}
diff --git a/usr/src/cmd/sdb/bio.h b/usr/src/cmd/sdb/bio.h
new file mode 100644 (file)
index 0000000..ebbc15e
--- /dev/null
@@ -0,0 +1,6 @@
+struct brbuf {
+       int     nl, nr;
+       char    *next;
+       char    b[512];
+       int     fd;
+};
diff --git a/usr/src/cmd/sdb/cdefs.h b/usr/src/cmd/sdb/cdefs.h
new file mode 100644 (file)
index 0000000..e8c946d
--- /dev/null
@@ -0,0 +1,32 @@
+/* type modifiers */
+
+# define PTR  020
+# define FTN  040
+# define ARY  060
+
+/* type packing constants */
+
+# define TMASK 060
+# define TMASK1 0300
+# define TMASK2  0360
+# define BTMASK 017
+# define BTSHIFT 4
+# define TSHIFT 2
+
+/*     macros  */
+
+# define BTYPE(x)  (x&BTMASK)   /* basic type of x */
+# define ISUNSIGNED(x) ((x)<=ULONG&&(x)>=UCHAR)
+# define UNSIGNABLE(x) ((x)<=LONG&&(x)>=CHAR)
+# define ENUNSIGN(x) ((x)+(UNSIGNED-INT))
+# define DEUNSIGN(x) ((x)+(INT-UNSIGNED))
+# define ISPTR(x) ((x&TMASK)==PTR)
+# define ISFTN(x)  ((x&TMASK)==FTN)  /* is x a function type */
+# define ISARY(x)   ((x&TMASK)==ARY)   /* is x an array type */
+# define INCREF(x) (((x&~BTMASK)<<TSHIFT)|PTR|(x&BTMASK))
+# define DECREF(x) (((x>>TSHIFT)&~BTMASK)|(x&BTMASK))
+       /* pack and unpack field descriptors (size and offset) */
+# define PKFIELD(s,o) ((o<<6)|s)
+# define UPKFSZ(v)  (v&077)
+# define UPKFOFF(v) (v>>6)
+
diff --git a/usr/src/cmd/sdb/decode.c b/usr/src/cmd/sdb/decode.c
new file mode 100644 (file)
index 0000000..bdd285c
--- /dev/null
@@ -0,0 +1,108 @@
+#include "head.h"
+
+/* decode() - read a line from standard input and decode it */
+
+decode() {
+       register char c, *q;
+       char *p;
+       integ = scallf = reflag = 0;
+       proc[0] = cmd = args[0] = var[0] = '\0';
+       argsp = args;
+       
+       p = readline(stdin);
+       
+/*
+       if (*p == '/'  &&  *(p+1) == '\n') {
+               cmd = '/';
+               return(0);
+       }
+*/
+       
+       if (eqany(*p, "/?")) {  /* regular expression */
+               c = *p;
+               redir = (c == '/');
+               reflag = 1;
+               p++;
+               if (*p == '\n' || *p == c) return(0);
+               q = re;
+               while(*p != c && *p != '\n') *q++ = *p++;
+               *q = '\0';
+               return(0);
+       }
+       
+       if (*p == '!') { /* shell escape */
+               for (q = p; *q != '\n'; q++) ;
+               *q = '\0';
+               system(p+1);
+               return(0);
+       }
+       
+       if (*p == '\n') {
+               cmd = '\n';
+               return(0);
+       }
+       
+       while (*p != '\n') {    /* decode item by item */
+       
+               if (number(*p)) {       /* decimal number */
+                       if(integ) {
+                               error("Too many numbers");
+                               return(1);
+                       }
+                       integ = readint(&p);
+                       continue;
+               }
+               
+               if (varchar(*p) || eqany(*p, COMMANDS)) { 
+                                       /* proc, variable or command */
+                       if (cmd != '\0') {
+                               p = cpall(args, p);
+                               continue;
+                       }
+                       q = p;
+                       while (varchar(*q) || number(*q) || eqany(*q,COMMANDS))
+                               q++;
+                       if (*q == '(') {        /* procedure call */
+                               if (proc[0] != '\0') {
+                                       error("Too many procedure calls");
+                                       return(1);
+                               }
+                               scallf = 1;
+                               p = cpname(proc, p);
+                               p = cpall(args, p);
+                               continue;
+                       }
+                       if (*q == ':') {        /* procedure name */
+                               p = cpname(proc, p);
+                               continue;
+                       }
+                       if (*q == '$') {        /* variable name */
+                               p = cpname(var, p);
+                               continue;
+                       }
+                       if ((q-p == 1 && eqany(*p,COMMANDS) && 
+                               (proc[0]=='\0' || *p == 'b')) ||
+                               integ || eqany(*p, "+-")) 
+                                                       {  /* command */
+                               cmd = *p++;
+                               continue;
+                       }
+                       /* otherwise, its a variable */
+                       if (var[0] != '\0') {
+                               error("Too many variable names");
+                               return(1);
+                       }
+                       p = cpname(var, p);
+                       if (*p == '\n') {
+                               cmd = '/';
+                               continue;
+                       }
+                       if (cmd == '\0') cmd = *p ? *p : '/';
+                       p++;
+                       p = cpall(args,p);
+                       continue;
+               }
+               p++;    /* otherwise ignore p */
+       }
+       return(0);
+}
diff --git a/usr/src/cmd/sdb/defs.h b/usr/src/cmd/sdb/defs.h
new file mode 100644 (file)
index 0000000..79a3ae2
--- /dev/null
@@ -0,0 +1,183 @@
+#
+/*
+ *
+ *     UNIX debugger - common definitions
+ *
+ */
+
+
+
+/*     Layout of a.out file (fsym):
+ *
+ *     header of 8 longwords
+ *                             magic number 410
+ *                             text size       )
+ *                             data size       ) padded with 0 to multiple of 4 bytes
+ *                             bss size        )
+ *                             symbol table size
+ *                             entry address
+ *                             size of text relocation info
+ *                             size of data relocation info
+ *
+ *
+ *     header:         0
+ *     text:           32
+ *     data:           32+textsize
+ *     text reloc:     32+textsize+datasize
+ *     data reloc:     32+textsize+datasize+textreloc
+ *     symbol table:   32+textsize+datasize+textreloc+datareloc
+ *
+ */
+
+#ifdef EDDT
+#define printf printadb
+#endif
+
+#include <sys/param.h>
+#include <sys/dir.h>
+#include <sys/psl.h>
+#include <sys/user.h>
+#include "mac.h"
+#include "mode.h"
+
+
+#define VARB   11
+#define VARD   13
+#define VARE   14
+#define VARM   22
+#define VARS   28
+#define VART   29
+
+#define COREMAGIC 0140000
+
+/* access modes */
+#define RD     0
+#define WT     1
+
+/* access spaces */
+#define NSP    0
+#define        ISP     1
+#define        DSP     2
+
+#define STAR   4
+#define STARCOM 0200
+#define DSYM   4
+#define ISYM   4
+#define ASYM   2
+#define NSYM   0
+#define ESYM   (-1)
+#define BKPTSET        1
+#define BKPTEXEC 2
+#define        SYMSIZ  100
+#define MAXSIG 20
+
+#define USERPS PSL
+#define USERPC PC
+#define BPT    03
+#define TBIT   020
+#define FD     0200
+
+/* ptracew modes */
+#define        SETTRC  0
+#define        RDUSER  2
+#define        RIUSER  1
+#define        WDUSER  5
+#define WIUSER 4
+#define        RUREGS  3
+#define        WUREGS  6
+#define        CONTIN  7
+#define        EXIT    8
+#define SINGLE 9
+
+#define FROFF  (&(0->fpsr))
+#define FRLEN  25
+#define FRMAX  6
+
+/* the quantities involving ctob() are located in the kernel stack.
+/* the others are in the pcb.
+*/
+#define KSP 0
+#define ESP 4
+#define SSP 8
+#define USP (ctob(4)-5*4)
+#define R0 (ctob(4)-19*4)
+#define R1 (ctob(4)-18*4)
+#define R2 (ctob(4)-17*4)
+#define R3 (ctob(4)-16*4)
+#define R4 (ctob(4)-15*4)
+#define R5 (ctob(4)-14*4)
+#define R6 (ctob(4)-13*4)
+#define R7 (ctob(4)-12*4)
+#define R8 (ctob(4)-11*4)
+#define R9 (ctob(4)-10*4)
+#define R10 (ctob(4)-9*4)
+#define R11 (ctob(4)-8*4)
+#define AP (ctob(4)-7*4)
+#define FP (ctob(4)-6*4)
+#define PC (ctob(4)-2*4)
+#define PSL (ctob(4)-1*4)
+#define P0BR 80
+#define P0LR 84
+#define P1BR 88
+#define P1LR 92
+
+#define MAXOFF 255
+#define MAXPOS 80
+#define MAXLIN 128
+#define EOR    '\n'
+#define SP     ' '
+#define TB     '\t'
+#define QUOTE  0200
+#define STRIP  0177
+#define LOBYTE 0377
+#define EVEN   -2
+
+
+#ifndef vax
+#define leng(a)                ((long)((unsigned)(a)))
+#define shorten(a)     ((int)(a))
+#define itol(a,b)      (itolws.I[0]=(a), itolws.I[1]=(b), itolws.L)
+#else
+#define leng(a)                itol(0,a)
+#define shorten(a)     ((short)(a))
+#define itol(a,b)      (itolws.I[0]=(b), itolws.I[1]=(a), itolws.L)
+#endif
+
+
+
+/* result type declarations */
+L_INT          inkdot();
+SYMPTR         lookupsym();
+SYMPTR         symget();
+POS            get();
+POS            chkget();
+STRING         exform();
+L_INT          round();
+BKPTR          scanbkpt();
+VOID           fault();
+
+
+INT            mkfault;
+INT            executing;
+CHAR           *lp;
+L_INT          maxoff;
+L_INT          maxpos;
+ADDR           sigint;
+ADDR           sigqit;
+INT            wtflag;
+L_INT          maxfile;
+L_INT          maxstor;
+L_INT          txtsiz;
+L_INT          datsiz;
+L_INT          datbas;
+L_INT          stksiz;
+STRING         errflg;
+INT            magic;
+L_INT          entrypt;
+
+CHAR           lastc;
+
+STRING         symfil;
+STRING         corfil;
+MAP            txtmap;
+MAP            datmap;
diff --git a/usr/src/cmd/sdb/display.c b/usr/src/cmd/sdb/display.c
new file mode 100644 (file)
index 0000000..bf79f28
--- /dev/null
@@ -0,0 +1,536 @@
+#include "head.h"
+#include <a.out.h>
+#include "cdefs.h"
+struct user u;
+BKPTR  bkpthead;
+/* initialize frame pointers to top of call stack */
+
+struct proct *
+initframe() {
+       argp = *(ADDR *) (((ADDR) &u) + AP);
+       frame = *(ADDR *) (((ADDR) &u) + FP);
+       callpc = *(ADDR *) (((ADDR) &u) + PC);
+       if ((frame == 0) || (frame & 0xf0000000 != 0x70000000))
+               return(badproc);
+       return(adrtoproc(callpc++));  /* ++ because UNIX backs up instrs */
+}
+
+
+struct proct *
+nextframe() {
+       callpc = get(frame+16, DSP);
+       argp = get(frame+8, DSP);
+       frame = get(frame+12, DSP) & EVEN;
+       if ((frame == 0) || (frame & 0xf0000000 != 0x70000000))
+               return(badproc);
+       return(adrtoproc(callpc-1));
+}
+
+/* print call frame */
+prframe() {
+       int narg;
+       char *p;
+       struct proct *procp;
+       
+       if ((procp = initframe()) == badproc) return;
+       do {
+               if (get(frame+12, DSP) == 0) return;
+               p = procp->pname;
+               if (p[0] == '_')
+                       printf("%.7s(", p+1);
+               else
+                       printf("%.8s(", p);
+               narg = get(argp, DSP);
+               if (narg & ~0xff) narg = 0;
+               while (narg) {
+                       printf("%d", get(argp+=4, DSP));
+                       if (--narg != 0) printf(",");
+               }
+               printf(")");
+               if (procp->sfptr != badfile)
+                       printf("   [%s:%d]", adrtofilep(callpc-1)->sfilename,
+                               adrtolineno(callpc-1));
+               printf("\n");
+       } while ((procp = nextframe()) != badproc);
+}
+
+STRING         signals[] = {
+               "",
+               "hangup",
+               "interrupt",
+               "quit",
+               "illegal instruction",
+               "trace/BPT",
+               "IOT",
+               "EMT",
+               "floating exception",
+               "killed",
+               "bus error",
+               "memory fault",
+               "bad system call",
+               "broken pipe",
+               "alarm call",
+               "terminated",
+};
+INT            signo;
+
+sigprint() {
+       printf("%s", signals[signo]);
+}
+
+
+/* returns core image address for variable */
+formaddr(proc, class, addr)
+register char *proc;
+register char class;
+ADDR addr; {
+if (debug) printf("formaddr(%s, %o, %d)\n", proc,class & 0377,addr);
+       switch(class & STABMASK) {
+       case N_RSYM:
+               if (getframe(proc) < 0) return(-1);
+       case N_GSYM:
+       case N_SSYM:
+       case N_STSYM:
+               return(addr);
+               
+       case N_PSYM:
+               if (getframe(proc) < 0) return(-1);
+               return(argp+addr);
+               
+       case N_LSYM:
+               if (getframe(proc) < 0) return(-1);
+               return(frame+addr);
+
+       default:
+               printf("Bad class in formaddr: 0%o: (%d, %d)\n",
+                       class & 0377, proc, addr);
+               return(0);
+       }
+}
+
+/* sets frame pointers to procedure proc */
+getframe(proc)
+register char *proc; {
+       register struct proct *procp, *fprocp;
+       
+       procp = findproc(proc);
+       if (procp == badproc) {
+               printf("%s: Bad procedure name\n", proc);
+               return(-1);
+       }
+       for (fprocp = initframe(); fprocp != badproc; fprocp = nextframe()) {
+               if (procp == fprocp) return(0);
+       }
+       printf("%s: Not an active procedure\n", proc);
+       return(-1);
+}
+
+char class;
+
+/* returns address of proc:var. Sets externals class and subflag */
+ADDR
+varaddr(proc, var)
+char *proc, *var; {
+       register struct proct *procp;
+       register ADDR addr;
+       char *p;
+       int localflag;
+       
+       if (debug) printf("varaddr(%s,%s)\n", proc, var);
+       localflag = 0;
+       subflag = 0;
+       procp = initframe();
+       do {
+               if (eqstr(proc, procp->pname)) goto found;
+       } while ((procp=nextframe()) != badproc);
+       localflag = 1;
+found:
+       if (eqany(var[0], ".->")) {
+               class = N_GSYM;
+               addr = integ;
+       }
+       else {
+               if (localflag || slookup(var, adrtostoffset(callpc-1)) == -1) {
+                       if (globallookup(var,findfile(curfile)->stf_offset) == -1) {
+                               if (localflag)
+                                       printf("%.8s not found\n", var);
+                               else
+                                       printf("%.8s:%s not found\n", proc, var);
+                               return(-1);
+                       }
+               }
+       class = sl_class & STABMASK;
+       addr = (class == N_LSYM) ? -sl_addr : sl_addr;
+       addr = formaddr(proc, class, addr);
+       }
+       if (addr == -1) return(-1);
+       for (p=var; *p; p++) {
+               if (*p == '.' && *(p+1) != '\0') {
+                       if (class == N_RSYM) {
+                               error("Not with a register variable");
+                               return(-1);
+                       }
+                       p++;
+                       if (localflag || slookup(p, adrtostoffset(callpc-1)) == -1) {
+                               if (globallookup(p, findfile(curfile)->stf_offset) == -1) {     
+                                       if (localflag)
+                                               printf("%s not found\n", var);
+                                       else
+                                               printf("%.8s:%s not found\n", proc, var);
+                                       return(-1);
+                               }
+                       }
+                       if ((sl_class & STABMASK) != N_SSYM) {
+                               error("Not a structure element");
+                               return(-1);
+                       }
+                       addr += sl_addr;
+                       subflag = 0;
+               }
+               if (eqany(*p, "->") != '\0') {
+                       addr = getindir(class, addr, sl_type);
+                       class = N_GSYM;
+                       if (debug) printf("Address %d after getval\n", addr);
+                       for (; eqany(*p, "->"); p++) ;
+                       if (*p == '\0') break;
+                       if (localflag ||
+                                  slookup(p, adrtostoffset(callpc-1)) == -1) {
+                               if (globallookup(p, findfile(curfile)->stf_offset) == -1) {     
+                                       if (localflag)
+                                               printf("%s not found\n", var);
+                                       else
+                                               printf("%.8s:%s not found\n", proc, var);
+                                       return(-1);
+                               }
+                       }
+                       addr += sl_addr;
+                       subflag = 0;
+               }
+               if (*p == '[' && *(p+1) != '\0') {
+                       long i;
+                       p++;
+                       i = readint(&p);
+                       if (debug) printf("Size %d\n", typetosize(sl_type, sl_size));
+                       addr = getindir(class, addr, sl_type);
+                       addr += typetosize(sl_type, sl_size)*i;  
+                       class = N_GSYM;
+                       subflag++;
+               }
+       }
+       return(addr);
+}
+
+/* displays value of proc:var, returns its address */
+ADDR
+dispvar(proc, var, fmt)
+char *proc, *var, *fmt; {
+       ADDR addr;
+       addr = varaddr(proc, var);
+       if (addr == -1) return(-1);
+       
+       prvar(sl_type, addr, fmt, class, subflag);
+       
+       return(addr);
+}
+
+prvar(type, addr, fmt, class, subflag) 
+ADDR addr;
+char *fmt, class; short type; {
+
+       dispf(addr, fmt, class, type, subflag);
+}
+
+prdebug() {
+       register struct proct *procp;
+       register struct filet *filep;
+       
+       printf("dot=%d\n", dot);
+       printf("extstart = %d\n", extstart);
+       for(filep=files;filep->sfilename[0];filep++)
+               printf("%s offs %d @ %d flag %d addr %d\n", filep->sfilename, filep->stf_offset, filep, filep->lineflag, filep->faddr);
+       for(procp=procs;procp->pname[0];procp++)
+               printf("%8.8s addr %d; offs %d; sfptr %d; line %d\n",
+                       procp->pname, procp->paddr, procp->st_offset, procp->sfptr,
+                       procp->lineno);
+}
+
+/* display addr using format desc or class s */
+char pd[] = "%x\n";
+dispf(addr, desc, class, type, subflag)
+char *desc; short type; ADDR addr; {
+       int i;
+       char *p;
+       char dlen, dfmt;
+       long value;
+       union {
+               struct {
+                       char c[WORDSIZE]; 
+                       };
+               struct {
+                       int w;
+               };
+               struct {
+                       float f;
+               }
+       } word;
+       union {
+               struct{
+                       int w1, w2;
+               };
+               struct {
+                       double d;
+               };
+       } dbl;
+
+       class &= STABMASK;
+       if (desc[0]  == '\0') desc = typetodesc(type, subflag);
+       odesc = desc;
+       otype = type;
+       oclass = class;
+       if (debug) printf("dispf(%d,%s,0%o,0%o)\n", addr,desc,class,type);
+       pd[1] = dfmt = 'd';
+       dlen = '\0';
+       for (p = desc; *p; p++) {
+               switch (*p) {
+                       case 'l':
+                       case 'h':
+                       case 'b':
+                               dlen = *p;
+                               break;
+
+                       case 'c':
+                       case 'd':
+                       case 'o':
+                       case 'x':
+                       case 'u':
+                       case 's':
+                       case 'a':
+                       case 'f':
+                       case 'g':
+                               pd[1] = dfmt = *p;
+                               break;
+
+                       default:
+                               printf("Illegal descriptor: %c\n", *p);
+                               return;
+                       }
+               }
+               
+               switch (dfmt) {
+               default:
+                       if (class == N_RSYM) {
+                               if ((addr > 0 && addr < 6) || addr > 11) {
+                                       printf("Bad register var %d\n", addr);
+                                       return;
+                               }
+                               value = *(ADDR *)(((ADDR) &u) + R0 + (WORDSIZE)*addr);
+                       }
+                       else {
+                               value = getval(addr, dfmt);
+                       }
+
+                       switch (dfmt) {
+                       case 'u':
+                       case 'x':
+                       case 'o':
+                               switch (dlen) {
+                               case 'h':
+                                       value = (unsigned short) value;
+                                       break;
+                               case 'b':
+                                       value = (unsigned char) value;
+                                       break;
+                               case 'l':
+                                       value = (unsigned long) value;
+                                       break;
+                               }
+                               break;
+
+                       default:
+                               switch (dlen) {
+                               case 'h':
+                                       value = (short) value;
+                                       break;
+                               case 'b':
+                                       value = (char) value;
+                                       break;
+                               case 'l':
+                                       value = (long) value;
+                                       break;
+                               }
+                       }
+                       if (value > 0) {
+                               if (value > 9  &&  dfmt == 'x')
+                                       printf("0x");
+                               else if (value > 7  &&  dfmt == 'o')
+                                       printf("0");
+                       }
+                       if (dfmt == 'c') {
+                               if ((value & 0177) < ' ') 
+                                       printf("^%c\n", value + ('A' - 1));
+                               else if ((value & 0177) == 0177)
+                                       printf("^?\n");
+                               else
+                                       printf(pd, value);
+                       } else
+                               printf(pd, value);
+                       return;
+                       
+               case 'f':
+                       pd[1] = 'g';
+                       word.w = getval(addr,dfmt);
+                       printf(pd, word.f);
+                       return;
+
+               case 'g':
+                       pd[1] = 'g';
+                       dbl.w1 = getval(addr, dfmt);
+                       dbl.w2 = getval(addr+WORDSIZE, dfmt);
+                       printf(pd, dbl.d);
+                       return;
+
+               case 's':
+                       addr = getindir(class, addr, type);
+                               
+               case 'a':
+                       for (;;) {
+                               word.w = getval(addr, 'd');
+                               for (i=0; i<WORDSIZE; i++) {
+                                       if (word.c[i] == 0) goto l1;
+                                       printf("%c", word.c[i]);
+                               }
+                               addr += WORDSIZE;
+                       }
+
+       l1:     printf("\n");
+               return;
+       }
+}
+
+/* print breakpoints */
+prbkpt() {
+       register BKPTR bkptr;
+       register int cnt;
+
+       cnt = 0;
+       
+       for (bkptr = bkpthead; bkptr; bkptr=bkptr->nxtbkpt)
+               if (bkptr->flag) {
+                       cnt++;
+                       printf("%.8s:%d\n", adrtoprocp(bkptr->loc)->pname,
+                               adrtolineno(bkptr->loc));
+               }
+       if (cnt == 0) 
+               printf("No breakpoints set\n");
+}
+
+idbkpt() {
+       register BKPTR bkptr;
+       register int yesflg, cnt;
+       register char c;
+       
+       cnt = 0;
+
+       for (bkptr = bkpthead; bkptr; bkptr=bkptr->nxtbkpt)
+               if (bkptr->flag) {
+                       printf("%.8s:%d ? ", adrtoprocp(bkptr->loc)->pname,
+                               adrtolineno(bkptr->loc));
+                       yesflg = 0;
+                       cnt++;
+                       do {
+                               c = getchar();
+                               if (c == 'y' || c == 'd') yesflg++;
+                       } while (c != '\n');
+                       if (yesflg)
+                               bkptr->flag = 0;
+               }
+       if (cnt == 0)
+               printf("No breakpoints set\n");
+}
+
+char *
+typetodesc(type, subflag)
+short type; {
+       register int ptr, ftn, ary;
+       register char *desc;
+       
+       static char *typedesc[] = {
+               "d",  /* undef */
+               "d",  /* farg */
+               "c",  /* char */
+               "hd",  /* short */
+               "d",  /* int */
+               "ld",  /* long */
+               "f",  /* float */
+               "g",  /* double */
+               "d",  /* strty */
+               "d",  /* unionty */
+               "d",  /* enumty */
+               "d",  /* moety */
+               "bu",  /* uchar */
+               "hu",  /* ushort */
+               "u",  /* unsigned */
+               "lu",  /* ulong */
+               "d"   /* ? */
+       };
+       
+       ptr = ftn = ary = 0;
+       
+       for (;; type = DECREF(type)) {
+               if (ISPTR(type)) ptr++;
+               else if (ISFTN(type)) ftn++;
+               else if (ISARY(type)) ary++;
+               else {
+                       desc = typedesc[type];
+                       break;
+               }
+       }
+       
+       if ((ptr-subflag == 1  || ary-subflag == 1)  &&  desc[0] == 'c') return("s");
+       if (debug) printf ("PTR %d; FTN %d; ARY %d; DESC %s\n",ptr,ftn,ary,desc);
+       if (ptr) return("x");
+       return(desc);
+}
+
+typetosize(type, stsize)
+short type; {
+       register int ptr, ftn, ary;
+       register int size;
+       
+       static char typesize[] = {
+               4,  /* undef */
+               4,  /* farg */
+               1,  /* char */
+               2,  /* short */
+               WORDSIZE,  /* int */
+               4,  /* long */
+               4,  /* float */
+               8,  /* double */
+               0,  /* strty */
+               0,  /* unionty */
+               4,  /* enumty */
+               4,  /* moety */
+               1,  /* uchar */
+               2,  /* ushort */
+               4,  /* unsigned */
+               4,  /* ulong */
+               4   /* ? */
+       };
+       
+       ptr = ftn = ary = 0;
+       
+       for (;; type = DECREF(type)) {
+               if (ISPTR(type)) ptr++;
+               else if (ISFTN(type)) ftn++;
+               else if (ISARY(type)) ary++;
+               else {
+                       size = typesize[type];
+                       break;
+               }
+       }
+       
+       if (debug) printf ("PTR %d; FTN %d; ARY %d; SIZE %d; STSIZE %d\n",ptr,ftn,ary,size,stsize);
+       if (ptr>1) return(4);
+       if (size == 0) return(stsize ? stsize : 1);
+       else return(size);
+}
diff --git a/usr/src/cmd/sdb/docomm.c b/usr/src/cmd/sdb/docomm.c
new file mode 100644 (file)
index 0000000..740cfc8
--- /dev/null
@@ -0,0 +1,276 @@
+#include <signal.h>
+#include "head.h"
+#include <a.out.h>
+
+struct user u;
+L_INT  cntval;
+INT    signo;
+INT    adrflg;
+long   oldaddr = -1;
+
+docommand() {
+       register char   *p;
+       register int    i;
+       register ADDR   addr, odot;
+       struct proct    *procp;
+       
+       if (signo == SIGINT) signo = 0;
+       cntval = 1;
+       adrflg = 0;
+       errflg = 0;
+
+       if (scallf) {
+               doscall();
+               setcur();
+               return;
+       }
+       
+       if (reflag) {  /* search for regular expression */
+               dore();
+               return;
+       }
+       
+       if (cmd == '\0') {
+               if (integ != 0 && var[0] != '\0') {
+                       error("Invalid command (1)");
+                       return;
+               }
+               if (integ != 0) { /* print line number */
+                       ffind(integ);
+                       fprint();
+                       return;
+               }
+               if (var[0] != 0) {
+                       printf("Unexpected null command\n");
+                       return;
+               }
+       }
+               
+       switch (cmd) {
+       
+       case 'a':
+               debug = !debug;
+               break;
+               
+       case 't':
+               prframe();
+               break;
+               
+       case 'e':
+               p = args;
+               if (*p == '\0') {
+                       printf("%.8s() in \"%s\"\n", curproc()->pname, curfile);
+                       break;
+               }
+
+               while (*p != '\0')
+                       if (*p++ == '.') goto l1;
+               /* argument is procedure name */
+               procp = findproc(args);
+               if ((procp->pname[0] != '\0') && (procp->sfptr != badfile)) {
+                       finit(adrtofilep(procp->paddr)->sfilename);
+                       ffind(procp->lineno);
+               }
+               else printf("Can't find %s\n", args);
+               printf("%.8s() in \"%s\"\n", curproc()->pname, curfile);
+               break;
+               
+       l1:     /* argument is filename */
+               finit(args);
+               printf("\"%s\"\n", curfile);
+               break;
+               
+       case 'p':
+               if (integ) ffind(integ);
+               fprint();
+               break;
+               
+       case 'q':
+               exit(0);
+               
+       case 'w':
+               if (integ) ffind(integ);
+               i = fline;
+               fback(WINDOW/2);
+               fprintn(WINDOW);
+               ffind(i);
+               break;
+               
+       case 'x':
+               prdebug();
+               break;
+
+       case 'z':
+               if (integ) ffind(integ);
+               fprintn(WINDOW);
+               break;
+
+       case '-':
+               fback(integ ? integ : 1);
+               fpargs();
+               break;
+
+       case '+':
+               fforward(integ ? integ : 1);
+               fpargs();
+               break;
+
+       case '\n':
+               fforward(1);
+               fprint();
+               break;
+
+       case '\004':
+               fforward(1);
+               printf("\b");
+               fprintn(WINDOW);
+               break;
+
+       case 'r':
+               if (debug) error("calling subpcs");
+               if (integ) cntval = integ;
+               if (!executing) {
+                       executing = TRUE;
+                       if (integ) cntval = integ;
+                       subpcs('r');
+                       executing = FALSE;
+               }
+               if (debug) error("exiting subpcs");
+/*
+               setcur();
+               break;
+*/
+
+       case 'c':
+               if (debug) error("calling subpcs");
+               if (integ) cntval = integ;
+               subpcs('c');
+               if (debug) error("exiting subpcs");
+               if (!signo) printf("Breakpoint");
+               printf(" at\n");
+               setcur();
+               break;
+               
+       case 's':
+               singstep(integ ? integ : 1);
+               if (signo) printf("\n");
+               setcur();
+               break;
+               
+       case 'n':
+               odot = *(ADDR *) (((ADDR) &u) + PC);
+               for (i=1; i<100; i++) {
+                       dot = getaddr(adrtoprocp(odot)->pname, adrtolineno(odot)+i);
+                       if (dot != odot || dot == -1) break;
+               }
+               if (odot == dot  ||  dot == -1) {
+                       error("Cannot find next line");
+                       break;
+               }
+               if (debug) printf("Setting bkpt with i=%d at %d, odot = %d\n", i, dot, odot);
+               odot = dot;
+               subpcs('b');
+               subpcs('c');
+               if (!signo) printf("Next statement\n");
+               else printf(" at\n");
+               setcur();
+               dot = odot;
+               subpcs('d');
+               break;
+               
+       case 'b':
+               if (proc[0] == '\0' && integ == 0) {
+                       prbkpt();
+               }
+               else {
+                       dot = getaddr(proc,integ);
+                       if (dot == -1) {
+                               error("Cannot set breakpoint");
+                               break;
+                       }
+                       subpcs('b');
+                       printf("%.8s:%d b\n",adrtoprocp(dot)->pname,
+                               adrtolineno(dot));
+               }
+               break;
+               
+       case 'd':
+               if (proc[0] == '\0' && integ == 0) {
+                       idbkpt();
+                       break;
+               }
+               dot = getaddr(proc,integ);
+               if (dot == -1) {
+                       error("Non existent breakpoint");
+                       break;
+               }
+               subpcs('d');
+               break;
+               
+       case 'm':
+               addr = varaddr(proc[0] ? proc : curproc()->pname, var);
+               printf("stopped with value %d\n", monex(addr, 'd'));
+               setcur();
+               break;
+               
+       case '/':
+               if (var[0] == '.' && var[1] == '\0') {
+                       if (integ == 0) integ = oldaddr;
+                       dispf((ADDR) integ, args[0] ? args : odesc,
+                               oclass == N_RSYM ? oclass : N_GSYM, otype, 0);
+                       oldaddr = integ;
+                       break;
+               }
+               if (integ) {
+                       dispf((ADDR) integ, args, N_GSYM, 0, 0);
+                       break;
+               }
+               oldaddr = dispvar(proc[0] ? proc : curproc()->pname, var, args);
+               break;
+               
+       case '=':
+               if (var[0] == '\0')
+                       addr = getaddr(proc, integ);
+               else
+                       addr = varaddr(proc[0] ? proc : curproc()->pname, var);
+               if (addr == -1)
+                       error("Unknown address");
+               else
+                       printf("0x%x\n", addr);
+               break;
+
+       case '!':
+               if (var[0] == '\0')
+                       addr = getaddr(proc, integ);
+               else
+                       addr = varaddr(proc[0] ? proc : curproc()->pname, var);
+               if (addr == -1) 
+                       error("Unknown variable");
+               else
+                       if (sl_class == N_RSYM)
+                               putreg(addr,typetodesc(sl_type,subflag)[0],argvalue(args));
+                       else
+                               putval(addr,typetodesc(sl_type,subflag)[0],argvalue(args));
+               break;
+       }
+}
+
+fpargs() {
+       register int i;
+       
+       switch(args[0]) {
+       case 'p':
+       case '\0':
+               fprint();
+               break;
+case 'w':
+               i = fline;
+               fback(WINDOW/2);
+               fprintn(WINDOW);
+               ffind(i);
+               break;
+       case 'z':
+               fprintn(WINDOW);
+               break;
+       }
+}
diff --git a/usr/src/cmd/sdb/err b/usr/src/cmd/sdb/err
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/src/cmd/sdb/fio.c b/usr/src/cmd/sdb/fio.c
new file mode 100644 (file)
index 0000000..e56660e
--- /dev/null
@@ -0,0 +1,137 @@
+#include "head.h"
+
+finit(name)
+char *name; {
+       register char *p, *q;
+       
+       if (fiobuf.fd) close(fiobuf.fd);
+       q = name;
+       for (p=fp; *q; *p++ = *q++) ;
+       *p = 0;
+       if ((fiobuf.fd = open(filework,0)) == -1) {
+               perror(filework);
+               return;
+       }
+       binit(&fiobuf);
+       cpstr(curfile, name);
+       for (p=fbuf;;p++) {
+               if (bread(&fiobuf,p,1) <= 0) {
+                       printf("%s - No lines in file\n", name);
+                       return;
+               }
+               if (*p == '\n') break;
+       }
+       fline = 1;
+       maxfline = 0;
+}
+
+fnext() {
+       register char *p;
+       
+       for(p=fbuf;;p++) {
+               if (bread(&fiobuf,p,1) <= 0) {
+                       p--;
+                       blseek(&fiobuf,0L,0);
+                       fline = 0;
+                       continue;
+               }
+               if (*p == '\n') break;
+       }
+       fline++;
+}
+
+
+fprev() {
+       char c;
+       register int i;
+       
+       for(i=0; i<3; i++) {
+               for (;;) {
+                       if (bread(&fiobuf, &c+1, -1) <= 0) {
+                               if (maxfline) blseek(&fiobuf,0L,2);
+                               else {
+                                       blseek(&fiobuf,0L,0);
+                                       for(;;) {
+                                               if (bread(&fiobuf,&c,1)<=0) break;
+                                               if (c == '\n') maxfline++;
+                                       }
+                               }
+                       }
+                       if (c == '\n') break;
+               }
+       }
+       bread(&fiobuf, &c, 1);  /* eat the '\n' */
+       
+       fline -= 2;
+       if (fline < 0) fline = maxfline - 1;
+       
+       fnext();
+}
+
+
+fprint() {
+       register char *p;
+       
+       printf("%d: ", fline);
+       p = fbuf;
+       while(putchar(*p++) != '\n')
+               ;
+}
+
+ffind(num)
+register int num; {
+       register int i, ofline;
+       
+       ofline = fline;
+       if (num>fline)
+               for (i=fline; i<num; i++) {
+                       fnext();
+                       if (fline == 1) goto bad;
+               }
+       if (num<fline)
+               for (i=num; i<ofline; i++) {
+                       fprev();
+               }
+               
+       if (maxfline & num>maxfline) goto bad;
+       
+       return;
+
+bad:   error("Not that many lines in file");
+       ffind(ofline);
+}
+
+fback(n) {
+       int i;
+       
+       for (i=0; i<n; i++) {
+               if (fline == 1) return(i);
+               fprev();
+       }
+       return(i);
+}
+
+fforward(n) {
+       int i;
+       
+       for (i=0; i<n; i++) {
+               fnext();
+               if (fline == 1) {
+                       fprev();
+                       return(i);
+               }
+       }
+       return(i);
+}
+
+fprintn(n) {
+       int i;
+       
+       for (i=0; i<n; i++) {
+               fprint();
+               fnext();
+               if (fline == 1) break;
+       }
+       fprev();
+       return(i);
+}
diff --git a/usr/src/cmd/sdb/head.h b/usr/src/cmd/sdb/head.h
new file mode 100644 (file)
index 0000000..cd696ef
--- /dev/null
@@ -0,0 +1,94 @@
+#include <stdio.h>
+#include "bio.h"
+#include "defs.h"
+
+/* input line decoding */
+char   proc[30];       /* procedure name */
+int    integ;          /* count or number in input */
+char   cmd;            /* command letter */
+char   re[128];        /* regular expression */
+char   args[128];      /* arguments */
+char   *argsp;         /* pointer to args */
+char   var[60];        /* variable name */
+int    scallf;         /* set to 1 iff procedure call */
+int    reflag;         /* set to 1 iff re */
+int    redir;          /* set to 1 iff forward search */
+
+/* source file i/o */
+char   curfile[30];    /* name of file being edited */
+int    fline;          /* line number in file */
+int    maxfline;       /* maximum line number in file, 0 if unknown */
+struct brbuf  fiobuf;  /* file descriptor */
+char   fbuf[256];      /* current line from file */
+char   filework[128];  /* place to put filename */
+char   *fp; /* pointer to it */
+
+/* returned by slookup */
+char   sl_name[8];
+char   sl_class, sl_type;
+int    sl_size, sl_addr;
+int    subflag;
+
+/* symbol table info */
+long   ststart;                /* offset of symbol table in a.out */
+struct brbuf sbuf;             /* buffer for symbol table */
+long   extstart;               /* offset of first external in a.out */
+
+/* address info */
+ADDR   dot;                    /* current address */
+ADDR   callpc, frame, argp;    /* current stack frame */
+
+char   *odesc;                 /* descriptor of last displayed variable */
+char   otype;                  /* type of last displayed variable */
+char   oclass;                 /* class of last displayed variable */
+
+#define        STABMASK        0376
+
+#define NUMARGS 16             /* number of args allowed in sub call */
+#define SUBSTSP 512            /* length of space for sub args and strings */
+#define WORDSIZE 4             /* wordsize in bytes on this machine */
+
+struct filet {
+       char    sfilename[31];  /* source file name */
+       char    lineflag;       /* set iff this is a '#line' file */
+       ADDR    faddr;          /* address in core */
+       long    stf_offset;     /* offset in a.out */
+} *files, *badfile;
+
+struct proct {
+       char    pname[8];       /* procedure name */
+       ADDR    paddr;          /* address in core */
+       long    st_offset;      /* offset in a.out */
+       struct filet  *sfptr;   /* source file name pointer */
+       int     lineno;         /* line number in source file */
+} *procs, *badproc;
+
+
+#define PROCINCR 20
+#define FILEINCR 10
+#define MAXADDR 1L<<30
+
+#define varchar(x)     ((x>='A' && x<='Z') || (x>='a' &&  x<='z') || x == '_' || x == '.' || x == '[' || x == ']' || x == '-' || x == '>')
+#define number(x)      (x >= '0' && x <= '9')
+
+char *readline();
+char *cpname();
+char *cpall();
+char *sbrk();
+char *typetodesc();
+int octdigit(), decdigit(); hexdigit();
+int octconv(), decconv(); hexconv();
+long readint(), rint();
+long adrtostoffset();
+long getval(), argvalue();
+ADDR varaddr(), dispvar();
+ADDR extaddr();
+struct proct *curproc();
+struct proct *findproc();
+struct proct *adrtoproc();
+struct proct *initframe(), *nextframe();
+struct filet *findfile(), *adrtofilep();
+
+#define        WINDOW  10
+#define        COMMANDS        "\004+-=!/abcdemnpqrstwxz"
+int    debug;
diff --git a/usr/src/cmd/sdb/install b/usr/src/cmd/sdb/install
new file mode 100755 (executable)
index 0000000..e6fe4f7
--- /dev/null
@@ -0,0 +1 @@
+make install
diff --git a/usr/src/cmd/sdb/mac.h b/usr/src/cmd/sdb/mac.h
new file mode 100644 (file)
index 0000000..26d91e6
--- /dev/null
@@ -0,0 +1,48 @@
+#
+/*
+ *     UNIX debugger
+ */
+
+#define TYPE   typedef
+#define STRUCT struct
+#define UNION  union
+#define REG    register
+
+#define BEGIN  {
+#define END    }
+
+#define IF     if(
+#define THEN   ){
+#define ELSE   } else {
+#define ELIF   } else if (
+#define FI     }
+
+#define FOR    for(
+#define WHILE  while(
+#define DO     ){
+#define OD     }
+#define REP    do{
+#define PER    }while(
+#define DONE   );
+#define LOOP   for(;;){
+#define POOL   }
+
+#define SKIP   ;
+#define DIV    /
+#define REM    %
+#define NEQ    ^
+#define ANDF   &&
+#define ORF    ||
+
+#define TRUE    (-1)
+#define FALSE  0
+#define LOBYTE 0377
+#define HIBYTE 0177400
+#define STRIP  0177
+#define HEXMSK 017
+
+#define SP     ' '
+#define TB     '\t'
+#define NL     '\n'
+
+#define SCCSID(arg) static char Sccsid[] = "arg"
diff --git a/usr/src/cmd/sdb/machine.h b/usr/src/cmd/sdb/machine.h
new file mode 100644 (file)
index 0000000..c92368e
--- /dev/null
@@ -0,0 +1,31 @@
+#
+/*
+ *     UNIX/vax debugger
+ */
+
+/* unix parameters */
+#define DBNAME "adb\n"
+#define LPRMODE "%R"
+#define OFFMODE "+%R"
+#define TXTRNDSIZ 512L
+
+TYPE   long TXTHDR[8];
+TYPE   long SYMV;
+
+#ifndef vax
+struct {short hiword; short loword;}; /* stupid fp-11 */
+#endif
+
+/* symbol table in a.out file */
+struct symtab {
+       char    symc[8];
+#ifndef EDDT
+       char    symf;
+       char    sympad[3];
+#endif
+       SYMV    symv;
+};
+#define SYMTABSIZ (sizeof (struct symtab))
+
+#define SYMCHK 057
+#define SYMTYPE(symflg) (symflg&41 ? DSYM : NSYM)
diff --git a/usr/src/cmd/sdb/main.c b/usr/src/cmd/sdb/main.c
new file mode 100644 (file)
index 0000000..85f4a73
--- /dev/null
@@ -0,0 +1,103 @@
+#
+/*
+ *
+ *     UNIX debugger
+ *
+ */
+
+#include       "head.h"
+
+INT            mkfault;
+INT            executing;
+CHAR           *lp;
+L_INT          maxoff;
+L_INT          maxpos;
+ADDR           sigint;
+ADDR           sigqit;
+INT            wtflag;
+L_INT          maxfile;
+L_INT          maxstor;
+L_INT          txtsiz;
+L_INT          datsiz;
+L_INT          datbas;
+L_INT          stksiz;
+STRING         errflg;
+INT            magic;
+L_INT          entrypt;
+
+CHAR           lastc;
+
+STRING         symfil;
+STRING         corfil;
+INT            argcount;
+
+
+
+main(argc, argv)
+REG STRING     *argv;
+REG INT                argc;
+{
+       register char *p;
+       maxfile=1L<<24; maxstor=1L<<31;
+
+       setbuf(stdout, NULL);
+       setbuf(stderr, NULL);
+
+       WHILE argc>1
+       DO      IF eqstr("-w",argv[1])
+               THEN    wtflag=2; argc--; argv++;
+               ELSE    break;
+               FI
+       OD
+
+       IF argc>1 THEN symfil = argv[1]; FI
+       IF argc>2 THEN corfil = argv[2]; FI
+       fp = filework;
+       if (argc > 3) {
+               for (p = argv[3]; *p; *fp++ = *p++) ;
+               *fp++ = '/';
+       }
+
+       argcount=argc;
+       setsym(); setcor();
+       initfp();
+
+       /* set up variables for user */
+       maxoff=MAXOFF; maxpos=MAXPOS;
+
+       IF (sigint=signal(SIGINT,01))!=01
+       THEN    sigint= (ADDR) fault; signal(SIGINT,fault);
+       FI
+       sigqit=signal(SIGQUIT,1);
+       setexit();
+       if (debug) printf("Sdb restarted\n");
+       IF executing THEN delbp(); FI
+       executing=FALSE;
+
+       for (;;) {
+               mkfault = 0;
+               printf("*");
+               if (decode() == 1) {
+                       printf("Error; try again\n");
+                       continue;
+               }
+
+       if (debug) {
+               printf("cmd %c:\n", cmd);
+               printf("%s:%s\n", proc, var);
+               printf("args-%s;re-%s;integ-%d\n", args, re, integ);
+               printf("scallf-%d;reflg-%d\n\n", scallf, reflag);
+       }
+
+               docommand();
+       }
+}
+
+
+fault(a)
+{
+       signal(a,fault);
+       mkfault++;
+       printf("\n");
+       reset();
+}
diff --git a/usr/src/cmd/sdb/make b/usr/src/cmd/sdb/make
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/src/cmd/sdb/message.c b/usr/src/cmd/sdb/message.c
new file mode 100644 (file)
index 0000000..6b39d42
--- /dev/null
@@ -0,0 +1,24 @@
+#
+/*
+ *
+ *     UNIX debugger
+ *
+ */
+
+
+
+#include       "mac.h"
+#include       "mode.h"
+
+
+MSG            BADMOD  =  "bad modifier";
+MSG            NOBKPT  =  "no breakpoint set";
+MSG            NOPCS   =  "no process";
+MSG            BADTXT  =  "text address not found";
+MSG            BADDAT  =  "data address not found";
+MSG            EXBKPT  =  "too many breakpoints";
+MSG            BADWAIT =  "wait error: process disappeared!";
+MSG            ENDPCS  =  "process terminated";
+MSG            NOFORK  =  "try again";
+MSG            SZBKPT  =  "bkpt: command too long";
+MSG            BADMAG  =  "bad core magic number";
diff --git a/usr/src/cmd/sdb/mode.h b/usr/src/cmd/sdb/mode.h
new file mode 100644 (file)
index 0000000..65036ce
--- /dev/null
@@ -0,0 +1,79 @@
+#include "machine.h"
+/*
+ *     UNIX debugger
+ */
+
+#define MAXCOM 64
+#define MAXARG 32
+#define LINSIZ 256
+TYPE   long    ADDR;
+#ifndef vax
+TYPE   int             INT;
+#else
+TYPE   short   INT;
+#endif
+TYPE   int             VOID;
+TYPE   long int        L_INT;
+TYPE   float           REAL;
+TYPE   double          L_REAL;
+TYPE   unsigned        POS;
+TYPE   char            BOOL;
+TYPE   char            CHAR;
+TYPE   char            *STRING;
+TYPE   char            MSG[];
+TYPE   struct map      MAP;
+TYPE   MAP             *MAPPTR;
+TYPE   struct symtab   SYMTAB;
+TYPE   SYMTAB          *SYMPTR;
+TYPE   struct symslave SYMSLAVE;
+TYPE   struct bkpt     BKPT;
+TYPE   BKPT            *BKPTR;
+
+
+/* file address maps */
+struct map {
+       L_INT   b1;
+       L_INT   e1;
+       L_INT   f1;
+       L_INT   b2;
+       L_INT   e2;
+       L_INT   f2;
+       INT     ufd;
+};
+
+
+/* slave table for symbols */
+struct symslave {
+       SYMV    valslave;
+       INT     typslave;
+};
+
+struct bkpt {
+       ADDR    loc;
+       ADDR    ins;
+       INT     count;
+       INT     initcnt;
+       INT     flag;
+       CHAR    comm[MAXCOM];
+       BKPT    *nxtbkpt;
+};
+
+TYPE   struct reglist  REGLIST;
+TYPE   REGLIST         *REGPTR;
+struct reglist {
+       STRING  rname;
+       INT     roffs;
+};
+
+struct {
+       INT     junk[2];
+       INT     fpsr;
+       REAL    Sfr[6];
+};
+
+struct {
+       INT     junk[2];
+       INT     fpsr;
+       L_REAL  Lfr[6];
+};
+
diff --git a/usr/src/cmd/sdb/ntest b/usr/src/cmd/sdb/ntest
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/src/cmd/sdb/pcs.c b/usr/src/cmd/sdb/pcs.c
new file mode 100644 (file)
index 0000000..857b42d
--- /dev/null
@@ -0,0 +1,114 @@
+#
+/*
+ *
+ *     UNIX debugger
+ *
+ */
+
+#include "defs.h"
+
+
+MSG            NOBKPT;
+MSG            SZBKPT;
+MSG            EXBKPT;
+MSG            NOPCS;
+MSG            BADMOD;
+
+/* breakpoints */
+BKPTR          bkpthead;
+
+CHAR           *lp;
+CHAR           lastc;
+struct user u;
+
+INT            signo;
+L_INT          dot;
+INT            pid;
+L_INT          cntval;
+L_INT          loopcnt;
+
+
+
+/* sub process control */
+
+subpcs(modif)
+{
+       REG INT         check;
+       INT             execsig,runmode;
+       REG BKPTR       bkptr;
+       STRING          comptr;
+       execsig=0; loopcnt=cntval;
+
+       switch (modif) {
+
+           /* delete breakpoint */
+           case 'd': case 'D':
+               IF (bkptr=scanbkpt(dot))
+               THEN bkptr->flag=0; return;
+               ELSE error(NOBKPT);
+               FI
+
+           /* set breakpoint */
+           case 'b': case 'B':
+               IF (bkptr=scanbkpt(dot))
+               THEN bkptr->flag=0;
+               FI
+               FOR bkptr=bkpthead; bkptr; bkptr=bkptr->nxtbkpt
+               DO IF bkptr->flag == 0
+                  THEN break;
+                  FI
+               OD
+               IF bkptr==0
+               THEN IF (bkptr=(BKPTR) sbrk(sizeof *bkptr)) == (BKPTR) -1
+                    THEN error(SZBKPT);
+                    ELSE bkptr->nxtbkpt=bkpthead;
+                         bkpthead=bkptr;
+                    FI
+               FI
+               bkptr->loc = dot;
+               bkptr->initcnt = bkptr->count = cntval;
+               bkptr->flag = BKPTSET;
+               check=MAXCOM-1; comptr=bkptr->comm; rdc(); lp--;
+               REP *comptr++ = readchar();
+               PER check-- ANDF lastc!=EOR DONE
+               *comptr=0; lp--;
+               IF check
+               THEN return;
+               ELSE error(EXBKPT);
+               FI
+
+           /* exit */
+           case 'k' :case 'K':
+               IF pid
+               THEN printf("%d: killed", pid); endpcs(); return;
+               FI
+               error(NOPCS);
+
+           /* run program */
+           case 'r': case 'R':
+               endpcs();
+               setup(); runmode=CONTIN;
+               break;
+
+           /* single step */
+           case 's': case 'S':
+               IF pid
+               THEN
+                       runmode=SINGLE; execsig=getsig(signo);
+               ELSE setup(); loopcnt--;
+               FI
+               break;
+
+           /* continue with optional signal */
+           case 'c': case 'C': case 0:
+               IF pid==0 THEN error(NOPCS); FI
+               runmode=CONTIN; execsig=getsig(signo);
+               break;
+
+           default: error(BADMOD);
+       }
+
+       runpcs(runmode,execsig);
+       delbp();
+}
+
diff --git a/usr/src/cmd/sdb/re.c b/usr/src/cmd/sdb/re.c
new file mode 100644 (file)
index 0000000..ede20e8
--- /dev/null
@@ -0,0 +1,331 @@
+#include "head.h"
+#define        CBRA    1
+#define        CCHR    2
+#define        CDOT    4
+#define        CCL     6
+#define        NCCL    8
+#define        CDOL    10
+#define        CEOF    11
+#define        CKET    12
+#define        CBACK   18
+
+#define        CSTAR   01
+
+#define        LBSIZE  512
+#define        ESIZE   256
+#define        NBRA    9
+
+char   expbuf[ESIZE];
+int    circf;
+char   *braslist[NBRA];
+char   *braelist[NBRA];
+char   bittab[] = {
+       1,
+       2,
+       4,
+       8,
+       16,
+       32,
+       64,
+       128
+};
+
+dore() {
+       register int line;
+       register char *p;
+       
+       line = fline;
+       compile(re);
+       do {
+               if (redir) fnext();
+               else fprev();
+               p = fbuf;
+               while(*p++ != '\n')
+                       ;
+               *--p = '\0';
+               if (match(fbuf)) goto l1;
+       } while (fline != line);
+       error("No match");
+l1:    *p = '\n';
+       fprint();
+}
+
+
+compile(astr)
+char *astr;
+{
+       register c;
+       register char *ep, *sp;
+       char *cstart;
+       char *lastep;
+       int cclcnt;
+       char bracket[NBRA], *bracketp;
+       int closed;
+       char numbra;
+       char neg;
+
+       ep = expbuf;
+       sp = astr;
+       lastep = 0;
+       bracketp = bracket;
+       closed = numbra = 0;
+       if (*sp == '^') {
+               circf++;
+               sp++;
+       }
+       for (;;) {
+               if (ep >= &expbuf[ESIZE])
+                       goto cerror;
+               if ((c = *sp++) != '*')
+                       lastep = ep;
+               switch (c) {
+
+               case '\0':
+                       *ep++ = CEOF;
+                       return;
+
+               case '.':
+                       *ep++ = CDOT;
+                       continue;
+
+               case '*':
+                       if (lastep==0 || *lastep==CBRA || *lastep==CKET)
+                               goto defchar;
+                       *lastep |= CSTAR;
+                       continue;
+
+               case '$':
+                       if (*sp != '\0')
+                               goto defchar;
+                       *ep++ = CDOL;
+                       continue;
+
+               case '[':
+                       if(&ep[17] >= &expbuf[ESIZE])
+                               goto cerror;
+                       *ep++ = CCL;
+                       neg = 0;
+                       if((c = *sp++) == '^') {
+                               neg = 1;
+                               c = *sp++;
+                       }
+                       cstart = sp;
+                       do {
+                               if (c=='\0')
+                                       goto cerror;
+                               if (c=='-' && sp>cstart && *sp!=']') {
+                                       for (c = sp[-2]; c<*sp; c++)
+                                               ep[c>>3] |= bittab[c&07];
+                                       sp++;
+                               }
+                               ep[c>>3] |= bittab[c&07];
+                       } while((c = *sp++) != ']');
+                       if(neg) {
+                               for(cclcnt = 0; cclcnt < 16; cclcnt++)
+                                       ep[cclcnt] ^= -1;
+                               ep[0] &= 0376;
+                       }
+
+                       ep += 16;
+
+                       continue;
+
+               case '\\':
+                       if((c = *sp++) == '(') {
+                               if(numbra >= NBRA) {
+                                       goto cerror;
+                               }
+                               *bracketp++ = numbra;
+                               *ep++ = CBRA;
+                               *ep++ = numbra++;
+                               continue;
+                       }
+                       if(c == ')') {
+                               if(bracketp <= bracket) {
+                                       goto cerror;
+                               }
+                               *ep++ = CKET;
+                               *ep++ = *--bracketp;
+                               closed++;
+                               continue;
+                       }
+
+                       if(c >= '1' && c <= '9') {
+                               if((c -= '1') >= closed)
+                                       goto cerror;
+                               *ep++ = CBACK;
+                               *ep++ = c;
+                               continue;
+                       }
+
+               defchar:
+               default:
+                       *ep++ = CCHR;
+                       *ep++ = c;
+               }
+       }
+    cerror:
+       errexit("RE error\n", (char *)NULL);
+}
+
+match(p1)
+register char *p1; {
+       register char *p2;
+       register c;
+               p2 = expbuf;
+               if (circf) {
+                       if (advance(p1, p2))
+                               goto found;
+                       goto nfound;
+               }
+               /* fast check for first character */
+               if (*p2==CCHR) {
+                       c = p2[1];
+                       do {
+                               if (*p1!=c)
+                                       continue;
+                               if (advance(p1, p2))
+                                       goto found;
+                       } while (*p1++);
+                       goto nfound;
+               }
+               /* regular algorithm */
+               do {
+                       if (advance(p1, p2))
+                               goto found;
+               } while (*p1++);
+       nfound:
+               return(0);
+       found:
+               return(1);
+}
+
+advance(lp, ep)
+register char *lp, *ep;
+{
+       register char *curlp;
+       char c;
+       char *bbeg;
+       int ct;
+
+       for (;;) switch (*ep++) {
+
+       case CCHR:
+               if (*ep++ == *lp++)
+                       continue;
+               return(0);
+
+       case CDOT:
+               if (*lp++)
+                       continue;
+               return(0);
+
+       case CDOL:
+               if (*lp=='\0')
+                       continue;
+               return(0);
+
+       case CEOF:
+               return(1);
+
+       case CCL:
+               c = *lp++ & 0177;
+               if(ep[c>>3] & bittab[c & 07]) {
+                       ep += 16;
+                       continue;
+               }
+               return(0);
+       case CBRA:
+               braslist[*ep++] = lp;
+               continue;
+
+       case CKET:
+               braelist[*ep++] = lp;
+               continue;
+
+       case CBACK:
+               bbeg = braslist[*ep];
+               if (braelist[*ep]==0)
+                       return(0);
+               ct = braelist[*ep++] - bbeg;
+               if(ecmp(bbeg, lp, ct)) {
+                       lp += ct;
+                       continue;
+               }
+               return(0);
+
+       case CBACK|CSTAR:
+               bbeg = braslist[*ep];
+               if (braelist[*ep]==0)
+                       return(0);
+               ct = braelist[*ep++] - bbeg;
+               curlp = lp;
+               while(ecmp(bbeg, lp, ct))
+                       lp += ct;
+               while(lp >= curlp) {
+                       if(advance(lp, ep))     return(1);
+                       lp -= ct;
+               }
+               return(0);
+
+
+       case CDOT|CSTAR:
+               curlp = lp;
+               while (*lp++);
+               goto star;
+
+       case CCHR|CSTAR:
+               curlp = lp;
+               while (*lp++ == *ep);
+               ep++;
+               goto star;
+
+       case CCL|CSTAR:
+               curlp = lp;
+               do {
+                       c = *lp++ & 0177;
+               } while(ep[c>>3] & bittab[c & 07]);
+               ep += 16;
+               goto star;
+
+       star:
+               if(--lp == curlp) {
+                       continue;
+               }
+
+               if(*ep == CCHR) {
+                       c = ep[1];
+                       do {
+                               if(*lp != c)
+                                       continue;
+                               if(advance(lp, ep))
+                                       return(1);
+                       } while(lp-- > curlp);
+                       return(0);
+               }
+
+               do {
+                       if (advance(lp, ep))
+                               return(1);
+               } while (lp-- > curlp);
+               return(0);
+
+       default:
+               errexit("RE botch\n", (char *)NULL);
+       }
+}
+ecmp(a, b, count)
+char   *a, *b;
+{
+       register cc = count;
+       while(cc--)
+               if(*a++ != *b++)        return(0);
+       return(1);
+}
+
+
+errexit(s)
+char *s; {
+       error(s);
+       return;
+}
diff --git a/usr/src/cmd/sdb/runpcs.c b/usr/src/cmd/sdb/runpcs.c
new file mode 100644 (file)
index 0000000..7b26505
--- /dev/null
@@ -0,0 +1,313 @@
+#
+/*
+ *
+ *     UNIX debugger
+ *
+ */
+
+#include "head.h"
+#include <a.out.h>
+struct user u;
+#include <stdio.h>
+
+
+MSG            NOFORK;
+MSG            ENDPCS;
+MSG            BADWAIT;
+
+ADDR           sigint;
+ADDR           sigqit;
+
+/* breakpoints */
+BKPTR          bkpthead;
+
+
+REGLIST reglist [] = {
+               "p1lr", P1LR,
+               "p1br",P1BR,
+               "p0lr", P0LR,
+               "p0br",P0BR,
+               "ksp",KSP,
+               "esp",ESP,
+               "ssp",SSP,
+               "psl", PSL,
+               "pc", PC,
+               "usp",USP,
+               "fp", FP,
+               "ap", AP,
+               "r11", R11,
+               "r10", R10,
+               "r9", R9,
+               "r8", R8,
+               "r7", R7,
+               "r6", R6,
+               "r5", R5,
+               "r4", R4,
+               "r3", R3,
+               "r2", R2,
+               "r1", R1,
+               "r0", R0,
+};
+
+
+CHAR           lastc;
+
+INT            fcor;
+INT            fsym;
+STRING         errflg;
+int            errno;
+INT            signo;
+
+L_INT          dot;
+STRING         symfil;
+INT            wtflag;
+INT            pid;
+INT            adrflg;
+L_INT          loopcnt;
+
+
+
+
+
+
+getsig(sig)
+{      return(sig);
+}
+
+ADDR userpc = 1;
+
+runpcs(runmode,execsig)
+{
+       REG BKPTR       bkpt;
+       IF adrflg THEN userpc=dot; FI
+/*
+       printf("%s: running\n", symfil);
+*/
+       WHILE --loopcnt>=0
+       DO
+               if (debug) printf("\ncontinue %x %d\n",userpc,execsig);
+               IF runmode==SINGLE
+               THEN delbp(); /* hardware handles single-stepping */
+               ELSE /* continuing from a breakpoint is hard */
+                       IF bkpt=scanbkpt(userpc)
+                       THEN execbkpt(bkpt,execsig); execsig=0;
+                       FI
+                       setbp();
+               FI
+               ptrace(runmode,pid,userpc,execsig);
+               bpwait(); chkerr(); execsig=0; delbp(); readregs();
+
+               IF (signo==0) ANDF (bkpt=scanbkpt(userpc))
+               THEN /* stopped by BPT instruction */
+                       if (debug) printf("\n BPT code; '%s'%o'%o'%d",
+                               bkpt->comm,bkpt->comm[0],EOR,bkpt->flag);
+                       dot=bkpt->loc;
+                       IF bkpt->flag==BKPTEXEC
+                       ORF ((bkpt->flag=BKPTEXEC)
+                               ANDF bkpt->comm[0]!=EOR
+                               ANDF --bkpt->count)
+                       THEN execbkpt(bkpt,execsig); execsig=0; loopcnt++;
+                       ELSE bkpt->count=bkpt->initcnt;
+                       FI
+               ELSE execsig=signo;
+               FI
+       OD
+               if (debug) printf("Returning from runpcs\n");
+}
+
+#define BPOUT 0
+#define BPIN 1
+INT bpstate = BPOUT;
+
+endpcs()
+{
+       REG BKPTR       bkptr;
+               if (debug) printf("Entering endpcs with pid=%d\n");
+       IF pid
+       THEN ptrace(EXIT,pid,0,0); pid=0; userpc=1;
+            FOR bkptr=bkpthead; bkptr; bkptr=bkptr->nxtbkpt
+            DO IF bkptr->flag
+               THEN bkptr->flag=BKPTSET;
+               FI
+            OD
+       FI
+       bpstate=BPOUT;
+}
+
+setup()
+{
+       close(fsym); fsym = -1;
+       IF (pid = fork()) == 0
+       THEN ptrace(SETTRC,0,0,0);
+            signal(SIGINT,sigint); signal(SIGQUIT,sigqit);
+               if (debug) printf("About to doexec  pid=%d\n",pid);
+            doexec(); exit(0);
+       ELIF pid == -1
+       THEN error(NOFORK);
+       ELSE bpwait(); readregs(); /******** lp[0]=EOR; lp[1]=0; */
+       if (debug) printf("About to open symfil = %s\n", symfil);
+            fsym=open(symfil,wtflag);
+            IF errflg
+            THEN printf("%s: cannot execute\n",symfil);
+               if (debug) printf("%d %s\n", errflg, errflg);
+                 endpcs();
+            FI
+       FI
+       bpstate=BPOUT;
+}
+
+execbkpt(bkptr,execsig)
+BKPTR  bkptr;
+{
+       if (debug) printf("exbkpt: %d\n",bkptr->count);
+       delbp();
+       ptrace(SINGLE,pid,bkptr->loc,execsig);
+       bkptr->flag=BKPTSET;
+       bpwait(); chkerr(); readregs();
+}
+
+extern STRING environ;
+
+doexec()
+{
+       STRING          argl[MAXARG];
+       CHAR            args[LINSIZ];
+       STRING          p, *ap, filnam;
+       ap=argl; p=args;
+       *ap++=symfil;
+       REP     IF rdc()==EOR THEN break; FI
+               *ap = p;
+               WHILE lastc!=EOR ANDF lastc!=SP ANDF lastc!=TB DO *p++=lastc; readchar(); OD
+               *p++=0; filnam = *ap+1;
+               IF **ap=='<'
+               THEN    close(0);
+                       IF open(filnam,0)<0
+                       THEN    printf("%s: cannot open\n",filnam); exit(0);
+                       FI
+               ELIF **ap=='>'
+               THEN    close(1);
+                       IF creat(filnam,0666)<0
+                       THEN    printf("%s: cannot create\n",filnam); exit(0);
+                       FI
+               ELSE    ap++;
+               FI
+       PER lastc!=EOR DONE
+       *ap++=0;
+       if (debug) printf("About to exect(%s, %d, %d)\n",symfil,argl,environ);
+       exect(symfil, argl, environ);
+       perror("Returned from exect");
+}
+
+BKPTR  scanbkpt(adr)
+ADDR adr;
+{
+       REG BKPTR       bkptr;
+       FOR bkptr=bkpthead; bkptr; bkptr=bkptr->nxtbkpt
+       DO IF bkptr->flag ANDF bkptr->loc==adr
+          THEN break;
+          FI
+       OD
+       return(bkptr);
+}
+
+delbp()
+{
+       REG ADDR        a;
+       REG BKPTR       bkptr;
+       IF bpstate!=BPOUT
+       THEN
+               FOR bkptr=bkpthead; bkptr; bkptr=bkptr->nxtbkpt
+               DO      IF bkptr->flag
+                       THEN a=bkptr->loc;
+                               ptrace(WIUSER,pid,a,
+                                       (bkptr->ins&0xFF)|(ptrace(RIUSER,pid,a,0)&~0xFF));
+                       FI
+               OD
+               bpstate=BPOUT;
+       FI
+}
+
+setbp()
+{
+       REG ADDR                a;
+       REG BKPTR       bkptr;
+
+       IF bpstate!=BPIN
+       THEN
+               FOR bkptr=bkpthead; bkptr; bkptr=bkptr->nxtbkpt
+               DO IF bkptr->flag
+                  THEN a = bkptr->loc;
+                       bkptr->ins = ptrace(RIUSER, pid, a, 0);
+                       ptrace(WIUSER, pid, a, BPT | (bkptr->ins&~0xFF));
+                       IF errno
+                       THEN error("cannot set breakpoint: ");
+                            printf("%s:%d @ %d\n", adrtoprocp(dot)->pname,
+                               adrtolineno(dot), dot);
+/********
+                            psymoff(bkptr->loc,ISYM,"\n");
+*/
+                       FI
+                  FI
+               OD
+               bpstate=BPIN;
+       FI
+}
+
+bpwait()
+{
+       REG ADDR w;
+       ADDR stat;
+
+       signal(SIGINT, 1);
+       if (debug) printf("Waiting for pid %d\n",pid);
+       WHILE (w = wait(&stat))!=pid ANDF w != -1 DONE
+       if (debug) printf("Ending wait\n");
+       if (debug) printf("w = %d; pid = %d; stat = %o;\n", w,pid,stat);
+       signal(SIGINT,sigint);
+       IF w == -1
+       THEN pid=0;
+            errflg=BADWAIT;
+       ELIF (stat & 0177) != 0177
+       THEN IF signo = stat&0177
+            THEN sigprint();
+            FI
+            IF stat&0200
+            THEN error(" - core dumped");
+                 close(fcor);
+                 setcor();
+            FI
+            pid=0;
+            errflg=ENDPCS;
+       ELSE signo = stat>>8;
+            if (debug) printf("PC = %d, dbsubn = %d\n",
+               ptrace(RUREGS, pid, PC, 0), extaddr("_dbsubn")); 
+            IF signo!=SIGTRC ANDF
+               ptrace(RUREGS, pid, PC, 0) != extaddr("_dbsubn")
+            THEN sigprint();
+            ELSE signo=0;
+            FI
+       FI
+}
+
+readregs()
+{
+       /*get REG values from pcs*/
+       REG i;
+       FOR i=24; --i>=0; 
+       DO *(ADDR *)(((ADDR)&u)+reglist[i].roffs) =
+                   ptrace(RUREGS, pid, reglist[i].roffs, 0);
+       OD
+       userpc= *(ADDR *)(((ADDR)&u)+PC);
+}
+
+rdc()
+{      REP     readchar();
+       PER     lastc==SP ORF lastc==TB
+       DONE
+       return(lastc);
+}
+
+readchar() {
+       lastc = *argsp++;
+       if (lastc == '\0') lastc = '\n';
+}
diff --git a/usr/src/cmd/sdb/setup.c b/usr/src/cmd/sdb/setup.c
new file mode 100644 (file)
index 0000000..38184c6
--- /dev/null
@@ -0,0 +1,139 @@
+#
+/*
+ *
+ *     UNIX debugger
+ *
+ */
+
+#include "head.h"
+
+
+MSG            BADMAG;
+
+INT            wtflag;
+INT            fcor;
+INT            fsym;
+L_INT          maxfile;
+L_INT          maxstor;
+L_INT          txtsiz;
+L_INT          datsiz;
+L_INT          datbas;
+L_INT          stksiz;
+STRING         errflg;
+INT            magic;
+L_INT          symbas;
+L_INT          symnum;
+L_INT          entrypt;
+
+INT            argcount;
+INT            signo;
+struct user u;
+
+STRING         symfil  = "a.out";
+STRING         corfil  = "core";
+
+#define TXTHDRSIZ      (sizeof(txthdr))
+
+#ifndef EDDT
+readl(f,p,n) int f,n; long * p;{
+#ifndef vax
+       int t=0;
+       do {t += read(f,&(p->loword),2); t += read(f,&(p->hiword),2); p++;} while (--n);
+       return(t);
+#else
+       return(read(f,p,n*sizeof(long)));
+#endif
+}
+#endif
+
+setsym()
+{
+#ifndef EDDT
+       TXTHDR          txthdr;
+
+       fsym=getfile(symfil,1);
+       txtmap.ufd=fsym;
+       IF readl(fsym, txthdr, TXTHDRSIZ/sizeof(txthdr[0]))==TXTHDRSIZ
+       THEN    magic=txthdr[0];
+               IF magic!=0411 ANDF magic!=0410 ANDF magic!=0407 ANDF magic!=0405
+               THEN    magic=0;
+               ELSE    symnum=txthdr[4]/SYMTABSIZ;
+                       txtsiz=txthdr[1];
+                       datsiz=txthdr[2];
+                       symbas=txtsiz+datsiz;
+                       txtmap.b1=0;
+                       txtmap.e1=(magic==0407?symbas:txtsiz);
+                       txtmap.f1 = TXTHDRSIZ;
+                       txtmap.b2=datbas=(magic==0410?round(txtsiz,TXTRNDSIZ):0);
+                       txtmap.e2=txtmap.b2+(magic==0407?symbas:datsiz);
+                       txtmap.f2 = TXTHDRSIZ+(magic==0407?0:txtmap.e1);
+                       entrypt=txthdr[5];
+                       symbas += txthdr[6]+txthdr[7];
+                       symbas += TXTHDRSIZ;
+                       ststart = symbas;
+
+                       /* set up symvec */
+               FI
+       FI
+       IF magic==0 THEN txtmap.e1=maxfile; FI
+#endif
+}
+
+setcor()
+{
+#ifndef EDDT
+       fcor=getfile(corfil,2);
+       datmap.ufd=fcor;
+       IF read(fcor, &u, ctob(4))==ctob(4)
+          ANDF (u.u_pcb.pcb_ksp & 0xF0000000L)==0x80000000L
+          ANDF (u.u_pcb.pcb_usp & 0xF0000000L)==0x70000000L
+       THEN    
+               signo = u.u_arg[0]&017;
+               txtsiz = ctob(u.u_tsize);
+               datsiz = ctob(u.u_dsize);
+               stksiz = ctob(u.u_ssize);
+               datmap.b1 = datbas = (magic==0410?round(txtsiz,TXTRNDSIZ):0);
+               datmap.e1=(magic==0407?txtsiz:datmap.b1)+datsiz;
+               datmap.f1 = ctob(USIZE);
+               datmap.b2 = maxstor-stksiz;
+               datmap.e2 = maxstor;
+               datmap.f2 = ctob(USIZE)+(magic==0410?datsiz:datmap.e1);
+               signo = *(ADDR *)(((ADDR)&u)+ctob(4)-4*4);
+               IF magic ANDF magic!=u.u_exdata.ux_mag
+               THEN    printf("%s\n",BADMAG);
+               FI
+       ELSE    datmap.e1 = maxfile;
+       FI
+#endif
+}
+
+#ifndef EDDT
+create(f)
+STRING f;
+{      int fd;
+       IF (fd=creat(f,0644))>=0
+       THEN close(fd); return(open(f,wtflag));
+       ELSE return(-1);
+       FI
+}
+
+getfile(filnam,cnt)
+STRING filnam;
+{
+       REG INT         fsym;
+
+       IF !eqstr("-",filnam)
+       THEN    fsym=open(filnam,wtflag);
+               IF fsym<0 ANDF argcount>cnt
+               THEN    IF wtflag
+                       THEN    fsym=create(filnam);
+                       FI
+                       IF fsym<0
+                       THEN printf("cannot open `%s'\n", filnam);
+                       FI
+               FI
+       ELSE    fsym = -1;
+       FI
+       return(fsym);
+}
+#endif
diff --git a/usr/src/cmd/sdb/sub.c b/usr/src/cmd/sdb/sub.c
new file mode 100644 (file)
index 0000000..ba0227e
--- /dev/null
@@ -0,0 +1,271 @@
+#include "head.h"
+#include <a.out.h>
+#include "cdefs.h"
+#include <stdio.h>
+struct user u;
+
+char *
+readline(f)
+FILE *f; {
+       static char buff[128];
+       
+       register char *p;
+       register int i;
+       
+       p = buff;
+       do {
+               if ((i = getc(f)) == EOF) {
+                       *p++ = '\004';
+                       *p = '\n';
+               }
+               else *p = i;
+       } while (*p++ != '\n');
+       
+       return(buff);
+}
+
+char *
+cpname(p, q)
+char *p, *q; {
+       while(varchar(*q) || number(*q))
+               *p++ = *q++;
+       *p = '\0';
+       return(q);
+}
+
+char *
+cpall(p, q)
+char *p, *q; {
+       while (*q != '\n') 
+               *p++ = *q++;
+       *p = '\0';
+       return(q);
+}
+
+eqany(c, s)
+char c, *s; {
+       while(*s != '\0')
+               if (c == *s++) return(1);
+       return(0);
+}
+
+error(s)
+char *s; {
+       printf("%s\n", s);
+}
+
+cpstr(p,q)
+char *p, *q; {
+       do {
+               *p++ = *q++;
+       } while (*q != '\0');
+       *p = '\0';
+}
+L_INT
+round(a,b)
+REG L_INT a, b;
+{
+       REG L_INT w;
+       w = (a/b)*b;
+       IF a!=w THEN w += b; FI
+       return(w);
+}
+
+/* error handling */
+
+chkerr()
+{
+       IF errflg ORF mkfault
+       THEN    error(errflg);
+               reset();
+       FI
+}
+
+eqstr(s1, s2)
+       REG STRING      s1, s2;
+{
+       REG STRING       es1;
+       if (s2 == (STRING) -1) return(0);
+       es1 = s1+8;
+       WHILE *s1++ == *s2
+       DO IF *s2++ == 0 ORF s1>=es1
+          THEN return(1);
+          FI
+       OD
+       return(0);
+}
+
+longseek(f, a)
+L_INT a;
+{
+#ifndef EDDT
+       return(lseek(f,(long) a,0) != -1);
+#endif
+}
+
+
+/* descriptor format to length */
+dtol(d)
+char d; {
+       switch(d) {
+       
+       case 'a':
+       case 's':
+               return(0);
+               
+       case 'b':
+       case 'c':
+               return(1);
+               
+       case 'h':
+               return(2);
+               
+       case 'l':
+       case 'f':
+               return(4);
+
+       case 'g':
+               return(8);
+
+       default:
+               return(WORDSIZE);
+       }
+}
+
+/*
+ * checks equality of pattern pat with str,
+ * assuming str is tructaed at length 8
+ */
+eqpat(pat, str)
+char *pat, *str; {
+       return(eqpatr(pat, str, 0));
+}
+
+eqpatr(pat, str, cnt)
+char *pat, *str; {
+       register int i;
+       register char p, s;
+       
+       p = pat[0];
+       s = str[0];
+       if (cnt == 8) return(1);
+       if (p == '?') return(eqpatr(pat+1, str+1, cnt+1));
+       if (p == '*') {
+               for(i=1; i<8-cnt; i++) {
+                       if (eqpatr(pat+1, str+i, cnt+i)) return(1);
+                       if (str[i] == '\0') return(0);
+               }
+               return(0);
+       }
+       if ((eqany(p, ".[->") || p == '\0') && s == '\0') return(1);
+       if (p != s) return(0);
+       return(eqpatr(pat+1, str+1, cnt+1));
+}
+
+/* gets indirect address for pointers and subscripts */
+getindir(class, addr, type) 
+ADDR addr; {
+       if (ISARY(type)) return(addr);
+       if (class == N_RSYM)
+               return(*(ADDR *)(((ADDR) &u) + R0 + (WORDSIZE)*addr));
+       return(getval(addr, 'd'));
+}
+
+long
+readint(p)
+char **p; {
+       int sign;
+
+       if (**p == '-') {
+               sign = -1;
+               (*p)++;
+       } else {
+               sign = 1;
+       }
+       if (**p == '0') {
+               (*p)++;
+               if (**p == 'x' || **p == 'X') {
+                       (*p)++;
+                       return(sign * rint(p, 16, hexdigit, hexconv));
+               }
+               else return(sign * rint(p, 8, octdigit, octconv));
+       }
+       else return(sign * rint(p, 10, decdigit, decconv));
+}
+
+long
+rint(p, base, digit, conv)
+char **p;
+int (*digit)(), (*conv)(); {
+       long value;
+       
+       value = 0;
+       while ((*digit)(**p)) value = base*value + (*conv)(*(*p)++);  
+       return(value);
+}
+
+octdigit(c) 
+char c; {
+       return(c >= '0' && c <= '7');
+}
+
+octconv(c)
+char c; {
+       return(c - '0');
+}
+
+decdigit(c)
+char c; {
+       return(c >= '0' && c <= '9');
+}
+
+decconv(c)
+char c; {
+       return(c - '0');
+}
+
+hexdigit(c)
+char c; {
+       return((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') ||
+               (c >= 'A' && c <= 'F'));
+}
+
+hexconv(c)
+char c; {
+       if (c >= '0' && c <= '9') return(c - '0');
+       if (c >= 'a' && c <= 'f') return(c - 'a' + 10);
+       if (c >= 'A' && c <= 'F') return(c - 'A' + 10);
+       error("hex conversion error");
+       return(0);
+}
+
+/* decodes number, character or variable */
+long
+argvalue(p)
+char *p; {
+       register char ch;
+       register long value;
+       register ADDR j;
+       char var[30];
+
+       ch = *p;
+       if (ch == '\'') {
+               value = *(p+1);
+       } else if ((ch >= '0' && ch <= '9') || ch == '-') {
+               value = readint(&p);
+       } else if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') ||
+               ch == '_') {
+               cpname(var, p);
+               j = varaddr(curproc()->pname, var);
+               if (j == -1) {
+                       printf("Unknown variable: %s\n", argsp);
+                       return(-1);
+               }
+               value = getval(j, typetodesc(sl_type, 0)[0]);
+               do {
+                       p++;
+               } while (varchar(*p) || number(*p));
+       }
+       return(value);
+}
+
diff --git a/usr/src/cmd/sdb/symt.c b/usr/src/cmd/sdb/symt.c
new file mode 100644 (file)
index 0000000..c398243
--- /dev/null
@@ -0,0 +1,422 @@
+#include "head.h"
+#include <a.out.h>
+
+struct user u;
+int compar();
+
+/* initialize file and procedure tables */
+initfp() {
+       struct nlist stentry;
+       register struct proct *procp;
+       register struct filet *filep;
+       long soffset;
+       int i;
+       char class;
+       register char *p, *q;
+       
+       sbuf.fd = txtmap.ufd;
+       soffset = ststart;
+       blseek(&sbuf,ststart,0);
+       filep = files = badfile = (struct filet *) sbrk(sizeof filep[0]);
+       procp = procs = badproc = (struct proct *) sbrk(sizeof procp[0]);
+       
+       for(;;) {
+               if (bread(&sbuf, &stentry, sizeof stentry) < sizeof stentry) break;
+               class = stentry.n_type & STABMASK;
+               switch (class & STABMASK) {
+               case N_SO:
+               case N_SOL:
+                       if (filep == badfile) {
+                               p = sbrk(FILEINCR*sizeof filep[0]);
+                               q = p + FILEINCR*sizeof filep[0];
+                               while (p > (char *) procs)
+                                       *--q = *--p;
+                               badfile += FILEINCR;
+                               procp = (struct proct *)
+                                   ((char *) procp + FILEINCR*sizeof filep[0]);
+                               procs = (struct proct *)
+                                   ((char *) procs + FILEINCR*sizeof filep[0]);
+                               badproc = (struct proct *)
+                                   ((char *)badproc + FILEINCR*sizeof filep[0]);
+                       }
+                       filep->faddr = stentry.n_value;
+                       filep->lineflag = (class == N_SOL);
+                       filep->stf_offset = soffset;
+                       p = filep->sfilename;
+                       for (;;) {
+                               for (i=0; i<8; i++) *p++ = stentry.n_name[i];
+                               if (*(p-1) == '\0') break;
+                               if (bread(&sbuf, &stentry, sizeof stentry) < sizeof stentry)
+                                       error("Bad N_SO entry (1)");
+                               if ((stentry.n_type & STABMASK) != (unsigned char) class)
+                                       error("Bad N_SO entry (2)");
+                               soffset += sizeof stentry;
+                       }
+                       filep++;
+                       break;
+                       
+               case N_TEXT:
+                       if (stentry.n_name[0] != '_') break;
+               case N_FUN:
+                       if (procp == badproc) {
+                               if (sbrk(PROCINCR*sizeof procp[0]) < 0) {
+                                       perror("sdb");
+                                       exit(4);
+                               }
+                               badproc += PROCINCR;
+                       }
+                       for(i=0; i<8; i++)
+                               procp->pname[i] = stentry.n_name[i];
+                       procp->paddr = stentry.n_value;
+                       procp->st_offset = soffset;
+                       procp->sfptr = (class==N_FUN) ? filep - 1 : badfile;
+                       procp->lineno = (class == N_FUN) ? stentry.n_desc : 0;
+                       procp++;
+                       break;
+               }
+               if (stentry.n_type & N_EXT  &&  !extstart) {
+                       extstart = soffset;
+               }
+               soffset += sizeof stentry;
+       }
+       qsort(procs, procp-procs, sizeof procs[0], compar);
+       badproc->sfptr = procp->sfptr = badfile;
+       badproc->pname[0] = badfile->sfilename[0]=
+               procp->pname[0] = filep->sfilename[0] = '\0';
+
+       setcur();
+}
+
+/* returns current procedure from state (curfile, fline) */
+struct proct
+*curproc() {
+       register int i;
+       register ADDR addr;
+
+/* The 'i' stuff is a kludge */
+       for (i = 0; i<10000; i++) {
+               addr = getaddr("", fline+i);
+               if (addr != -1) break;
+               }
+       if (addr == -1) return(badproc);
+       return(adrtoprocp(addr));
+
+}
+
+/* returns procedure s, uses curproc() if s == NULL */
+
+struct proct *
+findproc(s)
+char *s; {
+       register struct proct *p;
+       
+       if (s[0] == '\0') return(curproc());
+       
+       for(p=procs; p->pname[0]; p++)
+               if (eqstr(p->pname, s)) return(p);
+               
+       if (debug) printf("%s(): unknown name\n", s);
+       return(badproc);
+}
+
+/* returns file s containing filename */
+struct filet *
+findfile(s)
+char *s; {
+       register struct filet *f;
+       for (f=files; f->sfilename[0]; f++) {
+               if (eqstr(f->sfilename, s)) { 
+                       for( ; f->lineflag; f--) ;
+                       if (f < files) error("Bad file array");
+                       return(f);
+               }
+       }
+       return(f);
+}
+
+/* looks up variable matching pat starting at offset in a.out, searching
+ * backwards, ignoring nested blocks to beginning to procedure.
+ * Returns its offset and symbol table entries decoded in sl_*
+ */
+slookup(pat, offset)
+register long offset; char *pat; {
+       register int level, i;
+       char class; 
+       struct nlist stentry;
+       if (debug) printf("slookup(%s,%d)\n",pat,offset);
+       
+       offset += sizeof stentry;
+       level = 0;
+       blseek(&sbuf, offset, 0);
+       
+       for (;;) {
+               offset -= sizeof stentry;
+               if (offset < ststart) break;
+               if (bread(&sbuf, &stentry+1, -sizeof stentry) < sizeof stentry) break;
+               class = stentry.n_type & STABMASK;
+               switch (class & STABMASK) {
+               case 0:
+                       break;
+               case N_FUN:
+                       return(-1);
+               case N_RBRAC:
+                       level++;
+                       break;
+               case N_LBRAC:
+                       level--;
+                       break;
+               default:
+                       if (level <= 0  &&  eqpat(pat, stentry.n_name)) {
+                               if (class == N_LENG) {
+                                       sl_size = stentry.n_value;
+                                       offset -= sizeof stentry;
+                                       bread(&sbuf, &stentry+1, -sizeof stentry);
+                               }
+                               else sl_size = 0;
+                               sl_class = stentry.n_type & STABMASK;
+                               sl_type = stentry.n_desc;
+                               sl_addr = stentry.n_value;
+                               for (i=0; i<8; i++) sl_name[i] = stentry.n_name[i];
+                               return(offset);
+                       }
+               }
+       }
+       return(-1);
+}
+
+/* 
+ * Look up global variable matching pat
+ * Return its offset and symbol table entries decoded in sl_*
+ */
+globallookup(pat, filestart)
+char *pat; long filestart; {
+       register int offset, i;
+       struct nlist stentry;
+       
+       if (debug) printf("globallookup(%s,%d)\n", pat,filestart);
+       blseek(&sbuf, filestart, 0);
+       offset = filestart - sizeof stentry;
+       do {
+               if (bread(&sbuf, &stentry, sizeof stentry) < sizeof stentry) return(-1);
+               offset += sizeof stentry;
+       } while ((stentry.n_type & STABMASK) == N_SO);
+       for (;;) {
+               if ((stentry.n_type & STABMASK) == N_SO) return(-1);
+               if ((eqpat(pat, stentry.n_name))) {
+                       sl_class = stentry.n_type & STABMASK;
+                       if (sl_class != N_GSYM && sl_class != N_SSYM && 
+                               sl_class != N_STSYM) goto g1;
+                       sl_size = 0;
+                       sl_type = stentry.n_desc;
+                       sl_addr = stentry.n_value;
+                       for (i=0; i<8; i++) sl_name[i] = stentry.n_name[i];
+                       break;
+               }
+g1:            if (bread(&sbuf, &stentry, sizeof stentry) < sizeof stentry)
+                       return(-1);
+               offset += sizeof stentry;
+       }
+       bread(&sbuf, &stentry, sizeof stentry);
+       if (((stentry.n_type & STABMASK) == N_LENG) && (eqpat(pat, stentry.n_name)))
+               sl_size = stentry.n_value;
+
+       if (sl_class == N_GSYM) {
+               blseek(&sbuf, extstart, 0);
+               for(;;) {
+                       if (bread(&sbuf, &stentry, sizeof stentry) < sizeof stentry)
+                               return(-1);
+                       if (stentry.n_name[0] != '_') continue;
+                       if (eqpatr(pat, stentry.n_name+1, 1)) {
+                               sl_addr = stentry.n_value;
+                               break;
+                       }
+               }
+       }
+       return(offset);
+}
+
+/* core address to procedure (pointer to proc array) */
+struct proct *
+adrtoproc(addr) 
+ADDR addr; {
+       register struct proct *procp;
+       for (procp=procs; procp->pname[0]; procp++) {
+               if (procp->paddr > addr) break;
+       }
+       return (procp != procs ? procp-1 : badproc);
+}
+
+/* core address to file (pointer to file array) */
+struct filet *
+adrtofilep(addr) 
+ADDR addr; {
+       register struct filet *filep;
+       for (filep=files; filep->sfilename[0]; filep++) {
+               if (filep->faddr > addr) break;
+       }
+       return (filep != files ? filep-1 : badfile);
+}
+/* core address to linenumber */
+long lastoffset;
+
+adrtolineno(addr) 
+ADDR addr; {
+       register int lineno;
+       long offset; 
+       struct nlist stentry;
+       
+       lineno = lastoffset = -1;
+       offset = adrtoproc(addr)->st_offset;
+       blseek(&sbuf, offset, 0);
+       for (;;) {
+               if (bread(&sbuf, &stentry, sizeof stentry) < sizeof stentry) break;
+               if (stentry.n_type == N_SLINE) {
+                       if (stentry.n_value > addr) break;
+                       lastoffset = offset;
+                       lineno = stentry.n_desc;
+               }
+               offset += sizeof stentry;
+       }
+       return (lineno);
+}
+
+
+/* address to a.out offset */
+long
+adrtostoffset(addr) 
+ADDR addr; {
+       adrtolineno(addr);
+       return(lastoffset);
+}
+
+
+/*
+ * Set (curfile, lineno) from core image.
+ * Returns 1 if there is a core image, 0 otherwise.
+ */
+setcur() {
+       register struct proct *procp;
+       
+       dot = *(ADDR *) (((ADDR) &u) + PC);
+       
+       if (dot == 0) {
+               printf("No core image\n");
+               goto setmain;
+       }
+       procp = adrtoprocp(dot);
+       if ((procp->sfptr) != badfile) {
+               finit(adrtofilep(dot)->sfilename);
+               ffind(adrtolineno(dot));
+               printf("%.8s:", procp->pname);
+               fprint();
+               return(1);
+       }
+       if (procp->pname[0] == '_') 
+               printf("%.7s: address 0x%x\n", procp->pname+1, dot);
+       else
+               printf("%.8s: address %d\n", procp->pname, dot);
+       
+setmain:
+       procp = findproc("main");
+       if ((procp->pname[0] == 'm') && (procp->sfptr != badfile)) {
+               finit(procp->sfptr->sfilename);
+               ffind(procp->lineno);
+/*
+               printf("main() in \"%s\"\n", curfile);
+*/
+       }
+       else printf("main not compiled with debug flag\n");
+       return(0);
+}
+
+compar(a, b)
+struct proct *a, *b; {
+       if (a->paddr == b->paddr)
+               return(a->pname[0] == '_' ? -1 : 1);
+       return(a->paddr < b->paddr ? -1 : 1);
+}
+
+/* gets offset of file or procedure named s */
+nametooffset(s)
+char *s; {
+       register struct filet *f;
+       register struct proct *p;
+       
+       if (eqany('.', s)) {
+               f = findfile(s);
+               return(f->sfilename[0] ? f->stf_offset : -1);
+       }
+       p = findproc(s);
+       return(p->pname[0] ? p->st_offset : -1);
+}
+
+
+/* line number to address, starting at offset in a.out */
+/* THIS SHOULD BE FIXED TO KNOW ABOUT #line FILES */
+lntoaddr(lineno, offset) 
+long offset; {
+       struct nlist stentry;
+       
+       blseek(&sbuf, offset, 0);
+       
+       do {
+               if (bread(&sbuf, &stentry, sizeof stentry) < sizeof stentry) return(-1);
+       } while ((stentry.n_type & STABMASK) == N_SO);
+       for (;;) {
+               switch(stentry.n_type & STABMASK) {
+               case N_SLINE:
+                       if (stentry.n_desc == lineno) return(stentry.n_value);
+                       break;
+               case N_SO:
+                       return(-1);
+               }
+               if (bread(&sbuf, &stentry, sizeof stentry) < sizeof stentry) break;
+       }
+       return(-1);
+}
+
+/* gets address of proc:number */
+getaddr(proc,integ) 
+char *proc; {
+       register long offset;
+       register char *s;
+       ADDR addr;
+       
+       s = proc[0] ? proc : curfile;
+       offset = nametooffset(s);
+       if (debug) printf("getaddr() computed offset %d", offset);
+       if (offset == -1) {
+               addr = extaddr(proc);
+               if (addr != -1) addr += 2;  /* MACHINE DEPENDENT */
+               if (debug) printf(" extaddr computed %d\n", addr);
+               return(addr);
+       }
+       if (integ)
+               addr = lntoaddr(integ, offset);
+       else {
+               addr = findproc(proc)->paddr + 2;  /* MACHINE DEPENDENT */
+               addr = lntoaddr(adrtolineno(addr)+1, offset);
+       }
+       if (debug) printf(" and addr %d\n", addr);
+       if (addr == -1) return(-1);
+       return(addr);
+}
+
+/* returns address of external */
+ADDR
+extaddr(name)
+char *name; {
+       struct nlist stentry;
+       blseek(&sbuf, extstart, 0);
+       
+       for (;;) {
+               if (bread(&sbuf, &stentry, sizeof stentry) < sizeof stentry)
+                       return(-1);
+               if (stentry.n_name[0] == '_' && 
+                           eqpatr(name, stentry.n_name+1, 1)) 
+                       return(stentry.n_value);
+       }
+}
diff --git a/usr/src/cmd/sdb/udef.c b/usr/src/cmd/sdb/udef.c
new file mode 100644 (file)
index 0000000..958d783
--- /dev/null
@@ -0,0 +1,2 @@
+#include <sys/param.h>
+char           u[ctob(4)]; /* struct user u */
diff --git a/usr/src/cmd/sdb/xeq.c b/usr/src/cmd/sdb/xeq.c
new file mode 100644 (file)
index 0000000..6698b9e
--- /dev/null
@@ -0,0 +1,172 @@
+#include "head.h"
+#include <a.out.h>
+struct user u;
+#include <stdio.h>
+INT signo;
+INT adrflg;
+INT pid;
+L_INT cntval;
+
+
+/* service routines for sub process control */
+
+
+/*
+ * single step until loc with descriptor format d is modified
+ * return its new value.
+ */
+monex(loc, d)
+ADDR loc; char d; {
+       register ADDR oldval;
+       
+       oldval = getval(loc, d);
+       do {
+               subpcs('s');
+       } while (oldval == getval(loc, d));
+       return(getval(loc, d));
+}
+
+/* single step count source stmts */
+singstep(count) {
+       register int thisline, curline;
+       register ADDR dot;
+       register struct proct *thisproc;
+       
+       dot = *(ADDR *) (((ADDR) &u) + PC);
+       thisproc = adrtoprocp(dot);
+       thisline = adrtolineno(dot);
+       if (count == 0) count = 1;
+       for(; count; count--) {
+               do {
+                       subpcs('s');
+                       dot = *(ADDR *) (((ADDR) &u) + PC);
+                       curline = adrtolineno(dot);
+               } while (!signo && 
+                       ((thisproc == adrtoprocp(dot) && thisline == curline) ||
+                       curline == -1));
+               if (signo) return;
+       }
+}
+
+doscall() {
+       int subargs[NUMARGS];        /* subargs[0]    = address, 
+                                       subargs[1]    = number of arguments
+                                       subargs[2:NUMARGS] = actual arguments */
+       union {
+               struct {
+                       int w[128-NUMARGS];
+               };
+               struct {
+                       char c[4*(128-NUMARGS)];
+               };
+       }substr;
+       
+       register int i, numchars, *subargp;
+       register char ch;
+       ADDR straddr, adr, praddr;
+       ADDR j;
+       
+       praddr = extaddr(proc);
+       if (praddr == -1) {
+               printf("Cannot find %s\n", proc);
+               return;
+       }
+       straddr = extaddr("_dbargs");
+       if (straddr == -1) {
+               error("Program not loaded with -lg");
+               return;
+       }
+       
+       numchars = 0;
+       subargp = subargs;
+       argsp++;
+       *subargp++ = praddr;
+       subargp++;
+       
+       for (i=0; i<NUMARGS - 2; i++) {  /* process an argument */
+               ch = *argsp;
+               if (ch == '\'') {
+                       *subargp++ = *(argsp+1);
+                       argsp += 2;
+               } else if (ch == '"') {
+                       *subargp++ = straddr + sizeof subargs + numchars;
+                       argsp++;
+                       for (;;) {
+                               substr.c[numchars++] = ch = *argsp++;
+                               if (ch == '"') {
+                                       substr.c[numchars-1] = '\0';
+                                       break;
+                               }
+                               if (ch == '\0') {
+                                       error("Unterminated string constant");
+                                       return;
+                               }
+                               if (numchars > sizeof substr.c) {
+                                       error("Too many string constants");
+                                       return;
+                               }
+                       }
+               } else if ((ch >= '0' && ch <= '9') || ch == '-') {
+                       *subargp++ = readint(&argsp);
+               } else if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') ||
+                       ch == '_') {
+                       cpname(var, argsp);
+                       j = varaddr(curproc()->pname, var);
+                       if (j == -1) {
+                               printf("Unknown variable: %s\n", argsp);
+                               return;
+                       }
+                       *subargp++ = getval(j, typetodesc(sl_type, 0)[0]);
+                       do {
+                               argsp++;
+                       } while (varchar(*argsp) || number(*argsp));
+               } else if (ch != ')') {
+                       printf("Unexpected character %c\n", ch);
+                       return;
+               }
+       
+               do {
+                       ch = *argsp++;
+               } while(ch == ' ');
+               if (ch == ')') {
+                       dot = *(ADDR *)(((ADDR)&u)+PC) = extaddr("_dbsubc");
+                       if (dot == -1) {
+                               error("Internal error - cannot find _dbsubc");
+                               return;
+                       }
+                       adrflg = 1;
+                       cntval = 1;
+                       if (pid == 0 || signo) subpcs('r');
+                       subargs[1] = (subargp - subargs) - 2;
+                       adr = straddr;
+                       for (j=0; j<=(subargp-subargs); j++) {
+                               put(adr, DSP, subargs[j]);
+                               adr += WORDSIZE;
+                       }
+                       adr = straddr + sizeof subargs;
+                       for (j=0; j<(numchars+WORDSIZE-1)/WORDSIZE; j++) {
+                               put(adr, DSP, substr.w[j]);
+                               adr += WORDSIZE;
+                       }
+                       errflg = 0;
+                       subpcs('c');
+                       dot = *(ADDR *)(((ADDR)&u)+PC);
+                       if (dot != extaddr("_dbsubn")) {
+                               if (!signo) printf("Breakpoint\n");
+                               else printf(" at\n");
+                               return;
+                       }
+                       if (*argsp++ == '/') {
+                               dispf((ADDR) 0, *argsp ? *argsp : 'd', N_RSYM, 0, 0);
+                       }
+                       else
+                               printf("Procedure returned normally\n");
+                       reset();
+               }
+               while (*argsp == ' ' || *argsp == ',')
+                       argsp++;
+       }
+       
+       error ("Too many arguments");
+
+}
diff --git a/usr/src/cmd/sed/Makefile b/usr/src/cmd/sed/Makefile
new file mode 100644 (file)
index 0000000..96fea3e
--- /dev/null
@@ -0,0 +1,12 @@
+CFLAGS=-O
+
+sed:   sed0.o sed1.o
+       cc -o sed *.o
+
+sed0.o: sed0.c sed.h
+sed1.o: sed1.c sed.h
+
+install: sed
+       install -s sed $(DESTDIR)/usr/bin
+clean:
+       rm -f *.o
diff --git a/usr/src/cmd/sed/makefile b/usr/src/cmd/sed/makefile
deleted file mode 100644 (file)
index affa51f..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-CFLAGS = -n -O
-
-all:   sed
-       :
-
-cp:    all
-       cp sed /bin
-       rm sed *.o
-
-cmp:   all
-       cmp sed /bin/sed
-       rm sed *.o
-
-sed:   sed0.o sed1.o; cc -s -o sed -n *.o
-
-sed0.o: sed0.c sed.h
-sed1.o: sed1.c sed.h
index d64de3d..3b22446 100644 (file)
@@ -2,7 +2,9 @@
 /*
  * sed -- stream  editor
  *
 /*
  * sed -- stream  editor
  *
+ * Copyright 1975 Bell Telephone Laboratories, Incorporated
  *
  *
+ * Owner: lem
  */
 
 #define CBRA   1
  */
 
 #define CBRA   1
@@ -46,7 +48,6 @@ char  seof;
 char   *reend;
 char   *lbend;
 char   *hend;
 char   *reend;
 char   *lbend;
 char   *hend;
-char   *lcomend;
 union reptr    *ptrend;
 int    eflag;
 int    dolflag;
 union reptr    *ptrend;
 int    eflag;
 int    dolflag;
@@ -161,4 +162,3 @@ char        *compsub();
 struct label   *search();
 char   *gline();
 char   *place();
 struct label   *search();
 char   *gline();
 char   *place();
-char   compfl;
index c2f27c3..2b92948 100644 (file)
@@ -32,7 +32,6 @@ char  *argv[];
        rep->ad1 = respace;
        lbend = &linebuf[LBSIZE];
        hend = &holdsp[LBSIZE];
        rep->ad1 = respace;
        lbend = &linebuf[LBSIZE];
        hend = &holdsp[LBSIZE];
-       lcomend = &genbuf[71];
        ptrend = &ptrspace[PTRSIZE];
        reend = &respace[RESIZE];
        labend = &labtab[LABSIZE];
        ptrend = &ptrspace[PTRSIZE];
        reend = &respace[RESIZE];
        labend = &labtab[LABSIZE];
@@ -40,7 +39,6 @@ char  *argv[];
        pending = 0;
        depth = 0;
        spend = linebuf;
        pending = 0;
        depth = 0;
        spend = linebuf;
-       hspend = holdsp;
        fcode[0] = stdout;
        nfiles = 1;
 
        fcode[0] = stdout;
        nfiles = 1;
 
@@ -83,7 +81,7 @@ char  *argv[];
                }
 
 
                }
 
 
-       if(compfl == 0) {
+       if(rep == ptrspace) {
                eargv--;
                eargc++;
                eflag++;
                eargv--;
                eargc++;
                eflag++;
@@ -121,7 +119,6 @@ fcomp()
        int     i;
        struct label    *lpt;
 
        int     i;
        struct label    *lpt;
 
-       compfl = 1;
        op = lastre;
 
        if(rline(linebuf) < 0)  return;
        op = lastre;
 
        if(rline(linebuf) < 0)  return;
index 52dd768..1acc476 100644 (file)
@@ -1,41 +1,6 @@
 #include       <stdio.h>
 #include "sed.h"
 
 #include       <stdio.h>
 #include "sed.h"
 
-char   *trans[040]  = {
-       "\\01",
-       "\\02",
-       "\\03",
-       "\\04",
-       "\\05",
-       "\\06",
-       "\\07",
-       "<\b-",
-       ">\b-",
-       "\n",
-       "\\13",
-       "\\14",
-       "\\15",
-       "\\16",
-       "\\17",
-       "\\20",
-       "\\21",
-       "\\22",
-       "\\23",
-       "\\24",
-       "\\25",
-       "\\26",
-       "\\27",
-       "\\30",
-       "\\31",
-       "\\32",
-       "\\33",
-       "\\34",
-       "\\35",
-       "\\36",
-       "\\37"
-};
-char   rub[] = {"\177"};
-
 execute(file)
 char *file;
 {
 execute(file)
 char *file;
 {
@@ -404,7 +369,7 @@ command(ipc)
 union reptr    *ipc;
 {
        register int    i;
 union reptr    *ipc;
 {
        register int    i;
-       register char   *p1, *p2, *p3;
+       register char   *p1, *p2;
        char    *execp;
 
 
        char    *execp;
 
 
@@ -461,9 +426,7 @@ union reptr *ipc;
                        *spend++ = '\n';
                        p1 = spend;
                        p2 = holdsp;
                        *spend++ = '\n';
                        p1 = spend;
                        p2 = holdsp;
-                       while(*p1++ = *p2++)
-                               if(p1 >= lbend)
-                                       break;
+                       while(*p1++ = *p2++);
                        spend = p1-1;
                        break;
 
                        spend = p1-1;
                        break;
 
@@ -478,9 +441,7 @@ union reptr *ipc;
                        *hspend++ = '\n';
                        p1 = hspend;
                        p2 = linebuf;
                        *hspend++ = '\n';
                        p1 = hspend;
                        p2 = linebuf;
-                       while(*p1++ = *p2++)
-                               if(p1 >= hend)
-                                       break;
+                       while(*p1++ = *p2++);
                        hspend = p1-1;
                        break;
 
                        hspend = p1-1;
                        break;
 
@@ -495,42 +456,6 @@ union reptr        *ipc;
                        break;
 
                case LCOM:
                        break;
 
                case LCOM:
-                       p1 = linebuf;
-                       p2 = genbuf;
-                       genbuf[72] = 0;
-                       while(*p1)
-                               if(*p1 >= 040) {
-                                       if(*p1 == 0177) {
-                                               p3 = rub;
-                                               while(*p2++ = *p3++)
-                                                       if(p2 >= lcomend) {
-                                                               *p2 = '\\';
-                                                               fprintf(stdout, "%s\n", genbuf);
-                                                               p2 = genbuf;
-                                                       }
-                                               p2--;
-                                               p1++;
-                                               continue;
-                                       }
-                                       *p2++ = *p1++;
-                                       if(p2 >= lcomend) {
-                                               *p2 = '\\';
-                                               fprintf(stdout, "%s\n", genbuf);
-                                               p2 = genbuf;
-                                       }
-                               } else {
-                                       p3 = trans[*p1-1];
-                                       while(*p2++ = *p3++)
-                                               if(p2 >= lcomend) {
-                                                       *p2 = '\\';
-                                                       fprintf(stdout, "%s\n", genbuf);
-                                                       p2 = genbuf;
-                                               }
-                                       p2--;
-                                       p1++;
-                               }
-                       *p2 = 0;
-                       fprintf(stdout, "%s\n", genbuf);
                        break;
 
                case NCOM:
                        break;
 
                case NCOM:
@@ -596,7 +521,7 @@ union reptr *ipc;
 
                case SCOM:
                        i = substitute(ipc);
 
                case SCOM:
                        i = substitute(ipc);
-                       if(ipc->pfl && i)
+                       if(ipc->pfl && nflag && i)
                                if(ipc->pfl == 1) {
                                        for(p1 = linebuf; p1 < spend; p1++)
                                                putc(*p1, stdout);
                                if(ipc->pfl == 1) {
                                        for(p1 = linebuf; p1 < spend; p1++)
                                                putc(*p1, stdout);
@@ -641,8 +566,7 @@ union reptr *ipc;
 
 }
 
 
 }
 
-char   *
-gline(addr)
+char   *gline(addr)
 char   *addr;
 {
        register char   *p1, *p2;
 char   *addr;
 {
        register char   *p1, *p2;
diff --git a/usr/src/cmd/sh/Makefile b/usr/src/cmd/sh/Makefile
new file mode 100644 (file)
index 0000000..ca06d74
--- /dev/null
@@ -0,0 +1,33 @@
+CFLAGS = -n -s -O
+
+all:   sh
+
+cp:    sh
+       cp sh /bin/sh
+       rm sh *.o
+
+cmp:   sh
+       cmp sh /bin/sh
+       rm sh *.o
+
+sh:    setbrk.o
+sh:    builtin.o blok.o stak.o
+sh:    cmd.o fault.o main.o
+sh:    word.o string.o name.o args.o
+sh:    xec.o service.o error.o io.o
+sh:    print.o macro.o expand.o
+sh:    ctype.o msg.o
+blok.o:                brkincr.h
+fault.o:       brkincr.h
+main.o:                brkincr.h
+stak.o:                brkincr.h
+
+sh:;           cc -o sh -n *.o
+
+newsys:;       :newsys file=msg; make sh
+install:;      install -s sh $(DESTDIR)/bin
+clean:; rm -f sh *.o
+diff:;         :diff
+list:;         list Makefile *.h *.s *.c
+
+.c.o:; cc -O  -c $<
index 5d5f979..5384f68 100644 (file)
@@ -138,14 +138,13 @@ BOOL              prof;
                        THEN    prs(mailmsg)
                        FI
                        mailtime=statb.st_mtime;
                        THEN    prs(mailmsg)
                        FI
                        mailtime=statb.st_mtime;
-                       prs(ps1nod.namval); alarm(TIMEOUT); flags |= waiting;
+                       prs(ps1nod.namval);
                FI
 
                trapnote=0; peekc=readc();
                IF eof
                THEN    return;
                FI
                FI
 
                trapnote=0; peekc=readc();
                IF eof
                THEN    return;
                FI
-               alarm(0); flags &= ~waiting;
                execute(cmd(NL,MTFLG),0);
                eof |= (flags&oneflg);
        POOL
                execute(cmd(NL,MTFLG),0);
                eof |= (flags&oneflg);
        POOL
diff --git a/usr/src/cmd/sh/makefile b/usr/src/cmd/sh/makefile
deleted file mode 100644 (file)
index bf520ab..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-CFLAGS = -n -s -O
-
-all:   sh
-
-cp:    sh
-       cp sh /bin/sh
-       rm sh *.o
-
-cmp:   sh
-       cmp sh /bin/sh
-       rm sh *.o
-
-sh:    setbrk.o
-sh:    builtin.o blok.o stak.o
-sh:    cmd.o fault.o main.o
-sh:    word.o string.o name.o args.o
-sh:    xec.o service.o error.o io.o
-sh:    print.o macro.o expand.o
-sh:    ctype.o msg.o
-blok.o:                brkincr.h
-fault.o:       brkincr.h
-main.o:                brkincr.h
-stak.o:                brkincr.h
-
-sh:;           cc -o sh -n -s *.o
-
-newsys:;       :newsys file=msg; make sh
-install:;      :install
-diff:;         :diff
-list:;         list Makefile *.h *.s *.c
-
-.c.o:; cc -O -c $<
-.c.s:; cc -O -S -o $*.s $<
-.s.o:; as - -o $*.o /usr/include/sys.s $<
index fa129ed..a06a7da 100644 (file)
@@ -7,4 +7,4 @@
  *
  */
 
  *
  */
 
-#define TIMEOUT 0
+#define TIMEOUT 2400
index 7a3d75f..a04d3c9 100644 (file)
@@ -40,7 +40,7 @@ char **argv;
                        printf("%s: ", *argv);
                printf("%u+%u+%u = ", buf.a_text,buf.a_data,buf.a_bss);
                sum = (long) buf.a_text + (long) buf.a_data + (long) buf.a_bss;
                        printf("%s: ", *argv);
                printf("%u+%u+%u = ", buf.a_text,buf.a_data,buf.a_bss);
                sum = (long) buf.a_text + (long) buf.a_data + (long) buf.a_bss;
-               printf("%Db = 0%Ob\n", sum, sum);
+               printf("%Db = 0x%Xb\n", sum, sum);
                fclose(f);
        }
 }
                fclose(f);
        }
 }
index 8da6251..bccb330 100644 (file)
@@ -176,6 +176,7 @@ char **argv;
        char *arg;
        struct field *p, *q;
        int i;
        char *arg;
        struct field *p, *q;
        int i;
+       unsigned pid;
 
        copyproto();
        eargv = argv;
 
        copyproto();
        eargv = argv;
diff --git a/usr/src/cmd/spell/Makefile b/usr/src/cmd/spell/Makefile
new file mode 100644 (file)
index 0000000..8ef9073
--- /dev/null
@@ -0,0 +1,27 @@
+all:   spell hlist hlista hlistb hstop spellin
+
+install:       all
+       install -s spell $(DESTDIR)/usr/lib
+       install -c hlista $(DESTDIR)/usr/dict
+       install -c hlistb $(DESTDIR)/usr/dict
+       install -c hstop $(DESTDIR)/usr/dict
+       install -c spell.sh $(DESTDIR)/usr/bin/spell
+
+clean: 
+       rm -f spell spellin hlista hlistb hlist hstop
+
+spell: spell.c
+       cc -s -O spell.c -o spell
+spellin: spellin.c
+       cc -O -s spellin.c -o spellin
+spellout: spellout.c
+       cc -O -s spellout.c -o spellout
+
+hlist: /usr/dict/words spellin
+       spellin </usr/dict/words >hlist
+hlista: american local hlist spellin
+       (cat american local)|spellin hlist >hlista
+hlistb: british local hlist spellin
+       (cat british local)|spellin hlist >hlistb
+hstop: stop spellin
+       spellin <stop >hstop
index 5bf6965..7015f97 100644 (file)
@@ -73,7 +73,6 @@ demagnetize
 demeanor
 demineralize
 demoralize
 demeanor
 demineralize
 demoralize
-denormalize
 depersonalize
 depolarize
 desensitize
 depersonalize
 depolarize
 desensitize
@@ -118,7 +117,6 @@ favorite
 fervor
 fiber
 flavor
 fervor
 fiber
 flavor
-flavorful
 fraternize
 fueled
 fueler
 fraternize
 fueled
 fueler
@@ -184,6 +182,9 @@ medieval
 memorize
 mesmerize
 metallize
 memorize
 mesmerize
 metallize
+milligram
+milliliter
+millimeter
 modeled
 modeler
 modeling
 modeled
 modeler
 modeling
@@ -216,7 +217,6 @@ photolyze
 photosynthesize
 picogram
 plagiarize
 photosynthesize
 picogram
 plagiarize
-plow
 preprogram
 program
 proselytize
 preprogram
 program
 proselytize
index 4eb2e36..9d58195 100644 (file)
@@ -78,7 +78,6 @@ demagnetise
 demeanour
 demineralise
 demoralise
 demeanour
 demineralise
 demoralise
-denormalise
 depersonalise
 depolarise
 desensitise
 depersonalise
 depolarise
 desensitise
@@ -120,7 +119,6 @@ favourite
 fervour
 fibre
 flavour
 fervour
 fibre
 flavour
-flavourful
 fraternise
 fuelled
 fueller
 fraternise
 fuelled
 fueller
@@ -185,6 +183,9 @@ memorise
 mesmerise
 metallise
 metre
 mesmerise
 metallise
 metre
+milligramme
+millilitre
+millimetre
 modelled
 modeller
 modelling
 modelled
 modeller
 modelling
@@ -220,7 +221,6 @@ photolyse
 photosynthesise
 picogramme
 plagiarise
 photosynthesise
 picogramme
 plagiarise
-plough
 practise
 preprogramme
 programme
 practise
 preprogramme
 programme
@@ -276,6 +276,7 @@ squirrelling
 stigmatise
 succour
 summarise
 stigmatise
 succour
 summarise
+millimetre
 swivelled
 swivelling
 symmetrise
 swivelled
 swivelling
 symmetrise
diff --git a/usr/src/cmd/spell/makefile b/usr/src/cmd/spell/makefile
deleted file mode 100644 (file)
index 1440197..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-all:   spell hlist hlista hlistb hstop spellin
-       :
-
-cp:    all
-       cp spell /usr/lib
-       cp hlista /usr/dict
-       cp hlistb /usr/dict
-       cp hstop /usr/dict
-       rm spell hlista hlistb hstop hlist
-
-cmp:   spell
-       cmp spell /usr/lib/spell
-       rm spell
-
-spell: spell.c
-       cc -i -s -O spell.c -o spell
-spellin: spellin.c
-       cc -i -O -s spellin.c -o spellin
-spellout: spellout.c
-       cc -i -O -s spellout.c -o spellout
-
-hlist: /usr/dict/words spellin
-       spellin </usr/dict/words >hlist
-hlista: american local hlist spellin
-       (cat american local)|spellin hlist >hlista
-hlistb: british local hlist spellin
-       (cat british local)|spellin hlist >hlistb
-hstop: stop spellin
-       spellin <stop >hstop
index 0ffcba4..13369c4 100644 (file)
@@ -70,8 +70,7 @@ struct suftab {
        {"evit",tion,3,"-e+ive","+ive"},
        {"ezi",CCe,3,"-e+ize","+ize"},
        {"pihs",strip,4,"","+ship"},
        {"evit",tion,3,"-e+ive","+ive"},
        {"ezi",CCe,3,"-e+ize","+ize"},
        {"pihs",strip,4,"","+ship"},
-       {"dooh",ily,4,"-y+ihood","+hood"},
-       {"luf",ily,3,"-y+iful","+ful"},
+       {"dooh",ily,4,"-y+hood","+hood"},
        {"ekil",strip,4,"","+like"},
        0
 };
        {"ekil",strip,4,"","+like"},
        0
 };
diff --git a/usr/src/cmd/spell/spell.sh b/usr/src/cmd/spell/spell.sh
new file mode 100755 (executable)
index 0000000..8a8efeb
--- /dev/null
@@ -0,0 +1,28 @@
+: B flags, D dictionary, F files, H history, S stop, V data for -v
+H=${H-/usr/dict/spellhist}
+T=/tmp/spell.$$
+V=/dev/null
+F= B=
+trap "rm -f $T*; exit" 0 1 2 13 15
+for A in $*
+do
+       case $A in
+       -v)     B="$B -v"
+               V=${T}a ;;
+       -a)     ;;
+       -b)     D=${D-/usr/dict/hlistb}
+               B="$B -b" ;;
+       *)      F="$F $A"
+       esac
+       done
+deroff -w $F |\
+  sort -u |\
+  /usr/lib/spell ${S-/usr/dict/hstop} $T |\
+  /usr/lib/spell ${D-/usr/dict/hlista} $V $B |\
+  sort -u +0f +0 - $T |\
+  tee -a $H
+who am i >>$H 2>/dev/null
+case $V in
+/dev/null)     exit
+esac
+sed '/^\./d' $V | sort -u +1f +0
index 4c77774..d49fa85 100644 (file)
@@ -45,7 +45,6 @@ avered
 averer
 avering
 avertion
 averer
 avering
 avertion
-aweful
 axises
 axly
 baned
 axises
 axly
 baned
@@ -88,11 +87,6 @@ bited
 blader
 bleeded
 blowed
 blader
 bleeded
 blowed
-bootleged
-bootleger
-bootleging
-bootstraped
-bootstraping
 breaked
 breeded
 bringed
 breaked
 breeded
 bringed
@@ -100,7 +94,6 @@ bursted
 buyed
 byly
 Canadan
 buyed
 byly
 Canadan
-carful
 Carolinan
 casted
 catched
 Carolinan
 casted
 catched
@@ -132,6 +125,7 @@ compressable
 condensable
 conducter
 coner
 condensable
 conducter
 coner
+conferable
 confered
 conferer
 confering
 confered
 conferer
 confering
@@ -176,6 +170,7 @@ decontroler
 decontroling
 deductable
 defensable
 decontroling
 deductable
 defensable
+deferable
 defered
 deferer
 defering
 defered
 deferer
 defering
@@ -198,6 +193,7 @@ depressable
 desolator
 destructer
 detecter
 desolator
 destructer
 detecter
+deterable
 detered
 deterer
 detering
 detered
 deterer
 detering
@@ -408,7 +404,6 @@ hes
 hesitator
 hily
 holded
 hesitator
 hily
 holded
-hopful
 horrable
 huggest
 huging
 horrable
 huggest
 huging
@@ -448,6 +443,7 @@ inexhaustable
 inexpressable
 infallable
 infeasable
 inexpressable
 infallable
 infeasable
+inferable
 infered
 inferer
 infering
 infered
 inferer
 infering
@@ -461,6 +457,7 @@ insensable
 inspecter
 instructer
 intence
 inspecter
 instructer
 intence
+interable
 intered
 interer
 intering
 intered
 interer
 intering
@@ -479,9 +476,6 @@ ivly
 ivs
 ixes
 ixly
 ivs
 ixes
 ixly
-jitterbuged
-jitterbuger
-jitterbuging
 juter
 keeped
 kiloohm
 juter
 keeped
 kiloohm
@@ -621,6 +615,7 @@ redu
 reem
 reen
 reet
 reem
 reen
 reet
+referable
 refered
 referer
 refering
 refered
 referer
 refering
@@ -692,8 +687,6 @@ reso
 responsable
 reti
 reto
 responsable
 reti
 reto
-retrofited
-retrofiting
 reup
 reus
 reversable
 reup
 reus
 reversable
@@ -716,9 +709,6 @@ runed
 runned
 saging
 saly
 runned
 saging
 saly
-sandbaged
-sandbager
-sandbaging
 saturator
 sayed
 sculpter
 saturator
 sayed
 sculpter
@@ -809,6 +799,7 @@ toly
 tracter
 traiter
 tranquility
 tracter
 traiter
 tranquility
+transferable
 transfered
 transferer
 transfering
 transfered
 transferer
 transfering
@@ -913,7 +904,6 @@ unwieldly
 uply
 upseter
 upseting
 uply
 upseter
 upseting
-usful
 usly
 usses
 vendable
 usly
 usses
 vendable
@@ -935,6 +925,3 @@ wringed
 writed
 xily
 yiper
 writed
 xily
 yiper
-zigzaged
-zigzager
-zigzaging
index 97ce053..00b453d 100644 (file)
@@ -182,7 +182,7 @@ spline(){
                if(i>0){
                        hi = x.val[i]-x.val[i-1];
                        corr = end?2*s+u:zero;
                if(i>0){
                        hi = x.val[i]-x.val[i-1];
                        corr = end?2*s+u:zero;
-                       D2yi = (r[i]-hi1*D2yi1-s*D2yn1+end*v)/
+                       D2yi = (end*v+r[i]-hi1*D2yi1-s*D2yn1)/
                                (diag[i]+corr);
                        if(end) D2yn1 = D2yi;
                        if(i>1){
                                (diag[i]+corr);
                        if(end) D2yn1 = D2yi;
                        if(i>1){
diff --git a/usr/src/cmd/standalone/M.s b/usr/src/cmd/standalone/M.s
deleted file mode 100644 (file)
index d96690b..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/ Startup code for two-stage bootstrap
-
-/ non-UNIX instructions
-mfpi   = 6500^tst
-stst   = 170300^tst
-mtpi   = 6600^tst
-mfpd   = 106500^tst
-mtpd   = 106600^tst
-spl    = 230
-ldfps  = 170100^tst
-stfps  = 170200^tst
-wait   = 1
-rtt    = 6
-halt   = 0
-reset  = 5
-trap   = 104400
-
-.globl _end
-.globl _main
-start:
-       reset
-       mov     $340,PS
-       mov     $140100,sp
-
-/ set kernel I+D to physical 0 and IO page
-       clr     r1
-       mov     $77406,r2
-       mov     $KISA0,r3
-       mov     $KISD0,r4
-       jsr     pc,setseg
-       mov     $IO,-(r3)
-       clr     r1
-       mov     $KDSA0,r3
-       mov     $KDSD0,r4
-       jsr     pc,setseg
-       mov     $IO,-(r3)
-
-/ set user I+D to physical 64K (words) and IO page
-       mov     $4000,r1
-       mov     $UISA0,r3
-       mov     $UISD0,r4
-       jsr     pc,setseg
-       mov     $IO,-(r3)
-       mov     $4000,r1
-       mov     $UDSA0,r3
-       mov     $UDSD0,r4
-       jsr     pc,setseg
-       mov     $IO,-(r3)
-
-/ enable map
-       mov     $65,SSR3        / 22-bit map
-       bit     $20,SSR3
-       beq     1f
-       mov     $3,MSCR
-1:
-       mov     $30340,PS
-       inc     SSR0
-
-
-/ copy program to user I space
-       mov     $_end,r0
-       asr     r0
-       clr     r1
-1:
-       mov     (r1),-(sp)
-       mtpi    (r1)+
-       sob     r0,1b
-
-
-/ continue execution in user space copy
-       mov     $140004,sp
-       clr     *$KDSA6
-       mov     $140340,-(sp)
-       mov     $user,-(sp)
-       rtt
-user:
-       mov     $_end+512.,sp
-       mov     sp,r5
-
-       jsr     pc,_main
-
-       trap
-
-       br      user
-
-setseg:
-       mov     $8,r0
-1:
-       mov     r1,(r3)+
-       add     $200,r1
-       mov     r2,(r4)+
-       sob     r0,1b
-       rts     pc
-
-.globl _setseg
-_setseg:
-       mov     2(sp),r1
-       mov     r2,-(sp)
-       mov     r3,-(sp)
-       mov     r4,-(sp)
-       mov     $77406,r2
-       mov     $KISA0,r3
-       mov     $KISD0,r4
-       jsr     pc,setseg
-       mov     (sp)+,r4
-       mov     (sp)+,r3
-       mov     (sp)+,r2
-       rts     pc
-
-/ clrseg(addr,count)
-.globl _clrseg
-_clrseg:
-       mov     4(sp),r0
-       beq     2f
-       asr     r0
-       bic     $!77777,r0
-       mov     2(sp),r1
-1:
-       clr     -(sp)
-       mtpi    (r1)+
-       sob     r0,1b
-2:
-       rts     pc
-
-
-/ mtpi(word,addr)
-.globl _mtpi
-_mtpi:
-       mov     4(sp),r0
-       mov     2(sp),-(sp)
-       mtpi    (r0)+
-       rts     pc
-
-.globl __rtt
-__rtt:
-       halt
-
-PS     = 177776
-SSR0   = 177572
-SSR1   = 177574
-SSR2   = 177576
-SSR3   = 172516
-KISA0  = 172340
-KISA1  = 172342
-KISA7  = 172356
-KISD0  = 172300
-KISD7  = 172316
-KDSA0  = 172360
-KDSA6  = 172374
-KDSA7  = 172376
-KDSD0  = 172320
-KDSD5  = 172332
-SISA0  = 172240
-SISA1  = 172242
-SISD0  = 172200
-SISD1  = 172202
-UISA0  = 177640
-UISD0  = 177600
-UDSA0  = 177660
-UDSD0  = 177620
-MSCR   = 017777746     / 11/70 memory control register
-IO     = 177600
-SWR    = 177570
-
-.data
-
diff --git a/usr/src/cmd/standalone/SYS.c b/usr/src/cmd/standalone/SYS.c
deleted file mode 100644 (file)
index b87e766..0000000
+++ /dev/null
@@ -1,474 +0,0 @@
-#include <sys/param.h>
-#include <sys/ino.h>
-#include <sys/inode.h>
-#include <sys/filsys.h>
-#include <sys/dir.h>
-#include "saio.h"
-
-int    segflag = 0;
-
-
-static
-openi(n,io)
-register struct iob *io;
-{
-       register struct dinode *dp;
-
-       io->i_offset = 0;
-       io->i_bn = (daddr_t)((n+15)/INOPB) + io->i_boff;
-       io->i_cc = 512;
-       io->i_ma = io->i_buf;
-       devread(io);
-
-       dp = io->i_buf;
-       dp = &dp[(n-1)%INOPB];
-       io->i_ino.i_number = n;
-       io->i_ino.i_mode = dp->di_mode;
-       io->i_ino.i_size = dp->di_size;
-       l3tol((char *)io->i_ino.i_un.i_addr,(char *)dp->di_addr,NADDR);
-}
-
-
-static
-find(path, file)
-register char *path;
-struct iob *file;
-{
-       register char *q;
-       char c;
-       int n;
-
-       if (path==NULL || *path=='\0') {
-               printf("null path\n");
-               return(0);
-       }
-
-       openi((ino_t) 2, file);
-       while (*path) {
-               while (*path == '/')
-                       path++;
-               q = path;
-               while(*q != '/' && *q != '\0')
-                       q++;
-               c = *q;
-               *q = '\0';
-
-               if ((n=dlook(path, file))!=0) {
-                       if (c=='\0')
-                               break;
-                       openi(n, file);
-                       *q = c;
-                       path = q;
-                       continue;
-               } else {
-                       printf("%s not found\n",path);
-                       return(0);
-               }
-       }
-       return(n);
-}
-
-
-static daddr_t
-sbmap(io, bn)
-register struct iob *io;
-daddr_t bn;
-{
-       register i;
-       register struct inode *ip;
-       int j, sh;
-       daddr_t nb, *bap;
-
-       ip = &io->i_ino;;
-       if(bn < 0) {
-               printf("bn negative\n");
-               return((daddr_t)0);
-       }
-
-       /*
-        * blocks 0..NADDR-4 are direct blocks
-        */
-       if(bn < NADDR-3) {
-               i = bn;
-               nb = ip->i_un.i_addr[i];
-               return(nb);
-       }
-
-       /*
-        * addresses NADDR-3, NADDR-2, and NADDR-1
-        * have single, double, triple indirect blocks.
-        * the first step is to determine
-        * how many levels of indirection.
-        */
-       sh = 0;
-       nb = 1;
-       bn -= NADDR-3;
-       for(j=3; j>0; j--) {
-               sh += NSHIFT;
-               nb <<= NSHIFT;
-               if(bn < nb)
-                       break;
-               bn -= nb;
-       }
-       if(j == 0) {
-               printf("bn ovf %D\n",bn);
-               return((daddr_t)0);
-       }
-
-       /*
-        * fetch the address from the inode
-        */
-       nb = ip->i_un.i_addr[NADDR-j];
-       if(nb == 0) {
-               printf("bn void %D\n",bn);
-               return((daddr_t)0);
-       }
-
-       /*
-        * fetch through the indirect blocks
-        */
-       for(; j<=3; j++) {
-               if (blknos[j] != nb) {
-                       io->i_bn = nb + io->i_boff;
-                       io->i_ma = b[j];
-                       io->i_cc = 512;
-                       devread(io);
-                       blknos[j] = nb;
-               }
-               bap = b[j];
-               sh -= NSHIFT;
-               i = (bn>>sh) & NMASK;
-               nb = bap[i];
-               if(nb == 0) {
-                       printf("bn void %D\n",bn);
-                       return((daddr_t)0);
-               }
-       }
-
-       return(nb);
-}
-
-static ino_t
-dlook(s, io)
-char *s;
-register struct iob *io;
-{
-       register struct direct *dp;
-       register struct inode *ip;
-       daddr_t bn;
-       int n,dc;
-
-       if (s==NULL || *s=='\0')
-               return(0);
-       ip = &io->i_ino;
-       if ((ip->i_mode&IFMT)!=IFDIR) {
-               printf("not a directory\n");
-               return(0);
-       }
-
-       n = ip->i_size/sizeof(struct direct);
-
-       if (n==0) {
-               printf("zero length directory\n");
-               return(0);
-       }
-
-       dc = 512;
-       bn = (daddr_t)0;
-       while(n--) {
-               if (++dc >= 512/sizeof(struct direct)) {
-                       io->i_bn = sbmap(io, bn++) + io->i_boff;
-                       io->i_ma = io->i_buf;
-                       io->i_cc = 512;
-                       devread(io);
-                       dp = io->i_buf;
-                       dc = 0;
-               }
-
-               if (match(s, dp->d_name))
-                       return(dp->d_ino);
-               dp++;
-       }
-       return(0);
-}
-
-static
-match(s1,s2)
-register char *s1,*s2;
-{
-       register cc;
-
-       cc = DIRSIZ;
-       while (cc--) {
-               if (*s1 != *s2)
-                       return(0);
-               if (*s1++ && *s2++)
-                       continue; else
-                       return(1);
-       }
-       return(1);
-}
-
-lseek(fdesc, addr, ptr)
-int    fdesc;
-off_t  addr;
-int    ptr;
-{
-       register struct iob *io;
-
-       if (ptr != 0) {
-               printf("Seek not from beginning of file\n");
-               return(-1);
-       }
-       fdesc -= 3;
-       if (fdesc < 0 || fdesc >= NFILES || ((io = &iob[fdesc])->i_flgs&F_ALLOC) == 0)
-               return(-1);
-       io->i_offset = addr;
-       io->i_bn = addr/512 + io->i_boff;
-       io->i_cc = 0;
-       return(0);
-}
-
-getc(fdesc)
-int    fdesc;
-{
-       register struct iob *io;
-       register char *p;
-       register  c;
-       int off;
-
-
-       if (fdesc >= 0 && fdesc <= 2)
-               return(getchar());
-       fdesc -= 3;
-       if (fdesc < 0 || fdesc >= NFILES || ((io = &iob[fdesc])->i_flgs&F_ALLOC) == 0)
-               return(-1);
-       p = io->i_ma;
-       if (io->i_cc <= 0) {
-               io->i_bn = io->i_offset/(off_t)512;
-               if (io->i_flgs&F_FILE)
-                       io->i_bn = sbmap(io, io->i_bn) + io->i_boff;
-               io->i_ma = io->i_buf;
-               io->i_cc = 512;
-               devread(io);
-               if (io->i_flgs&F_FILE) {
-                       off = io->i_offset % (off_t)512;
-                       if (io->i_offset+(512-off) >= io->i_ino.i_size)
-                               io->i_cc = io->i_ino.i_size - io->i_offset + off;
-                       io->i_cc -= off;
-                       if (io->i_cc <= 0)
-                               return(-1);
-               } else
-                       off = 0;
-               p = &io->i_buf[off];
-       }
-       io->i_cc--;
-       io->i_offset++;
-       c = (unsigned)*p++;
-       io->i_ma = p;
-       return(c);
-}
-getw(fdesc)
-int    fdesc;
-{
-       register w,i;
-       register char *cp;
-       int val;
-
-       for (i = 0, val = 0, cp = &val; i < sizeof(val); i++) {
-               w = getc(fdesc);
-               if (w < 0) {
-                       if (i == 0)
-                               return(-1);
-                       else
-                               return(val);
-               }
-               *cp++ = w;
-       }
-       return(val);
-}
-
-read(fdesc, buf, count)
-int    fdesc;
-char   *buf;
-int    count;
-{
-       register i;
-       register struct iob *file;
-
-       if (fdesc >= 0 & fdesc <= 2) {
-               i = count;
-               do {
-                       *buf = getchar();
-               } while (--i && *buf++ != '\n');
-               return(count - i);
-       }
-       fdesc -= 3;
-       if (fdesc < 0 || fdesc >= NFILES || ((file = &iob[fdesc])->i_flgs&F_ALLOC) == 0)
-               return(-1);
-       if ((file->i_flgs&F_READ) == 0)
-               return(-1);
-       if ((file->i_flgs&F_FILE) == 0) {
-               file->i_cc = count;
-               file->i_ma = buf;
-               i = devread(file);
-               file->i_bn++;
-               return(i);
-       }
-       else {
-               if (file->i_offset+count > file->i_ino.i_size)
-                       count = file->i_ino.i_size - file->i_offset;
-               if ((i = count) <= 0)
-                       return(0);
-               do {
-                       *buf++ = getc(fdesc+3);
-               } while (--i);
-               return(count);
-       }
-}
-
-write(fdesc, buf, count)
-int    fdesc;
-char   *buf;
-int    count;
-{
-       register i;
-       register struct iob *file;
-
-       if (fdesc >= 0 && fdesc <= 2) {
-               i = count;
-               while (i--)
-                       putchar(*buf++);
-               return(count);
-       }
-       fdesc -= 3;
-       if (fdesc < 0 || fdesc >= NFILES || ((file = &iob[fdesc])->i_flgs&F_ALLOC) == 0)
-               return(-1);
-       if ((file->i_flgs&F_WRITE) == 0)
-               return(-1);
-       file->i_cc = count;
-       file->i_ma = buf;
-       i = devwrite(file);
-       file->i_bn++;
-       return(i);
-}
-
-open(str, how)
-char *str;
-int    how;
-{
-       register char *cp;
-       int i;
-       register struct iob *file;
-       register struct devsw *dp;
-       int     fdesc;
-       static first = 1;
-       long    atol();
-
-       if (first) {
-               for (i = 0; i < NFILES; i++)
-                       iob[i].i_flgs = 0;
-               first = 0;
-       }
-
-       for (fdesc = 0; fdesc < NFILES; fdesc++)
-               if (iob[fdesc].i_flgs == 0)
-                       goto gotfile;
-       _stop("No more file slots");
-gotfile:
-       (file = &iob[fdesc])->i_flgs |= F_ALLOC;
-
-       for (cp = str; *cp && *cp != '('; cp++)
-                       ;
-       if (*cp != '(') {
-               printf("Bad device\n");
-               file->i_flgs = 0;
-               return(-1);
-       }
-       *cp++ = '\0';
-       for (dp = devsw; dp->dv_name; dp++) {
-               if (match(str, dp->dv_name))
-                       goto gotdev;
-       }
-       printf("Unknown device\n");
-       file->i_flgs = 0;
-       return(-1);
-gotdev:
-       *(cp-1) = '(';
-       file->i_ino.i_dev = dp-devsw;
-       file->i_unit = *cp++ - '0';
-       if (file->i_unit < 0 || file->i_unit > 7) {
-               printf("Bad unit specifier\n");
-               file->i_flgs = 0;
-               return(-1);
-       }
-       if (*cp++ != ',') {
-badoff:
-               printf("Missing offset specification\n");
-               file->i_flgs = 0;
-               return(-1);
-       }
-       file->i_boff = atol(cp);
-       for (;;) {
-               if (*cp == ')')
-                       break;
-               if (*cp++)
-                       continue;
-               goto badoff;
-       }
-       devopen(file);
-       if (*++cp == '\0') {
-               file->i_flgs |= how+1;
-               file->i_cc = 0;
-               file->i_offset = 0;
-               return(fdesc+3);
-       }
-       if ((i = find(cp, file)) == 0) {
-               file->i_flgs = 0;
-               return(-1);
-       }
-       if (how != 0) {
-               printf("Can't write files yet.. Sorry\n");
-               file->i_flgs = 0;
-               return(-1);
-       }
-       openi(i, file);
-       file->i_offset = 0;
-       file->i_cc = 0;
-       file->i_flgs |= F_FILE | (how+1);
-       return(fdesc+3);
-}
-
-close(fdesc)
-int    fdesc;
-{
-       struct iob *file;
-
-       fdesc -= 3;
-       if (fdesc < 0 || fdesc >= NFILES || ((file = &iob[fdesc])->i_flgs&F_ALLOC) == 0)
-               return(-1);
-       if ((file->i_flgs&F_FILE) == 0)
-               devclose(file);
-       file->i_flgs = 0;
-       return(0);
-}
-
-exit()
-{
-       _stop("Exit called");
-}
-
-_stop(s)
-char   *s;
-{
-       printf("%s\n", s);
-       _rtt();
-}
-
-trap(ps)
-int ps;
-{
-       printf("Trap %o\n", ps);
-       for (;;)
-               ;
-}
diff --git a/usr/src/cmd/standalone/boot.c b/usr/src/cmd/standalone/boot.c
deleted file mode 100644 (file)
index 18465d0..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-#include <sys/param.h>
-#include <sys/ino.h>
-#include <sys/inode.h>
-#include <sys/filsys.h>
-#include <sys/dir.h>
-#include <saio.h>
-
-
-char line[100];
-
-main()
-{
-int i;
-       segflag = 2;
-
-
-       printf("Boot\n");
-       do {
-               printf(": "); gets(line);
-               i = open(line,0);
-       } while (i < 0);
-
-
-       copyunix(i);
-
-}
-
-
-copyunix(io)
-register io;
-{
-register addr,s;
-long phys;
-unsigned       txtsiz,datsiz,bsssiz;
-int    magic;
-
-
-       lseek(io, (off_t)0, 0);
-       magic = getw(io);
-       txtsiz = getw(io);
-       datsiz = getw(io);
-       bsssiz = getw(io);
-
-
-       switch (magic) {
-       case 0411:
-               setseg(0);
-               lseek(io, (long)(020+txtsiz), 0);
-
-               for(addr=0; addr!=datsiz; addr+=2)  {
-                       mtpi(getw(io),addr);
-               }
-
-               clrseg(addr,bsssiz);
-
-               phys = (long)datsiz + (long)bsssiz + 63L;
-               phys =/ 64;
-               setseg((int)phys);
-
-               lseek(io, 020L, 0);
-
-               for(addr=0; addr!=txtsiz; addr+=2) {
-                       mtpi(getw(io),addr);
-               }
-               return;
-       case 0407:
-               setseg(0);
-               /*
-                * space over the header. We do this instead of seeking
-                * because the input might be a tape which doesn't know 
-                * how to seek.
-                */
-               getw(io); getw(io); getw(io); getw(io);
-               phys = txtsiz+datsiz;
-               for (addr = 0; addr != phys; addr += 2)
-                       mtpi(getw(io),addr);
-               clrseg(addr, bsssiz);
-               return;
-       default:
-               printf("Can't load %o files\n", magic);
-               exit(1);
-       }
-}
diff --git a/usr/src/cmd/standalone/cat.c b/usr/src/cmd/standalone/cat.c
deleted file mode 100644 (file)
index cf69e62..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-main()
-{
-       int c, i;
-       char buf[50];
-
-       do {
-               printf("File: ");
-               gets(buf);
-               i = open(buf, 0);
-       } while (i <= 0);
-
-       while ((c = getc(i)) > 0)
-               putchar(c);
-       exit(0);
-}
diff --git a/usr/src/cmd/standalone/cc+ld-stand b/usr/src/cmd/standalone/cc+ld-stand
deleted file mode 100755 (executable)
index 2e71701..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-cc -c -O -DSTANDALONE ../$1.c
-ld -s -o $1 srt0.o $1.o -lsa -lc
-rm $1.o
diff --git a/usr/src/cmd/standalone/conf.c b/usr/src/cmd/standalone/conf.c
deleted file mode 100644 (file)
index 1d180dc..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <sys/param.h>
-#include <sys/inode.h>
-#include "saio.h"
-
-devread(io)
-register struct iob *io;
-{
-
-       return( (*devsw[io->i_ino.i_dev].dv_strategy)(io,READ) );
-}
-
-devwrite(io)
-register struct iob *io;
-{
-       return( (*devsw[io->i_ino.i_dev].dv_strategy)(io, WRITE) );
-}
-
-devopen(io)
-register struct iob *io;
-{
-       (*devsw[io->i_ino.i_dev].dv_open)(io);
-}
-
-devclose(io)
-register struct iob *io;
-{
-       (*devsw[io->i_ino.i_dev].dv_close)(io);
-}
-
-nullsys()
-{ ; }
-
-int rpstrategy();
-int rkstrategy();
-int    nullsys();
-int    tmstrategy(), tmrew(), tmopen();
-int    htstrategy(), htopen(),htclose();
-int    hpstrategy();
-struct devsw devsw[] {
-       "rp",   rpstrategy,     nullsys,        nullsys,
-       "hp",   hpstrategy,     nullsys,        nullsys,
-       "rk",   rkstrategy,     nullsys,        nullsys,
-       "tm",   tmstrategy,     tmopen,         tmrew,
-       "ht",   htstrategy,     htopen,         htclose,
-       0,0,0,0
-};
diff --git a/usr/src/cmd/standalone/contents b/usr/src/cmd/standalone/contents
deleted file mode 100644 (file)
index 9a1b305..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-File 1:
-       2 copies of magtape bootstrap (2 blocks total)
-       The standalone bootstrap
-File 2:
-       A file to console copy program
-File 3:
-       This file
-File 4:
-       The program mkfs
-File 5:
-       The program restor
-File 6:
-       A dump of rp0
-File 7:
-       A dump of rp3
diff --git a/usr/src/cmd/standalone/cpgroup b/usr/src/cmd/standalone/cpgroup
deleted file mode 100755 (executable)
index 97ed6ff..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-/etc/mkfs /dev/rrk2 4000
-/etc/mount /dev/rk2 /x
-dir=$1
-shift
-cd /x
-(cd $dir; tar cf - $*) | tar xf -
-cd /
-/etc/umount /dev/rk2
diff --git a/usr/src/cmd/standalone/hp.c b/usr/src/cmd/standalone/hp.c
deleted file mode 100644 (file)
index 67aefa6..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * RP04/RP06 disk driver
- */
-
-#include <sys/param.h>
-#include <sys/inode.h>
-#include "saio.h"
-
-struct device
-{
-       union {
-               int     w;
-               char    c[2];
-       } hpcs1;                /* Control and Status register 1 */
-       int     hpwc;           /* Word count register */
-       caddr_t hpba;           /* UNIBUS address register */
-       int     hpda;           /* Desired address register */
-       union {
-               int     w;
-               char    c[2];
-       } hpcs2;                /* Control and Status register 2*/
-       int     hpds;           /* Drive Status */
-       int     hper1;          /* Error register 1 */
-       int     hpas;           /* Attention Summary */
-       int     hpla;           /* Look ahead */
-       int     hpdb;           /* Data buffer */
-       int     hpmr;           /* Maintenance register */
-       int     hpdt;           /* Drive type */
-       int     hpsn;           /* Serial number */
-       int     hpof;           /* Offset register */
-       int     hpdc;           /* Desired Cylinder address register*/
-       int     hpcc;           /* Current Cylinder */
-       int     hper2;          /* Error register 2 */
-       int     hper3;          /* Error register 3 */
-       int     hpec1;          /* Burst error bit position */
-       int     hpec2;          /* Burst error bit pattern */
-       int     hpbae;          /* 11/70 bus extension */
-       int     hpcs3;
-};
-
-#define        HPADDR  ((struct device *)0176700)
-#define        NSECT   22
-#define        NTRAC   19
-#define        SDIST   2
-#define        RDIST   6
-
-#define        P400    020
-#define        M400    0220
-#define        P800    040
-#define        M800    0240
-#define        P1200   060
-#define        M1200   0260
-
-#define        GO      01
-#define        PRESET  020
-#define        RTC     016
-#define        OFFSET  014
-#define        SEARCH  030
-#define        RECAL   06
-#define DCLR   010
-#define        WCOM    060
-#define        RCOM    070
-
-#define        IE      0100
-#define        PIP     020000
-#define        DRY     0200
-#define        ERR     040000
-#define        TRE     040000
-#define        DCK     0100000
-#define        WLE     04000
-#define        ECH     0100
-#define VV     0100
-#define FMT22  010000
-
-hpstrategy(io, func)
-register struct iob *io;
-{
-       register unit;
-       register i;
-       daddr_t bn;
-       int sn, cn, tn;
-
-       if (((unit = io->i_unit) & 04) == 0)
-               bn = io->i_bn;
-       else {
-               unit &= 03;
-               bn = io->i_bn;
-               bn -= io->i_boff;
-               i = unit + 1;
-               unit = bn%i;
-               bn /= i;
-               bn += io->i_boff;
-       }
-
-       HPADDR->hpcs2.w = unit;
-
-       if((HPADDR->hpds & VV) == 0) {
-               HPADDR->hpcs1.c[0] = PRESET|GO;
-               HPADDR->hpof = FMT22;
-       }
-       cn = bn/(NSECT*NTRAC);
-       sn = bn%(NSECT*NTRAC);
-       tn = sn/NSECT;
-       sn = sn%NSECT;
-
-       HPADDR->hpdc = cn;
-       HPADDR->hpda = (tn << 8) + sn;
-       HPADDR->hpba = io->i_ma;
-       HPADDR->hpwc = -(io->i_cc>>1);
-       unit = (segflag << 8) | GO;
-       if (func == READ)
-               unit |= RCOM;
-       else if (func == WRITE)
-               unit |= WCOM;
-       HPADDR->hpcs1.w = unit;
-       while ((HPADDR->hpcs1.w&DRY) == 0)
-                       ;
-       if (HPADDR->hpcs1.w & TRE) {
-               printf("disk error: cyl=%d track=%d sect=%d cs2=%o, er1=%o\n",
-                   cn, tn, sn, HPADDR->hpcs2, HPADDR->hper1);
-               return(-1);
-       }
-       return(io->i_cc);
-}
diff --git a/usr/src/cmd/standalone/ht.c b/usr/src/cmd/standalone/ht.c
deleted file mode 100644 (file)
index 2fe9592..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * TJU16 tape driver
- */
-
-#include <sys/param.h>
-#include <sys/inode.h>
-#include "saio.h"
-
-struct device
-{
-       int     htcs1;
-       int     htwc;
-       caddr_t htba;
-       int     htfc;
-       int     htcs2;
-       int     htds;
-       int     hter;
-       int     htas;
-       int     htck;
-       int     htdb;
-       int     htmr;
-       int     htdt;
-       int     htsn;
-       int     httc;
-       int     htbae;  /* 11/70 bus extension */
-       int     htcs3;
-};
-
-
-
-#define        HTADDR  ((struct device *)0172440)
-
-#define        GO      01
-#define        WCOM    060
-#define        RCOM    070
-#define        NOP     0
-#define        WEOF    026
-#define        SFORW   030
-#define        SREV    032
-#define        ERASE   024
-#define        REW     06
-#define        DCLR    010
-#define CLR    040
-#define P800   01300           /* 800 + pdp11 mode */
-#define        P1600   02300           /* 1600 + pdp11 mode */
-#define        IENABLE 0100
-#define        RDY     0200
-#define        TM      04
-#define        DRY     0200
-#define EOT    02000
-#define CS     02000
-#define COR    0100000
-#define PES    040
-#define WRL    04000
-#define MOL    010000
-#define PIP    020000
-#define ERR    040000
-#define FCE    01000
-#define        TRE     040000
-#define HARD   064023  /* UNS|OPI|NEF|FMT|RMR|ILR|ILF */
-
-#define        SIO     1
-#define        SSFOR   2
-#define        SSREV   3
-#define SRETRY 4
-#define SCOM   5
-#define SOK    6
-
-htopen(io)
-register struct iob *io;
-{
-       register skip;
-int i;
-
-       htstrategy(io, REW);
-       skip = io->i_boff;
-       while (skip--) {
-               io->i_cc = -1;
-               while (htstrategy(io, SFORW))
-                       ;
-               i = 0;
-               while (--i)
-                       ;
-               htstrategy(io, NOP);
-       }
-}
-
-htclose(io)
-register struct iob *io;
-{
-       htstrategy(io, REW);
-}
-
-htstrategy(io, func)
-register struct iob *io;
-{
-       register unit, den, errcnt;
-
-       unit = io->i_unit;
-       errcnt = 0;
-retry:
-       HTADDR->htcs2 = unit&03;
-       if(unit > 3)
-               den = P1600;
-       else
-               den = P800;
-       htquiet();
-       if((HTADDR->httc&03777) != den)
-               HTADDR->httc = den;
-       HTADDR->htba = io->i_ma;
-       HTADDR->htfc = -io->i_cc;
-       HTADDR->htwc = -(io->i_cc>>1);
-       den = ((segflag) << 8) | GO;
-       if (func == READ)
-               den =| RCOM;
-       else if (func == WRITE)
-               den =| WCOM;
-       else if (func == SREV) {
-               HTADDR->htfc = -1;
-               HTADDR->htcs1 = den | SREV;
-               return(0);
-       } else
-               den |= func;
-       HTADDR->htcs1 = den;
-       while ((HTADDR->htcs1&RDY) == 0)
-               ;
-       if (HTADDR->htds&TM) {
-               htinit();
-               return(0);
-       }
-       if (HTADDR->htcs1&TRE) {
-               if (errcnt == 0)
-                       printf("tape error: cs2=%o, er=%o",
-                           HTADDR->htcs2, HTADDR->hter);
-               htinit();
-               if (errcnt == 10) {
-                       printf("\n");
-                       return(-1);
-               }
-               errcnt++;
-               htstrategy(io, SREV);
-               goto retry;
-       }
-       if (errcnt)
-               printf(" recovered by retry\n");
-       return(io->i_cc+HTADDR->htfc);
-}
-
-htinit()
-{
-       int omt, ocs2;
-
-       omt = HTADDR->httc & 03777;
-       ocs2 = HTADDR->htcs2 & 07;
-
-       HTADDR->htcs2 = CLR;
-       HTADDR->htcs2 = ocs2;
-       HTADDR->httc = omt;
-       HTADDR->htcs1 = DCLR|GO;
-}
-
-htquiet()
-{
-       while ((HTADDR->htcs1&RDY) == 0)
-               ;
-       while (HTADDR->htds&PIP)
-               ;
-}
diff --git a/usr/src/cmd/standalone/makefile b/usr/src/cmd/standalone/makefile
deleted file mode 100644 (file)
index 7f81b28..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-CFLAGS = -O
-
-all:   /usr/lib/libsa.a srt0.o restor cat icheck mkfs mtboot maketape boot
-
-cp cmp:
-       @echo "standalone stuff-- examine this makefile before running"
-
-xcp:   all
-       mkdir /stand
-       cp restor cat mkfs icheck /stand
-       rm restor cat mkfs icheck
-       cp boot /
-       rm boot
-       rm *.o
-
-/usr/lib/libsa.a:      SYS.o conf.o hp.o ht.o prf.o rk.o rp.o tm.o 
-       ar rv /usr/lib/libsa.a $?
-
-restor:        srt0.o
-       cc+ld-stand restor
-
-cat:   srt0.o
-       cc -c cat.c
-       ld -s -o cat srt0.o cat.o -lsa -lc
-       rm cat.o
-
-mkfs:  srt0.o
-       cc+ld-stand mkfs
-
-icheck:        srt0.o
-       cc+ld-stand icheck
-
-mtboot:        mtboot.s
-       as -o mtboot mtboot.s
-       strip mtboot
-
-maketape:      maketape.c
-       cc -o maketape maketape.c
-
-boot:  boot.o M.o
-       ld -s -o boot M.o boot.o -lsa -lc
-
-distr: restor cat mkfs boot mtboot maketape
-       maketape /dev/nrmt0 tapedir
-       dump 0f /dev/nrmt0 /dev/rp11
-       dump 0f /dev/rmt0 /dev/rp13
-
-rkdistr:       restor cat mkfs boot mtboot maketape
-       maketape /dev/nrmt0 rktapedir
-       mv /v7/rp*unix /v7/hp*unix /v7/usr
-       dump 0f /dev/nrmt0 /dev/rp11
-       mv /v7/usr/*unix /v7
-       cpgroup /v7/usr/src/cmd `cd /v7/usr/src/cmd; echo [a-m]*`
-       dump 0f /dev/nrmt0 /dev/rrk2
-       cpgroup /v7/usr/src/cmd `cd /v7/usr/src/cmd; echo [n-z]*`
-       dump 0f /dev/nrmt0 /dev/rrk2
-       cpgroup /v7/usr/src `cd /v7/usr/src/; echo [d-z]*`
-       dump 0f /dev/nrmt0 /dev/rrk2
-       cpgroup /v7/usr lib dmr games include mdec pub spool tmp
-       dump 0f /dev/nrmt0 /dev/rrk2
-       cpgroup /v7/usr doc
-       dump 0f /dev/nrmt0 /dev/rrk2
-       cpgroup /v7/usr dict sys man
-       dump 0f /dev/rmt0 /dev/rrk2
diff --git a/usr/src/cmd/standalone/maketape.c b/usr/src/cmd/standalone/maketape.c
deleted file mode 100644 (file)
index 3edcb19..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-#include <stdio.h>
-#define MAXB 30
-int mt;
-int fd;
-char   buf[MAXB*512];
-char   name[50];
-int    blksz;
-
-main(argc, argv)
-int    argc;
-char   *argv[];
-{
-       int i, j, k;
-       FILE *mf;
-
-       if (argc != 3) {
-               fprintf(stderr, "Usage: maketape tapedrive makefile\n");
-               exit(0);
-       }
-       if ((mt = creat(argv[1], 0666)) < 0) {
-               perror(argv[1]);
-               exit(1);
-       }
-       if ((mf = fopen(argv[2], "r")) == NULL) {
-               perror(argv[2]);
-               exit(2);
-       }
-
-       j = 0;
-       k = 0;
-       for (;;) {
-               if ((i = fscanf(mf, "%s %d", name, &blksz))== EOF)
-                       exit(0);
-               if (i != 2) {
-                       fprintf(stderr, "Help! Scanf didn't read 2 things (%d)\n", i);
-                       exit(1);
-               }
-               if (blksz <= 0 || blksz > MAXB) {
-                       fprintf(stderr, "Block size %d is invalid\n", blksz);
-                       continue;
-               }
-               if (strcmp(name, "*") == 0) {
-                       close(mt);
-                       mt = open(argv[1], 2);
-                       j = 0;
-                       k++;
-                       continue;
-               }
-               fd = open(name, 0);
-               if (fd < 0) {
-                       perror(name);
-                       continue;
-               }
-               printf("%s: block %d, file %d\n", name, j, k);
-               while (read(fd, buf, 512*blksz) > 0) {
-                       j++;
-                       write(mt, buf, 512*blksz);
-               }
-       }
-}
diff --git a/usr/src/cmd/standalone/mtboot.s b/usr/src/cmd/standalone/mtboot.s
deleted file mode 100644 (file)
index 73ba563..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-/ tape boot program to load and transfer
-/ the next item on the tape.
-
-/ entry is made by jsr pc,*$0
-/ so return can be rts pc
-
-core = 24.
-halt=0
-.. = [core*2048.]-512.
-start:
-       mov     $..,sp
-       mov     sp,r1
-       cmp     pc,r1
-       bhis    2f
-       clr     r0
-       cmp     (r0),$407
-       bne     1f
-       mov     $20,r0
-1:
-       mov     (r0)+,(r1)+
-       cmp     r1,$core*2048.
-       blo     1b
-       jmp     (sp)
-
-2:
-       mov     $1f,*$4
-       mov     $340,*$6
-       tst     *$htcs1
-       mov     $htrew,rew
-       mov     $htread,tread
-       br      2f
-1:
-       mov     $tmread,tread
-       mov     $tmrew,rew
-2:
-       jsr     pc,*rew
-       mov     $2,tapa
-       mov     $-256.,wc
-       jsr     pc,*tread
-
-       mov     *$2,r0
-       add     *$4,r0
-       sub     $512.,r0
-       asr     r0
-       neg     r0
-       bge     1f
-
-       mov     r0,wc
-       mov     $3,tapa
-       mov     $512.,ba
-       jsr     pc,*tread
-1:
-       jsr     pc,*rew
-       clr     r0
-       mov     $20,r1
-       mov     sp,r4
-       clc
-       ror     r4
-1:
-       mov     (r1)+,(r0)+
-       sob     r4,1b
-       jsr     pc,*$0
-       br      .
-
-htcs1 = 172440
-htba  = 172444
-htfc  = 172446
-htcs2 = 172450
-htds  = 172452
-httc  = 172472
-
-P800 = 1300
-P1600 = 2300
-PIP = 20000
-RESET = 40
-MOL = 10000
-ERR = 40000
-REV = 33
-READ = 71
-REW = 7
-
-htread:
-1:
-       mov     ba,mtma
-       cmp     mtapa,tapa
-       beq     1f
-       bhi     2f
-       jsr     pc,hrrec
-       br      1b
-2:
-       jsr     pc,htrew
-       br      1b
-1:
-       mov     wc,r1
-1:
-       jsr     pc,hrrec
-       add     $256.,r1
-       bmi     1b
-       rts     pc
-
-hrrec:
-       mov     $htds,r0
-       tstb    (r0)
-       bpl     hrrec
-       bit     $PIP,(r0)
-       bne     hrrec
-       bit     $MOL,(r0)
-       beq     hrrec
-       mov     $htfc,r0
-       mov     $-512.,(r0)
-       mov     mtma,-(r0)
-       mov     $-256.,-(r0)
-       mov     $READ,-(r0)
-1:
-       tstb    (r0)
-       bpl     1b
-       bit     $ERR,(r0)
-       bpl     1f
-       mov     $RESET,*$htcs2
-       mov     $-1,*$htfc
-       mov     $REV,(r0)
-       br      hrrec
-1:
-       add     $512.,mtma
-       inc     mtapa
-       rts     pc
-
-htrew:
-       mov     $RESET,*$htcs2
-       mov     $P800,*$httc
-       mov     $REW,*$htcs1
-       clr     mtapa
-       rts     pc
-
-
-mts = 172520
-mtc = 172522
-mtbrc = 172524
-mtcma = 172526
-
-tmread:
-1:
-       mov     ba,mtma
-       cmp     mtapa,tapa
-       beq     1f
-       bhi     2f
-       jsr     pc,tmrrec
-       br      1b
-2:
-       jsr     pc,tmrew
-       br      1b
-1:
-       mov     wc,r1
-1:
-       jsr     pc,tmrrec
-       add     $256.,r1
-       bmi     1b
-       rts     pc
-
-tmrrec:
-       mov     $mts,r0
-       bit     $2,(r0)+                / rewind status
-       bne     tmrrec
-       tstb    (r0)+           / cu ready
-       bpl     tmrrec
-       inc     r0
-       mov     $-512.,(r0)+    / byte count
-       mov     mtma,(r0)       / bus address
-       mov     $mtc,r0
-       mov     $60003,(r0)             / read 800bpi
-1:
-       tstb    (r0)
-       bpl     1b
-       tst     (r0)+
-       bpl     1f
-       mov     $-1,(r0)
-       mov     $60013,-(r0)            / backspace
-       br      tmrrec
-1:
-       add     $512.,mtma
-       inc     mtapa
-       rts     pc
-
-tmrew:
-       mov     $60017,*$mtc
-       clr     mtapa
-       rts     pc
-
-mtapa: 0
-mtma:  0
-tapa:  0
-wc:    0
-ba:    0
-rew:   0
-tread: 0
diff --git a/usr/src/cmd/standalone/prf.c b/usr/src/cmd/standalone/prf.c
deleted file mode 100644 (file)
index ab6ce27..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-
-/*
- * Scaled down version of C Library printf.
- * Only %s %u %d (==%u) %o %x %D are recognized.
- * Used to print diagnostic information
- * directly on console tty.
- * Since it is not interrupt driven,
- * all system activities are pretty much
- * suspended.
- * Printf should not be used for chit-chat.
- */
-printf(fmt, x1)
-register char *fmt;
-unsigned x1;
-{
-       register c;
-       register unsigned int *adx;
-       char *s;
-
-       adx = &x1;
-loop:
-       while((c = *fmt++) != '%') {
-               if(c == '\0')
-                       return;
-               putchar(c);
-       }
-       c = *fmt++;
-       if(c == 'd' || c == 'u' || c == 'o' || c == 'x')
-               printn((long)*adx, c=='o'? 8: (c=='x'? 16:10));
-       else if(c == 's') {
-               s = (char *)*adx;
-               while(c = *s++)
-                       putchar(c);
-       } else if (c == 'D') {
-               printn(*(long *)adx, 10);
-               adx += (sizeof(long) / sizeof(int)) - 1;
-       } else if (c == 'c')
-               putchar((char *)*adx);
-       adx++;
-       goto loop;
-}
-
-/*
- * Print an unsigned integer in base b.
- */
-printn(n, b)
-long n;
-{
-       register long a;
-
-       if (n<0) {      /* shouldn't happen */
-               putchar('-');
-               n = -n;
-       }
-       if(a = n/b)
-               printn(a, b);
-       putchar("0123456789ABCDEF"[(int)(n%b)]);
-}
-
-
-
-struct device  {
-       int     rcsr,rbuf;
-       int     tcsr,tbuf;
-};
-struct device  *KLADDR {0177560};
-putchar(c)
-register c;
-{
-       register s;
-       register unsigned timo;
-
-       /*
-        *  If last char was a break or null, don't print
-       if ((KLADDR->rbuf&0177) == 0)
-               return;
-       */
-       timo = 60000;
-       /*
-        * Try waiting for the console tty to come ready,
-        * otherwise give up after a reasonable time.
-        */
-       while((KLADDR->tcsr&0200) == 0)
-               if(--timo == 0)
-                       break;
-       if(c == 0)
-               return;
-       s = KLADDR->tcsr;
-       KLADDR->tcsr = 0;
-       KLADDR->tbuf = c;
-       if(c == '\n') {
-               putchar('\r');
-               putchar(0177);
-               putchar(0177);
-       }
-       putchar(0);
-       KLADDR->tcsr = s;
-}
-
-getchar()
-{
-       register c;
-
-       KLADDR->rcsr = 1;
-       while((KLADDR->rcsr&0200)==0);
-       c = KLADDR->rbuf&0177;
-       if (c=='\r')
-               c = '\n';
-       putchar(c);
-       return(c);
-}
-
-gets(buf)
-char   *buf;
-{
-register char *lp;
-register c;
-
-       lp = buf;
-       for (;;) {
-               c = getchar() & 0177;
-               if (c>='A' && c<='Z')
-                       c -= 'A' - 'a';
-               if (lp != buf && *(lp-1) == '\\') {
-                       lp--;
-                       if (c>='a' && c<='z') {
-                               c += 'A' - 'a';
-                               goto store;
-                       }
-                       switch ( c) {
-                       case '(':
-                               c = '{';
-                               break;
-                       case ')':
-                               c = '}';
-                               break;
-                       case '!':
-                               c = '|';
-                               break;
-                       case '^':
-                               c = '~';
-                               break;
-                       case '\'':
-                               c = '`';
-                               break;
-                       }
-               }
-       store:
-               switch(c) {
-               case '\n':
-               case '\r':
-                       c = '\n';
-                       *lp++ = '\0';
-                       return;
-               case '\b':
-               case '#':
-                       lp--;
-                       if (lp < buf)
-                               lp = buf;
-                       continue;
-               case '@':
-                       lp = buf;
-                       putchar('\n');
-                       continue;
-               default:
-                       *lp++ = c;
-               }
-       }
-}
diff --git a/usr/src/cmd/standalone/rk.c b/usr/src/cmd/standalone/rk.c
deleted file mode 100644 (file)
index e011c11..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * RK disk driver
- */
-
-#include <sys/param.h>
-#include <sys/inode.h>
-#include "saio.h"
-
-#define        RKADDR  ((struct device *)0177400)
-#define        NRK     4
-#define        NRKBLK  4872
-
-#define        RESET   0
-#define        WCOM    2
-#define        RCOM    4
-#define        GO      01
-#define        DRESET  014
-#define        IENABLE 0100
-#define        DRY     0200
-#define        ARDY    0100
-#define        WLO     020000
-#define        CTLRDY  0200
-
-struct device
-{
-       int     rkds;
-       int     rker;
-       int     rkcs;
-       int     rkwc;
-       caddr_t rkba;
-       int     rkda;
-};
-
-rkstrategy(io, func)
-register struct iob *io;
-{
-       register com;
-       daddr_t bn;
-       int dn, cn, sn;
-
-       bn = io->i_bn;
-       dn = io->i_unit;
-       cn = bn/12;
-       sn = bn%12;
-       RKADDR->rkda = (dn<<13) | (cn<<4) | sn;
-       RKADDR->rkba = io->i_ma;
-       RKADDR->rkwc = -(io->i_cc>>1);
-       com = (segflag<<4)|GO;
-       if (func == READ)
-               com |= RCOM; else
-               com |= WCOM;
-       RKADDR->rkcs = com;
-       while ((RKADDR->rkcs&CTLRDY) == 0)
-               ;
-       if (RKADDR->rkcs<0) {   /* error bit */
-               printf("disk error: cyl=%d, sector=%d, er=%o, ds=%o\n",
-                   cn, sn, RKADDR->rker, RKADDR->rkds);
-               return(-1);
-       }
-       return(io->i_cc);
-}
diff --git a/usr/src/cmd/standalone/rkcontents b/usr/src/cmd/standalone/rkcontents
deleted file mode 100644 (file)
index bc96b4e..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-File 1:
-       2 copies of magtape bootstrap (2 blocks total)
-       The standalone bootstrap
-File 2:
-       A file to console copy program
-File 3:
-       This file
-File 4:
-       The program mkfs
-File 5:
-       The program restor
-File 6:
-       A dump of rk0
-File 7:
-       A dump of all commands that live in subdirectories
-       of /usr/src/cmd
-File 8:
-       A dump of the rest of /usr/src/cmd
-File 9:
-       A dump of the rest of /usr/src
-File 10:
-       A dump of /usr excepting src, doc, man, dict, and sys.
-File 11:
-       A dump of /usr/doc
-File 12:
-       A dump of /usr/man, /usr/dict, and /usr/sys.
-       /usr/sys/ is the system source.
diff --git a/usr/src/cmd/standalone/rktapedir b/usr/src/cmd/standalone/rktapedir
deleted file mode 100644 (file)
index 7a9dc44..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-mtboot 1
-mtboot 1
-boot 1
-* 1
-cat 1
-* 1
-rkcontents 1
-* 1
-mkfs 1
-* 1
-restor 1
diff --git a/usr/src/cmd/standalone/rp.c b/usr/src/cmd/standalone/rp.c
deleted file mode 100644 (file)
index d811a2b..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-#
-/*
- * rp03 disk driver
- */
-
-#include <sys/param.h>
-#include <sys/inode.h>
-#include "saio.h"
-
-struct device {
-       int     rpds;
-       int     rper;
-       union {
-               int     w;
-               char    c;
-       } rpcs;
-       int     rpwc;
-       char    *rpba;
-       int     rpca;
-       int     rpda;
-};
-
-#define RPADDR ((struct device *) 0176710)
-
-#define        GO      01
-#define        DONE    0200
-#define        RESET   0
-#define        HSEEK   014
-
-#define        IENABLE 0100
-#define        READY   0200
-#define        RCOM    4
-#define        WCOM    2
-
-#define        SUFU    01000
-#define        SUSU    02000
-#define        SUSI    04000
-#define        HNF     010000
-
-
-
-rpstrategy(io, func)
-register struct iob *io;
-{
-       int com,cn,tn,sn;
-
-
-/*
-       dn = unit>>3;
-       bn = bp->b_blkno;
-       cn = bn/(20*10) + rp_sizes[unit&07].cyloff;
-*/
-       cn = io->i_bn/(20*10);
-       sn = io->i_bn%(20*10);
-       tn = sn/10;
-       sn = sn%10;
-       RPADDR->rpcs.w = (io->i_unit<<8);
-       RPADDR->rpda = (tn<<8) | sn;
-       RPADDR->rpca = cn;
-       RPADDR->rpba = io->i_ma;
-       RPADDR->rpwc = -(io->i_cc>>1);
-       com = (segflag<<4)|GO;
-       if (func == READ)
-               com |= RCOM; else
-               com |= WCOM;
-       
-       RPADDR->rpcs.w |= com;
-       while ((RPADDR->rpcs.w&DONE)==0)
-               ;
-       if (RPADDR->rpcs.w < 0) {       /* error bit */
-               printf("disk error: cyl=%d track=%d sect=%d er=%o ds=%o\n",
-                   cn, tn, sn, RPADDR->rper, RPADDR->rpds);
-               return(-1);
-       }
-       return(io->i_cc);
-}
diff --git a/usr/src/cmd/standalone/saio.h b/usr/src/cmd/standalone/saio.h
deleted file mode 100644 (file)
index fc074fc..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * header file for standalone package
- */
-
-/*
- * io block: includes an
- * inode, cells for the use of seek, etc,
- * and a buffer.
- */
-struct iob {
-       char    i_flgs;
-       struct inode i_ino;
-       int i_unit;
-       daddr_t i_boff;
-       daddr_t i_cyloff;
-       off_t   i_offset;
-       daddr_t i_bn;
-       char    *i_ma;
-       int     i_cc;
-       char    i_buf[512];
-};
-
-#define F_READ 01
-#define F_WRITE        02
-#define F_ALLOC        04
-#define F_FILE 010
-
-
-
-
-/*
- * dev switch
- */
-struct devsw {
-       char    *dv_name;
-       int     (*dv_strategy)();
-       int     (*dv_open)();
-       int     (*dv_close)();
-};
-
-struct devsw devsw[];
-
-/*
- * request codes. Must be the same a F_XXX above
- */
-#define        READ    1
-#define        WRITE   2
-
-
-#define        NBUFS   4
-
-
-char   b[NBUFS][512];
-daddr_t        blknos[NBUFS];
-
-
-
-#define NFILES 4
-struct iob iob[NFILES];
-
-/*
- * Set to which 32Kw segment the code is physically running in.
- * Must be set by the users main (or there abouts).
- */
-int    segflag;
diff --git a/usr/src/cmd/standalone/srt0.s b/usr/src/cmd/standalone/srt0.s
deleted file mode 100644 (file)
index bb4727a..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/ Startup code for two-stage bootstrap
-
-/ non-UNIX instructions
-mfpi   = 6500^tst
-stst   = 170300^tst
-mtpi   = 6600^tst
-mfpd   = 106500^tst
-mtpd   = 106600^tst
-spl    = 230
-ldfps  = 170100^tst
-stfps  = 170200^tst
-wait   = 1
-rtt    = 6
-reset  = 5
-/ trap = 104400
-
-PS     = 177776
-
-.globl _end
-.globl _main, __rtt
-.globl _edata
-       jmp     start
-
-/
-/ trap vectors
-/
-       trap;340
-       trap;341        / illegal instruction
-       trap;342        / BPT
-       trap;343        / IOT
-       trap;344        / POWER FAIL
-       trap;345        / EMT
-tvec:
-       start;346       / TRAP
-.=400^.
-.text
-
-
-start:
-       mov     $340,*$PS
-       mov     $trap,tvec
-/ fix up stack segment clobbered by trap
-       mov     $1400,*$KDSA6
-       mov     $157776,sp
-       mov     $_edata,r0
-       mov     $_end,r1
-       sub     r0,r1
-       inc     r1
-       clc
-       ror     r1
-1:
-       clr     (r0)+
-       sob     r1,1b
-       jsr     pc,_main
-
-/ fix up stack to point at trap ps-pc pair
-/ so we can return to the bootstrap
-__rtt:
-       clr     *$KDSA6
-       mov     $140000,sp
-       rtt                             / we hope!
-       br      .
-
-
-.globl _trap
-trap:
-       mov     r0,-(sp)
-       mov     r1,-(sp)
-       mov     *$PS,-(sp)
-       jsr     pc,_trap
-       tst     (sp)+
-       mov     (sp)+,r1
-       mov     (sp)+,r0
-       rtt
-
-KDSA6 = 172374
diff --git a/usr/src/cmd/standalone/tapedir b/usr/src/cmd/standalone/tapedir
deleted file mode 100644 (file)
index 7e531d5..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-mtboot 1
-mtboot 1
-boot 1
-* 1
-cat 1
-* 1
-contents 1
-* 1
-mkfs 1
-* 1
-restor 1
diff --git a/usr/src/cmd/standalone/tm.c b/usr/src/cmd/standalone/tm.c
deleted file mode 100644 (file)
index cd4a0bf..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-#
-
-/*
- * TM tape driver
- */
-
-#include <sys/param.h>
-#include <sys/inode.h>
-#include "saio.h"
-
-struct device {
-       int     tmer;
-       int     tmcs;
-       int     tmbc;
-       char    *tmba;
-       int     tmdb;
-       int     tmrd;
-};
-
-#define        TMADDR ((struct device *)0172520)
-
-#define        GO      01
-#define        RCOM    02
-#define        WCOM    04
-#define        WEOF    06
-#define        SFORW   010
-#define        SREV    012
-#define        WIRG    014
-#define        REW     016
-#define        DENS    060000          /* 9-channel */
-#define        IENABLE 0100
-#define        CRDY    0200
-#define GAPSD  010000
-#define        TUR     1
-#define        SDWN    010
-#define        HARD    0102200 /* ILC, EOT, NXM */
-#define        EOF     0040000
-
-#define        SSEEK   1
-#define        SIO     2
-
-
-tmrew(io)
-register struct iob *io;
-{
-       tmstrategy(io, REW);
-}
-
-tmopen(io)
-register struct iob *io;
-{
-       register skip;
-
-       tmstrategy(io, REW);
-       skip = io->i_boff;
-       while (skip--) {
-               io->i_cc = 0;
-               while (tmstrategy(io, SFORW))
-                       ;
-       }
-}
-tmstrategy(io, func)
-register struct iob *io;
-{
-       register int com, unit, errcnt;
-
-       unit = io->i_unit;
-       errcnt = 0;
-retry:
-       tmquiet();
-       com = (unit<<8)|(segflag<<4)|DENS;
-       TMADDR->tmbc = -io->i_cc;
-       TMADDR->tmba = io->i_ma;
-       if (func == READ)
-               TMADDR->tmcs = com | RCOM | GO;
-       else if (func == WRITE)
-               TMADDR->tmcs = com | WCOM | GO;
-       else if (func == SREV) {
-               TMADDR->tmbc = -1;
-               TMADDR->tmcs = com | SREV | GO;
-               return(0);
-       } else
-               TMADDR->tmcs = com | func | GO;
-       while ((TMADDR->tmcs&CRDY) == 0)
-               ;
-       if (TMADDR->tmer&EOF)
-               return(0);
-       if (TMADDR->tmer < 0) {
-               if (errcnt == 0)
-                       printf("tape error: er=%o", TMADDR->tmer);
-               if (errcnt==10) {
-                       printf("\n");
-                       return(-1);
-               }
-               errcnt++;
-               tmstrategy(io, SREV);
-               goto retry;
-       }
-       if (errcnt)
-               printf(" recovered by retry\n");
-       return( io->i_cc+TMADDR->tmbc );
-}
-
-tmquiet()
-{
-       while ((TMADDR->tmcs&CRDY) == 0)
-               ;
-       while ((TMADDR->tmer&TUR) == 0)
-               ;
-       while ((TMADDR->tmer&SDWN) != 0)
-               ;
-}
index 80890c9..8ef4a63 100644 (file)
@@ -54,13 +54,12 @@ char *name;
                status = 1;
                goto out;
        }
                status = 1;
                goto out;
        }
-       if(head.a_syms == 0 && (head.a_flag&1) != 0) {
+       if ((head.a_syms == 0) && (head.a_trsize == 0) && (head.a_drsize ==0)) {
                printf("%s already stripped\n", name);
                goto out;
        }
        size = (long)head.a_text + head.a_data;
                printf("%s already stripped\n", name);
                goto out;
        }
        size = (long)head.a_text + head.a_data;
-       head.a_syms = 0;
-       head.a_flag |= 1;
+       head.a_syms = head.a_trsize = head.a_drsize = 0 ;
 
        lseek(tf, (long)0, 0);
        write(tf, (char *)&head, sizeof(head));
 
        lseek(tf, (long)0, 0);
        write(tf, (char *)&head, sizeof(head));
index f879efe..f2618f6 100644 (file)
@@ -12,12 +12,12 @@ prgraph()
                fprintf(stderr,"%d %s:",v, typename[NTYPE(v)]);
                for (i = 0; i < ARCNUM(v); ++i)
                        {
                fprintf(stderr,"%d %s:",v, typename[NTYPE(v)]);
                for (i = 0; i < ARCNUM(v); ++i)
                        {
-                       fprintf(stderr,"%d ",ARC(v,i));
+                       printf("%d ",ARC(v,i));
                        ASSERT(UNDEFINED <= ARC(v,i) && ARC(v,i) < nodenum, prgraph);
                        }
                        ASSERT(UNDEFINED <= ARC(v,i) && ARC(v,i) < nodenum, prgraph);
                        }
-               fprintf(stderr,"\n");
+               printf("\n");
                }
                }
-       fprintf(stderr,"\n\n");
+       printf("\n\n");
        }
 
 prtree()
        }
 
 prtree()
@@ -34,7 +34,7 @@ int tab;
        fprintf(stderr,"%d %s:",v,typename[NTYPE(v)]);
        for (i = 0; i < ARCNUM(v); ++i)
                fprintf(stderr," %d",ARC(v,i));
        fprintf(stderr,"%d %s:",v,typename[NTYPE(v)]);
        for (i = 0; i < ARCNUM(v); ++i)
                fprintf(stderr," %d",ARC(v,i));
-       fprintf(stderr,"\n");
+       printf("\n");
        for (i = 0; i < CHILDNUM(v); ++i)
                {
                TABOVER(tab+1);
        for (i = 0; i < CHILDNUM(v); ++i)
                {
                TABOVER(tab+1);
index 2ca2bbd..de8d1ae 100644 (file)
@@ -61,6 +61,6 @@ struct list *ls;
        {
        struct list *lp;
        for (lp = ls; lp; lp = lp->nxtlist)
        {
        struct list *lp;
        for (lp = ls; lp; lp = lp->nxtlist)
-               fprintf(stderr,"%d,",lp->elt);
+               printf("%d,",lp->elt);
        fprintf(stderr,"\n");
        }
        fprintf(stderr,"\n");
        }
index cf0e3ed..df8173c 100644 (file)
@@ -191,7 +191,7 @@ char unbuf[maxunbp+1];
 int unbp;
 
 empseek(linebeg)
 int unbp;
 
 empseek(linebeg)
-unsigned int linebeg;
+int linebeg;
        {
        unbp = 0;
        if (fseek(infd,(long)(linebeg+rtnbeg),0) == -1)
        {
        unbp = 0;
        if (fseek(infd,(long)(linebeg+rtnbeg),0) == -1)
index 1b20507..5dc0658 100644 (file)
@@ -191,7 +191,7 @@ char c;
                        recognize(entry,0);  return(ABORT);
                /* error */
                case 999:
                        recognize(entry,0);  return(ABORT);
                /* error */
                case 999:
-                       fprintf(stderr,"error: symbol '%c' should not occur as %d'th symbol of: \n%s\n",
+                       printf("error: symbol '%c' should not occur as %d'th symbol of: \n%s\n",
                                c,bufptr, buffer);
                        return(ABORT);
                }
                                c,bufptr, buffer);
                        return(ABORT);
                }
index 58870f8..b57ff11 100644 (file)
@@ -28,11 +28,8 @@ long arclab[], labe;
                {
                if (!addcom || endcom < begline)
                        BEGCOM(num) = UNDEFINED;
                {
                if (!addcom || endcom < begline)
                        BEGCOM(num) = UNDEFINED;
-               else{
+               else
                        BEGCOM(num) = begchar - rtnbeg;
                        BEGCOM(num) = begchar - rtnbeg;
-                       if((unsigned)(BEGCOM(num))!=begchar-rtnbeg)
-                               faterr("program too long","","");
-                       }
                }
        return(num);
        }
                }
        return(num);
        }
index 54f552b..6e15c84 100644 (file)
@@ -79,8 +79,6 @@ int type, ifflag;                             /* do whatever is needed for this statement */
                case FMTVX:
                        num = makenode(FMTVX,FALSE,TRUE,implicit,0,arctype,arclab);
                        BEGCODE(num) = comchar + 1 - rtnbeg;
                case FMTVX:
                        num = makenode(FMTVX,FALSE,TRUE,implicit,0,arctype,arclab);
                        BEGCODE(num) = comchar + 1 - rtnbeg;
-                       if((unsigned)(BEGCODE(num))!=comchar+1-rtnbeg)
-                               faterr("program too long","","");
                        ONDISK(num) = endline - endcom;
                        if (label(0) != implicit)
                                fixvalue(label(0),num);
                        ONDISK(num) = endline - endcom;
                        if (label(0) != implicit)
                                fixvalue(label(0),num);
@@ -99,8 +97,6 @@ int type, ifflag;                             /* do whatever is needed for this statement */
                                        {
                                        stflag = num;
                                        BEGCODE(num) = comchar + 1 - rtnbeg;
                                        {
                                        stflag = num;
                                        BEGCODE(num) = comchar + 1 - rtnbeg;
-                                       if((unsigned)(BEGCODE(num))!=comchar+1-rtnbeg)
-                                               faterr("program too long","","");
                                        ONDISK(num) = endline - endcom;
                                        CODELINES(num) = 1;
                                        }
                                        ONDISK(num) = endline - endcom;
                                        CODELINES(num) = 1;
                                        }
@@ -194,8 +190,6 @@ int type, ifflag;                           /* do whatever is needed for this statement */
                case entry:
                        num = makenode(STLNVX,FALSE,TRUE,label(0),1,arctype,arclab);
                        BEGCODE(num) = comchar + 1 - rtnbeg;
                case entry:
                        num = makenode(STLNVX,FALSE,TRUE,label(0),1,arctype,arclab);
                        BEGCODE(num) = comchar + 1 - rtnbeg;
-                       if((unsigned)(BEGCODE(num))!=comchar+1-rtnbeg)
-                               faterr("program too long","","");
                        ONDISK(num) = endline - endcom;
                        CODELINES(num) = 1;
                        ENTLST = append(num,ENTLST);
                        ONDISK(num) = endline - endcom;
                        CODELINES(num) = 1;
                        ENTLST = append(num,ENTLST);
@@ -322,10 +316,10 @@ LOGICAL ifflag;
        num = makenode(SWCHVX,!ifflag,!ifflag,label(0),d,arctype,arclab);
        EXP(num) = exp;
 
        num = makenode(SWCHVX,!ifflag,!ifflag,label(0),d,arctype,arclab);
        EXP(num) = exp;
 
-       str = challoc(6*nlabs); /* 5 digits + , or \0 per label */
+       str = challoc(6*(nlabs-1));     /* 5 digits + , or \0 per label */
        for (i = 0; i < d; ++i)         /* construct list of values for each label */
                EXP(arctype[i]) = stralloc(str,accum(str,linelabs->nxtlab,arclab[i]));
        for (i = 0; i < d; ++i)         /* construct list of values for each label */
                EXP(arctype[i]) = stralloc(str,accum(str,linelabs->nxtlab,arclab[i]));
-       chfree(str,6*nlabs);
+       chfree(str,6*(nlabs-1));
        chfree(arctype,sizeof(*arctype) * nlabs);  chfree(arclab,sizeof(*arclab) * nlabs);
        return(num);
        }
        chfree(arctype,sizeof(*arctype) * nlabs);  chfree(arclab,sizeof(*arclab) * nlabs);
        return(num);
        }
@@ -361,7 +355,7 @@ struct lablist *vlist;  long dlist[];               /*count[] gets count of each label;  d di
 int count[],size;
        {int d,i;
        d = 0;
 int count[],size;
        {int d,i;
        d = 0;
-       for(i = 0; i <= size; i++)  count[i] = 0;
+       for(i = 0; i < size; i++)  count[i] = 0;
 
        for (;vlist && vlist->labelt != 0L; vlist = vlist ->nxtlab)
                {
 
        for (;vlist && vlist->labelt != 0L; vlist = vlist ->nxtlab)
                {
index 0b71804..89ec32e 100644 (file)
@@ -223,8 +223,6 @@ LOGICAL tabfirst;   /* same as for outrat */
        VERT w;
        if (NTYPE(v) == ACASVX || NTYPE(v) == ICASVX)
                addbrace = FALSE;
        VERT w;
        if (NTYPE(v) == ACASVX || NTYPE(v) == ICASVX)
                addbrace = FALSE;
-       else if (NTYPE(v) == SWCHVX)
-               addbrace = TRUE;
        else
                addbrace = HASBRACE(v,ch);
        ASSERT(tabfirst || !addbrace,newlevel);
        else
                addbrace = HASBRACE(v,ch);
        ASSERT(tabfirst || !addbrace,newlevel);
diff --git a/usr/src/cmd/struct/Makefile b/usr/src/cmd/struct/Makefile
new file mode 100644 (file)
index 0000000..bbbe3e7
--- /dev/null
@@ -0,0 +1,49 @@
+CFLAGS=-O
+YFLAGS=-d
+0FILES.c = 0.alloc.c 0.args.c 0.def.c 0.extr.c 0.graph.c 0.list.c 0.parts.c 0.string.c
+0FILES.o = 0.alloc.o 0.args.o 0.def.o 0.extr.o 0.graph.o 0.list.o 0.parts.o 0.string.o
+
+1FILES.c = 1.finish.c 1.form.c 1.fort.c 1.hash.c 1.init.c 1.line.c 1.main.c 1.node.c 1.recog.c 1.tables.c
+1FILES.o = 1.finish.o 1.form.o 1.fort.o 1.hash.o 1.init.o 1.line.o 1.main.o 1.node.o 1.recog.o 1.tables.o
+
+2FILES.c = 2.dfs.c 2.dom.c 2.head.c 2.inarc.c 2.main.c 2.tree.c
+2FILES.o = 2.dfs.o 2.dom.o 2.head.o 2.inarc.o 2.main.o 2.tree.o
+
+3FILES.c = 3.branch.c 3.flow.c 3.loop.c 3.main.c 3.reach.c 3.then.c
+3FILES.o = 3.branch.o 3.flow.o 3.loop.o 3.main.o 3.reach.o 3.then.o
+
+4FILES.c = 4.brace.c 4.form.c 4.main.c 4.out.c
+4FILES.o = 4.brace.o 4.form.o 4.main.o 4.out.o
+
+all:   structure beautify
+
+install: structure beautify
+       install -s structure $(DESTDIR)/usr/lib/struct
+       install -s beautify $(DESTDIR)/usr/lib/struct
+       install -c struct $(DESTDIR)/usr/bin
+clean:
+       rm -f *.o y.tab.h beauty.c
+
+structure: main.o $(0FILES.o) $(1FILES.o) $(2FILES.o) $(3FILES.o) $(4FILES.o)
+       cc -o structure main.o 0.*.o 1.*.o 2.*.o 3.*.o 4.*.o 
+
+beautify:      beauty.o tree.o lextab.o bdef.o
+       cc -O beauty.o tree.o lextab.o bdef.o -o beautify -lln
+
+lint:
+       lint $(0FILES.c) $(1FILES.c) $(2FILES.c) $(3FILES.c) $(4FILES.c) main.c
+
+main.o $(0FILES.o) $(1FILES.o) $(2FILES.o) $(3FILES.o) $(4FILES.o): def.h
+
+$(1FILES.o): 1.defs.h 1.incl.h
+$(2FILES.o): 2.def.h
+$(3FILES.o): 3.def.h
+$(4FILES.o): 4.def.h
+
+lextab.o tree.o: y.tab.h
+
+y.tab.h: beauty.y
+
+lextab.o tree.o beauty.y: b.h
+
+y.tab.h:       beauty.c
diff --git a/usr/src/cmd/struct/beauty.c b/usr/src/cmd/struct/beauty.c
new file mode 100644 (file)
index 0000000..9eea435
--- /dev/null
@@ -0,0 +1,833 @@
+# define xxif 300
+# define xxelse 301
+# define xxwhile 302
+# define xxrept 303
+# define xxdo 304
+# define xxrb 305
+# define xxpred 306
+# define xxident 307
+# define xxle 308
+# define xxge 309
+# define xxne 310
+# define xxnum 311
+# define xxcom 312
+# define xxstring 313
+# define xxexplist 314
+# define xxidpar 315
+# define xxelseif 316
+# define xxlb 318
+# define xxend 319
+# define xxcase 320
+# define xxswitch 321
+# define xxuntil 322
+# define xxdefault 323
+# define xxeq 324
+# define xxuminus 281
+
+# line 17 "beauty.y"
+#include "b.h"
+#include <stdio.h>
+#define yyclearin yychar = -1
+#define yyerrok yyerrflag = 0
+extern int yychar;
+extern short yyerrflag;
+#ifndef YYMAXDEPTH
+#define YYMAXDEPTH 150
+#endif
+#ifndef YYSTYPE
+#define YYSTYPE int
+#endif
+YYSTYPE yylval, yyval;
+
+# line 23 "beauty.y"
+struct node *t;
+# define YYERRCODE 256
+
+# line 228 "beauty.y"
+
+#define ASSERT(X,Y)    if (!(X)) error("struct bug: assertion 'X' invalid in routine Y","","");
+
+yyerror(s)
+char *s;
+       {
+       extern int yychar;
+       fprintf(stderr,"\n%s",s);
+       fprintf(stderr," in beautifying, output line %d,",xxlineno + 1);
+       fprintf(stderr," on input: ");
+               switch (yychar) {
+                       case '\t': fprintf(stderr,"\\t\n"); return;
+                       case '\n': fprintf(stderr,"\\n\n"); return;
+                       case '\0': fprintf(stderr,"$end\n"); return;
+                       default: fprintf(stderr,"%c\n",yychar); return;
+                       }
+       }
+
+yyinit(argc, argv)                     /* initialize pushdown store */
+int argc;
+char *argv[];
+       {
+       xxindent = 0;
+       xxbpertab = 8;
+       xxmaxchars = 120;
+       }
+
+
+#include <signal.h>
+main()
+       {
+       int exit();
+       if ( signal(SIGINT, SIG_IGN) != SIG_IGN)
+               signal(SIGINT, exit);
+       yyinit();
+       yyparse();
+       }
+
+
+putout(type,string)                    /* output string with proper indentation */
+int type;
+char *string;
+       {
+       static int lasttype;
+       if ( (lasttype != 0) && (lasttype != '\n') && (lasttype != ' ') && (lasttype != '\t') && (type == xxcom))
+               accum("\t");
+       else if (lasttype == xxcom && type != '\n')
+               tab(xxindent);
+       else
+               if (lasttype == xxif    ||
+                       lasttype == xxwhile     ||
+                       lasttype == xxdo        ||
+                       type == '='     ||
+                       lasttype == '=' ||
+                       (lasttype == xxident && (type == xxident || type == xxnum) )    ||
+                       (lasttype == xxnum && type == xxnum) )
+                       accum(" ");
+       accum(string);
+       lasttype = type;
+       }
+
+
+accum(token)           /* fill output buffer, generate continuation lines */
+char *token;
+       {
+       static char *buffer;
+       static int lstatus,llen,bufind;
+       int tstatus,tlen,i;
+
+#define NEW    0
+#define MID    1
+#define CONT   2
+
+       if (buffer == 0)
+               {
+               buffer = malloc(xxmaxchars);
+               if (buffer == 0) error("malloc out of space","","");
+               }
+       tlen = slength(token);
+       if (tlen == 0) return;
+       for (i = 0; i < tlen; ++i)
+               ASSERT(token[i] != '\n' || tlen == 1,accum);
+       switch(token[tlen-1])
+               {
+               case '\n':      tstatus = NEW;
+                               break;
+               case '+':
+               case '-':
+               case '*':
+               case ',':
+               case '|':
+               case '&':
+               case '(':       tstatus = CONT;
+                               break;
+               default:        tstatus = MID;
+               }
+       if (llen + bufind + tlen > xxmaxchars && lstatus == CONT && tstatus != NEW)
+               {
+               putchar('\n');
+               ++xxlineno;
+               for (i = 0; i < xxindent; ++i)
+                       putchar('\t');
+               putchar(' ');putchar(' ');
+               llen = 2 + xxindent * xxbpertab;
+               lstatus = NEW;
+               }
+       if (lstatus == CONT && tstatus == MID)
+               {                       /* store in buffer in case need \n after last CONT char */
+               ASSERT(bufind + tlen < xxmaxchars,accum);
+               for (i = 0; i < tlen; ++i)
+                       buffer[bufind++] = token[i];
+               }
+       else
+               {
+               for (i = 0; i < bufind; ++i)
+                       putchar(buffer[i]);
+               llen += bufind;
+               bufind = 0;
+               for (i = 0; i < tlen; ++i)
+                       putchar(token[i]);
+               if (tstatus == NEW) ++xxlineno;
+               llen = (tstatus == NEW) ? 0 : llen + tlen;
+               lstatus = tstatus;
+               }
+       }
+
+tab(n)
+int n;
+       {
+       int i;
+       newline();
+       for ( i = 0;  i < n; ++i)
+               putout('\t',"\t");
+       }
+
+newline()
+       {
+       static int already;
+       if (already)
+               putout('\n',"\n");
+       else
+               already = 1;
+       }
+
+error(mess1, mess2, mess3)
+char *mess1, *mess2, *mess3;
+       {
+       fprintf(stderr,"\nerror in beautifying, output line %d: %s %s %s \n",
+               xxlineno, mess1, mess2, mess3);
+       exit(1);
+       }
+
+
+
+
+
+
+
+push(type)
+int type;
+       {
+       if (++xxstind > xxtop)
+               error("nesting too deep, stack overflow","","");
+       xxstack[xxstind] = type;
+       }
+
+pop()
+       {
+       if (xxstind <= 0)
+               error("stack exhausted, can't be popped as requested","","");
+       --xxstind;
+       }
+
+
+forst()
+       {
+       while( (xxval = yylex()) != '\n')
+               {
+               putout(xxval, yylval);
+               free(yylval);
+               }
+       free(yylval);
+       }
+short yyexca[] ={
+-1, 0,
+       312, 17,
+       -2, 16,
+-1, 1,
+       0, -1,
+       -2, 0,
+-1, 2,
+       0, 18,
+       312, 17,
+       -2, 16,
+-1, 6,
+       312, 17,
+       -2, 16,
+-1, 7,
+       312, 17,
+       -2, 16,
+-1, 29,
+       312, 17,
+       -2, 16,
+-1, 36,
+       312, 17,
+       -2, 16,
+-1, 46,
+       322, 16,
+       -2, 65,
+-1, 93,
+       308, 0,
+       309, 0,
+       310, 0,
+       324, 0,
+       60, 0,
+       62, 0,
+       -2, 51,
+-1, 94,
+       308, 0,
+       309, 0,
+       310, 0,
+       324, 0,
+       60, 0,
+       62, 0,
+       -2, 52,
+-1, 95,
+       308, 0,
+       309, 0,
+       310, 0,
+       324, 0,
+       60, 0,
+       62, 0,
+       -2, 53,
+-1, 96,
+       308, 0,
+       309, 0,
+       310, 0,
+       324, 0,
+       60, 0,
+       62, 0,
+       -2, 54,
+-1, 97,
+       308, 0,
+       309, 0,
+       310, 0,
+       324, 0,
+       60, 0,
+       62, 0,
+       -2, 55,
+-1, 98,
+       308, 0,
+       309, 0,
+       310, 0,
+       324, 0,
+       60, 0,
+       62, 0,
+       -2, 56,
+-1, 104,
+       312, 17,
+       -2, 16,
+-1, 110,
+       312, 17,
+       125, 23,
+       -2, 16,
+-1, 126,
+       312, 17,
+       -2, 16,
+-1, 130,
+       312, 17,
+       320, 21,
+       323, 21,
+       125, 21,
+       -2, 16,
+-1, 132,
+       312, 17,
+       320, 21,
+       323, 21,
+       125, 21,
+       -2, 16,
+-1, 133,
+       312, 17,
+       320, 21,
+       323, 21,
+       125, 21,
+       -2, 16,
+       };
+# define YYNPROD 76
+# define YYLAST 384
+short yyact[]={
+
+  66,  31, 103,  55,  62,  60, 113,  61,  66,  63,
+  11,  40,  62,  60, 107,  61, 119,  63,  38, 120,
+  34,  44,  68,  39,  67,  11,  11,  31,  57,  31,
+  68,  66,  67,  85,  99,  62,  60,  11,  61,  66,
+  63, 110,  59,  62,  60, 109,  61, 100,  63,   8,
+   2,  64,  82,  68,   6,  67,  64,  29, 131,  30,
+  33,  68, 127,  67,  64,  36,  66,  51, 106,  16,
+  62,  60,  76,  61,  66,  63,  50,  24,  62,  60,
+  62,  61,  41,  63, 102,  63,  65,  64,  68, 118,
+  67, 124, 117,   7,  65,  64,  68,   3,  67,   5,
+  14,  62,  60,  21,  61,  32,  63,  22,  23,  28,
+  48,  52,  27,  83,  80,  15,  20,  65,  19,  68,
+  78,  67,  64,  18,  26,  65,  25,  14,  35,  53,
+  64,  54,  64,  45,  58, 104,  49,  62,  60,  17,
+  61,  56,  63,   9,   4,  13,  79,  46,  47,   1,
+   0,   0,  65,  64, 112, 114, 116, 129,   9,   9,
+ 112,   0,   0, 128, 134, 125, 135, 136,   0,   0,
+   0, 112,   0, 121,  77, 123, 101, 132,  22,  23,
+  28, 133,   0,  27, 126,  84,   0,  10,   0,  64,
+ 130,   0,   0,  37,   0,  26,   0,  25,  12,  55,
+   0,   0,  10,  10, 111,   0,   0,   0,   0, 115,
+ 111,   0,   0,  12,  12,  73,  74,  75, 108,   0,
+   0, 111,   0,   0,   0,   0,   0,   0,  81,   0,
+  14,  14,   0,   0,   0,   0,   0,  86,  87,  88,
+  89,  90,  91,  92,  93,  94,  95,  96,  97,  98,
+   0,   0,   0,   0,   0,   0,   0,   0,   0, 105,
+   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+  70,  71,  72,   0,   0,   0,   0,   0,  70,  71,
+  72,   0,   0,   0,   0,  44,  69,   0,   0,  42,
+ 122,  43,   0,   0,  69,   0,   0,   0,   0,   0,
+   0,  70,  71,  72,   0,   0,   0,   0,   0,  70,
+  71,  72,   0,   0,   0,   0,   0,  69,   0,   0,
+   0,   0,   0,   0,   0,  69,   0,   0,   0,   0,
+   0,   0,   0,   0,   0,   0,  70,  71,  72,   0,
+   0,   0,   0,   0,  70,  71,  72,   0,   0,   0,
+   0,   0,  69,   0,   0,   0,   0,   0,   0,   0,
+  69,   0,   0,   0,   0,   0,   0,  70,  71,  72,
+   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+   0,   0,   0,  69 };
+short yypact[]={
+
+ -97,-1000, -97,-1000,  29,-195, -98, -97,-292,-1000,
+-1000,-1000,-1000,-1000,-1000,-1000, -22,  29,-1000,-1000,
+  29,-1000,-1000,-1000,  23,-1000,-1000,-1000,-286, -97,
+-1000,-1000,-1000,-113,-1000,-273, -97,   1, -22, -22,
+ -22,-1000,-1000,-1000,  32,-1000,-1000,-1000,-1000,-1000,
+-1000, -22,  -9,-124,-1000,-1000,-1000,-1000,-1000,-1000,
+ -22, -22, -22, -22, -22, -22, -22, -22, -22, -22,
+ -22, -22, -22,  -7, -43,  59, -22,-1000,-1000,-320,
+ -86,  28, -22,-1000,-1000,-1000,  38,  38, -43, -43,
+ -43,  36,  59,  95,  95,  95,  95,  95,  95,-1000,
+  27, -30,  29,-1000,-1000, -38,-1000, -22,-1000,-1000,
+-1000,-304,-292, -22,-1000, -96,-1000, -22,-1000,-1000,
+   4,-309,  28,-1000,-1000,   0, -97,-1000,-1000,-1000,
+ -97,-1000, -97, -97,-1000,-1000,-1000 };
+short yypgo[]={
+
+   0, 149,  50, 145,  97, 144, 115, 128, 141,  99,
+ 139, 123, 120, 118, 116, 110,  65,  54,  45,  59,
+  33, 103,  93,  49,  60,  41,  92,  91,  89,  82,
+  47, 176,  84,  77,  76 };
+short yyr1[]={
+
+   0,   1,   2,   2,   4,   4,   4,   4,   4,   4,
+   4,   4,   4,   4,   4,   4,   9,  23,   3,   7,
+  16,  20,  18,  18,  25,  25,  25,  25,  26,  28,
+  14,  21,  21,  29,  29,  27,  30,  30,  15,  15,
+   6,  31,  31,  31,  31,  31,  31,  31,  31,  31,
+  31,  31,  31,  31,  31,  31,  31,  31,  31,  31,
+   5,   8,  10,  11,  12,  12,  32,  13,  33,  34,
+  34,  17,  19,  22,  24,  24 };
+short yyr2[]={
+
+   0,   2,   1,   2,   5,   3,   4,   4,   3,   9,
+   2,   4,   2,   2,   3,   1,   0,   0,   0,   3,
+   0,   0,   2,   1,   6,   5,   5,   3,   1,   2,
+   1,   1,   1,   4,   1,   2,   3,   1,   1,   0,
+   3,   3,   2,   2,   3,   3,   3,   3,   3,   3,
+   3,   3,   3,   3,   3,   3,   3,   1,   1,   1,
+   1,   1,   1,   1,   3,   0,   1,   2,   6,   2,
+   0,   1,   1,   1,   1,   2 };
+short yychk[]={
+
+-1000,  -1,  -2,  -4,  -5,  -9, -17, -22, -23, 256,
+ 300, 123, 311,  -3,  -4,  -6,  40, -10, -11, -13,
+ -14, -21, 302, 303, -33, 321, 319, 307, 304,  -2,
+ -19, 125,  -4, -24, 312,  -7, -16, -31,  40,  45,
+  33, -29, 311, 313, 307,  -6,  -7,  -7, -15,  -6,
+ -34,  44, -29,  -9,  -4, 312,  -8, 301,  -4,  41,
+  43,  45,  42,  47,  94, 124,  38,  62,  60, 324,
+ 308, 309, 310, -31, -31, -31,  40,  -7, -12,  -9,
+ -16, -31,  61, -19,  -7, -20, -31, -31, -31, -31,
+ -31, -31, -31, -31, -31, -31, -31, -31, -31,  41,
+ -30, -31, -32, 322, -17, -31,  41,  44,  -6, -18,
+ -25,  -9, -23,  44, -30,  -9, -18, -26, -28, 320,
+ 323, -24, -31, -19, -27, -30, -16,  58, -25, -20,
+ -16,  58,  -2,  -2, -20, -20, -20 };
+short yydef[]={
+
+  -2,  -2,  -2,   2,   0,   0,  -2,  -2,   0,  15,
+  60,  71,  73,   1,   3,  20,   0,   0,  20,  20,
+  39,  10,  62,  63,  70,  30,  31,  32,   0,  -2,
+  12,  72,  13,  16,  74,   5,  -2,   0,   0,   0,
+   0,  57,  58,  59,  34,  20,  -2,   8,  20,  38,
+  67,   0,   0,   0,  14,  75,  20,  61,  21,  40,
+   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+   0,   0,   0,   0,  42,  43,   0,   6,   7,   0,
+   0,  69,   0,  11,   4,  19,  44,  45,  46,  47,
+  48,  49,  50,  -2,  -2,  -2,  -2,  -2,  -2,  41,
+   0,  37,   0,  66,  -2,   0,  33,   0,  64,  16,
+  -2,   0,   0,   0,  36,   0,  22,   0,  20,  28,
+   0,  16,  68,  21,  20,   0,  -2,  29,  27,   9,
+  -2,  35,  -2,  -2,  25,  26,  24 };
+#
+# define YYFLAG -1000
+# define YYERROR goto yyerrlab
+# define YYACCEPT return(0)
+# define YYABORT return(1)
+
+/*     parser for yacc output  */
+
+#ifdef YYDEBUG
+int yydebug = 0; /* 1 for debugging */
+#endif
+YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
+int yychar = -1; /* current input token number */
+int yynerrs = 0;  /* number of errors */
+short yyerrflag = 0;  /* error recovery flag */
+
+yyparse() {
+
+       short yys[YYMAXDEPTH];
+       short yyj, yym;
+       register YYSTYPE *yypvt;
+       register short yystate, *yyps, yyn;
+       register YYSTYPE *yypv;
+       register short *yyxi;
+
+       yystate = 0;
+       yychar = -1;
+       yynerrs = 0;
+       yyerrflag = 0;
+       yyps= &yys[-1];
+       yypv= &yyv[-1];
+
+ yystack:    /* put a state and value onto the stack */
+
+#ifdef YYDEBUG
+       if( yydebug  ) printf( "state %d, char 0%o\n", yystate, yychar );
+#endif
+               if( ++yyps> &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
+               *yyps = yystate;
+               ++yypv;
+               *yypv = yyval;
+
+ yynewstate:
+
+       yyn = yypact[yystate];
+
+       if( yyn<= YYFLAG ) goto yydefault; /* simple state */
+
+       if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
+       if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;
+
+       if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
+               yychar = -1;
+               yyval = yylval;
+               yystate = yyn;
+               if( yyerrflag > 0 ) --yyerrflag;
+               goto yystack;
+               }
+
+ yydefault:
+       /* default state action */
+
+       if( (yyn=yydef[yystate]) == -2 ) {
+               if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
+               /* look through exception table */
+
+               for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
+
+               while( *(yyxi+=2) >= 0 ){
+                       if( *yyxi == yychar ) break;
+                       }
+               if( (yyn = yyxi[1]) < 0 ) return(0);   /* accept */
+               }
+
+       if( yyn == 0 ){ /* error */
+               /* error ... attempt to resume parsing */
+
+               switch( yyerrflag ){
+
+               case 0:   /* brand new error */
+
+                       yyerror( "syntax error" );
+               yyerrlab:
+                       ++yynerrs;
+
+               case 1:
+               case 2: /* incompletely recovered error ... try again */
+
+                       yyerrflag = 3;
+
+                       /* find a state where "error" is a legal shift action */
+
+                       while ( yyps >= yys ) {
+                          yyn = yypact[*yyps] + YYERRCODE;
+                          if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
+                             yystate = yyact[yyn];  /* simulate a shift of "error" */
+                             goto yystack;
+                             }
+                          yyn = yypact[*yyps];
+
+                          /* the current yyps has no shift onn "error", pop stack */
+
+#ifdef YYDEBUG
+                          if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
+#endif
+                          --yyps;
+                          --yypv;
+                          }
+
+                       /* there is no state on the stack with an error shift ... abort */
+
+       yyabort:
+                       return(1);
+
+
+               case 3:  /* no shift yet; clobber input char */
+
+#ifdef YYDEBUG
+                       if( yydebug ) printf( "error recovery discards char %d\n", yychar );
+#endif
+
+                       if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
+                       yychar = -1;
+                       goto yynewstate;   /* try again in the same state */
+
+                       }
+
+               }
+
+       /* reduction by production yyn */
+
+#ifdef YYDEBUG
+               if( yydebug ) printf("reduce %d\n",yyn);
+#endif
+               yyps -= yyr2[yyn];
+               yypvt = yypv;
+               yypv -= yyr2[yyn];
+               yyval = yypv[1];
+               yym=yyn;
+                       /* consult goto table to find next state */
+               yyn = yyr1[yyn];
+               yyj = yypgo[yyn] + *yyps + 1;
+               if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
+               switch(yym){
+                       
+case 16:
+# line 49 "beauty.y"
+       {
+                       if (!xxlablast) tab(xxindent);
+                       xxlablast = 0;
+                       } break;
+case 17:
+# line 54 "beauty.y"
+       newline(); break;
+case 18:
+# line 55 "beauty.y"
+       putout('\n',"\n"); break;
+case 20:
+# line 57 "beauty.y"
+
+                               {
+                               if (xxstack[xxstind] != xxlb)
+                                       ++xxindent;
+                               } break;
+case 21:
+# line 62 "beauty.y"
+
+                               {if (xxstack[xxstind] != xxlb && xxstack[xxstind] != xxelseif)
+                                       --xxindent;
+                               pop();
+                               } break;
+case 28:
+# line 77 "beauty.y"
+       {putout(xxcase,"case "); free (yypvt[-0]); push(xxcase); } break;
+case 29:
+# line 80 "beauty.y"
+               {
+                                               putout(xxcase,"default");
+                                               free(yypvt[-1]);
+                                               putout(':',":");
+                                               free(yypvt[-0]);
+                                               push(xxcase);
+                                               } break;
+case 30:
+# line 87 "beauty.y"
+       {putout(xxswitch,"switch"); free(yypvt[-0]); push(xxswitch); } break;
+case 31:
+# line 89 "beauty.y"
+       {
+                               free(yypvt[-0]);
+                               putout(xxident,"end");
+                               putout('\n',"\n");
+                               putout('\n',"\n");
+                               putout('\n',"\n");
+                               } break;
+case 32:
+# line 96 "beauty.y"
+       {
+                               putout(xxident,yypvt[-0]);
+                               free(yypvt[-0]);
+                               newflag = 1;
+                               forst();
+                               newflag = 0;
+                               } break;
+case 33:
+# line 106 "beauty.y"
+       {
+                               xxt = addroot(yypvt[-3],xxident,0,0);
+                               yyval = addroot("",xxidpar,xxt,yypvt[-1]);
+                               } break;
+case 34:
+# line 111 "beauty.y"
+       yyval = addroot(yypvt[-0],xxident,0,0); break;
+case 35:
+# line 114 "beauty.y"
+       {
+                               yield(yypvt[-1],0);
+                               putout(':',":");
+                               freetree(yypvt[-1]);
+                               } break;
+case 36:
+# line 119 "beauty.y"
+       yyval = addroot(yypvt[-1],xxexplist,checkneg(yypvt[-2],0),yypvt[-0]); break;
+case 37:
+# line 120 "beauty.y"
+       yyval = checkneg(yypvt[-0],0); break;
+case 40:
+# line 128 "beauty.y"
+       { t = checkneg(yypvt[-1],0);
+                               yield(t,100);  freetree(t);     } break;
+case 41:
+# line 131 "beauty.y"
+       yyval = yypvt[-1]; break;
+case 42:
+# line 132 "beauty.y"
+       yyval = addroot(yypvt[-1],xxuminus,yypvt[-0],0); break;
+case 43:
+# line 133 "beauty.y"
+       yyval = addroot(yypvt[-1],'!',yypvt[-0],0); break;
+case 44:
+# line 134 "beauty.y"
+       yyval = addroot(yypvt[-1],'+',yypvt[-2],yypvt[-0]); break;
+case 45:
+# line 135 "beauty.y"
+       yyval = addroot(yypvt[-1],'-',yypvt[-2],yypvt[-0]); break;
+case 46:
+# line 136 "beauty.y"
+       yyval = addroot(yypvt[-1],'*',yypvt[-2],yypvt[-0]); break;
+case 47:
+# line 137 "beauty.y"
+       yyval = addroot(yypvt[-1],'/',yypvt[-2],yypvt[-0]); break;
+case 48:
+# line 138 "beauty.y"
+       yyval = addroot(yypvt[-1],'^',yypvt[-2],yypvt[-0]); break;
+case 49:
+# line 139 "beauty.y"
+       yyval = addroot(yypvt[-1],'|',yypvt[-2],yypvt[-0]); break;
+case 50:
+# line 140 "beauty.y"
+       yyval = addroot(yypvt[-1],'&',yypvt[-2],yypvt[-0]); break;
+case 51:
+# line 141 "beauty.y"
+       yyval = addroot(yypvt[-1],'>',yypvt[-2],yypvt[-0]); break;
+case 52:
+# line 142 "beauty.y"
+       yyval = addroot(yypvt[-1],'<',yypvt[-2],yypvt[-0]); break;
+case 53:
+# line 143 "beauty.y"
+       yyval = addroot(yypvt[-1],xxeq,yypvt[-2],yypvt[-0]); break;
+case 54:
+# line 144 "beauty.y"
+       yyval = addroot(yypvt[-1],xxle,yypvt[-2],yypvt[-0]); break;
+case 55:
+# line 145 "beauty.y"
+       yyval = addroot(yypvt[-1],xxge,yypvt[-2],yypvt[-0]); break;
+case 56:
+# line 146 "beauty.y"
+       yyval = addroot(yypvt[-1],xxne,yypvt[-2],yypvt[-0]); break;
+case 57:
+# line 147 "beauty.y"
+       yyval = yypvt[-0]; break;
+case 58:
+# line 148 "beauty.y"
+       yyval = addroot(yypvt[-0],xxnum,0,0); break;
+case 59:
+# line 149 "beauty.y"
+       yyval = addroot(yypvt[-0],xxstring,0,0); break;
+case 60:
+# line 152 "beauty.y"
+
+                               {
+                               if (xxstack[xxstind] == xxelse && !xxlablast)
+                                       {
+                                       --xxindent;
+                                       xxstack[xxstind] = xxelseif;
+                                       putout(' '," ");
+                                       }
+                               else
+                                       {
+                                       if (!xxlablast)
+                                               tab(xxindent);
+                                       xxlablast = 0;
+                                       }
+                               putout(xxif,"if");
+                               free(yypvt[-0]);
+                               push(xxif);
+                               } break;
+case 61:
+# line 170 "beauty.y"
+
+                               {
+                               tab(xxindent);
+                               putout(xxelse,"else");
+                               free(yypvt[-0]);
+                               push(xxelse);
+                               } break;
+case 62:
+# line 177 "beauty.y"
+       {
+                               putout(xxwhile,"while");
+                               free(yypvt[-0]);
+                               push(xxwhile);
+                               } break;
+case 63:
+# line 182 "beauty.y"
+                       {
+                                       putout(xxrept,"repeat");
+                                       free(yypvt[-0]);
+                                       push(xxrept);
+                                       } break;
+case 66:
+# line 191 "beauty.y"
+       {
+                       putout('\t',"\t");
+                       putout(xxuntil,"until");
+                       free(yypvt[-0]);
+                       } break;
+case 68:
+# line 198 "beauty.y"
+
+                                       {push(xxdo);
+                                       putout(xxdo,"do");
+                                       free(yypvt[-5]);
+                                       puttree(yypvt[-4]);
+                                       putout('=',"=");
+                                       free(yypvt[-3]);
+                                       puttree(yypvt[-2]);
+                                       putout(',',",");
+                                       free(yypvt[-1]);
+                                       puttree(yypvt[-0]);
+                                       } break;
+case 69:
+# line 210 "beauty.y"
+       {
+                                               putout(',',",");
+                                               puttree(yypvt[-0]);
+                                               } break;
+case 71:
+# line 215 "beauty.y"
+       {
+                               putout('{'," {");
+                               push(xxlb);
+                               } break;
+case 72:
+# line 219 "beauty.y"
+       { putout('}',"}");  pop();   } break;
+case 73:
+# line 220 "beauty.y"
+       {
+                               tab(xxindent);
+                               putout(xxnum,yypvt[-0]);
+                               putout(' ',"  ");
+                               xxlablast = 1;
+                               } break;
+case 74:
+# line 226 "beauty.y"
+       { putout(xxcom,yypvt[-0]);  free(yypvt[-0]);  xxlablast = 0; } break;
+case 75:
+# line 227 "beauty.y"
+ { putout ('\n',"\n"); putout(xxcom,yypvt[-0]);  free(yypvt[-0]);  xxlablast = 0; } break;
+               }
+               goto yystack;  /* stack new state and value */
+
+       }
index ca8202f..067c08c 100644 (file)
@@ -130,7 +130,6 @@ pred:       '(' expr ')'    =       { t = checkneg($2,0);
 
 expr:          '(' expr ')'    =       $$ = $2;
        |       '-' expr        %prec xxuminus  =       $$ = addroot($1,xxuminus,$2,0);
 
 expr:          '(' expr ')'    =       $$ = $2;
        |       '-' expr        %prec xxuminus  =       $$ = addroot($1,xxuminus,$2,0);
-       |       '+' expr        %prec xxuminus  =       $$ = $2;
        |       '!' expr        =       $$ = addroot($1,'!',$2,0);
        |       expr '+' expr   =       $$ = addroot($2,'+',$1,$3);
        |       expr '-' expr   =       $$ = addroot($2,'-',$1,$3);
        |       '!' expr        =       $$ = addroot($1,'!',$2,0);
        |       expr '+' expr   =       $$ = addroot($2,'+',$1,$3);
        |       expr '-' expr   =       $$ = addroot($2,'-',$1,$3);
diff --git a/usr/src/cmd/struct/err b/usr/src/cmd/struct/err
new file mode 100644 (file)
index 0000000..57e3bb4
--- /dev/null
@@ -0,0 +1,126 @@
+cc -O -c main.c
+cc -O -c 0.alloc.c
+"0.alloc.c", line 50: warning: illegal combination of pointer and integer
+"0.alloc.c", line 57: warning: illegal combination of pointer and integer
+"0.alloc.c", line 93: warning: illegal combination of pointer and integer
+"0.alloc.c", line 105: warning: illegal pointer combination
+"0.alloc.c", line 106: warning: illegal combination of pointer and integer
+cc -O -c 0.args.c
+cc -O -c 0.def.c
+cc -O -c 0.extr.c
+cc -O -c 0.graph.c
+cc -O -c 0.list.c
+"0.list.c", line 9: warning: illegal combination of pointer and integer
+cc -O -c 0.parts.c
+"0.parts.c", line 107: warning: illegal combination of pointer and integer
+"0.parts.c", line 109: warning: illegal pointer combination
+"0.parts.c", line 112: warning: illegal combination of pointer and integer
+cc -O -c 0.string.c
+"0.string.c", line 102: warning: illegal combination of pointer and integer
+"0.string.c", line 105: warning: illegal combination of pointer and integer
+cc -O -c 1.finish.c
+cc -O -c 1.form.c
+cc -O -c 1.fort.c
+"1.fort.c", line 45: warning: illegal combination of pointer and integer
+"1.fort.c", line 70: warning: illegal combination of pointer and integer
+"1.fort.c", line 94: warning: illegal combination of pointer and integer
+"1.fort.c", line 111: warning: illegal combination of pointer and integer
+"1.fort.c", line 125: warning: illegal combination of pointer and integer
+"1.fort.c", line 130: warning: illegal combination of pointer and integer
+"1.fort.c", line 168: warning: illegal combination of pointer and integer
+"1.fort.c", line 169: warning: illegal combination of pointer and integer
+"1.fort.c", line 190: warning: illegal combination of pointer and integer
+"1.fort.c", line 207: warning: illegal combination of pointer and integer
+"1.fort.c", line 247: warning: illegal combination of pointer and integer
+"1.fort.c", line 249: warning: illegal combination of pointer and integer
+"1.fort.c", line 259: warning: illegal combination of pointer and integer
+cc -O -c 1.hash.c
+"1.hash.c", line 92: warning: illegal combination of pointer and integer
+"1.hash.c", line 93: warning: illegal combination of pointer and integer
+"1.hash.c", line 94: warning: illegal combination of pointer and integer
+"1.hash.c", line 162: warning: illegal combination of pointer and integer
+"1.hash.c", line 187: warning: illegal combination of pointer and integer
+"1.hash.c", line 212: warning: illegal combination of pointer and integer
+cc -O -c 1.init.c
+"1.init.c", line 11: warning: illegal combination of pointer and integer
+cc -O -c 1.line.c
+cc -O -c 1.main.c
+cc -O -c 1.node.c
+cc -O -c 1.recog.c
+"1.recog.c", line 14: warning: illegal combination of pointer and integer
+"1.recog.c", line 14: warning: illegal combination of pointer and integer
+"1.recog.c", line 37: warning: illegal combination of pointer and integer
+"1.recog.c", line 105: warning: illegal combination of pointer and integer
+"1.recog.c", line 127: warning: illegal combination of pointer and integer
+"1.recog.c", line 162: warning: illegal combination of pointer and integer
+"1.recog.c", line 163: warning: illegal combination of pointer and integer
+"1.recog.c", line 183: warning: illegal combination of pointer and integer
+"1.recog.c", line 187: warning: illegal combination of pointer and integer
+"1.recog.c", line 243: warning: illegal combination of pointer and integer
+"1.recog.c", line 308: warning: illegal combination of pointer and integer
+"1.recog.c", line 309: warning: illegal combination of pointer and integer
+"1.recog.c", line 317: warning: illegal combination of pointer and integer
+"1.recog.c", line 319: warning: illegal combination of pointer and integer
+cc -O -c 1.tables.c
+cc -O -c 2.dfs.c
+"2.dfs.c", line 40: warning: illegal combination of pointer and integer
+"2.dfs.c", line 50: warning: illegal combination of pointer and integer
+"2.dfs.c", line 53: warning: illegal combination of pointer and integer
+"2.dfs.c", line 54: warning: illegal combination of pointer and integer
+cc -O -c 2.dom.c
+cc -O -c 2.head.c
+cc -O -c 2.inarc.c
+"2.inarc.c", line 36: warning: illegal combination of pointer and integer
+cc -O -c 2.main.c
+"2.main.c", line 21: warning: illegal combination of pointer and integer
+"2.main.c", line 26: warning: illegal combination of pointer and integer
+"2.main.c", line 30: warning: illegal combination of pointer and integer
+cc -O -c 2.tree.c
+cc -O -c 3.branch.c
+cc -O -c 3.flow.c
+cc -O -c 3.loop.c
+cc -O -c 3.main.c
+"3.main.c", line 18: warning: illegal combination of pointer and integer
+cc -O -c 3.reach.c
+"3.reach.c", line 40: warning: illegal combination of pointer and integer
+"3.reach.c", line 53: warning: illegal combination of pointer and integer
+"3.reach.c", line 61: warning: illegal combination of pointer and integer
+"3.reach.c", line 87: warning: illegal combination of pointer and integer
+cc -O -c 3.then.c
+cc -O -c 4.brace.c
+cc -O -c 4.form.c
+cc -O -c 4.main.c
+"4.main.c", line 10: warning: illegal combination of pointer and integer
+cc -O -c 4.out.c
+cc -o structure main.o 0.*.o 1.*.o 2.*.o 3.*.o 4.*.o 
+cc -O -c beauty.c
+"beauty.c", line 122: warning: illegal combination of pointer and integer
+"beauty.y", line 128: warning: illegal combination of pointer and integer
+cc -O -c tree.c
+"tree.c", line 12: warning: illegal combination of pointer and integer
+"tree.c", line 16: warning: illegal combination of pointer and integer
+"tree.c", line 18: warning: illegal combination of pointer and integer
+"tree.c", line 39: warning: old-fashioned initialization: use =
+"tree.c", line 40: warning: old-fashioned initialization: use =
+"tree.c", line 41: warning: old-fashioned initialization: use =
+"tree.c", line 75: warning: illegal combination of pointer and integer
+"tree.c", line 79: warning: illegal combination of pointer and integer
+"tree.c", line 80: warning: illegal combination of pointer and integer
+"tree.c", line 82: warning: illegal combination of pointer and integer
+"tree.c", line 89: warning: illegal combination of pointer and integer
+"tree.c", line 94: warning: illegal combination of pointer and integer
+"tree.c", line 95: warning: illegal combination of pointer and integer
+"tree.c", line 98: warning: illegal combination of pointer and integer
+"tree.c", line 109: warning: illegal combination of pointer and integer
+"tree.c", line 110: warning: illegal combination of pointer and integer
+"tree.c", line 111: warning: illegal combination of pointer and integer
+lex  lextab.l
+cc -O -c lex.yy.c
+"lex.yy.c", line 58: warning: illegal combination of pointer and integer
+"lex.yy.c", line 178: warning: illegal combination of pointer and integer
+"lex.yy.c", line 180: warning: illegal combination of pointer and integer
+"lex.yy.c", line 197: warning: illegal combination of pointer and integer
+rm lex.yy.c
+mv lex.yy.o lextab.o
+cc -O -c bdef.c
+cc -O beauty.o tree.o lextab.o bdef.o -o beautify -lln
diff --git a/usr/src/cmd/struct/makefile b/usr/src/cmd/struct/makefile
deleted file mode 100644 (file)
index 58c5162..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-CFLAGS=-O
-YFLAGS=-d
-0FILES.c = 0.alloc.c 0.args.c 0.def.c 0.extr.c 0.graph.c 0.list.c 0.parts.c 0.string.c
-0FILES.o = 0.alloc.o 0.args.o 0.def.o 0.extr.o 0.graph.o 0.list.o 0.parts.o 0.string.o
-
-1FILES.c = 1.finish.c 1.form.c 1.fort.c 1.hash.c 1.init.c 1.line.c 1.main.c 1.node.c 1.recog.c 1.tables.c
-1FILES.o = 1.finish.o 1.form.o 1.fort.o 1.hash.o 1.init.o 1.line.o 1.main.o 1.node.o 1.recog.o 1.tables.o
-
-2FILES.c = 2.dfs.c 2.dom.c 2.head.c 2.inarc.c 2.main.c 2.tree.c
-2FILES.o = 2.dfs.o 2.dom.o 2.head.o 2.inarc.o 2.main.o 2.tree.o
-
-3FILES.c = 3.branch.c 3.flow.c 3.loop.c 3.main.c 3.reach.c 3.then.c
-3FILES.o = 3.branch.o 3.flow.o 3.loop.o 3.main.o 3.reach.o 3.then.o
-
-4FILES.c = 4.brace.c 4.form.c 4.main.c 4.out.c
-4FILES.o = 4.brace.o 4.form.o 4.main.o 4.out.o
-
-all:   structure beautify
-
-cp:    structure beautify
-       cp structure /usr/lib/struct
-       rm structure
-       cp beautify /usr/lib/struct
-       rm beautify
-       rm *.o y.tab.h beauty.c
-
-cmp:   beautify structure
-       cmp beautify /usr/lib/struct/beautify
-       cmp structure /usr/lib/struct/structure
-       rm beautify structure *.o y.tab.h beauty.c
-
-structure: main.o $(0FILES.o) $(1FILES.o) $(2FILES.o) $(3FILES.o) $(4FILES.o)
-       cc -o structure -i -n main.o 0.*.o 1.*.o 2.*.o 3.*.o 4.*.o 
-
-beautify:      beauty.o tree.o lextab.o bdef.o
-       cc -n -s -O beauty.o tree.o lextab.o bdef.o -o beautify -lln
-
-lint:
-       lint $(0FILES.c) $(1FILES.c) $(2FILES.c) $(3FILES.c) $(4FILES.c) main.c
-
-main.o $(0FILES.o) $(1FILES.o) $(2FILES.o) $(3FILES.o) $(4FILES.o): def.h
-
-$(1FILES.o): 1.defs.h 1.incl.h
-$(2FILES.o): 2.def.h
-$(3FILES.o): 3.def.h
-$(4FILES.o): 4.def.h
-
-lextab.o tree.o: y.tab.h
-
-y.tab.h: beauty.y
-
-lextab.o tree.o beauty.y: b.h
-
-y.tab.h:       beauty.c
diff --git a/usr/src/cmd/struct/struct b/usr/src/cmd/struct/struct
new file mode 100755 (executable)
index 0000000..69d2383
--- /dev/null
@@ -0,0 +1,19 @@
+trap "rm -f /tmp/struct*$$" 0 1 2 3 13 15
+files=no
+for i
+do
+       case $i in
+       -*)     ;;
+       *)      files=yes
+       esac
+done
+
+case $files in
+yes)
+       /usr/lib/struct/structure $* >/tmp/struct$$
+       ;;
+no)
+       cat >/tmp/structin$$
+       /usr/lib/struct/structure /tmp/structin$$ $* >/tmp/struct$$
+esac &&
+       /usr/lib/struct/beautify</tmp/struct$$
diff --git a/usr/src/cmd/struct/y.tab.h b/usr/src/cmd/struct/y.tab.h
new file mode 100644 (file)
index 0000000..3f940cd
--- /dev/null
@@ -0,0 +1,25 @@
+# define xxif 300
+# define xxelse 301
+# define xxwhile 302
+# define xxrept 303
+# define xxdo 304
+# define xxrb 305
+# define xxpred 306
+# define xxident 307
+# define xxle 308
+# define xxge 309
+# define xxne 310
+# define xxnum 311
+# define xxcom 312
+# define xxstring 313
+# define xxexplist 314
+# define xxidpar 315
+# define xxelseif 316
+# define xxlb 318
+# define xxend 319
+# define xxcase 320
+# define xxswitch 321
+# define xxuntil 322
+# define xxdefault 323
+# define xxeq 324
+# define xxuminus 281
index 11ca6fe..58f8e71 100644 (file)
@@ -4,13 +4,11 @@
 struct passwd *pwd,*getpwnam();
 char   *crypt();
 char   *getpass();
 struct passwd *pwd,*getpwnam();
 char   *crypt();
 char   *getpass();
-char   **environ;
 
 main(argc,argv)
 int    argc;
 char   **argv;
 {
 
 main(argc,argv)
 int    argc;
 char   **argv;
 {
-       register char **p;
        char *nptr;
        char *password;
        int badsw = 0;
        char *nptr;
        char *password;
        int badsw = 0;
@@ -38,12 +36,6 @@ ok:
        setuid(pwd->pw_uid);
        if (pwd->pw_shell && *pwd->pw_shell)
                shell = pwd->pw_shell;
        setuid(pwd->pw_uid);
        if (pwd->pw_shell && *pwd->pw_shell)
                shell = pwd->pw_shell;
-       for (p=environ; *p; p++) {
-               if (strncmp("PS1=", *p, 4) == 0) {
-                       *p = "PS1=# ";
-                       break;
-               }
-       }
        execl(shell, "su", 0);
        printf("No shell\n");
        exit(3);
        execl(shell, "su", 0);
        printf("No shell\n");
        exit(3);
index 19ed331..030ca85 100644 (file)
@@ -59,6 +59,7 @@ int argc; char **argv;
 {
        struct sgttyb tb;
        int type;
 {
        struct sgttyb tb;
        int type;
+       char *getenv();
 
        type=0;
        if (argc>=2 && strcmp(argv[1],"-n")==0) {
 
        type=0;
        if (argc>=2 && strcmp(argv[1],"-n")==0) {
@@ -66,6 +67,8 @@ int argc; char **argv;
        }
        if (argc>=2) {
                type=syslook(argv[1]);
        }
        if (argc>=2) {
                type=syslook(argv[1]);
+       } else {
+               type=syslook(getenv("TERM"));
        }
 
        switch(type) {
        }
 
        switch(type) {
diff --git a/usr/src/cmd/tabs4.sh b/usr/src/cmd/tabs4.sh
new file mode 100755 (executable)
index 0000000..8296947
--- /dev/null
@@ -0,0 +1,3 @@
+cat /usr/pub/tabclr
+cat /usr/pub/marg8
+cat /usr/pub/tabs4
diff --git a/usr/src/cmd/tabs8.sh b/usr/src/cmd/tabs8.sh
new file mode 100755 (executable)
index 0000000..476aa53
--- /dev/null
@@ -0,0 +1,2 @@
+cat /usr/pub/tabclr
+cat /usr/pub/tabs
index 974824c..b5e5aa9 100644 (file)
@@ -6,8 +6,6 @@
  *     + means nth line from beginning
  *     type 'b' means tail n blocks, not lines
  *     type 'c' means tail n characters
  *     + means nth line from beginning
  *     type 'b' means tail n blocks, not lines
  *     type 'c' means tail n characters
- *     Type 'r' means in lines in reverse order from end
- *      (for -r, default is entire buffer )
 */
 #include       <sys/types.h>
 #include       <sys/stat.h>
 */
 #include       <sys/types.h>
 #include       <sys/stat.h>
@@ -21,9 +19,10 @@ main(argc,argv)
 char **argv;
 {
        long n,di;
 char **argv;
 {
        long n,di;
+       int fromend;
        register i,j,k;
        char *p;
        register i,j,k;
        char *p;
-       int partial,piped,bylines,bkwds,fromend,lastnl;
+       int partial,piped,bylines;
        char *arg;
        lseek(0,(long)0,1);
        piped = errno==ESPIPE;
        char *arg;
        lseek(0,(long)0,1);
        piped = errno==ESPIPE;
@@ -35,6 +34,8 @@ char **argv;
        }
        fromend = *arg=='-';
        arg++;
        }
        fromend = *arg=='-';
        arg++;
+       if(!digit(*arg))
+               goto errcom;
        n = 0;
        while(digit(*arg))
                n = n*10 + *arg++ - '0';
        n = 0;
        while(digit(*arg))
                n = n*10 + *arg++ - '0';
@@ -49,17 +50,13 @@ char **argv;
                        exit(1);
                }
        }
                        exit(1);
                }
        }
-       bylines = 0; bkwds = 0;
+       bylines = 0;
        switch(*arg) {
        case 'b':
                n <<= 9;
                break;
        case 'c':
                break;
        switch(*arg) {
        case 'b':
                n <<= 9;
                break;
        case 'c':
                break;
-       case 'r':
-               if(n==0) n = LBIN;
-               bkwds = 1; fromend = 1; bylines = 1;
-               break;
        case '\0':
        case 'l':
                bylines = 1;
        case '\0':
        case 'l':
                bylines = 1;
@@ -97,7 +94,6 @@ char **argv;
                else
                        lseek(0,n,0);
        }
                else
                        lseek(0,n,0);
        }
-copy:
        while((i=read(0,bin,512))>0)
                write(1,bin,i);
        exit(0);
        while((i=read(0,bin,512))>0)
                write(1,bin,i);
        exit(0);
@@ -108,11 +104,9 @@ keep:
        if(n<=0) exit(0);
        if(!piped) {
                fstat(0,&statb);
        if(n<=0) exit(0);
        if(!piped) {
                fstat(0,&statb);
-               di = !bylines? n: LBIN-1;
+               di = !bylines&&n<LBIN?n:LBIN-1;
                if(statb.st_size > di)
                        lseek(0,-di,2);
                if(statb.st_size > di)
                        lseek(0,-di,2);
-               if(!bylines)
-                       goto copy;
        }
        partial = 1;
        for(;;) {
        }
        partial = 1;
        for(;;) {
@@ -134,33 +128,18 @@ brka:
                    i-n+LBIN;
                k--;
        } else {
                    i-n+LBIN;
                k--;
        } else {
-               if(bkwds && bin[i==0?LBIN-1:i-1]!='\n'){        /* force trailing newline */
-                       bin[i]='\n';
-                       if(++i>=LBIN) {i = 0; partial = 0;}
-               }
                k = i;
                j = 0;
                do {
                k = i;
                j = 0;
                do {
-                       lastnl = k;
                        do {
                                if(--k<0) {
                        do {
                                if(--k<0) {
-                                       if(partial) {
-                                               if(bkwds) write(1,bin,lastnl+1);
+                                       if(partial)
                                                goto brkb;
                                                goto brkb;
-                                       }
                                        k = LBIN -1;
                                }
                        } while(bin[k]!='\n'&&k!=i);
                                        k = LBIN -1;
                                }
                        } while(bin[k]!='\n'&&k!=i);
-                       if(bkwds && j>0){
-                               if(k<lastnl) write(1,&bin[k+1],lastnl-k);
-                               else {
-                                       write(1,&bin[k+1],LBIN-k-1);
-                                       write(1,bin,lastnl+1);
-                               }
-                       }
                } while(j++<n&&k!=i);
 brkb:
                } while(j++<n&&k!=i);
 brkb:
-               if(bkwds) exit(0);
                if(k==i) do {
                        if(++k>=LBIN)
                                k = 0;
                if(k==i) do {
                        if(++k>=LBIN)
                                k = 0;
@@ -174,7 +153,7 @@ brkb:
        }
        exit(0);
 errcom:
        }
        exit(0);
 errcom:
-       write(2,"usage: tail +\b_n[lbcr] [file]\n",30);
+       write(2,"usage: tail +\b_n[lbc] [file]\n",29);
        exit(1);
 }
 
        exit(1);
 }
 
diff --git a/usr/src/cmd/tar.c b/usr/src/cmd/tar.c
new file mode 100644 (file)
index 0000000..e24f4fe
--- /dev/null
@@ -0,0 +1,918 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/dir.h>
+#include <signal.h>
+
+char   *sprintf();
+char   *strcat();
+daddr_t        bsrch();
+#define TBLOCK 512
+#define NBLOCK 20
+#define NAMSIZ 100
+union hblock {
+       char dummy[TBLOCK];
+       struct header {
+               char name[NAMSIZ];
+               char mode[8];
+               char uid[8];
+               char gid[8];
+               char size[12];
+               char mtime[12];
+               char chksum[8];
+               char linkflag;
+               char linkname[NAMSIZ];
+       } dbuf;
+} dblock, tbuf[NBLOCK];
+
+struct linkbuf {
+       ino_t   inum;
+       dev_t   devnum;
+       int     count;
+       char    pathname[NAMSIZ];
+       struct  linkbuf *nextp;
+} *ihead;
+
+struct stat stbuf;
+
+int    rflag, xflag, vflag, tflag, mt, cflag, mflag;
+int    term, chksum, wflag, recno, first, linkerrok;
+int    freemem = 1;
+int    nblock = 1;
+
+daddr_t        low;
+daddr_t        high;
+
+FILE   *tfile;
+char   tname[] = "/tmp/tarXXXXXX";
+
+
+char   *usefile;
+char   magtape[]       = "/dev/mt1";
+
+char   *malloc();
+
+main(argc, argv)
+int    argc;
+char   *argv[];
+{
+       char *cp;
+       int onintr(), onquit(), onhup(), onterm();
+
+       if (argc < 2)
+               usage();
+
+       tfile = NULL;
+       usefile =  magtape;
+       argv[argc] = 0;
+       argv++;
+       for (cp = *argv++; *cp; cp++) 
+               switch(*cp) {
+               case 'f':
+                       usefile = *argv++;
+                       break;
+               case 'c':
+                       cflag++;
+                       rflag++;
+                       break;
+               case 'u':
+                       mktemp(tname);
+                       if ((tfile = fopen(tname, "w")) == NULL) {
+                               fprintf(stderr, "Tar: cannot create temporary file (%s)\n", tname);
+                               done(1);
+                       }
+                       fprintf(tfile, "!!!!!/!/!/!/!/!/!/! 000\n");
+                       /* FALL THROUGH */
+               case 'r':
+                       rflag++;
+                       if (nblock != 1) {
+noupdate:
+                               fprintf(stderr, "Blocked tapes cannot be updated (yet)\n");
+                               done(1);
+                       }
+                       break;
+               case 'v':
+                       vflag++;
+                       break;
+               case 'w':
+                       wflag++;
+                       break;
+               case 'x':
+                       xflag++;
+                       break;
+               case 't':
+                       tflag++;
+                       break;
+               case 'm':
+                       mflag++;
+                       break;
+               case '-':
+                       break;
+               case '0':
+               case '1':
+                       magtape[7] = *cp;
+                       usefile = magtape;
+                       break;
+               case 'b':
+                       nblock = atoi(*argv++);
+                       if (nblock > NBLOCK || nblock <= 0) {
+                               fprintf(stderr, "Invalid blocksize. (Max %d)\n", NBLOCK);
+                               done(1);
+                       }
+                       if (rflag && !cflag)
+                               goto noupdate;
+                       break;
+               case 'l':
+                       linkerrok++;
+                       break;
+               default:
+                       fprintf(stderr, "tar: %c: unknown option\n", *cp);
+                       usage();
+               }
+
+       if (rflag) {
+               if (cflag && tfile != NULL) {
+                       usage();
+                       done(1);
+               }
+               if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
+                       signal(SIGINT, onintr);
+               if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
+                       signal(SIGHUP, onhup);
+               if (signal(SIGQUIT, SIG_IGN) != SIG_IGN)
+                       signal(SIGQUIT, onquit);
+/*
+               if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
+                       signal(SIGTERM, onterm);
+*/
+               if (strcmp(usefile, "-") == 0) {
+                       if (cflag == 0) {
+                               fprintf(stderr, "Can only create standard output archives\n");
+                               done(1);
+                       }
+                       mt = dup(1);
+               }
+               else if ((mt = open(usefile, 2)) < 0) {
+                       if (cflag == 0 || (mt =  creat(usefile, 0666)) < 0) {
+                               fprintf(stderr, "tar: cannot open %s\n", usefile);
+                               done(1);
+                       }
+               }
+               dorep(argv);
+       }
+       else if (xflag)  {
+               if (strcmp(usefile, "-") == 0)
+                       mt = dup(0);
+               else if ((mt = open(usefile, 0)) < 0) {
+                       fprintf(stderr, "tar: cannot open %s\n", usefile);
+                       done(1);
+               }
+               doxtract(argv);
+       }
+       else if (tflag) {
+               if ((mt = open(usefile, 0)) < 0) {
+                       fprintf(stderr, "tar: cannot open %s\n", usefile);
+                       done(1);
+               }
+               dotable();
+       }
+       else
+               usage();
+       done(0);
+}
+
+usage()
+{
+       fprintf(stderr, "tar: usage  tar -{txru}[cvfblm] [tapefile] [blocksize] file1 file2...\n");
+       done(1);
+}
+
+dorep(argv)
+char   *argv[];
+{
+       register char *cp, *cp2;
+       char wdir[60];
+
+       if (!cflag) {
+               getdir();
+               do {
+                       passtape();
+                       getdir();
+               } while (!endtape());
+               if (tfile != NULL) {
+                       char buf[200];
+
+                       strcat(buf, "sort +0 -1 +1nr ");
+                       strcat(buf, tname);
+                       strcat(buf, " -o ");
+                       strcat(buf, tname);
+                       sprintf(buf, "sort +0 -1 +1nr %s -o %s; awk '$1 != prev {print; prev=$1}' %s >%sX;mv %sX %s",
+                               tname, tname, tname, tname, tname, tname);
+                       fflush(tfile);
+                       system(buf);
+                       freopen(tname, "r", tfile);
+                       fstat(fileno(tfile), &stbuf);
+                       high = stbuf.st_size;
+               }
+       }
+
+       getwdir(wdir);
+       while (*argv && ! term) {
+               cp2 = *argv;
+               for (cp = *argv; *cp; cp++)
+                       if (*cp == '/')
+                               cp2 = cp;
+               if (cp2 != *argv) {
+                       *cp2 = '\0';
+                       chdir(*argv);
+                       *cp2 = '/';
+                       cp2++;
+               }
+               putfile(*argv++, cp2);
+               chdir(wdir);
+       }
+       putempty();
+       putempty();
+       flushtape();
+       if (linkerrok == 1)
+               for (; ihead != NULL; ihead = ihead->nextp)
+                       if (ihead->count != 0)
+                               fprintf(stderr, "Missing links to %s\n", ihead->pathname);
+}
+
+endtape()
+{
+       if (dblock.dbuf.name[0] == '\0') {
+               backtape();
+               return(1);
+       }
+       else
+               return(0);
+}
+
+getdir()
+{
+       register struct stat *sp;
+       int i;
+
+       readtape( (char *) &dblock);
+       if (dblock.dbuf.name[0] == '\0')
+               return;
+       sp = &stbuf;
+       sscanf(dblock.dbuf.mode, "%o", &i);
+       sp->st_mode = i;
+       sscanf(dblock.dbuf.uid, "%o", &i);
+       sp->st_uid = i;
+       sscanf(dblock.dbuf.gid, "%o", &i);
+       sp->st_gid = i;
+       sscanf(dblock.dbuf.size, "%lo", &sp->st_size);
+       sscanf(dblock.dbuf.mtime, "%lo", &sp->st_mtime);
+       sscanf(dblock.dbuf.chksum, "%o", &chksum);
+       if (chksum != checksum()) {
+               fprintf(stderr, "directory checksum error\n");
+               done(2);
+       }
+       if (tfile != NULL)
+               fprintf(tfile, "%s %s\n", dblock.dbuf.name, dblock.dbuf.mtime);
+}
+
+passtape()
+{
+       long blocks;
+       char buf[TBLOCK];
+
+       if (dblock.dbuf.linkflag == '1')
+               return;
+       blocks = stbuf.st_size;
+       blocks += TBLOCK-1;
+       blocks /= TBLOCK;
+
+       while (blocks-- > 0)
+               readtape(buf);
+}
+
+putfile(longname, shortname)
+char *longname;
+char *shortname;
+{
+       int infile;
+       long blocks;
+       char buf[TBLOCK];
+       register char *cp, *cp2;
+       struct direct dbuf;
+       int i, j;
+
+       infile = open(shortname, 0);
+       if (infile < 0) {
+               fprintf(stderr, "tar: %s: cannot open file\n", longname);
+               return;
+       }
+
+       fstat(infile, &stbuf);
+
+       if (tfile != NULL && checkupdate(longname) == 0) {
+               close(infile);
+               return;
+       }
+       if (checkw('r', shortname) == 0) {
+               close(infile);
+               return;
+       }
+
+       if ((stbuf.st_mode & S_IFMT) == S_IFDIR) {
+               for (i = 0, cp = buf; *cp++ = longname[i++];);
+               *--cp = '/';
+               cp++;
+               i = 0;
+               chdir(shortname);
+               while (read(infile, (char *)&dbuf, sizeof(dbuf)) > 0 && !term) {
+                       if (dbuf.d_ino == 0) {
+                               i++;
+                               continue;
+                       }
+                       if (strcmp(".", dbuf.d_name) == 0 || strcmp("..", dbuf.d_name) == 0) {
+                               i++;
+                               continue;
+                       }
+                       cp2 = cp;
+                       for (j=0; j < DIRSIZ; j++)
+                               *cp2++ = dbuf.d_name[j];
+                       *cp2 = '\0';
+                       close(infile);
+                       putfile(buf, cp);
+                       infile = open(".", 0);
+                       i++;
+                       lseek(infile, (long) (sizeof(dbuf) * i), 0);
+               }
+               close(infile);
+               chdir("..");
+               return;
+       }
+       if ((stbuf.st_mode & S_IFMT) != S_IFREG) {
+               fprintf(stderr, "tar: %s is not a file. Not dumped\n", longname);
+               return;
+       }
+
+       tomodes(&stbuf);
+
+       cp2 = longname;
+       for (cp = dblock.dbuf.name, i=0; (*cp++ = *cp2++) && i < NAMSIZ; i++);
+       if (i >= NAMSIZ) {
+               fprintf(stderr, "%s: file name too long\n", longname);
+               close(infile);
+               return;
+       }
+
+       if (stbuf.st_nlink > 1) {
+               struct linkbuf *lp;
+               int found = 0;
+
+               for (lp = ihead; lp != NULL; lp = lp->nextp) {
+                       if (lp->inum == stbuf.st_ino && lp->devnum == stbuf.st_dev) {
+                               found++;
+                               break;
+                       }
+               }
+               if (found) {
+                       strcpy(dblock.dbuf.linkname, lp->pathname);
+                       dblock.dbuf.linkflag = '1';
+                       sprintf(dblock.dbuf.chksum, "%6o", checksum());
+                       writetape( (char *) &dblock);
+                       if (vflag) {
+                               fprintf(stderr, "a %s ", longname);
+                               fprintf(stderr, "link to %s\n", lp->pathname);
+                       }
+                       lp->count--;
+                       close(infile);
+                       return;
+               }
+               else {
+                       lp = (struct linkbuf *) malloc(sizeof(*lp));
+                       if (lp == NULL) {
+                               if (freemem) {
+                                       fprintf(stderr, "Out of memory. Link information lost\n");
+                                       freemem = 0;
+                               }
+                       }
+                       else {
+                               lp->nextp = ihead;
+                               ihead = lp;
+                               lp->inum = stbuf.st_ino;
+                               lp->devnum = stbuf.st_dev;
+                               lp->count = stbuf.st_nlink - 1;
+                               strcpy(lp->pathname, longname);
+                       }
+               }
+       }
+
+       blocks = (stbuf.st_size + (TBLOCK-1)) / TBLOCK;
+       if (vflag) {
+               fprintf(stderr, "a %s ", longname);
+               fprintf(stderr, "%ld blocks\n", blocks);
+       }
+       sprintf(dblock.dbuf.chksum, "%6o", checksum());
+       writetape( (char *) &dblock);
+
+       while ((i = read(infile, buf, TBLOCK)) > 0 && blocks > 0) {
+               writetape(buf);
+               blocks--;
+       }
+       close(infile);
+       if (blocks != 0 || i != 0)
+               fprintf(stderr, "%s: file changed size\n", longname);
+       while (blocks-- >  0)
+               putempty();
+}
+
+
+
+doxtract(argv)
+char   *argv[];
+{
+       long blocks, bytes;
+       char buf[TBLOCK];
+       char **cp;
+       int ofile;
+
+       for (;;) {
+               getdir();
+               if (endtape())
+                       break;
+
+               if (*argv == 0)
+                       goto gotit;
+
+               for (cp = argv; *cp; cp++)
+                       if (prefix(*cp, dblock.dbuf.name))
+                               goto gotit;
+               passtape();
+               continue;
+
+gotit:
+               if (checkw('x', dblock.dbuf.name) == 0) {
+                       passtape();
+                       continue;
+               }
+
+               checkdir(dblock.dbuf.name);
+
+               if (dblock.dbuf.linkflag == '1') {
+                       unlink(dblock.dbuf.name);
+                       if (link(dblock.dbuf.linkname, dblock.dbuf.name) < 0) {
+                               fprintf(stderr, "%s: cannot link\n", dblock.dbuf.name);
+                               continue;
+                       }
+                       if (vflag)
+                               fprintf(stderr, "%s linked to %s\n", dblock.dbuf.name, dblock.dbuf.linkname);
+                       continue;
+               }
+               if ((ofile = creat(dblock.dbuf.name, stbuf.st_mode & 07777)) < 0) {
+                       fprintf(stderr, "tar: %s - cannot create\n", dblock.dbuf.name);
+                       passtape();
+                       continue;
+               }
+
+               chown(dblock.dbuf.name, stbuf.st_uid, stbuf.st_gid);
+
+               blocks = ((bytes = stbuf.st_size) + TBLOCK-1)/TBLOCK;
+               if (vflag)
+                       fprintf(stderr, "x %s, %ld bytes, %ld tape blocks\n", dblock.dbuf.name, bytes, blocks);
+               while (blocks-- > 0) {
+                       readtape(buf);
+                       if (bytes > TBLOCK) {
+                               if (write(ofile, buf, TBLOCK) < 0) {
+                                       fprintf(stderr, "tar: %s: HELP - extract write error\n", dblock.dbuf.name);
+                                       done(2);
+                               }
+                       } else
+                               if (write(ofile, buf, (int) bytes) < 0) {
+                                       fprintf(stderr, "tar: %s: HELP - extract write error\n", dblock.dbuf.name);
+                                       done(2);
+                               }
+                       bytes -= TBLOCK;
+               }
+               close(ofile);
+               if (mflag == 0) {
+                       time_t timep[2];
+
+                       timep[0] = time(NULL);
+                       timep[1] = stbuf.st_mtime;
+                       utime(dblock.dbuf.name, timep);
+               }
+       }
+}
+
+dotable()
+{
+       for (;;) {
+               getdir();
+               if (endtape())
+                       break;
+               if (vflag)
+                       longt(&stbuf);
+               printf("%s", dblock.dbuf.name);
+               if (dblock.dbuf.linkflag == '1')
+                       printf(" linked to %s", dblock.dbuf.linkname);
+               printf("\n");
+               passtape();
+       }
+}
+
+putempty()
+{
+       char buf[TBLOCK];
+       char *cp;
+
+       for (cp = buf; cp < &buf[TBLOCK]; )
+               *cp++ = '\0';
+       writetape(buf);
+}
+
+longt(st)
+register struct stat *st;
+{
+       register char *cp;
+       char *ctime();
+
+       pmode(st);
+       printf("%3d/%1d", st->st_uid, st->st_gid);
+       printf("%7D", st->st_size);
+       cp = ctime(&st->st_mtime);
+       printf(" %-12.12s %-4.4s ", cp+4, cp+20);
+}
+
+#define        SUID    04000
+#define        SGID    02000
+#define        ROWN    0400
+#define        WOWN    0200
+#define        XOWN    0100
+#define        RGRP    040
+#define        WGRP    020
+#define        XGRP    010
+#define        ROTH    04
+#define        WOTH    02
+#define        XOTH    01
+#define        STXT    01000
+int    m1[] = { 1, ROWN, 'r', '-' };
+int    m2[] = { 1, WOWN, 'w', '-' };
+int    m3[] = { 2, SUID, 's', XOWN, 'x', '-' };
+int    m4[] = { 1, RGRP, 'r', '-' };
+int    m5[] = { 1, WGRP, 'w', '-' };
+int    m6[] = { 2, SGID, 's', XGRP, 'x', '-' };
+int    m7[] = { 1, ROTH, 'r', '-' };
+int    m8[] = { 1, WOTH, 'w', '-' };
+int    m9[] = { 2, STXT, 't', XOTH, 'x', '-' };
+
+int    *m[] = { m1, m2, m3, m4, m5, m6, m7, m8, m9};
+
+pmode(st)
+register struct stat *st;
+{
+       register int **mp;
+
+       for (mp = &m[0]; mp < &m[9];)
+               select(*mp++, st);
+}
+
+select(pairp, st)
+int *pairp;
+struct stat *st;
+{
+       register int n, *ap;
+
+       ap = pairp;
+       n = *ap++;
+       while (--n>=0 && (st->st_mode&*ap++)==0)
+               ap++;
+       printf("%c", *ap);
+}
+
+checkdir(name)
+register char *name;
+{
+       register char *cp;
+       int i;
+       for (cp = name; *cp; cp++) {
+               if (*cp == '/') {
+                       *cp = '\0';
+                       if (access(name, 01) < 0) {
+                               if (fork() == 0) {
+                                       execl("/bin/mkdir", "mkdir", name, 0);
+                                       execl("/usr/bin/mkdir", "mkdir", name, 0);
+                                       fprintf(stderr, "tar: cannot find mkdir!\n");
+                                       done(0);
+                               }
+                               while (wait(&i) >= 0);
+                               chown(name, stbuf.st_uid, stbuf.st_gid);
+                       }
+                       *cp = '/';
+               }
+       }
+}
+
+onintr()
+{
+       signal(SIGINT, SIG_IGN);
+       term++;
+}
+
+onquit()
+{
+       signal(SIGQUIT, SIG_IGN);
+       term++;
+}
+
+onhup()
+{
+       signal(SIGHUP, SIG_IGN);
+       term++;
+}
+
+onterm()
+{
+       signal(SIGTERM, SIG_IGN);
+       term++;
+}
+
+tomodes(sp)
+register struct stat *sp;
+{
+       register char *cp;
+
+       for (cp = dblock.dummy; cp < &dblock.dummy[TBLOCK]; cp++)
+               *cp = '\0';
+       sprintf(dblock.dbuf.mode, "%6o ", sp->st_mode & 07777);
+       sprintf(dblock.dbuf.uid, "%6o ", sp->st_uid);
+       sprintf(dblock.dbuf.gid, "%6o ", sp->st_gid);
+       sprintf(dblock.dbuf.size, "%11lo ", sp->st_size);
+       sprintf(dblock.dbuf.mtime, "%11lo ", sp->st_mtime);
+}
+
+checksum()
+{
+       register i;
+       register char *cp;
+
+       for (cp = dblock.dbuf.chksum; cp < &dblock.dbuf.chksum[sizeof(dblock.dbuf.chksum)]; cp++)
+               *cp = ' ';
+       i = 0;
+       for (cp = dblock.dummy; cp < &dblock.dummy[TBLOCK]; cp++)
+               i += *cp;
+       return(i);
+}
+
+checkw(c, name)
+char *name;
+{
+       if (wflag) {
+               printf("%c ", c);
+               if (vflag)
+                       longt(&stbuf);
+               printf("%s: ", name);
+               if (response() == 'y'){
+                       return(1);
+               }
+               return(0);
+       }
+       return(1);
+}
+
+response()
+{
+       char c;
+
+       c = getchar();
+       if (c != '\n')
+               while (getchar() != '\n');
+       else c = 'n';
+       return(c);
+}
+
+checkupdate(arg)
+char   *arg;
+{
+       char name[100];
+       long    mtime;
+       daddr_t seekp;
+       daddr_t lookup();
+
+       rewind(tfile);
+       for (;;) {
+               if ((seekp = lookup(arg)) < 0)
+                       return(1);
+               fseek(tfile, seekp, 0);
+               fscanf(tfile, "%s %lo", name, &mtime);
+               if (stbuf.st_mtime > mtime)
+                       return(1);
+               else
+                       return(0);
+       }
+}
+
+done(n)
+{
+       unlink(tname);
+       exit(n);
+}
+
+prefix(s1, s2)
+register char *s1, *s2;
+{
+       while (*s1)
+               if (*s1++ != *s2++)
+                       return(0);
+       if (*s2)
+               return(*s2 == '/');
+       return(1);
+}
+
+getwdir(s)
+char *s;
+{
+       int i;
+       int     pipdes[2];
+
+       pipe(pipdes);
+       if ((i = fork()) == 0) {
+               close(1);
+               dup(pipdes[1]);
+               execl("/bin/pwd", "pwd", 0);
+               execl("/usr/bin/pwd", "pwd", 0);
+               fprintf(stderr, "pwd failed!\n");
+               printf("/\n");
+               exit(1);
+       }
+       while (wait((int *)NULL) != -1)
+                       ;
+       read(pipdes[0], s, 50);
+       while(*s != '\n')
+               s++;
+       *s = '\0';
+       close(pipdes[0]);
+       close(pipdes[1]);
+}
+
+#define        N       200
+int    njab;
+daddr_t
+lookup(s)
+char *s;
+{
+       register i;
+       daddr_t a;
+
+       for(i=0; s[i]; i++)
+               if(s[i] == ' ')
+                       break;
+       a = bsrch(s, i, low, high);
+       return(a);
+}
+
+daddr_t
+bsrch(s, n, l, h)
+daddr_t l, h;
+char *s;
+{
+       register i, j;
+       char b[N];
+       daddr_t m, m1;
+
+       njab = 0;
+
+loop:
+       if(l >= h)
+               return(-1L);
+       m = l + (h-l)/2 - N/2;
+       if(m < l)
+               m = l;
+       fseek(tfile, m, 0);
+       fread(b, 1, N, tfile);
+       njab++;
+       for(i=0; i<N; i++) {
+               if(b[i] == '\n')
+                       break;
+               m++;
+       }
+       if(m >= h)
+               return(-1L);
+       m1 = m;
+       j = i;
+       for(i++; i<N; i++) {
+               m1++;
+               if(b[i] == '\n')
+                       break;
+       }
+       i = cmp(b+j, s, n);
+       if(i < 0) {
+               h = m;
+               goto loop;
+       }
+       if(i > 0) {
+               l = m1;
+               goto loop;
+       }
+       return(m);
+}
+
+cmp(b, s, n)
+char *b, *s;
+{
+       register i;
+
+       if(b[0] != '\n')
+               exit(2);
+       for(i=0; i<n; i++) {
+               if(b[i+1] > s[i])
+                       return(-1);
+               if(b[i+1] < s[i])
+                       return(1);
+       }
+       return(b[i+1] == ' '? 0 : -1);
+}
+
+readtape(buffer)
+char *buffer;
+{
+       int i, j;
+
+       if (recno >= nblock || first == 0) {
+               if (first == 0 && nblock == 1)
+                       j = NBLOCK;
+               else
+                       j = nblock;
+               if ((i = read(mt, tbuf, TBLOCK*j)) < 0) {
+                       fprintf(stderr, "Tar: tape read error\n");
+                       done(3);
+               }
+               if (first == 0) {
+                       if ((i % TBLOCK) != 0) {
+                               fprintf(stderr, "Tar: tape blocksize error\n");
+                               done(3);
+                       }
+                       i /= TBLOCK;
+                       if (rflag && i != 1) {
+                               fprintf(stderr, "Tar: Cannot update blocked tapes (yet)\n");
+                               done(4);
+                       }
+                       if (i != nblock && i != 1) {
+                               fprintf(stderr, "Tar: blocksize = %d\n", i);
+                               nblock = i;
+                       }
+               }
+               recno = 0;
+       }
+       first = 1;
+       copy(buffer, &tbuf[recno++]);
+       return(TBLOCK);
+}
+
+writetape(buffer)
+char *buffer;
+{
+       first = 1;
+       if (recno >= nblock) {
+               if (write(mt, tbuf, TBLOCK*nblock) < 0) {
+                       fprintf(stderr, "Tar: tape write error\n");
+                       done(2);
+               }
+               recno = 0;
+       }
+       copy(&tbuf[recno++], buffer);
+       if (recno >= nblock) {
+               if (write(mt, tbuf, TBLOCK*nblock) < 0) {
+                       fprintf(stderr, "Tar: tape write error\n");
+                       done(2);
+               }
+               recno = 0;
+       }
+       return(TBLOCK);
+}
+
+backtape()
+{
+       lseek(mt, (long) -TBLOCK, 1);
+       if (recno >= nblock) {
+               recno = nblock - 1;
+               if (read(mt, tbuf, TBLOCK*nblock) < 0) {
+                       fprintf(stderr, "Tar: tape read error after seek\n");
+                       done(4);
+               }
+               lseek(mt, (long) -TBLOCK, 1);
+       }
+}
+
+flushtape()
+{
+       write(mt, tbuf, TBLOCK*nblock);
+}
+
+copy(to, from)
+register char *to, *from;
+{
+       register i;
+
+       i = TBLOCK;
+       do {
+               *to++ = *from++;
+       } while (--i);
+}
diff --git a/usr/src/cmd/tar/makefile b/usr/src/cmd/tar/makefile
deleted file mode 100644 (file)
index 63d4413..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-V6LIB=/usr/src/libc/v6
-CFLAGS=-O
-
-all:   tar
-
-cp:    all
-       cp tar /bin
-       rm -f tar *.o
-
-cmp:   all
-       cmp tar /bin/tar
-       rm -f tar *.o
-
-tar:   tar.c
-       cc -i -s -O tar.c -o tar
-
-v6tar: tar.o access.o chown.o execl.o ftime.o gtty.o lseek.o stat.o syscall.o time.o
-       cc -i -s -O *.o -o v6tar
-
-access.o:      $(V6LIB)/access.c
-       cc -c -O $?
-
-chown.o:       $(V6LIB)/chown.c
-       cc -c -O $?
-
-execl.o:       $(V6LIB)/execl.c
-       cc -c -O $?
-
-ftime.o:       $(V6LIB)/ftime.c
-       cc -c -O $?
-
-gtty.o:        $(V6LIB)/gtty.c
-       cc -c -O $?
-
-lseek.o:       $(V6LIB)/lseek.c
-       cc -c -O $?
-
-stat.o:        $(V6LIB)/stat.c
-       cc -c -O $?
-
-syscall.o:     $(V6LIB)/syscall.s
-       cc -c -O $?
-
-time.o:        $(V6LIB)/time.s
-       cc -c -O $?
diff --git a/usr/src/cmd/tar/tar.c b/usr/src/cmd/tar/tar.c
deleted file mode 100644 (file)
index 9725252..0000000
+++ /dev/null
@@ -1,933 +0,0 @@
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/dir.h>
-#include <signal.h>
-
-char   *sprintf();
-char   *strcat();
-daddr_t        bsrch();
-#define TBLOCK 512
-#define NBLOCK 20
-#define NAMSIZ 100
-union hblock {
-       char dummy[TBLOCK];
-       struct header {
-               char name[NAMSIZ];
-               char mode[8];
-               char uid[8];
-               char gid[8];
-               char size[12];
-               char mtime[12];
-               char chksum[8];
-               char linkflag;
-               char linkname[NAMSIZ];
-       } dbuf;
-} dblock, tbuf[NBLOCK];
-
-struct linkbuf {
-       ino_t   inum;
-       dev_t   devnum;
-       int     count;
-       char    pathname[NAMSIZ];
-       struct  linkbuf *nextp;
-} *ihead;
-
-struct stat stbuf;
-
-int    rflag, xflag, vflag, tflag, mt, cflag, mflag;
-int    term, chksum, wflag, recno, first, linkerrok;
-int    freemem = 1;
-int    nblock = 1;
-
-daddr_t        low;
-daddr_t        high;
-
-FILE   *tfile;
-char   tname[] = "/tmp/tarXXXXXX";
-
-
-char   *usefile;
-char   magtape[]       = "/dev/mt1";
-
-char   *malloc();
-
-main(argc, argv)
-int    argc;
-char   *argv[];
-{
-       char *cp;
-       int onintr(), onquit(), onhup(), onterm();
-
-       if (argc < 2)
-               usage();
-
-       tfile = NULL;
-       usefile =  magtape;
-       argv[argc] = 0;
-       argv++;
-       for (cp = *argv++; *cp; cp++) 
-               switch(*cp) {
-               case 'f':
-                       usefile = *argv++;
-                       if (nblock == 1)
-                               nblock = 0;
-                       break;
-               case 'c':
-                       cflag++;
-                       rflag++;
-                       break;
-               case 'u':
-                       mktemp(tname);
-                       if ((tfile = fopen(tname, "w")) == NULL) {
-                               fprintf(stderr, "Tar: cannot create temporary file (%s)\n", tname);
-                               done(1);
-                       }
-                       fprintf(tfile, "!!!!!/!/!/!/!/!/!/! 000\n");
-                       /* FALL THROUGH */
-               case 'r':
-                       rflag++;
-                       if (nblock != 1 && cflag == 0) {
-noupdate:
-                               fprintf(stderr, "Tar: Blocked tapes cannot be updated (yet)\n");
-                               done(1);
-                       }
-                       break;
-               case 'v':
-                       vflag++;
-                       break;
-               case 'w':
-                       wflag++;
-                       break;
-               case 'x':
-                       xflag++;
-                       break;
-               case 't':
-                       tflag++;
-                       break;
-               case 'm':
-                       mflag++;
-                       break;
-               case '-':
-                       break;
-               case '0':
-               case '1':
-                       magtape[7] = *cp;
-                       usefile = magtape;
-                       break;
-               case 'b':
-                       nblock = atoi(*argv++);
-                       if (nblock > NBLOCK || nblock <= 0) {
-                               fprintf(stderr, "Invalid blocksize. (Max %d)\n", NBLOCK);
-                               done(1);
-                       }
-                       if (rflag && !cflag)
-                               goto noupdate;
-                       break;
-               case 'l':
-                       linkerrok++;
-                       break;
-               default:
-                       fprintf(stderr, "tar: %c: unknown option\n", *cp);
-                       usage();
-               }
-
-       if (rflag) {
-               if (cflag && tfile != NULL) {
-                       usage();
-                       done(1);
-               }
-               if (signal(SIGINT, SIG_IGN) != SIG_IGN)
-                       signal(SIGINT, onintr);
-               if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
-                       signal(SIGHUP, onhup);
-               if (signal(SIGQUIT, SIG_IGN) != SIG_IGN)
-                       signal(SIGQUIT, onquit);
-/*
-               if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
-                       signal(SIGTERM, onterm);
-*/
-               if (strcmp(usefile, "-") == 0) {
-                       if (cflag == 0) {
-                               fprintf(stderr, "Can only create standard output archives\n");
-                               done(1);
-                       }
-                       mt = dup(1);
-                       nblock = 1;
-               }
-               else if ((mt = open(usefile, 2)) < 0) {
-                       if (cflag == 0 || (mt =  creat(usefile, 0666)) < 0) {
-                               fprintf(stderr, "tar: cannot open %s\n", usefile);
-                               done(1);
-                       }
-               }
-               if (cflag == 0 && nblock == 0)
-                       nblock = 1;
-               dorep(argv);
-       }
-       else if (xflag)  {
-               if (strcmp(usefile, "-") == 0) {
-                       mt = dup(0);
-                       nblock = 1;
-               }
-               else if ((mt = open(usefile, 0)) < 0) {
-                       fprintf(stderr, "tar: cannot open %s\n", usefile);
-                       done(1);
-               }
-               doxtract(argv);
-       }
-       else if (tflag) {
-               if (strcmp(usefile, "-") == 0) {
-                       mt = dup(0);
-                       nblock = 1;
-               }
-               else if ((mt = open(usefile, 0)) < 0) {
-                       fprintf(stderr, "tar: cannot open %s\n", usefile);
-                       done(1);
-               }
-               dotable();
-       }
-       else
-               usage();
-       done(0);
-}
-
-usage()
-{
-       fprintf(stderr, "tar: usage  tar -{txru}[cvfblm] [tapefile] [blocksize] file1 file2...\n");
-       done(1);
-}
-
-dorep(argv)
-char   *argv[];
-{
-       register char *cp, *cp2;
-       char wdir[60];
-
-       if (!cflag) {
-               getdir();
-               do {
-                       passtape();
-                       if (term)
-                               done(0);
-                       getdir();
-               } while (!endtape());
-               if (tfile != NULL) {
-                       char buf[200];
-
-                       strcat(buf, "sort +0 -1 +1nr ");
-                       strcat(buf, tname);
-                       strcat(buf, " -o ");
-                       strcat(buf, tname);
-                       sprintf(buf, "sort +0 -1 +1nr %s -o %s; awk '$1 != prev {print; prev=$1}' %s >%sX;mv %sX %s",
-                               tname, tname, tname, tname, tname, tname);
-                       fflush(tfile);
-                       system(buf);
-                       freopen(tname, "r", tfile);
-                       fstat(fileno(tfile), &stbuf);
-                       high = stbuf.st_size;
-               }
-       }
-
-       getwdir(wdir);
-       while (*argv && ! term) {
-               cp2 = *argv;
-               for (cp = *argv; *cp; cp++)
-                       if (*cp == '/')
-                               cp2 = cp;
-               if (cp2 != *argv) {
-                       *cp2 = '\0';
-                       chdir(*argv);
-                       *cp2 = '/';
-                       cp2++;
-               }
-               putfile(*argv++, cp2);
-               chdir(wdir);
-       }
-       putempty();
-       putempty();
-       flushtape();
-       if (linkerrok == 1)
-               for (; ihead != NULL; ihead = ihead->nextp)
-                       if (ihead->count != 0)
-                               fprintf(stderr, "Missing links to %s\n", ihead->pathname);
-}
-
-endtape()
-{
-       if (dblock.dbuf.name[0] == '\0') {
-               backtape();
-               return(1);
-       }
-       else
-               return(0);
-}
-
-getdir()
-{
-       register struct stat *sp;
-       int i;
-
-       readtape( (char *) &dblock);
-       if (dblock.dbuf.name[0] == '\0')
-               return;
-       sp = &stbuf;
-       sscanf(dblock.dbuf.mode, "%o", &i);
-       sp->st_mode = i;
-       sscanf(dblock.dbuf.uid, "%o", &i);
-       sp->st_uid = i;
-       sscanf(dblock.dbuf.gid, "%o", &i);
-       sp->st_gid = i;
-       sscanf(dblock.dbuf.size, "%lo", &sp->st_size);
-       sscanf(dblock.dbuf.mtime, "%lo", &sp->st_mtime);
-       sscanf(dblock.dbuf.chksum, "%o", &chksum);
-       if (chksum != checksum()) {
-               fprintf(stderr, "directory checksum error\n");
-               done(2);
-       }
-       if (tfile != NULL)
-               fprintf(tfile, "%s %s\n", dblock.dbuf.name, dblock.dbuf.mtime);
-}
-
-passtape()
-{
-       long blocks;
-       char buf[TBLOCK];
-
-       if (dblock.dbuf.linkflag == '1')
-               return;
-       blocks = stbuf.st_size;
-       blocks += TBLOCK-1;
-       blocks /= TBLOCK;
-
-       while (blocks-- > 0)
-               readtape(buf);
-}
-
-putfile(longname, shortname)
-char *longname;
-char *shortname;
-{
-       int infile;
-       long blocks;
-       char buf[TBLOCK];
-       register char *cp, *cp2;
-       struct direct dbuf;
-       int i, j;
-
-       infile = open(shortname, 0);
-       if (infile < 0) {
-               fprintf(stderr, "tar: %s: cannot open file\n", longname);
-               return;
-       }
-
-       fstat(infile, &stbuf);
-
-       if (tfile != NULL && checkupdate(longname) == 0) {
-               close(infile);
-               return;
-       }
-       if (checkw('r', longname) == 0) {
-               close(infile);
-               return;
-       }
-
-       if ((stbuf.st_mode & S_IFMT) == S_IFDIR) {
-               for (i = 0, cp = buf; *cp++ = longname[i++];);
-               *--cp = '/';
-               cp++;
-               i = 0;
-               chdir(shortname);
-               while (read(infile, (char *)&dbuf, sizeof(dbuf)) > 0 && !term) {
-                       if (dbuf.d_ino == 0) {
-                               i++;
-                               continue;
-                       }
-                       if (strcmp(".", dbuf.d_name) == 0 || strcmp("..", dbuf.d_name) == 0) {
-                               i++;
-                               continue;
-                       }
-                       cp2 = cp;
-                       for (j=0; j < DIRSIZ; j++)
-                               *cp2++ = dbuf.d_name[j];
-                       *cp2 = '\0';
-                       close(infile);
-                       putfile(buf, cp);
-                       infile = open(".", 0);
-                       i++;
-                       lseek(infile, (long) (sizeof(dbuf) * i), 0);
-               }
-               close(infile);
-               chdir("..");
-               return;
-       }
-       if ((stbuf.st_mode & S_IFMT) != S_IFREG) {
-               fprintf(stderr, "tar: %s is not a file. Not dumped\n", longname);
-               return;
-       }
-
-       tomodes(&stbuf);
-
-       cp2 = longname;
-       for (cp = dblock.dbuf.name, i=0; (*cp++ = *cp2++) && i < NAMSIZ; i++);
-       if (i >= NAMSIZ) {
-               fprintf(stderr, "%s: file name too long\n", longname);
-               close(infile);
-               return;
-       }
-
-       if (stbuf.st_nlink > 1) {
-               struct linkbuf *lp;
-               int found = 0;
-
-               for (lp = ihead; lp != NULL; lp = lp->nextp) {
-                       if (lp->inum == stbuf.st_ino && lp->devnum == stbuf.st_dev) {
-                               found++;
-                               break;
-                       }
-               }
-               if (found) {
-                       strcpy(dblock.dbuf.linkname, lp->pathname);
-                       dblock.dbuf.linkflag = '1';
-                       sprintf(dblock.dbuf.chksum, "%6o", checksum());
-                       writetape( (char *) &dblock);
-                       if (vflag) {
-                               fprintf(stderr, "a %s ", longname);
-                               fprintf(stderr, "link to %s\n", lp->pathname);
-                       }
-                       lp->count--;
-                       close(infile);
-                       return;
-               }
-               else {
-                       lp = (struct linkbuf *) malloc(sizeof(*lp));
-                       if (lp == NULL) {
-                               if (freemem) {
-                                       fprintf(stderr, "Out of memory. Link information lost\n");
-                                       freemem = 0;
-                               }
-                       }
-                       else {
-                               lp->nextp = ihead;
-                               ihead = lp;
-                               lp->inum = stbuf.st_ino;
-                               lp->devnum = stbuf.st_dev;
-                               lp->count = stbuf.st_nlink - 1;
-                               strcpy(lp->pathname, longname);
-                       }
-               }
-       }
-
-       blocks = (stbuf.st_size + (TBLOCK-1)) / TBLOCK;
-       if (vflag) {
-               fprintf(stderr, "a %s ", longname);
-               fprintf(stderr, "%ld blocks\n", blocks);
-       }
-       sprintf(dblock.dbuf.chksum, "%6o", checksum());
-       writetape( (char *) &dblock);
-
-       while ((i = read(infile, buf, TBLOCK)) > 0 && blocks > 0) {
-               writetape(buf);
-               blocks--;
-       }
-       close(infile);
-       if (blocks != 0 || i != 0)
-               fprintf(stderr, "%s: file changed size\n", longname);
-       while (blocks-- >  0)
-               putempty();
-}
-
-
-
-doxtract(argv)
-char   *argv[];
-{
-       long blocks, bytes;
-       char buf[TBLOCK];
-       char **cp;
-       int ofile;
-
-       for (;;) {
-               getdir();
-               if (endtape())
-                       break;
-
-               if (*argv == 0)
-                       goto gotit;
-
-               for (cp = argv; *cp; cp++)
-                       if (prefix(*cp, dblock.dbuf.name))
-                               goto gotit;
-               passtape();
-               continue;
-
-gotit:
-               if (checkw('x', dblock.dbuf.name) == 0) {
-                       passtape();
-                       continue;
-               }
-
-               checkdir(dblock.dbuf.name);
-
-               if (dblock.dbuf.linkflag == '1') {
-                       unlink(dblock.dbuf.name);
-                       if (link(dblock.dbuf.linkname, dblock.dbuf.name) < 0) {
-                               fprintf(stderr, "%s: cannot link\n", dblock.dbuf.name);
-                               continue;
-                       }
-                       if (vflag)
-                               fprintf(stderr, "%s linked to %s\n", dblock.dbuf.name, dblock.dbuf.linkname);
-                       continue;
-               }
-               if ((ofile = creat(dblock.dbuf.name, stbuf.st_mode & 07777)) < 0) {
-                       fprintf(stderr, "tar: %s - cannot create\n", dblock.dbuf.name);
-                       passtape();
-                       continue;
-               }
-
-               chown(dblock.dbuf.name, stbuf.st_uid, stbuf.st_gid);
-
-               blocks = ((bytes = stbuf.st_size) + TBLOCK-1)/TBLOCK;
-               if (vflag)
-                       fprintf(stderr, "x %s, %ld bytes, %ld tape blocks\n", dblock.dbuf.name, bytes, blocks);
-               while (blocks-- > 0) {
-                       readtape(buf);
-                       if (bytes > TBLOCK) {
-                               if (write(ofile, buf, TBLOCK) < 0) {
-                                       fprintf(stderr, "tar: %s: HELP - extract write error\n", dblock.dbuf.name);
-                                       done(2);
-                               }
-                       } else
-                               if (write(ofile, buf, (int) bytes) < 0) {
-                                       fprintf(stderr, "tar: %s: HELP - extract write error\n", dblock.dbuf.name);
-                                       done(2);
-                               }
-                       bytes -= TBLOCK;
-               }
-               close(ofile);
-               if (mflag == 0) {
-                       time_t timep[2];
-
-                       timep[0] = time(NULL);
-                       timep[1] = stbuf.st_mtime;
-                       utime(dblock.dbuf.name, timep);
-               }
-       }
-}
-
-dotable()
-{
-       for (;;) {
-               getdir();
-               if (endtape())
-                       break;
-               if (vflag)
-                       longt(&stbuf);
-               printf("%s", dblock.dbuf.name);
-               if (dblock.dbuf.linkflag == '1')
-                       printf(" linked to %s", dblock.dbuf.linkname);
-               printf("\n");
-               passtape();
-       }
-}
-
-putempty()
-{
-       char buf[TBLOCK];
-       char *cp;
-
-       for (cp = buf; cp < &buf[TBLOCK]; )
-               *cp++ = '\0';
-       writetape(buf);
-}
-
-longt(st)
-register struct stat *st;
-{
-       register char *cp;
-       char *ctime();
-
-       pmode(st);
-       printf("%3d/%1d", st->st_uid, st->st_gid);
-       printf("%7D", st->st_size);
-       cp = ctime(&st->st_mtime);
-       printf(" %-12.12s %-4.4s ", cp+4, cp+20);
-}
-
-#define        SUID    04000
-#define        SGID    02000
-#define        ROWN    0400
-#define        WOWN    0200
-#define        XOWN    0100
-#define        RGRP    040
-#define        WGRP    020
-#define        XGRP    010
-#define        ROTH    04
-#define        WOTH    02
-#define        XOTH    01
-#define        STXT    01000
-int    m1[] = { 1, ROWN, 'r', '-' };
-int    m2[] = { 1, WOWN, 'w', '-' };
-int    m3[] = { 2, SUID, 's', XOWN, 'x', '-' };
-int    m4[] = { 1, RGRP, 'r', '-' };
-int    m5[] = { 1, WGRP, 'w', '-' };
-int    m6[] = { 2, SGID, 's', XGRP, 'x', '-' };
-int    m7[] = { 1, ROTH, 'r', '-' };
-int    m8[] = { 1, WOTH, 'w', '-' };
-int    m9[] = { 2, STXT, 't', XOTH, 'x', '-' };
-
-int    *m[] = { m1, m2, m3, m4, m5, m6, m7, m8, m9};
-
-pmode(st)
-register struct stat *st;
-{
-       register int **mp;
-
-       for (mp = &m[0]; mp < &m[9];)
-               select(*mp++, st);
-}
-
-select(pairp, st)
-int *pairp;
-struct stat *st;
-{
-       register int n, *ap;
-
-       ap = pairp;
-       n = *ap++;
-       while (--n>=0 && (st->st_mode&*ap++)==0)
-               ap++;
-       printf("%c", *ap);
-}
-
-checkdir(name)
-register char *name;
-{
-       register char *cp;
-       int i;
-       for (cp = name; *cp; cp++) {
-               if (*cp == '/') {
-                       *cp = '\0';
-                       if (access(name, 01) < 0) {
-                               if (fork() == 0) {
-                                       execl("/bin/mkdir", "mkdir", name, 0);
-                                       execl("/usr/bin/mkdir", "mkdir", name, 0);
-                                       fprintf(stderr, "tar: cannot find mkdir!\n");
-                                       done(0);
-                               }
-                               while (wait(&i) >= 0);
-                               chown(name, stbuf.st_uid, stbuf.st_gid);
-                       }
-                       *cp = '/';
-               }
-       }
-}
-
-onintr()
-{
-       signal(SIGINT, SIG_IGN);
-       term++;
-}
-
-onquit()
-{
-       signal(SIGQUIT, SIG_IGN);
-       term++;
-}
-
-onhup()
-{
-       signal(SIGHUP, SIG_IGN);
-       term++;
-}
-
-onterm()
-{
-       signal(SIGTERM, SIG_IGN);
-       term++;
-}
-
-tomodes(sp)
-register struct stat *sp;
-{
-       register char *cp;
-
-       for (cp = dblock.dummy; cp < &dblock.dummy[TBLOCK]; cp++)
-               *cp = '\0';
-       sprintf(dblock.dbuf.mode, "%6o ", sp->st_mode & 07777);
-       sprintf(dblock.dbuf.uid, "%6o ", sp->st_uid);
-       sprintf(dblock.dbuf.gid, "%6o ", sp->st_gid);
-       sprintf(dblock.dbuf.size, "%11lo ", sp->st_size);
-       sprintf(dblock.dbuf.mtime, "%11lo ", sp->st_mtime);
-}
-
-checksum()
-{
-       register i;
-       register char *cp;
-
-       for (cp = dblock.dbuf.chksum; cp < &dblock.dbuf.chksum[sizeof(dblock.dbuf.chksum)]; cp++)
-               *cp = ' ';
-       i = 0;
-       for (cp = dblock.dummy; cp < &dblock.dummy[TBLOCK]; cp++)
-               i += *cp;
-       return(i);
-}
-
-checkw(c, name)
-char *name;
-{
-       if (wflag) {
-               printf("%c ", c);
-               if (vflag)
-                       longt(&stbuf);
-               printf("%s: ", name);
-               if (response() == 'y'){
-                       return(1);
-               }
-               return(0);
-       }
-       return(1);
-}
-
-response()
-{
-       char c;
-
-       c = getchar();
-       if (c != '\n')
-               while (getchar() != '\n');
-       else c = 'n';
-       return(c);
-}
-
-checkupdate(arg)
-char   *arg;
-{
-       char name[100];
-       long    mtime;
-       daddr_t seekp;
-       daddr_t lookup();
-
-       rewind(tfile);
-       for (;;) {
-               if ((seekp = lookup(arg)) < 0)
-                       return(1);
-               fseek(tfile, seekp, 0);
-               fscanf(tfile, "%s %lo", name, &mtime);
-               if (stbuf.st_mtime > mtime)
-                       return(1);
-               else
-                       return(0);
-       }
-}
-
-done(n)
-{
-       unlink(tname);
-       exit(n);
-}
-
-prefix(s1, s2)
-register char *s1, *s2;
-{
-       while (*s1)
-               if (*s1++ != *s2++)
-                       return(0);
-       if (*s2)
-               return(*s2 == '/');
-       return(1);
-}
-
-getwdir(s)
-char *s;
-{
-       int i;
-       int     pipdes[2];
-
-       pipe(pipdes);
-       if ((i = fork()) == 0) {
-               close(1);
-               dup(pipdes[1]);
-               execl("/bin/pwd", "pwd", 0);
-               execl("/usr/bin/pwd", "pwd", 0);
-               fprintf(stderr, "pwd failed!\n");
-               printf("/\n");
-               exit(1);
-       }
-       while (wait((int *)NULL) != -1)
-                       ;
-       read(pipdes[0], s, 50);
-       while(*s != '\n')
-               s++;
-       *s = '\0';
-       close(pipdes[0]);
-       close(pipdes[1]);
-}
-
-#define        N       200
-int    njab;
-daddr_t
-lookup(s)
-char *s;
-{
-       register i;
-       daddr_t a;
-
-       for(i=0; s[i]; i++)
-               if(s[i] == ' ')
-                       break;
-       a = bsrch(s, i, low, high);
-       return(a);
-}
-
-daddr_t
-bsrch(s, n, l, h)
-daddr_t l, h;
-char *s;
-{
-       register i, j;
-       char b[N];
-       daddr_t m, m1;
-
-       njab = 0;
-
-loop:
-       if(l >= h)
-               return(-1L);
-       m = l + (h-l)/2 - N/2;
-       if(m < l)
-               m = l;
-       fseek(tfile, m, 0);
-       fread(b, 1, N, tfile);
-       njab++;
-       for(i=0; i<N; i++) {
-               if(b[i] == '\n')
-                       break;
-               m++;
-       }
-       if(m >= h)
-               return(-1L);
-       m1 = m;
-       j = i;
-       for(i++; i<N; i++) {
-               m1++;
-               if(b[i] == '\n')
-                       break;
-       }
-       i = cmp(b+j, s, n);
-       if(i < 0) {
-               h = m;
-               goto loop;
-       }
-       if(i > 0) {
-               l = m1;
-               goto loop;
-       }
-       return(m);
-}
-
-cmp(b, s, n)
-char *b, *s;
-{
-       register i;
-
-       if(b[0] != '\n')
-               exit(2);
-       for(i=0; i<n; i++) {
-               if(b[i+1] > s[i])
-                       return(-1);
-               if(b[i+1] < s[i])
-                       return(1);
-       }
-       return(b[i+1] == ' '? 0 : -1);
-}
-
-readtape(buffer)
-char *buffer;
-{
-       int i, j;
-
-       if (recno >= nblock || first == 0) {
-               if (first == 0 && nblock == 0)
-                       j = NBLOCK;
-               else
-                       j = nblock;
-               if ((i = read(mt, tbuf, TBLOCK*j)) < 0) {
-                       fprintf(stderr, "Tar: tape read error\n");
-                       done(3);
-               }
-               if (first == 0) {
-                       if ((i % TBLOCK) != 0) {
-                               fprintf(stderr, "Tar: tape blocksize error\n");
-                               done(3);
-                       }
-                       i /= TBLOCK;
-                       if (rflag && i != 1) {
-                               fprintf(stderr, "Tar: Cannot update blocked tapes (yet)\n");
-                               done(4);
-                       }
-                       if (i != nblock && i != 1) {
-                               fprintf(stderr, "Tar: blocksize = %d\n", i);
-                               nblock = i;
-                       }
-               }
-               recno = 0;
-       }
-       first = 1;
-       copy(buffer, &tbuf[recno++]);
-       return(TBLOCK);
-}
-
-writetape(buffer)
-char *buffer;
-{
-       first = 1;
-       if (nblock == 0)
-               nblock = 1;
-       if (recno >= nblock) {
-               if (write(mt, tbuf, TBLOCK*nblock) < 0) {
-                       fprintf(stderr, "Tar: tape write error\n");
-                       done(2);
-               }
-               recno = 0;
-       }
-       copy(&tbuf[recno++], buffer);
-       if (recno >= nblock) {
-               if (write(mt, tbuf, TBLOCK*nblock) < 0) {
-                       fprintf(stderr, "Tar: tape write error\n");
-                       done(2);
-               }
-               recno = 0;
-       }
-       return(TBLOCK);
-}
-
-backtape()
-{
-       lseek(mt, (long) -TBLOCK, 1);
-       if (recno >= nblock) {
-               recno = nblock - 1;
-               if (read(mt, tbuf, TBLOCK*nblock) < 0) {
-                       fprintf(stderr, "Tar: tape read error after seek\n");
-                       done(4);
-               }
-               lseek(mt, (long) -TBLOCK, 1);
-       }
-}
-
-flushtape()
-{
-       write(mt, tbuf, TBLOCK*nblock);
-}
-
-copy(to, from)
-register char *to, *from;
-{
-       register i;
-
-       i = TBLOCK;
-       do {
-               *to++ = *from++;
-       } while (--i);
-}
diff --git a/usr/src/cmd/tbl/Makefile b/usr/src/cmd/tbl/Makefile
new file mode 100644 (file)
index 0000000..221cbf2
--- /dev/null
@@ -0,0 +1,69 @@
+CFLAGS=-O
+o = t0.o t1.o t2.o t3.o t4.o t5.o t6.o t7.o t8.o t9.o\
+    tb.o tc.o te.o tf.o tg.o ti.o tm.o ts.o tt.o tu.o tv.o
+
+tbl :  $o
+       $(CC) $o -o tbl
+$o :   t..c
+
+install: 
+       install -s tbl $(DESTDIR)/usr/bin
+
+clean :
+       rm -f *.o
+
+test:
+       sh compr sample01
+       sh compr sample02
+       sh compr sample03
+       sh compr sample04
+       sh compr sample05
+       sh compr sample06
+       sh compr sample07
+       sh compr sample08
+       sh compeq sample09
+       sh compeq sample10
+       sh compeq sample11
+       sh compr sample12
+       sh compr sample13
+       sh compr sample14
+       sh compr sample15
+       sh compr sample16
+       sh compr sample17
+       sh compr sample18
+       sh compr sample19
+       sh compr sample20
+       sh compr sample21
+       sh compr sample22
+       sh compr sample23
+       sh compms sample24
+       sh compr sample25
+       sh compr sample26
+       sh compr sample27
+       sh compr sample28
+       sh compr sample29
+       sh compr sample30
+       sh compr sample31
+       sh compr sample32
+       sh compr sample33
+       sh compms sample34
+       sh compeq sample35
+       sh compeq sample36
+       sh compnr sample37
+       sh compr sample38
+       sh compr sample39
+       sh compr sample40
+       sh compr sample41
+       sh compr sample42
+       sh compr sample43
+       sh compr sample44
+       sh compms sample45
+       sh compms sample46
+       sh compr sample47
+       sh compnr sample48
+       sh compeq /usr/doc/mel/tables
+ichk: /usr/bin/tbl
+       /usr/bin/tbl sample1 >junk1
+       cmp -s junk1 out1
+comp: tbl
+       cmp -s tbl /usr/bin/tbl
diff --git a/usr/src/cmd/tbl/makefile b/usr/src/cmd/tbl/makefile
deleted file mode 100644 (file)
index e1be8b8..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-CFLAGS=-O -n -s
-all:   tbl
-       :
-
-cp:    tbl
-       cp tbl /bin/tbl
-       rm tbl *.o
-
-cmp:   tbl
-       cmp tbl /bin/tbl
-       rm tbl *.o
-
-tbl: t0.o t1.o t2.o t3.o t4.o t5.o t6.o t7.o t8.o t9.o tb.o tc.o te.o tf.o tg.o ti.o tm.o ts.o tt.o tu.o tv.o
-       cc -i -s -O t?.o -o tbl
-t0.o t1.o t2.o t3.o t4.o t5.o t6.o t7.o t8.o t9.o tb.o tc.o te.o tf.o tg.o ti.o tm.o ts.o tt.o tu.o tv.o: t..c
index 20efa17..71ccbf7 100644 (file)
@@ -63,8 +63,9 @@ setinp(argc,argv)
 }
 swapin()
 {
 }
 swapin()
 {
-       while (sargc>0 && **sargv=='-')
+       while (sargc>0 && **sargv=='-') /* Mem fault if no test on sargc */
                {
                {
+               if (sargc<=0) return(0);
                if (match("-ms", *sargv))
                        {
                        *sargv = MACROS;
                if (match("-ms", *sargv))
                        {
                        *sargv = MACROS;
@@ -99,7 +100,7 @@ swapin()
 # ifdef unix
 badsig()
 {
 # ifdef unix
 badsig()
 {
-signal(SIGPIPE, 1);
+signal(SIGPIPE, SIG_IGN);
  exit(0);
 }
 # endif
  exit(0);
 }
 # endif
index b5c1e6e..22f71ec 100644 (file)
@@ -1,6 +1,6 @@
  /* t3.c: interpret commands affecting whole table */
 # include "t..c"
  /* t3.c: interpret commands affecting whole table */
 # include "t..c"
-struct optstr {char *optnam; int *optadd;} options [] {
+struct optstr {char *optnam; int *optadd;} options [] {
        "expand", &expflg,
        "EXPAND", &expflg,
        "center", &ctrflg,
        "expand", &expflg,
        "EXPAND", &expflg,
        "center", &ctrflg,
index 5f837c0..e868dd8 100644 (file)
@@ -68,7 +68,7 @@ for(c=0; c<ncol; c++)
        {
        s = table[nl][c].col;
        if (s==0) continue;
        {
        s = table[nl][c].col;
        if (s==0) continue;
-       chfont |= (font[stynum[nl]][c]);
+       chfont |= (int)(font[stynum[nl]][c]);
        if (point(s) ) continue;
        lf=prev(nl);
        if (lf>=0 && vspen(table[lf][c].col))
        if (point(s) ) continue;
        lf=prev(nl);
        if (lf>=0 && vspen(table[lf][c].col))
index cebfea0..be2ef07 100644 (file)
@@ -411,7 +411,7 @@ getch(){
        return(*ap++);
 }
 
        return(*ap++);
 }
 
-char *asctab[128] {
+char *asctab[128] {
 "\0",  /*blank*/
 "h",   /*h*/
 "t",   /*t*/
 "\0",  /*blank*/
 "h",   /*h*/
 "t",   /*t*/
diff --git a/usr/src/cmd/tp/Makefile b/usr/src/cmd/tp/Makefile
new file mode 100644 (file)
index 0000000..f40817c
--- /dev/null
@@ -0,0 +1,14 @@
+CFLAGS=-O
+h = tp.h
+o  = tp0.o tp1.o tp2.o tp3.o
+
+tp :   $o
+       $(CC) -o tp $o
+
+$o :   $h
+
+install :
+       install -s tp $(DESTDIR)/bin
+
+clean : 
+       rm -f *.o
diff --git a/usr/src/cmd/tp/makefile b/usr/src/cmd/tp/makefile
deleted file mode 100644 (file)
index 296ef1e..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-CFLAGS=-n -s -O
-
-all:   tp
-       rm *.o
-
-cp:    tp
-       cp tp /bin/tp
-       rm *.o tp
-
-cmp:   tp
-       cmp tp /bin/tp
-       rm *.o tp
-
-tp:    tp0.o tp1.o tp2.o tp3.o
-       cc $(CFLAGS) tp0.o tp1.o tp2.o tp3.o -o tp
-
-tp0.c tp1.c tp2.c tp3.c: tp.h
index 72b7090..09197a4 100644 (file)
@@ -122,7 +122,8 @@ wrdir()
                        swab((char *)&ndirent, (char *)&tpentry[TPB-1].cksum, sizeof(ndirent));
                else
                        tpentry[TPB-1].cksum = ndirent;
                        swab((char *)&ndirent, (char *)&tpentry[TPB-1].cksum, sizeof(ndirent));
                else
                        tpentry[TPB-1].cksum = ndirent;
-       }
+       } else
+               printf("\7\7\7Warning: cannot read prototype boot block.\n");
        dptr = &dir[0];
        count = ndirent;
        for (;;) {
        dptr = &dir[0];
        count = ndirent;
        for (;;) {
diff --git a/usr/src/cmd/troff/Makefile b/usr/src/cmd/troff/Makefile
new file mode 100644 (file)
index 0000000..9e3161a
--- /dev/null
@@ -0,0 +1,16 @@
+all : troff nroff terms
+troff  : 
+       make -f Maketroff clean
+       make -f Maketroff CC=$(CC)
+nroff  :
+       make -f Makenroff clean
+       make -f Makenroff CC=$(CC)
+terms:
+       cd term; make DESTDIR=$(DESTDIR)
+clean  :
+       rm -f *.o
+       cd term; make clean
+install :
+       install -s troff $(DESTDIR)/usr/bin
+       install -s nroff $(DESTDIR)/usr/bin
+       cd term; make install DESTDIR=$(DESTDIR)
diff --git a/usr/src/cmd/troff/Makenroff b/usr/src/cmd/troff/Makenroff
new file mode 100644 (file)
index 0000000..6e61105
--- /dev/null
@@ -0,0 +1,25 @@
+CFLAGS = -O -DNROFF
+c = ni.o nii.o n1.o n2.o n3.o n4.o n5.o n6.o n7.o n8.o n9.o n10.o
+s = hytab.o ntab.o suftab.o
+nroff : $c $s
+       $(CC) -o nroff  $s $c  
+hytab.o : hytab.c
+       cc -S hytab.c
+       ../as/:rofix hytab.s
+       as -o hytab.o hytab.s
+       rm hytab.s
+ntab.o: ntab.c
+       cc -S ntab.c
+       ../as/:rofix ntab.s
+       as -o ntab.o ntab.s
+       rm ntab.s
+suftab.o: suftab.c
+       cc -S suftab.c
+       ../as/:rofix suftab.s
+       as -o suftab.o suftab.s
+       rm suftab.s
+
+install :
+       install -s nroff /usr/bin
+clean :
+       rm -f *.o
diff --git a/usr/src/cmd/troff/Maketroff b/usr/src/cmd/troff/Maketroff
new file mode 100644 (file)
index 0000000..176623b
--- /dev/null
@@ -0,0 +1,26 @@
+CFLAGS = -O
+c = ni.o nii.o n1.o n2.o n3.o n4.o n5.o t6.o n7.o n8.o n9.o t10.o
+s = hytab.o suftab.o tab3.o
+troff : $c $s
+       $(CC) -o troff $s $c  
+hytab.o : hytab.c
+       cc -S hytab.c
+       ../as/:rofix hytab.s
+       as -o hytab.o hytab.s
+       rm hytab.s
+suftab.o: suftab.c
+       cc -S suftab.c
+       ../as/:rofix suftab.s
+       as -o suftab.o suftab.s
+       rm suftab.s
+tab3.o: tab3.c
+       cc -S tab3.c
+       :       ../as/:rofix tab3.s     ;: ".fp" writes over the font tables
+       as -o tab3.o tab3.s
+       rm tab3.s
+
+install :
+       install -s troff /usr/bin
+
+clean :
+       rm -f *.o
diff --git a/usr/src/cmd/troff/font/ftBC.n b/usr/src/cmd/troff/font/ftBC.n
new file mode 100644 (file)
index 0000000..71a7309
--- /dev/null
@@ -0,0 +1,102 @@
+13
+8
+13
+20
+7
+7
+9
+11
+13
+13
+10
+9
+7
+13
+12
+13
+36
+11
+13
+18
+12
+7
+13
+7
+13
+19
+8
+19
+11
+11
+19
+13
+14
+7
+13
+19
+7
+19
+12
+19
+17
+14
+17
+17
+18
+24
+13
+16
+17
+8
+15
+16
+15
+13
+13
+17
+16
+15
+14
+13
+15
+16
+23
+13
+17
+15
+15
+15
+15
+15
+15
+15
+15
+15
+15
+15
+14
+27
+17
+17
+18
+15
+26
+26
+8
+8
+12
+12
+13
+17
+27
+20
+11
+27
+11
+27
+17
+10
+2
+20
+27
+15
diff --git a/usr/src/cmd/troff/font/ftC.n b/usr/src/cmd/troff/font/ftC.n
new file mode 100644 (file)
index 0000000..b6748e4
--- /dev/null
@@ -0,0 +1,102 @@
+14
+12
+14
+22
+8
+8
+12
+14
+15
+15
+13
+11
+8
+14
+14
+15
+36
+8
+14
+18
+14
+8
+14
+8
+15
+24
+10
+24
+14
+10
+20
+15
+18
+8
+14
+24
+8
+23
+14
+24
+18
+17
+18
+17
+18
+22
+15
+17
+18
+8
+16
+17
+17
+15
+15
+17
+17
+17
+17
+15
+16
+19
+24
+13
+17
+17
+16
+16
+16
+16
+16
+16
+16
+16
+16
+16
+14
+27
+18
+18
+20
+0
+19
+18
+11
+11
+10
+10
+15
+19
+27
+0
+8
+27
+8
+27
+14
+9
+5
+0
+36
+16
diff --git a/usr/src/cmd/troff/font/ftCW.n b/usr/src/cmd/troff/font/ftCW.n
new file mode 100644 (file)
index 0000000..a383b9c
--- /dev/null
@@ -0,0 +1,102 @@
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
+33
diff --git a/usr/src/cmd/troff/font/ftGR.n b/usr/src/cmd/troff/font/ftGR.n
new file mode 100644 (file)
index 0000000..fe41535
--- /dev/null
@@ -0,0 +1,102 @@
+23
+17
+20
+24
+21
+12
+17
+24
+19
+25
+23
+24
+18
+19
+21
+21
+0
+14
+23
+38
+18
+10
+17
+10
+19
+19
+24
+16
+15
+15
+24
+21
+0
+10
+21
+0
+10
+20
+24
+0
+30
+25
+26
+23
+30
+33
+28
+29
+24
+16
+25
+28
+21
+27
+25
+28
+26
+27
+33
+30
+29
+23
+24
+20
+29
+29
+20
+20
+0
+0
+0
+0
+0
+0
+0
+20
+0
+17
+30
+29
+34
+20
+17
+20
+16
+16
+28
+0
+0
+20
+20
+0
+11
+0
+0
+0
+20
+10
+0
+0
+0
+20
diff --git a/usr/src/cmd/troff/font/ftR.n b/usr/src/cmd/troff/font/ftR.n
new file mode 100644 (file)
index 0000000..0a654c9
--- /dev/null
@@ -0,0 +1,102 @@
+21
+12
+21
+32
+10
+10
+17
+15
+20
+20
+20
+13
+9
+21
+20
+19
+36
+12
+17
+18
+16
+12
+18
+12
+20
+29
+14
+29
+20
+13
+26
+19
+17
+10
+18
+29
+12
+28
+18
+29
+27
+24
+27
+29
+29
+35
+24
+27
+30
+13
+22
+26
+27
+24
+23
+30
+23
+20
+27
+23
+28
+29
+36
+16
+29
+28
+19
+19
+19
+19
+19
+19
+19
+19
+19
+19
+16
+36
+21
+21
+24
+19
+32
+32
+16
+16
+14
+14
+15
+20
+36
+20
+10
+36
+12
+27
+20
+8
+2
+20
+27
+19
diff --git a/usr/src/cmd/troff/font/makefile b/usr/src/cmd/troff/font/makefile
deleted file mode 100644 (file)
index 2799d3a..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-cp:    all
-       for i in *.o; do cp $$i /usr/lib/font/`basename $$i .o`; done
-       rm *.o
-
-cmp:   all
-       for i in *.o; do cmp $$i /usr/lib/font/`basename $$i .o`; done
-       rm *.o
-
-.c.o:
-       cc -c $<; strip $@
-
-all:   ftB.o ftBC.o ftC.o ftCE.o ftCI.o ftCK.o ftCS.o ftCW.o ftG.o ftGI.o ftGM.o ftGR.o
-all:   ftI.o ftL.o ftLI.o ftPA.o ftPB.o ftPI.o ftR.o ftS.o ftSB.o ftSI.o ftSM.o ftUD.o ftXM.o
-
-mkfont:mkfont.c mkfont1.c -o mkfont
-       cc -n -s mkfont.c
diff --git a/usr/src/cmd/troff/font/onefont b/usr/src/cmd/troff/font/onefont
new file mode 100755 (executable)
index 0000000..bcae016
--- /dev/null
@@ -0,0 +1,5 @@
+cc -c $1.c
+strip $1.o
+mv $1.o /usr/lib/font/$1
+chmod 755 /usr/lib/font/$1
+echo $1 done
diff --git a/usr/src/cmd/troff/makefile b/usr/src/cmd/troff/makefile
deleted file mode 100644 (file)
index 018f970..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-all:   nroff troff
-
-nroff:
-       make -f nmake
-       rm *.o
-
-troff:
-       make -f tmake
-       rm *.o
-
-cp:    all
-       cp nroff troff /bin
-       rm nroff troff
-
-cmp:   all
-       cmp nroff /bin/nroff
-       cmp troff /bin/troff
-       rm nroff troff
index 1b990bf..84d44b8 100644 (file)
@@ -298,6 +298,7 @@ report(){
                a.use = paper;
                a.uid = getuid();
                write(acctf,(char *)&a,sizeof(a));
                a.use = paper;
                a.uid = getuid();
                write(acctf,(char *)&a,sizeof(a));
+               close(acctf);
        }
 }
 #endif
        }
 }
 #endif
index 0c18457..72fdb0b 100644 (file)
@@ -471,7 +471,7 @@ collect()
        lim = (int *)(nxf = savnxf + sizeof(struct s)/sizeof(savnxf));
        strflg = 0;
        if((argppend =
        lim = (int *)(nxf = savnxf + sizeof(struct s)/sizeof(savnxf));
        strflg = 0;
        if((argppend =
-               (argpp = (int **)savnxf+(sizeof(struct s)/sizeof(int **))) + (sizeof(struct s)-1))
+               (argpp = (int **)savnxf+(sizeof(struct s)/sizeof(int **))) + 9)
                > (int **)enda)setbrk(DELTA);
        strp = (int *)argppend;
        for(i=8; i>=0; i--)argpp[i] = 0;
                > (int **)enda)setbrk(DELTA);
        strp = (int *)argppend;
        for(i=8; i>=0; i--)argpp[i] = 0;
diff --git a/usr/src/cmd/troff/nmake b/usr/src/cmd/troff/nmake
deleted file mode 100644 (file)
index 1c084af..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-CFLAGS=-n -s -O -DNROFF
-NFILES=n1.o n2.o n3.o n4.o n5.o n6.o n7.o n8.o n9.o n10.o ni.o nii.o ntab.o hytab.o suftab.o
-
-nroff: $(NFILES)
-       cc -o nroff $(CFLAGS) $(NFILES)
-
-n1.o:  tdef.h d.h v.h tw.h s.h
-n2.o:  tdef.h d.h v.h tw.h s.h
-n3.o:  tdef.h d.h v.h tw.h s.h
-n4.o:  tdef.h d.h v.h tw.h s.h
-n5.o:  tdef.h d.h v.h tw.h s.h
-n6.o:  tdef.h d.h v.h tw.h s.h
-t6.o:  tdef.h d.h v.h tw.h s.h
-n7.o:  tdef.h d.h v.h tw.h s.h
-n8.o:  tdef.h d.h v.h tw.h s.h
-n9.o:  tdef.h d.h v.h tw.h s.h
-n10.o: tdef.h d.h v.h tw.h s.h
-t10.o: tdef.h d.h v.h tw.h s.h
-ni.o:  tdef.h d.h v.h tw.h s.h
-nii.o: tdef.h d.h v.h tw.h s.h
-
-hytab.o:       hytab.c
-       cc -S hytab.c
-       ed hytab.s <textscript
-       as -o hytab.o hytab.s
-       rm hytab.s
-
-suftab.o:      suftab.c
-       cc -S suftab.c
-       ed suftab.s <textscript
-       as -o suftab.o suftab.s
-       rm suftab.s
index a33e936..5aceebd 100644 (file)
@@ -1,4 +1,4 @@
-#define        MAXPTR  (char *)-1      /* max value of any pointer variable */
+#define MAXPTR 0x7fffffff      /* max value of any pointer variable */
 #ifdef NROFF   /*NROFF*/
 #define EM t.Em
 #define HOR t.Hor
 #ifdef NROFF   /*NROFF*/
 #define EM t.Em
 #define HOR t.Hor
 #define FT 0   /*default font position*/
 #define LL 65*INCH/10  /*line length; 39picas=6.5in*/
 #define VS INCH/6      /*vert space; 12points*/
 #define FT 0   /*default font position*/
 #define LL 65*INCH/10  /*line length; 39picas=6.5in*/
 #define VS INCH/6      /*vert space; 12points*/
-#define NN 200 /*number registers*/
-/* NN changed Jan 31 from 132 */
+#define NN 132 /*number registers*/
+/* #define NN 200      */
 #define NNAMES 14 /*predefined reg names*/
 #define NIF 15 /*if-else nesting*/
 #define NS 64  /*name buffer*/
 #define NTM 256        /*tm buffer*/
 #define NEV 3  /*environments*/
 #define EVLSZ 10       /*size of ev stack*/
 #define NNAMES 14 /*predefined reg names*/
 #define NIF 15 /*if-else nesting*/
 #define NS 64  /*name buffer*/
 #define NTM 256        /*tm buffer*/
 #define NEV 3  /*environments*/
 #define EVLSZ 10       /*size of ev stack*/
-#define EVS 4*256      /*environment size in words*/
-/* BWK - trying 4*256 instead of 3*256 */
+#define EVS 3*256      /*environment size in words*/
+/* #define EVS 4*256   */
 #define NM 300 /*requests + macros*/
 #define DELTA 512      /*delta core bytes*/
 #define NHYP 10        /*max hyphens per word*/
 #define NM 300 /*requests + macros*/
 #define DELTA 512      /*delta core bytes*/
 #define NHYP 10        /*max hyphens per word*/
@@ -58,8 +58,8 @@
 #define NTAB 35        /*tab stops*/
 #define NSO 5  /*"so" depth*/
 #define WDSIZE 170     /*word buffer size*/
 #define NTAB 35        /*tab stops*/
 #define NSO 5  /*"so" depth*/
 #define WDSIZE 170     /*word buffer size*/
-#define LNSIZE 680     /*line buffer size*/
-/* BWK - changed from 480 after EVS changed */
+#define LNSIZE 480     /*line buffer size*/
+/* #define LNSIZE 680  */
 #define NDI 5  /*number of diversions*/
 #define DBL 0100000    /*double size indicator*/
 #define MOT 0100000    /*motion character indicator*/
 #define NDI 5  /*number of diversions*/
 #define DBL 0100000    /*double size indicator*/
 #define MOT 0100000    /*motion character indicator*/
diff --git a/usr/src/cmd/troff/term/Makefile b/usr/src/cmd/troff/term/Makefile
new file mode 100644 (file)
index 0000000..1d61db2
--- /dev/null
@@ -0,0 +1,40 @@
+CFLAGS=-O
+all: tab300 tab300S tab300X tab300s tab37 tab450-12 tab450 tab450X tab450-12-8
+all: tabtn300
+
+tab300: tab300.o
+       mv tab300.o tab300
+tab300S: tab300S.o
+       mv tab300S.o tab300S
+tab300X: tab300X.o
+       mv tab300X.o tab300X
+tab300s: tab300s.o
+       mv tab300s.o tab300s
+tab37: tab37.o
+       mv tab37.o tab37
+tab450-12: tab450-12.o
+       mv tab450-12.o tab450-12
+tab450: tab450.o
+       mv tab450.o tab450
+tab450X: tab450X.o
+       mv tab450X.o tab450X
+tab450-12-8: tab450-12-8.o
+       mv tab450-12-8.o tab450-12-8
+tabtn300: tabtn300.o
+       mv tabtn300.o tabtn300
+
+install:
+       install tab300 $(DESTDIR)/usr/lib/term
+       install tab300S $(DESTDIR)/usr/lib/term
+       install tab300X $(DESTDIR)/usr/lib/term
+       install tab300s $(DESTDIR)/usr/lib/term
+       install tab37 $(DESTDIR)/usr/lib/term
+       install tab450-12-8 $(DESTDIR)/usr/lib/term
+       install tab450-12 $(DESTDIR)/usr/lib/term
+       install tab450 $(DESTDIR)/usr/lib/term
+       install tab450X $(DESTDIR)/usr/lib/term
+       install tabtn300 $(DESTDIR)/usr/lib/term
+clean:
+       : already clean
+
+
index 95b9180..eaf6514 100644 (file)
 "\000\0",      /*narrow sp*/
 "\001-",        /*hyphen*/
 "\001o\b+",     /*bullet*/
 "\000\0",      /*narrow sp*/
 "\001-",        /*hyphen*/
 "\001o\b+",     /*bullet*/
-"\002\[]",      /*square*/
+"\002[]",       /*square*/
 "\001-",        /*3/4 em*/
 "\001_",        /*rule*/
 "\001-",        /*3/4 em*/
 "\001_",        /*rule*/
-"\0031/4",      /*1/4*/
-"\0031/2",      /*1/2*/
-"\0033/4",      /*3/4*/
+"\000\0",       /*1/4*/
+"\000\0",       /*1/2*/
+"\000\0",       /*3/4*/
 "\001-",        /*minus*/
 "\202fi",       /*fi*/
 "\202fl",       /*fl*/
 "\202ff",       /*ff*/
 "\203ffi",      /*ffi*/
 "\203ffl",      /*ffl*/
 "\001-",        /*minus*/
 "\202fi",       /*fi*/
 "\202fl",       /*fl*/
 "\202ff",       /*ff*/
 "\203ffi",      /*ffi*/
 "\203ffl",      /*ffl*/
-"\001\344o\304",        /*degree*/
-"\001|\b-",     /*dagger*/
-"\001l\bo",    /* section*/
+"\000\0",       /*degree*/
+"\000\0",       /*dagger*/
+"\000\0",       /*section*/
 "\001'",        /*foot mark*/
 "\001'",        /*acute accent*/
 "\001`",        /*grave accent*/
 "\001'",        /*foot mark*/
 "\001'",        /*acute accent*/
 "\001`",        /*grave accent*/
 "\000\0",      /*half narrow space*/
 "\001 ",       /*unpaddable space*/
 "\001\241c\202(\241", /*alpha*/
 "\000\0",      /*half narrow space*/
 "\001 ",       /*unpaddable space*/
 "\001\241c\202(\241", /*alpha*/
-"\001\200B\242\302\|\202\342", /*beta*/
+"\001\200B\242\302|\202\342", /*beta*/
 "\001\200)\201/\241", /*gamma*/
 "\001\200o\342<\302", /*delta*/
 "\001<\b-", /*epsilon*/
 "\001\200)\201/\241", /*gamma*/
 "\001\200o\342<\302", /*delta*/
 "\001<\b-", /*epsilon*/
 "\001\242/\303-\204-\343\\\242", /*Delta*/
 "\001O\b=", /*Theta*/
 "\001\242/\204\\\242", /*Lambda*/
 "\001\242/\303-\204-\343\\\242", /*Delta*/
 "\001O\b=", /*Theta*/
 "\001\242/\204\\\242", /*Lambda*/
-"\001\\b/",     /*Xi*/
+"\000\0",       /*Xi*/
 "\001\242[]\204[]\242\343-\303", /*Pi*/
 "\001\200>\302-\345-\303", /*Sigma*/
 "\000\0",       /**/
 "\001\242[]\204[]\242\343-\303", /*Pi*/
 "\001\200>\302-\345-\303", /*Sigma*/
 "\000\0",       /**/
 "\001c\bO",     /*copyright*/
 "\001|",        /*box rule */
 "\001c\b/",     /*cent sign*/
 "\001c\bO",     /*copyright*/
 "\001|",        /*box rule */
 "\001c\b/",     /*cent sign*/
-"\001|\b=",     /*dbl dagger*/
-"\002=>",       /*right hand*/
-"\002<=",       /*left hand*/
+"\000\0",       /*dbl dagger*/
+"\000\0",       /*right hand*/
+"\001*",        /*left hand*/
 "\001*",        /*math * */
 "\000\0",       /*bell system sign*/
 "\001|",        /*or (was star)*/
 "\001*",        /*math * */
 "\000\0",       /*bell system sign*/
 "\001|",        /*or (was star)*/
diff --git a/usr/src/cmd/troff/term/makefile b/usr/src/cmd/troff/term/makefile
deleted file mode 100644 (file)
index 0f3cda7..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-cp:    all
-       for i in *.o; do cp $$i /usr/lib/term/`basename $$i .o`; done
-       rm *.o
-
-cmp:   all
-       for i in *.o; do cmp $$i /usr/lib/term/`basename $$i .o`; done
-       rm *.o
-
-all:   tab300-12.o tab300.o tab300s-12.o tab300s.o
-all:   tab37.o tab450-12-8.o tab450-12.o tab450.o tab832.o taba1.o tablp.o tabtn300.o
-       :
-
-.c.o:
-       cc -c $<; strip $@
diff --git a/usr/src/cmd/troff/term/tab300-12.c b/usr/src/cmd/troff/term/tab300-12.c
deleted file mode 100644 (file)
index 44af584..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#define INCH 240
-/*
-DASI300
-nroff driving tables
-width and code tables
-*/
-
-struct {
-       int bset;
-       int breset;
-       int Hor;
-       int Vert;
-       int Newline;
-       int Char;
-       int Em;
-       int Halfline;
-       int Adj;
-       char *twinit;
-       char *twrest;
-       char *twnl;
-       char *hlr;
-       char *hlf;
-       char *flr;
-       char *bdon;
-       char *bdoff;
-       char *ploton;
-       char *plotoff;
-       char *up;
-       char *down;
-       char *right;
-       char *left;
-       char *codetab[256-32];
-       int zzz;
-       } t {
-/*bset*/       0,
-/*breset*/     0177420,
-/*Hor*/                INCH/60,
-/*Vert*/       INCH/48,
-/*Newline*/    INCH/8,
-/*Char*/       INCH/12,
-/*Em*/         INCH/12,
-/*Halfline*/   INCH/16,
-/*Adj*/                INCH/12,
-/*twinit*/     "\007",
-/*twrest*/     "\007",
-/*twnl*/       "\015\n",
-/*hlr*/                "\006\013\013\013\006",
-/*hlf*/                "\006\012\012\012\006",
-/*flr*/                "\013",
-/*bdon*/       "",
-/*bdoff*/      "",
-/*ploton*/     "\006",
-/*plotoff*/    "\033\006",
-/*up*/         "\013",
-/*down*/       "\n",
-/*right*/      " ",
-/*left*/       "\b",
-/*codetab*/
-#include "code.300"
index 2c15488..f4af9ee 100644 (file)
@@ -31,7 +31,7 @@ struct {
        char *left;
        char *codetab[256-32];
        int zzz;
        char *left;
        char *codetab[256-32];
        int zzz;
-       } t {
+       } t {
 /*bset*/       0,
 /*breset*/     0177420,
 /*Hor*/                INCH/60,
 /*bset*/       0,
 /*breset*/     0177420,
 /*Hor*/                INCH/60,
@@ -44,8 +44,8 @@ struct {
 /*twinit*/     "\007",
 /*twrest*/     "\007",
 /*twnl*/       "\015\n",
 /*twinit*/     "\007",
 /*twrest*/     "\007",
 /*twnl*/       "\015\n",
-/*hlr*/                "\006\013\013\013\013\006",
-/*hlf*/                "\006\012\012\012\012\006",
+/*hlr*/                "",
+/*hlf*/                "",
 /*flr*/                "\013",
 /*bdon*/       "",
 /*bdoff*/      "",
 /*flr*/                "\013",
 /*bdon*/       "",
 /*bdoff*/      "",
diff --git a/usr/src/cmd/troff/term/tab300S.c b/usr/src/cmd/troff/term/tab300S.c
new file mode 100644 (file)
index 0000000..8d2b858
--- /dev/null
@@ -0,0 +1,59 @@
+#define INCH 240
+/*
+DASI300S
+nroff driving tables
+width and code tables
+*/
+
+struct {
+       int bset;
+       int breset;
+       int Hor;
+       int Vert;
+       int Newline;
+       int Char;
+       int Em;
+       int Halfline;
+       int Adj;
+       char *twinit;
+       char *twrest;
+       char *twnl;
+       char *hlr;
+       char *hlf;
+       char *flr;
+       char *bdon;
+       char *bdoff;
+       char *ploton;
+       char *plotoff;
+       char *up;
+       char *down;
+       char *right;
+       char *left;
+       char *codetab[256-32];
+       int zzz;
+       } t = {
+/*bset*/       0,
+/*breset*/     0177420,
+/*Hor*/                INCH/60,
+/*Vert*/       INCH/48,
+/*Newline*/    INCH/6,
+/*Char*/       INCH/10,
+/*Em*/         INCH/10,
+/*Halfline*/   INCH/12,
+/*Adj*/                INCH/10,
+/*twinit*/     "\033\006",
+/*twrest*/     "\033\006",
+/*twnl*/       "\015\n",
+/*hlr*/                "\033H",
+/*hlf*/                "\033h",
+/*flr*/                "\032",
+/*bdon*/       "",
+/*bdoff*/      "",
+/*ploton*/     "\006",
+/*plotoff*/    "\033\006",
+/*up*/         "\032",
+/*down*/       "\n",
+/*right*/      " ",
+/*left*/       "\b",
+/*codetab*/
+#include "code.300"
diff --git a/usr/src/cmd/troff/term/tab300X.c b/usr/src/cmd/troff/term/tab300X.c
new file mode 100644 (file)
index 0000000..f4af9ee
--- /dev/null
@@ -0,0 +1,59 @@
+#define INCH 240
+/*
+DASI300
+nroff driving tables
+width and code tables
+*/
+
+struct {
+       int bset;
+       int breset;
+       int Hor;
+       int Vert;
+       int Newline;
+       int Char;
+       int Em;
+       int Halfline;
+       int Adj;
+       char *twinit;
+       char *twrest;
+       char *twnl;
+       char *hlr;
+       char *hlf;
+       char *flr;
+       char *bdon;
+       char *bdoff;
+       char *ploton;
+       char *plotoff;
+       char *up;
+       char *down;
+       char *right;
+       char *left;
+       char *codetab[256-32];
+       int zzz;
+       } t = {
+/*bset*/       0,
+/*breset*/     0177420,
+/*Hor*/                INCH/60,
+/*Vert*/       INCH/48,
+/*Newline*/    INCH/6,
+/*Char*/       INCH/10,
+/*Em*/         INCH/10,
+/*Halfline*/   INCH/12,
+/*Adj*/                INCH/10,
+/*twinit*/     "\007",
+/*twrest*/     "\007",
+/*twnl*/       "\015\n",
+/*hlr*/                "",
+/*hlf*/                "",
+/*flr*/                "\013",
+/*bdon*/       "",
+/*bdoff*/      "",
+/*ploton*/     "\006",
+/*plotoff*/    "\033\006",
+/*up*/         "\013",
+/*down*/       "\n",
+/*right*/      " ",
+/*left*/       "\b",
+/*codetab*/
+#include "code.300"
diff --git a/usr/src/cmd/troff/term/tab300s-12.c b/usr/src/cmd/troff/term/tab300s-12.c
deleted file mode 100644 (file)
index f480565..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#define INCH 240
-/*
-DASI300S
-nroff driving tables
-width and code tables
-*/
-
-struct {
-       int bset;
-       int breset;
-       int Hor;
-       int Vert;
-       int Newline;
-       int Char;
-       int Em;
-       int Halfline;
-       int Adj;
-       char *twinit;
-       char *twrest;
-       char *twnl;
-       char *hlr;
-       char *hlf;
-       char *flr;
-       char *bdon;
-       char *bdoff;
-       char *ploton;
-       char *plotoff;
-       char *up;
-       char *down;
-       char *right;
-       char *left;
-       char *codetab[256-32];
-       int zzz;
-       } t {
-/*bset*/       0,
-/*breset*/     0177420,
-/*Hor*/                INCH/60,
-/*Vert*/       INCH/48,
-/*Newline*/    INCH/8,
-/*Char*/       INCH/12,
-/*Em*/         INCH/12,
-/*Halfline*/   INCH/16,
-/*Adj*/                INCH/12,
-/*twinit*/     "\033\006",
-/*twrest*/     "\033\006",
-/*twnl*/       "\015\n",
-/*hlr*/                "",
-/*hlf*/                "",
-/*flr*/                "\032",
-/*bdon*/       "\033E",
-/*bdoff*/      "\033E",
-/*ploton*/     "\006",
-/*plotoff*/    "\033\006",
-/*up*/         "\032",
-/*down*/       "\n",
-/*right*/      " ",
-/*left*/       "\b",
-/*codetab*/
-#include "code.300"
index 7f47ba8..8d2b858 100644 (file)
@@ -31,7 +31,7 @@ struct {
        char *left;
        char *codetab[256-32];
        int zzz;
        char *left;
        char *codetab[256-32];
        int zzz;
-       } t {
+       } t {
 /*bset*/       0,
 /*breset*/     0177420,
 /*Hor*/                INCH/60,
 /*bset*/       0,
 /*breset*/     0177420,
 /*Hor*/                INCH/60,
@@ -47,8 +47,8 @@ struct {
 /*hlr*/                "\033H",
 /*hlf*/                "\033h",
 /*flr*/                "\032",
 /*hlr*/                "\033H",
 /*hlf*/                "\033h",
 /*flr*/                "\032",
-/*bdon*/       "\033E",
-/*bdoff*/      "\033E",
+/*bdon*/       "",
+/*bdoff*/      "",
 /*ploton*/     "\006",
 /*plotoff*/    "\033\006",
 /*up*/         "\032",
 /*ploton*/     "\006",
 /*plotoff*/    "\033\006",
 /*up*/         "\032",
index 903e43f..e391923 100644 (file)
@@ -31,7 +31,7 @@ struct {
        char *left;
        char *codetab[256-32];
        int zzz;
        char *left;
        char *codetab[256-32];
        int zzz;
-       } t {
+       } t {
 /*bset*/       0,
 /*breset*/     0,
 /*Hor*/                INCH/10,
 /*bset*/       0,
 /*breset*/     0,
 /*Hor*/                INCH/10,
@@ -154,7 +154,7 @@ struct {
 "\000\0",      /*narrow sp*/
 "\001-",        /*hyphen*/
 "\001o\b+",     /*bullet*/
 "\000\0",      /*narrow sp*/
 "\001-",        /*hyphen*/
 "\001o\b+",     /*bullet*/
-"\002\[]",      /*square*/
+"\002[]",       /*square*/
 "\001-",        /*3/4 em*/
 "\001_",        /*rule*/
 "\0031/4",     /*1/4*/
 "\001-",        /*3/4 em*/
 "\001_",        /*rule*/
 "\0031/4",     /*1/4*/
@@ -166,8 +166,8 @@ struct {
 "\202ff",       /*ff*/
 "\203ffi",      /*ffi*/
 "\203ffl",      /*ffl*/
 "\202ff",       /*ff*/
 "\203ffi",      /*ffi*/
 "\203ffl",      /*ffl*/
-"\001\0338o\0339",      /*degree*/
-"\001|\b-",     /*dagger*/
+"\000\0",       /*degree*/
+"\000\0",       /*dagger*/
 "\000\0",       /*section*/
 "\001'",        /*foot mark*/
 "\001'",        /*acute accent*/
 "\000\0",       /*section*/
 "\001'",        /*foot mark*/
 "\001'",        /*acute accent*/
@@ -249,9 +249,9 @@ struct {
 "\001\0338c\0339",      /*copyright*/
 "\001|",        /*box rule */
 "\001c\b/",     /*cent sign*/
 "\001\0338c\0339",      /*copyright*/
 "\001|",        /*box rule */
 "\001c\b/",     /*cent sign*/
-"\001|\b=",     /*dbl dagger*/
-"\002=>",       /*right hand*/
-"\002<=",       /*left hand*/
+"\000\0",       /*dbl dagger*/
+"\000\0",       /*right hand*/
+"\001*",        /*left hand*/
 "\001*",        /*math * */
 "\000\0",       /*bell system sign*/
 "\001|",        /*or (was star)*/
 "\001*",        /*math * */
 "\000\0",       /*bell system sign*/
 "\001|",        /*or (was star)*/
index ca0575f..f38e7ad 100644 (file)
@@ -1,7 +1,6 @@
 #define INCH 240
 /*
 DASI450
 #define INCH 240
 /*
 DASI450
-12 chars/inch, 6 lines/inch
 nroff driving tables
 width and code tables
 */
 nroff driving tables
 width and code tables
 */
@@ -32,7 +31,7 @@ struct {
        char *left;
        char *codetab[256-32];
        int zzz;
        char *left;
        char *codetab[256-32];
        int zzz;
-       } t {
+       } t {
 /*bset*/       0,
 /*breset*/     0177420,
 /*Hor*/                INCH/60,
 /*bset*/       0,
 /*breset*/     0177420,
 /*Hor*/                INCH/60,
index 368da41..1ebcd34 100644 (file)
@@ -31,7 +31,7 @@ struct {
        char *left;
        char *codetab[256-32];
        int zzz;
        char *left;
        char *codetab[256-32];
        int zzz;
-       } t {
+       } t {
 /*bset*/       0,
 /*breset*/     0177420,
 /*Hor*/                INCH/60,
 /*bset*/       0,
 /*breset*/     0177420,
 /*Hor*/                INCH/60,
diff --git a/usr/src/cmd/troff/term/tab450X.c b/usr/src/cmd/troff/term/tab450X.c
new file mode 100644 (file)
index 0000000..687afb2
--- /dev/null
@@ -0,0 +1,59 @@
+#define INCH 240
+/*
+DASI300S
+nroff driving tables
+width and code tables
+*/
+
+struct {
+       int bset;
+       int breset;
+       int Hor;
+       int Vert;
+       int Newline;
+       int Char;
+       int Em;
+       int Halfline;
+       int Adj;
+       char *twinit;
+       char *twrest;
+       char *twnl;
+       char *hlr;
+       char *hlf;
+       char *flr;
+       char *bdon;
+       char *bdoff;
+       char *ploton;
+       char *plotoff;
+       char *up;
+       char *down;
+       char *right;
+       char *left;
+       char *codetab[256-32];
+       int zzz;
+       } t = {
+/*bset*/       0,
+/*breset*/     0177420,
+/*Hor*/                INCH/60,
+/*Vert*/       INCH/48,
+/*Newline*/    INCH/6,
+/*Char*/       INCH/10,
+/*Em*/         INCH/10,
+/*Halfline*/   INCH/12,
+/*Adj*/                INCH/10,
+/*twinit*/     "\0334",
+/*twrest*/     "\0334",
+/*twnl*/       "\015\n",
+/*hlr*/                "\033D",
+/*hlf*/                "\033U",
+/*flr*/                "\033\n",
+/*bdon*/       "",
+/*bdoff*/      "",
+/*ploton*/     "\0333",
+/*plotoff*/    "\0334",
+/*up*/         "\033\n",
+/*down*/       "\n",
+/*right*/      " ",
+/*left*/       "\b",
+/*codetab*/
+#include "code.300"
diff --git a/usr/src/cmd/troff/term/tab832.c b/usr/src/cmd/troff/term/tab832.c
deleted file mode 100644 (file)
index 6c4bf8c..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#define INCH 240
-/*
-Anderson Jacobson 832
-nroff driving tables
-width and code tables
-*/
-
-struct {
-       int bset;
-       int breset;
-       int Hor;
-       int Vert;
-       int Newline;
-       int Char;
-       int Em;
-       int Halfline;
-       int Adj;
-       char *twinit;
-       char *twrest;
-       char *twnl;
-       char *hlr;
-       char *hlf;
-       char *flr;
-       char *bdon;
-       char *bdoff;
-       char *ploton;
-       char *plotoff;
-       char *up;
-       char *down;
-       char *right;
-       char *left;
-       char *codetab[256-32];
-       int zzz;
-       } t {
-/*bset*/       0,
-/*breset*/     0177420,
-/*Hor*/                INCH/60,
-/*Vert*/       INCH/48,
-/*Newline*/    INCH/6,
-/*Char*/       INCH/10,
-/*Em*/         INCH/10,
-/*Halfline*/   INCH/12,
-/*Adj*/                INCH/10,
-/*twinit*/     "\033N",
-/*twrest*/     "\033N",
-/*twnl*/       "\015\n",
-/*hlr*/                "\0338",
-/*hlf*/                "\0339",
-/*flr*/                "\0337",
-/*bdon*/       "",
-/*bdoff*/      "",
-/*ploton*/     "\033P",
-/*plotoff*/    "\033N",
-/*up*/         "\013",
-/*down*/       "\n",
-/*right*/      " ",
-/*left*/       "\b",
-/*codetab*/
-#include "code.300"
diff --git a/usr/src/cmd/troff/term/taba1.c b/usr/src/cmd/troff/term/taba1.c
deleted file mode 100644 (file)
index 4f42f08..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#define INCH 240
-/*
-DASI450
-nroff driving tables
-width and code tables
-*/
-
-struct {
-       int bset;
-       int breset;
-       int Hor;
-       int Vert;
-       int Newline;
-       int Char;
-       int Em;
-       int Halfline;
-       int Adj;
-       char *twinit;
-       char *twrest;
-       char *twnl;
-       char *hlr;
-       char *hlf;
-       char *flr;
-       char *bdon;
-       char *bdoff;
-       char *ploton;
-       char *plotoff;
-       char *up;
-       char *down;
-       char *right;
-       char *left;
-       char *codetab[256-32];
-       int zzz;
-       } t {
-/*bset*/       0,
-/*breset*/     0177420,
-/*Hor*/                INCH/60,
-/*Vert*/       INCH/48,
-/*Newline*/    INCH/6,
-/*Char*/       INCH/10,
-/*Em*/         INCH/10,
-/*Halfline*/   INCH/12,
-/*Adj*/                INCH/10,
-/*twinit*/     "\033R",
-/*twrest*/     "\033R",
-/*twnl*/       "\015\n",
-/*hlr*/                "\033S",
-/*hlf*/                "\033B",
-/*flr*/                "\033\n",
-/*bdon*/       "",
-/*bdoff*/      "",
-/*ploton*/     "\0334",
-/*plotoff*/    "\033R",
-/*up*/         "\005",
-/*down*/       "\n",
-/*right*/      " ",
-/*left*/       "\b",
-/*codetab*/
-#include "code.300"
diff --git a/usr/src/cmd/troff/term/tablp.c b/usr/src/cmd/troff/term/tablp.c
deleted file mode 100644 (file)
index 46568cb..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-#define INCH 240
-/*
-Line Printer with col-only reverse line feed
-nroff driving tables
-width and code tables
-*/
-
-struct {
-       int bset;
-       int breset;
-       int Hor;
-       int Vert;
-       int Newline;
-       int Char;
-       int Em;
-       int Halfline;
-       int Adj;
-       char *twinit;
-       char *twrest;
-       char *twnl;
-       char *hlr;
-       char *hlf;
-       char *flr;
-       char *bdon;
-       char *bdoff;
-       char *ploton;
-       char *plotoff;
-       char *up;
-       char *down;
-       char *right;
-       char *left;
-       char *codetab[256-32];
-       int zzz;
-       } t {
-/*bset*/       0,
-/*breset*/     0,
-/*Hor*/                INCH/10,
-/*Vert*/       INCH/6,
-/*Newline*/    INCH/6,
-/*Char*/       INCH/10,
-/*Em*/         INCH/10,
-/*Halfline*/   INCH/12,
-/*Adj*/                INCH/10,
-/*twinit*/     "",
-/*twrest*/     "",
-/*twnl*/       "\n",
-/*hlr*/                "",
-/*hlf*/                "",
-/*flr*/                "\0337",
-/*bdon*/       "",
-/*bdoff*/      "",
-/*ploton*/     "",
-/*plotoff*/    "",
-/*up*/         "",
-/*down*/       "",
-/*right*/      "",
-/*left*/       "",
-/*codetab*/
-"\001 ",       /*space*/
-"\001!",       /*!*/
-"\001\"",      /*"*/
-"\001#",       /*#*/
-"\001$",       /*$*/
-"\001%",       /*%*/
-"\001&",       /*&*/
-"\001'",       /*' close*/
-"\001(",       /*(*/
-"\001)",       /*)*/
-"\001*",       /***/
-"\001+",       /*+*/
-"\001,",       /*,*/
-"\001-",       /*- hyphen*/
-"\001.",       /*.*/
-"\001/",       /*/*/
-"\2010",       /*0*/
-"\2011",       /*1*/
-"\2012",       /*2*/
-"\2013",       /*3*/
-"\2014",       /*4*/
-"\2015",       /*5*/
-"\2016",       /*6*/
-"\2017",       /*7*/
-"\2018",       /*8*/
-"\2019",       /*9*/
-"\001:",       /*:*/
-"\001;",       /*;*/
-"\001<",       /*<*/
-"\001=",       /*=*/
-"\001>",       /*>*/
-"\001?",       /*?*/
-"\001@",       /*@*/
-"\201A",       /*A*/
-"\201B",       /*B*/
-"\201C",       /*C*/
-"\201D",       /*D*/
-"\201E",       /*E*/
-"\201F",       /*F*/
-"\201G",       /*G*/
-"\201H",       /*H*/
-"\201I",       /*I*/
-"\201J",       /*J*/
-"\201K",       /*K*/
-"\201L",       /*L*/
-"\201M",       /*M*/
-"\201N",       /*N*/
-"\201O",       /*O*/
-"\201P",       /*P*/
-"\201Q",       /*Q*/
-"\201R",       /*R*/
-"\201S",       /*S*/
-"\201T",       /*T*/
-"\201U",       /*U*/
-"\201V",       /*V*/
-"\201W",       /*W*/
-"\201X",       /*X*/
-"\201Y",       /*Y*/
-"\201Z",       /*Z*/
-"\001[",       /*[*/
-"\001\\",      /*\*/
-"\001]",       /*]*/
-"\001^",       /*^*/
-"\001_",       /*_ dash*/
-"\001`",       /*` open*/
-"\201a",       /*a*/
-"\201b",       /*b*/
-"\201c",       /*c*/
-"\201d",       /*d*/
-"\201e",       /*e*/
-"\201f",       /*f*/
-"\201g",       /*g*/
-"\201h",       /*h*/
-"\201i",       /*i*/
-"\201j",       /*j*/
-"\201k",       /*k*/
-"\201l",       /*l*/
-"\201m",       /*m*/
-"\201n",       /*n*/
-"\201o",       /*o*/
-"\201p",       /*p*/
-"\201q",       /*q*/
-"\201r",       /*r*/
-"\201s",       /*s*/
-"\201t",       /*t*/
-"\201u",       /*u*/
-"\201v",       /*v*/
-"\201w",       /*w*/
-"\201x",       /*x*/
-"\201y",       /*y*/
-"\201z",       /*z*/
-"\001{",       /*{*/
-"\001|",       /*|*/
-"\001}",       /*}*/
-"\001~",       /*~*/
-"\000\0",      /*nar sp*/
-"\001-",        /*hyphen*/
-"\001o\b+",     /*bullet*/
-"\002\[]",      /*square*/
-"\001-",        /*3/4 em*/
-"\001_",        /*rule*/
-"\000\0",       /*1/4*/
-"\000\0",       /*1/2*/
-"\000\0",       /*3/4*/
-"\001-",        /*minus*/
-"\202fi",       /*fi*/
-"\202fl",       /*fl*/
-"\202ff",       /*ff*/
-"\203ffi",      /*ffi*/
-"\203ffl",      /*ffl*/
-"\000\0",       /*degree*/
-"\000\0",       /*dagger*/
-"\000\0",       /*section*/
-"\001'",        /*foot mark*/
-"\001'",        /*acute accent*/
-"\001`",        /*grave accent*/
-"\001_",        /*underrule*/
-"\001/",        /*slash (longer)*/
-"\000\0",      /*half narrow space*/
-"\001 ",       /*unpaddable space*/
-"\000", /*alpha*/
-"\000", /*beta*/
-"\000", /*gamma*/
-"\000", /*delta*/
-"\000", /*epsilon*/
-"\000", /*zeta*/
-"\000", /*eta*/
-"\000", /*theta*/
-"\201i",        /*iota*/
-"\201k",        /*kappa*/
-"\000", /*lambda*/
-"\000", /*mu*/
-"\000", /*nu*/
-"\000", /*xi*/
-"\201o",        /*omicron*/
-"\000", /*pi*/
-"\000", /*rho*/
-"\000", /*sigma*/
-"\000", /*tau*/
-"\201v",        /*upsilon*/
-"\000", /*phi*/
-"\201x",        /*chi*/
-"\000", /*psi*/
-"\000", /*omega*/
-"\000", /*Gamma*/
-"\000", /*Delta*/
-"\000", /*Theta*/
-"\000", /*Lambda*/
-"\000\0",       /*Xi*/
-"\000", /*Pi*/
-"\000", /*Sigma*/
-"\000\0",       /**/
-"\201Y",        /*Upsilon*/
-"\000", /*Phi*/
-"\000", /*Psi*/
-"\000", /*Omega*/
-"\000\0",       /*square root*/
-"\000\0",       /*terminal sigma*/
-"\000\0",       /*root en*/
-"\001>\b_",     /*>=*/
-"\001<\b_",     /*<=*/
-"\001=\b_",     /*identically equal*/
-"\001-",        /*equation minus*/
-"\001=\b~",     /*approx =*/
-"\000\0",       /*approximates*/
-"\001=\b/",     /*not equal*/
-"\002->",       /*right arrow*/
-"\002<-",       /*left arrow*/
-"\001|\b^",     /*up arrow*/
-"\000\0",       /*down arrow*/
-"\001=",        /*equation equal*/
-"\001x",        /*multiply*/
-"\001/",        /*divide*/
-"\001+\b_",     /*plus-minus*/
-"\001U",        /*cup (union)*/
-"\000\0",       /*cap (intersection)*/
-"\000\0",       /*subset of*/
-"\000\0",       /*superset of*/
-"\000\0",       /*improper subset*/
-"\000\0",       /* improper superset*/
-"\002oo",       /*infinity*/
-"\000", /*partial derivative*/
-"\000", /*gradient*/
-"\000", /*not*/
-"\000", /*integral sign*/
-"\000\0",       /*proportional to*/
-"\000\0",       /*empty set*/
-"\000\0",       /*member of*/
-"\001+",        /*equation plus*/
-"\001r\bO",     /*registered*/
-"\001c\bO",     /*copyright*/
-"\001|",        /*box rule */
-"\001c\b/",     /*cent sign*/
-"\000\0",       /*dbl dagger*/
-"\000\0",       /*right hand*/
-"\001*",        /*left hand*/
-"\001*",        /*math * */
-"\000\0",       /*bell system sign*/
-"\001|",        /*or (was star)*/
-"\001O",        /*circle*/
-"\001|",        /*left top (of big curly)*/
-"\001|",        /*left bottom*/
-"\001|",        /*right top*/
-"\001|",        /*right bot*/
-"\001|",        /*left center of big curly bracket*/
-"\001|",        /*right center of big curly bracket*/
-"\001|",       /*bold vertical*/
-"\001|",       /*left floor (left bot of big sq bract)*/
-"\001|",       /*right floor (rb of ")*/
-"\001|",       /*left ceiling (lt of ")*/
-"\001|"};      /*right ceiling (rt of ")*/
index 5f70e5b..fa1934e 100644 (file)
@@ -1,6 +1,6 @@
 #define INCH 240
 /*
 #define INCH 240
 /*
-Terminet300
+TTY M37
 nroff driving tables
 width and code tables
 */
 nroff driving tables
 width and code tables
 */
@@ -31,7 +31,7 @@ struct {
        char *left;
        char *codetab[256-32];
        int zzz;
        char *left;
        char *codetab[256-32];
        int zzz;
-       } t {
+       } t {
 /*bset*/       0,
 /*breset*/     0,
 /*Hor*/                INCH/10,
 /*bset*/       0,
 /*breset*/     0,
 /*Hor*/                INCH/10,
@@ -154,12 +154,12 @@ struct {
 "\000\0",      /*nar sp*/
 "\001-",        /*hyphen*/
 "\001o\b+",     /*bullet*/
 "\000\0",      /*nar sp*/
 "\001-",        /*hyphen*/
 "\001o\b+",     /*bullet*/
-"\002\[]",      /*square*/
+"\002[]",       /*square*/
 "\001-",        /*3/4 em*/
 "\001_",        /*rule*/
 "\001-",        /*3/4 em*/
 "\001_",        /*rule*/
-"\0031/4",      /*1/4*/
-"\0031/2",      /*1/2*/
-"\0033/4",      /*3/4*/
+"\000\0",       /*1/4*/
+"\000\0",       /*1/2*/
+"\000\0",       /*3/4*/
 "\001-",        /*minus*/
 "\202fi",       /*fi*/
 "\202fl",       /*fl*/
 "\001-",        /*minus*/
 "\202fi",       /*fi*/
 "\202fl",       /*fl*/
@@ -167,7 +167,7 @@ struct {
 "\203ffi",      /*ffi*/
 "\203ffl",      /*ffl*/
 "\000\0",       /*degree*/
 "\203ffi",      /*ffi*/
 "\203ffl",      /*ffl*/
 "\000\0",       /*degree*/
-"\001|\b-",     /*dagger*/
+"\000\0",       /*dagger*/
 "\000\0",       /*section*/
 "\001'",        /*foot mark*/
 "\001'",        /*acute accent*/
 "\000\0",       /*section*/
 "\001'",        /*foot mark*/
 "\001'",        /*acute accent*/
@@ -249,9 +249,9 @@ struct {
 "\001c\bO",     /*copyright*/
 "\001|",        /*box rule */
 "\001c\b/",     /*cent sign*/
 "\001c\bO",     /*copyright*/
 "\001|",        /*box rule */
 "\001c\b/",     /*cent sign*/
-"\001|\b=",     /*dbl dagger*/
-"\002=>",       /*right hand*/
-"\002<=",       /*left hand*/
+"\000\0",       /*dbl dagger*/
+"\000\0",       /*right hand*/
+"\001*",        /*left hand*/
 "\001*",        /*math * */
 "\000\0",       /*bell system sign*/
 "\001|",        /*or (was star)*/
 "\001*",        /*math * */
 "\000\0",       /*bell system sign*/
 "\001|",        /*or (was star)*/
diff --git a/usr/src/cmd/troff/textscript b/usr/src/cmd/troff/textscript
deleted file mode 100644 (file)
index ae322fe..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-g/\.data/d
-0a
-.text
-.
-w
diff --git a/usr/src/cmd/troff/tmake b/usr/src/cmd/troff/tmake
deleted file mode 100644 (file)
index ddc735d..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-CFLAGS=-n -s -O
-TFILES=n1.o n2.o n3.o n4.o n5.o t6.o n7.o n8.o n9.o t10.o ni.o nii.o tab3.o hytab.o suftab.o
-
-troff: $(TFILES)
-       cc -o troff $(CFLAGS) $(TFILES)
-
-n1.o:  tdef.h d.h v.h tw.h s.h
-n2.o:  tdef.h d.h v.h tw.h s.h
-n3.o:  tdef.h d.h v.h tw.h s.h
-n4.o:  tdef.h d.h v.h tw.h s.h
-n5.o:  tdef.h d.h v.h tw.h s.h
-n6.o:  tdef.h d.h v.h tw.h s.h
-t6.o:  tdef.h d.h v.h tw.h s.h
-n7.o:  tdef.h d.h v.h tw.h s.h
-n8.o:  tdef.h d.h v.h tw.h s.h
-n9.o:  tdef.h d.h v.h tw.h s.h
-n10.o: tdef.h d.h v.h tw.h s.h
-t10.o: tdef.h d.h v.h tw.h s.h
-ni.o:  tdef.h d.h v.h tw.h s.h
-nii.o: tdef.h d.h v.h tw.h s.h
-
-hytab.o:       hytab.c
-       cc -S hytab.c
-       ed hytab.s <textscript
-       as -o hytab.o hytab.s
-       rm hytab.s
-
-suftab.o:      suftab.c
-       cc -S suftab.c
-       ed suftab.s <textscript
-       as -o suftab.o suftab.s
-       rm suftab.s
diff --git a/usr/src/cmd/true.sh b/usr/src/cmd/true.sh
new file mode 100755 (executable)
index 0000000..e69de29
index 39b06e0..d876a5e 100644 (file)
@@ -9,13 +9,16 @@
 
 /*     the nodelist always has an empty element at the end to
  *     make it easy to grow in natural order
 
 /*     the nodelist always has an empty element at the end to
  *     make it easy to grow in natural order
-*/
+ *     states of the "live" field:*/
+#define DEAD 0 /* already printed*/
+#define LIVE 1 /* not yet printed*/
+#define VISITED 2      /*used only in findloop()*/
 
 struct nodelist {
        struct nodelist *nextnode;
        struct predlist *inedges;
        char *name;
 
 struct nodelist {
        struct nodelist *nextnode;
        struct predlist *inedges;
        char *name;
-       enum {DEAD, LIVE, ONCE, TWICE} live;
+       int live;
 } firstnode = {NULL, NULL, NULL, DEAD};
 
 /*     a predecessor list tells all the immediate
 } firstnode = {NULL, NULL, NULL, DEAD};
 
 /*     a predecessor list tells all the immediate
@@ -162,35 +165,41 @@ struct nodelist *
 findloop()
 {
        register struct nodelist *i, *j;
 findloop()
 {
        register struct nodelist *i, *j;
-       register struct predlist *p;
        for(i= &firstnode; i->nextnode!=NULL; i=i->nextnode)
                if(i->live==LIVE)
                        break;
        for(i= &firstnode; i->nextnode!=NULL; i=i->nextnode)
                if(i->live==LIVE)
                        break;
-       note("cycle in reverse order",empty);
-       while(i->live==LIVE) {
-               i->live = ONCE;
-               for(p=i->inedges; ; p=p->nextpred) {
-                       if(p==NULL)
-                               error("error 1");
-                       i = p->pred;
-                       if(i->live!=DEAD)
-                               break;
-               }
-       }
-       while(i->live==ONCE) {
-               i->live = TWICE;
-               note(i->name,empty);
-               for(p=i->inedges; ; p=p->nextpred) {
-                       if(p==NULL)
-                               error("error 2");
-                       i = p->pred;
-                       if(i->live!=DEAD)
-                               break;
-               }
-       }
+       note("cycle in data",empty);
+       i = mark(i);
+       if(i==NULL)
+               error("program error",empty);
        for(j= &firstnode; j->nextnode!=NULL; j=j->nextnode)
        for(j= &firstnode; j->nextnode!=NULL; j=j->nextnode)
-               if(j->live!=DEAD)
+               if(j->live==VISITED)
                        j->live = LIVE;
        return(i);
 }
 
                        j->live = LIVE;
        return(i);
 }
 
+/*     depth-first search of LIVE predecessors
+ *     to find some element of a cycle;
+ *     VISITED is a temporary state recording the
+ *     visits of the search
+*/
+struct nodelist *
+mark(i)
+register struct nodelist *i;
+{
+       register struct nodelist *j;
+       register struct predlist *t;
+       if(i->live==DEAD)
+               return(NULL);
+       if(i->live==VISITED)
+               return(i);
+       i->live = VISITED;
+       for(t=i->inedges; t!=NULL; t=t->nextpred) {
+               j = mark(t->pred);
+               if(j!=NULL) {
+                       note(i->name,empty);
+                       return(j);
+               }
+       }
+       return(NULL);
+}
diff --git a/usr/src/cmd/und.c b/usr/src/cmd/und.c
new file mode 100644 (file)
index 0000000..e562d5b
--- /dev/null
@@ -0,0 +1,37 @@
+#include <stdio.h>
+
+main(argc, argv)
+char **argv;
+{
+       register bflg, c, n;
+       int undc=8;
+
+       bflg = 1;
+       if (argc>1 && argv[1][0]=='-') {
+               undc = atoi(&argv[1][1]);
+               if (undc>16)
+                       undc = 0;
+               argc--;
+               argv++;
+       }
+       if (argc>1) {
+               if ((freopen(argv[1], "r", stdin))==NULL) {
+                       fprintf(stderr, "Cannot open %s\n", argv[1]);
+                       exit(1);
+               }
+       }
+       while((c = getchar()) != EOF) {
+               if(c == '\n' || c == 014) {
+                       bflg = 1;
+                       putchar(c);
+                       continue;
+               }
+               if(bflg) {
+                       for (n=0; n<undc; n++)
+                               putchar('\b');
+                       bflg = 0;
+               }
+               putchar(c);
+       }
+       return(0);
+}
index 2822c15..2cb4996 100644 (file)
@@ -443,6 +443,7 @@ char *name;
        np = name;
        while(*np)
                h = h*57 + *np++ - '0';
        np = name;
        while(*np)
                h = h*57 + *np++ - '0';
+       if( ((int)h)<0) h= -(int)h;
        h %= NTAB;
        tp = &table[h];
 l0:
        h %= NTAB;
        tp = &table[h];
 l0:
diff --git a/usr/src/cmd/uucp/anyread.c b/usr/src/cmd/uucp/anyread.c
new file mode 100644 (file)
index 0000000..0df24bc
--- /dev/null
@@ -0,0 +1,20 @@
+#include "uucp.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+
+/*******
+ *     anyread         check if anybody can read
+ *     return 0 ok: FAIL not ok
+ */
+
+anyread(file)
+char *file;
+{
+       struct stat s;
+
+       if (stat(file, &s) != 0)
+               return(FAIL);
+       if (!(s.st_mode & ANYREAD))
+               return(FAIL);
+       return(0);
+}
index 268759c..11b6204 100644 (file)
@@ -67,8 +67,10 @@ char *path, *logname, *mchname;
                        return(FAIL);
        }
 
                        return(FAIL);
        }
 
-       if (chklnk(path) > LINKLEVEL)
-               return(FAIL);
+       if (strcmp(*p, "/") != SAME) {
+               if (chklnk(path) > LINKLEVEL)
+                       return(FAIL);
+       }
        for (p = u->us_path; *p != NULL; p++)
                if (prefix(*p, path))
                        return(0);
        for (p = u->us_path; *p != NULL; p++)
                if (prefix(*p, path))
                        return(0);
index 839e871..a86be79 100644 (file)
@@ -264,7 +264,6 @@ char *flds[];
                ndev = ckdev(flds[F_LINE], flds[F_SPEED], ndev);
                if (ndev < 0) {
                        logent("AVAILABLE DEVICE", "NO");
                ndev = ckdev(flds[F_LINE], flds[F_SPEED], ndev);
                if (ndev < 0) {
                        logent("AVAILABLE DEVICE", "NO");
-                       DEBUG(4, "NO AVAILABLE DEVICE %s\n", "");
                        return(FAIL);
                }
                pd = &Devs[ndev];
                        return(FAIL);
                }
                pd = &Devs[ndev];
@@ -476,7 +475,6 @@ int nf, fn;
 struct sg_spds {int sp_val, sp_name;} spds[] = {
        { 300,  B300},
        {1200, B1200},
 struct sg_spds {int sp_val, sp_name;} spds[] = {
        { 300,  B300},
        {1200, B1200},
-       {4800, B4800},
        {9600, B9600},
        {0, 0} };
 
        {9600, B9600},
        {0, 0} };
 
index 758ee87..4cfd8d7 100644 (file)
@@ -1,9 +1,5 @@
 #include <stdio.h>
 
 #include <stdio.h>
 
-#define LQUOTE '('
-#define RQUOTE ')'
-#define NOSYSPART      0
-#define HASSYSPART     1
 
 /*******
  *     char *
 
 /*******
  *     char *
@@ -17,7 +13,6 @@ char *
 getprm(s, prm)
 char *s, *prm;
 {
 getprm(s, prm)
 char *s, *prm;
 {
-       char *c;
 
        while (*s == ' ' || *s == '\t' || *s == '\n')
                s++;
 
        while (*s == ' ' || *s == '\t' || *s == '\n')
                s++;
@@ -33,17 +28,6 @@ char *s, *prm;
                return(s);
        }
 
                return(s);
        }
 
-       /* look for quoted argument */
-       if (*s == LQUOTE) {
-               if ((c = index(s + 1, RQUOTE)) != NULL) {
-                       c++;
-                       while (c != s)
-                               *prm++ = *s++;
-                       *prm = '\0';
-                       return(s);
-               }
-       }
-
        while (*s != ' ' && *s != '\t' && *s != '<'
        && *s != '>' && *s != '|' && *s != '\0'
        && *s != ';' && *s != '\n')
        while (*s != ' ' && *s != '\t' && *s != '<'
        && *s != '>' && *s != '|' && *s != '\0'
        && *s != ';' && *s != '\n')
@@ -52,46 +36,3 @@ char *s, *prm;
 
        return(s);
 }
 
        return(s);
 }
-
-/***
- *     split(name, sys, rest)  split into system and file part
- *     char *name, *sys, *rest;
-
- *
- *     return codes:
- *             NOSYSPART
- *             HASSYSPART
- */
-
-split(name, sys, rest)
-char *name, *sys, *rest;
-{
-       char *c;
-       int i;
-
-       if (*name == LQUOTE) {
-               if ((c = index(name + 1, RQUOTE)) != NULL) {
-               /* strip off quotes */
-                       name++;
-                       while (c != name)
-                               *rest++ = *name++;
-                       *rest = '\0';
-                       *sys = '\0';
-                       return(NOSYSPART);
-               }
-       }
-
-       if ((c = index(name, '!')) == NULL) {
-               strcpy(rest, name);
-               *sys = '\0';
-               return(NOSYSPART);
-       }
-
-       *c = '\0';
-       for (i = 0; i < 7; i++)
-               if ((*sys++ = *name++) == '\0')
-                       break;
-
-       strcpy(rest, ++c);
-       return(HASSYSPART);
-}
index 36a2463..6289db0 100644 (file)
@@ -32,7 +32,7 @@ char *filename;
        for (i = 0, s = dentry.d_name; i <= DIRSIZ; i++)
                if ((filename[i] = *s++) == '\0')
                        break;
        for (i = 0, s = dentry.d_name; i <= DIRSIZ; i++)
                if ((filename[i] = *s++) == '\0')
                        break;
-       filename[NAMESIZE] = '\0';
+       filename[NAMESIZE-1] = '\0';
        return(1);
 }
 
        return(1);
 }
 
index ae0bc06..49bcbf4 100644 (file)
@@ -1,6 +1,6 @@
 CC=cc
 CC=cc
-LFLAGS=-s -i
-CFLAGS=-O
+LFLAGS=
+CFLAGS=-O -g
 LIBS=
 FRC=
 OWNER=uucpa
 LIBS=
 FRC=
 OWNER=uucpa
@@ -13,30 +13,26 @@ OFILES=cpmv.o expfile.o gename.o getpwinfo.o index.o lastpart.o \
 INIT=init
 
 all:   $(INIT) $(COMMANDS) 
 INIT=init
 
 all:   $(INIT) $(COMMANDS) 
+       :
+
+install:       all
+       install -s uucp $(DESTDIR)/bin
+       install -s uux $(DESTDIR)/bin
+       install -s uuxqt $(DESTDIR)$(INSDIR)
+       install -s uucico $(DESTDIR)$(INSDIR)
+       install -s uulog $(DESTDIR)$(INSDIR)
+       install -s uuclean $(DESTDIR)$(INSDIR)
+
+clean:
+       rm -f uucp uux uuxqt uucico uulog uuclean *.o
 
 
-cp:    all
-       cp uucp /bin
-       cp uux /bin
-       cp uuxqt $(INSDIR)
-       cp uucico $(INSDIR)
-       cp uulog /bin
-       cp uuclean $(INSDIR)
-       rm *.o uucp uux uuxqt uucico uulog uuclean
-
-cmp:   all
-       cmp uucp /bin/uucp
-       cmp uux /bin/uux
-       cmp uuxqt $(INSDIR)/uuxqt
-       cmp uucico $(INSDIR)/uucico
-       cmp uulog /bin/uulog
-       cmp uuclean $(INSDIR)/uuclean
-       rm *.o uucp uux uuxqt uucico uulog uuclean
 
 init:  anlwrk.o chkpth.o cpmv.o expfile.o gename.o \
        getargs.o getprm.o getpwinfo.o gnamef.o gnsys.o \
        gnxseq.o gwd.o imsg.o index.o lastpart.o logent.o \
        prefix.o sdmail.o shio.o sysacct.o \
 
 init:  anlwrk.o chkpth.o cpmv.o expfile.o gename.o \
        getargs.o getprm.o getpwinfo.o gnamef.o gnsys.o \
        gnxseq.o gwd.o imsg.o index.o lastpart.o logent.o \
        prefix.o sdmail.o shio.o sysacct.o \
-       systat.o ulockf.o versys.o xqt.o
+       systat.o ulockf.o versys.o xqt.o anyread.o
+       :
 
 uucp:  uucp.o gwd.o $(OFILES) chkpth.o getargs.o logent.o versys.o
        $(CC) uucp.o gwd.o $(OFILES) \
 
 uucp:  uucp.o gwd.o $(OFILES) chkpth.o getargs.o logent.o versys.o
        $(CC) uucp.o gwd.o $(OFILES) \
@@ -48,7 +44,7 @@ uucp.o: $(FRC)
 
 uux:  uux.o
        $(CC) uux.o gwd.o $(OFILES) \
 
 uux:  uux.o
        $(CC) uux.o gwd.o $(OFILES) \
-       chkpth.o getargs.o getprm.o versys.o \
+       chkpth.o getargs.o getprm.o versys.o anyread.o \
        $(LIBS) $(LFLAGS) -o uux
 
 uux.o: $(FRC)
        $(LIBS) $(LFLAGS) -o uux
 
 uux.o: $(FRC)
@@ -71,29 +67,7 @@ uucico:  cico.o conn.o cntrl.o pk0.o pk1.o gio.o uucp.h uucpdefs.h \
        $(LIBS) $(LFLAGS) -o uucico
 
 
        $(LIBS) $(LFLAGS) -o uucico
 
 
-cico.o: $(FRC)
-       $(CC) -c $(CFLAGS) cico.c
-
-conn.o: $(FRC)
-       $(CC) -c $(CFLAGS) conn.c
-
-cntrl.o: $(FRC)
-       $(CC) -c $(CFLAGS) cntrl.c
-
-gio.o: $(FRC)
-       $(CC) -c $(CFLAGS) gio.c
-
-pkon.o: $(FRC)
-       $(CC) -c $(CFLAGS) pkon.c
-
-pk0.o: $(FRC)
-       $(CC) -c $(CFLAGS) pk0.c
-
-pk1.o: $(FRC)
-       $(CC) -c $(CFLAGS) pk1.c
-
-ioctl.o: $(FRC)
-       $(CC) -c $(CFLAGS) ioctl.c
+cico.o conn.o cntrl.o gio.o pkon.o pk0.o pk1.o ioctl.o: $(FRC)
 
 uulog:  uulog.o
        $(CC) uulog.o prefix.o xqt.o ulockf.o gnamef.o \
 
 uulog:  uulog.o
        $(CC) uulog.o prefix.o xqt.o ulockf.o gnamef.o \
index ce13e7f..bbe6ecf 100644 (file)
@@ -110,6 +110,7 @@ char m, cntl, *p, imask, **bp;
 int bad,accept,skip,s,t,h,cc;
 unsigned short sum;
 
 int bad,accept,skip,s,t,h,cc;
 unsigned short sum;
 
+
        bad = accept = skip = 0;
        /*
         * wait for input
        bad = accept = skip = 0;
        /*
         * wait for input
@@ -153,7 +154,7 @@ free:
                }
 
                pk->p_is[x] = ~(B_COPY+B_MARK);
                }
 
                pk->p_is[x] = ~(B_COPY+B_MARK);
-               sum = (unsigned)chksum(pk->p_ib[x], pk->p_rsize) ^ (unsigned)cntl;
+               sum = (unsigned)chksum(pk->p_ib[x], pk->p_rsize) ^ (unsigned)(cntl&0377);
                sum += pk->p_isum[x];
                if (sum == CHECK) {
                        seq = (cntl>>3) & MOD8;
                sum += pk->p_isum[x];
                if (sum == CHECK) {
                        seq = (cntl>>3) & MOD8;
@@ -178,7 +179,7 @@ free:
                                if (cntl&B_SHORT) {
                                        pk->p_is[seq] = B_MARK+B_SHORT;
                                        p = pk->p_ib[seq];
                                if (cntl&B_SHORT) {
                                        pk->p_is[seq] = B_MARK+B_SHORT;
                                        p = pk->p_ib[seq];
-                                       cc = (unsigned)*p++;
+                                       cc = (unsigned)*p++ & 0377;
                                        if (cc & 0200) {
                                                cc &= 0177;
                                                cc |= *p << 7;
                                        if (cc & 0200) {
                                                cc &= 0177;
                                                cc |= *p << 7;
@@ -601,8 +602,8 @@ register char *s;
 register n;
 {
        register short sum;
 register n;
 {
        register short sum;
-       register unsigned t;
-       register x;
+       register unsigned short t;
+       register short x;
 
        sum = -1;
        x = 0;
 
        sum = -1;
        x = 0;
@@ -614,7 +615,7 @@ register n;
                } else
                        sum <<= 1;
                t = sum;
                } else
                        sum <<= 1;
                t = sum;
-               sum += (unsigned)*s++;
+               sum += (unsigned)*s++ & 0377;
                x += sum^n;
                if ((unsigned)sum <= t) {
                        sum ^= x;
                x += sum^n;
                if ((unsigned)sum <= t) {
                        sum ^= x;
index fc340ba..4d0588a 100644 (file)
@@ -145,7 +145,7 @@ struct pack *ipk;
        p = (caddr_t) h;
        hdchk = p[1] ^ p[2] ^ p[3] ^ p[4];
        p += 2;
        p = (caddr_t) h;
        hdchk = p[1] ^ p[2] ^ p[3] ^ p[4];
        p += 2;
-       sum = (unsigned) *p++;
+       sum = (unsigned) *p++ & 0377;
        sum |= (unsigned) *p << 8;
        h->sum = sum;
        PKDEBUG(7, "rec h->cntl %o\n", (unsigned) h->cntl);
        sum |= (unsigned) *p << 8;
        h->sum = sum;
        PKDEBUG(7, "rec h->cntl %o\n", (unsigned) h->cntl);
@@ -260,7 +260,7 @@ register x;
        }
        else {
                *p++ = hdchk = pk->p_lpsize;
        }
        else {
                *p++ = hdchk = pk->p_lpsize;
-               checkword = pk->p_osum[x] ^ (unsigned)cntl;
+               checkword = pk->p_osum[x] ^ (unsigned)(cntl&0377);
        }
        checkword = CHECK - checkword;
        *p = checkword;
        }
        checkword = CHECK - checkword;
        *p = checkword;
index d221717..4e8e0db 100644 (file)
@@ -103,10 +103,8 @@ char *name;
                return(SS_OK);
 
        case SS_INPROGRESS:
                return(SS_OK);
 
        case SS_INPROGRESS:
-               if (prestime - lasttime < INPROGTIME) {
-                       DEBUG(4, "CALL IN PROGRESS %s\n", "");
+               if (prestime - lasttime < INPROGTIME)
                        return(type);
                        return(type);
-               }
                else
                        return(SS_OK);
 
                else
                        return(SS_OK);
 
@@ -114,13 +112,11 @@ char *name;
        case SS_FAIL:
                if (count > MAXRECALLS) {
                        logent("MAX RECALLS", "NO CALL");
        case SS_FAIL:
                if (count > MAXRECALLS) {
                        logent("MAX RECALLS", "NO CALL");
-                       DEBUG(4, "MAX RECALL COUNT %d\n", count);
                        return(type);
                }
 
                if (prestime - lasttime < RETRYTIME) {
                        logent("RETRY TIME NOT REACHED", "NO CALL");
                        return(type);
                }
 
                if (prestime - lasttime < RETRYTIME) {
                        logent("RETRY TIME NOT REACHED", "NO CALL");
-                       DEBUG(4, "RETRY TIME (%d) NOT REACHED\n", RETRYTIME);
                        return(type);
                }
 
                        return(type);
                }
 
index 599c03d..301afbc 100644 (file)
@@ -1,6 +1,6 @@
 #include "stdio.h"
        /*  some system names  */
 #include "stdio.h"
        /*  some system names  */
-#define MYNAME         "myname"
+#define MYNAME         "vax135"
 
 #define THISDIR                "/usr/lib/uucp"
 #define SQFILE         "/usr/lib/uucp/SQFILE"
 
 #define THISDIR                "/usr/lib/uucp"
 #define SQFILE         "/usr/lib/uucp/SQFILE"
@@ -52,6 +52,7 @@ cleanup(FAIL);};
 #define EOTMSG "\004\n\004\n"
 #define CALLBACK 1
 #define LINKLEVEL 1
 #define EOTMSG "\004\n\004\n"
 #define CALLBACK 1
 #define LINKLEVEL 1
+#define ANYREAD 04
 
        /*  commands  */
 #define SHELL          "/bin/sh"
 
        /*  commands  */
 #define SHELL          "/bin/sh"
index 6f8bc98..96e2cb5 100644 (file)
@@ -325,3 +325,34 @@ int code;
        DEBUG(1, "exit code %d\n", code);
        exit(code);
 }
        DEBUG(1, "exit code %d\n", code);
        exit(code);
 }
+
+/***
+ *     split(name, sys, rest)  split into system and file part
+ *     char *name, *sys, *rest;
+
+ *
+ *     return codes:
+ *             NOSYSPART
+ *             HASSYSPART
+ */
+
+split(name, sys, rest)
+char *name, *sys, *rest;
+{
+       char *c;
+       int i;
+
+       if ((c = index(name, '!')) == NULL) {
+               strcpy(rest, name);
+               *sys = '\0';
+               return(NOSYSPART);
+       }
+
+       *c = '\0';
+       for (i = 0; i < 7; i++)
+               if ((*sys++ = *name++) == '\0')
+                       break;
+
+       strcpy(rest, ++c);
+       return(HASSYSPART);
+}
diff --git a/usr/src/cmd/uudiff/Makefile b/usr/src/cmd/uudiff/Makefile
new file mode 100644 (file)
index 0000000..1554397
--- /dev/null
@@ -0,0 +1,20 @@
+CFLAGS=-O
+
+uudiff: lenrem locpart printable run1 trim
+
+lenrem: lenrem.c
+       cc $(CFLAGS) lenrem.c -o lenrem
+locpart: locpart.c
+       cc $(CFLAGS) locpart.c -o locpart
+printable: printable.c
+       cc $(CFLAGS) printable.c -o printable
+run1: run1.c
+       cc $(CFLAGS) run1.c -o run1
+trim: trim.c
+       cc $(CFLAGS) trim.c -o trim
+
+install:
+       : stuff lives here!
+
+clean:
+       rm -f *.o
diff --git a/usr/src/cmd/uudiff/lenrem.c b/usr/src/cmd/uudiff/lenrem.c
new file mode 100644 (file)
index 0000000..1ee56e9
--- /dev/null
@@ -0,0 +1,9 @@
+main(argc,argv)
+       char *argv[];
+{
+/* args: 1 is name to fix, 2 is this directory */
+if (argv[1][0] == '/')
+       printf("%s\n",argv[1]);
+else
+       printf("%s/%s\n", argv[2], argv[1]);
+}
diff --git a/usr/src/cmd/uudiff/locpart.c b/usr/src/cmd/uudiff/locpart.c
new file mode 100644 (file)
index 0000000..e0a7176
--- /dev/null
@@ -0,0 +1,8 @@
+main(argc,argv)
+       char *argv[];
+{
+char *p;
+for (p=argv[1]; *p; p++);
+while (*p != '/') p--;
+printf("%s\n", p+1);
+}
diff --git a/usr/src/cmd/uudiff/printable.c b/usr/src/cmd/uudiff/printable.c
new file mode 100644 (file)
index 0000000..2c94072
--- /dev/null
@@ -0,0 +1,12 @@
+main(argc,argv)
+       char *argv[];
+{
+char b[512], *p;
+int f, c;
+f = open(argv[1], 0);
+if (f<0) return(1);
+p = b + read(f, b, 512);
+while (p>b)
+       if ( (c= *--p) ==0 || (c&0200) ) return(1);
+return(0);
+}
diff --git a/usr/src/cmd/uudiff/remdiff b/usr/src/cmd/uudiff/remdiff
new file mode 100755 (executable)
index 0000000..e2aa342
--- /dev/null
@@ -0,0 +1,113 @@
+: 'usage: uudiff directory-local sys![directory-remote]'
+
+set UUDIR=/usr/src/cmd/uudiff
+set UUCP=/usr/src/cmd/uucp
+set SPOOL=/usr/tmp/uucp
+set UNIXNAME=vax1
+set DIFF=YES
+case $1 in
+       -d) set DIFF=NO; shift;;
+esac
+
+set HERE=`pwd`
+set ME=`getuid`
+
+set LOCAL=$1
+set SYS=`echo $2 | sed "s/!.*//"`
+if [ $SYS = $2 ]
+       then set SYS=$UNIXNAME
+fi
+
+set REMOTE=`echo $2 | sed "s/.*!//"`
+if [ x$REMOTE = x ]
+       then set $REMOTE = $LOCAL
+fi
+
+set LOCAL=`$UUDIR/lenrem $LOCAL $HERE`
+set REMOTE=`$UUDIR/lenrem $REMOTE $HERE`
+set LOCDIR=$LOCAL
+set DIR=YES
+set REMDIR=$REMOTE
+if [ -f $LOCDIR ]
+       then
+       set LOCDIR=`$UUDIR/trim $LOCDIR`
+       set REMDIR=`$UUDIR/trim $REMDIR`
+       set DIR=NO
+       fi
+
+cat >zza$pid <<!
+$UUCP/filsum $REMOTE >zzb$pid
+!
+uucp -f zza$pid $SYS!ef$pid
+$UUCP/tdemon >>/$UUCP/tmess &
+if [ $SYS = research ]
+       then
+       cat >$SPOOL/cq$pid <<%
+zzb$pid
+
+cp zzb$pid $HERE/zzc$pid
+%
+else
+uucp -f -w $SYS!zzb$pid $HERE/zzc$pid
+fi
+$UUCP/tdemon >>/$UUCP/tmess &
+$UUCP/filsum $LOCAL >zzd$pid
+cat >$SPOOL/cz$pid <<!
+$HERE/zzc$pid
+
+chdir $HERE
+cat >zzy$pid <<%
+rm zzb$pid
+%
+uucp -f zzy$pid $SYS!ey$pid
+rm zzy$pid
+cat >uudiff$pid <<%
+uudiff comparison of
+  $LOCAL here
+with
+  $REMOTE on system $SYS
+
+
+
+%
+$UUDIR/run1 zzd$pid zzc$pid  zzl$pid  | sort >>uudiff$pid
+
+cat >zzm$pid <<%
+cg$pid
+%
+cat >zzn$pid <<%
+
+chdir $HERE
+%
+
+if [ $DIFF = YES ]
+       then
+       if [ $DIR = NO ]
+               then $UUDIR/locpart $LOCAL >zzl$pid
+               fi
+       for f in \`cat zzl${pid}\`
+       do
+               if $UUDIR/printable $LOCDIR/\$f
+               then
+               if [ $DIR = YES ]
+                       then uucp $SYS!$REMDIR/\$f \$f.$pid
+                       else uucp $SYS!$REMOTE \$f.$pid
+                       fi
+               echo $HERE/\$f.$pid >>zzm$pid
+               cat >>zzn$pid <<%
+
+echo >>uudiff$pid
+echo DIFF of \$f: '(< here, > remote)' >>uudiff$pid
+diff $LOCDIR/\$f \$f.$pid >>uudiff$pid
+%
+               fi
+       done
+fi
+
+cat >>zzn$pid <<%
+echo uudiff$pid arrived in $HERE "|" mail $ME
+rm zz?$pid
+%
+cat zzm$pid zzn$pid >>$SPOOL/cg$pid
+!
+$UUCP/tdemon >>/$UUCP/tmess 
diff --git a/usr/src/cmd/uudiff/run1.c b/usr/src/cmd/uudiff/run1.c
new file mode 100644 (file)
index 0000000..60e6553
--- /dev/null
@@ -0,0 +1,76 @@
+# include "stdio.h"
+# define LAST "\177\177"
+main (argc,argv)
+       char *argv[];
+{
+       FILE *rem, *loc, *cfil;
+       char namel[100], namer[100];
+       char cname[20], zname[20];
+       int mr, ml;
+       long suml, sumr;
+ml=mr=1;
+loc = fopen(argv[1], "r");
+rem = fopen (argv[2], "r");
+cfil = fopen (argv[3], "w");
+ml = fetch (loc, namel, &suml, ml);
+mr = fetch (rem, namer, &sumr, mr);
+while ( ml || mr)
+       {
+       int x;
+       x = strcmp(namel, namer);
+       if (x>0) x=1;
+       if (x<0) x= -1;
+       switch(x)
+               {
+               case -1: /* name l lower */
+                       /* check that file is not our zz* tempfile */
+                       if (notmp(namel, argv[2]))
+                       printf("Missing on remote system: %s\n",namel);
+                       ml = fetch (loc, namel, &suml, ml);
+                       continue;
+               case 0: /* match names */
+                       if (strcmp(namel, LAST)==0)
+                               exit(0);
+                       if (suml == sumr)
+                               printf("Presumed identical: %s\n",namel);
+                       else
+                               {
+                               printf("Differ: %s\n", namel);
+                               fprintf(cfil, "%s\n", namel);
+                               }
+                       ml=fetch(loc, namel, &suml, ml);
+                       mr=fetch(rem, namer, &sumr, mr);
+                       continue;
+               case 1: /* name 2 lower */
+                       printf("Extraneous file on remote system: %s\n",namer);
+                       mr=fetch(rem, namer, &sumr, mr);
+                       continue;
+               default:
+                       printf("illegal case %d\n", strcmp(namel,namer));
+                       exit(0);
+               }
+       }
+}
+fetch (f, s, lp, m)
+       FILE *f;
+       char *s;
+       long *lp;
+{
+char b[200];
+if (m==0 ||fgets(b, 200, f)==0)
+       {
+       strcpy (s, LAST);
+       return (0);
+       }
+sscanf(b, "%s %lo", s, lp);
+return (1);
+}
+notmp(s1, s2)
+       char *s1, *s2;
+{
+char bf1[20], bf2[20];
+strcpy (bf1, s1);
+strcpy (bf2, s2);
+bf1[2]= bf2[2] = '0';
+return (strcmp(bf1, bf2));
+}
diff --git a/usr/src/cmd/uudiff/trim.c b/usr/src/cmd/uudiff/trim.c
new file mode 100644 (file)
index 0000000..c989966
--- /dev/null
@@ -0,0 +1,15 @@
+# if interdata
+# include "stdio.h"
+# endif
+main(argc,argv)
+       char *argv[];
+{
+char *nm, *p;
+p = nm = argv[1];
+while (*p) p++;
+while (*p != '/') p--;
+if (p==nm) p++;
+*p = 0;
+printf("%s\n", nm);
+exit(0);
+}
diff --git a/usr/src/cmd/vis.c b/usr/src/cmd/vis.c
new file mode 100644 (file)
index 0000000..2b083bc
--- /dev/null
@@ -0,0 +1,47 @@
+#include <stdio.h>
+#defi\ ee        MAXCOL  72      /* fold after here */
+
+/*
+ *     vis - make all funny characters visible
+ */
+
+main(argc, argv)
+char *argv[];
+{
+       FILE *fp;
+
+       if (argc <= 1)
+               vis(stdin);
+       else
+               while (--argc > 0) {
+                       if ((fp = fopen(*++argv, "r")) == NULL) {
+                               fprintf(stderr, "vis: can't open %s\n", *argv);
+                               exit(1);
+                       }
+                       vis(fp);
+                       fclose(fp);
+               }
+       exit(0);
+}
+
+vis(fp)        /* make visible output of file fp */
+FILE *fp;
+{
+       int c, col=0;
+
+       while ((c = getc(fp)) != EOF) {
+               if (c == '\n' || c == '\t' || c >= ' ' && c <= 0176) {
+                       putchar(c);
+                       col++;
+               } else {
+                       printf("\\%03o", c);
+                       col += 4;
+               }
+               if (c == '\n')
+                       col = 0;
+               if (col > MAXCOL) {
+                       printf("\\\n");
+                       col = 0;
+               }
+       }
+}
index 003ff7c..e174cc9 100644 (file)
@@ -3,15 +3,17 @@
 #define        USERS   50
 
 char   mesg[3000];
 #define        USERS   50
 
 char   mesg[3000];
-int    msize;
+int    msize,sline;
 struct utmp utmp[USERS];
 char   *strcpy();
 char   *strcat();
 struct utmp utmp[USERS];
 char   *strcpy();
 char   *strcat();
+char who[9] = "???";
 
 main(argc, argv)
 char *argv[];
 {
        register i;
 
 main(argc, argv)
 char *argv[];
 {
        register i;
+       register char c;
        register struct utmp *p;
        FILE *f;
 
        register struct utmp *p;
        FILE *f;
 
@@ -23,6 +25,7 @@ char *argv[];
        fclose(f);
        f = stdin;
        if(argc >= 2) {
        fclose(f);
        f = stdin;
        if(argc >= 2) {
+               /* take message from unix file instead of standard input */
                if((f = fopen(argv[1], "r")) == NULL) {
                        fprintf(stderr,"Cannot open %s\n", argv[1]);
                        exit(1);
                if((f = fopen(argv[1], "r")) == NULL) {
                        fprintf(stderr,"Cannot open %s\n", argv[1]);
                        exit(1);
@@ -30,6 +33,12 @@ char *argv[];
        }
        while((i = getc(f)) != EOF) mesg[msize++] = i;
        fclose(f);
        }
        while((i = getc(f)) != EOF) mesg[msize++] = i;
        fclose(f);
+       sline = ttyslot(2); /* 'utmp' slot no. of sender */
+       if (sline) {
+               for (i=0;c=utmp[sline].ut_name[i];i++)
+                       who[i]=c;
+               who[i] = '\0'; /* sender initials */
+               }
        for(i=0; i<USERS; i++) {
                p = &utmp[i];
                if(p->ut_name[0] == 0)
        for(i=0; i<USERS; i++) {
                p = &utmp[i];
                if(p->ut_name[0] == 0)
@@ -62,7 +71,8 @@ char *tty;
                exit(1);
        }
        setbuf(f, buf);
                exit(1);
        }
        setbuf(f, buf);
-       fprintf(f, "\a\a\aBroadcast Message ...\n\n");
+       fprintf(f, "\a\a\aBroadcast Message from %s (%s) ...\n\n",who,
+               utmp[sline].ut_line);
        fwrite(mesg, msize, 1, f);
        exit(0);
 }
        fwrite(mesg, msize, 1, f);
        exit(0);
 }
index 194fe96..27e0b1d 100644 (file)
@@ -9,7 +9,7 @@ struct utmp utmp;
 struct passwd *pw;
 struct passwd *getpwuid();
 
 struct passwd *pw;
 struct passwd *getpwuid();
 
-char *ttyname(), *rindex(), *ctime(), *strcpy(), *index();
+char *ttyname(), *rindex(), *ctime(), *strcpy();
 main(argc, argv)
 char **argv;
 {
 main(argc, argv)
 char **argv;
 {
@@ -22,7 +22,7 @@ char **argv;
        if (argc==3) {
                tp = ttyname(0);
                if (tp)
        if (argc==3) {
                tp = ttyname(0);
                if (tp)
-                       tp = index(tp+1, '/') + 1;
+                       tp = rindex(tp, '/') + 1;
                else {  /* no tty - use best guess from passwd file */
                        pw = getpwuid(getuid());
                        strcpy(utmp.ut_name, pw?pw->pw_name: "?");
                else {  /* no tty - use best guess from passwd file */
                        pw = getpwuid(getuid());
                        strcpy(utmp.ut_name, pw?pw->pw_name: "?");
@@ -40,8 +40,8 @@ char **argv;
                if(argc==3) {
                        if (strcmp(utmp.ut_line, tp))
                                continue;
                if(argc==3) {
                        if (strcmp(utmp.ut_line, tp))
                                continue;
-#ifdef interdata
-                       printf("(Interdata) ");
+#ifdef vax
+                       printf("(Vax) ");
 #endif
                        putline();
                        exit(0);
 #endif
                        putline();
                        exit(0);
index febeadf..b896a7c 100644 (file)
@@ -18,7 +18,7 @@ char  *mytty;
 char   histty[32];
 char   *histtya;
 char   *ttyname();
 char   histty[32];
 char   *histtya;
 char   *ttyname();
-char   *rindex(), *index();
+char   *rindex();
 int    logcnt;
 int    eof();
 int    timout();
 int    logcnt;
 int    eof();
 int    timout();
@@ -48,7 +48,7 @@ char *argv[];
                printf("Can't find your tty\n");
                exit(1);
        }
                printf("Can't find your tty\n");
                exit(1);
        }
-       mytty = index(mytty+1, '/') + 1;
+       mytty = rindex(mytty, '/') + 1;
        if (histtya) {
                strcpy(histty, "/dev/");
                strcat(histty, histtya);
        if (histtya) {
                strcpy(histty, "/dev/");
                strcat(histty, histtya);
@@ -99,7 +99,6 @@ cont:
                exit(1);
        }
        if (access(histty, 0) < 0) {
                exit(1);
        }
        if (access(histty, 0) < 0) {
-               printf("%s: ", histty);
                printf("No such tty\n");
                exit(1);
        }
                printf("No such tty\n");
                exit(1);
        }
index 90a92c8..f86de3c 100644 (file)
@@ -1,22 +1,22 @@
-CFLAGS = -n -O -s
-
-cp:    all
-       cp xsend xget enroll /bin
-       rm *.o xsend xget enroll
-
-cmp:   all
-       cmp xsend /bin/xsend
-       cmp xget /bin/xget
-       cmp enroll /bin/enroll
-       rm *.o xsend xget enroll
+CFLAGS = -O -d2
 
 all:   enroll xsend xget
 
 all:   enroll xsend xget
+
 enroll:        enroll.o lib.o
 enroll:        enroll.o lib.o
-       cc -n -s enroll.o lib.o -lmp -o enroll
+       cc enroll.o lib.o -lmp -o enroll
 xget:  xget.o lib.o
 xget:  xget.o lib.o
-       cc -n -s xget.o lib.o -lmp -o xget
+       cc xget.o lib.o -lmp -o xget
 xsend: xsend.o lib.o
 xsend: xsend.o lib.o
-       cc -n -s xsend.o lib.o -lmp -o xsend
+       cc xsend.o lib.o -lmp -o xsend
 enroll.o xget.o xsend.o lib.o: xmail.h
 enroll.o xget.o xsend.o lib.o: xmail.h
+
 list:
        @pr -2 -w124 m.h xmail.h enroll.c xsend.c xget.c lib.c makefile
 list:
        @pr -2 -w124 m.h xmail.h enroll.c xsend.c xget.c lib.c makefile
+
+install: enroll xsend xget
+       install -s enroll $(DESTDIR)/usr/bin
+       install -s xsend $(DESTDIR)/usr/bin
+       install -s xget $(DESTDIR)/usr/bin
+
+clean:
+       rm -f *.o
diff --git a/usr/src/cmd/yacc/Makefile b/usr/src/cmd/yacc/Makefile
new file mode 100644 (file)
index 0000000..6e94edf
--- /dev/null
@@ -0,0 +1,10 @@
+CFLAGS=-O -DWORD32
+head: yacc 
+yacc: y1.o y2.o y3.o y4.o
+       $(CC) -o yacc y?.o 
+y1.o y2.o y3.o y4.o: dextern files
+install:
+       install -s yacc $(DESTDIR)/usr/bin
+       install -c yaccpar $(DESTDIR)/usr/lib
+clean :
+       rm -f *.o 
index 6a1c47a..c9d4676 100644 (file)
@@ -4,6 +4,7 @@
        /* on some systems, notably IBM, the names for the output files and tempfiles must
        /* also be changed  */
 
        /* on some systems, notably IBM, the names for the output files and tempfiles must
        /* also be changed  */
 
+#define WORD32
        /* location of the parser text file */
 # define PARSER "/usr/lib/yaccpar"
 
        /* location of the parser text file */
 # define PARSER "/usr/lib/yaccpar"
 
diff --git a/usr/src/cmd/yacc/makefile b/usr/src/cmd/yacc/makefile
deleted file mode 100644 (file)
index 70d9f3e..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-CFLAGS=-O
-all: yacc
-       :
-
-cmp: all
-       cmp yacc /bin/yacc
-       rm yacc *.o
-
-cp:    all
-       cp yacc /bin/yacc
-       rm yacc *.o
-
-yacc: y1.o y2.o y3.o y4.o
-       cc -i -s -o yacc y?.o
-
-y1.o y2.o y3.o y4.o: dextern files
diff --git a/usr/src/cmd/yacc/yaccdiffs b/usr/src/cmd/yacc/yaccdiffs
new file mode 100644 (file)
index 0000000..e5f7f4f
--- /dev/null
@@ -0,0 +1,198 @@
+
+
+
+
+
+
+
+
+
+                      Yacc Differences
+
+
+
+
+
+This document gives a short list of differences between  the
+new Yacc and earlier Yaccs.
+
+_\bB_\bu_\bg_\bs _\bF_\bi_\bx_\be_\bd
+
+1.   There was a bug which caused  Yacc  to  silently  steal
+     away in the night if an action had mismatched '' in it;
+     this is fixed.
+
+2.   A number of table size overflow conditions used  to  be
+     checked incorrectly or not at all; this is now better.
+
+3.   A bug which suppressed the printing of some rules  with
+     empty RHS's on the y.output file has been fixed.
+
+_\bS_\bp_\be_\be_\bd_\bu_\bp_\bs, _\bS_\bh_\br_\bi_\bn_\bk_\bs, _\ba_\bn_\bd _\bD_\bi_\bd_\bd_\bl_\be_\bs
+
+1.   The old optimizer (-o) flag is now the default in Yacc.
+     At the same time, the Yacc process itself has been sped
+     up; the result is that Yacc takes  about  the  same  or
+     slightly  longer on short inputs, but is much faster on
+     long inputs.
+
+2.   The optimized parsers produced by Yacc are likely to be
+     2-3  times  faster  and 1-2k bytes smaller than the old
+     ones, for medium/large grammars.  The time to parse  is
+     now  essentially  independent  of  the grammar size; it
+     used to grow as the size of the grammar did.
+
+3.   The y.output file has been considerably reformatted, to
+     make  it easier to read.  The old "goto" table is gone;
+     the goto's for nonterminal symbols are now  printed  in
+     the  states  where  they  occur.   Rules  which  can be
+     reduced in a state have their rule number printed after
+     them,  in  ().   This makes it much easier to interpret
+     the "reduce n" actions.  The message "same  as  n"  has
+     been  removed; duplicate states are in fact duplicated,
+     saving shuffling and cross-referencing.
+
+4.   Various table sizes are somewhat bigger.
+
+5.   The form feed character, and the construction '\f', are
+     now  recognized;  form feed is ignored (=whitespace) on
+     input.
+
+
+
+
+                      January 14, 1977
+
+
+
+
+
+                           - 2 -
+
+
+
+6.   The arrays "yysterm" and "yysnter" are no  longer  pro-
+     duced  on  output; they were little used, and took up a
+     surprising amount of space in the parser.
+
+7.   Rules in the input which are not reduced are  now  com-
+     plained  about; they may represent unreachable parts of
+     the grammar, botched precedence,  or  duplicate  rules.
+     As  with  conflicts,  a summary complaint, "n rules not
+     reduced", appears at the terminal; more information  is
+     on the y.output file.
+
+_\bN_\be_\bw _\bF_\be_\ba_\bt_\bu_\br_\be_\bs
+
+1.   The actions are now  copied  into  the  middle  of  the
+     parser, rather than being gathered into a separate rou-
+     tine.  It's faster.  Also, you can return a value  from
+     yyparse (and stop parsing...) by saying `return(x);' in
+     an action.  There are  macros  which  simulate  various
+     interesting parsing actions:
+
+     YYERROR  causes the parser to behave as if a syntax
+     error had been encountered (i.e., do error recovery)
+     YYACCEPT causes a return from yyparse with a value of 0
+     YYABORT  causes a return from yyparse with a value of 1
+
+
+2.   The repositioning of the actions may cause scope  prob-
+     lems  for  some people who include lexical analyzers in
+     funny places.  This can probably be  avoided  by  using
+     another  new  feature:  the `-d' option.  Invoking Yacc
+     with the -d option causes  the  #defines  generated  by
+     Yacc  to  be  written out onto a file called "y.tab.h",
+     (as well as on the "y.tab.c" file).  This can  then  be
+     included as desired in lexical analyzers, etc.
+
+3.   Actions  are  now  permitted  within  rules;  for  such
+     actions,  $$, $1, $2, etc. continue to have their usual
+     meanings.  An error  message  is  returned  if  any  $n
+     refers  to  a value lying to the right of the action in
+     the rule.  These internal actions are assumed to return
+     a  value,  which  is accessed through the $n mechanism.
+     In the y.output file, the actions are  referred  to  by
+     created  nonterminal  names  of  the  form  $$nnn.  All
+     actions within rules are assumed to  be  distinct.   If
+     some   actions   are   the   same,  Yacc  might  report
+     reduce/reduce conflicts  which  could  be  resolved  by
+     explicitly  identifying  identical actions; does anyone
+     have a good idea for a syntax to do this?  The  =  sign
+     may  now be omitted in action constructions of the form
+     ={  ...   }.
+
+
+
+
+
+
+                      January 14, 1977
+
+
+
+
+
+                           - 3 -
+
+
+
+4.   As a result of the rearrangement of rules,  people  who
+     thought they knew what $1 really turned into, and wrote
+     programs which referred to yypv[1], etc., are in  trou-
+     ble.  See Steve Johnson if you are really suffering.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+                      January 14, 1977
+
+
diff --git a/usr/src/cmd/yacc/yaccnews b/usr/src/cmd/yacc/yaccnews
new file mode 100644 (file)
index 0000000..547c81e
--- /dev/null
@@ -0,0 +1,149 @@
+5/18/78
+A new version of Yacc has been installed which contains some new
+features relating to error recovery, detection of funny conditions in the
+grammar, and strong typing.  Existing grammars should continue to work,
+with the possible exception of somewhat better error recovery behavior.
+More details follow:
+
+***    Ratfor and EFL Yacc are dead.  Long live C!
+
+***    The y.tab.c file now uses the # line feature to reflect
+       most error conditions in actions, etc., back to the yacc source
+       file, rather than the y.tab.c file.  As always with such features,
+       lookahead may cause the line number to be one too large
+       occasionally.
+
+***    The error recovery algorithm has been changed to cause the
+       parser never to reduce on a state where there is a shift
+       on the special token `error'.  This has the effect of causing
+       the error recovery action to take place somewhat closer to the
+       location of the error than previously.  It does not affect the
+       behavior of the parser in the absence of errors.  The parse
+       tables may be 1-2% larger as a result of this change.
+
+***    Yacc now detects the existence of nonterminals in the grammar
+       which can never derive any strings of tokens (even the empty string).
+       The simplest example is the grammar:
+               %%
+               s       :       s 'a' ;
+       Here, one must reduce `s' in order to reduce `s': the
+       parser would always report error.  If such nonterminals are
+       present, Yacc reports all such, then terminates.
+
+***    There is a new reserved word, %start.  When used in the declarations
+       section, it may be used to declare the start symbol of the grammar.
+       If %start does not appear, the start symbol is, as at present, the
+       first nonterminal symbol encountered.
+
+***    Yacc produced parsers are notorious for producing many many
+       comments from lint.  The problem is the value stack of the
+       parser, which typically may contain integers, pointers, and
+       possibly even floating point, etc., values.  The lack
+       of tight specification of this stack leads to potential
+       nonportability, and considerable loss of the diagnostic power
+       of lint.  Thus, some new features have been added which make use
+       of the new structure and union facilities of C.  In effect,
+       the user of Yacc may `honestly' declare the value stack, as
+       well as the lexical interface variable, yylval, to be unions
+       of all the types desired.  Yacc will keep track of the types
+       declared for all terminals and nonterminals, and automatically
+       insert the appropriate union tag for all constructions such
+       as $1, $$, etc.  It is up to the user to supply the appropriate
+       union declaration, and to declare the type of all the terminal
+       and nonterminal symbols which will have values.  If the type
+       declaration feature is used at all, it must be used correctly;
+       if it is not used, the default values are integers, as at present.
+       The new type declaration features are described below:
+
+***    There is a new keyword, %union.  A construction such as
+               %union {
+                       int inttag;
+                       float floattag;
+                       struct mumble *ptrtag;
+                       }
+       can be used, in the declarations section, to declare
+       the type of the yacc stack.  The declaration is
+       effectively copied to the y.tab.c file, and, if the -d
+       option is present, to the y.tab.h file as well.  The
+       declaration is used to declare the typedef YYSTYPE, which is the
+       type of the value stack.  If the -d option is present,
+       the declaration
+               extern YYSTYPE yylval;
+       is also placed onto the y.tab.h file.  Note that the lexical
+       analyzer must be changed to use the appropriate union tag when
+       assigning values.  It is not necessary that the %union
+       mechanism be used, as long as there is a union type YYSTYPE
+       defined in the declarations section.
+
+***    The %token, %left, %right, and %nonassoc declarations now
+       accept a union tag, enclosed in angle brackets (<...>), immediately
+       after the keyword.  All tokens mentioned in that declaration are
+       taken to have the appropriate type.
+
+***    There is a new keyword, %type, also followed by a union tag
+       in angle brackets, which may be used in the declarations section to
+       declare nonterminal symbols to have a particular type.
+
+       In both cases, whenever a $$ or $n is encountered in an action,
+       the appropriate union tag is supplied by Yacc.  Once any type is
+       declared, it is an error to use a $$ or $n whose type is unknown.
+       It is also illegal to have a grammar rule whose LHS has a type,
+       but the rule has no action and the default action { $$ = $1; }
+       would be inapplicable because $1 had a different type.
+
+***    There are occasional times when the type of something is
+       not known (for example, when an action within a rule returns a
+       value).  In this case, the $$ and $n syntax is extended
+       to permit the declaration of the type: the syntax is
+               $<tag>$
+       and
+               $<tag>n
+       respectively.  This rather strange syntax is necessitated by the 
+       need to distinguish the <> surrounding the tag from the < and >
+       operators of C in the action.  It is anticipated that the usage
+       will be rare.
+
+***    As always, report gripes, bugs, suggestions to SCJ ***
+
+12/01/76
+A newer version of Yacc has been installed which copies the actions directly
+into the parser, rather than gathering them into a separate routine.
+The advantages include
+1.  It's faster
+2.  You can return a value from yyparse (and stop parsing...) by
+    saying `return(x);' in an action
+3.  There are macros which simulate various interesting parsing
+    actions:
+      YYERROR  causes the parser to behave as if a syntax
+               error had been encountered (i.e., do error recovery)
+      YYACCEPT causes a return from yyparse with a value of 0
+      YYABORT  causes a return from yyparse with a value of 1
+
+The repositioning of the actions may cause scope problems
+for some people who include lexical analyzers in funny places.
+This can probably be avoided by using another
+new feature: the `-d' option.
+Invoking Yacc with the -d option causes the #defines
+generated by Yacc to be written out onto a file
+called "y.tab.h".  This can then be included as desired
+in lexical analyzers, etc.
+
+11/28/76
+A new version of Yacc has been installed which permits actions within
+rules.  For such actions, $$ and $1, $2, etc. continue to have their
+usual meanings.  An error message is returned if any $n refers to
+a value lying to the right of the action in the rule.
+
+These internal actions are assumed to return a value, which is accessed
+through the $n mechanism.
+
+In the y.output file, the actions are referred to by created nonterminal
+names of the form $$nnn.
+
+All actions within rules are assumed to be distinct.  If some actions
+are the same, Yacc might report reduce/reduce conflicts which could
+be resolved by explicitly identifying identical actions; does anyone
+have a good idea for a syntax to do this?
+
+In the new Yacc, the = sign may now be omitted in action constructions
+of the form    ={  ...   }
diff --git a/usr/src/cmd/yacc/yaccpar b/usr/src/cmd/yacc/yaccpar
new file mode 100644 (file)
index 0000000..daa01c4
--- /dev/null
@@ -0,0 +1,149 @@
+#
+# define YYFLAG -1000
+# define YYERROR goto yyerrlab
+# define YYACCEPT return(0)
+# define YYABORT return(1)
+
+/*     parser for yacc output  */
+
+#ifdef YYDEBUG
+int yydebug = 0; /* 1 for debugging */
+#endif
+YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
+int yychar = -1; /* current input token number */
+int yynerrs = 0;  /* number of errors */
+short yyerrflag = 0;  /* error recovery flag */
+
+yyparse() {
+
+       short yys[YYMAXDEPTH];
+       short yyj, yym;
+       register YYSTYPE *yypvt;
+       register short yystate, *yyps, yyn;
+       register YYSTYPE *yypv;
+       register short *yyxi;
+
+       yystate = 0;
+       yychar = -1;
+       yynerrs = 0;
+       yyerrflag = 0;
+       yyps= &yys[-1];
+       yypv= &yyv[-1];
+
+ yystack:    /* put a state and value onto the stack */
+
+#ifdef YYDEBUG
+       if( yydebug  ) printf( "state %d, char 0%o\n", yystate, yychar );
+#endif
+               if( ++yyps> &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
+               *yyps = yystate;
+               ++yypv;
+               *yypv = yyval;
+
+ yynewstate:
+
+       yyn = yypact[yystate];
+
+       if( yyn<= YYFLAG ) goto yydefault; /* simple state */
+
+       if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
+       if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;
+
+       if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
+               yychar = -1;
+               yyval = yylval;
+               yystate = yyn;
+               if( yyerrflag > 0 ) --yyerrflag;
+               goto yystack;
+               }
+
+ yydefault:
+       /* default state action */
+
+       if( (yyn=yydef[yystate]) == -2 ) {
+               if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
+               /* look through exception table */
+
+               for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
+
+               while( *(yyxi+=2) >= 0 ){
+                       if( *yyxi == yychar ) break;
+                       }
+               if( (yyn = yyxi[1]) < 0 ) return(0);   /* accept */
+               }
+
+       if( yyn == 0 ){ /* error */
+               /* error ... attempt to resume parsing */
+
+               switch( yyerrflag ){
+
+               case 0:   /* brand new error */
+
+                       yyerror( "syntax error" );
+               yyerrlab:
+                       ++yynerrs;
+
+               case 1:
+               case 2: /* incompletely recovered error ... try again */
+
+                       yyerrflag = 3;
+
+                       /* find a state where "error" is a legal shift action */
+
+                       while ( yyps >= yys ) {
+                          yyn = yypact[*yyps] + YYERRCODE;
+                          if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
+                             yystate = yyact[yyn];  /* simulate a shift of "error" */
+                             goto yystack;
+                             }
+                          yyn = yypact[*yyps];
+
+                          /* the current yyps has no shift onn "error", pop stack */
+
+#ifdef YYDEBUG
+                          if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
+#endif
+                          --yyps;
+                          --yypv;
+                          }
+
+                       /* there is no state on the stack with an error shift ... abort */
+
+       yyabort:
+                       return(1);
+
+
+               case 3:  /* no shift yet; clobber input char */
+
+#ifdef YYDEBUG
+                       if( yydebug ) printf( "error recovery discards char %d\n", yychar );
+#endif
+
+                       if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
+                       yychar = -1;
+                       goto yynewstate;   /* try again in the same state */
+
+                       }
+
+               }
+
+       /* reduction by production yyn */
+
+#ifdef YYDEBUG
+               if( yydebug ) printf("reduce %d\n",yyn);
+#endif
+               yyps -= yyr2[yyn];
+               yypvt = yypv;
+               yypv -= yyr2[yyn];
+               yyval = yypv[1];
+               yym=yyn;
+                       /* consult goto table to find next state */
+               yyn = yyr1[yyn];
+               yyj = yypgo[yyn] + *yyps + 1;
+               if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
+               switch(yym){
+                       $A
+               }
+               goto yystack;  /* stack new state and value */
+
+       }
diff --git a/usr/src/games/arithmetic.c b/usr/src/games/arithmetic.c
deleted file mode 100644 (file)
index df6f707..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-#include <signal.h>
-
-#define        MAX     100
-
-char   types[10];
-int    right[MAX];
-int    left[MAX];
-int    rights;
-int    wrongs;
-long   stvec;
-long   etvec;
-long   dtvec;
-
-main(argc,argv)
-char   *argv[];
-{
-       int range, k, dif, l;
-       char line[100];
-       int ans,pans,i,j,t;
-       extern  delete();
-
-       signal(SIGINT, delete);
-
-       range = 11;
-       dif = 0;
-       while(argc > 1) {
-               switch(*argv[1]) {
-               case '+':
-               case '-':
-               case 'x':
-               case '/':
-                       while(types[dif] = argv[1][dif])
-                               dif++;
-                       break;
-
-               default:
-                       range = getnum(argv[1]) + 1;
-               }
-               argv++;
-               argc--;
-       }
-       if(range > MAX) {
-               printf("Range is too large.\n");
-               exit(0);
-       }
-
-       if(dif == 0) {
-               types[0] = '+';
-               types[1] = '-';
-               dif = 2;
-       }
-
-       for(i = 0; i < range; i++) {
-               left[i] = right[i] = i;
-       }
-       time(&stvec);
-       k = stvec;
-       srand(k);
-       k = 0;
-       l = 0;
-       goto start;
-
-loop:
-       if(++k%20 == 0)
-               score();
-
-start:
-       i = skrand(range);
-       j = skrand(range);
-       if(dif > 1)
-               l = random(dif);
-
-       switch(types[l]) {
-               case '+':
-               default:
-                       ans = left[i] + right[j];
-                       printf("%d + %d =   ", left[i], right[j]);
-                       break;
-
-               case '-':
-                       t = left[i] + right[j];
-                       ans = left[i];
-                       printf("%d - %d =   ", t, right[j]);
-                       break;
-
-               case 'x':
-                       ans = left[i] * right[j];
-                       printf("%d x %d =   ", left[i], right[j]);
-                       break;
-
-               case '/':
-                       while(right[j] == 0)
-                               j = random(range);
-                       t = left[i] * right[j] + random(right[j]);
-                       ans = left[i];
-                       printf("%d / %d =   ", t, right[j]);
-                       break;
-       }
-
-
-loop1:
-       getline(line);
-       dtvec += etvec - stvec;
-       if(line[0]=='\n') goto loop1;
-       pans = getnum(line);
-       if(pans == ans) {
-               printf("Right!\n");
-               rights++;
-               goto loop;
-       }
-       else {
-               printf("What?\n");
-               wrongs++;
-               if(range >= MAX)        goto loop1;
-               left[range] = left[i];
-               right[range++] = right[j];
-               goto loop1;
-       }
-}
-
-getline(s)
-char *s;
-{
-       register char   *rs;
-
-       rs = s;
-
-       while((*rs = getchar()) == ' ');
-       while(*rs != '\n')
-               if(*rs == 0)
-                       exit(0);
-               else if(rs >= &s[99]) {
-                       while((*rs = getchar()) != '\n')
-                               if(*rs == '\0') exit(0);
-               }
-               else
-                       *++rs = getchar();
-       while(*--rs == ' ')
-               *rs = '\n';
-}
-
-getnum(s)
-char *s;
-{
-       int     a;
-       char    c;
-
-       a = 0;
-       while((c = *s++) >= '0' && c <= '9') {
-               a = a*10 + c - '0';
-       }
-       return(a);
-}
-
-
-random(range)
-{
-       return(rand()%range);
-}
-
-skrand(range){
-int temp;
-       temp = random(range) + random(range);
-       if(temp > range - 1) temp = 2*range - 1 - temp;
-       return(temp);
-       }
-
-score()
-{
-       time(&etvec);
-
-       printf("\n\nRights %d; Wrongs %d; Score %d%%\n", rights, wrongs,
-               (rights * 100)/(rights + wrongs));
-
-       if(rights == 0) return;
-       printf("Total time %ld seconds; %.1f seconds per problem\n\n\n",
-               etvec - stvec,
-               (etvec - stvec) / (rights + 0.));
-
-       sleep(3);
-       time(&dtvec);
-       stvec += dtvec - etvec;
-}
-
-delete()
-{
-       if(rights + wrongs == 0.) {
-               printf("\n");
-               exit(0);
-       }
-       score();
-       exit(0);
-}
diff --git a/usr/src/games/backgammon.c b/usr/src/games/backgammon.c
deleted file mode 100644 (file)
index 50fbecd..0000000
+++ /dev/null
@@ -1,584 +0,0 @@
-# include <stdio.h>
-
-#
-#define NIL (-1)
-#define MAXGMOV 10
-#define MAXIMOVES 1000
-       char level;             /*'b'=beginner, 'i'=intermediate, 'e'=expert*/
-int die1;
-int die2;
-int i;
-int j;
-int l;
-int m;
-int count;
-int red[]     {0,2,0,0,0,0,0,0,0,0,0,0,5,
-                0,0,0,0,3,0,5,0,0,0,0,0,
-                0,0,0,0,0,0};
-int white[]   {0,2,0,0,0,0,0,0,0,0,0,0,5,
-                0,0,0,0,3,0,5,0,0,0,0,0,
-                0,0,0,0,0,0};
-int probability[]{0,11,12,13,14,15,16,
-                   06,05,04,03,02,01};
-int imoves;
-int goodmoves[MAXGMOV] ;
-int probmoves[MAXGMOV] ;
-struct {int pos[4],mov[4];} moves[MAXIMOVES] ;
-
-main()
-{
-       int t,k,n,go[5];
-       char s[100];
-       go[5]=NIL;
-       srand();
-       printf( "Do you want instructions? Type 'y' for yes,\n");
-       printf( "anything else means no.?? ");
-       getstr(s);
-       if(*s=='y')instructions();
-       printf( "Choose the level of your oppponent.\n");
-       printf( "Type 'b' for beginner, or 'i' for intermediate.\n");
-       printf( "Anything else gets you an expert.?? ");
-       level='e';
-       getstr(s);
-       if(*s=='b')level='b';
-       else if(*s=='i')level='i';
-       printf( "You will play red. Do you wan't to move first?\n");
-       printf( "Type 'y' for yes, anything else means no.?? ");
-       getstr(s);
-       if(*s=='y')goto nowhmove;
-whitesmv:
-       roll();
-       printf( "white rolls %d,%d\n",die1,die2);
-       printf( "white's move is:");
-       if(nextmove(white,red)==NIL)goto nowhmove;
-       if(piececount(white,0,24)==0){
-           printf( "White wins\n");
-           printf( "Aren't you ashamed. You've been beaten by a computer.\n");
-           exit();
-       }
-nowhmove:
-       prtbrd();
-
-       roll();
-retry:
-       printf( "your roll is %d,  %d\n",die1,die2);
-       printf( "your move, please?? ");
-       getstr(s);
-       if(*s==0){
-           printf( "red's move skipped\n");
-           goto whitesmv;
-       }
-       n=sscanf(s,"%d%d%d%d%d",&go[0],&go[1],&go[2],&go[3],&go[4]);
-       if((die1!=die2&&n>2)||n>4){
-           printf( "you've made too many moves\n");
-           goto retry;
-       }
-       go[n]=NIL;
-       if(*s=='-'){
-           go[0]= -go[0];
-           t=die1;
-           die1=die2;
-           die2=t;
-       }
-       for(k=0;k<n;k++){
-           if(0<=go[k] && go[k]<=24)continue;
-           else{
-               printf( "move %d is illegal\n",go[k]);
-               goto retry;
-           }
-       }
-       if(play(red,white,go))goto retry;
-       if(piececount(red,0,24)==0){
-           printf( "Red wins.\n");
-           printf( "Congratulations! You have just defeated a dumb machine.\n");
-           exit();
-       }
-       goto whitesmv;
-}
-
-getstr(s)
-char *s;
-{
-       while((*s=getchar())!='\n')s++;
-       *s=0;
-}
-
-play(player,playee,pos)
-int *player,*playee,pos[];
-{
-       int k,n,die,ipos;
-       for(k=0;k<player[0];k++){  /*blots on player[0] must be moved first*/
-           if(pos[k]==NIL)break;
-           if(pos[k]!=0){
-               printf( "piece on position 0 must be moved first\n");
-               return(-1);
-           }
-       }
-       for(k=0;(ipos=pos[k])!=NIL;k++){
-           die=k?die2:die1;
-           n=25-ipos-die;
-           if(player[ipos]==0)goto badmove;
-           if(n>0&&playee[n]>=2)goto badmove;
-           if(n<=0){
-               if(piececount(player,0,18)!=0)goto badmove;
-               if((ipos+die)!=25&&
-                   piececount(player,19,24-die)!=0)goto badmove;
-           }
-           player[ipos]--;
-           player[ipos+die]++;
-       }
-       for(k=0;pos[k]!=NIL;k++){
-           die=k?die2:die1;
-           n=25-pos[k]-die;
-           if(n>0 && playee[n]==1){
-               playee[n]=0;
-               playee[0]++;
-           }
-       }
-       return(0);
-
-badmove:
-       printf( "Move %d is not legal.\n",ipos);
-       while(k--){
-           die=k?die2:die1;
-           player[pos[k]]++;
-           player[pos[k]+die]--;
-       }
-       return(-1);
-}
-nextmove(player,playee)
-int *player,*playee;
-{
-       int k;
-       imoves=0;
-       movegen(player,playee);
-       if(die1!=die2){
-       k=die1;
-       die1=die2;
-       die2=k;
-       movegen(player,playee);
-       }
-       if(imoves==0){
-           printf( "roll was %d,%d; no white move possible\n",die1,die2);
-           return(NIL);
-       }
-       k=strategy(player,playee);              /*select kth possible move*/
-       prtmov(k);
-       update(player,playee,k);
-       return(0);
-}
-prtmov(k)
-int k;
-{
-       int n;
-       if(k==NIL)printf( "no move possible\n");
-       else for(n=0;n<4;n++){
-           if(moves[k].pos[n]==NIL)break;
-           printf( "    %d, %d",25-moves[k].pos[n],moves[k].mov[n]);
-       }
-       printf( "\n");
-}
-update(player,playee,k)
-int *player,*playee,k;
-{
-       int n,t;
-       for(n=0;n<4;n++){
-           if(moves[k].pos[n]==NIL)break;
-           player[moves[k].pos[n]]--;
-           player[moves[k].pos[n]+moves[k].mov[n]]++;
-           t=25-moves[k].pos[n]-moves[k].mov[n];
-           if(t>0 && playee[t]==1){
-               playee[0]++;
-               playee[t]--;
-           }
-       }
-}
-piececount(player,startrow,endrow)
-int *player,startrow,endrow;
-{
-       int sum;
-       sum=0;
-       while(startrow<=endrow)
-       sum=+player[startrow++];
-       return(sum);
-}
-/*
-prtmovs()
-{
-       int i1,i2;
-       printf( "possible moves are\n");
-       for(i1=0;i1<imoves;i1++){
-               printf( "\n%d",i1);
-               for(i2=0;i2<4;i2++){
-                       if(moves[i1].pos[i2]==NIL)break;
-                       printf( "%d, %d",moves[i1].pos[i2],moves[i1].mov[i2]);
-               }
-       }
-       printf( "\n");
-}
-*/
-
-roll()
-{
-       extern int die1,die2;
-       die1=(rand()>>8)%6+1;
-       die2=(rand()>>8)%6+1;
-}
-
-movegen(mover,movee)
-int *mover,*movee;
-{
-       extern int i,j,l,m,count;
-       extern int die1,die2;
-       int k;
-       for(i=0;i<=24;i++){
-               count=0;
-               if(mover[i]==0)continue;
-               if((k=25-i-die1)>0&&movee[k]>=2)
-                   if(mover[0]>0)break;
-                   else continue;
-               if(k<=0){
-                   if(piececount(mover,0,18)!=0)break;
-                   if((i+die1)!=25&&
-                       piececount(mover,19,24-die1)!=0)break;
-               }
-               mover[i]--;
-               mover[i+die1]++;
-               count=1;
-               for(j=0;j<=24;j++){
-                       if(mover[j]==0)continue;
-                       if((k=25-j-die2)>0&&movee[k]>=2)
-                           if(mover[0]>0)break;
-                           else continue;
-                       if(k<=0){
-                           if(piececount(mover,0,18)!=0)break;
-                           if((j+die2)!=25&&
-                               piececount(mover,19,24-die2)!=0)break;
-                       }
-                       mover[j]--;
-                       mover[j+die2]++;
-                       count=2;
-                       if(die1!=die2){
-                           moverecord(mover);
-                           if(mover[0]>0)break;
-                           else continue;
-                       }
-                       for(l=0;l<=24;l++){
-                           if(mover[l]==0)continue;
-                           if((k=25-l-die1)>0&&movee[k]>=2)
-                               if(mover[0]>0)break;
-                               else continue;
-                           if(k<=0){
-                               if(piececount(mover,0,18)!=0)break;
-                               if((l+die2)!=25&&
-                                   piececount(mover,19,24-die1)!=0)break;
-                           }
-                           mover[l]--;
-                           mover[l+die1]++;
-                           count=3;
-                           for(m=0;m<=24;m++){
-                               if(mover[m]==0)continue;
-                               if((k=25-m-die1)>=0&&movee[k]>=2)
-                                   if(mover[0]>0)break;
-                                   else continue;
-                               if(k<=0){
-                                   if(piececount(mover,0,18)!=0)break;
-                                   if((m+die2)!=25&&
-                                       piececount(mover,19,24-die1)!=0)break;
-                               }
-                               count=4;
-                               moverecord(mover);
-                               if(mover[0]>0)break;
-                           }
-                           if(count==3)moverecord(mover);
-                           else{
-                               mover[l]++;
-                               mover[l+die1]--;
-                           }
-                           if(mover[0]>0)break;
-                       }
-                       if(count==2)moverecord(mover);
-                       else{
-                           mover[j]++;
-                           mover[j+die1]--;
-                       }
-                       if(mover[0]>0)break;
-               }
-               if(count==1)moverecord(mover);
-               else{
-                   mover[i]++;
-                   mover[i+die1]--;
-               }
-               if(mover[0]>0)break;
-       }
-}
-moverecord(mover)
-int *mover;
-{
-       extern int i,j,l,m,imoves,count;
-       int t;
-       if(imoves>=MAXIMOVES)goto undo;;
-       for(t=0;t<=3;t++)
-           moves[imoves].pos[t]= NIL;
-       switch(count){
-case 4:
-           moves[imoves].pos[3]=m;
-           moves[imoves].mov[3]=die1;
-case 3:
-           moves[imoves].pos[2]=l;
-           moves[imoves].mov[2]=die1;
-case 2:
-           moves[imoves].pos[1]=j;
-           moves[imoves].mov[1]=die2;
-case 1:
-           moves[imoves].pos[0]=i;
-           moves[imoves].mov[0]=die1;
-           imoves++;
-       }
-undo:
-       switch(count){
-case 4:
-           break;
-case 3:
-           mover[l]++;
-           mover[l+die1]--;
-           break;
-case 2:
-           mover[j]++;
-           mover[j+die2]--;
-           break;
-case 1:
-           mover[i]++;
-           mover[i+die1]--;
-       }
-}
-
-
-strategy(player,playee)
-int *player,*playee;
-{
-       extern char level;
-       int k,n,nn,bestval,moveval,prob;
-       n=0;
-       if(imoves==0)return(NIL);
-       goodmoves[0]=NIL;
-       bestval= -32000;
-       for(k=0;k<imoves;k++){
-           if((moveval=eval(player,playee,k,&prob))<bestval)continue;
-           if(moveval>bestval){
-               bestval=moveval;
-               n=0;
-           }
-           if(n<MAXGMOV){
-               goodmoves[n]=k;
-               probmoves[n++]=prob;
-           }
-       }
-       if(level=='e' && n>1){
-           nn=n;
-           n=0;
-           prob=32000;
-           for(k=0;k<nn;k++){
-               if((moveval=probmoves[k])>prob)continue;
-               if(moveval<prob){
-                   prob=moveval;
-                   n=0;
-               }
-               goodmoves[n]=goodmoves[k];
-               probmoves[n++]=probmoves[k];
-           }
-       }
-       return(goodmoves[(rand()>>4)%n]);
-}
-
-eval(player,playee,k,prob)
-int *player,*playee,k,*prob;
-{
-       extern char level;
-       int newtry[31],newother[31],*r,*q,*p,n,sum,first;
-       int ii,lastwhite,lastred;
-       *prob=sum=0;
-       r=player+25;
-       p=newtry;
-       q=newother;
-       while(player<r){
-           *p++= *player++;
-           *q++= *playee++;
-       }
-       q=newtry+31;
-       for(p=newtry+25;p<q;) *p++ = 0; /*zero out spaces for hit pieces*/
-       for(n=0;n<4;n++){
-           if(moves[k].pos[n]==NIL)break;
-           newtry[moves[k].pos[n]]--;
-           newtry[ii=moves[k].pos[n]+moves[k].mov[n]]++;
-           if(ii<25 && newother[25-ii]==1){
-               newother[25-ii]=0;
-               newother[0]++;
-               if(ii<=15 && level=='e')sum++;  /*hit if near other's home*/
-           }
-       }
-       for(lastred=0;newother[lastred]==0;lastred++);
-       for(lastwhite=0;newtry[lastwhite]==0;lastwhite++);
-       lastwhite=25-lastwhite;
-       if(lastwhite<=6 && lastwhite<lastred)sum=1000;
-       if(lastwhite<lastred && level=='e'
-           && lastwhite>6){                    /*expert's running game.
-                                                 First priority to get all
-                                                 pieces into white's home*/
-           for(sum=1000;lastwhite>6;lastwhite--)
-               sum=sum-lastwhite*newtry[25-lastwhite];
-       }
-       for(first=0;first<25;first++)
-           if(newother[first]!=0)break;        /*find other's first piece*/
-       q=newtry+25;
-       for(p=newtry+1;p<q;)if(*p++ > 1)sum++;  /*blocked points are good*/
-       if(first>5){    /*only stress removing pieces if homeboard
-                         cannot be hit
-                       */
-           q=newtry+31;
-           p=newtry+25;
-           for(n=6;p<q;n--)
-               sum=+ *p++ * n; /*remove pieces, but just barely*/
-       }
-       if(level!='b'){
-           r=newtry+25-first;  /*singles past this point can't be hit*/
-           for(p=newtry+7;p<r;)
-               if(*p++ == 1)sum--;     /*singles are bad after 1st 6 points
-                                         if they can be hit*/
-           q=newtry+3;
-           for(p=newtry;p<q;)sum=- *p++;  /*bad to be on 1st three points*/
-       }
-
-       for(n=1;n<=4;n++)
-           *prob=+ n*getprob(newtry,newother,6*n-5,6*n);
-       return(sum);
-}
-instructions()
-{
-       printf( "To play backgammon, type the numbers of the points\n");
-       printf( "from which pieces are to be moved. Thus, if the\n");
-       printf( "roll is '3,5', typing '2 6' will move a piece\n");
-       printf( "from point 2 three spaces to point 5,\n");
-       printf( "and a piece from point 6 forward to\n");
-       printf( "point 11.  If the moves must be made in the\n");
-       printf( "opposite order, the first character typed must\n");
-       printf( "be a minus ('-'). Thus, typing\n");
-       printf( "'-2 6' moves the piece on point 2\n");
-       printf( "by 5, and the piece on point 6 by 3.\n");
-       printf( "If you want to move a single piece several times,\n");
-       printf( "the sequence of points from which it is to be\n");
-       printf( "moved must be typed. Thus '14 17' will move\n");
-       printf( "a piece from point 14 to point 17 and thence to\n");
-       printf( "to point 22.\n");
-       printf( "If a double is rolled, you should type four numbers.\n");
-       printf( "Red pieces that have been removed from the board by\n");
-       printf( "being hit by white are on point 0 and\n");
-       printf( "must be brought in before any other move can be made.\n");
-       printf( "White pieces that are hit are removed to point 25.\n");
-       printf( "You will not be allowed to make an illegal move, or\n");
-       printf( "to make too many moves. However, if you make too\n");
-       printf( "few moves, the program does not care. In particular\n");
-       printf( "you may skip your turn by typing a 'new-line'\n");
-       printf( "all by itself.\n\n");
-}
-
-getprob(player,playee,start,finish)
-int *player,*playee,start,finish;
-{                      /*returns the probability (times 102) that any
-                         pieces belonging to 'player' and lying between
-                         his points 'start' and 'finish' will be hit
-                         by a piece belonging to playee
-                       */
-       int k,n,sum;
-       sum=0;
-       for(;start<=finish;start++){
-           if(player[start]==1){
-               for(k=1;k<=12;k++){
-                   if((n=25-start-k)<0)break;
-                   if(playee[n]!=0)sum=+probability[k];
-               }
-           }
-       }
-       return(sum);
-}
-prtbrd()
-{
-       int k;
-       printf( "White's Home\n");
-       for(k=1;k<=6;k++)
-           printf( "%4d",k);
-       printf( "    ");
-       for(k=7;k<=12;k++)printf( "%4d",k);
-       putchar('\r' );
-       for(k=1;k<=54;k++)putchar('_' );
-       putchar('\n' );
-       numline(red,white,1,6);
-       printf( "    ");
-       numline(red,white,7,12);
-       putchar('\n' );
-       colorline(red,'R',white,'W',1,6);
-       printf( "    ");
-       colorline(red,'R',white,'W',7,12);
-       putchar('\n' );
-       if(white[0]!=0)printf( "%28dW\n",white[0]);
-       else putchar('\n' );
-       if(red[0]!=0)printf( "%28dR\n",red[0]);
-       else putchar('\n' );
-       colorline(white,'W',red,'R',1,6);
-       printf( "    ");
-       colorline(white,'W',red,'R',7,12);
-       putchar('\n' );
-       numline(white,red,1,6);
-       printf( "    ");
-       numline(white,red,7,12);
-       putchar('\r' );
-       for(k=1;k<=54;k++)putchar('_' );
-       putchar('\n' );
-       for(k=24;k>=19;k--)printf( "%4d",k);
-       printf( "    ");
-       for(k=18;k>=13;k--)printf( "%4d",k);
-       printf( "\nRed's Home\n\n\n\n\n");
-}
-numline(upcol,downcol,start,fin)
-int *upcol,*downcol,start,fin;
-{
-       int k,n;
-       for(k=start;k<=fin;k++){
-           if((n=upcol[k])!=0 || (n=downcol[25-k])!=0)printf( "%4d",n);
-           else printf( "    ");
-       }
-}
-colorline(upcol,c1,downcol,c2,start,fin)
-int *upcol,*downcol,start,fin;
-char c1,c2;
-{
-       int k;
-       char c;
-       for(k=start;k<=fin;k++){
-           c=' ';
-           if(upcol[k]!=0)c=c1;
-           if(downcol[25-k]!=0)c=c2;
-       printf( "   %c",c);
-       }
-}
-
-int rrno 0;
-
-srand(){
-       rrno = _look( 0x40000 );
-       _store( 0x40000, rrno+1 );
-       }
-
-rand(){
-       rrno =* 0106273;
-       rrno =+ 020202;
-       return( rrno & 077777 );
-       }
-
-_look(p) int *p; {
-       return( *p );
-       }
-
-_store( p, numb ) int *p; {
-       *p = numb;
-       }
diff --git a/usr/src/games/chess/README b/usr/src/games/chess/README
deleted file mode 100644 (file)
index 9cdc14b..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-This program is not the one
-that won the U. S. championship.
diff --git a/usr/src/games/chess/agen.c b/usr/src/games/chess/agen.c
deleted file mode 100644 (file)
index 839d061..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-#include "old.h"
-
-bagen()
-{
-       int *p1, *p2, v;
-
-       p1 = lmp;
-       if((flag&010)!=0)
-       if(board[5]==0 && board[6]==0 && board[7]==4)
-       if(wattack(4) && wattack(5) && wattack(6))
-               btry(4, 0, 2); /* kingside castle */
-       if((flag&020)!=0)
-       if(board[0]==4 && board[1]==0 && board[2]==0 && board[3]==0)
-       if(wattack(2) && wattack(3) && wattack(4))
-               btry(4, 0, -2); /* queenside castle */
-       bgen();
-       p2 = p1;
-       while(p2 != lmp) {
-               v = *p2++;
-               bmove(*p2);
-               if(wattack(bkpos)) {
-                       *p1++ = v;
-                       *p1++ = *p2;
-               }
-               p2++;
-               bremove();
-       }
-       lmp = p1;
-}
-
-btry(from, mask, offset)
-int from, mask, offset;
-{
-
-       if((dir[from]&mask)==0)
-               bcheck(from, from+offset);
-}
-
-bcheck(from, to)
-int from, to;
-{
-
-       if(board[to]>0) return(1);
-       *lmp++ = (pval+6)[board[to]]-value;
-       *lmp++ = (from<<8)|to;
-       return(board[to] != 0);
-}
-
-wagen()
-{
-       int *p1, *p2, v;
-
-       p1 = lmp;
-       if((flag&1)!=0)
-       if(board[61]==0 && board[62]==0 && board[63]== -4)
-       if(battack(60) && battack(61) && battack(62))
-               wtry(60, 0, 2); /* kingside castle */
-       if((flag&2)!=0)
-       if(board[56]== -4 && board[57]==0 && board[58]==0 && board[59]==0)
-       if(battack(58) && battack(59) && battack(60))
-               wtry(60, 0, -2); /* queenside castle */
-       wgen();
-       p2 = p1;
-       while(p2 != lmp) {
-               v = *p2++;
-               wmove(*p2);
-               if(battack(wkpos)) {
-                       *p1++ = v;
-                       *p1++ = *p2;
-               }
-               p2++;
-               wremove();
-       }
-       lmp = p1;
-}
-
-wtry(from, mask, offset)
-int from, mask, offset;
-{
-
-       if((dir[from]&mask)==0)
-               wcheck(from, from+offset);
-}
-
-wcheck(from, to)
-int from, to;
-{
-
-       if(board[to]<0) return(1);
-       *lmp++ = value-(pval+6)[board[to]];
-       *lmp++ = (from<<8)|to;
-       return(board[to] != 0);
-}
-
diff --git a/usr/src/games/chess/att.s b/usr/src/games/chess/att.s
deleted file mode 100644 (file)
index 6579161..0000000
+++ /dev/null
@@ -1,293 +0,0 @@
-/ does white/black attack position?
-
-.globl _battack
-.globl _wattack
-
-.globl _dir, _board
-
-uleft  = 04040;
-uright = 04004;
-dleft  = 00440;
-dright = 00404;
-left   = 00040;
-right  = 00004;
-up     = 04000;
-down   = 00400;
-u2r1   = 06004;
-u1r2   = 04006;
-d1r2   = 00406;
-d2r1   = 00604;
-d2l1   = 00640;
-d1l2   = 00460;
-u1l2   = 04060;
-u2l1   = 06040;
-
-_battack:
-       mov     2(sp),r0
-       asl     r0
-       mov     _dir(r0),r1
-       mov     $2,r2
-       bit     $u2r1,r1
-       bne     1f
-       cmp     _board+[-15.*2](r0),r2
-       beq     2f
-1:
-       bit     $u1r2,r1
-       bne     1f
-       cmp     _board+[-6.*2](r0),r2
-       beq     2f
-1:
-       bit     $d1r2,r1
-       bne     1f
-       cmp     _board+[+10.*2](r0),r2
-       beq     2f
-1:
-       bit     $d2r1,r1
-       bne     1f
-       cmp     _board+[+17.*2](r0),r2
-       beq     2f
-1:
-       bit     $d2l1,r1
-       bne     1f
-       cmp     _board+[+15.*2](r0),r2
-       beq     2f
-1:
-       bit     $d1l2,r1
-       bne     1f
-       cmp     _board+[+6.*2](r0),r2
-       beq     2f
-1:
-       bit     $u1l2,r1
-       bne     1f
-       cmp     _board+[-10.*2](r0),r2
-       beq     2f
-1:
-       bit     $u2l1,r1
-       bne     1f
-       cmp     _board+[-17.*2](r0),r2
-       beq     2f
-1:
-       jsr     r5,badiag; uleft; -9.*2
-       jsr     r5,badiag; uright; -7.*2
-       jsr     r5,badiag; dleft; 7.*2
-       jsr     r5,badiag; dright; 9.*2
-       jsr     r5,barank; up; -8.*2
-       jsr     r5,barank; left; -1.*2
-       jsr     r5,barank; right; 1.*2
-       jsr     r5,barank; down; 8.*2
-
-       bit     $uleft,_dir(r0)
-       bne     1f
-       cmp     _board-18.(r0),$1               / pawn?
-       beq     2f
-1:
-       bit     $uright,_dir(r0)
-       bne     1f
-       cmp     _board-14.(r0),$1
-       bne     1f
-2:
-       clr     r0
-       rts     pc
-1:
-       mov     $1,r0
-       rts     pc
-
-badiag:
-       mov     r0,r1
-       mov     (r5)+,r2
-       mov     (r5)+,r3
-       bit     r2,_dir(r1)
-       bne     1f
-       add     r3,r1
-       mov     _board(r1),r4
-       beq     2f
-       cmp     r4,$3
-       beq     9f
-       cmp     r4,$5
-       beq     9f
-       cmp     r4,$6
-       beq     9f
-1:
-       rts     r5
-2:
-       bit     r2,_dir(r1)
-       bne     2f
-       add     r3,r1
-       mov     _board(r1),r4
-       beq     2b
-       cmp     r4,$3
-       beq     9f
-       cmp     r4,$5
-       beq     9f
-2:
-       rts     r5
-
-barank:
-       mov     r0,r1
-       mov     (r5)+,r2
-       mov     (r5)+,r3
-       bit     r2,_dir(r1)
-       bne     1f
-       add     r3,r1
-       mov     _board(r1),r4
-       beq     2f
-       cmp     r4,$4
-       beq     9f
-       cmp     r4,$5
-       beq     9f
-       cmp     r4,$6
-       beq     9f
-1:
-       rts     r5
-2:
-       bit     r2,_dir(r1)
-       bne     2f
-       add     r3,r1
-       mov     _board(r1),r4
-       beq     2b
-       cmp     r4,$4
-       beq     9f
-       cmp     r4,$5
-       beq     9f
-2:
-       rts     r5
-
-9:
-       mov     (sp)+,r5
-       clr     r0
-       rts     pc
-
-_wattack:
-       mov     2(sp),r0
-       asl     r0
-       mov     _dir(r0),r1
-       mov     $-2,r2
-       bit     $u2r1,r1
-       bne     1f
-       cmp     _board+[-15.*2](r0),r2
-       beq     2f
-1:
-       bit     $u1r2,r1
-       bne     1f
-       cmp     _board+[-6.*2](r0),r2
-       beq     2f
-1:
-       bit     $d1r2,r1
-       bne     1f
-       cmp     _board+[+10.*2](r0),r2
-       beq     2f
-1:
-       bit     $d2r1,r1
-       bne     1f
-       cmp     _board+[+17.*2](r0),r2
-       beq     2f
-1:
-       bit     $d2l1,r1
-       bne     1f
-       cmp     _board+[+15.*2](r0),r2
-       beq     2f
-1:
-       bit     $d1l2,r1
-       bne     1f
-       cmp     _board+[+6.*2](r0),r2
-       beq     2f
-1:
-       bit     $u1l2,r1
-       bne     1f
-       cmp     _board+[-10.*2](r0),r2
-       beq     2f
-1:
-       bit     $u2l1,r1
-       bne     1f
-       cmp     _board+[-17.*2](r0),r2
-       beq     2f
-1:
-       jsr     r5,wadiag; uleft; -9.*2
-       jsr     r5,wadiag; uright; -7.*2
-       jsr     r5,wadiag; dleft; 7.*2
-       jsr     r5,wadiag; dright; 9.*2
-       jsr     r5,warank; up; -8.*2
-       jsr     r5,warank; left; -1.*2
-       jsr     r5,warank; right; 1.*2
-       jsr     r5,warank; down; 8.*2
-
-       bit     $dleft,_dir(r0)
-       bne     1f
-       cmp     _board+14.(r0),$-1              / pawn?
-       beq     2f
-1:
-       bit     $dright,_dir(r0)
-       bne     1f
-       cmp     _board+18.(r0),$-1
-       bne     1f
-2:
-       clr     r0
-       rts     pc
-1:
-       mov     $1,r0
-       rts     pc
-
-wadiag:
-       mov     r0,r1
-       mov     (r5)+,r2
-       mov     (r5)+,r3
-       bit     r2,_dir(r1)
-       bne     1f
-       add     r3,r1
-       mov     _board(r1),r4
-       beq     2f
-       cmp     r4,$-3
-       beq     9f
-       cmp     r4,$-5
-       beq     9f
-       cmp     r4,$-6
-       beq     9f
-1:
-       rts     r5
-2:
-       bit     r2,_dir(r1)
-       bne     2f
-       add     r3,r1
-       mov     _board(r1),r4
-       beq     2b
-       cmp     r4,$-3
-       beq     9f
-       cmp     r4,$-5
-       beq     9f
-2:
-       rts     r5
-
-warank:
-       mov     r0,r1
-       mov     (r5)+,r2
-       mov     (r5)+,r3
-       bit     r2,_dir(r1)
-       bne     1f
-       add     r3,r1
-       mov     _board(r1),r4
-       beq     2f
-       cmp     r4,$-4
-       beq     9f
-       cmp     r4,$-5
-       beq     9f
-       cmp     r4,$-6
-       beq     9f
-1:
-       rts     r5
-2:
-       bit     r2,_dir(r1)
-       bne     2f
-       add     r3,r1
-       mov     _board(r1),r4
-       beq     2b
-       cmp     r4,$-4
-       beq     9f
-       cmp     r4,$-5
-       beq     9f
-2:
-       rts     r5
-
-9:
-       mov     (sp)+,r5
-       clr     r0
-       rts     pc
diff --git a/usr/src/games/chess/bgen.s b/usr/src/games/chess/bgen.s
deleted file mode 100644 (file)
index eeec87f..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-/ generate moves
-
-.globl _bgen
-
-.globl _pval, _board, _dir
-.globl _flag, _lmp, _bkpos
-.globl _eppos
-.globl _value
-
-uleft  = 04040
-uright = 04004
-dleft  = 00440
-dright = 00404
-left   = 00040
-right  = 00004
-up     = 04000
-down   = 00400
-u2r1   = 06004
-u1r2   = 04006
-d1r2   = 00406
-d2r1   = 00604
-d2l1   = 00640
-d1l2   = 00460
-u1l2   = 04060
-u2l1   = 06040
-rank2  = 00200
-rank7  = 02000
-
-_bgen:
-       mov     $_dir+126.,r4
-       mov     $_board+126.,r3
-       mov     _lmp,r2
-       mov     $63.,r1
-0:
-       mov     (r3),r0
-       ble     1f
-       asl     r0
-       jmp     *2f-2(r0)
-
-2:
-       pawn
-       knight
-       bishop
-       rook
-       queen
-       king
-
-pawn:
-       bit     $dleft,(r4)
-       bne     2f
-       tst     2*7.(r3)
-       bge     3f
-       jsr     r5,btry; 0; 7.*2
-3:
-       mov     r1,r0
-       add     $7,r0
-       cmp     r0,_eppos
-       bne     2f
-       jsr     r5,btry; 0; -1*2
-2:
-       bit     $dright,(r4)
-       bne     2f
-       tst     9.*2(r3)
-       bge     3f
-       jsr     r5,btry; 0; 2*9.
-3:
-       mov     r1,r0
-       add     $9,r0
-       cmp     r0,_eppos
-       bne     2f
-       jsr     r5,btry; 0; 2*1
-2:
-       tst     2*8.(r3)
-       bne     1f
-       jsr     r5,btry; 0; 2*8.
-       bit     $rank7,(r4)
-       beq     1f
-       tst     2*16.(r3)
-       bne     1f
-       jsr     r5,btry; 0; 16.*2
-       br      1f
-
-knight:
-       jsr     r5,btry; u2r1; -15.*2
-       jsr     r5,btry; u1r2; -6.*2
-       jsr     r5,btry; d1r2; 10.*2
-       jsr     r5,btry; d2r1; 17.*2
-       jsr     r5,btry; d2l1; 15.*2
-       jsr     r5,btry; d1l2; 6.*2
-       jsr     r5,btry; u1l2; -10.*2
-       jsr     r5,btry; u2l1; -17.*2
-       br      1f
-
-
-1:
-       cmp     -(r4),-(r3)
-       dec     r1
-       bpl     0b
-       mov     r2,_lmp
-       rts     pc
-
-bishop:
-       jsr     r5,bslide; uleft; -9.*2
-       jsr     r5,bslide; uright; -7.*2
-       jsr     r5,bslide; dleft; 7.*2
-       jsr     r5,bslide; dright; 9.*2
-       br      1b
-
-rook:
-       jsr     r5,bslide; up; -8.*2
-       jsr     r5,bslide; down; 8.*2
-       jsr     r5,bslide; left; -1.*2.
-       jsr     r5,bslide; right; 1.*2
-       br      1b
-queen:
-       jsr     r5,bslide; uleft; -9.*2
-       jsr     r5,bslide; uright; -7.*2
-       jsr     r5,bslide; dleft; 7.*2
-       jsr     r5,bslide; dright; 9.*2
-       jsr     r5,bslide; up; -8.*2
-       jsr     r5,bslide; left; -1.*2
-       jsr     r5,bslide; right; 1.*2
-       jsr     r5,bslide; down; 8.*2
-       br      1b
-
-king:
-       jsr     r5,btry; uleft; -9.*2
-       jsr     r5,btry; uright; -7.*2
-       jsr     r5,btry; dleft; 7.*2
-       jsr     r5,btry; dright; 9.*2
-       jsr     r5,btry; up; -8.*2
-       jsr     r5,btry; left; -1.*2
-       jsr     r5,btry; right; 1.*2
-       jsr     r5,btry; down; 8.*2
-       br      1b
-
-btry:
-       bit     (r5)+,(r4)
-       bne     1f
-       mov     r3,r0
-       add     (r5),r0
-       mov     (r0),r0
-       bgt     1f
-       asl     r0
-       mov     _pval+12.(r0),(r2)
-       sub     _value,(r2)+
-       mov     (r5)+,r0
-       asr     r0
-       add     r1,r0
-       movb    r0,(r2)+
-       movb    r1,(r2)+
-       rts     r5
-1:
-       tst     (r5)+
-       rts     r5
-
-bslide:
-       mov     r4,-(sp)
-       mov     r3,-(sp)
-1:
-       bit     (r5)+,(r4)
-       bne     1f
-       add     (r5),r3
-       add     (r5),r4
-       mov     (r3),r0
-       bgt     1f
-       blt     2f
-       clr     (r2)
-       sub     _value,(r2)+
-       mov     r3,r0
-       sub     $_board,r0
-       asr     r0
-       movb    r0,(r2)+
-       movb    r1,(r2)+
-       tst     -(r5)
-       br      1b
-2:
-       asl     r0
-       mov     _pval+12.(r0),(r2)
-       sub     _value,(r2)+
-       mov     r3,r0
-       sub     $_board,r0
-       asr     r0
-       movb    r0,(r2)+
-       movb    r1,(r2)+
-1:
-       tst     (r5)+
-       mov     (sp)+,r3
-       mov     (sp)+,r4
-       rts     r5
diff --git a/usr/src/games/chess/bheur.c b/usr/src/games/chess/bheur.c
deleted file mode 100644 (file)
index 835cfee..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-#include "old.h"
-
-/*
- *     mobility
- *     1 for each potential move
- */
-
-bheur1()
-{
-
-       return(-wheur1());
-}
-
-/*
- *     opening 'goodies'
- *     10 for each minor piece out
- *     -10 for blocking kq pawns
- */
-
-bheur2()
-{
-       int i, mt;
-
-       i = 0;
-       if(game > 2) return(i);
-       mt = amp[-1];
-       if(mt == 2 || mt == 3) i =+ 30;
-       if(mt == 0) i =- 20;
-       i =+ 9*((board[1] != 2)+
-               (board[6] != 2));
-       i =+ 8*((board[2] != 3)+
-               (board[5] != 3));
-
-       /*
-        * -10 for blocked central pawns
-        */
-       if(board[11]==1 && board[11+8]!=0) i =- 10;
-       if(board[12]==1 && board[12+8]!=0) i =- 10;
-       return(i);
-}
-
-/*
- *     ability to castle
- *     22 for both flags
- *     20 for one flag
- */
-
-bheur3()
-{
-       int i;
-
-       i = 0;
-       /*
-        * queenside ability
-        */
-       if(flag&020 && board[8]==1 && board[9]==1 && board[10]==1)
-               i =+ 20;
-       /*
-        *  kingside ability
-        */
-       if(flag&010 && board[13]==1 && board[14]==1 && board[15]==1)
-               i =+ 20;
-       /*
-        * if both
-        */
-       if(i == 40)
-               i = 22;
-       /*
-        * if castled,
-        * keep pawns in
-        */
-       if(bkpos==2)
-               if(board[10]==1 && (board[8]==1 || board[8+8]==1) &&
-                       (board[9]==1 || board[9+8]==1))
-                               i =+ 40;
-       if(bkpos==6)
-               if(board[13]==1 && (board[14]==1 || board[14+8]==1) &&
-                       (board[15]== -1 || board[15+8]== -1))
-                               i =+ 40;
-       return(i);
-}
-
-/*
- *     prance
- *     a percentage if the
- *     piece on the move
- *     can be driven back
- *     by a smaller piece
- */
-
-bheur4()
-{
-       int *p1, *p2, ploc, i;
-
-       if(amp[-1] != 1) return(0);
-       ploc = amp[-3];
-       if(board[ploc] == 1) return(0);
-       if(xheur(ploc)) return(0);
-       p1 = lmp;
-       p2 = p1;
-       wagen();
-       i = 0;
-       while(p2 != lmp) {
-               p2++;
-               wmove(*p2++);
-               i = xheur(ploc);
-               wremove();
-               if(i)
-                       break;
-       }
-       lmp = p1;
-       return(-i);
-}
-
-/*
- *     control
- *     center control
- *             opening
- *             beginning
- *     king control
- *             middle
- *             end
- */
-
-bheur5()
-{
-
-       return(-wheur5());
-}
-
-/*
- * mate threat
- * bad to capture
- */
-bheur6()
-{
-       int i;
-
-       *amp++ = -1;
-       i = 0;
-       if(battack(wkpos))
-               if(mate(2, 0))
-                       i =+ 15;
-       amp--;
-       return(i);
-}
diff --git a/usr/src/games/chess/bmove.s b/usr/src/games/chess/bmove.s
deleted file mode 100644 (file)
index 56356dd..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
-.globl _bmove, _bremove
-.globl _board, _pval, _amp, _flag, _eppos, _value, _bkpos
-.globl _game
-
-_bmove:
-       mov     _amp,r4
-       movb    2(sp),r3                / to
-       movb    3(sp),r2                / from
-       mov     _value,(r4)+
-       mov     _flag,(r4)+
-       mov     _eppos,(r4)+
-       mov     r2,(r4)+
-       mov     r3,(r4)+
-       asl     r2                      / from as a word index
-       asl     r3                      / to as word index
-       mov     _board(r3),r0
-       mov     r0,(r4)+
-       beq     1f
-       asl     r0
-       sub     _pval+12.(r0),_value
-1:
-       mov     _board(r2),r0
-       mov     r0,_board(r3)
-       clr     _board(r2)
-       mov     $-1,_eppos
-       asl     r0
-       ble     error
-       jmp     *0f-2(r0)               / type of man
-0:
-       pmove
-       nmove
-       bmove
-       rmove
-       qmove
-       kmove
-
-error:
-       3
-
-pmove:
-       sub     r3,r2
-       bge     1f
-       neg     r2
-1:
-       cmp     r2,$2*1                 / ep capture
-       bne     1f
-       clr     _board(r3)
-       mov     $1,_board+[2*8.](r3)
-       mov     $4,(r4)+
-       mov     r4,_amp
-       rts     pc
-1:
-       cmp     r2,$2*16.               / double move
-       bne     1f
-       movb    3(sp),r2
-       add     $8,r2
-       mov     r2,_eppos
-       br      move
-1:
-       cmp     r3,$40.*2
-       blt     move
-       add     $25.,_value
-       cmp     r3,$48.*2
-       blt     move
-       add     $50.,_value
-       cmp     r3,$56.*2               / queen promotion
-       blt     move
-       add     $625.,_value
-       mov     $5,_board(r3)
-       mov     $5,(r4)+
-       mov     r4,_amp
-       rts     pc
-
-rmove:
-       cmp     r2,$2*7.
-       bne     1f
-       bic     $10,_flag
-       br      move
-1:
-       tst     r2
-       bne     move
-       bic     $20,_flag
-       br      move
-
-kmove:
-       asr     r3
-       mov     r3,_bkpos
-       bic     $30,_flag
-       cmp     r2,$2*4.
-       bne     2f
-       cmp     r3,$6                   / kingside castle
-       bne     1f
-       inc     _value
-       mov     $4,_board+[2*5.]
-       clr     _board+[2*7.]
-       mov     $2,(r4)+
-       mov     r4,_amp
-       rts     pc
-1:
-       cmp     r3,$2                   / queenside castle
-       bne     2f
-       inc     _value
-       mov     $4,_board+[2*3.]
-       clr     _board+[2*0.]
-       mov     $3,(r4)+
-       mov     r4,_amp
-       rts     pc
-2:                                     / king move
-       tst     _game
-       bne     1f
-       sub     $2,_value
-1:
-       clr     (r4)+
-       mov     r4,_amp
-       rts     pc
-
-qmove:
-       tst     _game
-       bne     move
-       dec     _value
-       br      move
-
-nmove:
-bmove:
-move:
-       mov     $1,(r4)+
-       mov     r4,_amp
-       rts     pc
-
-_bremove:
-       mov     _amp,r4
-       mov     -(r4),r0
-       mov     -(r4),r1
-       mov     -(r4),r3
-       mov     -(r4),r2
-       mov     -(r4),_eppos
-       mov     -(r4),_flag
-       mov     -(r4),_value
-       mov     r4,_amp
-       asl     r2
-       asl     r3
-       mov     _board(r3),_board(r2)
-       mov     r1,_board(r3)
-       asl     r0
-       jmp     *0f(r0)
-0:
-       movek
-       movex
-       moveo
-       moveoo
-       movep
-       moveq
-
-movek:
-       asr     r2
-       mov     r2,_bkpos
-
-movex:
-       rts     pc
-
-moveo:
-       mov     $4,_board+[2*7.]
-       clr     _board+[2*5]
-       mov     $4,_bkpos
-       rts     pc
-
-moveoo:
-       mov     $4,_board+[2*0]
-       clr     _board+[2*3]
-       mov     $4,_bkpos;
-       rts     pc
-
-movep:
-       mov     $1,_board(r2)
-       clr     _board+[2*8.](r3)
-       rts     pc
-
-moveq:
-       mov     $1,_board(r2)
-       rts     pc
diff --git a/usr/src/games/chess/book.c b/usr/src/games/chess/book.c
deleted file mode 100644 (file)
index 8b88fe8..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-#include "old.h"
-
-bookm()
-{
-       int i, buf[2];
-
-       if(!bookp) return(0);
-       lseek(bookf, (long)(unsigned)bookp, 0);
-
-       i = 0;
-loop:
-       read(bookf, buf, 4);
-       *buf = booki(*buf);
-       if(*buf >= 0) {
-               if(!i)
-                       i = *buf;
-               goto loop;
-       }
-       if(abmove = i)
-               return(1);
-       return(0);
-}
-
-makmov(m)
-{
-       int buf[2];
-
-       out1(m);
-       mantom? bmove(m): wmove(m);
-       increm();
-       if(!bookp) return;
-       lseek(bookf, (long)(unsigned)bookp, 0);
-
-loop:
-       read(bookf, buf, 4);
-       *buf = booki(*buf);
-       if(m == *buf || *buf == 0) {
-               bookp = buf[1] & ~1;
-               goto l1;
-       }
-       if(*buf < 0) {
-               bookp = 0;
-               goto l1;
-       }
-       goto loop;
-
-l1:
-       if(!bookp) {
-               putchar('\n');
-               return;
-       }
-}
-
-booki(m)
-{
-       int i;
-       struct {
-               char low;
-               char high;
-       };
-       i.high = m.low;
-       i.low = m.high;
-       return(i);
-}
-
diff --git a/usr/src/games/chess/bplay.c b/usr/src/games/chess/bplay.c
deleted file mode 100644 (file)
index 927b86b..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-#include "old.h"
-
-bplay()
-{
-       int v1, v2, *p1, *p2, *p3, ab;
-
-       if(value > ivalue)
-               ivalue = value;
-       ab = 0;
-       v1 = -3000;
-       ply = 0;
-       p1 = statl();
-       if(lmp == p1+2) {
-               abmove = p1[1];
-               lmp = p1;
-               return(ivalue);
-       }
-       p2 = p1;
-       mantom = !mantom;
-       while(p2 != lmp) {
-               p2++;
-               bmove(*p2);
-               if(testf) {
-                       mantom = !mantom;
-                       bstatic(1);
-                       mantom = !mantom;
-               }
-               if(rept())
-                       v2 = 0; else
-                       v2 = wplay1(v1);
-               if(v2 > v1 && !mate(3, 0)) {
-                       ab = *p2;
-                       v1 = v2;
-               }
-               bremove();
-               if(testf) {
-                       mantom = !mantom;
-                       printf("%6d ", v2);
-                       out(*p2);
-                       printf("\n");
-                       mantom = !mantom;
-               }
-               p2++;
-       }
-       if(ab == 0 && lmp != p1)
-               ab = p1[1];
-       mantom = !mantom;
-       lmp = p1;
-       abmove = ab;
-       return(v1);
-}
-
-bplay1(ab)
-int ab;
-{
-       int v1, v2, *p1, *p2;
-
-       if(ply >= depth)
-               return(bquies(ab));
-       ply++;
-       p1 = p2 = lmp;
-       bgen();
-       qsort(p1, lmp);
-       v1 = -3000;
-       while(p2 != lmp) {
-               if(intrp)
-                       goto out;
-               p2++;
-               bmove(*p2);
-               if(wattack(bkpos)) {
-                       v2 = wplay1(v1);
-                       if(v2 > v1)
-                               v1 = v2;
-               }
-               bremove();
-               if(v1 >= ab)
-                       goto out;
-               p2++;
-       }
-out:
-       ply--;
-       lmp = p1;
-       if(v1 == -3000) {
-               v1++;
-               if(!check())
-                       v1 = 0;
-       }
-       return(v1);
-}
-
-bquies(ab)
-int ab;
-{
-       int *p1, *p2, *p3, v1, v2;
-
-       if(ply >= qdepth)
-               return(ivalue);
-       p1 = p2 = p3 = lmp;
-       bgen();
-       while(p2 != lmp) {
-               v1 = -(*p2++);
-               if(v1 != value && v1 >= ivalue-50) {
-                       *p3++ = ((-(pval+6)[board[*p2>>8]]/100)<<8) |
-                               ((pval+6)[board[*p2&0377]]/100);
-                       *p3++ = *p2;
-               }
-               p2++;
-       }
-       if(p3 == p1) {
-               lmp = p1;
-               return(value);
-       }
-       ply++;
-       qsort(p1, p3);
-       lmp = p3;
-       p2 = p1;
-       v1 = value;
-       while(p2 != lmp) {
-               p2++;
-               bmove(*p2);
-               if(wattack(bkpos)) {
-                       v2 = wquies(v1);
-               } else
-                       v2 = -3000;
-               if(v2 > v1)
-                       v1 = v2;
-               bremove();
-               if(v1 >= ab)
-                       goto out;
-               p2++;
-       }
-out:
-       ply--;
-       lmp = p1;
-       return(v1);
-}
diff --git a/usr/src/games/chess/ctrl.s b/usr/src/games/chess/ctrl.s
deleted file mode 100644 (file)
index 6091624..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/ list pieces controlling a square
-
-.globl _attack
-
-.globl _dir, _board
-.globl _attacv
-
-none   = 12345
-uleft  = 04040;
-uright = 04004;
-dleft  = 00440;
-dright = 00404;
-left   = 00040;
-right  = 00004;
-up     = 04000;
-down   = 00400;
-u2r1   = 06004;
-u1r2   = 04006;
-d1r2   = 00406;
-d2r1   = 00604;
-d2l1   = 00640;
-d1l2   = 00460;
-u1l2   = 04060;
-u2l1   = 06040;
-
-_attack:
-       mov     2(sp),r0
-       asl     r0
-       mov     $_attacv,r4
-
-       jsr     r5,patt
-               u2r1
-               -15.*2
-               2; -2
-       jsr     r5,patt
-               u1r2
-               -6.*2
-               2; -2
-       jsr     r5,patt
-               d2r1
-               17.*2
-               2; -2
-       jsr     r5,patt
-               d2l1
-               15.*2
-               2; -2
-       jsr     r5,patt
-               d1l2
-               6.*2
-               2; -2
-       jsr     r5,patt
-               u1l2
-               -10.*2
-               2; -2
-       jsr     r5,patt
-               u2l1
-               -17.*2
-               2; -2
-
-       jsr     r5,satt
-               uleft; -9.*2
-               1
-               3; -3; 5; -5
-       jsr     r5,satt
-               uright; -7.*2
-               1
-               3; -3; 5; -5
-       jsr     r5,satt
-               dleft; 7.*2
-               -1
-               3; -3; 5; -5
-       jsr     r5,satt
-               dright; 9.*2
-               -1
-               3; -3; 5; -5
-       jsr     r5,satt
-               up; -8.*2
-               none
-               4; -4; 5; -5
-       jsr     r5,satt
-               left; -1.*2
-               none
-               4; -4; 5; -5
-       jsr     r5,satt
-               right; 1.*2
-               none
-               4; -4; 5; -5
-       jsr     r5,satt
-               down; 8.*2
-               none
-               4; -4; 5; -5
-       clr     (r4)+
-       rts     pc
-
-patt:
-       bit     (r5)+,_dir(r0)
-       bne     1f
-       mov     r0,r1
-       add     (r5)+,r1
-       jsr     pc,look
-       jsr     pc,look
-       rts     r5
-1:
-       add     $6,r5
-       rts     r5
-
-satt:
-       mov     r5,-(sp)
-       bit     (r5)+,_dir(r0)
-       bne     1f
-       mov     r0,r1
-       add     (r5)+,r1
-       jsr     pc,look                 / pawn
-       mov     r0,r1
-2:
-       mov     (sp),r5
-       bit     (r5)+,_dir(r1)
-       bne     1f
-       add     (r5)+,r1
-       tst     _board(r1)
-       beq     2b
-       tst     (r5)+
-       mov     r4,-(sp)
-       jsr     pc,look
-       jsr     pc,look
-       jsr     pc,look
-       jsr     pc,look
-       cmp     (sp)+,r4
-       bne     2b
-1:
-       mov     (sp)+,r5
-       add     $14.,r5
-       rts     r5
-
-look:
-       cmp     (r5)+,_board(r1)
-       bne     1f
-       mov     -2(r5),(r4)+
-1:
-       rts     pc
diff --git a/usr/src/games/chess/data.c b/usr/src/games/chess/data.c
deleted file mode 100644 (file)
index 12a512f..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-int    center[]
-{
-       2,3,4,4,4,4,3,2,
-       3,6,8,8,8,8,6,3,
-       4,8,12,12,12,12,8,4,
-       4,8,12,14,14,12,8,4,
-       4,8,12,14,14,12,8,4,
-       4,8,12,12,12,12,8,4,
-       3,6,8,8,8,8,6,3,
-       2,3,4,4,4,4,3,2
-};
-
-int    wheur1();
-int    wheur2();
-int    wheur3();
-int    wheur4();
-int    wheur5();
-int    wheur6();
-int    wheur[]
-{
-       &wheur1,
-       &wheur2,
-       &wheur3,
-       &wheur4,
-       &wheur5,
-       &wheur6,
-       0
-};
-
-int    bheur1();
-int    bheur2();
-int    bheur3();
-int    bheur4();
-int    bheur5();
-int    bheur6();
-int    bheur[]
-{
-       &bheur1,
-       &bheur2,
-       &bheur3,
-       &bheur4,
-       &bheur5,
-       &bheur6,
-       0
-};
-
-int    ipval[]
-{
-       -3000, -900, -500, -300, -300, -100,
-       0,
-       100, 300, 300, 500, 900, 3000
-};
-
-int    moveno  1;
-int    depth   2;
-int    qdepth  8;
-int    mdepth  4;
-int    flag    033;
-int    eppos   64;
-int    bkpos   4;
-int    wkpos   60;
-int    edge[]
-{
-       040, 020, 010, 0, 0, 1, 2, 4
-};
-int    board[]
-{
-       4, 2, 3, 5, 6, 3, 2, 4,
-       1, 1, 1, 1, 1, 1, 1, 1,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       -1, -1, -1, -1, -1, -1, -1, -1,
-       -4, -2, -3, -5, -6, -3, -2, -4,
-};
diff --git a/usr/src/games/chess/init.c b/usr/src/games/chess/init.c
deleted file mode 100644 (file)
index 366557b..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-#include "old.h"
-
-main()
-{
-       int i;
-
-       printf("Chess\n");
-       itinit();
-       lmp = lmbuf;
-       amp = ambuf;
-       *amp++ = -1;
-       *lmp++ = -1;            /* fence */
-       bookf = open("/usr/lib/book", 0);
-       if(bookf > 0)
-               read(bookf, &bookp, 2);
-       i = 64;
-       while(i--)
-               dir[i] = (edge[i/8]<<6) | edge[i%8];
-       play(0);
-}
-
-ctime(s, t)
-{
-
-       printf("%s: %d:%d%d\n", s, t/60, (t/10)%6, t%10);
-}
-
-check()
-{
-
-       return((!wattack(bkpos) || !battack(wkpos))? 1: 0);
-}
-
-increm()
-{
-
-       clktim[mantom] =+ clock();
-       if(mantom)
-               moveno++;
-       mantom = !mantom;
-}
-
-decrem()
-{
-
-       mantom = !mantom;
-       if(mantom)
-               moveno--;
-}
-
-stage()
-{
-       int i, a;
-
-       qdepth = depth+8;
-       for(i=0; i<13; i++)
-               pval[i] = ipval[i];
-       value = 0;
-       for(i=0; i<64; i++) {
-               a = board[i];
-               value =+ (pval+6)[a];
-       }
-       if(value > 150)
-               gval = 1; else
-       if(value < -150)
-               gval = -1; else
-               gval = 0;
-       i = -6;
-       while(i <= 6) {
-               a = (pval+6)[i];
-               if(a < 0)
-                       a =- 50; else
-                       a =+ 50;
-               if(a < 0)
-                       a = -((-a)/100); else
-                       a =/ 100;
-               if(i)
-                       (pval+6)[i] = a*100-gval;
-               i++;
-       }
-       a = 13800;
-       i = 64;
-       while(i--)
-               a =- abs((pval+6)[board[i]]);
-       if(a > 4000)
-               game = 3; else
-       if(a > 2000)
-               game = 2; else
-       if(moveno > 5)
-               game = 1; else
-               game = 0;
-}
-
-posit(f, p, a)
-int (*f)();
-int *p;
-{
-       int m;
-
-       while(amp != p) {
-               m = amp[3]<<8;
-               m =| amp[4]&0377;
-               (*f)(m, a);
-               if(mantom) {
-                       bmove(m);
-                       moveno++;
-                       mantom = 0;
-               } else {
-                       wmove(m);
-                       mantom = 1;
-               }
-       }
-}
-
-rept1(m, a)
-int *a;
-{
-       int i;
-
-       if(mantom != a[64])
-               return;
-       for(i=0; i<64; i++)
-               if(board[i] != a[i])
-                       return;
-       a[65]++;
-}
-
-rept()
-{
-       int a[66], i, *p;
-
-       for(i=0; i<64; i++)
-               a[i] = board[i];
-       a[64] = mantom;
-       a[65] = 0;
-       p = amp;
-       while(amp[-1] != -1) {
-               if(amp[-2])
-                       break;
-               i = board[amp[-3]];
-               if(i == 1 || i == -1)
-                       break;
-               mantom? wremove(): bremove();
-               decrem();
-       }
-       posit(rept1, p, a);
-       return(a[65]);
-}
diff --git a/usr/src/games/chess/io.c b/usr/src/games/chess/io.c
deleted file mode 100644 (file)
index 70ffdb4..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-#include "old.h"
-
-rline()
-{
-       char *p1;
-       int c;
-
-       p1 = sbuf;
-       while((c = getchar()) != '\n')
-               if(c <= 0)
-                       onhup(); else
-                       *p1++ = c;
-       *p1++ = '\0';
-}
-
-getchar()
-{
-       int c;
-
-loop:
-       c = 0;
-       read(0, &c, 1);
-       if(c == 0 && intrp) {
-               intrp = 0;
-               goto loop;
-       }
-       return(c);
-}
-
-pboard()
-{
-       int i, x, y, c, p;
-
-       c = 0;
-       i = 0;
-       x = 8;
-       while(x--) {
-               if(!mantom || mfmt)
-                       putchar('1'+x); else
-                       putchar('8'-x);
-               putchar(' ');
-               c++;
-               y = 8;
-               while(y--) {
-                       c++;
-                       putchar(' ');
-                       if(p = board[i++])
-                               putchar("kqrbnp PNBRQK"[p+6]); else
-                               if((c&1)!=0)
-                                       putchar('*'); else
-                                       putchar('-');
-               }
-               putchar('\n');
-               if(intrp)
-                       return;
-       }
-       if(mfmt)
-               printf("\n   a b c d e f g h"); else
-               printf("\n   q q q q k k k k\n   r n b     b n r");
-               printf("\n");
-}
-
-out1(m)
-{
-       printf("%d. ", moveno);
-       if(mantom)
-               printf("... ");
-       out(m);
-       putchar('\n');
-}
-
-out(m)
-int m;
-{
-       int from, to, epf, pmf;
-
-       from = m>>8;
-       to = m&0377;
-       if(mfmt) {
-               algco(from);
-               algco(to);
-               return;
-       }
-       mantom? bmove(m): wmove(m);
-       epf = pmf = 0;
-       switch(amp[-1]) {
-
-       case 0:
-       case 1:
-               stdp(board[to]);
-       ed:
-               putchar('/');
-               stdb(from);
-               if(amp[-2]) {
-                       putchar('x');
-                       stdp(amp[-2]);
-                       putchar('/');
-               } else
-                       putchar('-');
-               stdb(to);
-               break;
-
-       case 3:
-               putchar('o');
-               putchar('-');
-
-       case 2:
-               putchar('o');
-               putchar('-');
-               putchar('o');
-               break;
-
-       case 4:
-               epf = 1;
-               putchar('p');
-               goto ed;
-
-       case 5:
-               pmf = 1;
-               putchar('p');
-               goto ed;
-       }
-       if(pmf) {
-               putchar('(');
-               putchar('q');
-               putchar(')');
-       }
-       if(epf) {
-               putchar('e');
-               putchar('p');
-       }
-       if(check())
-               putchar('+');
-       mantom? bremove(): wremove();
-}
-
-stdp(p)
-int p;
-{
-
-       if(p < 0)
-               p = -p;
-       p = "ppnbrqk"[p];
-       putchar(p);
-}
-
-stdb(b)
-int b;
-{
-       int r, f;
-
-       r = b/8;
-       if((f = b%8) < 4)
-               putchar('q'); else {
-               putchar('k');
-               f = 7-f;
-       }
-       f = "rnb\0"[f];
-       if(f)
-               putchar(f);
-       putchar(mantom? r+'1': '8'-r);
-}
-
-algco(p)
-int p;
-{
-       putchar('a'+(p%8));
-       putchar('8'-(p/8));
-}
-
-putchar(c)
-{
-
-       switch(c) {
-
-       case '\t':
-               do
-                       putchar(' ');
-               while(column%8);
-               return;
-
-       case '\n':
-               column = 0;
-               break;
-
-       default:
-               column++;
-       }
-       write(1, &c, 1);
-}
-
-prtime(a, b)
-{
-
-       printf("time = %d/%d\n", a, b);
-}
-
-score1(m)
-{
-       if(intrp)
-               return;
-       if(!mantom) {
-               if(moveno < 10)
-                       putchar(' '); else
-                       putchar(moveno/10 + '0');
-               putchar(moveno%10 + '0');
-               putchar('.');
-               putchar(' ');
-       } else
-               while(column < 20)
-                       putchar(' ');
-       out(m);
-       if(mantom)
-               putchar('\n');
-}
-
-score()
-{
-       int *p;
-
-       putchar('\n');
-       p = amp;
-       while(amp[-1] != -1) {
-               mantom? wremove(): bremove();
-               decrem();
-       }
-       posit(score1, p);
-       putchar('\n');
-}
diff --git a/usr/src/games/chess/makefile b/usr/src/games/chess/makefile
deleted file mode 100644 (file)
index f556d3f..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-a.out: agen.o\
-       att.o\
-       bgen.o\
-       bheur.o\
-       bmove.o\
-       book.o\
-       bplay.o\
-       ctrl.o\
-       data.o\
-       init.o\
-       io.o\
-       mater.o\
-       play.o\
-       qsort.o\
-       savres.o\
-       setup.o\
-       stat.o\
-       stdin.o\
-       wgen.o\
-       wheur.o\
-       wmove.o\
-       wplay.o
-       cc -n -s agen.o\
-       att.o\
-       bgen.o\
-       bheur.o\
-       bmove.o\
-       book.o\
-       bplay.o\
-       ctrl.o\
-       data.o\
-       init.o\
-       io.o\
-       mater.o\
-       play.o\
-       qsort.o\
-       savres.o\
-       setup.o\
-       stat.o\
-       stdin.o\
-       wgen.o\
-       wheur.o\
-       wmove.o\
-       wplay.o
-
-agen.i:        agen.c old.h
-       cc -S -O agen.c
-       mv agen.s  agen.i
-
-agen.o:        agen.i
-       as - -o agen.o agen.i
-
-bheur.i:       bheur.c old.h
-       cc -S -O bheur.c
-       mv bheur.s  bheur.i
-
-bheur.o:       bheur.i
-       as - -o bheur.o bheur.i
-
-book.i:        book.c old.h
-       cc -S -O book.c
-       mv book.s  book.i
-
-book.o:        book.i
-       as - -o book.o book.i
-
-bplay.i:       bplay.c old.h
-       cc -S -O bplay.c
-       mv bplay.s  bplay.i
-
-bplay.o:       bplay.i
-       as - -o bplay.o bplay.i
-
-data.i:        data.c old.h
-       cc -S -O data.c
-       mv data.s  data.i
-
-data.o:        data.i
-       as - -o data.o data.i
-
-init.i:        init.c old.h
-       cc -S -O init.c
-       mv init.s  init.i
-
-init.o:        init.i
-       as - -o init.o init.i
-
-io.i:  io.c old.h
-       cc -S -O io.c
-       mv io.s  io.i
-
-io.o:  io.i
-       as - -o io.o io.i
-
-mater.i:       mater.c old.h
-       cc -S -O mater.c
-       mv mater.s  mater.i
-
-mater.o:       mater.i
-       as - -o mater.o mater.i
-
-play.i:        play.c old.h
-       cc -S -O play.c
-       mv play.s  play.i
-
-play.o:        play.i
-       as - -o play.o play.i
-
-savres.i:      savres.c old.h
-       cc -S -O savres.c
-       mv savres.s  savres.i
-
-savres.o:      savres.i
-       as - -o savres.o savres.i
-
-setup.i:       setup.c old.h
-       cc -S -O setup.c
-       mv setup.s  setup.i
-
-setup.o:       setup.i
-       as - -o setup.o setup.i
-
-stat.i:        stat.c old.h
-       cc -S -O stat.c
-       mv stat.s  stat.i
-
-stat.o:        stat.i
-       as - -o stat.o stat.i
-
-stdin.i:       stdin.c old.h
-       cc -S -O stdin.c
-       mv stdin.s  stdin.i
-
-stdin.o:       stdin.i
-       as - -o stdin.o stdin.i
-
-wheur.i:       wheur.c old.h
-       cc -S -O wheur.c
-       mv wheur.s  wheur.i
-
-wheur.o:       wheur.i
-       as - -o wheur.o wheur.i
-
-wplay.i:       wplay.c old.h
-       cc -S -O wplay.c
-       mv wplay.s  wplay.i
-
-wplay.o:       wplay.i
-       as - -o wplay.o wplay.i
-
-att.o: att.s
-       as - -o att.o att.s
-
-bgen.o:        bgen.s
-       as - -o bgen.o bgen.s
-
-bmove.o:       bmove.s
-       as - -o bmove.o bmove.s
-
-ctrl.o:        ctrl.s
-       as - -o ctrl.o ctrl.s
-
-qsort.o:       qsort.s
-       as - -o qsort.o qsort.s
-
-wgen.o:        wgen.s
-       as - -o wgen.o wgen.s
-
-wmove.o:       wmove.s
-       as - -o wmove.o wmove.s
-
diff --git a/usr/src/games/chess/mater.c b/usr/src/games/chess/mater.c
deleted file mode 100644 (file)
index 422a989..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-#include "old.h"
-
-mate(n, f)
-{
-       int a, b;
-
-       mantom = !mantom;
-       if(f == 0) {
-               b = mater(n);
-               mantom = !mantom;
-               return(b);
-       }
-       b = 0;
-       if(matflg) {
-               a = 1;
-               while(!mater(a)) {
-                       if(a >= n) {
-                               matflg = 0;
-                               return(0);
-                       }
-                       a++;
-               }
-               b = abmove;
-               goto out;
-       }
-       a = n;
-       while(mater(a)) {
-               if(a == mdepth) {
-                       printf("Forced mate\n");
-                       matflg++;
-               }
-               b = abmove;
-               if(a == 0)
-                       break;
-               a--;
-       }
-out:
-       mantom = !mantom;
-       if(b) {
-               abmove = b;
-               return(1);
-       }
-       return(0);
-}
-
-mater(ns)
-{
-       int *p1, *p2, *p3, f;
-
-       if(intrp || --ns < 0)
-               return(0);
-       p1 = lmp;
-       p2 = p1;
-       p3 = p1;
-       mantom? wgen(): bgen();
-       while(p2 != lmp) {
-               p2++;
-               mantom? wmove(*p2): bmove(*p2);
-               if((!mantom && !battack(wkpos) && wattack(bkpos)) ||
-                 (mantom && !wattack(bkpos) && battack(wkpos))) {
-                       *p3 = *p2;
-                       p3++;
-               }
-               mantom? wremove(): bremove();
-               p2++;
-       }
-       lmp = p3;
-       p2 = p1;
-       while(p2 != lmp) {
-               mantom? wmove(*p2): bmove(*p2);
-               f = xmater(ns);
-               mantom? wremove(): bremove();
-               if(f) {
-                       abmove = *p2;
-                       lmp = p1;
-                       return(1);
-               }
-               p2++;
-       }
-       lmp = p1;
-       return(0);
-}
-
-xmater(ns)
-{
-       int *p1, *p2, f;
-
-       p1 = lmp;
-       p2 = p1;
-       mantom? bagen(): wagen();
-       if(p2+2 == lmp && rept() == 0)
-               ns++;
-       while(p2 != lmp) {
-               p2++;
-               mantom? bmove(*p2): wmove(*p2);
-               f = mater(ns);
-               mantom? bremove(): wremove();
-               if(!f) {
-                       lmp = p1;
-                       return(0);
-               }
-               p2++;
-       }
-       lmp = p1;
-       return(1);
-}
diff --git a/usr/src/games/chess/old.h b/usr/src/games/chess/old.h
deleted file mode 100644 (file)
index 2f554ac..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-#define        uleft   04040
-#define        uright  04004
-#define        dleft   00440
-#define        dright  00404
-#define        left    00040
-#define        right   00004
-#define        up      04000
-#define        down    00400
-#define        u2r1    06004
-#define        u1r2    04006
-#define        d1r2    00406
-#define        d2r1    00604
-#define        d2l1    00640
-#define        d1l2    00460
-#define        u1l2    04060
-#define        u2l1    06040
-#define        rank2   00200
-#define        rank7   02000
-
-int    attacv[64];
-int    center[64];
-int    wheur[];
-int    bheur[];
-int    control[64];
-int    clktim[2];
-int    testf;
-int    qdepth;
-int    mdepth;
-int    bookf;
-int    bookp;
-int    manflg;
-int    matflg;
-int    intrp;
-int    moveno;
-int    gval;
-int    game;
-int    abmove;
-int    *lmp;
-int    *amp;
-char   *sbufp;
-int    lastmov;
-int    mantom;
-int    ply;
-int    value;
-int    ivalue;
-int    mfmt;
-int    depth;
-int    flag;
-int    eppos;
-int    bkpos;
-int    wkpos;
-int    column;
-int    edge[8];
-int    pval[13];
-int    ipval[13];
-int    dir[64];
-int    board[64];
-int    lmbuf[1000];
-int    ambuf[1200];
-char   sbuf[100];
diff --git a/usr/src/games/chess/pio.c b/usr/src/games/chess/pio.c
deleted file mode 100644 (file)
index ca0ec0c..0000000
+++ /dev/null
@@ -1,377 +0,0 @@
-#include "old.h"
-
-rline()
-{
-       char *p1;
-       int c;
-
-loop0:
-       p1 = sbuf;
-loop:
-       c = getchar();
-       if(c <= 0)
-               exit(0);
-       if(c == '#')
-               goto loop0;
-       if(c != '*') {
-               *p1++ = c;
-               goto loop;
-       }
-       switch(getchar()) {
-
-       case '#':
-               goto loop0;
-
-       case '*':
-               if(p1 != sbuf+4) {
-                       printf("bad input\n");
-                       goto loop0;
-               }
-               sbuf[0] =+ 'a'-'1';
-               sbuf[2] =+ 'a'-'1';
-               *p1++ = '\0';
-               return;
-
-       case '0':
-               exit(0);
-
-       case '1':
-               spread("");
-               return;
-
-       case '2':
-               spread("first");
-               return;
-
-       case '3':
-               spread("clock");
-               return;
-
-       case '4':
-               spread("score");
-               return;
-
-       case '5':
-               spread("remove");
-               return;
-
-       case '6':
-               spread("repeat");
-               return;
-
-       case '7':
-               spread("save");
-               return;
-
-       case '8':
-               spread("restore");
-               return;
-       }
-       printf("bad option\n");
-       goto loop;
-}
-
-spread(s)
-char *s;
-{
-       char *p;
-
-       p = sbuf;
-       while(*p++ = *s++) ;
-}
-
-pboard()
-{
-       int i, x, y, c, p;
-
-       i = 0;
-       x = 8;
-       while(x--) {
-               y = 8;
-               while(y--) {
-                       p = board[i++];
-                       if(p == 0) {
-                               printf("space\n");
-                               continue;
-                       }
-                       if(p < 0)
-                               printf("white "); else
-                               printf("black ");
-                       putpiece("kqrbnp pnbrqk"[p+6]);
-               }
-               pause();
-               printf("end\n");
-               pause();
-       }
-}
-
-putpiece(p)
-{
-       char *s;
-
-       s = "god only knows";
-       switch(p) {
-
-       case 'p':
-               s = "pawn";
-               break;
-
-       case 'n':
-               s = "knight";
-               break;
-
-       case 'b':
-               s = "bishop";
-               break;
-
-       case 'r':
-               s = "rook";
-               break;
-
-       case 'q':
-               s = "queen";
-               break;
-
-       case 'k':
-               s = "king";
-               break;
-       }
-       printf("%s\n", s);
-}
-
-out1(m)
-{
-       putnumb(moveno);
-       pause();
-       out(m);
-       pause();
-}
-
-out(m)
-int m;
-{
-       int from, to, epf, pmf;
-
-       from = m>>8;
-       to = m&0377;
-       mantom? bmove(m): wmove(m);
-       epf = pmf = 0;
-       switch(amp[-1]) {
-
-       case 0:
-       case 1:
-               stdp(board[to]);
-       ed:
-               printf("at\n");
-               stdb(from);
-               if(amp[-2]) {
-                       printf("takes\n");
-                       stdp(amp[-2]);
-                       printf("at\n");
-               } else
-                       printf("to\n");
-               stdb(to);
-               break;
-
-       case 3:
-               printf("castle queen side\n");
-               break;
-
-       case 2:
-               printf("castle king side\n");
-               break;
-
-       case 4:
-               epf = 1;
-               putpiece('p');
-               goto ed;
-
-       case 5:
-               pmf = 1;
-               putpiece('p');
-               goto ed;
-       }
-       if(pmf) {
-               printf("becomes\n");
-               putpiece('q');
-       }
-       if(epf) {
-               printf("en passent\n");
-       }
-       if(check())
-               printf("check\n");
-       mantom? bremove(): wremove();
-}
-
-stdp(p)
-int p;
-{
-
-       if(p < 0)
-               p = -p;
-       p = "ppnbrqk"[p];
-       putpiece(p);
-}
-
-stdb(b)
-int b;
-{
-       int r, f;
-
-       r = b/8;
-       if((f = b%8) < 4)
-               putpiece('q'); else {
-               putpiece('k');
-               f = 7-f;
-       }
-       f = "rnb\0"[f];
-       if(f)
-               putpiece(f);
-       putnumb(mantom? r+1: 8-r);
-}
-
-prtime(a, b)
-{
-
-       printf("compute time is\n");
-       putnumb(a);
-       printf("real time is\n");
-       putnumb(b);
-       pause();
-}
-
-putnumb(n)
-{
-
-       if(n <= 12) {
-               putdig(n);
-               putchar('\n');
-               return;
-       }
-       if(n <= 19) {
-               putdig(n+1);
-               printf("teen\n");
-               return;
-       }
-       if(n >= 100) {
-               putnumb(n/100);
-               printf("hundred\n");
-               n =% 100;
-               if(n)
-                       putnumb(n);
-               return;
-       }
-       putdig(n/10+11);
-       printf("tee\n");
-       n =% 10;
-       if(n)
-               putnumb(n);
-}
-
-putdig(n)
-{
-       char *s;
-
-       s = "god only knows";
-       switch(n) {
-
-       case 0:
-               s = "zero";
-               break;
-
-       case 1:
-               s = "one";
-               break;
-
-       case 2:
-               s = "two";
-               break;
-
-       case 3:
-               s = "three";
-               break;
-
-       case 4:
-       case 15:
-               s = "four";
-               break;
-
-       case 5:
-               s = "five";
-               break;
-
-       case 6:
-       case 17:
-               s = "six";
-               break;
-
-       case 7:
-       case 18:
-               s = "seven";
-               break;
-
-       case 8:
-       case 19:
-               s = "eight";
-               break;
-
-       case 9:
-       case 20:
-               s = "nine";
-               break;
-
-       case 10:
-               s = "ten";
-               break;
-
-       case 11:
-               s = "eleven";
-               break;
-
-       case 12:
-               s = "twelve";
-               break;
-
-       case 13:
-               s = "twen";
-               break;
-
-       case 14:
-               s = "thir";
-               break;
-
-       case 16:
-               s = "fif";
-               break;
-       }
-       printf(s);
-}
-
-pause()
-{
-
-       printf("...\n");
-}
-
-score1(m)
-{
-       if(!mantom) {
-               putnumb(moveno);
-               pause();
-       }
-       out(m);
-       pause();
-}
-
-score()
-{
-       int *p;
-
-       p = amp;
-       while(amp[-1] != -1) {
-               mantom? wremove(): bremove();
-               decrem();
-       }
-       posit(score1, p);
-       printf("the end\n");
-}
diff --git a/usr/src/games/chess/play.c b/usr/src/games/chess/play.c
deleted file mode 100644 (file)
index 1b0ba52..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-#include "old.h"
-
-play(f)
-int f;
-{
-       int t, i, ts[9];
-
-       clock();
-       ts[8] = 0;
-       if(f) goto first;
-loop:
-       intrp = 0;
-       move();
-
-first:
-       if(manflg)
-               goto loop;
-       i = mantom;
-       t = clktim[i];
-       if(!bookm())
-       if(!mate(mdepth, 1))
-               xplay();
-       if(intrp) {
-               decrem();
-               mantom? bremove(): wremove();
-               goto loop;
-       }
-       if(!abmove) {
-               printf("Resign\n");
-               onhup();
-       }
-       makmov(abmove);
-       i = clktim[i];
-       t = i-t;
-       times(ts);
-       ts[8] = ts[1];
-       if(i/moveno > 150) {
-               if(depth > 1)
-                       goto decr;
-               goto loop;
-       }
-       if(depth==3 && t>180)
-               goto decr;
-       if(depth==1 && t<60)
-               goto incr;
-       if(game==3 && t<60 && depth==2)
-               goto incr;
-       goto loop;
-
-incr:
-       depth++;
-       goto loop;
-
-decr:
-       goto loop;
-}
-
-move()
-{
-       int a, *p, *p1;
-
-loop:
-       lmp = done();
-       a = manual();
-       p = done();
-       p1 = p;
-       while(p1 != lmp) {
-               p1++;
-               if(*p1++ == a) {
-                       lmp = p;
-                       makmov(a);
-                       return;
-               }
-       }
-       printf("Illegal move\n");
-       lmp = p;
-       goto loop;
-}
-
-manual()
-{
-       int a, b, c;
-       char *p1;
-       extern out1;
-
-loop:
-       intrp = 0;
-       stage();
-       rline();
-       sbufp = sbuf;
-       if(match("save")) {
-               save();
-               goto loop;
-       }
-       if(match("test")) {
-               testf = !testf;
-               goto loop;
-       }
-       if(match("remove")) {
-               if(amp[-1] != -1) {
-                       decrem();
-                       mantom? bremove(): wremove();
-               }
-               if(amp[-1] != -1) {
-                       decrem();
-                       mantom? bremove(): wremove();
-               }
-               goto loop;
-       }
-       if(match("exit"))
-               exit();
-       if(match("manual")) {
-               manflg = !manflg;
-               goto loop;
-       }
-       if(match("resign"))
-               onhup();
-       if(moveno == 1 && mantom == 0) {
-               if(match("first"))
-                       play(1);
-               if(match("alg")) {
-                       mfmt = 1;
-                       goto loop;
-               }
-               if(match("restore")) {
-                       restore();
-                       goto loop;
-               }
-       }
-       if(match("clock")) {
-               clktim[mantom] =+ clock();
-               ctime("white", clktim[0]);
-               ctime("black", clktim[1]);
-               goto loop;
-       }
-       if(match("score")) {
-               score();
-               goto loop;
-       }
-       if(match("setup")) {
-               setup();
-               goto loop;
-       }
-       if(match("hint")) {
-               a = xplay();
-               out(abmove);
-               printf(" %d\n", a);
-               goto loop;
-       }
-       if(match("repeat")) {
-               if(amp[-1] != -1) {
-                       a = amp;
-                       mantom? wremove(): bremove();
-                       decrem();
-                       posit(&out1, a);
-               }
-               goto loop;
-       }
-       if(*sbufp == '\0') {
-               pboard();
-               goto loop;
-       }
-       if((a=algin()) != 0) {
-               mfmt = 1;
-               return(a);
-       }
-       if((a=stdin()) != 0) {
-               mfmt = 0;
-               return(a);
-       }
-       printf("eh?\n");
-       goto loop;
-}
-
-algin()
-{
-       int from, to;
-
-       from = cooin();
-       to = cooin();
-       if(*sbufp != '\0') return(0);
-       return((from<<8)|to);
-}
-
-cooin()
-{
-       int a, b;
-
-       a = sbufp[0];
-       if(a<'a' || a>'h') return(0);
-       b = sbufp[1];
-       if(b<'1' || b>'8') return(0);
-       sbufp =+ 2;
-       a = (a-'a')+8*('8'-b);
-       return(a);
-}
-
-match(s)
-char *s;
-{
-       char *p1;
-       int c;
-
-       p1 = sbufp;
-       while((c = *s++) != '\0')
-               if(*p1++ != c) return(0);
-       sbufp = p1;
-       return(1);
-}
-
-done()
-{
-       int *p;
-
-       if(rept() > 3) {
-               printf("Draw by repetition\n");
-               onhup();
-       }
-       p = lmp;
-       mantom? bagen(): wagen();
-       if(p == lmp) {
-               if(check())
-                       if(mantom)
-                               printf("White wins\n"); else
-                               printf("Black wins\n"); else
-               printf("Stale mate\n");
-               onhup();
-       }
-       return(p);
-}
-
-xplay()
-{
-       int a;
-
-       stage();
-       abmove = 0;
-       a = mantom? bplay(): wplay();
-       ivalue = a;
-       return(a);
-}
-
-term()
-{
-
-       exit(0);
-}
diff --git a/usr/src/games/chess/qsort.s b/usr/src/games/chess/qsort.s
deleted file mode 100644 (file)
index 8a6a79c..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/ qsort interfact to c
-
-/      qsort(from, to)
-
-.globl _qsort
-_qsort:
-       mov     2(sp),r1
-       mov     4(sp),r2
-       jsr     pc,qsort
-       rts     pc
-
-
-qsort:
-       mov     r2,r3
-       sub     r1,r3
-       cmp     r3,$4
-       ble     done
-       asr     r3
-       bic     $3,r3
-       add     r1,r3
-       mov     r1,-(sp)
-       mov     r2,-(sp)
-
-loop:
-       cmp     r1,r3
-       bhis    loop1
-       cmp     (r1),(r3)
-       bgt     loop1
-       add     $4,r1
-       br      loop
-
-loop1:
-       cmp     r2,r3
-       blos    1f
-       sub     $4,r2
-       mov     r2,r0
-       cmp     (r0),(r3)
-       bge     loop1
-
-       mov     (r1),r0
-       mov     (r2),(r1)+
-       mov     r0,(r2)+
-       mov     (r1),r0
-       mov     (r2),(r1)
-       mov     r0,(r2)
-       cmp     -(r1),-(r2)
-       cmp     r1,r3
-       bne     loop
-       mov     r2,r3
-       br      loop
-
-1:
-       cmp     r1,r3
-       beq     1f
-       mov     (r1),r0
-       mov     (r2),(r1)+
-       mov     r0,(r2)+
-       mov     (r1),r0
-       mov     (r2),(r1)
-       mov     r0,(r2)
-       cmp     -(r1),-(r2)
-       mov     r1,r3
-       br      loop1
-
-1:
-       mov     (sp)+,r2
-       mov     r3,-(sp)
-       mov     r3,r1
-       add     $4,r1
-       jsr     pc,qsort
-       mov     (sp)+,r2
-       mov     (sp)+,r1
-       br      qsort
-
-done:
-       rts     pc
-
-       rti = 2
-
-/      itinit()
-
-.globl _itinit
-.globl _intrp, _term
-signal = 48.
-time = 13.
-
-_itinit:
-       sys     signal; 1; 1
-       bit     $1,r0
-       bne     1f
-       sys     signal; 1; _onhup
-1:
-       sys     signal; 2; 1
-       bit     $1,r0
-       bne     1f
-       sys     signal; 2; onint
-1:
-       sys     signal; 3; 1
-       rts     pc
-
-.globl _onhup
-_onhup:
-       sys     signal; 1; 1
-       sys     signal; 2; 1
-       sys     signal; 3; 1
-       jmp     _term
-
-onint:
-       mov     r0,-(sp)
-       sys     signal; 2; onint
-       inc     _intrp
-       mov     (sp)+,r0
-       rti
-
-/      t = clock()
-
-.globl _clock
-_clock:
-       sys     time
-       mov     r0,-(sp)
-       mov     r1,-(sp)
-       sub     t+2,r1
-       sbc     r0
-       sub     t,r0
-       mov     r1,r0
-       mov     (sp)+,t+2
-       mov     (sp)+,t
-       rts     pc
-
-.bss
-t:     .=.+4
diff --git a/usr/src/games/chess/savres.c b/usr/src/games/chess/savres.c
deleted file mode 100644 (file)
index 1f2d975..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#include "old.h"
-
-save()
-{
-       int i;
-       int f;
-
-       f = creat("chess.out", 0666);
-       if(f < 0) {
-               printf("cannot create file\n");
-               return;
-       }
-       write(f, clktim, 4);
-       write(f, &bookp, 2);
-       write(f, &moveno, 2);
-       write(f, &game, 2);
-       i = amp-ambuf;
-       write(f, &i, 2);
-       write(f, &mantom, 2);
-       write(f, &value, 2);
-       write(f, &ivalue, 2);
-       write(f, &depth, 2);
-       write(f, &flag, 2);
-       write(f, &eppos, 2);
-       write(f, &bkpos, 2);
-       write(f, &wkpos, 2);
-       write(f, board, 128);
-       write(f, ambuf, i*2);
-       close(f);
-}
-
-restore()
-{
-       int i;
-       int f;
-
-       f = open("chess.out", 0);
-       if(f < 0) {
-               printf("cannot open file\n");
-               return;
-       }
-       read(f, clktim, 4);
-       read(f, &bookp, 2);
-       read(f, &moveno, 2);
-       read(f, &game, 2);
-       read(f, &i, 2);
-       amp = ambuf+i;
-       read(f, &mantom, 2);
-       read(f, &value, 2);
-       read(f, &ivalue, 2);
-       read(f, &depth, 2);
-       read(f, &flag, 2);
-       read(f, &eppos, 2);
-       read(f, &bkpos, 2);
-       read(f, &wkpos, 2);
-       read(f, board, 128);
-       read(f, ambuf, i*2);
-       close(f);
-}
diff --git a/usr/src/games/chess/setup.c b/usr/src/games/chess/setup.c
deleted file mode 100644 (file)
index b7a280d..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-#include "old.h"
-
-setup()
-{
-       char bd[64];
-       char *p, *ip;
-       int i, err, nkng, c;
-       int wkp, bkp;
-
-       for(p=bd; p<bd+64; )
-               *p++ = 0;
-       err = 0;
-       nkng = 101;
-       p = bd;
-       for(i=0; i<8; i++) {
-               ip = p+8;
-
-       loop:
-               switch(c = getchar()) {
-
-               case 'K':
-                       nkng =- 100;
-                       c = 6;
-                       bkp = p-bd;
-                       break;
-
-               case 'k':
-                       nkng--;
-                       c = -6;
-                       wkp = p-bd;
-                       break;
-
-               case 'P':
-                       c = 1;
-                       break;
-
-               case 'p':
-                       c = -1;
-                       break;
-
-               case 'N':
-                       c = 2;
-                       break;
-
-               case 'n':
-                       c = -2;
-                       break;
-
-               case 'B':
-                       c = 3;
-                       break;
-
-               case 'b':
-                       c = -3;
-                       break;
-
-               case 'R':
-                       c = 4;
-                       break;
-
-               case 'r':
-                       c = -4;
-                       break;
-
-               case 'Q':
-                       c = 5;
-                       break;
-
-               case 'q':
-                       c = -5;
-                       break;
-
-               case '1':
-               case '2':
-               case '3':
-               case '4':
-               case '5':
-               case '6':
-               case '7':
-               case '8':
-                       p =+ c-'0';
-                       goto loop;
-
-               case ' ':
-                       p++;
-                       goto loop;
-
-               case '\n':
-                       if(p > ip)
-                               err++;
-                       p = ip;
-                       continue;
-
-               default:
-                       err++;
-                       if(c <= 0)
-                               onhup();
-                       goto loop;
-               }
-               if(p < ip)
-                       *p++ = c;
-               goto loop;
-       }
-       if(nkng)
-               err++;
-       if(err) {
-               printf("Illegal setup\n");
-               return;
-       }
-       for(i=0; i<64; i++)
-               board[i] = bd[i];
-       amp = ambuf+1;
-       lmp = lmbuf+1;
-       eppos = 64;
-       bookp = 0;
-       mantom = 0;
-       moveno = 1;
-       wkpos = wkp;
-       bkpos = bkp;
-       flag = 0;
-       if(wkpos == 60) {
-               if(board[56] == -4)
-                       flag =| 2;
-               if(board[63] == -4)
-                       flag =| 1;
-       }
-       if(bkpos == 4) {
-               if(board[0] == 4)
-                       flag =| 020;
-               if(board[7] == 4)
-                       flag =| 010;
-       }
-       printf("Setup successful\n");
-}
diff --git a/usr/src/games/chess/stat.c b/usr/src/games/chess/stat.c
deleted file mode 100644 (file)
index dc62932..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-#include "old.h"
-
-statl()
-{
-       int *p1, *p2, *p3;
-
-       p1 = p2 = lmp;
-       stage();
-       mantom? bagen(): wagen();
-       if(lmp == p1+1)
-               return(p1);
-       while(p2 != lmp) {
-               p3 = p2++;
-               if(mantom) {
-                       bmove(*p2++);
-                       *p3 = bstatic(0);
-                       bremove();
-               } else {
-                       wmove(*p2++);
-                       *p3 = wstatic(0);
-                       wremove();
-               }
-       }
-       qsort(p1, lmp);
-       return(p1);
-}
-
-wstatic(f)
-{
-       int i, j, h, (*p)();
-
-       h = i = 0;
-       while(p = wheur[h++]) {
-               j = (*p)();
-               if(f)
-                       printf("%4d ", j);
-               i =+ j;
-       }
-       if(f)
-               printf("=%4d ", i);
-       return(-i);
-}
-
-bstatic(f)
-{
-       int i, j, h, (*p)();
-
-       h = i = 0;
-       while(p = bheur[h++]) {
-               j = (*p)();
-               if(f)
-                       printf("%4d ", j);
-               i =+ j;
-       }
-       if(f)
-               printf("=%4d ", i);
-       return(-i);
-}
-
-xheur(ploc)
-int ploc;
-{
-       int *p1, *p2, from, to, pie;
-
-       pie = board[ploc];
-       p1 = lmp;
-       p2 = p1;
-       mantom? wgen(): bgen();
-       while(p2 != lmp) {
-               p2++;
-               to = *p2++ & 0377;
-               if(to == ploc) {
-                       from = p2[-1] >> 8;
-                       if(abs(board[from]) < abs(pie)) {
-                               lmp = p1;
-                               return((pval+6)[pie]/60);
-                       }
-               }
-       }
-       lmp = p1;
-       return(0);
-}
-
-srnd(p)
-int p;
-{
-
-       srnd1(p, uleft, -9);
-       srnd1(p, uright, -7);
-       srnd1(p, dleft, 7);
-       srnd1(p, dright, 9);
-       srnd1(p, up, -8);
-       srnd1(p, left, -1);
-       srnd1(p, right, 1);
-       srnd1(p, down, 8);
-       srnd1(p, 0, 0);
-}
-
-srnd1(p, m, o)
-int p, m, o;
-{
-
-       if((dir[p]&m) == 0)
-               control[p+o] =+ 10;
-}
diff --git a/usr/src/games/chess/stdin.c b/usr/src/games/chess/stdin.c
deleted file mode 100644 (file)
index a57df4d..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-#include "old.h"
-
-stdin()
-{
-       int piece1, piece2, side1, side2, rnk1, rnk2, file1, file2;
-       int ckf, c, m, *p1, *p2, to, amb, piece;
-
-       piece1 = piece2 = side1 = side2 = -1;
-       rnk1 = rnk2 = file1 = file2  = -1;
-       ckf = 0;
-       if(match("o-o-o")||match("ooo")) {
-               piece1 = 6;
-               file1 = 3;
-               side1 = 1;
-               file2 = 2;
-               side2 = 0;
-               goto search;
-       }
-       if(match("o-o")||match("oo")) {
-               piece1 = 6;
-               file1 = 3;
-               file2 = 1;
-               goto search;
-       }
-       stdpin(&piece1, &side1, &rnk1, &file1);
-       c = *sbufp++;
-       if(c=='*' || c=='x')
-               stdpin(&piece2, &side2, &rnk2, &file2); else
-       if(c == '-')
-               stdbin(&side2, &rnk2, &file2); else
-               sbufp--;
-
-search:
-       c = *sbufp++;
-       if(c == '+') {
-               ckf = 1;
-               c = *sbufp++;
-       }
-       if(c != '\0')
-               return(0);
-
-       p1 = p2 = lmp;
-       mantom? bagen(): wagen();
-       m = -1;
-       amb = 0;
-       while(p1 != lmp) {
-               p1++;
-               piece = board[*p1>>8];
-               mantom? bmove(*p1): wmove(*p1);
-               to = amp[-3];
-               if(pcomp(piece, amp[-4],
-                       piece1, side1, rnk1, file1))
-               if(pcomp(amp[-2], to,
-                       piece2, side2, rnk2, file2))
-               if(comp(ckf, check())) {
-                       if(m >= 0) {
-                               if(!amb) {
-                                       printf("ambiguous\n");
-                                       amb = 1;
-                               }
-                       }
-                       m = *p1;
-               }
-               p1++;
-               mantom? bremove(): wremove();
-       }
-       lmp = p2;
-       if(amb) return(-1);
-       return(m);
-}
-
-stdpin(ap, as, ar, af)
-int *ap, *as, *ar, *af;
-{
-       int c;
-
-       c = *sbufp++;
-       if(c == 'q') {
-               *as = 0;
-               stdpin(ap, as, ar, af);
-               return;
-       }
-       if(c == 'k') {
-               *as = 1;
-               stdpin(ap, as, ar, af);
-               return;
-       }
-       if(c == 'p') {
-               *ap = 1;
-               if(*as >= 0)
-                       *af = 3;
-               goto loc;
-       }
-       if(c == 'n') {
-               *ap = 2;
-               goto pie;
-       }
-       if(c == 'b') {
-               *ap = 3;
-               goto pie;
-       }
-       if(c == 'r') {
-               *ap = 4;
-               goto pie;
-       }
-       sbufp--;
-       goto loc;
-
-pie:
-       if(*sbufp == 'p') {
-               *af = (*ap-1)%3;
-               *ap = 1;
-               sbufp++;
-       }
-
-loc:
-       if(*ap<0 && *as>=0) {
-               *ap = *as+5;
-               *as = -1;
-       }
-       if(*sbufp == '/') {
-               sbufp++;
-               stdbin(as, ar, af);
-       }
-}
-
-stdbin(as, ar, af)
-int *as, *ar, *af;
-{
-       int c;
-
-loop:
-       c = *sbufp++;
-       if(c == 'q') {
-               *as = 0;
-               goto kq;
-       }
-       if(c == 'k') {
-               *as = 1;
-       kq:
-               stdbin(as, ar, af);
-               if(*af < 0)
-                       *af = 3;
-               return;
-       }
-
-       if(c == 'r') {
-               *af = 0;
-               goto loop;
-       }
-       if(c == 'n') {
-               *af = 1;
-               goto loop;
-       }
-       if(c == 'b') {
-               *af = 2;
-               goto loop;
-       }
-       if(c>'0' && c<'9')
-               *ar = c-'1'; else
-               sbufp--;
-}
-
-pcomp(p, l, pp, sp, rp, fp)
-int p, l, pp, sp, rp, fp;
-{
-       int r, f, s;
-
-       f = l%8;
-       r = l/8;
-       if(!mantom)
-               r = 7-r;
-       if(f > 3) {
-               f = 7-f;
-               s = 1;
-       } else
-               s = 0;
-
-       if(comp(pp, p))
-       if(comp(sp, s))
-       if(comp(rp, r))
-       if(comp(fp, f))
-               return(1);
-       return(0);
-}
-
-comp(p, v)
-int p, v;
-{
-
-       if(p < 0) return(1);
-       return(p == abs(v));
-}
-
-abs(x)
-int x;
-{
-
-       if(x < 0)
-               return(-x);
-       return(x);
-}
diff --git a/usr/src/games/chess/wgen.s b/usr/src/games/chess/wgen.s
deleted file mode 100644 (file)
index 461a376..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/ generate moves
-
-.globl _wgen
-
-.globl _pval, _board, _dir
-.globl _flag, _lmp, _wkpos
-.globl _eppos
-.globl _value
-
-uleft  = 04040
-uright = 04004
-dleft  = 00440
-dright = 00404
-left   = 00040
-right  = 00004
-up     = 04000
-down   = 00400
-u2r1   = 06004
-u1r2   = 04006
-d1r2   = 00406
-d2r1   = 00604
-d2l1   = 00640
-d1l2   = 00460
-u1l2   = 04060
-u2l1   = 06040
-rank2  = 00200
-rank7  = 02000
-
-_wgen:
-       mov     $_dir+126.,r4
-       mov     $_board+126.,r3
-       mov     _lmp,r2
-       mov     $63.,r1
-0:
-       mov     (r3),r0
-       bge     1f
-       asl     r0
-       jmp     *2f(r0)
-
-       king
-       queen
-       rook
-       bishop
-       knight
-       pawn
-2:
-
-pawn:
-       bit     $uleft,(r4)
-       bne     2f
-       tst     -2*9.(r3)
-       ble     3f
-       jsr     r5,wtry; 0; -9.*2
-3:
-       mov     r1,r0
-       sub     $9,r0
-       cmp     r0,_eppos
-       bne     2f
-       jsr     r5,wtry; 0; -1*2
-2:
-       bit     $uright,(r4)
-       bne     2f
-       tst     -7.*2(r3)
-       ble     3f
-       jsr     r5,wtry; 0; -7.*2
-3:
-       mov     r1,r0
-       sub     $7,r0
-       cmp     r0,_eppos
-       bne     2f
-       jsr     r5,wtry; 0; 2*1
-2:
-       tst     -2*8.(r3)
-       bne     1f
-       jsr     r5,wtry; 0; -2*8.
-       bit     $rank2,(r4)
-       beq     1f
-       tst     -2*16.(r3)
-       bne     1f
-       jsr     r5,wtry; 0; -16.*2
-       br      1f
-
-knight:
-       jsr     r5,wtry; u2r1; -15.*2
-       jsr     r5,wtry; u1r2; -6.*2
-       jsr     r5,wtry; d1r2; 10.*2
-       jsr     r5,wtry; d2r1; 17.*2
-       jsr     r5,wtry; d2l1; 15.*2
-       jsr     r5,wtry; d1l2; 6.*2
-       jsr     r5,wtry; u1l2; -10.*2
-       jsr     r5,wtry; u2l1; -17.*2
-       br      1f
-
-
-1:
-       cmp     -(r4),-(r3)
-       dec     r1
-       bpl     0b
-       mov     r2,_lmp
-       rts     pc
-
-bishop:
-       jsr     r5,wslide; uleft; -9.*2
-       jsr     r5,wslide; uright; -7.*2
-       jsr     r5,wslide; dleft; 7.*2
-       jsr     r5,wslide; dright; 9.*2
-       br      1b
-
-rook:
-       jsr     r5,wslide; up; -8.*2
-       jsr     r5,wslide; down; 8.*2
-       jsr     r5,wslide; left; -1.*2.
-       jsr     r5,wslide; right; 1.*2
-       br      1b
-queen:
-       jsr     r5,wslide; uleft; -9.*2
-       jsr     r5,wslide; uright; -7.*2
-       jsr     r5,wslide; dleft; 7.*2
-       jsr     r5,wslide; dright; 9.*2
-       jsr     r5,wslide; up; -8.*2
-       jsr     r5,wslide; left; -1.*2
-       jsr     r5,wslide; right; 1.*2
-       jsr     r5,wslide; down; 8.*2
-       br      1b
-
-king:
-       jsr     r5,wtry; uleft; -9.*2
-       jsr     r5,wtry; uright; -7.*2
-       jsr     r5,wtry; dleft; 7.*2
-       jsr     r5,wtry; dright; 9.*2
-       jsr     r5,wtry; up; -8.*2
-       jsr     r5,wtry; left; -1.*2
-       jsr     r5,wtry; right; 1.*2
-       jsr     r5,wtry; down; 8.*2
-       br      1b
-
-wtry:
-       bit     (r5)+,(r4)
-       bne     1f
-       mov     r3,r0
-       add     (r5),r0
-       mov     (r0),r0
-       blt     1f
-       asl     r0
-       mov     _value,(r2)
-       sub     _pval+12.(r0),(r2)+
-       mov     (r5)+,r0
-       asr     r0
-       add     r1,r0
-       movb    r0,(r2)+
-       movb    r1,(r2)+
-       rts     r5
-1:
-       tst     (r5)+
-       rts     r5
-
-wslide:
-       mov     r4,-(sp)
-       mov     r3,-(sp)
-1:
-       bit     (r5)+,(r4)
-       bne     1f
-       add     (r5),r3
-       add     (r5),r4
-       mov     (r3),r0
-       blt     1f
-       bgt     2f
-       mov     _value,(r2)+
-       mov     r3,r0
-       sub     $_board,r0
-       asr     r0
-       movb    r0,(r2)+
-       movb    r1,(r2)+
-       tst     -(r5)
-       br      1b
-2:
-       asl     r0
-       mov     _value,(r2)
-       sub     _pval+12.(r0),(r2)+
-       mov     r3,r0
-       sub     $_board,r0
-       asr     r0
-       movb    r0,(r2)+
-       movb    r1,(r2)+
-1:
-       tst     (r5)+
-       mov     (sp)+,r3
-       mov     (sp)+,r4
-       rts     r5
diff --git a/usr/src/games/chess/wheur.c b/usr/src/games/chess/wheur.c
deleted file mode 100644 (file)
index 95fb643..0000000
+++ /dev/null
@@ -1,197 +0,0 @@
-#include "old.h"
-
-/*
- *     mobility
- *     1 for each potential move
- */
-
-wheur1()
-{
-       int *p1, *p2, *p3, i;
-       int pto;
-
-       if(amp[-2]) {
-               i = amp[-3];
-               pto = board[i];
-               board[i] = 0;
-       }
-       p1 = lmp;
-       wgen();
-       p2 = lmp;
-       lmp = p1;
-       bgen();
-       p3 = lmp;
-       lmp = p1;
-       i = p2-p3;
-       i =>> 1;
-       if(amp[-2])
-               board[amp[-3]] = pto;
-       return(i);
-}
-
-/*
- *     opening 'goodies'
- */
-
-wheur2()
-{
-       int i;
-
-       i = 0;
-       if(game > 2) return(i);
-       /*
-        * minor pieces out
-        * knights before bishops
-        */
-       i =+ 9*((board[57] != -2)+
-               (board[62] != -2));
-       i =+ 8*((board[58] != -3)+
-               (board[61] != -3));
-       /*
-        * blocked central pawns
-        */
-       if(board[51] == -1 && board[51-8]!=0) i =- 10;
-       if(board[52] == -1 && board[52-8]!=0) i =- 10;
-       return(i);
-}
-
-/*
- *     castle
- */
-
-wheur3()
-{
-       int i;
-
-       i = 0;
-       /*
-        * queenside ability
-        */
-       if(flag&02 && board[48]== -1 && board[49]== -1 && board[50]== -1)
-               i =+ 20;
-       /*
-        *  kingside ability
-        */
-       if(flag&01 && board[53]== -1 && board[54]== -1 && board[55]== -1)
-               i =+ 20;
-       /*
-        * if both
-        */
-       if(i == 40)
-               i = 22;
-       /*
-        * if castled,
-        * keep pawns in
-        */
-       if(wkpos==58)
-               if(board[50]== -1 && (board[48]== -1 || board[48-8]== -1) &&
-                       (board[49]== -1 || board[49-8]== -1))
-                               i =+ 40;
-       if(wkpos==62)
-               if(board[53]== -1 && (board[54]== -1 || board[54-8]== -1) &&
-                       (board[55]== -1 || board[55-8]== -1))
-                               i =+ 40;
-       return(i);
-}
-
-/*
- *     prance
- *     a percentage if the
- *     piece on the move
- *     can be driven back
- *     by a smaller piece
- */
-
-wheur4()
-{
-       int *p1, *p2, ploc, i;
-
-       if(amp[-1] != 1) return(0);
-       ploc = amp[-3];
-       if(board[ploc] == -1) return(0);
-       if(xheur(ploc)) return(0);
-       p1 = lmp;
-       p2 = p1;
-       bagen();
-       i = 0;
-       while(p2 != lmp) {
-               p2++;
-               bmove(*p2++);
-               i = xheur(ploc);
-               bremove();
-               if(i)
-                       break;
-       }
-       lmp = p1;
-       return(i);
-}
-
-/*
- *     control
- *     center control
- *             opening
- *             beginning
- *     king control
- *             middle
- *             end
- */
-
-wheur5()
-{
-       int i, j, k;
-       int s, n, d, pto;
-
-       if(amp[-2]) {
-               i = amp[-3];
-               pto = board[i];
-               board[i] = 0;
-       }
-       i = 64;
-       while(i--)
-               control[i] = 0;
-       if(game < 2) {
-               i = 64;
-               while(i--)
-                       control[i] =+ center[i];
-       }
-       if(mantom) {
-               if((flag&03)==0)
-                       srnd(wkpos);
-       } else {
-               if((flag&030)==0)
-                       srnd(bkpos);
-       }
-       i = 64;
-       s = 0;
-       while(i--) {
-               n = control[i]*100;
-               attack(i);
-               j = 0;
-               while(k = attacv[j++]) {
-                       d = (pval+6)[k];
-                       if(d < 0)
-                               s =- n/(-d); else
-                               s =+ n/d;
-               }
-       }
-       if(amp[-2])
-               board[amp[-3]] = pto;
-       return(-s);
-}
-
-/*
- * mate threat
- * minus for captures
- */
-wheur6()
-{
-       int i;
-
-       i = 0;
-       *amp++ = -1;
-       if(wattack(bkpos))
-               if(mate(2, 0))
-                       i =+ 15;
-       amp--;
-       return(i);
-}
diff --git a/usr/src/games/chess/wmove.s b/usr/src/games/chess/wmove.s
deleted file mode 100644 (file)
index 2b47dd0..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
-.globl _wmove, _wremove
-.globl _board, _pval, _amp, _flag, _eppos, _value, _wkpos
-.globl _game
-
-_wmove:
-       mov     _amp,r4
-       movb    2(sp),r3                / to
-       movb    3(sp),r2                / from
-       mov     _value,(r4)+
-       mov     _flag,(r4)+
-       mov     _eppos,(r4)+
-       mov     r2,(r4)+
-       mov     r3,(r4)+
-       asl     r2                      / from as a word index
-       asl     r3                      / to as word index
-       mov     _board(r3),r0
-       mov     r0,(r4)+
-       beq     1f
-       asl     r0
-       sub     _pval+12.(r0),_value
-1:
-       mov     _board(r2),r0
-       mov     r0,_board(r3)
-       clr     _board(r2)
-       mov     $-1,_eppos
-       asl     r0
-       bge     error
-       jmp     *0f(r0)         / type of man
-       kmove
-       qmove
-       rmove
-       bmove
-       nmove
-       pmove
-0:
-error:
-       3
-
-
-pmove:
-       sub     r3,r2
-       bge     1f
-       neg     r2
-1:
-       cmp     r2,$2*1                 / ep capture
-       bne     1f
-       clr     _board(r3)
-       mov     $-1,_board-16.(r3)
-       mov     $4,(r4)+
-       mov     r4,_amp
-       rts     pc
-1:
-       cmp     r2,$2*16.               / double move
-       bne     1f
-       movb    3(sp),r2
-       sub     $8,r2
-       mov     r2,_eppos
-       br      move
-1:
-       cmp     r3,$24.*2
-       bge     move
-       sub     $25.,_value
-       cmp     r3,$16.*2
-       bge     move
-       sub     $50.,_value
-       cmp     r3,$8.*2                / queen promotion
-       bge     move
-       sub     $625.,_value
-       mov     $-5,_board(r3)
-       mov     $5,(r4)+
-       mov     r4,_amp
-       rts     pc
-
-rmove:
-       cmp     r2,$2*63.
-       bne     1f
-       bic     $1,_flag
-       br      move
-1:
-       cmp     r2,$2*56.
-       bne     move
-       bic     $2,_flag
-       br      move
-
-kmove:
-       asr     r3
-       mov     r3,_wkpos
-       bic     $3,_flag
-       cmp     r2,$2*60.
-       bne     2f
-       cmp     r3,$62.                 / kingside castle
-       bne     1f
-       dec     _value
-       mov     $-4,_board+[2*61.]
-       clr     _board+[2*63.]
-       mov     $2,(r4)+
-       mov     r4,_amp
-       rts     pc
-1:
-       cmp     r3,$58.                 / queenside castle
-       bne     2f
-       dec     _value
-       mov     $-4,_board+[2*59.]
-       clr     _board+[2*56.]
-       mov     $3,(r4)+
-       mov     r4,_amp
-       rts     pc
-2:                                     / king move
-       tst     _game
-       bne     1f
-       add     $2,_value
-1:
-       clr     (r4)+
-       mov     r4,_amp
-       rts     pc
-
-qmove:
-       tst     _game
-       bne     move
-       inc     _value
-       br      move
-
-nmove:
-bmove:
-move:
-       mov     $1,(r4)+
-       mov     r4,_amp
-       rts     pc
-
-_wremove:
-       mov     _amp,r4
-       mov     -(r4),r0
-       mov     -(r4),r1
-       mov     -(r4),r3
-       mov     -(r4),r2
-       mov     -(r4),_eppos
-       mov     -(r4),_flag
-       mov     -(r4),_value
-       mov     r4,_amp
-       asl     r2
-       asl     r3
-       mov     _board(r3),_board(r2)
-       mov     r1,_board(r3)
-       asl     r0
-       jmp     *0f(r0)
-0:
-       movek
-       movex
-       moveo
-       moveoo
-       movep
-       moveq
-
-movek:
-       asr     r2
-       mov     r2,_wkpos
-
-movex:
-       rts     pc
-
-moveo:
-       mov     $-4,_board+[2*63.]
-       clr     _board+[2*61.]
-       mov     $60.,_wkpos
-       rts     pc
-
-moveoo:
-       mov     $-4,_board+[2*56.]
-       clr     _board+[2*59.]
-       mov     $60.,_wkpos;
-       rts     pc
-
-movep:
-       mov     $-1,_board(r2)
-       clr     _board-[2*8.](r3)
-       rts     pc
-
-moveq:
-       mov     $-1,_board(r2)
-       rts     pc
diff --git a/usr/src/games/chess/wplay.c b/usr/src/games/chess/wplay.c
deleted file mode 100644 (file)
index fce525a..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-#include "old.h"
-
-wplay()
-{
-       int v1, v2, *p1, *p2, *p3, ab;
-
-       if(value < ivalue)
-               ivalue = value;
-       ab = 0;
-       v1 = 3000;
-       ply = 0;
-       p1 = statl();
-       if(lmp == p1+2) {
-               abmove = p1[1];
-               lmp = p1;
-               return(ivalue);
-       }
-       p2 = p1;
-       mantom = !mantom;
-       while(p2 != lmp) {
-               p2++;
-               wmove(*p2);
-               if(testf) {
-                       mantom = !mantom;
-                       wstatic(1);
-                       mantom = !mantom;
-               }
-               if(rept())
-                       v2 = 0; else
-                       v2 = bplay1(v1);
-               if(v2 < v1 && !mate(3, 0)) {
-                       ab = *p2;
-                       v1 = v2;
-               }
-               wremove();
-               if(testf) {
-                       mantom = !mantom;
-                       printf("%6d ", v2);
-                       out(*p2);
-                       printf("\n");
-                       mantom = !mantom;
-               }
-               p2++;
-       }
-       if(ab == 0 && lmp != p1)
-               ab = p1[1];
-       mantom = !mantom;
-       lmp = p1;
-       abmove = ab;
-       return(v1);
-}
-
-wplay1(ab)
-int ab;
-{
-       int v1, v2, *p1, *p2;
-
-       if(ply >= depth)
-               return(wquies(ab));
-       ply++;
-       p1 = p2 = lmp;
-       wgen();
-       qsort(p1, lmp);
-       v1 = 3000;
-       while(p2 != lmp) {
-               if(intrp)
-                       goto out;
-               p2++;
-               wmove(*p2);
-               if(battack(wkpos)) {
-                       v2 = bplay1(v1);
-                       if(v2 < v1)
-                               v1 = v2;
-               }
-               wremove();
-               if(v1 <= ab)
-                       goto out;
-               p2++;
-       }
-out:
-       ply--;
-       lmp = p1;
-       if(v1 == 3000) {
-               v1--;
-               if(!check())
-                       v1 = 0;
-       }
-       return(v1);
-}
-
-wquies(ab)
-int ab;
-{
-       int *p1, *p2, *p3, v1, v2;
-
-       if(ply >= qdepth)
-               return(ivalue);
-       p1 = p2 = p3 = lmp;
-       wgen();
-       while(p2 != lmp) {
-               v1 = *p2++;
-               if(v1 != value && v1 <= ivalue+50) {
-                       *p3++ = (((pval+6)[board[*p2>>8]]/100)<<8) |
-                               (-(pval+6)[board[*p2&0377]]/100);
-                       *p3++ = *p2;
-               }
-               p2++;
-       }
-       if(p3 == p1) {
-               lmp = p1;
-               return(value);
-       }
-       ply++;
-       qsort(p1, p3);
-       lmp = p3;
-       p2 = p1;
-       v1 = value;
-       while(p2 != lmp) {
-               p2++;
-               wmove(*p2);
-               if(battack(wkpos)) {
-                       v2 = bquies(v1);
-               } else
-                       v2 = 3000;
-               if(v2 < v1)
-                       v1 = v2;
-               wremove();
-               if(v1 <= ab)
-                       goto out;
-               p2++;
-       }
-out:
-       ply--;
-       lmp = p1;
-       return(v1);
-}
diff --git a/usr/src/games/fish.c b/usr/src/games/fish.c
deleted file mode 100644 (file)
index 02ed4ba..0000000
+++ /dev/null
@@ -1,498 +0,0 @@
-# include <stdio.h>
-
-/*     Through, `my' refers to the program, `your' to the player */
-
-# define CTYPE 13
-# define CTSIZ (CTYPE+1)
-# define DECK 52
-# define NOMORE 0
-# define DOUBTIT (-1);
-
-typedef char HAND[CTSIZ];
-
-/* data structures */
-
-short debug;
-
-HAND myhand;
-HAND yourhand;
-char deck[DECK];
-short nextcd;
-int proflag;
-
-/* utility and output programs */
-
-shuffle(){
-       /* shuffle the deck, and reset nextcd */
-       /* uses the random number generator `rand' in the C library */
-       /* assumes that `srand' has already been called */
-
-       register i;
-
-       for( i=0; i<DECK; ++i ) deck[i] = (i%13)+1;  /* seed the deck */
-
-       for( i=DECK; i>0; --i ){ /* select the next card at random */
-               deck[i-1] = choose( deck, i );
-               }
-
-       nextcd = 0;
-       }
-
-choose( a, n ) char a[]; {
-       /* pick and return one at random from the n choices in a */
-       /* The last one is moved to replace the one chosen */
-       register j, t;
-
-       if( n <= 0 ) error( "null choice" );
-
-       j = rand() % n;
-       t = a[j];
-       a[j] = a[n-1];
-       return(t);
-       }
-
-draw() {
-       if( nextcd >= DECK ) return( NOMORE );
-       return( deck[nextcd++] );
-       }
-
-error( s ) char *s; {
-       fprintf( stderr, "error: " );
-       fprintf( stderr, s );
-       exit( 1 );
-       }
-
-empty( h ) HAND h; {
-       register i;
-
-       for( i=1; i<=CTYPE; ++i ){
-               if( h[i] != 0 && h[i] != 4 ) return( 0 );
-               }
-       return( i );
-       }
-
-mark( cd, hand ) HAND hand; {
-       if( cd != NOMORE ){
-               ++hand[cd];
-               if( hand[cd] > 4 ){
-                       error( "mark overflow" );
-                       }
-               }
-       return( cd );
-       }
-
-deal( hand, n ) HAND hand; {
-       while( n-- ){
-               if( mark( hand, draw() ) == NOMORE ) error( "deck exhausted" );
-               }
-       }
-
-char *cname[] {
-       "NOMORE!!!",
-       "A",
-       "2",
-       "3",
-       "4",
-       "5",
-       "6",
-       "7",
-       "8",
-       "9",
-       "10",
-       "J",
-       "Q",
-       "K",
-       };
-
-stats(){
-       register i, ct, b;
-
-       if( proflag ) printf( "Pro level\n" );
-       b = ct = 0;
-
-       for( i=1; i<=CTYPE; ++i ){
-               if( myhand[i] == 4 ) ++b;
-               else ct += myhand[i];
-               }
-
-       if( b ){
-               printf( "My books: " );
-               for( i=1; i<=CTYPE; ++i ){
-                       if( myhand[i] == 4 ) printf( "%s ", cname[i] );
-                       }
-               printf( "\n" );
-               }
-
-       printf( "%d cards in my hand, %d in the pool\n", ct, DECK-nextcd );
-       printf( "You ask me for: " );
-       }
-
-phand( h ) HAND h; {
-       register i, j;
-
-       j = 0;
-
-       for( i = 1; i<= CTYPE; ++i ){
-               if( h[i] == 4 ) {
-                       ++j;
-                       continue;
-                       }
-               if( h[i] ){
-                       register k;
-                       k = h[i];
-                       while( k-- ) printf( "%s ", cname[i] );
-                       }
-               }
-
-       if( j ){
-               printf( "+ Books of " );
-               for( i=1; i<=CTYPE; ++i ){
-                       if( h[i] == 4 ) printf( "%s ", cname[i] );
-                       }
-               }
-
-       printf( "\n" );
-       }
-
-main( argc, argv ) char * argv[]; { 
-       /* initialize shuffling, ask for instructions, play game, die */
-       register c;
-
-       if( argc > 1 && argv[1][0] == '-' ){
-               while( argv[1][0] == '-' ) { ++argv[1]; ++debug; }
-               argv++;
-               argc--;
-               }
-
-       srand( getpid() );
-
-       printf( "instructions?\n" );
-       if( (c=getchar()) != '\n' ){
-               if( c != 'n' ) instruct();
-               while( getchar() != '\n' );
-               }
-
-       game();
-       }
-
-/*     print instructions */
-
-char *inst[] {
-       "`Go Fish' is a childrens' card game.",
-       "The Object is to accumulate `books' of 4 cards",
-       "with the same face value.",
-       "The players alternate turns; each turn begins with one",
-       "player selecting a card from his hand, and asking the",
-       "other player for all cards of that face value.",
-       "If the other player has one or more cards of that face value",
-       "in his hand, he gives them to the first player, and the",
-       "first player makes another request.",
-       "Eventually, the first player asks for a card which",
-       "is not in the second player's hand: he replies `GO FISH!'",
-       "The first player then draws a card from the `pool' of",
-       "undealt cards.  If this is the card he had last requested, he",
-       "draws again.",
-       "When a book is made, either through drawing or requesting,",
-       "the cards are laid down and no further action takes",
-       "place with that face value.",
-       "To play the computer, simply make guesses by typing",
-       "a, 2, 3, 4, 5, 6, 7, 8, 9, 10, j, q, or k when asked.",
-       "Hitting return gives you information about the size of",
-       "my hand and the pool, and tells you about my books.",
-       "Saying `p' as a first guess puts you into `pro' level;",
-       "The default is pretty dumb!",
-       "Good Luck!",
-       "",
-       };
-
-instruct(){
-       register char **cpp;
-
-       printf( "\n" );
-
-       for( cpp = inst; **cpp != '\0'; ++cpp ){
-               printf( "%s\n", *cpp );
-               }
-       }
-
-game(){
-
-       shuffle();
-
-       deal( myhand, 7 );
-       deal( yourhand, 7 );
-
-       start( myhand );
-
-       for(;;){
-
-               register g;
-
-
-               /* you make repeated guesses */
-
-               for(;;) {
-                       printf( "your hand is: " );
-                       phand( yourhand );
-                       printf( "you ask me for: " );
-                       if( !move( yourhand, myhand, g=guess(), 0 ) ) break;
-                       printf( "Guess again\n" );
-                       }
-
-               /* I make repeated guesses */
-
-               for(;;) {
-                       if( (g=myguess()) != NOMORE ){
-                               printf( "I ask you for: %s\n", cname[g] );
-                               }
-                       if( !move( myhand, yourhand, g, 1 ) ) break;
-                       printf( "I get another guess\n" );
-                       }
-               }
-       }
-
-/*     reflect the effect of a move on the hands */
-
-move( hs, ht, g, v ) HAND hs, ht; {
-       /* hand hs has made a guess, g, directed towards ht */
-       /* v on indicates that the guess was made by the machine */
-       register d;
-       char *sp, *tp;
-
-       sp = tp = "I";
-       if( v ) tp = "You";
-       else sp = "You";
-
-       if( g == NOMORE ){
-               d = draw();
-               if( d == NOMORE ) score();
-               else {
-
-                       printf( "Empty Hand\n" );
-                       if( !v ) printf( "You draw %s\n", cname[d] );
-                       mark( hs, d );
-                       }
-               return( 0 );
-               }
-
-       if( !v ) heguessed( g );
-
-       if( hs[g] == 0 ){
-               if( v ) error( "Rotten Guess" );
-               printf( "You don't have any %s's\n", cname[g] );
-               return(1);
-               }
-
-       if( ht[g] ){ /* successful guess */
-               printf( "%s have %d %s%s\n", tp, ht[g], cname[g], ht[g]>1?"'s":"" );
-               hs[g] += ht[g];
-               ht[g] = 0;
-               if( hs[g] == 4 ) madebook(g);
-               return(1);
-               }
-
-       /* GO FISH! */
-
-       printf( "%s say \"GO FISH!\"\n", tp );
-
-       newdraw:
-       d = draw();
-       if( d == NOMORE ) {
-               printf( "No more cards\n" );
-               return(0);
-               }
-       mark( hs, d );
-       if( !v ) printf( "You draw %s\n", cname[d] );
-       if( hs[d] == 4 ) madebook(d);
-       if( d == g ){
-               printf( "%s drew the guess, so draw again\n", sp );
-               if( !v ) hedrew( d );
-               goto newdraw;
-               }
-       return( 0 );
-       }
-
-madebook( x ){
-       printf( "Made a book of %s's\n", cname[x] );
-       }
-
-score(){
-       register my, your, i;
-
-       my = your = 0;
-
-       printf( "The game is over.\nMy books: " );
-
-       for( i=1; i<=CTYPE;++i ){
-               if( myhand[i] == 4 ){
-                       ++my;
-                       printf( "%s ", cname[i] );
-                       }
-               }
-
-       printf( "\nYour books: " );
-
-       for( i=1; i<=CTYPE;++i ){
-               if( yourhand[i] == 4 ){
-                       ++your;
-                       printf( "%s ", cname[i] );
-                       }
-               }
-
-       printf( "\n\nI have %d, you have %d\n", my, your );
-
-       printf( "\n%s win!!!\n", my>your?"I":"You" );
-       exit(0);
-       }
-
-# define G(x) { if(go) goto err;  else go = x; }
-
-guess(){
-       /* get the guess from the tty and return it... */
-       register g, go;
-
-       go = 0;
-
-       for(;;) {
-               switch( g = getchar() ){
-
-               case 'p':
-               case 'P':
-                       ++proflag;
-                       continue;
-
-               case '2':
-               case '3':
-               case '4':
-               case '5':
-               case '6':
-               case '7':
-               case '8':
-               case '9':
-                       G(g-'0');
-                       continue;
-
-               case 'a':
-               case 'A':
-                       G(1);
-                       continue;
-
-               case '1':
-                       G(10);
-                       continue;
-
-               case '0':
-                       if( go != 10 ) goto err;
-                       continue;
-
-               case 'J':
-               case 'j':
-                       G(11);
-                       continue;
-
-               case 'Q':
-               case 'q':
-                       G(12);
-                       continue;
-
-               case 'K':
-               case 'k':
-                       G(13);
-                       continue;
-
-               case '\n':
-                       if( empty( yourhand ) ) return( NOMORE );
-                       if( go == 0 ){
-                               stats();
-                               continue;
-                               }
-                       return( go );
-
-               case ' ':
-               case '\t':
-                       continue;
-
-               default:
-                       err:
-                       while( g != '\n' ) g = getchar();
-                       printf( "what?\n" );
-                       continue;
-                       }
-               }
-       }
-
-/*     the program's strategy appears from here to the end */
-
-char try[100];
-char ntry;
-char haveguessed[CTSIZ];
-
-char hehas[CTSIZ];
-
-start( h ) HAND h; {
-       ;
-       }
-
-hedrew( d ){
-       ++hehas[d];
-       }
-
-heguessed( d ){
-       ++hehas[d];
-       }
-
-myguess(){
-
-       register i, lg, t;
-
-       if( empty( myhand ) ) return( NOMORE );
-
-       /* make a list of those things which i have */
-       /* leave off any which are books */
-       /* if something is found that he has, guess it! */
-
-       ntry = 0;
-       for( i=1; i<=CTYPE; ++i ){
-               if( myhand[i] == 0 || myhand[i] == 4 ) continue;
-               try[ntry++] = i;
-               }
-
-       if( !proflag ) goto random;
-
-       /* get ones he has, if any */
-
-       for( i=0; i<ntry; ++i ){
-               if( hehas[try[i]] ) {
-                       i = try[i];
-                       goto gotguess;
-                       }
-               }
-
-       /* is there one that has never been guessed; if so, guess it */
-       lg = 101;
-       for( i=0; i<ntry; ++i ){
-               if( haveguessed[try[i]] < lg ) lg = haveguessed[try[i]];
-               }
-       /* remove all those not guessed longest ago */
-
-       t = 0;
-       for( i=0; i<ntry; ++i ){
-               if( haveguessed[try[i]] == lg ) try[t++] = try[i];
-               }
-       ntry = t;
-       if( t <= 0 ) error( "bad guessing loop" );
-
-       random:
-       i = choose( try, ntry );  /* make a random choice */
-
-       gotguess:  /* do bookkeeping */
-
-       hehas[i] = 0;  /* he won't anymore! */
-       for( t=1; t<=CTYPE; ++t ){
-               if( haveguessed[t] ) --haveguessed[t];
-               }
-       haveguessed[i] = 100;  /* will have guessed it */
-       return(i);
-
-       }
-
index 0e1669e..cdd3d48 100644 (file)
@@ -22,7 +22,7 @@ main()
                l = fgets(line, 500, f);
                if(l == NULL)
                        break;
                l = fgets(line, 500, f);
                if(l == NULL)
                        break;
-               if(rand() < 32768./p)
+               if(rand() < 2147483648./p)
                        strcpy(bline, line);
                p += 1.;
        }
                        strcpy(bline, line);
                p += 1.;
        }
diff --git a/usr/src/games/hangman.c b/usr/src/games/hangman.c
deleted file mode 100644 (file)
index f069bbb..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#define DICT "/usr/dict/words"
-#define EDICT "/crp/dict/web2"
-#define MAXERR 7
-#define MINSCORE 0
-#define MINLEN 7
-char *dictfile;
-int alive,lost;
-FILE *dict;
-long int dictlen;
-float errors=0, words=0;
-main(argc,argv) char **argv;
-{
-       if(argc==1) dictfile=DICT;
-       else if(*argv[1]=='-') dictfile=EDICT;
-       else dictfile=argv[1];
-       setup();
-       for(;;)
-       {       startnew();
-               while(alive>0)
-               {       stateout();
-                       getguess();
-               }
-               words=words+1;
-               if(lost) wordout();
-               else youwon();
-       }
-}
-setup()
-{      int tvec[2];
-       struct stat statb;
-       time(tvec);
-       srand(tvec[1]+tvec[2]);
-       if((dict=fopen(dictfile,"r"))==NULL) fatal("no dictionary");
-       if(stat(dictfile,&statb)<0) fatal("can't stat");
-       dictlen=statb.st_size;
-}
-double frand()
-{
-       return(rand()/32768.);
-}
-char word[26],alph[26],realword[26];
-startnew()
-{      int i;
-       long int pos;
-       char buf[128];
-       for(i=0;i<26;i++) word[i]=alph[i]=realword[i]=0;
-       pos=frand()*dictlen;
-       fseek(dict,pos,0);
-       fscanf(dict,"%s\n",buf);
-       getword();
-       alive=MAXERR;
-       lost=0;
-}
-stateout()
-{      int i;
-       printf("guesses: ");
-       for(i=0;i<26;i++)
-               if(alph[i]!=0) putchar(alph[i]);
-       printf(" word: %s ",word);
-       printf("errors: %d/%d\n",MAXERR-alive,MAXERR);
-}
-getguess()
-{      char gbuf[128],c;
-       int ok=0,i;
-loop:
-       printf("guess: ");
-       if(gets(gbuf)==NULL)
-       {       putchar('\n');
-               exit(0);
-       }
-       if((c=gbuf[0])<'a' || c>'z')
-       {       printf("lower case\n");
-               goto loop;
-       }
-       if(alph[c-'a']!=0)
-       {       printf("you guessed that\n");
-               goto loop;
-       }
-       else alph[c-'a']=c;
-       for(i=0;realword[i]!=0;i++)
-               if(realword[i]==c)
-               {       word[i]=c;
-                       ok=1;
-               }
-       if(ok==0)
-       {       alive--;
-               errors=errors+1;
-               if(alive<=0) lost=1;
-               return;
-       }
-       for(i=0;word[i]!=0;i++)
-               if(word[i]=='.') return;
-       alive=0;
-       lost=0;
-       return;
-}
-wordout()
-{
-       errors=errors+2;
-       printf("the answer was %s, you blew it\n",realword);
-}
-youwon()
-{
-       printf("you win, the word is %s\n",realword);
-}
-fatal(s) char *s;
-{
-       fprintf(stderr,"%s\n",s);
-       exit(1);
-}
-getword()
-{      char wbuf[128],c;
-       int i,j;
-loop:
-       if(fscanf(dict,"%s\n",wbuf)==EOF)
-       {       fseek(dict,0L,0);
-               goto loop;
-       }
-       if((c=wbuf[0])>'z' || c<'a') goto loop;
-       for(i=j=0;wbuf[j]!=0;i++,j++)
-       {       if(wbuf[j]=='-') j++;
-               wbuf[i]=wbuf[j];
-       }
-       wbuf[i]=0;
-       if(i<MINLEN) goto loop;
-       for(j=0;j<i;j++)
-               if((c=wbuf[j])<'a' || c>'z') goto loop;
-       pscore();
-       strcpy(realword,wbuf);
-       for(j=0;j<i;word[j++]='.');
-}
-long int freq[]
-{      42066,  9228,   24412,  14500,  55162,
-       6098,   11992,  12648,  48241,  639,
-       2944,   33351,  15545,  35618,  36211,
-       16033,  937,    36686,  34957,  37544,
-       17621,  5453,   3028,   1556,   12875,
-       1743
-};
-pscore()
-{
-       if(words!=0) printf("(%4.2f/%.0f) ",errors/words,words);
-}
diff --git a/usr/src/games/quiz.c b/usr/src/games/quiz.c
deleted file mode 100644 (file)
index 606d10a..0000000
+++ /dev/null
@@ -1,473 +0,0 @@
-#include <stdio.h>
-#include <signal.h>
-
-#define NF 10
-#define NL 300
-#define NC 200
-#define SL 100
-#define NA 10
-
-int tflag;
-int xx[NL];
-char score[NL];
-int rights;
-int wrongs;
-int guesses;
-FILE *input;
-int nl = 0;
-int na = NA;
-int inc;
-int ptr  = 0;
-int nc = 0;
-char line[150];
-char response[100];
-char *tmp[NF];
-int select[NF];
-char   *malloc();
-
-readline()
-{
-       char *t;
-       register c;
-loop:
-       for (t=line; c=getc(input), *t=c, c!=EOF; t++) {
-               nc++;
-               if(*t==' '&&(t==line||t[-1]==' '))
-                       t--;
-               if(*t=='\n') {
-                       if(t[-1]=='\\')         /*inexact test*/
-                               continue;
-                       while(t>line&&t[-1]==' ')
-                               *--t = '\n';
-                       *++t = 0;
-                       return(1);
-               }
-               if(t-line>=NC) {
-                       printf("Too hard for me\n");
-                       do {
-                               *line = getc(input);
-                               if(*line==0377)
-                                       return(0);
-                       } while(*line!='\n');
-                       goto loop;
-               }
-       }
-       return(0);
-}
-
-char *eu;
-char *ev;
-cmp(u,v)
-char *u, *v;
-{
-       int x;
-       eu = u;
-       ev = v;
-       x = disj(1);
-       if(x!=1)
-               return(x);
-       return(eat(1,0));
-}
-
-disj(s)
-{
-       int t, x;
-       char *u;
-       u = eu;
-       t = 0;
-       for(;;) {
-               x = string(s);
-               if(x>1)
-                       return(x);
-               switch(*ev) {
-               case 0:
-               case ']':
-               case '}':
-                       return(t|x&s);
-               case '|':
-                       ev++;
-                       t |= s;
-                       s = 0;
-                       continue;
-               }
-               if(s) eu = u;
-               if(string(0)>1)
-                       return(2);
-               switch(*ev) {
-               case 0:
-               case ']':
-                       return(0);
-               case '}':
-                       return(1);
-               case '|':
-                       ev++;
-                       continue;
-               default:
-                       return(2);
-               }
-       }
-}
-
-string(s)
-{
-       int x;
-       for(;;) {
-               switch(*ev) {
-               case 0:
-               case '|':
-               case ']':
-               case '}':
-                       return(1);
-               case '\\':
-                       ev++;
-                       if(*ev==0)
-                               return(2);
-                       if(*ev=='\n') {
-                               ev++;
-                               continue;
-                       }
-               default:
-                       if(eat(s,*ev)==1)
-                               continue;
-                       return(0);
-               case '[':
-                       ev++;
-                       x = disj(s);
-                       if(*ev!=']' || x>1)
-                               return(2);
-                       ev++;
-                       if(s==0)
-                               continue;
-                       if(x==0)
-                               return(0);
-                       continue;
-               case '{':
-                       ev++;
-                       x = disj(s);
-                       if(*ev!='}'||x>1)
-                               return(2);
-                       ev++;
-                       continue;
-               }
-       }
-}
-
-eat(s,c)
-char c;
-{
-       if(*ev!=c)
-               return(2);
-       if(s==0) {
-               ev++;
-               return(1);
-       }
-       if(fold(*eu)!=fold(c))
-               return(0);
-       eu++;
-       ev++;
-       return(1);
-}
-
-fold(c)
-char c;
-{
-       if(c<'A'||c>'Z')
-               return(c);
-       return(c|040);
-}
-
-publish(t)
-char *t;
-{
-       ev = t;
-       pub1(1);
-}
-
-pub1(s)
-{
-       for(;;ev++){
-               switch(*ev) {
-               case '|':
-                       s = 0;
-                       continue;
-               case ']':
-               case '}':
-               case 0:
-                       return;
-               case '[':
-               case '{':
-                       ev++;
-                       pub1(s);
-                       continue;
-               case '\\':
-                       if(*++ev=='\n')
-                               continue;
-               default:
-                       if(s)
-                               putchar(*ev);
-               }
-       }
-}
-
-segment(u,w)
-char *u, *w[];
-{
-       char *s;
-       int i;
-       char *t;
-       s = u;
-       for(i=0;i<NF;i++) {
-               u = s;
-               t = w[i];
-               while(*s!=':'&&*s!='\n'&&s-u<SL) {
-                       if(*s=='\\')  {
-                               if(s[1] == '\n') {
-                                       s += 2;
-                                       continue;
-                               }
-                               *t++ = *s++;
-                       }
-                       *t++ = *s++;
-               }
-
-               while(*s!=':'&&*s!='\n')
-                       s++;
-               *t = 0;
-               if(*s++=='\n') {
-                       return(i+1);
-               }
-       }
-       printf("Too many facts about one thing\n");
-       return(0);
-}
-
-perm(u,m,v,n,p)
-int p[];
-char *u[], *v[];
-{
-       int i, j;
-       int x;
-       for(i=0;i<m;i++) {
-               for(j=0;j<n;j++) {
-                       x = cmp(u[i],v[j]);
-                       if(x>1) badinfo();
-                       if(x==0)
-                               continue;
-                       p[i] = j;
-                       goto uloop;
-               }
-               return(0);
-uloop:         ;
-       }
-       return(1);
-}
-
-find(u,m)
-char *u[];
-{
-       int n;
-       while(readline()){
-               n = segment(line,tmp);
-               if(perm(u,m,tmp+1,n-1,select))
-                       return(1);
-       }
-       return(0);
-}
-
-readindex()
-{
-       xx[0] = nc = 0;
-       while(readline()) {
-               xx[++nl] = nc;
-               if(nl>=NL) {
-                       printf("I've forgotten some of it;\n");
-                       printf("I remember %d items.\n", nl);
-                       break;
-               }
-       }
-}
-
-talloc()
-{
-       int i;
-       for(i=0;i<NF;i++)
-               tmp[i] = malloc(SL);
-}
-
-main(argc,argv)
-char *argv[];
-{
-       register j;
-       int i;
-       int x;
-       int z;
-       char *info;
-       long tm;
-       extern done();
-       int count;
-       info = "/usr/games/quiz.k/index";
-       time(&tm);
-       inc = (int)tm&077774|01;
-loop:
-       if(argc>1&&*argv[1]=='-') {
-               switch(argv[1][1]) {
-               case 'i':
-                       if(argc>2) 
-                               info = argv[2];
-                       argc -= 2;
-                       argv += 2;
-                       goto loop;
-               case 't':
-                       tflag = 1;
-                       argc--;
-                       argv++;
-                       goto loop;
-               }
-       }
-       input = fopen(info,"r");
-       if(input==NULL) {
-               printf("No info\n");
-               exit(0);
-       }
-       talloc();
-       if(argc<=2)
-               instruct(info);
-       signal(SIGINT, done);
-       argv[argc] = 0;
-       if(find(&argv[1],argc-1)==0)
-               dunno();
-       fclose(input);
-       input = fopen(tmp[0],"r");
-       if(input==NULL)
-               dunno();
-       readindex();
-       if(!tflag || na>nl)
-               na = nl;
-       stdout->_flag |= _IONBF;
-       for(;;) {
-               i = next();
-               fseek(input,xx[i]+0L,0);
-               z = xx[i+1]-xx[i];
-               for(j=0;j<z;j++)
-                       line[j] = getc(input);
-               segment(line,tmp);
-               if(*tmp[select[0]] == '\0' || *tmp[select[1]] == '\0') {
-                       score[i] = 1;
-                       continue;
-               }
-               publish(tmp[select[0]]);
-               printf("\n");
-               for(count=0;;count++) {
-                       if(query(response)==0) {
-                               publish(tmp[select[1]]);
-                               printf("\n");
-                               if(count==0) wrongs++;
-                               score[i] = tflag?-1:1;
-                               break;
-                       }
-                       x = cmp(response,tmp[select[1]]);
-                       if(x>1) badinfo();
-                       if(x==1) {
-                               printf("Right!\n");
-                               if(count==0) rights++;
-                               if(++score[i]>=1 && na<nl)
-                                       na++;
-                               break;
-                       }
-                       printf("What?\n");
-                       if(count==0) wrongs++;
-                       score[i] = tflag?-1:1;
-               }
-               guesses += count;
-       }
-}
-
-query(r)
-char *r;
-{
-       char *t;
-       for(t=r;;t++) {
-               if(read(0,t,1)==0)
-                       done();
-               if(*t==' '&&(t==r||t[-1]==' '))
-                       t--;
-               if(*t=='\n') {
-                       while(t>r&&t[-1]==' ')
-                               *--t = '\n';
-                       break;
-               }
-       }
-       *t = 0;
-       return(t-r);
-}
-
-next()
-{
-       int flag;
-       inc = inc*3125&077777;
-       ptr = (inc>>2)%na;
-       flag = 0;
-       while(score[ptr]>0)
-               if(++ptr>=na) {
-                       ptr = 0;
-                       if(flag) done();
-                       flag = 1;
-               }
-       return(ptr);
-}
-
-done()
-{
-       printf("\nRights %d, wrongs %d, ", rights, wrongs);
-       if(guesses)
-               printf("extra guesses %d, ", guesses);
-       printf("score %d%%\n",100*rights/(rights+wrongs));
-       exit(0);
-}
-instruct(info)
-char *info;
-{
-       int i, n;
-       printf("Subjects:\n\n");
-       while(readline()) {
-               printf("-");
-               n = segment(line,tmp);
-               for(i=1;i<n;i++) {
-                       printf(" ");
-                       publish(tmp[i]);
-               }
-               printf("\n");
-       }
-       printf("\n");
-       input = fopen(info,"r");
-       if(input==NULL)
-               abort();
-       readline();
-       segment(line,tmp);
-       printf("For example,\n");
-       printf("    quiz ");
-       publish(tmp[1]);
-       printf(" ");
-       publish(tmp[2]);
-       printf("\nasks you a ");
-       publish(tmp[1]);
-       printf(" and you answer the ");
-       publish(tmp[2]);
-       printf("\n    quiz ");
-       publish(tmp[2]);
-       printf(" ");
-       publish(tmp[1]);
-       printf("\nworks the other way around\n");
-       printf("\nType empty line to get correct answer.\n");
-       exit(0);
-}
-
-badinfo(){
-       printf("Bad info %s\n",line);
-}
-
-dunno()
-{
-       printf("I don't know about that\n");
-       exit(0);
-}
diff --git a/usr/src/games/wump.c b/usr/src/games/wump.c
deleted file mode 100644 (file)
index 6db98bb..0000000
+++ /dev/null
@@ -1,375 +0,0 @@
-#
-
-/*
- *     wumpus
- *     stolen from PCC Vol 2 No 1
- */
-
-#define        NBAT    3
-#define        NROOM   20
-#define        NTUNN   3
-#define        NPIT    3
-
-struct room
-{
-       int     tunn[NTUNN];
-       int     flag;
-} room[NROOM];
-
-char   *intro[]
-{
-       "\n",
-       "Welcome to 'Hunt the Wumpus.'\n",
-       "\n",
-       "The Wumpus lives in a cave of %d rooms.\n",
-       "Each room has %d tunnels leading to other rooms.\n",
-       "\n",
-       "Hazards:\n",
-       "\n",
-       "Bottomless Pits - Some rooms have Bottomless Pits in them.\n",
-       "       If you go there, you fall into the pit and lose!\n",
-       "Super Bats - Some other rooms have super bats.\n",
-       "       If you go there, a bat will grab you and take you to\n",
-       "       somewhere else in the cave where you could\n",
-       "       fall into a pit or run into the . . .\n",
-       "\n",
-       "Wumpus:\n",
-       "\n",
-       "The Wumpus is not bothered by the hazards since\n",
-       "he has sucker feet and is too big for a bat to lift.\n",
-       "\n",
-       "Usually he is asleep.\n",
-       "Two things wake him up:\n",
-       "       your entering his room\n",
-       "       your shooting an arrow anywhere in the cave.\n",
-       "If the wumpus wakes, he either decides to move one room or\n",
-       "stay where he was.  But if he ends up where you are,\n",
-       "he eats you up and you lose!\n",
-       "\n",
-       "You:\n",
-       "\n",
-       "Each turn you may either move or shoot a crooked arrow.\n",
-       "\n",
-       "Moving - You can move to one of the adjoining rooms;\n",
-       "       that is, to one that has a tunnel connecting it with\n",
-       "       the room you are in.\n",
-       "\n",
-       "Shooting - You have 5 arrows.  You lose when you run out.\n",
-       "       Each arrow can go from 1 to 5 rooms.\n",
-       "       You aim by telling the computer\n",
-       "       The arrow's path is a list of room numbers\n",
-       "       telling the arrow which room to go to next.\n",
-       "       The list is terminated with a 0.\n",
-       "       The first room in the path must be connected to the\n",
-       "       room you are in.  Each succeeding room must be\n",
-       "       connected to the previous room.\n",
-       "       If there is no tunnel between two of the rooms\n",
-       "       in the arrow's path, the arrow chooses one of the\n",
-       "       three tunnels from the room it's in and goes its\n",
-       "       own way.\n",
-       "\n",
-       "       If the arrow hits the wumpus, you win!\n",
-       "       If the arrow hits you, you lose!\n",
-       "\n",
-       "Warnings:\n",
-       "\n",
-       "When you are one or two rooms away from the wumpus,\n",
-       "the computer says:\n",
-       "               'I smell a Wumpus'\n",
-       "When you are one room away from some other hazard, it says:\n",
-       "               Bat    - 'Bats nearby'\n",
-       "               Pit    - 'I feel a draft'\n",
-       "\n",
-       0,
-};
-
-#define        BAT     01
-#define        PIT     02
-#define        WUMP    04
-
-int    arrow;
-int    loc;
-int    wloc;
-int    tchar;
-
-main()
-{
-       register i, j;
-       register struct room *p;
-       int k, icomp();
-
-       printf("Instructions? (y-n) ");
-       if(rline() == 'y')
-               for(i=0; intro[i]; i++)
-                       printf(intro[i], i&1? NROOM: NTUNN);
-
-
-/*
- * initialize the room connections
- */
-
-init:
-       p = &room[0];
-       for(i=0; i<NROOM; i++) {
-               for(j=0; j<NTUNN; j++)
-                       p->tunn[j] = -1;
-               p++;
-       }
-       k = 0;
-       for(i=1; i<NROOM; ) {
-               j = rnum(NROOM);
-               p = &room[j];
-               if(j == k || p->tunn[0] >= 0 || p->tunn[1] >= 0)
-                       continue;
-               p->tunn[1] = k;
-               room[k].tunn[0] = j;
-               k = j;
-               i++;
-       }
-       p = &room[0];
-       for(i=0; i<NROOM; i++) {
-               for(j=0; j<NTUNN; j++) {
-                       if(p->tunn[j] < 0)
-                               p->tunn[j] = tunnel(i);
-                       if(p->tunn[j] == i)
-                               goto init;
-                       for(k=0; k<j; k++)
-                               if(p->tunn[j] == p->tunn[k])
-                                       goto init;
-               }
-               qsort(&p->tunn[0], NTUNN, 2, icomp);
-               p++;
-       }
-
-/*
- * put in player, wumpus,
- * pits and bats
- */
-
-setup:
-       arrow = 5;
-       p = &room[0];
-       for(i=0; i<NROOM; i++) {
-               p->flag = 0;
-               p++;
-       }
-       for(i=0; i<NPIT; ) {
-               p = &room[rnum(NROOM)];
-               if((p->flag&PIT) == 0) {
-                       p->flag =| PIT;
-                       i++;
-               }
-       }
-       for(i=0; i<NBAT; ) {
-               p = &room[rnum(NROOM)];
-               if((p->flag&(PIT|BAT)) == 0) {
-                       p->flag =| BAT;
-                       i++;
-               }
-       }
-       i = rnum(NROOM);
-       wloc = i;
-       room[i].flag =| WUMP;
-       for(;;) {
-               i = rnum(NROOM);
-               if((room[i].flag&(PIT|BAT|WUMP)) == 0) {
-                       loc = i;
-                       break;
-               }
-       }
-
-/*
- *     main loop of the game
- */
-
-loop:
-       printf("You are in room %d\n", loc+1);
-       p = &room[loc];
-       if(p->flag&PIT) {
-               printf("You fell into a pit\n");
-               goto done;
-       }
-       if(p->flag&WUMP) {
-               printf("You were eaten by the wumpus\n");
-               goto done;
-       }
-       if(p->flag&BAT) {
-               printf("Theres a bat in your room\n");
-               loc = rnum(NROOM);
-               goto loop;
-       }
-       for(i=0; i<NTUNN; i++)
-       if(near(&room[p->tunn[i]], WUMP))
-               goto nearwump;
-       if (near(p, WUMP)) {
-       nearwump:
-               printf("I smell a wumpus\n");
-       }
-       if (near(p, BAT))
-               printf("Bats nearby\n");
-       if (near(p, PIT))
-               printf("I feel a draft\n");
-       printf("There are tunnels to");
-       for(i=0; i<NTUNN; i++)
-               printf(" %d", p->tunn[i]+1);
-       printf("\n");
-
-again:
-       printf("Move or shoot (m-s) ");
-       switch(rline()) {
-       case 'm':
-               if(tchar == '\n')
-                       printf("which room? ");
-               i = rin()-1;
-               for(j=0; j<NTUNN; j++)
-                       if(i == p->tunn[j])
-                               goto groom;
-               printf("You hit the wall\n");
-               goto again;
-       groom:
-               loc = i;
-               if(i == wloc)
-                       goto mwump;
-               goto loop;
-
-       case 's':
-               if(tchar == '\n')
-                       printf("Give list of rooms terminated by 0\n");
-               for(i=0; i<5; i++) {
-                       j = rin()-1;
-                       if(j == -1)
-                               break;
-               ranarw:
-                       for(k=0; k<NTUNN; k++)
-                               if(j == p->tunn[k])
-                                       goto garow;
-                       j = rnum(NROOM);
-                       goto ranarw;
-               garow:
-                       p = &room[j];
-                       if(j == loc) {
-                               printf("You shot yourself\n");
-                               goto done;
-                       }
-                       if(p->flag&WUMP) {
-                               printf("You slew the wumpus\n");
-                               goto done;
-                       }
-               }
-               if(--arrow == 0) {
-                       printf("That was your last shot\n");
-                       goto done;
-               }
-               goto mwump;
-       }
-
-       goto again;
-
-mwump:
-       p = &room[wloc];
-       p->flag =& ~WUMP;
-       i = rnum(NTUNN+1);
-       if(i != NTUNN)
-               wloc = p->tunn[i];
-       room[wloc].flag =| WUMP;
-       goto loop;
-
-done:
-       printf("Another game? (y-n) ");
-       if(rline() == 'y') {
-               printf("Same room setup? (y-n) ");
-               if(rline() == 'y')
-                       goto setup;
-               goto init;
-       }
-}
-
-tunnel(i)
-{
-       register struct room *p;
-       register n, j;
-       int c;
-
-       c = 20;
-
-loop:
-       n = rnum(NROOM);
-       if(n == i)
-               if(--c > 0)
-                       goto loop;
-       p = &room[n];
-       for(j=0; j<NTUNN; j++)
-       if(p->tunn[j] == -1) {
-               p->tunn[j] = i;
-               return(n);
-       }
-       goto loop;
-}
-
-rline()
-{
-       register char c, r;
-
-       while((c=getchar()) == ' ');
-       r = c;
-       while(c != '\n' && c != ' ') {
-               if(c == '\0')
-                       exit();
-               c = getchar();
-       }
-       tchar = c;
-       return(r);
-}
-
-rnum(n)
-{
-       static first[2];
-
-       if(first[1] == 0) {
-               time(first);
-               srand((first[1]*first[0])^first[1]);
-       }
-       return((rand()/32768.0) * n);
-}
-
-rin()
-{
-       register n, c;
-
-       n = 0;
-       c = getchar();
-       while(c != '\n' && c != ' ') {
-               if(c<'0' || c>'9') {
-                       while(c != '\n') {
-                               if(c == 0)
-                                       exit();
-                               c = getchar();
-                       }
-                       return(0);
-               }
-               n = n*10 + c-'0';
-               c = getchar();
-       }
-       return(n);
-}
-
-near(ap, ahaz)
-struct room *ap;
-{
-       register struct room *p;
-       register haz, i;
-
-       p = ap;
-       haz = ahaz;
-       for(i=0; i<NTUNN; i++)
-       if(room[p->tunn[i]].flag & haz)
-               return (1);
-       return(0);
-}
-
-icomp(p1, p2)
-int *p1, *p2;
-{
-
-       return(*p1 - *p2);
-}
diff --git a/usr/src/libF77/compall b/usr/src/libF77/compall
deleted file mode 100755 (executable)
index dbf8456..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-cc -c -O [a-l]*.c
-cc -c -O [m-z]*.c
diff --git a/usr/src/libF77/d_erf.c b/usr/src/libF77/d_erf.c
new file mode 100644 (file)
index 0000000..97f8785
--- /dev/null
@@ -0,0 +1,6 @@
+double derf_(x)
+double *x;
+{
+double erf();
+return( erf(*x) );
+}
diff --git a/usr/src/libF77/d_erfc.c b/usr/src/libF77/d_erfc.c
new file mode 100644 (file)
index 0000000..6fae94c
--- /dev/null
@@ -0,0 +1,6 @@
+double derfc_(x)
+double *x;
+{
+double erfc();
+return( erfc(*x) );
+}
diff --git a/usr/src/libF77/erf.c b/usr/src/libF77/erf.c
new file mode 100644 (file)
index 0000000..b724b90
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+       C program for floating point error function
+
+       erf(x) returns the error function of its argument
+       erfc(x) returns 1.0-erf(x)
+
+       erf(x) is defined by
+       ${2 over sqrt(pi)} int from 0 to x e sup {-t sup 2} dt$
+
+       the entry for erfc is provided because of the
+       extreme loss of relative accuracy if erf(x) is
+       called for large x and the result subtracted
+       from 1. (e.g. for x= 10, 12 places are lost).
+
+       There are no error returns.
+
+       Calls exp.
+
+       Coefficients for large x are #5667 from Hart & Cheney (18.72D).
+*/
+
+#define M 7
+#define N 9
+int errno;
+static double torp = 1.1283791670955125738961589031;
+static double p1[] = {
+       0.804373630960840172832162e5,
+       0.740407142710151470082064e4,
+       0.301782788536507577809226e4,
+       0.380140318123903008244444e2,
+       0.143383842191748205576712e2,
+       -.288805137207594084924010e0,
+       0.007547728033418631287834e0,
+};
+static double q1[]  = {
+       0.804373630960840172826266e5,
+       0.342165257924628539769006e5,
+       0.637960017324428279487120e4,
+       0.658070155459240506326937e3,
+       0.380190713951939403753468e2,
+       0.100000000000000000000000e1,
+       0.0,
+};
+static double p2[]  = {
+       0.18263348842295112592168999e4,
+       0.28980293292167655611275846e4,
+       0.2320439590251635247384768711e4,
+       0.1143262070703886173606073338e4,
+       0.3685196154710010637133875746e3,
+       0.7708161730368428609781633646e2,
+       0.9675807882987265400604202961e1,
+       0.5641877825507397413087057563e0,
+       0.0,
+};
+static double q2[]  = {
+       0.18263348842295112595576438e4,
+       0.495882756472114071495438422e4,
+       0.60895424232724435504633068e4,
+       0.4429612803883682726711528526e4,
+       0.2094384367789539593790281779e4,
+       0.6617361207107653469211984771e3,
+       0.1371255960500622202878443578e3,
+       0.1714980943627607849376131193e2,
+       1.0,
+};
+
+double
+erf(arg) double arg;{
+       double erfc();
+       int sign;
+       double argsq;
+       double d, n;
+       int i;
+
+       errno = 0;
+       sign = 1;
+       if(arg < 0.){
+               arg = -arg;
+               sign = -1;
+       }
+       if(arg < 0.5){
+               argsq = arg*arg;
+               for(n=0,d=0,i=M-1; i>=0; i--){
+                       n = n*argsq + p1[i];
+                       d = d*argsq + q1[i];
+               }
+               return(sign*torp*arg*n/d);
+       }
+       if(arg >= 10.)
+               return(sign*1.);
+       return(sign*(1. - erfc(arg)));
+}
+
+double
+erfc(arg) double arg;{
+       double erf();
+       double exp();
+       double n, d;
+       int i;
+
+       errno = 0;
+       if(arg < 0.)
+               return(2. - erfc(-arg));
+/*
+       if(arg < 0.5)
+               return(1. - erf(arg));
+*/
+       if(arg >= 10.)
+               return(0.);
+
+       for(n=0,d=0,i=N-1; i>=0; i--){
+               n = n*arg + p2[i];
+               d = d*arg + q2[i];
+       }
+       return(exp(-arg*arg)*n/d);
+}
diff --git a/usr/src/libF77/mklib b/usr/src/libF77/mklib
deleted file mode 100755 (executable)
index 226f25f..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-ar rc libF77.a \
-main.o \
-abort_.o \
-getarg_.o \
-iargc_.o \
-signal_.o \
-s_stop.o \
-s_paus.o \
-pow_ci.o \
-pow_dd.o \
-pow_di.o \
-pow_hh.o \
-pow_ii.o \
-pow_ri.o \
-pow_zi.o \
-pow_zz.o \
-c_abs.o \
-c_cos.o \
-c_div.o \
-c_exp.o \
-c_log.o \
-c_sin.o \
-c_sqrt.o \
-z_abs.o \
-z_cos.o \
-z_div.o \
-z_exp.o \
-z_log.o \
-z_sin.o \
-z_sqrt.o \
-r_abs.o \
-r_acos.o \
-r_asin.o \
-r_atan.o \
-r_atn2.o \
-r_cnjg.o \
-r_cos.o \
-r_cosh.o \
-r_dim.o \
-r_exp.o \
-r_imag.o \
-r_int.o \
-r_lg10.o \
-r_log.o \
-r_mod.o \
-r_nint.o \
-r_sign.o \
-r_sin.o \
-r_sinh.o \
-r_sqrt.o \
-r_tan.o \
-r_tanh.o \
-d_abs.o \
-d_acos.o \
-d_asin.o \
-d_atan.o \
-d_atn2.o \
-d_cnjg.o \
-d_cos.o \
-d_cosh.o \
-d_dim.o \
-d_exp.o \
-d_imag.o \
-d_int.o \
-d_lg10.o \
-d_log.o \
-d_mod.o \
-d_nint.o \
-d_prod.o \
-d_sign.o \
-d_sin.o \
-d_sinh.o \
-d_sqrt.o \
-d_tan.o \
-d_tanh.o \
-i_abs.o \
-i_dim.o \
-i_dnnt.o \
-i_indx.o \
-i_len.o \
-i_mod.o \
-i_nint.o \
-i_sign.o \
-h_abs.o \
-h_dim.o \
-h_dnnt.o \
-h_indx.o \
-h_len.o \
-h_mod.o \
-h_nint.o \
-h_sign.o \
-l_ge.o \
-l_gt.o \
-l_le.o \
-l_lt.o \
-hl_ge.o \
-hl_gt.o \
-hl_le.o \
-hl_lt.o \
-s_cat.o \
-s_cmp.o \
-s_copy.o \
-cabs.o
diff --git a/usr/src/libF77/r_erf.c b/usr/src/libF77/r_erf.c
new file mode 100644 (file)
index 0000000..38e333c
--- /dev/null
@@ -0,0 +1,6 @@
+float erf_(x)
+float *x;
+{
+double erf();
+return( erf(*x) );
+}
diff --git a/usr/src/libF77/r_erfc.c b/usr/src/libF77/r_erfc.c
new file mode 100644 (file)
index 0000000..73667d6
--- /dev/null
@@ -0,0 +1,6 @@
+float erfc_(x)
+float *x;
+{
+double erfc();
+return( erfc(*x) );
+}
diff --git a/usr/src/libF77/sinh.c b/usr/src/libF77/sinh.c
new file mode 100644 (file)
index 0000000..878a760
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+       sinh(arg) returns the hyperbolic sign of its floating-
+       point argument.
+
+       The exponential function is called for arguments
+       greater in magnitude than 0.5.
+       The result overflows and 'huge' is returned for
+       arguments greater than somewhat.
+
+       A series is used for arguments smaller in magnitude than 0.5.
+       The coeffieients are #2029 from Hart & Cheney. (20.36D)
+
+       cosh(arg) is computed from the exponential function for
+       all arguments.
+*/
+
+double exp();
+
+static double p0 -0.6307673640497716991184787251e+6;
+static double p1 -0.8991272022039509355398013511e+5;
+static double p2 -0.2894211355989563807284660366e+4;
+static double p3 -0.2630563213397497062819489e+2;
+static double q0 -0.6307673640497716991212077277e+6;
+static double q1  0.1521517378790019070696485176e+5;
+static double q2 -0.173678953558233699533450911e+3;
+static double q3  1.0;
+
+double
+sinh(arg) double arg; {
+
+       double sign, temp, argsq;
+
+       sign = 1;
+       if(arg < 0){
+               arg = - arg;
+               sign = -1;
+       }
+
+       if(arg > 21.){
+               temp = exp(arg)/2;
+               return(sign*temp);
+       }
+
+       if(arg > 0.5) {
+               temp = (exp(arg) - exp(-arg))/2;
+               return(sign*temp);
+       }
+
+       argsq = arg*arg;
+       temp = (((p3*argsq+p2)*argsq+p1)*argsq+p0)*arg;
+       temp = temp/(((q3*argsq+q2)*argsq+q1)*argsq+q0);
+       return(sign*temp);
+
+}
+
+double
+cosh(arg) double arg; {
+
+       double temp;
+
+       if(arg < 0)
+               arg = - arg;
+
+       if(arg > 21.){
+               temp = exp(arg)/2;
+               return(temp);
+       }
+
+       temp = (exp(arg) + exp(-arg))/2;
+       return(temp);
+}
diff --git a/usr/src/libF77/tanh.c b/usr/src/libF77/tanh.c
new file mode 100644 (file)
index 0000000..9a9ac93
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+       tanh(arg) computes the hyperbolic tangent of its floating
+       point argument.
+
+       sinh and cosh are called except for large arguments, which
+       would cause overflow improperly.
+*/
+
+double sinh(), cosh();
+
+double
+tanh(arg) double arg; {
+
+       double sign;
+
+       sign = 1.;
+       if(arg < 0.){
+               arg = -arg;
+               sign = -1.;
+       }
+
+       if(arg > 21.){
+               return(sign);
+       }
+
+       return(sign*sinh(arg)/cosh(arg));
+}
index 3cfc103..c0f6dd4 100644 (file)
@@ -161,12 +161,6 @@ e_d(s,p) char *s,**p;
                        op_gen(x==1?EE:GE,w,d,e);
                }
                break;
                        op_gen(x==1?EE:GE,w,d,e);
                }
                break;
-       case 'o':
-               found = 1;
-               s = gt_num(s, &w);
-               if(w==0) break;
-               op_gen(O, w, 0, 0);
-               break;
        case 'l':
                found=1;
                s=gt_num(s,&w);
        case 'l':
                found=1;
                s=gt_num(s,&w);
@@ -374,7 +368,6 @@ type_f(n)
        case I:
        case IM:
        case A: case AW:
        case I:
        case IM:
        case A: case AW:
-       case O:
        case L:
        case E: case EE: case D:
        case G: case GE:
        case L:
        case E: case EE: case D:
        case G: case GE:
index 0f1b498..76604a1 100644 (file)
@@ -32,7 +32,6 @@ struct syl
 #define L 29
 #define A 30
 #define AW 31
 #define L 29
 #define A 30
 #define AW 31
-#define O 32
 extern struct syl syl[];
 extern int pc,parenlvl,revloc;
 extern int (*doed)(),(*doned)();
 extern struct syl syl[];
 extern int pc,parenlvl,revloc;
 extern int (*doed)(),(*doned)();
index d745c66..4eaa404 100644 (file)
@@ -1,6 +1,5 @@
-#define MAXINTLENGTH 12
-char *icvt(value,ndigit,sign, base) long value; int *ndigit,*sign;
-register int base;
+#define MAXINTLENGTH 10
+char *icvt(value,ndigit,sign) long value; int *ndigit,*sign;
 {      static char buf[MAXINTLENGTH+1];
        register int i;
        if(value>0) *sign=0;
 {      static char buf[MAXINTLENGTH+1];
        register int i;
        if(value>0) *sign=0;
@@ -15,8 +14,8 @@ register int base;
                return(&buf[MAXINTLENGTH]);
        }
        for(i=MAXINTLENGTH-1;value>0;i--)
                return(&buf[MAXINTLENGTH]);
        }
        for(i=MAXINTLENGTH-1;value>0;i--)
-       {       *(buf+i)=(int)(value%base)+'0';
-               value /= base;
+       {       *(buf+i)=(int)(value%10)+'0';
+               value /= 10;
        }
        *ndigit=MAXINTLENGTH-1-i;
        return(&buf[i+1]);
        }
        *ndigit=MAXINTLENGTH-1-i;
        return(&buf[i+1]);
index 2e220f6..c08a6c2 100644 (file)
@@ -9,17 +9,15 @@ int (*lioproc)();
 #define issep(x) (ltab[x+1]&SX)
 #define isapos(x) (ltab[x+1]&AX)
 #define isexp(x) (ltab[x+1]&EX)
 #define issep(x) (ltab[x+1]&SX)
 #define isapos(x) (ltab[x+1]&AX)
 #define isexp(x) (ltab[x+1]&EX)
-#define issign(x) (ltab[x+1]&SG)
 #define SX 1
 #define B 2
 #define AX 4
 #define EX 8
 #define SX 1
 #define B 2
 #define AX 4
 #define EX 8
-#define SG 16
 char ltab[128+1]       /* offset one for EOF */
 {      0,
        0,0,AX,0,0,0,0,0,0,0,B,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
 char ltab[128+1]       /* offset one for EOF */
 {      0,
        0,0,AX,0,0,0,0,0,0,0,B,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-       SX|B,0,AX,0,0,0,0,0,0,0,0,SG,SX,SG,0,SX,
+       SX|B,0,AX,0,0,0,0,0,0,0,0,0,SX,0,0,SX,
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,0,0,0,EX,EX,0,0,0,0,0,0,0,0,0,0,
        AX,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,0,0,0,EX,EX,0,0,0,0,0,0,0,0,0,0,
        AX,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@@ -160,10 +158,6 @@ l_R()
        }
        else    dc=rd_int(&c);
        if(isexp(GETC(ch))) db=rd_int(&d);
        }
        else    dc=rd_int(&c);
        if(isexp(GETC(ch))) db=rd_int(&d);
-       else if(issign(ch))
-       {       ungetc(ch, cf);
-               db = rd_int(&d);
-       }
        else
        {       ungetc(ch,cf);
                d=0;
        else
        {       ungetc(ch,cf);
                d=0;
diff --git a/usr/src/libI77/pwd.c b/usr/src/libI77/pwd.c
new file mode 100644 (file)
index 0000000..e3cad7e
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Print working (current) directory
+ */
+#include       <sys/types.h>
+#include       <sys/stat.h>
+#include       <sys/dir.h>
+
+char   dot[]   ".";
+char   dotdot[]        "..";
+char   root[]  "/";
+char   name[512];
+int    file;
+int    off     -1;
+struct stat    x;
+struct direct  y;
+
+main()
+{
+       for (;;) {
+               stat(dot, &x);
+               if ((file = open(dotdot,0)) < 0) prname();
+               do {
+                       if (read(file, &y, sizeof(y)) < sizeof(y))
+                               prname();
+               } while (y.d_ino != x.st_ino);
+               close(file);
+               if (y.d_ino == 2)
+                       ckroot();
+               cat();
+               chdir(dotdot);
+       }
+}
+
+ckroot()
+{
+       register i;
+
+       if (stat(y.d_name,&x)<0 || chdir(root)<0 || (file=open(root,0))<0)
+               prname();
+       i = x.st_dev;
+       do {
+               if (read(file,&y,sizeof(y)) < sizeof(y))
+                       prname();
+               if (y.d_ino == 0)
+                       continue;
+               if (stat(y.d_name,&x) < 0)
+                       prname();
+       } while (x.st_dev!=i || (x.st_mode&S_IFMT)!=S_IFDIR);
+       if (strcmp(dot, y.d_name) || strcmp(dotdot, y.d_name))
+               cat();
+       write(1, root, 1);
+       prname();
+}
+
+prname()
+{
+       if (off<0)
+               off = 0;
+       name[off] = '\n';
+       write(1, name, off+1);
+       exit(0);
+}
+
+cat()
+{
+       register i, j;
+
+       i = -1;
+       while (y.d_name[++i] != 0);
+       if ((off+i+2) > 511)
+               prname();
+       for(j=off+1; j>=0; --j)
+               name[j+i+1] = name[j];
+       off=i+off+1;
+       name[i] = root[0];
+       for(--i; i>=0; --i)
+               name[i] = y.d_name[i];
+}
index 9bdd49c..34e52a8 100644 (file)
@@ -15,11 +15,9 @@ rd_ed(p,ptr,len) char *ptr; struct syl *p; ftnlen len;
        default: fprintf(stderr,"rd_ed, unexpected code: %d\n%s\n",
                        p->op,fmtbuf);
                abort();
        default: fprintf(stderr,"rd_ed, unexpected code: %d\n%s\n",
                        p->op,fmtbuf);
                abort();
-       case I: ch = (rd_I(ptr,p->p1,len, 10));
+       case I: ch = (rd_I(ptr,p->p1,len));
                break;
                break;
-       case IM: ch = (rd_I(ptr,p->p1,len, 10));
-               break;
-       case O: ch = (rd_I(ptr, p->p1, len, 8));
+       case IM: ch = (rd_I(ptr,p->p1,len));
                break;
        case L: ch = (rd_L(ptr,p->p1));
                break;
                break;
        case L: ch = (rd_L(ptr,p->p1));
                break;
@@ -60,7 +58,7 @@ rd_ned(p,ptr) char *ptr; struct syl *p;
                return(1);
        }
 }
                return(1);
        }
 }
-rd_I(n,w,len, base) ftnlen len; uint *n; register int base;
+rd_I(n,w,len) ftnlen len; uint *n;
 {      long x=0;
        int i,sign=0,ch;
        for(i=0;i<w;i++)
 {      long x=0;
        int i,sign=0,ch;
        for(i=0;i<w;i++)
@@ -75,20 +73,19 @@ rd_I(n,w,len, base) ftnlen len; uint *n; register int base;
                case '-':
                        sign=1;
                        break;
                case '-':
                        sign=1;
                        break;
-               case '\n':
                case ' ':
                case ' ':
-                       if(cblank) x *= base;
+                       if(cblank) x *= 10;
                        break;
                        break;
+               case '\n':  break;
                case '0': case '1': case '2': case '3': case '4':
                case '5': case '6': case '7': case '8': case '9':
                case '0': case '1': case '2': case '3': case '4':
                case '5': case '6': case '7': case '8': case '9':
-                       x=base*x+ch-'0';
+                       x=10*x+ch-'0';
                        break;
                }
        }
 done:
        if(sign) x = -x;
        if(len==sizeof(short)) n->is=x;
                        break;
                }
        }
 done:
        if(sign) x = -x;
        if(len==sizeof(short)) n->is=x;
-       else if(len == sizeof(char)) n->ic = x;
        else n->il=x;
        return(0);
 }
        else n->il=x;
        return(0);
 }
@@ -115,20 +112,18 @@ rd_F(p,w,d,len) ftnlen len; ufloat *p;
        for(i=0;i<w;)
        {       i++;
                if((ch=(*getn)())<0) return(ch);
        for(i=0;i<w;)
        {       i++;
                if((ch=(*getn)())<0) return(ch);
-               else if(ch == ' ' && !cblank || ch == '+' && x == 0
-                       || ch == '\n' && !cblank) continue;
-               else if(ch=='-' && x==0) sx=1;
-               else if(ch == '+' || ch == '-') goto expon;
+               else if(ch==' ' && !cblank || ch=='+') continue;
+               else if(ch=='-') sx=1;
                else if(ch<='9' && ch>='0')
                        x=10*x+ch-'0';
                else if(ch=='e' || ch=='d' || ch=='.')
                        break;
                else if(ch<='9' && ch>='0')
                        x=10*x+ch-'0';
                else if(ch=='e' || ch=='d' || ch=='.')
                        break;
-               else if(cblank && (ch==' ' || ch== '\n')) x*=10;
+               else if(cblank && ch==' ') x*=10;
                else if(ch==',')
                {       i=w;
                        break;
                }
                else if(ch==',')
                {       i=w;
                        break;
                }
-               else return(errno = 115);
+               else if(ch!='\n') return(errno=115);
        }
        if(ch=='.') dot=1;
        while(i<w && ch!='e' && ch!='d' && ch!='+' && ch!='-')
        }
        if(ch=='.') dot=1;
        while(i<w && ch!='e' && ch!='d' && ch!='+' && ch!='-')
@@ -136,14 +131,13 @@ rd_F(p,w,d,len) ftnlen len; ufloat *p;
                if((ch=(*getn)())<0) return(ch);
                else if(ch<='9' && ch>='0')
                        y=10*y+ch-'0';
                if((ch=(*getn)())<0) return(ch);
                else if(ch<='9' && ch>='0')
                        y=10*y+ch-'0';
-               else if(cblank && (ch==' ' || ch == '\n'))
+               else if(cblank && ch==' ')
                        y *= 10;
                else if(ch==',') {i=w; break;}
                else if(ch==' ') continue;
                else continue;
                ny++;
        }
                        y *= 10;
                else if(ch==',') {i=w; break;}
                else if(ch==' ') continue;
                else continue;
                ny++;
        }
-expon:
        if(ch=='-') sz=1;
        while(i<w)
        {       i++;
        if(ch=='-') sz=1;
        while(i<w)
        {       i++;
@@ -152,7 +146,7 @@ expon:
                else if(ch=='-') sz=1;
                else if(ch<='9' && ch>='0')
                        z=10*z+ch-'0';
                else if(ch=='-') sz=1;
                else if(ch<='9' && ch>='0')
                        z=10*z+ch-'0';
-               else if(cblank && (ch==' ' || ch == '\n'))
+               else if(cblank && ch==' ')
                        z *= 10;
                else if(ch==',') break;
                else if(ch==' ') continue;
                        z *= 10;
                else if(ch==',') break;
                else if(ch==' ') continue;
@@ -206,6 +200,7 @@ rd_H(n,s) char *s;
 {      int i,ch;
        for(i=0;i<n;i++)
                if((ch=(*getn)())<0) return(ch);
 {      int i,ch;
        for(i=0;i<n;i++)
                if((ch=(*getn)())<0) return(ch);
+               else if(ch=='\n') *s++ = ' ';
                else *s++ = ch=='\n'?' ':ch;
        return(1);
 }
                else *s++ = ch=='\n'?' ':ch;
        return(1);
 }
index 3d76887..d8e3c4d 100644 (file)
@@ -4,7 +4,7 @@ f_rew(a) alist *a;
        unit *b;
        if(a->aunit>=MXUNIT || a->aunit<0) err(a->aerr,101,"rewind");
        b = &units[a->aunit];
        unit *b;
        if(a->aunit>=MXUNIT || a->aunit<0) err(a->aerr,101,"rewind");
        b = &units[a->aunit];
-       if(b->ufd == NULL) return(0);
+       if(b->ufd==NULL && fk_open(READ,SEQ,FMT,a->aunit)) err(a->aerr,114,"rewind")
        if(!b->useek) err(a->aerr,106,"rewind")
        if(b->uwrt)
        {       nowreading(b);
        if(!b->useek) err(a->aerr,106,"rewind")
        if(b->uwrt)
        {       nowreading(b);
index 5334378..d3bd219 100644 (file)
@@ -22,10 +22,9 @@ w_ed(p,ptr,len) char *ptr; struct syl *p; ftnlen len;
                fprintf(stderr,"w_ed, unexpected code: %d\n%s\n",
                        p->op,fmtbuf);
                abort();
                fprintf(stderr,"w_ed, unexpected code: %d\n%s\n",
                        p->op,fmtbuf);
                abort();
-       case I: return(wrt_I(ptr,p->p1,len, 10));
+       case I: return(wrt_I(ptr,p->p1,len));
        case IM:
                return(wrt_IM(ptr,p->p1,p->p2,len));
        case IM:
                return(wrt_IM(ptr,p->p1,p->p2,len));
-       case O: return(wrt_I(ptr, p->p1, len, 8));
        case L: return(wrt_L(ptr,p->p1));
        case A: return(wrt_A(ptr,len));
        case AW:
        case L: return(wrt_L(ptr,p->p1));
        case A: return(wrt_A(ptr,len));
        case AW:
@@ -63,14 +62,14 @@ w_ned(p,ptr) char *ptr; struct syl *p;
                return(wrt_H(p->p1,p->p2));
        }
 }
                return(wrt_H(p->p1,p->p2));
        }
 }
-wrt_I(n,w,len, base) uint *n; ftnlen len; register int base;
+wrt_I(n,w,len) uint *n; ftnlen len;
 {      int ndigit,sign,spare,i;
        long x;
        char *ans;
        if(len==sizeof(short)) x=n->is;
        else if(len == sizeof(char)) x = n->ic;
        else x=n->il;
 {      int ndigit,sign,spare,i;
        long x;
        char *ans;
        if(len==sizeof(short)) x=n->is;
        else if(len == sizeof(char)) x = n->ic;
        else x=n->il;
-       ans=icvt(x,&ndigit,&sign, base);
+       ans=icvt(x,&ndigit,&sign);
        spare=w-ndigit;
        if(sign || cplus) spare--;
        if(spare<0)
        spare=w-ndigit;
        if(sign || cplus) spare--;
        if(spare<0)
index 5b64244..6b6537e 100644 (file)
@@ -52,7 +52,6 @@ pr_put(c)
 x_wSL()
 {
        recpos=0;
 x_wSL()
 {
        recpos=0;
-       cursor = 0;
        (*putn)('\n');
        return(1);
 }
        (*putn)('\n');
        return(1);
 }
diff --git a/usr/src/libc/Makefile b/usr/src/libc/Makefile
new file mode 100644 (file)
index 0000000..8585c47
--- /dev/null
@@ -0,0 +1,26 @@
+DESTDIR=
+
+libc.a :
+       cc -c -O crt/*.s
+       cc -c -O gen/*.c
+       cc -c -O gen/atofo.s
+       mv atofo.o atof.o
+       cc -c -O stdio/*.c
+       cc -c -O sys/*.s
+       cp stdio/doprnt.s doprnt.c
+       cc -E doprnt.c | as -o doprnt.o
+       rm doprnt.c
+       -for i in *.o ; do ld -x -r $$i; mv a.out $$i; done
+       ar cr libc.a `lorder *.o | tsort`
+       ar ma flsbuf.o libc.a exit.o
+       ar ma exit.o libc.a cleanup.o
+       cc -c -O csu/*.s
+
+clean :
+       rm *.o
+
+install :
+       mv $(DESTDIR)/lib/libc.a  /usr/old/$(DESTDIR)/lib/libc.a
+       install libc.a $(DESTDIR)/lib/libc.a
+       install crt0.o $(DESTDIR)/lib
+       install mcrt0.o $(DESTDIR)/lib
diff --git a/usr/src/libc/compall b/usr/src/libc/compall
deleted file mode 100755 (executable)
index 7bf3abf..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-cc -c -O /usr/src/libc/stdio/getgrgid.c
-cc -c -O /usr/src/libc/stdio/getgrnam.c
-cc -c -O /usr/src/libc/stdio/getgrent.c
-cc -c -O /usr/src/libc/stdio/getpass.c
-cc -c -O /usr/src/libc/stdio/getpwnam.c
-cc -c -O /usr/src/libc/stdio/getpwuid.c
-cc -c -O /usr/src/libc/stdio/getpwent.c
-cc -c -O /usr/src/libc/stdio/fgetc.c
-cc -c -O /usr/src/libc/stdio/fputc.c
-cc -c -O /usr/src/libc/stdio/getchar.c
-cc -c -O /usr/src/libc/stdio/putchar.c
-cc -c -O /usr/src/libc/stdio/popen.c
-cc -c -O /usr/src/libc/stdio/freopen.c
-cc -c -O /usr/src/libc/stdio/fgets.c
-cc -c -O /usr/src/libc/stdio/fputs.c
-cc -c -O /usr/src/libc/stdio/getpw.c
-cc -c -O /usr/src/libc/stdio/fseek.c
-cc -c -O /usr/src/libc/stdio/ftell.c
-cc -c -O /usr/src/libc/stdio/rew.c
-cc -c -O /usr/src/libc/stdio/rdwr.c
-cc -c -O /usr/src/libc/stdio/system.c
-cc -c -O /usr/src/libc/stdio/fopen.c
-cc -c -O /usr/src/libc/stdio/fdopen.c
-cc -c -O /usr/src/libc/stdio/scanf.c
-cc -c -O /usr/src/libc/stdio/doscan.c
-cc -c -O /usr/src/libc/stdio/fprintf.c
-cc -c -O /usr/src/libc/stdio/gets.c
-cc -c -O /usr/src/libc/stdio/getw.c
-cc -c -O /usr/src/libc/stdio/printf.c
-cc -c -O /usr/src/libc/stdio/puts.c
-cc -c -O /usr/src/libc/stdio/putw.c
-cc -c -O /usr/src/libc/stdio/sprintf.c
-cc -c -O /usr/src/libc/stdio/ungetc.c
-cc -c -O /usr/src/libc/stdio/filbuf.c
-cc -c -O /usr/src/libc/stdio/setbuf.c
-cc -c /usr/src/libc/stdio/fltpr.s
-cc -c /usr/src/libc/stdio/doprnt.s
-cc -c -O /usr/src/libc/stdio/gcvt.c
-cc -c /usr/src/libc/stdio/ffltpr.s
-cc -c -O /usr/src/libc/stdio/strout.c
-cc -c -O /usr/src/libc/stdio/flsbuf.c
-cc -c -O /usr/src/libc/stdio/endopen.c
-cc -c -O /usr/src/libc/stdio/findiop.c
-cc -c -O /usr/src/libc/stdio/clrerr.c
-cc -c -O /usr/src/libc/stdio/data.c
-cc -c /usr/src/libc/gen/cuexit.s
-cc -c -O /usr/src/libc/gen/execvp.c
-cc -c -O /usr/src/libc/gen/getenv.c
-cc -c -O /usr/src/libc/gen/getlogin.c
-cc -c -O /usr/src/libc/gen/perror.c
-cc -c -O /usr/src/libc/gen/sleep.c
-cc -c -O /usr/src/libc/gen/timezone.c
-cc -c -O /usr/src/libc/gen/ttyslot.c
-cc -c -O /usr/src/libc/gen/ttyname.c
-cc -c /usr/src/libc/gen/abort.s
-cc -c -O /usr/src/libc/gen/abs.c
-cc -c -O /usr/src/libc/gen/atof.c
-cc -c -O /usr/src/libc/gen/atoi.c
-cc -c -O /usr/src/libc/gen/atol.c
-cc -c -O /usr/src/libc/gen/crypt.c
-cc -c -O /usr/src/libc/gen/ctime.c
-cc -c -O /usr/src/libc/gen/calloc.c
-cc -c -O /usr/src/libc/gen/malloc.c
-cc -c -O /usr/src/libc/gen/ecvt.c
-cc -c -O /usr/src/libc/gen/errlst.c
-cc -c /usr/src/libc/gen/fakcu.s
-cc -c /usr/src/libc/gen/fakfp.s
-cc -c /usr/src/libc/gen/frexp11.s
-cc -c -O /usr/src/libc/gen/isatty.c
-cc -c -O /usr/src/libc/gen/l3.c
-cc -c /usr/src/libc/gen/ldexp11.s
-cc -c /usr/src/libc/gen/ldfps.s
-cc -c -O /usr/src/libc/gen/mktemp.c
-cc -c /usr/src/libc/gen/modf11.s
-cc -c -O /usr/src/libc/gen/mpx.c
-cc -c -O /usr/src/libc/gen/mon.c
-cc -c -O /usr/src/libc/gen/nlist.c
-cc -c -O /usr/src/libc/gen/qsort.c
-cc -c -O /usr/src/libc/gen/rand.c
-cc -c /usr/src/libc/gen/setjmp.s
-cc -c -O /usr/src/libc/gen/stty.c
-cc -c -O /usr/src/libc/gen/swab.c
-cc -c -O /usr/src/libc/gen/tell.c
-cc -c -O /usr/src/libc/gen/ctype_.c
-cc -c -O /usr/src/libc/gen/index.c
-cc -c -O /usr/src/libc/gen/rindex.c
-cc -c -O /usr/src/libc/gen/strcat.c
-cc -c -O /usr/src/libc/gen/strncat.c
-cc -c -O /usr/src/libc/gen/strcmp.c
-cc -c -O /usr/src/libc/gen/strncmp.c
-cc -c -O /usr/src/libc/gen/strcpy.c
-cc -c -O /usr/src/libc/gen/strncpy.c
-cc -c -O /usr/src/libc/gen/strlen.c
-cc -c /usr/src/libc/sys/access.s
-cc -c /usr/src/libc/sys/acct.s
-cc -c /usr/src/libc/sys/alarm.s
-cc -c /usr/src/libc/sys/chdir.s
-cc -c /usr/src/libc/sys/chroot.s
-cc -c /usr/src/libc/sys/chmod.s
-cc -c /usr/src/libc/sys/chown.s
-cc -c /usr/src/libc/sys/close.s
-cc -c /usr/src/libc/sys/creat.s
-cc -c /usr/src/libc/sys/dup.s
-cc -c /usr/src/libc/sys/execl.s
-cc -c /usr/src/libc/sys/execle.s
-cc -c /usr/src/libc/sys/execv.s
-cc -c /usr/src/libc/sys/execve.s
-cc -c /usr/src/libc/sys/exit.s
-cc -c /usr/src/libc/sys/fork.s
-cc -c /usr/src/libc/sys/fstat.s
-cc -c /usr/src/libc/sys/getgid.s
-cc -c /usr/src/libc/sys/getpid.s
-cc -c /usr/src/libc/sys/getuid.s
-cc -c /usr/src/libc/sys/ioctl.s
-cc -c /usr/src/libc/sys/kill.s
-cc -c /usr/src/libc/sys/link.s
-cc -c /usr/src/libc/sys/lock.s
-cc -c /usr/src/libc/sys/lseek.s
-cc -c /usr/src/libc/sys/mknod.s
-cc -c /usr/src/libc/sys/mount.s
-cc -c /usr/src/libc/sys/mpxcall.s
-cc -c /usr/src/libc/sys/nice.s
-cc -c /usr/src/libc/sys/open.s
-cc -c /usr/src/libc/sys/pause.s
-cc -c /usr/src/libc/sys/phys.s
-cc -c /usr/src/libc/sys/pipe.s
-cc -c /usr/src/libc/sys/profil.s
-cc -c /usr/src/libc/sys/ptrace.s
-cc -c /usr/src/libc/sys/read.s
-cc -c /usr/src/libc/sys/sbrk.s
-cc -c /usr/src/libc/sys/setgid.s
-cc -c /usr/src/libc/sys/setuid.s
-cc -c /usr/src/libc/sys/signal.s
-cc -c /usr/src/libc/sys/stat.s
-cc -c /usr/src/libc/sys/stime.s
-cc -c /usr/src/libc/sys/sync.s
-cc -c /usr/src/libc/sys/time.s
-cc -c /usr/src/libc/sys/times.s
-cc -c /usr/src/libc/sys/umask.s
-cc -c /usr/src/libc/sys/umount.s
-cc -c /usr/src/libc/sys/unlink.s
-cc -c /usr/src/libc/sys/utime.s
-cc -c /usr/src/libc/sys/wait.s
-cc -c /usr/src/libc/sys/write.s
-cc -c /usr/src/libc/crt/aldiv.s
-cc -c /usr/src/libc/crt/almul.s
-cc -c /usr/src/libc/crt/alrem.s
-cc -c /usr/src/libc/crt/cerror.s
-cc -c /usr/src/libc/crt/ldiv.s
-cc -c /usr/src/libc/crt/lmul.s
-cc -c /usr/src/libc/crt/lrem.s
-cc -c /usr/src/libc/crt/mcount.s
-cc -c /usr/src/libc/crt/csv.s
diff --git a/usr/src/libc/crt/aldiv.s b/usr/src/libc/crt/aldiv.s
deleted file mode 100644 (file)
index d1c3706..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/ Long quotient
-
-.globl aldiv
-.globl csv, cret
-aldiv:
-       jsr     r5,csv
-       mov     8.(r5),r3
-       sxt     r4
-       bpl     1f
-       neg     r3
-1:
-       cmp     r4,6.(r5)
-       bne     hardldiv
-       mov     4(r5),r1
-       mov     2(r1),r2
-       mov     (r1),r1
-       bge     1f
-       neg     r1
-       neg     r2
-       sbc     r1
-       com     r4
-1:
-       mov     r4,-(sp)
-       clr     r0
-       div     r3,r0
-       mov     r0,r4           /high quotient
-       mov     r1,r0
-       mov     r2,r1
-       div     r3,r0
-       bvc     1f
-       sub     r3,r0           / this is the clever part
-       div     r3,r0
-       tst     r1
-       sxt     r1
-       add     r1,r0           / cannot overflow!
-1:
-       mov     r0,r1
-       mov     r4,r0
-       tst     (sp)+
-       bpl     9f
-       neg     r0
-       neg     r1
-       sbc     r0
-9:
-       mov     4.(r5),r2
-       mov     r0,(r2)+
-       mov     r1,(r2)
-       jmp     cret
-
-/ The divisor is known to be >= 2^15 so only 16 cycles are needed.
-hardldiv:
-       clr     -(sp)
-       mov     4.(r5),r0
-       mov     2(r0),r2
-       mov     (r0),r1
-       bpl     1f
-       com     (sp)
-       neg     r1
-       neg     r2
-       sbc     r1
-1:
-       clr     r0
-       mov     6.(r5),r3
-       bge     1f
-       neg     r3
-       neg     8.(r5)
-       sbc     r3
-       com     (sp)
-1:
-       mov     $16.,r4
-1:
-       clc
-       rol     r2
-       rol     r1
-       rol     r0
-       cmp     r3,r0
-       bgt     3f
-       blt     2f
-       cmp     8.(r5),r1
-       blos    2f
-3:
-       sob     r4,1b
-       br      1f
-2:
-       sub     8.(r5),r1
-       sbc     r0
-       sub     r3,r0
-       inc     r2
-       sob     r4,1b
-1:
-       mov     r2,r1
-       clr     r0
-       tst     (sp)+
-       beq     1f
-       neg     r0
-       neg     r1
-       sbc     r0
-1:
-       mov     4.(r5),r2
-       mov     r0,(r2)+
-       mov     r1,(r2)
-       jmp     cret
diff --git a/usr/src/libc/crt/almul.s b/usr/src/libc/crt/almul.s
deleted file mode 100644 (file)
index d1d8b84..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/
-/ 32-bit multiplication routine for fixed pt hardware.
-/  Implements *= operator
-/ Credit to an unknown author who slipped it under the door.
-.globl almul
-.globl csv, cret
-
-almul:
-       jsr     r5,csv
-       mov     4(r5),r4
-       mov     2(r4),r2
-       sxt     r1
-       sub     (r4),r1
-       mov     8.(r5),r0
-       sxt     r3
-       sub     6.(r5),r3
-       mul     r0,r1
-       mul     r2,r3
-       add     r1,r3
-       mul     r2,r0
-       sub     r3,r0
-       mov     r0,(r4)+
-       mov     r1,(r4)
-       jmp     cret
diff --git a/usr/src/libc/crt/alrem.s b/usr/src/libc/crt/alrem.s
deleted file mode 100644 (file)
index 720bd54..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/ Long remainder
-
-.globl alrem
-.globl csv, cret
-alrem:
-       jsr     r5,csv
-       mov     8.(r5),r3
-       sxt     r4
-       bpl     1f
-       neg     r3
-1:
-       cmp     r4,6.(r5)
-       bne     hardlrem
-       mov     4.(r5),r0
-       mov     2(r0),r2
-       mov     (r0),r1
-       mov     r1,r4
-       bge     1f
-       neg     r1
-       neg     r2
-       sbc     r1
-1:
-       clr     r0
-       div     r3,r0
-       mov     r1,r0
-       mov     r2,r1
-       div     r3,r0
-       bvc     1f
-       sub     r3,r0
-       div     r3,r0
-       tst     r1
-       beq     9f
-       add     r3,r1
-1:
-       tst     r4
-       bpl     9f
-       neg     r1
-9:
-       sxt     r0
-       mov     4.(r5),r3
-       mov     r0,(r3)+
-       mov     r1,(r3)
-       jmp     cret
-
-/ The divisor is known to be >= 2^15.  Only 16 cycles are
-/ needed to get a remainder.
-hardlrem:
-       mov     4.(r5),r0
-       mov     2(r0),r2
-       mov     (r0),r1
-       bpl     1f
-       neg     r1
-       neg     r2
-       sbc     r1
-1:
-       clr     r0
-       mov     6.(r5),r3
-       bge     1f
-       neg     r3
-       neg     8.(r5)
-       sbc     r3
-1:
-       mov     $16.,r4
-1:
-       clc
-       rol     r2
-       rol     r1
-       rol     r0
-       cmp     r3,r0
-       blt     2f
-       bgt     3f
-       cmp     8.(r5),r1
-       blos    2f
-3:
-       sob     r4,1b
-       br      1f
-2:
-       sub     8.(r5),r1
-       sbc     r0
-       sub     r3,r0
-       sob     r4,1b
-1:
-       mov     4.(r5),r3
-       tst     (r3)
-       bge     1f
-       neg     r0
-       neg     r1
-       sbc     r0
-1:
-       mov     r0,(r3)+
-       mov     r1,(r3)
-       jmp     cret
index d7e2231..3859b03 100644 (file)
@@ -1,12 +1,10 @@
-/ C return sequence which
-/ sets errno, returns -1.
+# C return sequence which
+# sets errno, returns -1.
 
 .globl cerror
 
 .globl cerror
-.comm  _errno,2
+.comm  _errno,4
 
 cerror:
 
 cerror:
-       mov     r0,_errno
-       mov     $-1,r0
-       mov     r5,sp
-       mov     (sp)+,r5
-       rts     pc
+       movl    r0,_errno
+       mnegl   $1,r0
+       ret
diff --git a/usr/src/libc/crt/csv.s b/usr/src/libc/crt/csv.s
deleted file mode 100644 (file)
index 858b79b..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/ C register save and restore -- version 7/75
-
-.globl csv
-.globl cret
-
-csv:
-       mov     r5,r0
-       mov     sp,r5
-       mov     r4,-(sp)
-       mov     r3,-(sp)
-       mov     r2,-(sp)
-       jsr     pc,(r0)         / jsr part is sub $2,sp
-
-cret:
-       mov     r5,r2
-       mov     -(r2),r4
-       mov     -(r2),r3
-       mov     -(r2),r2
-       mov     r5,sp
-       mov     (sp)+,r5
-       rts     pc
diff --git a/usr/src/libc/crt/ldiv.s b/usr/src/libc/crt/ldiv.s
deleted file mode 100644 (file)
index 31aafe2..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/ Long quotient
-
-.globl ldiv
-.globl csv, cret
-
-ldiv:
-       jsr     r5,csv
-       mov     10.(r5),r3
-       sxt     r4
-       bpl     1f
-       neg     r3
-1:
-       cmp     r4,8.(r5)
-       bne     hardldiv
-       mov     6.(r5),r2
-       mov     4.(r5),r1
-       bge     1f
-       neg     r1
-       neg     r2
-       sbc     r1
-       com     r4
-1:
-       mov     r4,-(sp)
-       clr     r0
-       div     r3,r0
-       mov     r0,r4           /high quotient
-       mov     r1,r0
-       mov     r2,r1
-       div     r3,r0
-       bvc     1f
-       sub     r3,r0           / this is the clever part
-       div     r3,r0
-       tst     r1
-       sxt     r1
-       add     r1,r0           / cannot overflow!
-1:
-       mov     r0,r1
-       mov     r4,r0
-       tst     (sp)+
-       bpl     9f
-       neg     r0
-       neg     r1
-       sbc     r0
-9:
-       jmp     cret
-
-/ The divisor is known to be >= 2^15 so only 16 cycles are needed.
-hardldiv:
-       clr     -(sp)
-       mov     6.(r5),r2
-       mov     4.(r5),r1
-       bpl     1f
-       com     (sp)
-       neg     r1
-       neg     r2
-       sbc     r1
-1:
-       clr     r0
-       mov     8.(r5),r3
-       bge     1f
-       neg     r3
-       neg     10.(r5)
-       sbc     r3
-       com     (sp)
-1:
-       mov     $16.,r4
-1:
-       clc
-       rol     r2
-       rol     r1
-       rol     r0
-       cmp     r3,r0
-       bgt     3f
-       blt     2f
-       cmp     10.(r5),r1
-       blos    2f
-3:
-       sob     r4,1b
-       br      1f
-2:
-       sub     10.(r5),r1
-       sbc     r0
-       sub     r3,r0
-       inc     r2
-       sob     r4,1b
-1:
-       mov     r2,r1
-       clr     r0
-       tst     (sp)+
-       beq     1f
-       neg     r0
-       neg     r1
-       sbc     r0
-1:
-       jmp     cret
diff --git a/usr/src/libc/crt/lmul.s b/usr/src/libc/crt/lmul.s
deleted file mode 100644 (file)
index 1d24660..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/
-/ 32-bit multiplication routine for fixed pt hardware.
-/  Implements * operator
-/ Credit to an unknown author who slipped it under the door.
-.globl lmul
-.globl csv, cret
-
-lmul:
-       jsr     r5,csv
-       mov     6(r5),r2
-       sxt     r1
-       sub     4(r5),r1
-       mov     10.(r5),r0
-       sxt     r3
-       sub     8.(r5),r3
-       mul     r0,r1
-       mul     r2,r3
-       add     r1,r3
-       mul     r2,r0
-       sub     r3,r0
-       jmp     cret
diff --git a/usr/src/libc/crt/lrem.s b/usr/src/libc/crt/lrem.s
deleted file mode 100644 (file)
index b37a3d8..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/ Long remainder
-
-.globl lrem
-.globl csv, cret
-
-lrem:
-       jsr     r5,csv
-       mov     10.(r5),r3
-       sxt     r4
-       bpl     1f
-       neg     r3
-1:
-       cmp     r4,8.(r5)
-       bne     hardlrem
-       mov     6.(r5),r2
-       mov     4.(r5),r1
-       mov     r1,r4
-       bge     1f
-       neg     r1
-       neg     r2
-       sbc     r1
-1:
-       clr     r0
-       div     r3,r0
-       mov     r1,r0
-       mov     r2,r1
-       div     r3,r0
-       bvc     1f
-       sub     r3,r0
-       div     r3,r0
-       tst     r1
-       beq     9f
-       add     r3,r1
-1:
-       tst     r4
-       bpl     9f
-       neg     r1
-9:
-       sxt     r0
-       jmp     cret
-
-/ The divisor is known to be >= 2^15.  Only 16 cycles are
-/ needed to get a remainder.
-hardlrem:
-       mov     6.(r5),r2
-       mov     4.(r5),r1
-       bpl     1f
-       neg     r1
-       neg     r2
-       sbc     r1
-1:
-       clr     r0
-       mov     8.(r5),r3
-       bge     1f
-       neg     r3
-       neg     10.(r5)
-       sbc     r3
-1:
-       mov     $16.,r4
-1:
-       clc
-       rol     r2
-       rol     r1
-       rol     r0
-       cmp     r3,r0
-       blt     2f
-       bgt     3f
-       cmp     10.(r5),r1
-       blos    2f
-3:
-       sob     r4,1b
-       br      1f
-2:
-       sub     10.(r5),r1
-       sbc     r0
-       sub     r3,r0
-       sob     r4,1b
-1:
-       tst     4(r5)
-       bge     1f
-       neg     r0
-       neg     r1
-       sbc     r0
-1:
-       jmp     cret
old mode 100644 (file)
new mode 100755 (executable)
index a3d91d2..e9d84a7
@@ -1,20 +1,19 @@
-/ count subroutine calls during profiling
+# count subroutine called during profiling
 
 .globl mcount
 
 .globl mcount
-.comm  countbase,2
+.comm  countbase,4
 
 mcount:
 
 mcount:
-       mov     (r0),r1
-       bne     1f
-       mov     countbase,r1
-       beq     2f
-       add     $6,countbase
-       mov     (sp),(r1)+
-       mov     r1,(r0)
-1:
-       inc     2(r1)
-       bne     2f
-       inc     (r1)
-2:
-       rts     pc
-
+       movl    (r0),r1
+       beql    init
+incr:
+       incl    (r1)
+return:
+       rsb
+init:
+       movl    countbase,r1
+       beql    return
+       addl2   $8,countbase
+       movl    (sp),(r1)+
+       movl    r1,(r0)
+       brb     incr
index 816c7fd..90fa265 100644 (file)
@@ -1,36 +1,33 @@
-/ C runtime startoff
+# C runtime startoff
 
 
-.globl _exit, _environ
+       .set    exit,1
+.globl _exit
 .globl start
 .globl _main
 .globl start
 .globl _main
-exit = 1.
+.globl _environ
 
 
-start:
-       setd
-       mov     2(sp),r0
-       clr     -2(r0)
-       mov     sp,r0
-       sub     $4,sp
-       mov     4(sp),(sp)
-       tst     (r0)+
-       mov     r0,2(sp)
-1:
-       tst     (r0)+
-       bne     1b
-       cmp     r0,*2(sp)
-       blo     1f
-       tst     -(r0)
-1:
-       mov     r0,4(sp)
-       mov     r0,_environ
-       jsr     pc,_main
-       cmp     (sp)+,(sp)+
-       mov     r0,(sp)
-       jsr     pc,*$_exit
-       sys     exit
+#
+#      C language startup routine
 
 
-.bss
-_environ:
-       .=.+2
-.data
-       .=.+2           / loc 0 for I/D; null ptr points here.
+start:
+       .word   0x0000
+       subl2   $8,sp
+       movl    8(sp),(sp)  #  argc
+       movab   12(sp),r0
+       movl    r0,4(sp)  #  argv
+L1:
+       tstl    (r0)+  #  null args term ?
+       bneq    L1
+       cmpl    r0,*4(sp)  #  end of 'env' or 'argv' ?
+       blss    L2
+       tstl    -(r0)  # envp's are in list
+L2:
+       movl    r0,8(sp)  #  env
+       movl    r0,_environ  #  indir is 0 if no env ; not 0 if env
+       calls   $3,_main
+       pushl   r0
+       calls   $1,_exit
+       chmk    $exit
+#
+       .data
+_environ:      .space  4
diff --git a/usr/src/libc/csu/fcrt0.s b/usr/src/libc/csu/fcrt0.s
deleted file mode 100644 (file)
index a61ca3b..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/ C runtime startoff
-/ with floating point interpreter
-
-.globl fptrap
-.globl _exit
-.globl _main
-.globl _environ
-exit = 1.
-signal = 48.
-
-start:
-       sys     signal; 4; fptrap
-       setd
-       mov     2(sp),r0
-       clr     -2(r0)
-       mov     sp,r0
-       sub     $4,sp
-       mov     4(sp),(sp)
-       tst     (r0)+
-       mov     r0,2(sp)
-1:
-       tst     (r0)+
-       bne     1b
-       cmp     r0,*2(sp)
-       blo     1f
-       tst     -(r0)
-1:
-       mov     r0,4(sp)
-       mov     r0,_environ
-       jsr     pc,_main
-       cmp     (sp)+,(sp)+
-       mov     r0,(sp)
-       jsr     pc,*$_exit
-       sys     exit
-.bss
-_environ:
-       .=.+2
-.data
-       .=.+2
diff --git a/usr/src/libc/csu/fmcrt0.s b/usr/src/libc/csu/fmcrt0.s
deleted file mode 100644 (file)
index 330b387..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/ C runtime startoff including monitoring
-
-cbufs  = 300.
-exit   = 1.
-write  = 4.
-signal = 48.
-
-.globl _monitor
-.globl _sbrk
-.globl _main
-.globl _exit
-.globl _environ
-.globl _etext
-.globl __cleanup
-.globl countbase
-.globl fptrap
-
-
-start:
-       sys     signal; 4; fptrap
-       setd
-       mov     2(sp),r0
-       clr     -2(r0)
-       mov     sp,r0
-       sub     $4,sp
-       mov     4(sp),(sp)
-       tst     (r0)+
-       mov     r0,2(sp)
-1:
-       tst     (r0)+
-       bne     1b
-       cmp     r0,*2(sp)
-       blo     1f
-       tst     -(r0)
-1:
-       mov     r0,4(sp)
-       mov     r0,_environ
-
-       mov     $_etext,r1
-       sub     $eprol,r1
-       add     $7,r1
-       ash     $-3,r1
-       bic     $!17777,r1
-       mov     $cbufs,-(sp)
-       add     $3*[cbufs+1],r1
-       mov     r1,-(sp)
-       asl     r1
-       mov     r1,-(sp)
-       jsr     pc,_sbrk
-       tst     (sp)+
-       cmp     r0,$-1
-       beq     9f
-       mov     r0,-(sp)
-       add     $6,r0
-       mov     r0,countbase
-       mov     $_etext,-(sp)
-       mov     $eprol,-(sp)
-       jsr     pc,_monitor
-       add     $10.,sp
-       jsr     pc,_main
-       cmp     (sp)+,(sp)+
-       mov     r0,(sp)
-       jsr     pc,_exit
-
-9:
-       mov     $2,r0
-       sys     write; 8f; 9f-8f
-
-.data; 8: <No space for monitor buffer\n>; 9:.even; .text
-
-_exit:
-       mov     r5,-(sp)
-       mov     sp,r5
-       jsr     pc,__cleanup
-       clr     -(sp)
-       jsr     pc,_monitor
-       tst     (sp)+
-       mov     4(r5),r0
-       sys     exit
-eprol:
-.bss
-_environ:
-       .=.+2
-countbase:
-       .=.+2
-.data
-       .=.+2
index 3c1a21c..fdc0dc1 100644 (file)
@@ -1,84 +1,83 @@
-/ C runtime startoff including monitoring
+# C runtime startoff including monitoring
 
 
-cbufs  = 300.
-exit   = 1
-write  = 4
+       .set    exit,1
+       .set    cbufs,300
 
 
+.globl start
 .globl _monitor
 .globl _sbrk
 .globl _main
 .globl _exit
 .globl _monitor
 .globl _sbrk
 .globl _main
 .globl _exit
-.globl _environ
+.globl _IEH3exit
 .globl _etext
 .globl _etext
+.globl _environ
 .globl __cleanup
 .globl __cleanup
-.globl countbase
+.comm  countbase,4
 
 
 start:
 
 
 start:
-       setd
-       mov     2(sp),r0
-       clr     -2(r0)
-       mov     sp,r0
-       sub     $4,sp
-       mov     4(sp),(sp)
-       tst     (r0)+
-       mov     r0,2(sp)
-1:
-       tst     (r0)+
-       bne     1b
-       cmp     r0,*2(sp)
-       blo     1f
-       tst     -(r0)
-1:
-       mov     r0,4(sp)
-       mov     r0,_environ
+       .word   0x0000
+       subl2   $8,sp
+       movl    8(sp),(sp)  #  argc
+       movab   12(sp),r0
+       movl    r0,4(sp)  #  argv
+L1:
+       tstl    (r0)+  #  null args term ?
+       bneq    L1
+       cmpl    r0,*4(sp)  #  end of 'env' or 'argv' ?
+       blss    L2
+       tstl    -(r0)  # envp's are in list
+L2:
+       movl    r0,8(sp)  #  env
+       movl    r0,_environ  #  indir is 0 if no env ; not 0 if env
 
 
-       mov     $_etext,r1
-       sub     $eprol,r1
-       add     $7,r1
-       ash     $-3,r1
-       bic     $!17777,r1
-       mov     $cbufs,-(sp)
-       add     $3*[cbufs+1],r1
-       mov     r1,-(sp)
-       asl     r1
-       mov     r1,-(sp)
-       jsr     pc,_sbrk
-       tst     (sp)+
-       cmp     r0,$-1
-       beq     9f
-       mov     r0,-(sp)
-       add     $6,r0
-       mov     r0,countbase
-       mov     $_etext,-(sp)
-       mov     $eprol,-(sp)
-       jsr     pc,_monitor
-       add     $10.,sp
-       jsr     pc,_main
-       cmp     (sp)+,(sp)+
-       mov     r0,(sp)
-       jsr     pc,_exit
+       subl3   $eprol,$_etext,r1
+       addl2   $7,r1
+       extzv   $3,$16,r1,r1
+       addl2   r1,r1           # tally size
+       addl2   $8*cbufs+12,r1          # entrance count plus header
+       pushl   $cbufs          # # entrance counters
+       pushl   r1              # bufsiz
+       pushl   r1              # for sbrk
+       calls   $1,_sbrk
+       cmpl    r0,$-1
+       beql    nospace
+# bandaid for sbrk not clearing memory (remove bandaid when fixed)
+#      addl3   (sp),(sp),r1
+#L100:
+#      clrb    -1(r0)[r1]
+#      sobgtr  r1,L100
+# end bandaid
+       pushl   r0
+       addl3   $12,r0,countbase
+       pushab  _etext
+       pushab  eprol
+       calls   $5,_monitor
+       calls   $3,_main
+       pushl   r0
+       calls   $1,_exit
 
 
-9:
-       mov     $2,r0
-       sys     write; 8f; 9f-8f
+       .data
+_environ:      .space  4
+emsg:
+       .byte   'N,'o,' ,'s,'p,'a,'c,'e,' ,'f,'o,'r,' 
+       .byte   'm,'o,'n,'i,'t,'o,'r,' ,'b,'u,'f,'f,'e,'r,0xa,0x0
+em1:
+       .text
 
 
-.data; 8: <No space for monitor buffer\n>; 9:.even; .text
+nospace:
+       pushl   $em1-emsg
+       pushab  emsg
+       pushl   $2
+       calls   $3,_write
 
 _exit:
 
 _exit:
-       mov     r5,-(sp)
-       mov     sp,r5
-       jsr     pc,__cleanup
-       clr     -(sp)
-       jsr     pc,_monitor
-       tst     (sp)+
-       mov     4(r5),r0
-       sys     exit
+_IEH3exit:
+       .word   0x0000
+       calls   $0,__cleanup
+       pushl   $0
+       calls   $1,_monitor
+       chmk    $exit
 eprol:
 eprol:
-.bss
-_environ:
-       .=.+2
-countbase:
-       .=.+2
-.data
-       .=.+2
+
+
diff --git a/usr/src/libc/gen/abort.s b/usr/src/libc/gen/abort.s
deleted file mode 100644 (file)
index 6bdb9ad..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/ C library -- abort
-
-.globl _abort
-iot    = 4
-.globl csv,cret
-
-_abort:
-       jsr     r5,csv
-       iot
-       clr     r0
-       jmp     cret
diff --git a/usr/src/libc/gen/abs.c b/usr/src/libc/gen/abs.c
deleted file mode 100644 (file)
index 618e625..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-abs(arg)
-{
-
-       if(arg < 0)
-               arg = -arg;
-       return(arg);
-}
index 608de64..2818907 100644 (file)
@@ -1,98 +1,49 @@
-/*
-       C library - ascii to floating
-*/
-
-#include <math.h>
-#include <ctype.h>
-
-double
-atof(p)
-register char *p;
-{
-       register c;
-       double fl, flexp, exp5;
-       double big = 72057594037927936.;  /*2^56*/
-       double ldexp();
-       int nd;
-       register eexp, exp, neg, negexp, bexp;
-
-       neg = 1;
-       while((c = *p++) == ' ')
-               ;
-       if (c == '-')
-               neg = -1;
-       else if (c=='+')
-               ;
-       else
-               --p;
-
-       exp = 0;
-       fl = 0;
-       nd = 0;
-       while ((c = *p++), isdigit(c)) {
-               if (fl<big)
-                       fl = 10*fl + (c-'0');
-               else
-                       exp++;
-               nd++;
-       }
-
-       if (c == '.') {
-               while ((c = *p++), isdigit(c)) {
-                       if (fl<big) {
-                               fl = 10*fl + (c-'0');
-                               exp--;
-                       }
-               nd++;
-               }
-       }
-
-       negexp = 1;
-       eexp = 0;
-       if ((c == 'E') || (c == 'e')) {
-               if ((c= *p++) == '+')
-                       ;
-               else if (c=='-')
-                       negexp = -1;
-               else
-                       --p;
-
-               while ((c = *p++), isdigit(c)) {
-                       eexp = 10*eexp+(c-'0');
-               }
-               if (negexp<0)
-                       eexp = -eexp;
-               exp = exp + eexp;
-       }
-
-       negexp = 1;
-       if (exp<0) {
-               negexp = -1;
-               exp = -exp;
-       }
-
-
-       if((nd+exp*negexp) < -LOGHUGE){
-               fl = 0;
-               exp = 0;
-       }
-       flexp = 1;
-       exp5 = 5;
-       bexp = exp;
-       for (;;) {
-               if (exp&01)
-                       flexp *= exp5;
-               exp >>= 1;
-               if (exp==0)
-                       break;
-               exp5 *= exp5;
-       }
-       if (negexp<0)
-               fl /= flexp;
-       else
-               fl *= flexp;
-       fl = ldexp(fl, negexp*bexp);
-       if (neg<0)
-               fl = -fl;
-       return(fl);
+union {
+       short foo0[4];
+       double big;
+} bar0 /* = {0x5c80,0,0,0} */ ; /* 2**56 as double floating point */
+union {
+       short foo1[4];
+       double huge;
+} bar1 /* = {0x8000,0,0,0} */ ; /* reserved operand */
+
+double atof(p) register char *p; {
+register double exp,val;
+register char c; register int dpdig;
+int scale; char sign,esign;
+
+abort(); /* THE REAL ROUTINE IS atofo.s !!!!! */
+while ((c= *p++)==' ');        /* skip leading spaces */
+sign=0;
+if (c=='-') ++sign;    /* mark negative */
+else if (c=='+') ;     /* ignore plus */
+else --p;              /* get back on track */
+
+val=0; dpdig=0;
+/* true value is aproximately  ((-1)**sign) * val * (10 ** dpdig) */
+while ((c= *p++)<='9' && c>='0')
+       if(val<bar0.big) {val *= 10; val += c-'0';}
+       else ++dpdig;
+if (c=='.')
+       while ((c= *p++)<='9' && c>='0')
+               if(val<bar0.big) {--dpdig; val *= 10; val += c-'0';}
+if (sign) val = -val; /* sign has been taken care of, if  val  in range */
+scale=0;
+if (c=='E' || c=='e') {/* scale factor */
+       esign=0;
+       if ((c= *p++)=='-') ++esign;
+       else if (c=='+');
+       else --p;
+       while ((c= *p++)<='9' && c>='0') {scale *= 10; scale += c-'0';}
+       if (esign) scale = -scale;
+}
+dpdig += scale;
+if (dpdig==0) return(val);
+esign=0; if (dpdig<0) {++esign; dpdig = -dpdig;}
+if (dpdig>38) if (esign) return(0); else return(sign? -bar1.huge : bar1.huge);
+exp=1; while (dpdig) {
+       if (dpdig==21) {exp *= 1.0e+21; break;}
+       exp *= 10; --dpdig;
+}
+if (esign) return(val/exp); return(val*exp);
 }
 }
diff --git a/usr/src/libc/gen/atofo.s b/usr/src/libc/gen/atofo.s
new file mode 100644 (file)
index 0000000..4397fe2
--- /dev/null
@@ -0,0 +1,148 @@
+       # optimized (and corrected) from output of C compiler
+       #       -16(fp) --> r0
+       #       -20(fp) --> r8
+       #       -8(fp) --> r6
+       #       -21(fp) --> r5
+       #       -22(fp) --> r4
+       .set    one,010                         # 1.0 in floating immediate format
+       .set    ten,042                         # 10.0 in floating immediate format
+big:   .word   0x5c80,0,0,0            # 2**56 in double floating
+huge:  .word   0x8000,0,0,0            # reserved operand
+L49:   .double 0d1.00000000000000000000e+21
+       .set    .R1,0xff0
+       .set    .F1,24
+       .globl  _atof
+_atof:
+       .word   .R1
+       movl    4(ap),r11
+L15:
+       cvtbl   (r11)+,r10
+       cmpl    r10,$32
+       jeql    L15
+       clrb    r5
+       cmpb    r10,$45
+       jneq    L17
+       incb    r5
+       jbr     L18
+L17:
+       cmpb    r10,$43
+       jeql    L18
+       decl    r11
+L18:
+       clrd    r0
+       clrl    r9
+       jbr     L22
+L20001:
+       muld2   $ten,r0
+       subl3   $48,r10,r6
+       cvtld   r6,r6
+       addd2   r6,r0
+       jbr     L22
+L20003:
+       cmpb    r10,$48
+       jlss    L23
+       cmpd    r0,big
+       jlss    L20001
+       incl    r9
+L22:
+       cvtbl   (r11)+,r10
+       cmpl    r10,$57
+       jleq    L20003
+L23:
+       cmpb    r10,$46
+       jeql    L28
+       jbr     L27
+L20005:
+       cmpb    r10,$48
+       jlss    L27
+       cmpd    r0,big
+       jgeq    L28
+       decl    r9
+       muld2   $ten,r0
+       subl3   $48,r10,r6
+       cvtld   r6,r6
+       addd2   r6,r0
+L28:
+       cvtbl   (r11)+,r10
+       cmpl    r10,$57
+       jleq    L20005
+L27:
+       tstb    r5
+       jeql    L8827
+       mnegd   r0,r0
+L8827:
+       clrl    r8
+       cmpb    r10,$69
+       jeql    L10000
+       cmpb    r10,$101
+       jneq    L32
+L10000:
+       clrb    r4
+       cvtbl   (r11)+,r10
+       cmpl    r10,$45
+       jneq    L33
+       incb    r4
+       jbr     L37
+L33:
+       cmpb    r10,$43
+       jeql    L37
+       decl    r11
+       jbr     L37
+L20007:
+       cmpb    r10,$48
+       jlss    L38
+       moval   (r8)[r8],r8
+       movaw   -48(r10)[r8],r8
+L37:
+       cvtbl   (r11)+,r10
+       cmpl    r10,$57
+       jleq    L20007
+L38:
+       tstb    r4
+       jeql    L32
+       mnegl   r8,r8
+L32:
+       addl2   r8,r9
+       jneq    L40
+       ret
+L40:
+       clrb    r4
+       tstl    r9
+       jgeq    L41
+       incb    r4
+       mnegl   r9,r9
+L41:
+       cmpl    r9,$38
+       jleq    L42
+       tstb    r4
+       jeql    L43
+       clrd    r0
+       ret
+L43:
+       tstb    r5
+       jeql    L8843
+       mnegd   huge,r0
+       ret
+L8843:
+       movd    huge,r0
+       ret
+L42:
+       movd    $one,r6
+       jbr     L46
+L20009:
+       divd2   r6,r0
+       ret
+L48:
+       muld2   $ten,r6
+       decl    r9
+L46:
+       tstl    r9
+       jeql    L47
+       cmpl    r9,$21
+       jneq    L48
+       muld2   L49,r6
+L47:
+       tstb    r4
+       jneq    L20009
+       muld2   r6,r0
+       ret
diff --git a/usr/src/libc/gen/atoi.c b/usr/src/libc/gen/atoi.c
deleted file mode 100644 (file)
index 57c7ff1..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-atoi(p)
-register char *p;
-{
-       register int n;
-       register int f;
-
-       n = 0;
-       f = 0;
-       for(;;p++) {
-               switch(*p) {
-               case ' ':
-               case '\t':
-                       continue;
-               case '-':
-                       f++;
-               case '+':
-                       p++;
-               }
-               break;
-       }
-       while(*p >= '0' && *p <= '9')
-               n = n*10 + *p++ - '0';
-       return(f? -n: n);
-}
diff --git a/usr/src/libc/gen/atos.c b/usr/src/libc/gen/atos.c
new file mode 100644 (file)
index 0000000..5e8012a
--- /dev/null
@@ -0,0 +1,24 @@
+short atoi(ap)
+char *ap;
+{
+       register short  n, c;
+       register char *p;
+       int f;
+
+       p = ap;
+       n = 0;
+       f = 0;
+loop:
+       while(*p == ' ' || *p == '      ')
+               p++;
+       if(*p == '-') {
+               f++;
+               p++;
+               goto loop;
+       }
+       while(*p >= '0' && *p <= '9')
+               n = n*10 + *p++ - '0';
+       if(f)
+               n = -n;
+       return(n);
+}
diff --git a/usr/src/libc/gen/chrtab.c b/usr/src/libc/gen/chrtab.c
new file mode 100644 (file)
index 0000000..4d8a81a
--- /dev/null
@@ -0,0 +1,98 @@
+char   chrtab[][16] = {
+0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, sp, */
+0010,0010,0010,0010,0010,0010,0010,0010,0000,0000,0010,0000,0000,0000,0000,0000, /*, !, */
+0024,0024,0024,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, ", */
+0000,0000,0000,0044,0044,0176,0044,0044,0176,0044,0044,0000,0000,0000,0000,0000, /*, #, */
+0000,0010,0010,0010,0076,0101,0100,0076,0001,0101,0076,0010,0010,0000,0000,0000, /*, $, */
+0000,0000,0000,0141,0142,0004,0010,0010,0020,0043,0103,0000,0000,0000,0000,0000, /*, %, */
+0000,0000,0070,0104,0110,0060,0060,0111,0106,0106,0071,0000,0000,0000,0000,0000, /*, &, */
+0004,0010,0020,0040,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, ', */
+0000,0004,0010,0020,0040,0040,0040,0040,0040,0040,0020,0010,0004,0000,0000,0000, /*, (, */
+0000,0040,0020,0010,0004,0004,0004,0004,0004,0004,0010,0020,0040,0000,0000,0000, /*, ), */
+0000,0000,0000,0010,0111,0052,0034,0177,0034,0052,0111,0010,0000,0000,0000,0000, /*, *, */
+0000,0000,0000,0000,0010,0010,0010,0177,0010,0010,0010,0000,0000,0000,0000,0000, /*, +, */
+0000,0000,0000,0000,0000,0000,0000,0000,0000,0030,0030,0010,0020,0000,0000,0000, /*, ,, */
+0000,0000,0000,0000,0000,0000,0000,0176,0000,0000,0000,0000,0000,0000,0000,0000, /*, -, */
+0000,0000,0000,0000,0000,0000,0000,0000,0000,0030,0030,0000,0000,0000,0000,0000, /*, ., */
+0000,0000,0001,0002,0004,0010,0010,0010,0020,0040,0100,0000,0000,0000,0000,0000, /*, /, */
+0000,0030,0044,0102,0102,0102,0102,0102,0102,0044,0030,0000,0000,0000,0000,0000, /*, 0, */
+0000,0010,0030,0010,0010,0010,0010,0010,0010,0010,0034,0000,0000,0000,0000,0000, /*, 1, */
+0000,0070,0104,0004,0004,0010,0020,0040,0100,0100,0174,0000,0000,0000,0000,0000, /*, 2, */
+0000,0176,0004,0004,0010,0014,0002,0002,0002,0104,0070,0000,0000,0000,0000,0000, /*, 3, */
+0000,0004,0014,0024,0044,0104,0176,0004,0004,0004,0004,0000,0000,0000,0000,0000, /*, 4, */
+0000,0174,0100,0100,0130,0144,0002,0002,0102,0044,0030,0000,0000,0000,0000,0000, /*, 5, */
+0000,0074,0102,0100,0130,0144,0102,0102,0102,0044,0030,0000,0000,0000,0000,0000, /*, 6, */
+0000,0176,0004,0004,0010,0010,0020,0020,0040,0040,0040,0000,0000,0000,0000,0000, /*, 7, */
+0000,0034,0042,0101,0042,0076,0101,0101,0101,0101,0076,0000,0000,0000,0000,0000, /*, 8, */
+0000,0034,0042,0101,0101,0101,0043,0036,0004,0010,0020,0040,0000,0000,0000,0000, /*, 9, */
+0000,0000,0000,0000,0000,0000,0030,0030,0000,0030,0030,0000,0000,0000,0000,0000, /*, :, */
+0000,0000,0000,0000,0000,0000,0030,0030,0000,0030,0030,0020,0040,0000,0000,0000, /*, ;, */
+0002,0004,0010,0020,0040,0100,0040,0020,0010,0004,0002,0000,0000,0000,0000,0000, /*, <, */
+0000,0000,0000,0000,0177,0000,0177,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, =, */
+0100,0040,0020,0010,0004,0002,0004,0010,0020,0040,0100,0000,0000,0000,0000,0000, /*, >, */
+0000,0030,0044,0102,0001,0002,0004,0010,0010,0000,0010,0000,0000,0000,0000,0000, /*, ?, */
+0000,0074,0102,0101,0115,0123,0121,0121,0121,0111,0046,0000,0000,0000,0000,0000, /*, @, */
+0000,0010,0024,0042,0101,0101,0177,0101,0101,0101,0101,0000,0000,0000,0000,0000, /*, A, */
+0000,0176,0101,0101,0101,0176,0101,0101,0101,0101,0176,0000,0000,0000,0000,0000, /*, B, */
+0000,0076,0101,0100,0100,0100,0100,0100,0100,0101,0076,0000,0000,0000,0000,0000, /*, C, */
+0000,0176,0101,0101,0101,0101,0101,0101,0101,0101,0176,0000,0000,0000,0000,0000, /*, D, */
+0000,0176,0100,0100,0100,0170,0100,0100,0100,0100,0177,0000,0000,0000,0000,0000, /*, E, */
+0000,0177,0100,0100,0100,0174,0100,0100,0100,0100,0100,0000,0000,0000,0000,0000, /*, F, */
+0000,0076,0101,0100,0100,0117,0101,0101,0101,0101,0076,0000,0000,0000,0000,0000, /*, G, */
+0000,0101,0101,0101,0101,0176,0101,0101,0101,0101,0101,0000,0000,0000,0000,0000, /*, H, */
+0000,0034,0010,0010,0010,0010,0010,0010,0010,0010,0034,0000,0000,0000,0000,0000, /*, I, */
+0000,0016,0004,0004,0004,0004,0004,0004,0104,0104,0070,0000,0000,0000,0000,0000, /*, J, */
+0000,0101,0102,0104,0110,0120,0160,0110,0104,0102,0101,0000,0000,0000,0000,0000, /*, K, */
+0000,0100,0100,0100,0100,0100,0100,0100,0100,0100,0177,0000,0000,0000,0000,0000, /*, L, */
+0000,0101,0143,0125,0111,0101,0101,0101,0101,0101,0101,0000,0000,0000,0000,0000, /*, M, */
+0000,0101,0141,0121,0111,0105,0103,0101,0101,0101,0101,0000,0000,0000,0000,0000, /*, N, */
+0000,0076,0101,0101,0101,0101,0101,0101,0101,0101,0076,0000,0000,0000,0000,0000, /*, O, */
+0000,0176,0101,0101,0101,0176,0100,0100,0100,0100,0100,0000,0000,0000,0000,0000, /*, P, */
+0000,0076,0101,0101,0101,0101,0101,0101,0131,0105,0076,0002,0001,0000,0000,0000, /*, Q, */
+0000,0176,0101,0101,0101,0176,0104,0102,0101,0101,0101,0000,0000,0000,0000,0000, /*, R, */
+0000,0076,0101,0100,0100,0076,0001,0001,0001,0101,0076,0000,0000,0000,0000,0000, /*, S, */
+0000,0177,0010,0010,0010,0010,0010,0010,0010,0010,0010,0000,0000,0000,0000,0000, /*, T, */
+0000,0101,0101,0101,0101,0101,0101,0101,0101,0101,0076,0000,0000,0000,0000,0000, /*, U, */
+0000,0101,0101,0101,0101,0101,0101,0101,0042,0024,0010,0000,0000,0000,0000,0000, /*, V, */
+0000,0101,0101,0101,0101,0111,0111,0125,0143,0101,0101,0000,0000,0000,0000,0000, /*, W, */
+0000,0101,0101,0042,0024,0010,0024,0042,0101,0101,0101,0000,0000,0000,0000,0000, /*, X, */
+0000,0101,0042,0024,0010,0010,0010,0010,0010,0010,0010,0000,0000,0000,0000,0000, /*, Y, */
+0000,0177,0001,0002,0004,0010,0020,0040,0100,0100,0177,0000,0000,0000,0000,0000, /*, Z, */
+0000,0034,0020,0020,0020,0020,0020,0020,0020,0020,0020,0034,0000,0000,0000,0000, /*, [, */
+0000,0000,0100,0040,0020,0010,0010,0010,0004,0002,0001,0000,0000,0000,0000,0000, /*, , \, */
+0000,0070,0010,0010,0010,0010,0010,0010,0010,0010,0010,0070,0000,0000,0000,0000, /*, ], */
+0010,0024,0042,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, ^, */
+0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0377,0000,0000, /*, _, */
+0040,0020,0010,0004,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, `, */
+0000,0000,0000,0000,0000,0074,0002,0076,0102,0102,0076,0000,0000,0000,0000,0000, /*, a, */
+0000,0100,0100,0100,0100,0174,0102,0102,0102,0102,0174,0000,0000,0000,0000,0000, /*, b, */
+0000,0000,0000,0000,0000,0074,0102,0100,0100,0102,0074,0000,0000,0000,0000,0000, /*, c, */
+0002,0002,0002,0002,0002,0076,0102,0102,0102,0102,0076,0000,0000,0000,0000,0000, /*, d, */
+0000,0000,0000,0000,0000,0074,0102,0174,0100,0102,0074,0000,0000,0000,0000,0000, /*, e, */
+0000,0016,0020,0020,0020,0176,0020,0020,0020,0020,0020,0000,0000,0000,0000,0000, /*, f, */
+0000,0000,0000,0000,0000,0076,0102,0102,0102,0102,0076,0002,0002,0102,0076,0000, /*, g, */
+0000,0100,0100,0100,0100,0174,0102,0102,0102,0102,0102,0000,0000,0000,0000,0000, /*, h, */
+0000,0000,0000,0010,0000,0030,0010,0010,0010,0010,0034,0000,0000,0000,0000,0000, /*, i, */
+0000,0000,0000,0010,0000,0030,0010,0010,0010,0010,0010,0010,0010,0050,0020,0000, /*, j, */
+0000,0100,0100,0100,0100,0106,0110,0120,0160,0110,0106,0000,0000,0000,0000,0000, /*, k, */
+0000,0030,0010,0010,0010,0010,0010,0010,0010,0010,0034,0000,0000,0000,0000,0000, /*, l, */
+0000,0000,0000,0000,0000,0166,0111,0111,0111,0111,0111,0000,0000,0000,0000,0000, /*, m, */
+0000,0000,0000,0000,0100,0174,0102,0102,0102,0102,0102,0000,0000,0000,0000,0000, /*, n, */
+0000,0000,0000,0000,0000,0074,0102,0102,0102,0102,0074,0000,0000,0000,0000,0000, /*, o, */
+0000,0000,0000,0000,0000,0174,0102,0102,0102,0102,0174,0100,0100,0100,0100,0000, /*, p, */
+0000,0000,0000,0000,0000,0076,0102,0102,0102,0102,0076,0002,0002,0002,0002,0000, /*, q, */
+0000,0000,0000,0000,0000,0134,0142,0100,0100,0100,0100,0000,0000,0000,0000,0000, /*, r, */
+0000,0000,0000,0000,0000,0076,0100,0074,0002,0102,0074,0000,0000,0000,0000,0000, /*, s, */
+0000,0020,0020,0020,0020,0176,0020,0020,0020,0020,0014,0000,0000,0000,0000,0000, /*, t, */
+0000,0000,0000,0000,0000,0102,0102,0102,0102,0102,0075,0000,0000,0000,0000,0000, /*, u, */
+0000,0000,0000,0000,0000,0101,0101,0101,0042,0024,0010,0000,0000,0000,0000,0000, /*, v, */
+0000,0000,0000,0000,0000,0111,0111,0111,0111,0111,0066,0000,0000,0000,0000,0000, /*, w, */
+0000,0000,0000,0000,0000,0102,0044,0030,0030,0044,0102,0000,0000,0000,0000,0000, /*, x, */
+0000,0000,0000,0000,0000,0102,0102,0102,0042,0024,0010,0020,0040,0100,0000,0000, /*, y, */
+0000,0000,0000,0000,0000,0176,0004,0010,0020,0040,0176,0000,0000,0000,0000,0000, /*, z, */
+0000,0014,0020,0020,0020,0020,0040,0020,0020,0020,0020,0014,0000,0000,0000,0000, /*, {, */
+0000,0010,0010,0010,0010,0000,0000,0010,0010,0010,0010,0000,0000,0000,0000,0000, /*, |, */
+0000,0030,0010,0010,0010,0010,0004,0010,0010,0010,0010,0030,0000,0000,0000,0000, /*, }, */
+0020,0052,0004,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000, /*, ~, */
+0000,0176,0176,0176,0176,0176,0176,0176,0176,0176,0176,0000,0000,0000,0000,0000, /*, del, */
+};
index 85464d5..164fd5c 100644 (file)
@@ -46,7 +46,7 @@ static        char    PC1_C[] = {
        19,11, 3,60,52,44,36,
 };
 
        19,11, 3,60,52,44,36,
 };
 
-static char    PC1_D[] {
+static char    PC1_D[] {
        63,55,47,39,31,23,15,
         7,62,54,46,38,30,22,
        14, 6,61,53,45,37,29,
        63,55,47,39,31,23,15,
         7,62,54,46,38,30,22,
        14, 6,61,53,45,37,29,
@@ -143,7 +143,7 @@ char *key;
  * The E bit-selection table.
  */
 static char    E[48];
  * The E bit-selection table.
  */
 static char    E[48];
-static char    e[] {
+static char    e[] {
        32, 1, 2, 3, 4, 5,
         4, 5, 6, 7, 8, 9,
         8, 9,10,11,12,13,
        32, 1, 2, 3, 4, 5,
         4, 5, 6, 7, 8, 9,
         8, 9,10,11,12,13,
@@ -159,7 +159,7 @@ static      char    e[] {
  * For some reason, they give a 0-origin
  * index, unlike everything else.
  */
  * For some reason, they give a 0-origin
  * index, unlike everything else.
  */
-static char    S[8][64] {
+static char    S[8][64] {
        14, 4,13, 1, 2,15,11, 8, 3,10, 6,12, 5, 9, 0, 7,
         0,15, 7, 4,14, 2,13, 1,10, 6,12,11, 9, 5, 3, 8,
         4, 1,14, 8,13, 6, 2,11,15,12, 9, 7, 3,10, 5, 0,
        14, 4,13, 1, 2,15,11, 8, 3,10, 6,12, 5, 9, 0, 7,
         0,15, 7, 4,14, 2,13, 1,10, 6,12,11, 9, 5, 3, 8,
         4, 1,14, 8,13, 6, 2,11,15,12, 9, 7, 3,10, 5, 0,
@@ -205,7 +205,7 @@ static      char    S[8][64] {
  * P is a permutation on the selected combination
  * of the current L and key.
  */
  * P is a permutation on the selected combination
  * of the current L and key.
  */
-static char    P[] {
+static char    P[] {
        16, 7,20,21,
        29,12,28,17,
         1,15,23,26,
        16, 7,20,21,
        29,12,28,17,
         1,15,23,26,
diff --git a/usr/src/libc/gen/cuexit.s b/usr/src/libc/gen/cuexit.s
deleted file mode 100644 (file)
index f4ffb99..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/ C library -- exit
-
-/ exit(code)
-/ code is return in r0 to system
-
-.globl _exit
-.globl __cleanup
-exit = 1
-
-_exit:
-       mov     r5,-(sp)
-       mov     sp,r5
-       jsr     pc,__cleanup
-       mov     4(r5),r0
-       sys     exit
-
diff --git a/usr/src/libc/gen/fakcu.s b/usr/src/libc/gen/fakcu.s
deleted file mode 100644 (file)
index f8d74f6..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-/
-/ dummy cleanup routine if none supplied by user.
-
-.globl __cleanup
-
-__cleanup:
-       rts     pc
diff --git a/usr/src/libc/gen/fakfp.s b/usr/src/libc/gen/fakfp.s
deleted file mode 100644 (file)
index 6af0922..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/ fakefp -- fake floating point simulator
-
-.globl fptrap
-signal = 48.
-rti = 2
-
-fptrap:
-       sub     $2,(sp)
-       mov     r0,-(sp)
-       sys     signal; 4; 0
-       mov     (sp)+,r0
-       rti
diff --git a/usr/src/libc/gen/frexp.c b/usr/src/libc/gen/frexp.c
new file mode 100644 (file)
index 0000000..8d9425a
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+       the call
+               x = frexp(arg,&exp);
+       must return a double fp quantity x which is <1.0
+       and the corresponding binary exponent "exp".
+       such that
+               arg = x*2^exp
+*/
+
+double
+frexp(x,i)
+double x;
+int *i;
+{
+       int neg;
+       int j;
+       j = 0;
+       neg = 0;
+       if(x<0){
+               x = -x;
+               neg = 1;
+               }
+       if(x>1.0)
+               while(x>1){
+                       j = j+1;
+                       x = x/2;
+                       }
+       else if(x<0.5)
+               while(x<0.5){
+                       j = j-1;
+                       x = 2*x;
+                       }
+       *i = j;
+       if(neg) x = -x;
+       return(x);
+       }
diff --git a/usr/src/libc/gen/frexp11.s b/usr/src/libc/gen/frexp11.s
deleted file mode 100644 (file)
index 46fc518..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/  double frexp(x, ip)
-/  double x; int *ip;
-/  returns a fractional part 1/16 <= |value| < 1
-/ and stores an exponent so x = value * 2^(*ip)
-
-.globl _frexp
-.globl csv, cret
-
-_frexp:
-       jsr     r5,csv
-       movf    4(r5),fr0
-       movei   fr0,r0
-       clr     r1
-       movie   r1,fr0
-       mov     r0,*12.(r5)
-       jmp     cret
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/usr/src/libc/gen/l3.c b/usr/src/libc/gen/l3.c
deleted file mode 100644 (file)
index 623f9c9..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Convert longs to and from 3-byte disk addresses
- */
-ltol3(cp, lp, n)
-char   *cp;
-long   *lp;
-int    n;
-{
-       register i;
-       register char *a, *b;
-
-       a = cp;
-       b = (char *)lp;
-       for(i=0;i<n;i++) {
-#ifdef interdata
-               b++;
-               *a++ = *b++;
-               *a++ = *b++;
-               *a++ = *b++;
-#else
-               *a++ = *b++;
-               b++;
-               *a++ = *b++;
-               *a++ = *b++;
-#endif
-       }
-}
-
-l3tol(lp, cp, n)
-long   *lp;
-char   *cp;
-int    n;
-{
-       register i;
-       register char *a, *b;
-
-       a = (char *)lp;
-       b = cp;
-       for(i=0;i<n;i++) {
-#ifdef interdata
-               *a++ = 0;
-               *a++ = *b++;
-               *a++ = *b++;
-               *a++ = *b++;
-#else
-               *a++ = *b++;
-               *a++ = 0;
-               *a++ = *b++;
-               *a++ = *b++;
-#endif
-       }
-}
diff --git a/usr/src/libc/gen/l3tol.c b/usr/src/libc/gen/l3tol.c
new file mode 100644 (file)
index 0000000..645d486
--- /dev/null
@@ -0,0 +1,24 @@
+l3tol(lp, cp, n)
+long   *lp;
+char   *cp;
+int    n;
+{
+       register i;
+       register char *a, *b;
+
+       a = (char *)lp;
+       b = cp;
+       for(i=0;i<n;i++) {
+#ifdef interdata
+               *a++ = 0;
+               *a++ = *b++;
+               *a++ = *b++;
+               *a++ = *b++;
+#else
+               *a++ = *b++;
+               *a++ = *b++;
+               *a++ = *b++;
+               *a++ = 0;
+#endif
+       }
+}
diff --git a/usr/src/libc/gen/ldexp.c b/usr/src/libc/gen/ldexp.c
new file mode 100644 (file)
index 0000000..e306ca9
--- /dev/null
@@ -0,0 +1,40 @@
+double
+ldexp(fr,exp) double fr; int exp;{
+double huge    = 1.701411834604692293e38;
+       int neg;
+       int i;
+       double frexp();
+
+       neg = 0;
+       if(fr<0){
+               fr = -fr;
+               neg = 1;
+               }
+       fr = frexp(fr,&i);
+       while(fr<.5){
+               fr = 2*fr;
+               i = i-1;
+               }
+       exp = exp+i;
+       if(exp>127)
+               if(neg)
+                       return(-huge);
+               else
+                       return(huge);
+       if(exp<-127)
+               return(0);
+       while(exp>30){
+               fr = fr*(1L<<30);
+               exp = exp-30;
+               }
+       while(exp<-30){
+               fr = fr/(1L<<30);
+               exp = exp+30;
+               }
+       if(exp>0)
+               fr = fr*(1L<<exp);
+       if(exp<0)
+               fr = fr/(1L<<-exp);
+       if(neg) fr = -fr;
+       return(fr);
+       }
diff --git a/usr/src/libc/gen/ldexp11.s b/usr/src/libc/gen/ldexp11.s
deleted file mode 100644 (file)
index 1abb9d5..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/ double ldexp(number, exp)
-/ double number
-/  -- returns number * 2^exp
-
-.globl _ldexp
-.globl csv, cret
-
-ERANGE = 34.
-
-_ldexp:
-       jsr     r5,csv
-       movf    4(r5),fr0
-       movei   fr0,r0
-       add     12.(r5),r0
-       movie   r0,fr0
-       cfcc
-       bvc     1f
-       bmi     2f
-       movf    huge,fr0
-       br      3f
-2:
-       movf    huge,fr0
-       negf    fr0
-3:
-       mov     $ERANGE,_errno
-1:
-       jmp     cret
-
-       .comm   _errno,2
-       .data
-huge:  077777; 0177776; 0177777; 0177777
diff --git a/usr/src/libc/gen/ldfps.s b/usr/src/libc/gen/ldfps.s
deleted file mode 100644 (file)
index 800cf62..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-ldfps = 170100^tst
-/
-/ ldfps(number);
-
-.globl _ldfps
-_ldfps:
-       mov     r5,-(sp)
-       mov     sp,r5
-       ldfps   4(r5)
-       mov     (sp)+,r5
-       rts     pc
diff --git a/usr/src/libc/gen/ltol3.c b/usr/src/libc/gen/ltol3.c
new file mode 100755 (executable)
index 0000000..09489a7
--- /dev/null
@@ -0,0 +1,24 @@
+ltol3(cp, lp, n)
+char   *cp;
+long   *lp;
+int    n;
+{
+       register i;
+       register char *a, *b;
+
+       a = cp;
+       b = (char *)lp;
+       for(i=0;i<n;i++) {
+#ifdef interdata
+               b++;
+               *a++ = *b++;
+               *a++ = *b++;
+               *a++ = *b++;
+#else
+               *a++ = *b++;
+               *a++ = *b++;
+               *a++ = *b++;
+               b++;
+#endif
+       }
+}
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/usr/src/libc/gen/modf.c b/usr/src/libc/gen/modf.c
new file mode 100644 (file)
index 0000000..32acfa5
--- /dev/null
@@ -0,0 +1,46 @@
+double
+modf(arg,ent)
+double arg;
+double *ent;
+{
+       int neg;
+       int i;
+       double two30 = 1073741824.;
+       double big = 72057594037927936.;  /*2^56*/
+       double x, temp;
+       double ldexp();
+       double frexp();
+       long l;
+
+       neg = 1;
+       if(arg<0){
+               neg = -1;
+               arg = -arg;
+               }
+       if(arg>big){
+               *ent = neg*arg;
+               return(0);
+               }
+       if(arg<1){
+               *ent = 0;
+               return(neg*arg);
+               }
+
+       temp = 0;
+       while(arg>two30){
+               x = frexp(arg,&i);
+               if(arg<0.5){
+                       arg = 2*arg;
+                       i = i-1;
+                       }
+               x = ldexp(0.5,i);
+               arg = arg - x;
+               temp = temp + x;
+               }
+
+       l = arg;
+       arg = arg-l;
+       temp = temp+l;
+       *ent = neg*temp;
+       return(neg*arg);
+       }
diff --git a/usr/src/libc/gen/modf11.s b/usr/src/libc/gen/modf11.s
deleted file mode 100644 (file)
index cec82ca..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/ double modf(x, *fp)
-/ double x, *fp;
-/ return fractional part
-/ stash integer part (as double)
-
-.globl _modf
-.globl csv, cret
-one    = 040200
-
-_modf:
-       jsr     r5,csv
-       movf    4(r5),fr0
-       modf    $one,fr0
-       movf    fr1,*12.(r5)
-       jmp     cret
old mode 100644 (file)
new mode 100755 (executable)
index eacafdf..a906c65
@@ -4,27 +4,37 @@ int *buf, bufsiz;
 {
        register o;
        static *sbuf, ssiz;
 {
        register o;
        static *sbuf, ssiz;
+       struct phdr {
+               int *lpc;
+               int *hpc;
+               int ncnt;
+       };
+       struct cnt {
+               int *pc;
+               long ncall;
+       };
 
        if (lowpc == 0) {
                profil(0, 0, 0, 0);
                o = creat("mon.out", 0666);
 
        if (lowpc == 0) {
                profil(0, 0, 0, 0);
                o = creat("mon.out", 0666);
-               write(o, sbuf, ssiz<<1);
+               write(o, sbuf, ssiz);
                close(o);
                return;
        }
                close(o);
                return;
        }
+       sbuf = buf;
        ssiz = bufsiz;
        buf[0] = (int)lowpc;
        buf[1] = (int)highpc;
        buf[2] = cntsiz;
        ssiz = bufsiz;
        buf[0] = (int)lowpc;
        buf[1] = (int)highpc;
        buf[2] = cntsiz;
-       sbuf = buf;
-       buf += 3*(cntsiz+1);
-       bufsiz -= 3*(cntsiz+1);
+       o = sizeof(struct phdr) + cntsiz*sizeof(struct cnt);
+       buf = (int *) (((int)buf) + o);
+       bufsiz -= o;
        if (bufsiz<=0)
                return;
        o = ((highpc - lowpc)>>1) & 077777;
        if(bufsiz < o)
                o = ((long)bufsiz<<15) / o;
        else
        if (bufsiz<=0)
                return;
        o = ((highpc - lowpc)>>1) & 077777;
        if(bufsiz < o)
                o = ((long)bufsiz<<15) / o;
        else
-               o = 077777;
-       profil(buf, bufsiz<<1, lowpc, o<<1);
+               o = 0177777;
+       profil(buf, bufsiz, lowpc, o);
 }
 }
diff --git a/usr/src/libc/gen/mpx.c b/usr/src/libc/gen/mpx.c
deleted file mode 100644 (file)
index e42a649..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-#include <sys/param.h>
-#include <sys/tty.h>
-#include <sys/mx.h>
-
-static struct mx_args vec;
-int    mpxcall();
-
-
-mpx(name,mode)
-char *name;
-{
-       if (*name) {
-               vec.m_name = name;
-               vec.m_arg[0] = mode;
-               return(mpxcall(MPX, &vec));
-       } else
-               return(mpxcall(MPXN, 0));
-}
-
-chan(gr)
-{
-       vec.m_arg[1] = gr;
-       return(mpxcall(CHAN, &vec));
-}
-
-join(fd,ch)
-{
-       vec.m_arg[0] = fd;
-       vec.m_arg[1] = ch;
-       return(mpxcall(JOIN, &vec));
-}
-
-connect(fd,ch,side)
-{
-       vec.m_arg[0] = fd;
-       vec.m_arg[1] = ch;
-       vec.m_arg[2] = side;
-       return(mpxcall(CONNECT, &vec));
-}
-
-attach(sub,gp)
-{
-       vec.m_arg[0] = sub;
-       vec.m_arg[1] = gp;
-       return(mpxcall(ATTACH, &vec));
-}
-
-detach(sub,gp)
-{
-       vec.m_arg[0] = sub;
-       vec.m_arg[1] = gp;
-       return(mpxcall(DETACH, &vec));
-}
-
-extract(sub,ch,side)
-{
-       vec.m_arg[0] = sub;
-       vec.m_arg[1] = ch;
-       vec.m_arg[2] = side;
-       return(mpxcall(EXTR, &vec));
-}
-
-debug(var,val)
-{
-       vec.m_arg[0] = var;
-       vec.m_arg[1] = val;
-       return(mpxcall(DEBUG, &vec));
-}
-
-npgrp(ch, gfd, pid)
-{
-       vec.m_arg[0] = ch;
-       vec.m_arg[1] = gfd;
-       vec.m_arg[2] = pid;
-       return(mpxcall(NPGRP, &vec));
-}
-ckill(index,gp,sig)
-{
-       vec.m_arg[0] = index;
-       vec.m_arg[1] = gp;
-       vec.m_arg[2] = sig;
-       return(mpxcall(CSIG, &vec));
-}
old mode 100644 (file)
new mode 100755 (executable)
index 3701df7..f5c8c14
@@ -27,7 +27,7 @@ struct nlist *list;
                return(-1);
        }
        sa = buf.a_text + (long)buf.a_data;
                return(-1);
        }
        sa = buf.a_text + (long)buf.a_data;
-       if(buf.a_flag != 1) sa *= 2;
+       sa += buf.a_trsize + buf.a_drsize;
        sa += sizeof buf;
        lseek(f, sa, 0);
        n = buf.a_syms;
        sa += sizeof buf;
        lseek(f, sa, 0);
        n = buf.a_syms;
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/usr/src/libc/gen/pkon.c b/usr/src/libc/gen/pkon.c
deleted file mode 100644 (file)
index a91bd5e..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#include <sgtty.h>
-
-struct piocb {
-       unsigned t;
-       short   psize;
-       short   mode;
-       short   state;
-       char    window;
-};
-pkon(fd, size)
-{
-       if (size&037 || size > 128) {
-               write(2,"bad packet size\n",16);
-               return(-1);
-       }
-       return(turnon(fd, size, 2, 0));
-}
-turnon(fd,psize,window,mode)
-{
-struct piocb p;
-
-       p.window = window;
-       p.psize = psize;
-       p.mode = mode;
-       p.t = 1;
-       if (ioctl(fd,TIOCSETD,&p) < 0 || ioctl(fd,DIOCGETP,&p) < 0) {
-               return(-1);
-       }
-       return(p.psize);
-}
-
-pkoff(fd)
-{
-struct piocb p;
-
-       close(fd);
-       return;
-/*
-       p.t = 0;
-       return(ioctl(fd,TIOCSETD,&p));
-*/
-}
old mode 100644 (file)
new mode 100755 (executable)
index 01afa99..eff6735 100644 (file)
@@ -8,5 +8,5 @@ unsigned x;
 
 rand()
 {
 
 rand()
 {
-       return(((randx = randx*1103515245 + 12345)>>16) & 077777);
+       return((randx = randx * 1103515245 + 12345) & 0x7fffffff);
 }
 }
diff --git a/usr/src/libc/gen/rin.c b/usr/src/libc/gen/rin.c
new file mode 100755 (executable)
index 0000000..1f12da3
--- /dev/null
@@ -0,0 +1,35 @@
+#include <stdio.h>
+
+rin()
+{
+       double d;
+       register n, c, f;
+
+       d = 0.;
+       f = 0;
+       n = 0;
+loop:
+       c = getchar();
+       if(c == EOF)
+               exit();
+       if(c == '-') {
+               f++;
+               goto loop;
+       }
+       if(c == '.') {
+               n++;
+               goto loop;
+       }
+       if(isdigit(c)) {
+               if(n)
+                       n++;
+               d = d*10.+c-'0';
+               goto loop;
+       }
+       if(f)
+               d = -d;
+       for(f=1; f<n; f++)
+               d /= 10.;
+       n = d;
+       return(n);
+}
diff --git a/usr/src/libc/gen/setjmp.s b/usr/src/libc/gen/setjmp.s
deleted file mode 100644 (file)
index 00dabcd..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/ C library -- setjmp, longjmp
-
-/      longjmp(a,v)
-/ will generate a "return(v)" from
-/ the last call to
-/      setjmp(a)
-/ by restoring sp, r5, pc from `a'
-/ and doing a return.
-/
-
-.globl _setjmp
-.globl _longjmp
-.globl csv, cret
-
-_setjmp:
-       mov     2(sp),r0
-       mov     r5,(r0)+
-       mov     sp,(r0)+
-       mov     (sp),(r0)
-       clr     r0
-       rts     pc
-
-_longjmp:
-       jsr     r5,csv
-       mov     4(r5),r1
-       mov     6(r5),r0
-       bne     1f
-       mov     $1,r0
-1:
-       cmp     (r5),(r1)
-       beq     1f
-       mov     (r5),r5
-       bne     1b
-/ panic -- r2-r4 lost
-       mov     (r1)+,r5
-       mov     (r1)+,sp
-       mov     (r1),(sp)
-       rts     pc
-1:
-       mov     4(r1),2(r5)
-       jmp     cret
-
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/usr/src/libc/gen/strcatn.c b/usr/src/libc/gen/strcatn.c
new file mode 100644 (file)
index 0000000..80e4a99
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Concatenate s2 on the end of s1.  S1's space must be large enough.
+ * At most n characters are moved.
+ * Return s1.
+ */
+
+char *
+strcatn(s1, s2, n)
+register char *s1, *s2;
+register n;
+{
+       register char *os1;
+
+       os1 = s1;
+       while (*s1++)
+               ;
+       --s1;
+       while (*s1++ = *s2++)
+               if (--n < 0) {
+                       *--s1 = '\0';
+                       break;
+               }
+       return(os1);
+}
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/usr/src/libc/gen/strcmpn.c b/usr/src/libc/gen/strcmpn.c
new file mode 100644 (file)
index 0000000..625fd15
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Compare strings (at most n bytes):  s1>s2: >0  s1==s2: 0  s1<s2: <0
+ */
+
+strcmpn(s1, s2, n)
+register char *s1, *s2;
+register n;
+{
+
+       while (--n >= 0 && *s1 == *s2++)
+               if (*s1++ == '\0')
+                       return(0);
+       return(n<0 ? 0 : *s1 - *--s2);
+}
diff --git a/usr/src/libc/gen/strcpyn.c b/usr/src/libc/gen/strcpyn.c
new file mode 100644 (file)
index 0000000..eebf2ac
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copy s2 to s1, truncating or null-padding to always copy n bytes
+ * return s1
+ */
+
+char *
+strcpyn(s1, s2, n)
+register char *s1, *s2;
+{
+       register i;
+       register char *os1;
+
+       os1 = s1;
+       for (i = 0; i < n; i++)
+               if ((*s1++ = *s2++) == '\0') {
+                       while (++i < n)
+                               *s1++ = '\0';
+                       return(os1);
+               }
+       return(os1);
+}
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/usr/src/libc/gen/ttytest.c b/usr/src/libc/gen/ttytest.c
new file mode 100644 (file)
index 0000000..de49f2f
--- /dev/null
@@ -0,0 +1,5 @@
+#include "stdio.h"
+main() {
+printf("\nttyname(fd)=%s\n", ttyname(0));
+printf("\nttyname=%s\n", ttyname(stdin));
+}
diff --git a/usr/src/libc/mklib b/usr/src/libc/mklib
deleted file mode 100755 (executable)
index 56ecefe..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-ar rc libc.a \
-getgrgid.o \
-getgrnam.o \
-getgrent.o \
-getpass.o \
-getpwnam.o \
-getpwuid.o \
-getpwent.o \
-timezone.o \
-fgetc.o \
-fputc.o \
-getchar.o \
-putchar.o \
-popen.o \
-freopen.o \
-fgets.o \
-fputs.o \
-getpw.o \
-fseek.o \
-ftell.o \
-rew.o \
-rdwr.o \
-system.o \
-fopen.o \
-fdopen.o \
-scanf.o \
-doscan.o \
-fprintf.o \
-gets.o \
-getw.o \
-printf.o \
-puts.o \
-putw.o \
-sprintf.o \
-ungetc.o \
-filbuf.o \
-setbuf.o \
-fltpr.o \
-doprnt.o \
-gcvt.o \
-ffltpr.o \
-strout.o \
-flsbuf.o \
-endopen.o \
-findiop.o \
-clrerr.o \
-data.o \
-cuexit.o \
-execvp.o \
-getenv.o \
-getlogin.o \
-perror.o \
-sleep.o \
-ttyslot.o \
-ttyname.o \
-abort.o \
-abs.o \
-atof.o \
-atoi.o \
-atol.o \
-crypt.o \
-ctime.o \
-calloc.o \
-malloc.o \
-ecvt.o \
-errlst.o \
-fakcu.o \
-fakfp.o \
-frexp11.o \
-isatty.o \
-l3.o \
-ldexp11.o \
-ldfps.o \
-mktemp.o \
-modf11.o \
-mon.o \
-mpx.o \
-nlist.o \
-qsort.o \
-rand.o \
-setjmp.o \
-stty.o \
-swab.o \
-tell.o \
-ctype_.o \
-index.o \
-rindex.o \
-strcat.o \
-strncat.o \
-strcmp.o \
-strncmp.o \
-strcpy.o \
-strncpy.o \
-strlen.o \
-access.o \
-acct.o \
-alarm.o \
-chdir.o \
-chroot.o \
-chmod.o \
-chown.o \
-close.o \
-creat.o \
-dup.o \
-execl.o \
-execle.o \
-execv.o \
-execve.o \
-exit.o \
-fork.o \
-fstat.o \
-getgid.o \
-getpid.o \
-getuid.o \
-ioctl.o \
-kill.o \
-link.o \
-lock.o \
-lseek.o \
-mknod.o \
-mount.o \
-mpxcall.o \
-nice.o \
-open.o \
-pause.o \
-phys.o \
-pipe.o \
-profil.o \
-ptrace.o \
-read.o \
-sbrk.o \
-setgid.o \
-setuid.o \
-signal.o \
-stat.o \
-stime.o \
-sync.o \
-time.o \
-times.o \
-umask.o \
-umount.o \
-unlink.o \
-utime.o \
-wait.o \
-write.o \
-aldiv.o \
-almul.o \
-alrem.o \
-cerror.o \
-ldiv.o \
-lmul.o \
-lrem.o \
-mcount.o \
-csv.o
diff --git a/usr/src/libc/stdio/Makefile b/usr/src/libc/stdio/Makefile
new file mode 100644 (file)
index 0000000..a4a435a
--- /dev/null
@@ -0,0 +1,32 @@
+CFLAGS=-O -I/usr/gks/11/usr/include
+
+o=getgrgid.o getgrnam.o getgrent.o getpwnam.o getpwuid.o getpwent.o\
+intss.o getchar.o putchar.o fgetc.o fputc.o freopen.o fdopen.o\
+fgets.o fputs.o getpw.o fseek.o rew.o rdwr.o stuff.o\
+system.o tmpnam.o popen.o fopen.o scanf.o doscan.o\
+fprintf.o gets.o getw.o printf.o puts.o putw.o\
+sprintf.o ungetc.o filbuf.o setbuf.o doprnt.o ffltpr.o\
+strout.o flsbuf.o error.o ftell.o gcvt.o clrerr.o\
+data.o    
+
+libS.a : $o
+       ar cr libS.a $o
+
+clean :
+       rm -f *.o
+
+doprnt.o :
+       cp doprnt.s doprnt.c
+       cc -E doprnt.c | as -o doprnt.o
+       -ld -x -r doprnt.o
+       mv a.out doprnt.o
+       rm doprnt.c
+
+.c.o :
+       cc $(CFLAGS) -c $*.c
+       -ld -x -r $*.o
+       mv a.out $*.o
+
+.s.o :
+       as -o $*.o $*.s
+
index 56141c4..85c559e 100644 (file)
@@ -2,12 +2,12 @@
 char   _sibuf[BUFSIZ];
 char   _sobuf[BUFSIZ];
 
 char   _sibuf[BUFSIZ];
 char   _sobuf[BUFSIZ];
 
-struct _iobuf  _iob[_NFILE] = {
-       { _sibuf, 0, _sibuf, _IOREAD, 0},
-       { NULL, 0, NULL, _IOWRT, 1},
-       {NULL, 0, NULL, _IOWRT+_IONBF, 2},
+struct _iobuf  _iob[_NFILE] ={
+       { 0, _sibuf, _sibuf, _IOREAD, 0},
+       { 0, NULL, NULL, _IOWRT, 1},
+       { 0, NULL, NULL, _IOWRT+_IONBF, 2},
 };
 /*
  * Ptr to end of buffers
  */
 };
 /*
  * Ptr to end of buffers
  */
-struct _iobuf  *_lastbuf = { &_iob[_NFILE] };
+struct _iobuf  *_lastbuf ={ &_iob[_NFILE] };
index bed67a0..909641a 100644 (file)
-/ C library -- conversions
+       # C library -- conversions
 
 
-width=-8.
-formp=-10.
-rjust=-12.
-ndfnd=-14.
-ndigit=-16.
-zfill=-18.
 .globl __doprnt
 .globl __doprnt
-
-.globl pfloat
-.globl pscien
-.globl pgen
-
 .globl __strout
 .globl __strout
-.globl csv
-.globl cret
 
 
+#define flags r10
+#define literb 0
+#define liter 1
+#define ndfndb 0
+#define ndfnd 1
+#define ljustb 1
+#define ljust 2
+#define zfillb 2
+#define zfill 4
+#define precb 3
+#define prec 8
+#define psignb 4
+#define psign 16
+#define gflagb 5
+#define gflag 32
+#define width r9
+#define ndigit r8
+#define fdesc -4(fp)
+#define exp -8(fp)
+#define sign -9(fp)
+       .set one,010                    # 1.0 in floating immediate
+       .set ch.zer,'0                  # cpp doesn't like single appostrophes
+
+       .align  1
 __doprnt:
 __doprnt:
-       jsr     r5,csv
-       sub     $128.+12.,sp
-       mov     4(r5),formp(r5)         / format
-       mov     6(r5),r4
+       .word   0xfc0                   # uses r11-r6
+       subl2 $128,sp
+       movl 4(ap),r11                  # addr of format string
+       movl 12(ap),fdesc               # output FILE ptr
+       movl 8(ap),ap                   # addr of first arg
 loop:
 loop:
-       mov     sp,r3
-       mov     formp(r5),r1
-2:
-       movb    (r1)+,r2
-       beq     2f
-       cmp     r2,$'%
-       beq     2f
-       movb    r2,(r3)+
-       br      2b
-2:
-       mov     r1,formp(r5)
-       cmp     r3,sp
-       beq     2f
-       mov     sp,r0
-       mov     8(r5),-(sp)
-       clr     -(sp)
-       mov     r3,-(sp)
-       sub     r0,(sp)
-       mov     r0,-(sp)
-       jsr     pc,__strout
-       add     $8,sp
-2:
-       tst     r2
-       bne     2f
-       jmp     cret
-2:
-       mov     sp,r3
-2:
-       clr     rjust(r5)
-       clr     ndigit(r5)
-       mov     $' ,zfill(r5)
-       cmpb    *formp(r5),$'-
-       bne     2f
-       inc     formp(r5)
-       inc     rjust(r5)
-2:
-       cmpb    *formp(r5),$'0
-       bne     2f
-       mov     $'0,zfill(r5)
-2:
-       jsr     r3,gnum
-       mov     r1,width(r5)
-       clr     ndfnd(r5)
-       cmp     r0,$'.
-       bne     1f
-       jsr     r3,gnum
-       mov     r1,ndigit(r5)
-1:
-       mov     $swtab,r1
-1:
-       mov     (r1)+,r2
-       bne     2f
-       movb    r0,(r3)+
-       jmp     prbuf
-2:
-       cmp     r0,(r1)+
-       bne     1b
-       jmp     (r2)
-       .data
-swtab:
-       decimal;        'd
-       octal;          'o
-       hex;            'x
-       float;          'f
-       scien;          'e
-       general;        'g
-       charac;         'c
-       string;         's
-       longorunsg;     'l
-       longorunsg;     'L
-       unsigned;       'u
-       remote;         'r
-       long;           'D
-       loct;           'O
-       lhex;           'X
-       lunsigned;      'U
-       0;  0
-       .text
+       movl r11,r0                     # current point in format
+       bicl2 $liter,flags              # no literal characters yet
+L1:    movb (r11)+,width               # next character of format
+       beql L2                         # end of format string
+       cmpb width,$'%
+       beql L2                         # warning character
+       bisl2 $liter,flags              # literal character
+       jbr L1
+L2:    blbc flags,L3                   # bbc $literb,flags,L3 # no literals in format
+       pushl fdesc                     # file pointer
+       pushl $0                        # no left/right adjust
+       pushl r0                        # addr
+       subl3 r0,r11,r1                 # length
+       subl3 $1,r1,-(sp)               # % or null not part of literal
+       calls $4,__strout               # dump the literal
+L3:
+       blbs width,L4                   # % is odd; end of format?
+       ret                             # yes
+
+       # htab overlaps last 16 characters of ftab
+ftab:  .byte    0, 0, 0,'c,'d,'e,'f,'g, 0, 0, 0,'+,'l,'-,'.,'o
+htab:  .byte   '0,'1,'2,'3,'4,'5,'6,'7,'8,'9,'a,'b,'c,'d,'e,'f
+
+L4:    movl sp,r5                      # reset output buffer pointer
+       clrq r9                         # width; flags ljustb,ndfndb,zfillb
+L4a:   movzbl (r11)+,r0                # supposed format
+       extzv $0,$5,r0,r1                # bottom 5 bits
+L4b:   cmpb r0,ftab[r1]                # good enough?
+       jneq L6                         # no
+L4c:   casel r1,$3,$22                 # yes
+L5:    .word charac-L5                 # c
+       .word decimal-L5                # d
+       .word scien-L5                  # e
+       .word float-L5                  # f
+       .word general-L5                # g
+       .word L6-L5                     # h
+       .word L6-L5                     # i
+       .word L6-L5                     # j
+       .word plus-L5                   # +
+       .word longorunsg-L5             # l
+       .word minus-L5                  # -
+       .word dot-L5                    # .
+       .word octal-L5                  # o
+       .word gnum0-L5                  # 0
+       .word gnum-L5                   # 1
+       .word gnum-L5                   # 2
+       .word gnum-L5                   # 3
+       .word gnum-L5                   # 4
+       .word gnum-L5                   # 5
+       .word gnum-L5                   # 6
+       .word gnum-L5                   # 7
+       .word gnum-L5                   # 8
+       .word gnum-L5                   # 9
+
+L6:    jbcs $5,r0,L4b                  # capitals same as small
+       cmpb r0,$'s
+       jeql string
+       cmpb r0,$'x
+       jeql hex
+       cmpb r0,$'u
+       jeql unsigned
+       cmpb r0,$'r
+       jeql remote
+       movzbl -1(r11),r0               # orginal "format" character
+       cmpb r0,$'*
+       jeql indir
+L9:    movb r0,(r5)+                   # print the unfound character
+       jbr prbuf
+
+nulstr:
+       .byte '(,'n,'u,'l,'l,'),0
+
+string:
+       movl ndigit,r0
+       jbs $precb,flags,L20            # max length was specified
+       mnegl $1,r0                     # default max length
+L20:   movl (ap)+,r2                   # addr first byte
+       bneq L21
+       movab nulstr,r2
+L21:   locc $0,r0,(r2)                 # find the zero at the end
+       movl r1,r5                      # addr last byte +1
+       movl r2,r1                      # addr first byte
+       jbr prstr
 
 
-general:
-       mov     ndigit(r5),r0
-       mov     ndfnd(r5),r2
-       jsr     pc,pgen
-       jbr     prbuf
 
 longorunsg:
 
 longorunsg:
-       movb    *formp(r5),r0
-       inc     formp(r5)
-       cmp     r0,$'o
-       beq     loct
-       cmp     r0,$'x
-       beq     lhex
-       cmp     r0,$'d
-       beq     long
-       cmp     r0,$'u
-       beq     lunsigned
-       dec     formp(r5)
-       br      unsigned
+       movb (r11)+,r0
+       cmpb r0,$'o
+       jeql loct
+       cmpb r0,$'x
+       jeql lhex
+       cmpb r0,$'d
+       jeql long
+       cmpb r0,$'u
+       jeql lunsigned
+       decl r11
+       jbr unsigned
 
 
-octal:
-       clr     r0
-       br      1f
 loct:
 loct:
-       mov     (r4)+,r0
-1:
-       mov     $8.,r2
-       br      2f
+octal:
+       movl $30,r2                     # init position
+       movl $3,r3                      # field width
+       movl $10,r4                     # result length -1
+       jbr L10
 
 
+lhex:
 hex:
 hex:
-       clr     r0
-       br      1f
+       movl $28,r2                     # init position
+       movl $4,r3                      # field width
+       movl $7,r4                      # result length -1
+L10:   mnegl r3,r6                     # increment
+       clrl r1
+       movl (ap)+,r0                   # fetch arg
+L11:   extzv r2,r3,r0,r1               # pull out a digit
+       movb htab[r1],(r5)+             # convert to character
+L12:   acbl $0,r6,r2,L11               # continue until done
+       clrb (r5)                       # flag end
+       skpc $'0,r4,(sp)                # skip over leading zeroes
+       jbr prstr
 
 
-lhex:
-       mov     (r4)+,r0
-1:
-       mov     $16.,r2
-2:
-       mov     (r4)+,r1
-       br      compute
+patdec:                                        # editpc pattern for decimal printing
+       .byte 0xA9                      # eo$float 9
+       .byte 0x01                      # eo$end_float
+       .byte 0x91                      # eo$move 1
+       .byte 0                         # eo$end
 
 
+long:
 decimal:
 decimal:
-       mov     (r4)+,r1
-       sxt     r0
-       bmi     3f
-       br      2f
+       cvtlp (ap)+,$10,(sp)            # 10 digits max
+L14:   editpc $10,(sp),patdec,8(sp)    # ascii at 8(sp); r5=end+1
+       skpc $' ,$10,8(sp)              # skip leading blanks; r1=first
 
 
-unsigned:
-       clr     r0
-       br      1f
-
-long:
-       mov     (r4)+,r0
-       bge     1f
-       mov     (r4)+,r1
-3:
-       neg     r0
-       neg     r1
-       sbc     r0
-       movb    $'-,(r3)+
-       br      2f
+prstr:                 # r1=addr first byte; r5=addr last byte +1
+       cvtbl $' ,-(sp)                 # blank fill
+       jbc $zfillb,flags,L15
+       cvtbl $'0,(sp)                  # zero fill
+L15:   pushl fdesc                     # FILE
+       subl2 r1,r5                     # r5=actual length=end+1-first
+       subl3 r5,width,r0               # if >0, how much to fill
+       bgeq L24
+       clrl r0                         # no fill
+L24:   jbs $ljustb,flags,L25
+       mnegl r0,r0
+L25:   pushl r0                        # fill count
+       pushl r1                        # addr first byte
+       pushl r5                        # length
+       calls $5,__strout
+       jbr     loop
 
 
+pone:  .byte   0x1C                    # packed 1
+       
+unsigned:
 lunsigned:
 lunsigned:
-       mov     (r4)+,r0
-1:
-       mov     (r4)+,r1
-2:
-       mov     $10.,r2
-
-/
-/ Algorithm courtesy Keith Davis
-/
-compute:
-       mov     r5,-(sp)
-       mov     r4,-(sp)
-       mov     r0,r4
-       mov     ndigit(r5),r0
-       mov     r1,r5
-       ashc    $0,r4
-       beq     1f
-       tst     r0
-       beq     1f
-       movb    $'0,(r3)+
-1:
-       jsr     pc,1f
-       mov     (sp)+,r4
-       mov     (sp)+,r5
-       br      prbuf
+       extzv $1,$31,(ap),r0            # right shift logical 1 bit
+       cvtlp r0,$10,(sp)               # convert [n/2] to packed
+       movp $10,(sp),8(sp)             # copy packed
+       addp4 $10,8(sp),$10,(sp)        # 2*[n/2] in packed, at (sp)
+       blbc (ap)+,L14                  # n was even
+       addp4 $1,pone,$10,(sp)          # n was odd
+       jbr L14
 
 
-1:
-       clr     r0
-       mov     r4,r1
-       beq     2f
-       div     r2,r0
-       mov     r0,r4
-       mov     r1,r0
-2:
-       mov     r5,r1
-       asl     r2
-       div     r2,r0
-       asr     r2
-       asl     r0
-       cmp     r2,r1
-       bgt     2f
-       sub     r2,r1
-       inc     r0
-2:
-       mov     r1,-(sp)
-       mov     r0,r5
-       bne     2f
-       tst     r4
-       beq     1f
-2:
-       jsr     pc,1b
-1:
-       mov     (sp)+,r0
-       add     $'0,r0
-       cmp     r0,$'9
-       ble     1f
-       add     $'a-'0-10.,r0
-1:
-       movb    r0,(r3)+
-       rts     pc
-       
 charac:
 charac:
-       mov     $' ,zfill(r5)
-       mov     (r4)+,r0
-       bic     $!377,r0
-       beq     prbuf
-       movb    r0,(r3)+
-       br      prbuf
+       movl $4,r0                      # chars per word
+L18:   movb (ap)+,(r5)+                # transfer char
+       bneq L19
+       decl r5                         # omit null characters
+L19:   sobgtr r0,L18
 
 
-string:
-       mov     $' ,zfill(r5)
-       mov     ndigit(r5),r1
-       mov     (r4),r2
-       mov     r2,r3
-       bne     1f
-       mov     $nulstr,r2
-       mov     r2,r3
-       mov     r2,(r4)
-1:
-       tstb    (r2)+
-       beq     1f
-       inc     r3
-       sob     r1,1b
-1:
-       mov     (r4)+,r2
-       br      prstr
+prbuf:
+       movl sp,r1                      # addr first byte
+       jbr prstr
+
+plus:  bisl2 $psign,flags              # always print sign for floats
+       jbr L4a
+minus: bisl2 $ljust,flags              # left justification, please
+       jbr L4a
+gnum0: jbs $ndfndb,flags,gnum
+       jbs $precb,flags,gnump          # ignore when reading precision
+       bisl2 $zfill,flags              # leading zero fill, please
+gnum:  jbs $precb,flags,gnump
+       moval (width)[width],width      # width *= 5;
+       movaw -ch.zer(r0)[width],width  # width = 2*witdh + r0 - '0';
+       jbr gnumd
+gnump: moval (ndigit)[ndigit],ndigit   # ndigit *= 5;
+       movaw -ch.zer(r0)[ndigit],ndigit # ndigit = 2*ndigit + r0 - '0';
+gnumd: bisl2 $ndfnd,flags              # digit seen
+       jbr L4a
+dot:   clrl ndigit                     # start on the precision
+       bisl2 $prec,flags
+       bicl2 $ndfnd,flags
+       jbr L4a
+indir: movl (ap)+,ndigit               # width specified by parameter
+       jbr gnumd
+remote:        movl (ap)+,ap
+       movl (ap)+,r11
+       jbr loop
 
 float:
 
 float:
-       mov     ndigit(r5),r0
-       mov     ndfnd(r5),r2
-       jsr     pc,pfloat
-       br      prbuf
+       bsbw fltcvt
+fltg:  jbs $ndfndb,flags,float1
+       movl $6,ndigit                  # default # digits to right of decpt.
+float1:        addl3 exp,ndigit,r7
+       movl r7,r6                      # for later "underflow" checking
+       bgeq fxplrd
+       clrl r7                         # poor programmer planning
+fxplrd:        cmpl r7,$31                     # expressible in packed decimal?
+       bleq fnarro                     # yes
+       movl $31,r7
+fnarro:        subl3 $17,r7,r0                 # where to round
+       ashp r0,$17,(sp),$5,r7,16(sp)   # do it
+       bvc fnovfl
+       # band-aid for microcode error (spurious overflow)
+       clrl r0                         # assume even length result
+       jlbc r7,fleven                  # right
+       movl $4,r0                      # odd length result
+fleven:        cmpv r0,$4,16(sp),$0            # top digit zero iff true overflow
+       bneq fnovfl
+       # end band-aid
+       aobleq $0,r6,fnovfl             # if "underflow" then jump
+       movl r7,r0
+       incl exp
+       incl r7
+       ashp r0,$1,pone,$0,r7,16(sp)
+       ashl $-1,r7,r0                  # displ to last byte
+       bisb2 sign,16(sp)[r0]           # insert sign
+fnovfl:
+       movc3 $4,patsci,(sp)
+       clrl r6                         # # digits moved so far
+       movl exp,r0
+       bleq fexpng
+       bsbb patmov                     # digits to left of decpt.
+fexpng:        tstl ndigit
+       jeql fnodp
+       movc3 $2,fpatdp,(r3)
+       tstl exp
+       bgeq fxppos
+       addl3 exp,ndigit,r6
+       bgeq  flfakl
+       clrl r6                         # it's all fill
+flfakl:        subl3 r6,$31,r6                 # fake length for patmov
+flfill:        movc3 $2,fpatzf,(r3)            # zero fill to right of dec.pt
+fxppos:        movl ndigit,r0
+       bsbb patmov
+fnodp: sobgeq r6,fledit                # must move at least 1 digit
+       movl $31,r6                     # none moved; fake it
+       aobleq $1,ndigit,flfill         # with a one-character zero fill
+fledit:        editpc r7,16(sp),(sp),32(sp)
+       jbr prflt
+
+patexp:        .byte   0x03                    # eo$set_signif
+       .byte   0x44,'e                 # eo$insert 'e
+       .byte   0x42,'+                 # eo$load_plus '+
+       .byte   0x04                    # eo$store_sign
+       .byte   0x92                    # eo$move 2
+       .byte   0                       # eo$end
+patsci:        .byte   0x42,'+                 # eo$load_plus '+
+       .byte   0x03                    # eo$set_signif
+       .byte   0x04                    # eo$store_sign
+       .byte   0x91                    # eo$move 1
+fpatdp:        .byte   0x44,'.                 # eo$insert '.
+fpatzf:        .byte   0x40,'0                 # eo$load_fill '0
+
+       # construct pattern at (r3) to move  r0  digits in  editpc;
+       #  r6  digits already moved for this number
+patmov:
+       movb $0x90,r2                   # eo$move
+       subl3 r6,$31,r1                 # # digits remaining in packed
+       addl2 r0,r6
+       cmpl r0,r1                      # enough digits remaining?
+       bleq patsml                     # yes
+       tstl exp                        # zero 'fill'; before or after rest?
+       bgeq pataft                     # after
+       pushl r1                        # # digits remaining
+       movb $0x80,r2                   # eo$fill
+       subl3 $31,r6,r0                 # number of fill bytes
+       bsbb patsml                     # recursion!
+       movl (sp)+,r0
+       movb $0x90,r2                   # eo$move
+       jbr patsml
+pataft:        movl r1,r0                      # last of the 31
+       bsbb patsml                     # recursion!
+       subl3 $31,r6,r0                 # number of fill bytes
+       movb $0x80,r2                   # eo$fill
+patsml:        tstl r0
+       bleq patzer                     # DEC doesn't like repetition counts of 0
+       mnegl $15,r1                    # 15 digits at a time
+       subl2 r1,r0                     # counteract acbl
+       jbr pattst
+patmlp:        bisb3 r2,$15,(r3)+              # 15
+pattst:        acbl $16,r1,r0,patmlp           # until <= 15 left
+       bisb3 r2,r0,(r3)+               # rest
+patzer:        clrb (r3)                       # eo$end
+       rsb
 
 scien:
 
 scien:
-       mov     ndigit(r5),r0
-       inc     r0
-       tst     ndfnd(r5)
-       bne     1f
-       mov     $7,r0
-1:
-       mov     pc,r2
-       jsr     pc,pscien
-       br      prbuf
+       bsbw fltcvt                     # get packed digits
+scig:  incl ndigit
+       jbs $ndfndb,flags,L23
+       movl $7,ndigit
+L23:   subl3 $17,ndigit,r0             # rounding position
+       ashp r0,$17,(sp),$5,ndigit,16(sp) # shift and round
+       bvc snovfl
+       # band-aid for microcode error (spurious overflow)
+       clrl r0                         # assume even length result
+       jlbc ndigit,sceven              # right
+       movl $4,r0                      # odd length result
+sceven:        cmpv r0,$4,16(sp),$0            # top digit zero iff true overflow
+       bneq snovfl
+       # end band-aid
+       incl exp                        # rounding overflowed to 100...
+       subl3 $1,ndigit,r0
+       ashp r0,$1,pone,$0,ndigit,16(sp)
+       ashl $-1,ndigit,r0              # displ to last byte
+       bisb2 sign,16(sp)[r0]           # insert sign
+snovfl:
+       jbc $gflagb,flags,enotg         # not %g format
+ # find trailing zeroes in packed number
+       ashl $-1,ndigit,r0
+       addl2 r3,r0                     # addr of l.s.digit and sign
+       movl $4,r1                      # bit position of digit
+       movl ndigit,r7                  # current length of packed
+       jbr gtz
+gtz1:  xorl2 $4,r1                     # position of next digit
+       bneq gtz                        # same byte
+       decl r0                         # different byte
+gtz:   cmpv r1,$4,(r0),$0              # a trailing zero?
+       jneq gntz
+       sobgtr r7,gtz1
+       incl r7
+gntz:                                  # r7: minimum width of fraction
+       cmpl exp,$-4
+       jleq eg                         # small exponents use %e
+       subl3 r7,exp,r0
+       cmpl $5,r0
+       jleq eg                         # so do (w+5) <= exp
+       tstl r0                         # rest use %f
+       jleq fg                         # did we trim too many trailing zeroes?
+       movl exp,r7                     # yes
+fg:    subl3 ndigit,r7,r0
+       ashp r0,ndigit,16(sp),$0,r7,(sp)
+       movp r7,(sp),16(sp)
+       subl3 exp,r7,ndigit             # correct ndigit for %f
+       jbr fnovfl
+eg:    subl3 ndigit,r7,r0
+       ashp r0,ndigit,16(sp),$0,r7,(sp)
+       movp r7,(sp),16(sp)
+       movl r7,ndigit                  # packed number has been trimmed
+enotg:
+       movc3 $7,patsci,(sp)
+       movl $1,r6                      # 1P
+       subl3 $1,ndigit,r0              # digits after dec.pt
+       bsbw patmov
+       editpc ndigit,16(sp),(sp),32(sp)        # 32(sp)->result, r5->(end+1)
+       decl exp                        # compensate: 1 digit left of dec.pt
+       cvtlp exp,$2,(sp)               # exponent
+       editpc $2,(sp),patexp,(r5)
+prflt: movab 32(sp),r1
+       jbs $psignb,flags,prflt1
+       cmpb (r1)+,$'+
+       beql prflt1
+       decl r1
+prflt1:        skpc $' ,$63,(r1)
+       jbr prstr
 
 
-remote:
-       mov     (r4)+,r4
-       mov     (r4)+,formp(r5)
-       jmp     loop
+general:
+       jbcs $gflagb,flags,scien
+       jbr scien                       # safety net
 
 
-prbuf:
-       mov     sp,r2
-prstr:
-       sub     r2,r3
-       mov     width(r5),r1
-       sub     r3,r1
-       bge     1f
-       clr     r1
-1:
-       tst     rjust(r5)
-       bne     1f
-       neg     r1
-1:
-       mov     zfill(r5),-(sp)
-       mov     8(r5),-(sp)
-       mov     r1,-(sp)
-       mov     r3,-(sp)
-       mov     r2,-(sp)
-       jsr     pc,__strout
-       add     $10.,sp
-       jmp     loop
+       # convert double-floating at (ap) to 17-digit packed at (sp),
+       # set 'sign' and 'exp', advance ap.
+fltcvt:
+       clrb sign
+       movd (ap)+,r5
+       jeql fzero
+       bgtr fpos
+       mnegd r5,r5
+       incb sign
+fpos:
+       extzv $7,$8,r5,r2               # exponent of 2
+       movaw -0600(r2)[r2],r2          # unbias and mult by 3
+       bgeq epos
+       subl2 $9,r2
+epos:  divl2 $10,r2
+       bsbb expten
+       cmpd r0,r5
+       bgtr ceil
+       incl r2
+ceil:  movl r2,exp
+       mnegl r2,r2
+       cmpl r2,$29                     # 10^(29+9) is all we can handle
+       bleq getman
+       muld2 ten16,r5
+       subl2 $16,r2
+getman:        addl2 $9,r2                     # -ceil(log10(x)) + 9
+       bsbb expten
+       emodd r0,r4,r5,r0,r5            # (r0+r4)*r5; r0=int, r5=frac
+fz1:   cvtlp r0,$9,16(sp)              # leading 9 digits
+       ashp $8,$9,16(sp),$0,$17,4(sp)  # as top 9 of 17
+       emodd ten8,$0,r5,r0,r5
+       cvtlp r0,$8,16(sp)              # trailing 8 digits
+       addp4 $8,16(sp),$17,4(sp)       # combine leading and trailing
+       bisb2 sign,12(sp)               # and insert sign
+       rsb
+fzero: clrl r0
+       movl $1,exp             # 0.000e+00 and 0.000 rather than 0.000e-01 and .000
+       jbr fz1
 
 
-gnum:
-       clr     ndfnd(r5)
-       clr     r1
-1:
-       movb    *formp(r5),r0
-       inc     formp(r5)
-       sub     $'0,r0
-       cmp     r0,$'*-'0
-       bne     2f
-       mov     (r4)+,r0
-       br      3f
-2:
-       cmp     r0,$9.
-       bhi     1f
-3:
-       inc     ndfnd(r5)
-       mul     $10.,r1
-       add     r0,r1
-       br      1b
-1:
-       add     $'0,r0
-       rts     r3
+       # return 10^r2 as a double float in r0||r1 and 8 extra bits of precision in r4
+       # preserve r2, r5||r6
+expten:
+       movd $one,r0                    # begin computing 10^exp10
+       clrl r4                         # bit counter
+       movad ten1,r3                   # table address
+       tstl r2
+       bgeq e10lp
+       mnegl r2,r2                     # get absolute value
+       jbss $6,r2,e10lp                # flag as negative
+e10lp: jbc r4,r2,el1                   # want this power?
+       muld2 (r3),r0                   # yes
+el1:   addl2 $8,r3                     # advance to next power
+       aobleq $5,r4,e10lp              # through 10^32
+       jbcc $6,r2,el2                  # correct for negative exponent
+       divd3 r0,$one,r0                # by taking reciprocal
+       mnegl r2,r2
+el2:   clrl r4                         # 8 extra bits of precision
+       rsb
 
 
-.data
-nulstr:
-       <(null)\0>
+       # powers of ten
+       .align  3
+ten1:  .word   0x4220,0,0,0
+ten2:  .word   0x43c8,0,0,0
+ten4:  .word   0x471c,0x4000,0,0
+ten8:  .word   0x4dbe,0xbc20,0,0
+ten16: .word   0x5b0e,0x1bc9,0xbf04,0
+ten32: .word   0x759d,0xc5ad,0xa82b,0x70b6
index 95a9bb0..bafc4ab 100644 (file)
@@ -54,8 +54,8 @@ register int **argp;
                if (len == 0)
                        len = 30000;
                if (ch=='l') {
                if (len == 0)
                        len = 30000;
                if (ch=='l') {
-                       ch = *fmt++;
                        size = LONG;
                        size = LONG;
+                       ch = *fmt++;
                } else if (ch=='h') {
                        size = SHORT;
                        ch = *fmt++;
                } else if (ch=='h') {
                        size = SHORT;
                        ch = *fmt++;
@@ -141,7 +141,7 @@ struct _iobuf *iop;
                        else
                                lcval <<= 4;
                        c1 = c;
                        else
                                lcval <<= 4;
                        c1 = c;
-                       if ('0'<=c && c<='9')
+                       if (isdigit(c))
                                c -= '0';
                        else if ('a'<=c && c<='f')
                                c -= 'a'-10;
                                c -= '0';
                        else if ('a'<=c && c<='f')
                                c -= 'a'-10;
diff --git a/usr/src/libc/stdio/endopen.c b/usr/src/libc/stdio/endopen.c
deleted file mode 100644 (file)
index 5e91de0..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#include       <stdio.h>
-#include       <errno.h>
-
-FILE *
-_endopen(file, mode, iop)
-       char *file, *mode;
-       register FILE *iop;
-{
-       extern int errno;
-       register int rw, f;
-
-       if (iop == NULL)
-               return(NULL);
-
-       rw = mode[1] == '+';
-
-       switch (*mode) {
-
-       case 'w':
-               f = create(file, rw);
-               break;
-
-       case 'a':
-               if ((f = open(file, rw? 2: 1)) < 0) {
-                       if (errno == ENOENT)
-                               f = create(file, rw);
-               }
-               lseek(f, 0L, 2);
-               break;
-
-       case 'r':
-               f = open(file, rw? 2: 0);
-               break;
-
-       default:
-               return(NULL);
-       }
-
-       if (f < 0)
-               return(NULL);
-
-       iop->_cnt = 0;
-       iop->_file = f;
-
-       if (rw)
-               iop->_flag |= _IORW;
-       else if(*mode == 'r')
-               iop->_flag |= _IOREAD;
-       else
-               iop->_flag |= _IOWRT;
-
-       return(iop);
-}
-
-static int
-create(file, rw)
-       register char *file;
-       int rw;
-{
-       register int f;
-
-       f = creat(file, 0666);
-       if (rw && f>=0) {
-               close(f);
-               f = open(file, 2);
-       }
-       return(f);
-}
diff --git a/usr/src/libc/stdio/error.c b/usr/src/libc/stdio/error.c
new file mode 100644 (file)
index 0000000..482b0b2
--- /dev/null
@@ -0,0 +1,12 @@
+#include       <stdio.h>
+
+_error(s)
+register char *s;
+{
+       static reentered;
+
+       if (reentered++)
+               _exit(0177);
+       write(2, s, strlen(s));
+       exit(0176);
+}
index 5ca8195..d47ad5f 100644 (file)
@@ -9,37 +9,22 @@
 
 FILE *
 fdopen(fd, mode)
 
 FILE *
 fdopen(fd, mode)
-       register char *mode;
+register char *mode;
 {
 {
+       extern int errno;
        register FILE *iop;
        register FILE *iop;
-       FILE *_findiop();
-
-       if ((iop = _findiop()) == NULL)
-               return(NULL);
+       extern FILE *_lastbuf;
 
 
+       for (iop = _iob; iop->_flag&(_IOREAD|_IOWRT); iop++)
+               if (iop >= _lastbuf)
+                       return(NULL);
        iop->_cnt = 0;
        iop->_file = fd;
        iop->_cnt = 0;
        iop->_file = fd;
-       switch (*mode) {
-
-       case 'r':
-               iop->_flag |= _IOREAD;
-               break;
-
-       case 'a':
-               lseek(fd, 0L, 2);
-               /* No break */
-       case 'w':
+       if (*mode != 'r') {
                iop->_flag |= _IOWRT;
                iop->_flag |= _IOWRT;
-               break;
-
-       default:
-               return(NULL);
-       }
-
-       if (mode[1] == '+') {
-               iop->_flag &= ~(_IOREAD|_IOWRT);
-               iop->_flag |= _IORW;
-       }
-
+               if (*mode == 'a')
+                       lseek(fd, 0L, 2);
+       } else
+               iop->_flag |= _IOREAD;
        return(iop);
 }
        return(iop);
 }
diff --git a/usr/src/libc/stdio/ffltpr.s b/usr/src/libc/stdio/ffltpr.s
deleted file mode 100644 (file)
index d816bf8..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/ C library-- fake floating output
-
-.globl pfloat
-.globl pscien
-.globl pgen
-
-pfloat:
-pscien:
-pgen:
-       add     $8,r4
-       movb    $'?,(r3)+
-       rts     pc
index 3cb9555..7705792 100644 (file)
@@ -1,23 +1,18 @@
 #include       <stdio.h>
 #include       <stdio.h>
-
 char   *malloc();
 
 char   *malloc();
 
-
-int
 _filbuf(iop)
 _filbuf(iop)
-       register FILE *iop;
+register FILE *iop;
 {
        static char smallbuf[_NFILE];
 
 {
        static char smallbuf[_NFILE];
 
-       if (iop->_flag & _IORW)
-               iop->_flag |= _IOREAD;
-
-       if ((iop->_flag & _IOREAD) == 0 || iop->_flag & _IOSTRG)
+       if ((iop->_flag&_IOREAD) == 0)
+               return(EOF);
+       if (iop->_flag&_IOSTRG)
                return(EOF);
                return(EOF);
-
 tryagain:
 tryagain:
-       if (iop->_base == NULL) {
-               if (iop->_flag & _IONBF) {
+       if (iop->_base==NULL) {
+               if (iop->_flag&_IONBF) {
                        iop->_base = &smallbuf[fileno(iop)];
                        goto tryagain;
                }
                        iop->_base = &smallbuf[fileno(iop)];
                        goto tryagain;
                }
@@ -30,14 +25,12 @@ tryagain:
        iop->_ptr = iop->_base;
        iop->_cnt = read(fileno(iop), iop->_ptr, iop->_flag&_IONBF?1:BUFSIZ);
        if (--iop->_cnt < 0) {
        iop->_ptr = iop->_base;
        iop->_cnt = read(fileno(iop), iop->_ptr, iop->_flag&_IONBF?1:BUFSIZ);
        if (--iop->_cnt < 0) {
-               if (iop->_cnt == -1) {
+               if (iop->_cnt == -1)
                        iop->_flag |= _IOEOF;
                        iop->_flag |= _IOEOF;
-                       if (iop->_flag & _IORW)
-                               iop->_flag &= ~_IOREAD;
-               } else
+               else
                        iop->_flag |= _IOERR;
                iop->_cnt = 0;
                        iop->_flag |= _IOERR;
                iop->_cnt = 0;
-               return(EOF);
+               return(-1);
        }
        }
-       return(*iop->_ptr++ & 0377);
+       return(*iop->_ptr++&0377);
 }
 }
diff --git a/usr/src/libc/stdio/findiop.c b/usr/src/libc/stdio/findiop.c
deleted file mode 100644 (file)
index 752f820..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <stdio.h>
-
-FILE *
-_findiop()
-{
-       extern FILE *_lastbuf;
-       register FILE *iop;
-
-       for(iop = _iob; iop->_flag & (_IOREAD|_IOWRT|_IORW); iop++)
-               if (iop >= _lastbuf)
-                       return(NULL);
-
-       return(iop);
-}
index b381bb2..a4763aa 100644 (file)
@@ -2,30 +2,25 @@
 
 char   *malloc();
 
 
 char   *malloc();
 
-int
 _flsbuf(c, iop)
 _flsbuf(c, iop)
-       int c;
-       register FILE *iop;
+register FILE *iop;
 {
        register char *base;
        register n, rn;
        char c1;
        extern char _sobuf[];
 
 {
        register char *base;
        register n, rn;
        char c1;
        extern char _sobuf[];
 
-       if (iop->_flag & _IORW) {
-               iop->_flag |= _IOWRT;
-               iop->_flag &= ~_IOEOF;
-       }
-
+       if ((iop->_flag&_IOWRT)==0)
+               return(EOF);
 tryagain:
 tryagain:
-       if (iop->_flag & _IONBF) {
+       if (iop->_flag&_IONBF) {
                c1 = c;
                rn = 1;
                n = write(fileno(iop), &c1, rn);
                iop->_cnt = 0;
        } else {
                c1 = c;
                rn = 1;
                n = write(fileno(iop), &c1, rn);
                iop->_cnt = 0;
        } else {
-               if ((base = iop->_base) == NULL) {
-                       if (iop == stdout) {
+               if ((base=iop->_base)==NULL) {
+                       if (iop==stdout) {
                                if (isatty(fileno(stdout))) {
                                        iop->_flag |= _IONBF;
                                        goto tryagain;
                                if (isatty(fileno(stdout))) {
                                        iop->_flag |= _IONBF;
                                        goto tryagain;
@@ -34,17 +29,17 @@ tryagain:
                                iop->_ptr = _sobuf;
                                goto tryagain;
                        }
                                iop->_ptr = _sobuf;
                                goto tryagain;
                        }
-                       if ((iop->_base = base = malloc(BUFSIZ)) == NULL) {
+                       if ((iop->_base=base=malloc(BUFSIZ)) == NULL) {
                                iop->_flag |= _IONBF;
                                goto tryagain;
                        }
                        iop->_flag |= _IOMYBUF;
                        rn = n = 0;
                                iop->_flag |= _IONBF;
                                goto tryagain;
                        }
                        iop->_flag |= _IOMYBUF;
                        rn = n = 0;
-               } else if((rn = n = iop->_ptr - base) > 0) {
+               } else if ((rn = n = iop->_ptr - base) > 0) {
                        iop->_ptr = base;
                        n = write(fileno(iop), base, n);
                }
                        iop->_ptr = base;
                        n = write(fileno(iop), base, n);
                }
-               iop->_cnt = BUFSIZ - 1;
+               iop->_cnt = BUFSIZ-1;
                *base++ = c;
                iop->_ptr = base;
        }
                *base++ = c;
                iop->_ptr = base;
        }
@@ -55,18 +50,17 @@ tryagain:
        return(c);
 }
 
        return(c);
 }
 
-int
 fflush(iop)
 fflush(iop)
-       register FILE *iop;
+register struct _iobuf *iop;
 {
        register char *base;
        register n;
 
 {
        register char *base;
        register n;
 
-       if ((iop->_flag & (_IONBF|_IOWRT)) == _IOWRT
-        && (base = iop->_base) != NULL && (n = iop->_ptr - base) > 0) {
+       if ((iop->_flag&(_IONBF|_IOWRT))==_IOWRT
+        && (base=iop->_base)!=NULL && (n=iop->_ptr-base)>0) {
                iop->_ptr = base;
                iop->_cnt = BUFSIZ;
                iop->_ptr = base;
                iop->_cnt = BUFSIZ;
-               if (write(fileno(iop), base, n) != n) {
+               if (write(fileno(iop), base, n)!=n) {
                        iop->_flag |= _IOERR;
                        return(EOF);
                }
                        iop->_flag |= _IOERR;
                        return(EOF);
                }
@@ -80,32 +74,29 @@ fflush(iop)
 
 _cleanup()
 {
 
 _cleanup()
 {
-       register FILE *iop;
-       extern FILE *_lastbuf;
+       register struct _iobuf *iop;
+       extern struct _iobuf *_lastbuf;
 
 
-       for(iop = _iob; iop < _lastbuf; iop++)
+       for (iop = _iob; iop < _lastbuf; iop++)
                fclose(iop);
 }
 
                fclose(iop);
 }
 
-int
 fclose(iop)
 fclose(iop)
-       register FILE *iop;
+register struct _iobuf *iop;
 {
        register r;
 
        r = EOF;
 {
        register r;
 
        r = EOF;
-       if (iop->_flag & (_IOREAD|_IOWRT|_IORW)
-           && (iop->_flag & _IOSTRG) == 0) {
+       if (iop->_flag&(_IOREAD|_IOWRT) && (iop->_flag&_IOSTRG)==0) {
                r = fflush(iop);
                if (close(fileno(iop)) < 0)
                        r = EOF;
                r = fflush(iop);
                if (close(fileno(iop)) < 0)
                        r = EOF;
-               if (iop->_flag & _IOMYBUF)
+               if (iop->_flag&_IOMYBUF)
                        free(iop->_base);
                        free(iop->_base);
-               if (iop->_flag & (_IOMYBUF|_IONBF))
+               if (iop->_flag&(_IOMYBUF|_IONBF))
                        iop->_base = NULL;
        }
                        iop->_base = NULL;
        }
-       iop->_flag &=
-               ~(_IOREAD|_IOWRT|_IONBF|_IOMYBUF|_IOERR|_IOEOF|_IOSTRG|_IORW);
+       iop->_flag &= ~(_IOREAD|_IOWRT|_IONBF|_IOMYBUF|_IOERR|_IOEOF|_IOSTRG);
        iop->_cnt = 0;
        return(r);
 }
        iop->_cnt = 0;
        return(r);
 }
diff --git a/usr/src/libc/stdio/fltpr.s b/usr/src/libc/stdio/fltpr.s
deleted file mode 100644 (file)
index 51cf7da..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/ C library-- floating output
-
-.globl pfloat
-.globl pscien
-.globl pgen
-.globl fltused
-
-.globl _ecvt
-.globl _fcvt
-.globl _gcvt
-
-fltused:               / force loading
-
-pgen:
-       mov     r3,-(sp)
-       mov     r0,-(sp)
-       tst     r2
-       bne     1f
-       mov     $6,(sp)
-1:
-       movf    (r4)+,fr0
-       movf    fr0,-(sp)
-       jsr     pc,_gcvt
-       add     $8+2+2,sp
-1:
-       tstb    (r3)+
-       bne     1b
-       dec     r3
-       rts     pc
-
-pfloat:
-       mov     $sign,-(sp)
-       mov     $decpt,-(sp)
-       tst     r2
-       bne     1f
-       mov     $6,r0
-1:
-       mov     r0,-(sp)
-       mov     r0,ndigit
-       movf    (r4)+,fr0
-       movf    fr0,-(sp)
-       jsr     pc,_fcvt
-       add     $8+2+2+2,sp
-       tst     sign
-       beq     1f
-       movb    $'-,(r3)+
-1:
-       mov     decpt,r2
-       bgt     1f
-       movb    $'0,(r3)+
-1:
-       mov     r2,r1
-       ble     1f
-2:
-       movb    (r0)+,(r3)+
-       sob     r1,2b
-1:
-       mov     ndigit,r1
-       beq     1f
-       movb    $'.,(r3)+
-1:
-       neg     r2
-       ble     1f
-2:
-       dec     r1
-       blt     1f
-       movb    $'0,(r3)+
-       sob     r2,2b
-1:
-       tst     r1
-       ble     2f
-1:
-       movb    (r0)+,(r3)+
-       sob     r1,1b
-2:
-       rts     pc
-
-pscien:
-       mov     $sign,-(sp)
-       mov     $decpt,-(sp)
-       mov     r0,-(sp)
-       mov     r0,ndigit
-       tst     r2
-       bne     1f
-       mov     $6,(sp)
-1:
-       movf    (r4)+,fr0
-       movf    fr0,-(sp)
-       jsr     pc,_ecvt
-       add     $8+2+2+2,sp
-       tst     sign
-       beq     1f
-       movb    $'-,(r3)+
-1:
-       cmpb    (r0),$'0
-       bne     1f
-       inc     decpt
-1:
-       movb    (r0)+,(r3)+
-       movb    $'.,(r3)+
-       mov     ndigit,r1
-       dec     r1
-       ble     1f
-2:
-       movb    (r0)+,(r3)+
-       sob     r1,2b
-1:
-       movb    $'e,(r3)+
-       mov     decpt,r2
-       dec     r2
-       mov     r2,r1
-       bge     1f
-       movb    $'-,(r3)+
-       neg     r1
-       br      2f
-1:
-       movb    $'+,(r3)+
-2:
-       clr     r0
-       div     $10.,r0
-       add     $'0,r0
-       movb    r0,(r3)+
-       add     $'0,r1
-       movb    r1,(r3)+
-       rts     pc
-.data
-sign:  .=.+2
-ndigit:        .=.+2
-decpt: .=.+2
index a5a04e5..26ca43e 100644 (file)
@@ -1,10 +1,36 @@
 #include       <stdio.h>
 #include       <stdio.h>
+#include       <errno.h>
 
 FILE *
 fopen(file, mode)
 
 FILE *
 fopen(file, mode)
-       char *file, *mode;
+char *file;
+register char *mode;
 {
 {
-       FILE *_findiop(), *_endopen();
+       extern int errno;
+       register f;
+       register FILE *iop;
+       extern FILE *_lastbuf;
 
 
-       return(_endopen(file, mode, _findiop()));
+       for (iop = _iob; iop->_flag&(_IOREAD|_IOWRT); iop++)
+               if (iop >= _lastbuf)
+                       return(NULL);
+       if (*mode=='w')
+               f = creat(file, 0666);
+       else if (*mode=='a') {
+               if ((f = open(file, 1)) < 0) {
+                       if (errno == ENOENT)
+                               f = creat(file, 0666);
+               }
+               lseek(f, 0L, 2);
+       } else
+               f = open(file, 0);
+       if (f < 0)
+               return(NULL);
+       iop->_cnt = 0;
+       iop->_file = f;
+       if (*mode != 'r')
+               iop->_flag |= _IOWRT;
+       else
+               iop->_flag |= _IOREAD;
+       return(iop);
 }
 }
index 016c0b2..1ef88b7 100644 (file)
@@ -2,11 +2,27 @@
 
 FILE *
 freopen(file, mode, iop)
 
 FILE *
 freopen(file, mode, iop)
-       char *file, *mode;
-       register FILE *iop;
+char *file;
+register char *mode;
+register FILE *iop;
 {
 {
-       FILE *_endopen();
+       register f;
 
        fclose(iop);
 
        fclose(iop);
-       return(_endopen(file, mode, iop));
+       if (*mode=='w')
+               f = creat(file, 0666);
+       else if (*mode=='a') {
+               if ((f = open(file, 1)) < 0)
+                       f = creat(file, 0666);
+               lseek(f, 0L, 2);
+       } else
+               f = open(file, 0);
+       if (f < 0)
+               return(NULL);
+       iop->_file = f;
+       if (*mode != 'r')
+               iop->_flag |= _IOWRT;
+       else
+               iop->_flag |= _IOREAD;
+       return(iop);
 }
 }
index ecbda88..6ac9b3f 100644 (file)
@@ -7,42 +7,38 @@
 long lseek();
 
 fseek(iop, offset, ptrname)
 long lseek();
 
 fseek(iop, offset, ptrname)
-       register FILE *iop;
-       long offset;
+FILE *iop;
+long offset;
 {
 {
-       register int c;
+       register resync, c;
        long p;
 
        iop->_flag &= ~_IOEOF;
        long p;
 
        iop->_flag &= ~_IOEOF;
-       if (iop->_flag & _IOREAD) {
-               if (ptrname < 2 && iop->_base && !(iop->_flag&_IONBF)) {
+       if (iop->_flag&_IOREAD) {
+               if (ptrname<2 && iop->_base &&
+                       !(iop->_flag&_IONBF)) {
                        c = iop->_cnt;
                        p = offset;
                        c = iop->_cnt;
                        p = offset;
-                       if (ptrname == 0)
-                               p += c - lseek(fileno(iop), 0L, 1);
+                       if (ptrname==0)
+                               p += c - lseek(fileno(iop),0L,1);
                        else
                                offset -= c;
                        else
                                offset -= c;
-                       if (!(iop->_flag&_IORW) && c > 0 && p <= c
-                           && p >= iop->_base - iop->_ptr){
-                               iop->_ptr += (int) p;
-                               iop->_cnt -= (int) p;
+                       if(c>0&&p<=c&&p>=iop->_base-iop->_ptr){
+                               iop->_ptr += (int)p;
+                               iop->_cnt -= (int)p;
                                return(0);
                        }
                                return(0);
                        }
-               }
-               if (iop->_flag & _IORW) {
-                       iop->_ptr = iop->_base;
-                       iop->_flag &= ~_IOREAD;
-               }
-               p = lseek(fileno(iop), offset, ptrname);
+                       resync = offset&01;
+               } else 
+                       resync = 0;
+               p = lseek(fileno(iop), offset-resync, ptrname);
                iop->_cnt = 0;
                iop->_cnt = 0;
-       } else if(iop->_flag & (_IOWRT|_IORW)) {
+               if (resync)
+                       getc(iop);
+       }
+       else if (iop->_flag&_IOWRT) {
                fflush(iop);
                fflush(iop);
-               if (iop->_flag & _IORW) {
-                       iop->_cnt = 0;
-                       iop->_flag &= ~_IOWRT;
-                       iop->_ptr = iop->_base;
-               }
                p = lseek(fileno(iop), offset, ptrname);
        }
                p = lseek(fileno(iop), offset, ptrname);
        }
-       return(p==-1? -1: 0);
+       return(p==-1?-1:0);
 }
 }
index 1f328a4..b33252b 100644 (file)
@@ -17,9 +17,9 @@ FILE *iop;
                iop->_cnt = 0;
        if (iop->_flag&_IOREAD)
                adjust = - iop->_cnt;
                iop->_cnt = 0;
        if (iop->_flag&_IOREAD)
                adjust = - iop->_cnt;
-       else if(iop->_flag&(_IOWRT|_IORW)) {
+       else if (iop->_flag&_IOWRT) {
                adjust = 0;
                adjust = 0;
-               if (iop->_flag&_IOWRT && iop->_base && (iop->_flag&_IONBF)==0)
+               if (iop->_base && (iop->_flag&_IONBF)==0)
                        adjust = iop->_ptr - iop->_base;
        } else
                return(-1);
                        adjust = iop->_ptr - iop->_base;
        } else
                return(-1);
index 572520e..0c78110 100644 (file)
@@ -1,12 +1,16 @@
-#include       <stdio.h>
+#include <stdio.h>
 
 getw(iop)
 
 getw(iop)
-register struct _iobuf *iop;
+register FILE *iop;
 {
        register i;
 {
        register i;
+       register char *p;
+       int w;
 
 
-       i = getc(iop);
-       if (iop->_flag&_IOEOF)
-               return(-1);
-       return(i | (getc(iop)<<8));
+       p = (char *)&w;
+       for (i=sizeof(int); --i>=0;)
+               *p++ = getc(iop);
+       if (feof(iop))
+               return(EOF);
+       return(w);
 }
 }
diff --git a/usr/src/libc/stdio/intss.c b/usr/src/libc/stdio/intss.c
new file mode 100644 (file)
index 0000000..26e8535
--- /dev/null
@@ -0,0 +1,4 @@
+intss()
+{
+       return(ttyn(0) != 'x');
+}
diff --git a/usr/src/libc/stdio/ios.r b/usr/src/libc/stdio/ios.r
new file mode 100644 (file)
index 0000000..6a7aa16
--- /dev/null
@@ -0,0 +1,685 @@
+.de s
+.sp .5v
+..
+.de sr
+.ft I
+.ne 2
+\\$1
+.if t .sp .2
+.br
+.ft R
+..
+.de it
+\fI\\$1\fR
+..
+.TL
+A New Input-Output Package
+.AU
+D. M. Ritchie
+.AI
+.MH
+.PP
+A new package of IO routines is available.
+It was designed with the following goals in mind.
+.IP 1.
+It should be similar in spirit to the earlier Portable
+Library, and, to the extent possible, be compatible with it.
+At the same time a few dubious design choices
+in the Portable Library will be corrected.
+.IP 2.
+It must be as efficient as possible, both in time and in space,
+so that there will be no hesitation in using it
+no matter how critical the application.
+.IP 3.
+It must be simple to use, and also free of the magic
+numbers and mysterious calls the use
+of which mars the understandability and portability
+of many programs using older packages.
+.IP 4.
+The interface provided should be applicable on all machines,
+whether or not the programs which implement it are directly portable
+to other systems,
+or to machines other than the PDP11 running a version of Unix.
+.PP
+It is intended that this package replace the Portable Library.
+Although it is not directly compatible, as discussed below,
+it is sufficiently similar that
+modifying programs to use it should be a simple exercise.
+.PP
+The most crucial difference between this package and the Portable
+Library is that the current offering names streams in terms
+of pointers rather than by
+the integers known as `file descriptors.'
+Thus, for example, the routine which opens a named file
+returns a pointer to a certain structure rather than a number;
+the routine which reads an open file
+takes as an argument the pointer returned from the open call.
+.SH
+General Usage
+.PP
+Each program using the library must have the line
+.DS
+               #include <stdio.h>
+.DE
+which defines certain macros and variables.
+The library containing the routines is `/usr/lib/libS.a,'
+so the command to compile is
+.DS
+               cc  . . .  \-lS
+.DE
+All names in the include file intended only for internal use begin
+with an underscore `\_' to reduce the possibility
+of collision with a user name.
+The names intended to be visible outside the package are
+.IP stdin 10
+The name of the standard input file
+.IP stdout 10
+The name of the standard output file
+.IP stderr 10
+The name of the standard error file
+.IP EOF 10
+is actually \-1, and is the value returned by
+the read routines on end-of-file or error.
+.IP NULL 10
+is a notation for the null pointer, returned by
+pointer-valued functions
+to indicate an error
+.IP FILE 10
+expands to `struct \_iob' and is a useful
+shorthand when declaring pointers
+to streams.
+.IP BUFSIZ
+is a number (viz. 512)
+of the size suitable for an IO buffer supplied by the user.
+See
+.it setbuf,
+below.
+.IP "getc, getchar, putc, putchar, feof, ferror, fileno" 10
+
+.br
+are defined as macros.
+Their actions are described below;
+they are mentioned here
+to point out that it is not possible to
+redeclare them
+and that they are not actually functions;
+thus, for example, they may not have breakpoints set on them.
+.PP
+The routines in this package, like the Portable
+Library,
+offer the convenience of automatic buffer allocation
+and output flushing where appropriate.
+Absent, however, is the facility
+of changing the default input and output streams
+by assigning to `cin' and `cout.'
+The names `stdin,' stdout,' and `stderr'
+are in effect constants and may not be assigned to.
+.SH
+Calls
+.PP
+The routines in the library are in nearly one-to-one
+correspondence with those in the Portable Library.
+In several cases the name has been changed.
+This is an attempt to reduce confusion.
+.s
+.sr "FILE *fopen(filename, type) char *filename, *type"
+.it Fopen
+opens the file and, if needed, allocates a buffer for it.
+.it Filename
+is a character string specifying the name.
+.it Type
+is a character string (not a single character).
+It may be `"r",' `"w",' or `"a"' to indicate
+intent to read, write, or append.
+The value returned is a file pointer.
+If it is NULL the attempt to open failed.
+.s
+.sr "FILE *freopen(filename, type, ioptr) char *filename, *type; FILE *ioptr
+The stream named by
+.it ioptr
+is closed, if necessary, and then reopened
+as if by
+.it fopen.
+If the attempt to open fails, NULL is returned,
+otherwise
+.it ioptr,
+which will now refer to the new file.
+Often the reopened stream is
+.it stdin
+or
+.it stdout.
+.s
+.sr "int getc(ioptr) FILE *ioptr
+returns the next character from the stream named by
+.it ioptr,
+which is a pointer to a file such as returned by
+.it fopen,
+or the name
+.it stdin.
+The integer EOF is returned on end-of-file or when
+an error occurs.
+The null character \(aa\e0\(aa is a legal character.
+.s
+.sr "int fgetc(ioptr) FILE *ioptr
+acts like
+.it getc
+but is a genuine function,
+not a macro.
+.s
+.sr "putc(c, ioptr) FILE *ioptr
+.it Putc
+writes the character
+.it c
+on the output stream named by
+.it ioptr,
+which is a value returned from
+.it fopen
+or perhaps
+.it stdout
+or
+.it stderr.
+The character is returned as value,
+but EOF is returned on error.
+.s
+.sr "fputc(c, ioptr) FILE *ioptr
+.it Fputc
+acts like
+.it putc
+but is a genuine
+function, not a macro.
+.s
+.sr "fclose(ioptr) FILE *ioptr
+The file corresponding to
+.it ioptr
+is closed after any buffers are emptied.
+A buffer allocated by the IO system is freed.
+.it Fclose
+is automatic on normal termination of the program.
+.s
+.sr "fflush(ioptr) FILE *ioptr
+Any buffered information on the (output) stream named by
+.it ioptr
+is written out.
+Output files are normally buffered
+if and only if they are not directed to the terminal,
+but
+.it stderr
+is unbuffered unless
+.it setbuf
+is used.
+.s
+.sr exit(errcode)
+.it Exit
+terminates the process and returns its argument as status
+to the parent.
+This is a special version of the routine
+which calls
+.it fflush
+for each output file.
+To terminate without flushing,
+use
+.it \_exit.
+.s
+.sr "feof(ioptr) FILE *ioptr
+returns non-zero when end-of-file
+has occurred on the specified input stream.
+.s
+.sr "ferror(ioptr) FILE *ioptr
+returns non-zero when an error has occurred while reading
+or writing the named stream.
+The error indication lasts until the file has been closed.
+.s
+.sr "getchar( )"
+is identical to
+.it "getc(stdin).
+.s
+.sr "putchar(c)"
+is identical to
+.it "putc(c, stdout).
+.s
+.sr "char *gets(s) char *s
+reads characters up to a new-line from the standard input.
+The new-line character is replaced by a null character.
+It is the user's responsibility to make sure that the character array
+.it s
+is large enough.
+.it Gets
+returns its argument, or NULL if end-of-file or error occurred.
+Note that this routine is not compatible with
+.it fgets;
+it is included for downward compatibility.
+.s
+.sr "char *fgets(s, n, ioptr) char *s; FILE *ioptr
+reads up to
+.it n
+characters from the stream
+.it ioptr
+into the character pointer
+.it s.
+The read terminates with a new-line character.
+The new-line character is placed in the buffer
+followed by a null character.
+The first argument,
+or NULL if error or end-of-file occurred,
+is returned.
+.s
+.sr "puts(s) char *s
+writes the null-terminated string (character array)
+.it s
+on the standard output.
+A new-line is appended.
+No value is returned.
+Note that this routine
+is not compatible with
+.it fputs;
+it is included for downward compatibility.
+.s
+.sr "*fputs(s, ioptr) char *s; FILE *ioptr
+writes the null-terminated string (character array)
+.it s
+on the stream
+.it ioptr.
+No new-line is appended.
+No value is returned.
+.s
+.sr "ungetc(c, ioptr) FILE *ioptr
+The argument character
+.it c
+is pushed back on the input stream named by
+.it ioptr.
+Only one character may be pushed back.
+.s
+.sr "printf(format, a1, . . .) char *format
+.sr "fprintf(ioptr, format, a1, . . .) FILE *ioptr; char *format
+.sr "sprintf(s, format, a1, . . .)char *s, *format
+.it Printf
+writes on the standard output.
+.it Fprintf
+writes on the named output stream.
+.it Sprintf
+puts characters in the character array (string)
+named by
+.it s.
+The specifications are as described in section
+.it "printf
+(III)
+of the Unix Programmer's Manual.
+There is a new conversion:
+.it %m.n\fB\|g\fI
+converts a double argument in the style of
+.it e
+or
+.it f
+as most appropriate.
+.s
+.sr "scanf(format, a1, . . .) char *format
+.sr "fscanf(ioptr, format, a1, . . .) FILE *ioptr; char *format
+.sr "sscanf(s, format, a1, . . .) char *s, *format
+.it Scanf
+reads from the standard input.
+.it Fscanf
+reads from the named input stream.
+.it Sscanf
+reads from the character string
+supplied as
+.it s.
+The specifications are identical
+to those of the Portable Library.
+.it Scanf
+reads characters, interprets
+them according to a format, and stores the results in its arguments.
+It expects as arguments
+a control string
+.it format,
+described below,
+and a set of arguments,
+.I
+each of which must be a pointer,
+.R
+indicating where the converted input should be stored.
+.PP
+The
+control string
+usually contains
+conversion specifications, which are used to direct interpretation
+of input sequences.
+The control string may contain:
+.IP 1.
+Blanks, tabs or newlines, which are ignored.
+.IP 2.
+Ordinary characters (not %) which are expected to match
+the next non-space character of the input stream
+(where space characters are defined as blank, tab or newline).
+.IP 3.
+Conversion specifications, consisting of the
+character %, an optional assignment suppressing character \**,
+an optional numerical maximum field width, and a conversion
+character.
+.PP
+A conversion specification is used to direct the conversion of the
+next input field; the result
+is placed in the variable pointed to by the corresponding argument,
+unless assignment suppression was
+indicated by the \** character.
+An input field is defined as a string of non-space characters;
+it extends either to the next space character or until the field
+width, if specified, is exhausted.
+.PP
+The conversion character indicates the interpretation of the
+input field; the corresponding pointer argument must
+usually be of a restricted type.
+The following conversion characters are legal:
+.IP %
+indicates that a single % character is expected
+in the input stream at this point;
+no assignment is done.
+.IP d
+indicates that a decimal integer is expected
+in the input stream;
+the corresponding argument should be an integer pointer.
+.IP o
+indicates that an octal integer is expected in the
+input stream; the corresponding argument should be a integer pointer.
+.IP x
+indicates that a hexadecimal integer is expected in the input stream;
+the corresponding argument should be an integer pointer.
+.ti -0.2i
+.IP s
+indicates that a character string is expected;
+the corresponding argument should be a character pointer
+pointing to an array of characters large enough to accept the
+string and a terminating `\e0', which will be added.
+The input field is terminated by a space character
+or a newline.
+.IP c
+indicates that a character is expected; the
+corresponding argument should be a character pointer;
+the next input character is placed at the indicated spot.
+The normal skip over space characters is suppressed
+in this case;
+to read the next non-space character, try
+.I
+%1s.
+.R
+If a field width is given, the corresponding argument
+should refer to a character array, and the
+indicated number of characters is read.
+.IP e
+(or
+.I f\|\fR)
+.R
+indicates that a floating point number is expected in the input stream;
+the next field is converted accordingly and stored through the
+corresponding argument, which should be a pointer to a
+.it float.
+The input format for
+floating point numbers is
+an optionally signed
+string of digits
+possibly containing a decimal point, followed by an optional
+exponent field beginning with an E or e followed by an optionally signed integer.
+.IP [
+indicates a string not to be delimited by space characters.
+The left bracket is followed by a set of characters and a right
+bracket; the characters between the brackets define a set
+of characters making up the string.
+If the first character
+is not circumflex (\|^\|), the input field
+is all characters until the first character not in the set between
+the brackets; if the first character
+after the left bracket is ^, the input field is all characters
+until the first character which is in the remaining set of characters
+between the brackets.
+The corresponding argument must point to a character array.
+.PP
+The conversion characters
+.I
+d, o
+.R
+and
+.I
+x
+.R
+may be capitalized or preceded
+by
+.I
+l
+.R
+to indicate that a pointer to
+.I
+long
+.R
+rather than
+.I
+int
+.R
+is expected.
+Similarly, the conversion characters
+.I
+e
+.R
+or
+.I
+f
+.R
+may be capitalized or
+preceded by
+.I
+l
+.R
+to indicate that a pointer to 
+.I
+double
+.R
+rather than 
+.I
+float
+.R
+is in the argument list.
+The character
+.I
+h
+.R
+will function similarly in the future to indicate
+.I
+short
+.R
+data items.
+.PP
+For example, the call
+.DS
+int i; float x; char name[50];
+scanf( "%d%f%s", &i, &x, name);
+.DE
+with the input line
+.DS
+25   54.32E\(mi1  thompson
+.DE
+will assign to
+.it i
+the value
+25,
+.it x
+the value 5.432, and
+.it name
+will contain
+.it ``thompson\e0''.
+Or,
+.DS
+int i; float x; char name[50];
+scanf("%2d%f%\**d%[1234567890]", &i, &x, name);
+.DE
+with input
+.DS
+56789 0123 56a72
+.DE
+will assign 56 to
+.it i,
+789.0 to
+.it x,
+skip ``0123'',
+and place the string ``56\e0'' in
+.it name.
+The next call to
+.it getchar
+will return `a'.
+.PP
+.it Scanf
+returns as its value the number of successfully matched and assigned input
+items.
+This can be used to decide how many input items were found.
+On end of file, EOF is returned; note that this is different
+from 0, which means that the next input character does not
+match what was called for in the control string.
+.s
+.sr "fread(ptr, sizeof(*ptr), nitems, ioptr) FILE *ioptr
+reads
+.it nitems
+of data beginning at
+.it ptr
+from file
+.it ioptr.
+It behaves identically to the Portable Library's
+.it cread.
+No advance notification
+that binary IO is being done is required;
+when, for portability reasons,
+it becomes required, it will be done
+by adding an additional character to the mode-string on the
+fopen call.
+.s
+.sr "fwrite(ptr, sizeof(*ptr), nitems, ioptr) FILE *ioptr
+Like
+.it fread,
+but in the other direction.
+.s
+.sr "rewind(ioptr) FILE *ioptr
+rewinds the stream
+named by
+.it ioptr.
+It is not very useful except on input,
+since a rewound output file is still open only for output.
+.s
+.sr "system(string) char *string
+The
+.it string
+is executed by the shell as if typed at the terminal.
+.s
+.sr "getw(ioptr) FILE *ioptr
+returns the next word from the input stream named by
+.it ioptr.
+EOF is returned on end-of-file or error,
+but since this a perfectly good
+integer
+.it feof
+and
+.it ferror
+should be used.
+.s
+.sr "putw(w, ioptr) FILE *ioptr
+writes the integer
+.it w
+on the named output stream.
+.s
+.sr "setbuf(ioptr, buf) FILE *ioptr; char *buf
+.it Setbuf
+may be used after a stream has been opened
+but before IO has started.
+If
+.it buf
+is NULL,
+the stream will be unbuffered.
+Otherwise the buffer supplied will be used.
+It is a character array of sufficient size:
+.DS
+char   buf[BUFSIZ];
+.DE
+.s
+.sr "fileno(ioptr) FILE *ioptr
+returns the integer file descriptor associated with the file.
+.s
+.sr "fseek(ioptr, offset, ptrname) FILE *ioptr; long offset
+The location of the next byte in the stream
+named by
+.it ioptr
+is adjusted.
+.it Offset
+is a long integer.
+If
+.it ptrname
+is 0, the offset is measured from the beginning of the file;
+if
+.it ptrname
+is 1, the offset is measured from the current read or
+write pointer;
+if
+.it ptrname
+is 2, the offset is measured from the end of the file.
+The routine accounts properly for any buffering.
+(When this routine is used on non-Unix systems,
+the offset must be a value returned from
+.it ftell
+and the ptrname must be 0).
+.s
+.sr "long ftell(ioptr) FILE *ioptr
+The byte offset, measured from the beginning of the file,
+associated with the named stream is returned.
+Any buffering is properly accounted for.
+(On non-Unix systems the value of this call is useful only
+for handing to
+.it fseek,
+so as to position the file to the same place it was when
+.it ftell
+was called.)
+.s
+.sr "getpw(uid, buf) char *buf
+The password file is searched for the given integer user ID.
+If an appropriate line is found, it is copied into
+the character array
+.it buf,
+and 0 is returned.
+If no line is found corresponding to the user ID
+then 1 is returned.
+.s
+.sr "char *calloc(num, size)
+allocates space for
+.it num
+items each of size
+.it size.
+The space is guaranteed to be set to 0 and the pointer is
+sufficiently well aligned to be usable for any purpose.
+NULL is returned if no space is available.
+.s
+.sr "cfree(ptr) char *ptr
+Space is returned to the pool used by
+.it calloc.
+Disorder can be expected if the pointer was not obtained
+from
+.it calloc.
+.LP
+The following are macros defined by stdio.h.
+.s
+.sr isalpha(c)
+returns non-zero if the argument is alphabetic.
+.s
+.sr isupper(c)
+returns non-zero if the argument is upper-case alphabetic.
+.s
+.sr islower(c)
+returns non-zero if the argument is lower-case alphabetic.
+.s
+.sr isdigit(c)
+returns non-zero if the argument is a digit.
+.s
+.sr isspace(c)
+returns non-zero if the argument is a spacing character:
+tab, new-line, carriage return, vertical tab,
+form feed, space.
+.s
+.sr toupper(c)
+returns the upper-case character corresponding to the lower-case
+letter c.
+.s
+.sr tolower(c)
+returns the lower-case character corresponding to the upper-case
+letter c.
diff --git a/usr/src/libc/stdio/portli.cc b/usr/src/libc/stdio/portli.cc
new file mode 100644 (file)
index 0000000..480d069
--- /dev/null
@@ -0,0 +1,136 @@
+#include       <stdio.h>
+#define        ntof(n) (&_iob[n])
+
+int    cin     0;
+int    cout    1;
+
+cclose(n)
+{
+       return(fclose(ntof(n)));
+}
+
+ceof(n)
+{
+       return(feof(ntof(n)));
+}
+
+cexit(x)
+{
+       exit(x);
+}
+
+cflush(n)
+{
+       return(fflush(ntof(n)));
+}
+
+cgetc(n)
+{
+       register c;
+
+       if ((c = getc(ntof(n))) < 0)
+               return(0);
+       return(c);
+}
+
+copen(f, m)
+char m;
+{
+       register struct _iobuf *iop;
+
+       if ((iop = fopen(f, &m)) == NULL)
+               return(-1);
+       return(fileno(iop));
+}
+
+cputc(c, n)
+{
+       putc(c, ntof(n));
+}
+
+cread(a, b, c, n)
+{
+       return(fread(a, b, c, ntof(n)));
+}
+
+cwrite(a, b, c, n)
+{
+       return(fwrite(a, b, c, ntof(n)));
+}
+getcharz()
+{
+       register c;
+
+       if ((c = getc(ntof(cin))) < 0)
+               return(0);
+       return(c);
+}
+
+printf(a, b, c, d)
+{
+       struct _iobuf _strbuf;
+       if (a==-1) {
+               _strbuf._flag = _IOWRT+_IOSTRG;
+               _strbuf._ptr = b;
+               _strbuf._cnt = 32767;
+               _doprnt(c, &d, &_strbuf);
+               putc('\0', &_strbuf);
+       } else if (a<=10) {
+               _doprnt(b, &c, ntof(a));
+       } else
+               _doprnt(a, &b, ntof(cout));
+}
+
+putcharz(c)
+{
+       return(putc(c, ntof(cout)));
+}
+
+gets(s)
+char *s;
+{
+       register c;
+       register char *cs;
+
+       cs = s;
+       while ((c = getc(ntof(cin))) != '\n' && c>=0)
+               *cs++ = c;
+       if (c<0 && cs==s)
+               return(NULL);
+       *cs++ = '\0';
+       return(s);
+}
+
+puts(s)
+char *s;
+{
+       register c;
+
+       while (c = *s++)
+               putc(c, ntof(cout));
+       putc('\n', ntof(cout));
+}
+
+rew(n)
+{
+       rewind(ntof(n));
+}
+
+scanf(a, b, c, d)
+{
+       struct _iobuf strbuf;
+       register char *s;
+
+       if (a == -1) {
+               strbuf._flag = _IOREAD|_IOSTRG;
+               strbuf._ptr = strbuf._base = b;
+               strbuf._cnt = 0;
+               s = b;
+               while (*s++)
+                       strbuf._cnt++;
+               return(_doscan(&strbuf, c, &d));
+       } else if (a<=10)
+               return(_doscan(ntof(a), b, &c));
+       else
+               return(_doscan(ntof(cin), a, &b));
+}
index accd47e..b775413 100644 (file)
@@ -1,9 +1,13 @@
-#include       <stdio.h>
+#include <stdio.h>
 
 
-putw(i, iop)
-register i;
-register struct _iobuf *iop;
+putw(w, iop)
+register FILE *iop;
 {
 {
-       putc(i, iop);
-       putc(i>>8, iop);
+       register char *p;
+       register i;
+
+       p = (char *)&w;
+       for (i=sizeof(int); --i>=0;)
+               putc(*p++, iop);
+       return(ferror(iop));
 }
 }
index 2184a4f..81f323c 100644 (file)
@@ -1,13 +1,11 @@
 #include       <stdio.h>
 
 rewind(iop)
 #include       <stdio.h>
 
 rewind(iop)
-       register struct _iobuf *iop;
+register struct _iobuf *iop;
 {
        fflush(iop);
        lseek(fileno(iop), 0L, 0);
        iop->_cnt = 0;
        iop->_ptr = iop->_base;
        iop->_flag &= ~(_IOERR|_IOEOF);
 {
        fflush(iop);
        lseek(fileno(iop), 0L, 0);
        iop->_cnt = 0;
        iop->_ptr = iop->_base;
        iop->_flag &= ~(_IOERR|_IOEOF);
-       if (iop->_flag & _IORW)
-               iop->_flag &= ~(_IOREAD|_IOWRT);
 }
 }
index f981583..545a001 100644 (file)
@@ -1,6 +1,6 @@
 #include       <stdio.h>
 
 #include       <stdio.h>
 
-_strout(string, count, adjust, file, fillch)
+_strout(count, string, adjust, file, fillch)
 register char *string;
 register count;
 int adjust;
 register char *string;
 register count;
 int adjust;
diff --git a/usr/src/libc/stdio/stuff.c b/usr/src/libc/stdio/stuff.c
new file mode 100644 (file)
index 0000000..10b0ed1
--- /dev/null
@@ -0,0 +1,6 @@
+int    yyportlib       =1;
+
+wdleng()
+{
+       return(32);
+}
diff --git a/usr/src/libc/stdio/tmpnam.c b/usr/src/libc/stdio/tmpnam.c
new file mode 100644 (file)
index 0000000..b803533
--- /dev/null
@@ -0,0 +1,8 @@
+char *tmpnam(s)
+char *s;
+{
+       static seed;
+
+       sprintf(s, "temp.%d.%d", getpid(), seed++);
+       return(s);
+}
diff --git a/usr/src/libc/sys/_exit.s b/usr/src/libc/sys/_exit.s
new file mode 100644 (file)
index 0000000..000f393
--- /dev/null
@@ -0,0 +1,14 @@
+# C library -- _exit
+
+# _exit(code)
+# code is return in r0 to system
+# Same as plain exit, for user who want to define their own exit.
+
+       .set    exit,1
+.globl __exit
+
+       .align  1
+__exit:
+       .word   0x0000
+       chmk    $exit
+       halt
diff --git a/usr/src/libc/sys/abort.s b/usr/src/libc/sys/abort.s
new file mode 100644 (file)
index 0000000..7acecb2
--- /dev/null
@@ -0,0 +1,10 @@
+# C library -- abort
+
+.globl _abort
+
+       .align  1
+_abort:
+       .word   0x0000
+       halt
+       clrl    r0
+       ret
diff --git a/usr/src/libc/sys/abs.s b/usr/src/libc/sys/abs.s
new file mode 100644 (file)
index 0000000..a0a92bb
--- /dev/null
@@ -0,0 +1,22 @@
+# abs - int absolute value.
+# fabs - floating abs
+
+.globl _abs
+       .align  1
+_abs:
+       .word   0x0000
+       movl    4(ap),r0
+       bgeq    absl
+       mnegl   r0,r0
+absl:
+       ret
+
+.globl _fabs
+       .align  1
+_fabs:
+       .word   0x0000
+       movd    4(ap),r0
+       bgeq    fabsl
+       mnegd   r0,r0
+fabsl:
+       ret
index 78c88ef..a70f1f8 100644 (file)
@@ -1,26 +1,16 @@
-/ access(file, request)
-/  test ability to access file in all indicated ways
-/  1 - read
-/  2 - write
-/  4 - execute
+# access(file, request)
+#  test ability to access file in all indicated ways
+#  1 - read
+#  2 - write
+#  4 - execute
 
 
+       .set    access,33
 .globl _access
 .globl _access
-.globl csv, cret
-.comm  _errno,2
-
-.access = 33.
 
 _access:
 
 _access:
-       jsr     r5,csv
-       mov     4(r5),0f+2
-       mov     6(r5),0f+4
-       clr     r0
-       sys     0; 0f
-.data
-0:     sys     .access; ..; ..
-.text
-       bec     1f
-       mov     r0,_errno
-       mov     $-1,r0
-1:
-       jmp     cret
+       .word   0x0000
+       chmk    $access
+       bcc     noerror
+       jmp     cerror
+noerror:
+       ret
old mode 100644 (file)
new mode 100755 (executable)
index ecbbe47..8703355
@@ -1,22 +1,13 @@
-/ C library -- acct
-
-/ error = acct(string);
+# C library -- acct
 
 
+       .set    acct,51
 .globl _acct
 .globl _acct
-.globl cerror
-.acct = 51.
+.globl  cerror
 
 _acct:
 
 _acct:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       sys     0; 9f
-       bec     1f
-       jmp     cerror
-1:
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .acct; 0:..
+       .word   0x0000
+       chmk    $acct
+       bcc     noerror
+       jmp     cerror
+noerror:
+       ret
index e5f0068..461c330 100644 (file)
@@ -1,12 +1,18 @@
-/ C library - alarm
+# C library - alarm, pause
 
 
+       .set    alarm,27
 .globl _alarm
 .globl _alarm
-.alarm = 27.
+       .set    pause,29
+.globl _pause
 
 
+       .align  1
 _alarm:
 _alarm:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),r0
-       sys     .alarm
-       mov     (sp)+,r5
-       rts     pc
+       .word   0x0000
+       chmk    $alarm
+       ret
+
+       .align  1
+_pause:
+       .word   0x0000
+       chmk    $pause
+       ret
diff --git a/usr/src/libc/sys/alloca.s b/usr/src/libc/sys/alloca.s
new file mode 100644 (file)
index 0000000..2a51f6e
--- /dev/null
@@ -0,0 +1,13 @@
+# like alloc, but automatic
+# automatic free in return
+
+.globl _alloca
+_alloca:
+       .word   0x0000
+       subl2   4(ap),sp        # crude allocation
+       movl    16(fp),r1       # pc
+       movq    8(fp),ap        # new (old) ap and fp
+       bicl2   $3,sp           # 4-byte align
+       addl2   $7*4,sp         # reuse space of mscp
+       movl    sp,r0           # return value
+       jmp     (r1)            # funny return
diff --git a/usr/src/libc/sys/cerror.s b/usr/src/libc/sys/cerror.s
new file mode 100644 (file)
index 0000000..3859b03
--- /dev/null
@@ -0,0 +1,10 @@
+# C return sequence which
+# sets errno, returns -1.
+
+.globl cerror
+.comm  _errno,4
+
+cerror:
+       movl    r0,_errno
+       mnegl   $1,r0
+       ret
index 646f5e8..913e6ef 100644 (file)
@@ -1,22 +1,15 @@
-/ C library -- chdir
+# C library -- chdir
 
 
-/ error = chdir(string);
+# error = chdir(string);
 
 
+       .set    chdir,12
 .globl _chdir
 .globl _chdir
-.globl cerror
-.chdir = 12.
 
 _chdir:
 
 _chdir:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       sys     0; 9f
-       bec     1f
-       jmp     cerror
-1:
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .chdir; 0:..
+       .word   0x0000
+       chmk    $chdir
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
index da58b90..cc2e833 100644 (file)
@@ -1,23 +1,15 @@
-/ C library -- chmod
+# C library -- chmod
 
 
-/ error = chmod(string, mode);
+# error = chmod(string, mode);
 
 
+       .set    chmod,15
 .globl _chmod
 .globl _chmod
-.globl cerror
-.chmod = 15.
 
 _chmod:
 
 _chmod:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       mov     6(r5),0f+2
-       sys     0; 9f
-       bec     1f
-       jmp     cerror
-1:
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .chmod; 0:..; ..
+       .word   0x0000
+       chmk    $chmod
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
index 09dc3ee..ec49e51 100644 (file)
@@ -1,24 +1,15 @@
-/ C library -- chown
+# C library -- chown
 
 
-/ error = chown(string, owner);
+# error = chown(string, owner);
 
 
-.globl _chown,
-.globl cerror
-.chown = 16.
+       .set    chown,16
+.globl _chown
 
 _chown:
 
 _chown:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       mov     6(r5),0f+2
-       mov     8(r5),0f+4
-       sys     0; 9f
-       bec     1f
-       jmp     cerror
-1:
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .chown; 0:..; ..; ..
+       .word   0x0000
+       chmk    $chown
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
index b7e3814..139df3f 100644 (file)
@@ -1,22 +1,15 @@
-/ C library -- chroot
-
-/ error = chroot(string);
-
+#  C library -- chroot
+#  error = chroot(string);
+       .set    chroot,61
 .globl _chroot
 .globl cerror
 .globl _chroot
 .globl cerror
-.chroot = 61.
-
 _chroot:
 _chroot:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       sys     0; 9f
-       bec     1f
+       .word   0x0000
+       chmk    $chroot
+       bcc     noerror
        jmp     cerror
        jmp     cerror
-1:
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .chroot; 0:..
+noerror:
+       ret
diff --git a/usr/src/libc/sys/cleanup.s b/usr/src/libc/sys/cleanup.s
new file mode 100644 (file)
index 0000000..75e7782
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# dummy cleanup routine if none supplied by user.
+
+.globl __cleanup
+
+__cleanup:
+       .word   0x0000
+       ret
index a540e6f..dfec111 100644 (file)
@@ -1,19 +1,15 @@
-/ C library -- close
+# C library -- close
 
 
-/ error =  close(file);
+# error =  close(file);
 
 
-.globl _close,
-.globl cerror
-.close = 6.
+       .set    close,6
+.globl _close
 
 _close:
 
 _close:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),r0
-       sys     .close
-       bec     1f
-       jmp     cerror
-1:
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
+       .word   0x0000
+       chmk    $close
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
index d9e3178..933b550 100644 (file)
@@ -1,24 +1,16 @@
-/ C library -- creat
+# C library -- creat
 
 
-/ file = creat(string, mode);
-/
-/ file == -1 if error
+# file = creat(string, mode);
+#
+# file == -1 if error
 
 
+       .set    creat,8
 .globl _creat
 .globl _creat
-.globl cerror
-.creat = 8.
 
 _creat:
 
 _creat:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       mov     6(r5),0f+2
-       sys     0; 9f
-       bec     1f
-       jmp     cerror
-1:
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .creat; 0:..; ..
+       .word   0x0000
+       chmk    $creat
+       bcc     noerror
+       jmp     cerror
+noerror:
+       ret
diff --git a/usr/src/libc/sys/crt0.s b/usr/src/libc/sys/crt0.s
new file mode 100644 (file)
index 0000000..90fa265
--- /dev/null
@@ -0,0 +1,33 @@
+# C runtime startoff
+
+       .set    exit,1
+.globl _exit
+.globl start
+.globl _main
+.globl _environ
+
+#
+#      C language startup routine
+
+start:
+       .word   0x0000
+       subl2   $8,sp
+       movl    8(sp),(sp)  #  argc
+       movab   12(sp),r0
+       movl    r0,4(sp)  #  argv
+L1:
+       tstl    (r0)+  #  null args term ?
+       bneq    L1
+       cmpl    r0,*4(sp)  #  end of 'env' or 'argv' ?
+       blss    L2
+       tstl    -(r0)  # envp's are in list
+L2:
+       movl    r0,8(sp)  #  env
+       movl    r0,_environ  #  indir is 0 if no env ; not 0 if env
+       calls   $3,_main
+       pushl   r0
+       calls   $1,_exit
+       chmk    $exit
+#
+       .data
+_environ:      .space  4
index 907df94..bcd847e 100644 (file)
@@ -1,28 +1,22 @@
-/ C library -- dup
+# C library -- dup
 
 
-/      f = dup(of [ ,nf])
-/      f == -1 for error
+#      f = dup(of [ ,nf])
+#      f == -1 for error
 
 
-.globl _dup,_dup2
+       .set    dup,41
+.globl _dup
+.globl _dup2
 .globl cerror
 .globl cerror
-.dup = 41.
 
 _dup2:
 
 _dup2:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),r0
-       bis     $100,r0
-       br      1f
-
+       .word   0x0000
+       bisb2   $0100,4(ap)
+       brb     L1
 _dup:
 _dup:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),r0
-1:
-       mov     6(r5),r1
-       sys     .dup
-       bec     1f
-       jmp     cerror
-1:
-       mov     (sp)+,r5
-       rts     pc
+       .word   0x0000
+L1:
+       chmk    $dup
+       bcc     noerror
+       jmp     cerror
+noerror:
+       ret
index 3195d81..43c2a89 100644 (file)
@@ -1,23 +1,13 @@
-/ C library -- execl
+# C library -- execl
 
 
-/ execl(file, arg1, arg2, ... , 0);
-/
-/ environment automatically passed
+# execl(file, arg1, arg2, ... , 0);
+#
 
 .globl _execl
 
 .globl _execl
-.globl cerror, _environ
-.exece = 59.
 
 _execl:
 
 _execl:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       mov     r5,r0
-       add     $6,r0
-       mov     r0,0f+2
-       mov     _environ,0f+4
-       sys     0; 9f
-       jmp     cerror
-.data
-9:
-       sys     .exece; 0:..; ..; ..
+       .word   0x0000
+       pushab  8(ap)
+       pushl   4(ap)
+       calls   $2,_execv
+       ret
index ccfd5e6..d02bf1b 100644 (file)
@@ -1,25 +1,15 @@
-/ C library -- execle
+# C library -- execle
 
 
-/ execle(file, arg1, arg2, ... , 0, env);
-/
+# execle(file, arg1, arg2, ... , env);
+#
 
 .globl _execle
 
 .globl _execle
-.globl cerror
-.exece = 59.
 
 _execle:
 
 _execle:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       mov     r5,r0
-       add     $6,r0
-       mov     r0,0f+2
-1:
-       tst     (r0)+
-       bne     1b
-       mov     (r0),0f+4
-       sys     0; 9f
-       jmp     cerror
-.data
-9:
-       sys     .exece; 0:..; ..; ..
+       .word   0x0000
+       movl    (ap),r0  #  nargs
+       pushl   (ap)[r0]  #  env
+       pushab  8(ap)  # argv
+       pushl   4(ap)  #  file
+       calls   $3,_execve
+       ret
index c4abfd0..87faf4e 100644 (file)
@@ -1,23 +1,17 @@
-/ C library -- execv
+# C library -- execv
 
 
-/ execv(file, argv);
-/
-/ where argv is a vector argv[0] ... argv[x], 0
-/ last vector element must be 0
-/ environment passed automatically
+# execv(file, argv);
+#
+# where argv is a vector argv[0] ... argv[x], 0
+# last vector element must be 0
 
 
-.globl _execv,
-.globl cerror, _environ
-.exece = 59.
+.globl _execv
+.globl _environ
 
 _execv:
 
 _execv:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       mov     6(r5),0f+2
-       mov     _environ,0f+4
-       sys     0; 9f
-       jmp     cerror
-.data
-9:
-       sys     .exece; 0:..; ..; ..
+       .word   0x0000
+       pushl   _environ  #  default environ
+       pushl   8(ap)     #  argv
+       pushl   4(ap)     #  file
+       calls   $3,_execve
+       ret
index a270d0c..c240eb0 100644 (file)
@@ -1,22 +1,14 @@
-/ C library -- execve
+# C library -- execve
 
 
-/ execve(file, argv, env);
-/
-/ where argv is a vector argv[0] ... argv[x], 0
-/ last vector element must be 0
+# execve(file, argv, env);
+#
+# where argv is a vector argv[0] ... argv[x], 0
+# last vector element must be 0
 
 
+       .set    exece,59
 .globl _execve
 .globl _execve
-.globl cerror
-.exece = 59.
 
 _execve:
 
 _execve:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       mov     6(r5),0f+2
-       mov     8(r5),0f+4
-       sys     0; 9f
-       jmp     cerror
-.data
-9:
-       sys     .exece; 0:..; ..; ..
+       .word   0x0000
+       chmk    $exece
+       jmp     cerror
index 2fc69de..36f14bf 100644 (file)
@@ -1,15 +1,15 @@
-/ C library -- _exit
+# C library -- exit
 
 
-/ _exit(code)
-/ code is return in r0 to system
-/ Same as plain exit, for user who want to define their own exit.
+# exit(code)
+# code is return in r0 to system
 
 
-.globl __exit
-.exit = 1.
-
-__exit:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),r0
-       sys     .exit
+       .set    exit,1
+.globl _exit
+.globl __cleanup
 
 
+       .align  1
+_exit:
+       .word   0x0000
+       calls   $0,__cleanup
+       chmk    $exit
+       halt
index 3d248ff..c16e1f7 100644 (file)
@@ -1,26 +1,21 @@
-/ C library -- fork
+# C library -- fork
 
 
-/ pid = fork();
-/
-/ pid == 0 in child process; pid == -1 means error return
-/ in child, parents id is in par_uid if needed
+# pid = fork();
+#
+# r1 == 0 in parent process, r1 == 1 in child process.
+# r0 == pid of child in parent, r0 == pid of parent in child.
 
 
-.globl _fork, _par_uid
-.globl cerror
-.fork = 2.
+       .set    fork,2
+.globl _fork
 
 _fork:
 
 _fork:
-       mov     r5,-(sp)
-       mov     sp,r5
-       sys     .fork
-               br 1f
-       bec     2f
-       jmp     cerror
-1:
-       mov     r0,_par_uid
-       clr     r0
-2:
-       mov     (sp)+,r5
-       rts     pc
-.bss
-_par_uid: .=.+2
+       .word   0x0000
+       chmk    $fork
+       tstl    r1              # child process ?
+       bneq    child   # yes
+       bcc     parent          # if c-bit not set, fork ok
+       jmp     cerror
+child:
+       clrl    r0
+parent:
+       ret
index 9c8bf77..6b5aff5 100644 (file)
@@ -1,27 +1,17 @@
-/ C library -- fstat
+# C library -- fstat
 
 
-/ error = fstat(file, statbuf);
+# error = fstat(file, statbuf);
 
 
-/ int statbuf[17] or
-/ char statbuf[34]
-/ as appropriate
+# char statbuf[34]
 
 
+       .set    fstat,28
 .globl _fstat
 .globl _fstat
-.globl cerror
-.fstat = 28.
 
 _fstat:
 
 _fstat:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),r0
-       mov     6(r5),0f
-       sys     0; 9f
-       bec     1f
-       jmp     cerror
-1:
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .fstat; 0:..
+       .word   0x0000
+       chmk    $fstat
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
diff --git a/usr/src/libc/sys/getcsw.s b/usr/src/libc/sys/getcsw.s
new file mode 100644 (file)
index 0000000..18bbe9d
--- /dev/null
@@ -0,0 +1,11 @@
+# C library - getcsw
+
+# csw = getcsw();
+
+       .set    getcsw,38
+.globl _getcsw
+
+_getcsw:
+       .word   0x0000
+       chmk    $getcsw
+       ret
index 0a017f1..476bc40 100644 (file)
@@ -1,26 +1,25 @@
-/ C library -- getgid, getegid
+# C library -- getgid
 
 
-/ gid = getgid();
+# gid = getgid();
+#
 
 
+       .set    getgid,47
 .globl _getgid
 .globl _getgid
-.getgid = 47.
 
 _getgid:
 
 _getgid:
-       mov     r5,-(sp)
-       mov     sp,r5
-       sys     .getgid
-       mov     (sp)+,r5
-       rts     pc
+       .word   0x0000
+       chmk    $getgid
+       ret
 
 
-/ gid = getegid();
-/ returns effective gid
+# C library -- getegid
+
+# gid = getegid();
+# returns effective gid
 
 .globl _getegid
 
 _getegid:
 
 .globl _getegid
 
 _getegid:
-       mov     r5,-(sp)
-       mov     sp,r5
-       sys     .getgid
-       mov     r1,r0
-       mov     (sp)+,r5
-       rts     pc
+       .word   0x0000
+       chmk    $getgid
+       movl    r1,r0
+       ret
index 4ed1dd3..602e885 100644 (file)
@@ -1,11 +1,17 @@
-/ getpid -- get process ID
+# getpid -- get process ID
 
 
+       .set    getpid,20
 .globl _getpid
 .globl _getpid
-.getpid        = 20.
 
 _getpid:
 
 _getpid:
-       mov     r5,-(sp)
-       mov     sp,r5
-       sys     .getpid
-       mov     (sp)+,r5
-       rts     pc
+       .word   0x0000
+       chmk    $getpid
+       ret
+
+.globl _getppid
+
+_getppid:
+       .word   0x0000
+       chmk    $getpid
+       movl    r1,r0
+       ret
index 5f2f639..ee6f2e3 100644 (file)
@@ -1,27 +1,27 @@
-/ C library -- getuid, geteuid
+# C library -- getuid
 
 
-/ uid = getuid();
+# uid = getuid();
+#
 
 
+       .set    getuid,24
 .globl _getuid
 .globl _getuid
-.getuid = 24.
 
 _getuid:
 
 _getuid:
-       mov     r5,-(sp)
-       mov     sp,r5
-       sys     .getuid
-       mov     (sp)+,r5
-       rts     pc
+       .word   0x0000
+       chmk    $getuid
+       ret
 
 
 
 
-/ uid = geteuid();
-/  returns effective uid
+
+# C library -- geteuid
+
+# uid = geteuid();
+#  returns effective uid
 
 .globl _geteuid
 
 _geteuid:
 
 .globl _geteuid
 
 _geteuid:
-       mov     r5,-(sp)
-       mov     sp,r5
-       sys     .getuid
-       mov     r1,r0
-       mov     (sp)+,r5
-       rts     pc
+       .word   0x0000
+       chmk    $getuid
+       movl    r1,r0
+       ret
index 8a1b821..3e5c072 100644 (file)
@@ -1,26 +1,18 @@
-/ C library -- ioctl
-
-/ ioctl(fdes, command, arg)
-/ struct * arg;
-/
-/ result == -1 if error
-
-.globl _ioctl, cerror
-.ioctl = 54.
-
+#  C library -- ioctl
+#  ioctl(fdes,command,arg)
+#  struct * arg;
+#
+#  result == -1 if error
+       .set    ioctl,54
+.globl _ioctl
+.globl cerror
 _ioctl:
 _ioctl:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       mov     6(r5),0f+2
-       mov     8(r5),0f+4
-       sys     0; 9f
-       bec     1f
+       .word   0x0000
+       chmk    $ioctl
+       bcc     noerror
        jmp     cerror
        jmp     cerror
-1:
-       mov     (sp)+,r5
-       clr     r0
-       rts     pc
-.data
-9:
-       sys     .ioctl; 0:..; ..; ..
+noerror:
+       ret
diff --git a/usr/src/libc/sys/itol.s b/usr/src/libc/sys/itol.s
new file mode 100755 (executable)
index 0000000..1764cbc
--- /dev/null
@@ -0,0 +1,12 @@
+#
+# Convert pair of integers to a long
+#
+
+.globl _itol
+
+_itol:
+       .word   0x0000
+       ashl    $16,4(ap),r0
+       bicl3   $0xffff0000,8(ap),r1
+       addl2   r1,r0
+       ret
old mode 100644 (file)
new mode 100755 (executable)
index 0a28e4a..6d5ba88
@@ -1,21 +1,14 @@
-/ C library -- kill
+# C library -- kill
 
 
-.globl _kill, cerror
-.kill = 37.
+       .set    kill,37
+.globl _kill
+.globl cerror
 
 _kill:
 
 _kill:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(sp),r0
-       mov     6(sp),8f
-       sys     0; 9f
-       bec     1f
-       jmp     cerror
-1:
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
-
-.data
-9:
-       sys     .kill; 8:..
+       .word   0x0000
+       chmk    $kill
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
old mode 100644 (file)
new mode 100755 (executable)
index 525cd49..d1aec44
@@ -1,23 +1,17 @@
-/ C library -- link
+# C library -- link
 
 
-/ error = link(old-file, new-file);
+# error = link(old-file, new-file);
+#
 
 
+       .set    link,9
 .globl _link
 .globl _link
-.globl cerror
-.link = 9.
+.globl cerror
 
 _link:
 
 _link:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       mov     6(r5),0f+2
-       sys     0; 9f
-       bec     1f
-       jmp     cerror
-1:
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .link; 0:..; ..
+       .word   0x0000
+       chmk    $link
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
diff --git a/usr/src/libc/sys/lock.s b/usr/src/libc/sys/lock.s
deleted file mode 100644 (file)
index a5084b5..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/ lock -- C library
-
-/      lock(f)
-
-.globl _lock, cerror
-
-.lock = 53.
-
-_lock:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       sys     0; 9f
-       .data
-9:
-       sys     .lock; 0:..
-       .text
-       bec     1f
-       jmp     cerror
-1:
-       mov     (sp)+,r5
-       rts     pc
diff --git a/usr/src/libc/sys/locv.s b/usr/src/libc/sys/locv.s
new file mode 100755 (executable)
index 0000000..e02a2e8
--- /dev/null
@@ -0,0 +1,15 @@
+# C library -- long output conversion
+
+.globl _locv
+
+_locv:
+       .word   0x0000
+       subl2   $8,sp
+       cvtlp   4(ap),$11,(sp)
+       editpc  $11,(sp),edpat,str
+       skpc    $' ,$11,str
+       movl    r1,r0
+       ret
+       .data
+edpat: .byte   0xaa,0x01,0x91,0x44,0x00,0x00
+str:   .space  13
old mode 100644 (file)
new mode 100755 (executable)
index df0bfa7..afd125f
@@ -1,26 +1,15 @@
-/ C library -- lseek
+# C library -- lseek
 
 
-/ error = lseek(file, offset, ptr);
-/ long offset
-/ long lseek()
+# error = lseek(file, offset, ptr);
 
 
-.globl _lseek, cerror
-.lseek = 19.
+       .set    lseek,19
+.globl _lseek
+.globl  cerror
 
 _lseek:
 
 _lseek:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),r0
-       mov     6(r5),0f
-       mov     8(r5),0f+2
-       mov     10.(r5),0f+4
-       sys     0; 9f
-       bec     1f
-       mov     $1,r1
-       jmp     cerror
-1:
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .lseek; 0:..; ..; ..
+       .word   0x0000
+       chmk    $lseek
+       bcc     noerror
+       jmp     cerror
+noerror:
+       ret
diff --git a/usr/src/libc/sys/ltod.s b/usr/src/libc/sys/ltod.s
new file mode 100755 (executable)
index 0000000..36d7b05
--- /dev/null
@@ -0,0 +1,18 @@
+# C library
+# return floating-point from long integer
+#      d = ltod(l)
+
+.globl _ltod
+_ltod:
+       .word   0x0000
+       cvtld   4(ap),r0
+       ret
+
+# return long integer from floating
+#      dtol(d, l)
+
+.globl _dtol
+_dtol:
+       .word   0x0000
+       cvtdl   4(ap),*12(ap)
+       ret
diff --git a/usr/src/libc/sys/ltoi.s b/usr/src/libc/sys/ltoi.s
new file mode 100755 (executable)
index 0000000..b01ae7c
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# ltoi(long) returns the long as an int.
+
+.globl _ltoi
+_ltoi:
+       .word   0x0000
+       movl    4(ap),r0
+       ret
diff --git a/usr/src/libc/sys/makdir.s b/usr/src/libc/sys/makdir.s
new file mode 100755 (executable)
index 0000000..dd4596c
--- /dev/null
@@ -0,0 +1,16 @@
+# C library -- makdir
+
+# error = makdir(string);
+
+       .set    mknod,14
+.globl _makdir
+.globl  cerror
+
+_makdir:
+       .word   0x0000
+       chmk    $mknod
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
diff --git a/usr/src/libc/sys/mcount.s b/usr/src/libc/sys/mcount.s
new file mode 100755 (executable)
index 0000000..e9d84a7
--- /dev/null
@@ -0,0 +1,19 @@
+# count subroutine called during profiling
+
+.globl mcount
+.comm  countbase,4
+
+mcount:
+       movl    (r0),r1
+       beql    init
+incr:
+       incl    (r1)
+return:
+       rsb
+init:
+       movl    countbase,r1
+       beql    return
+       addl2   $8,countbase
+       movl    (sp),(r1)+
+       movl    r1,(r0)
+       brb     incr
diff --git a/usr/src/libc/sys/mcrt0.s b/usr/src/libc/sys/mcrt0.s
new file mode 100644 (file)
index 0000000..fdc0dc1
--- /dev/null
@@ -0,0 +1,83 @@
+# C runtime startoff including monitoring
+
+       .set    exit,1
+       .set    cbufs,300
+
+.globl start
+.globl _monitor
+.globl _sbrk
+.globl _main
+.globl _exit
+.globl _IEH3exit
+.globl _etext
+.globl _environ
+.globl __cleanup
+.comm  countbase,4
+
+
+start:
+       .word   0x0000
+       subl2   $8,sp
+       movl    8(sp),(sp)  #  argc
+       movab   12(sp),r0
+       movl    r0,4(sp)  #  argv
+L1:
+       tstl    (r0)+  #  null args term ?
+       bneq    L1
+       cmpl    r0,*4(sp)  #  end of 'env' or 'argv' ?
+       blss    L2
+       tstl    -(r0)  # envp's are in list
+L2:
+       movl    r0,8(sp)  #  env
+       movl    r0,_environ  #  indir is 0 if no env ; not 0 if env
+
+       subl3   $eprol,$_etext,r1
+       addl2   $7,r1
+       extzv   $3,$16,r1,r1
+       addl2   r1,r1           # tally size
+       addl2   $8*cbufs+12,r1          # entrance count plus header
+       pushl   $cbufs          # # entrance counters
+       pushl   r1              # bufsiz
+       pushl   r1              # for sbrk
+       calls   $1,_sbrk
+       cmpl    r0,$-1
+       beql    nospace
+# bandaid for sbrk not clearing memory (remove bandaid when fixed)
+#      addl3   (sp),(sp),r1
+#L100:
+#      clrb    -1(r0)[r1]
+#      sobgtr  r1,L100
+# end bandaid
+       pushl   r0
+       addl3   $12,r0,countbase
+       pushab  _etext
+       pushab  eprol
+       calls   $5,_monitor
+       calls   $3,_main
+       pushl   r0
+       calls   $1,_exit
+
+       .data
+_environ:      .space  4
+emsg:
+       .byte   'N,'o,' ,'s,'p,'a,'c,'e,' ,'f,'o,'r,' 
+       .byte   'm,'o,'n,'i,'t,'o,'r,' ,'b,'u,'f,'f,'e,'r,0xa,0x0
+em1:
+       .text
+
+nospace:
+       pushl   $em1-emsg
+       pushab  emsg
+       pushl   $2
+       calls   $3,_write
+
+_exit:
+_IEH3exit:
+       .word   0x0000
+       calls   $0,__cleanup
+       pushl   $0
+       calls   $1,_monitor
+       chmk    $exit
+eprol:
+
+
diff --git a/usr/src/libc/sys/mdate.s b/usr/src/libc/sys/mdate.s
new file mode 100755 (executable)
index 0000000..b4596d6
--- /dev/null
@@ -0,0 +1,14 @@
+# C library-- mdate
+
+       .set    mdate,30
+.globl _mdate
+.globl  cerror
+
+_mdate:
+       .word   0x0000
+       chmk    $mdate
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
index 8064307..218a43a 100644 (file)
@@ -1,23 +1,16 @@
-/ C library -- mknod
+# C library -- mknod
 
 
-/ error = mknod(string, mode, major.minor);
+# error = mknod(string, mode, major.minor);
 
 
-.globl _mknod, cerror
+       .set    mknod,14
+.globl _mknod
+.globl  cerror
 
 
-.mknod = 14.
 _mknod:
 _mknod:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       mov     6(r5),0f+2
-       mov     8(r5),0f+4
-       sys     0; 9f
-       bec     1f
-       jmp     cerror
-1:
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .mknod; 0:..; ..; ..
+       .word   0x0000
+       chmk    $mknod
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
old mode 100644 (file)
new mode 100755 (executable)
index f3f38c2..d4273eb
@@ -1,24 +1,16 @@
-/ C library -- mount
+# C library -- mount
 
 
-/ error = mount(dev, file, flag)
+# error = mount(dev, file, flag)
 
 
-.globl _mount,
-.globl cerror
-.mount = 21.
+       .set    mount,21
+.globl _mount
+.globl  cerror
 
 _mount:
 
 _mount:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(sp),0f
-       mov     6(sp),0f+2
-       mov     8(sp),0f+4
-       sys     0; 9f
-       bec     1f
-       jmp     cerror
-1:
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .mount; 0:..; ..; ..
+       .word   0x0000
+       chmk    $mount
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
diff --git a/usr/src/libc/sys/mpxcall.s b/usr/src/libc/sys/mpxcall.s
deleted file mode 100644 (file)
index 2efecb5..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-.globl _mpxcall, cerror
-
-_mpxcall:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       mov     6(r5),0f+2
-call:
-       sys     0; 9f
-       bec     1f
-       jmp     cerror
-1:
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     56.; 0:..; ..
-
diff --git a/usr/src/libc/sys/nargs.s b/usr/src/libc/sys/nargs.s
new file mode 100755 (executable)
index 0000000..a493983
--- /dev/null
@@ -0,0 +1,9 @@
+# C library -- nargs
+
+
+.globl _nargs
+
+_nargs:
+       .word   0x0000
+       movzbl  *8(fp),r0       # 8(fp) is old ap
+       ret
diff --git a/usr/src/libc/sys/nexect.s b/usr/src/libc/sys/nexect.s
new file mode 100644 (file)
index 0000000..865313e
--- /dev/null
@@ -0,0 +1,20 @@
+# C library -- exect
+
+# exect(file, argv, env);
+#
+# where argv is a vector argv[0] ... argv[x], 0
+# last vector element must be 0
+#
+# The same as execve except that it sets the TBIT causing
+# a trace trap on the first instruction of the executed process,
+# to give a chance to set breakpoints.
+
+.globl _exect
+.globl cerror
+
+       .set    execve,59
+_exect:
+       .word   0x0000
+       bispsw  $0x10           # set tbit
+       chmk    $execve
+       jmp     cerror
old mode 100644 (file)
new mode 100755 (executable)
index 3dda6d5..41bcd29
@@ -1,19 +1,16 @@
-/ C library-- nice
+# C library-- nice
 
 
-/ error = nice(hownice)
+# error = nice(hownice)
 
 
-.globl _nice,
-.globl cerror
-.nice = 34.
+       .set    nice,34
+.globl _nice
+.globl  cerror
 
 _nice:
 
 _nice:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(sp),r0
-       sys     .nice
-       bec     1f
-       jmp     cerror
-1:
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
+       .word   0x0000
+       chmk    $nice
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
old mode 100644 (file)
new mode 100755 (executable)
index b69cbb8..4da292b
@@ -1,23 +1,17 @@
-/ C library -- open
+# C library -- open
 
 
-/ file = open(string, mode)
-/ file == -1 means error
+# file = open(string, mode)
+#
+# file == -1 means error
 
 
-.globl _open,
-.globl cerror
-.open = 5.
+       .set    open,5
+.globl _open
+.globl  cerror
 
 _open:
 
 _open:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       mov     6(r5),0f+2
-       sys     0; 9f
-       bec     1f
-       jmp     cerror
-1:
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .open; 0:..; ..
+       .word   0x0000
+       chmk    $open
+       bcc     noerror
+       jmp     cerror
+noerror:
+       ret
diff --git a/usr/src/libc/sys/pause.s b/usr/src/libc/sys/pause.s
deleted file mode 100644 (file)
index 1ebe761..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/ C library - pause
-
-.globl _pause
-.pause = 29.
-
-_pause:
-       mov     r5,-(sp)
-       mov     sp,r5
-       sys     .pause
-       mov     (sp)+,r5
-       rts     pc
diff --git a/usr/src/libc/sys/phys.s b/usr/src/libc/sys/phys.s
deleted file mode 100644 (file)
index e1279a1..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/ phys -- C library
-
-/      phys(seg, size, physad)
-
-.globl _phys, cerror
-
-.phys = 52.
-
-_phys:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       mov     6(r5),0f+2
-       mov     8(r5),0f+4
-       sys     0; 9f
-       .data
-9:
-       sys     .phys; 0: ..; ..; ..
-       .text
-       bec     1f
-       jmp     cerror
-1:
-       mov     (sp)+,r5
-       rts     pc
index 04c8e59..fe28ed0 100644 (file)
@@ -1,24 +1,20 @@
-/ pipe -- C library
+# pipe -- C library
 
 
-/      pipe(f)
-/      int f[2];
+#      pipe(f)
+#      int f[2];
 
 
-.globl _pipe, cerror
-
-.pipe = 42.
+       .set    pipe,42
+.globl _pipe
+.globl  cerror
 
 _pipe:
 
 _pipe:
-       mov     r5,-(sp)
-       mov     sp,r5
-       sys     .pipe
-       bec     1f
-       jmp     cerror
-1:
-       mov     r2,-(sp)
-       mov     4(r5),r2
-       mov     r0,(r2)+
-       mov     r1,(r2)
-       clr     r0
-       mov     (sp)+,r2
-       mov     (sp)+,r5
-       rts     pc
+       .word   0x0000
+       chmk    $pipe
+       bcc     noerror
+       jmp     cerror
+noerror:
+       movl    4(ap),r2
+       movl    r0,(r2)+
+       movl    r1,(r2)
+       clrl    r0
+       ret
diff --git a/usr/src/libc/sys/prof.s b/usr/src/libc/sys/prof.s
new file mode 100755 (executable)
index 0000000..bac187b
--- /dev/null
@@ -0,0 +1,8 @@
+# profil
+
+       .set    prof,44
+.globl _profil
+_profil:
+       .word   0x0000
+       chmk    $prof
+       ret
diff --git a/usr/src/libc/sys/profil.s b/usr/src/libc/sys/profil.s
deleted file mode 100644 (file)
index bc4abb9..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/ profil
-
-.globl _profil
-.prof = 44.
-
-_profil:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       mov     6(r5),0f+2
-       mov     10(r5),0f+4
-       mov     12(r5),0f+6
-       sys     0; 9f
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .prof; 0:..; ..; ..; ..
old mode 100644 (file)
new mode 100755 (executable)
index d400429..be6b9db
@@ -1,28 +1,17 @@
-/ ptrace -- C library
+# ptrace -- C library
 
 
-/      result = ptrace(req, pid, addr, data);
-
-.ptrace = 26.
-indir = 0
+#      result = ptrace(req, pid, addr, data);
 
 
+       .set    ptrace,26
 .globl _ptrace
 .globl _ptrace
-.globl cerror, _errno
+.globl cerror
+.globl  _errno
 
 _ptrace:
 
 _ptrace:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4.(r5),0f+4
-       mov     6.(r5),0f+0
-       mov     8.(r5),0f+2
-       mov     10.(r5),r0
-       clr     _errno
-       sys     indir; 9f
-       bec     1f
-       jmp     cerror
-1:
-       mov     (sp)+,r5
-       rts     pc
-
-.data
-9:
-       sys     .ptrace; 0: .=.+6
+       .word   0x0000
+       clrl    _errno
+       chmk    $ptrace
+       bcc     noerror
+       jmp     cerror
+noerror:
+       ret
index 5225cf6..e4b1cbf 100644 (file)
@@ -1,24 +1,17 @@
-/ C library -- read
+# C library -- read
 
 
-/ nread = read(file, buffer, count);
-/ nread ==0 means eof; nread == -1 means error
+# nread = read(file, buffer, count);
+#
+# nread ==0 means eof; nread == -1 means error
 
 
+       .set    read,3
 .globl _read
 .globl _read
-.globl cerror
-.read = 3.
+.globl  cerror
 
 _read:
 
 _read:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),r0
-       mov     6(r5),0f
-       mov     8(r5),0f+2
-       sys     0; 9f
-       bec     1f
-       jmp     cerror
-1:
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .read; 0:..; ..
+       .word   0x0000
+       chmk    $read
+       bcc     noerror
+       jmp     cerror
+noerror:
+       ret
diff --git a/usr/src/libc/sys/reset.s b/usr/src/libc/sys/reset.s
new file mode 100755 (executable)
index 0000000..acfce11
--- /dev/null
@@ -0,0 +1,45 @@
+# C library -- reset, setexit
+
+#      reset(x)
+# will generate a "return" from
+# the last call to
+#      setexit()
+# by restoring r6 - r12, ap, fp
+# and doing a return.
+# The returned value is x; on the original
+# call the returned value is 0.
+#
+# useful for going back to the main loop
+# after a horrible error in a lowlevel
+# routine.
+
+.globl _setexit
+.globl _reset
+
+       .align  1
+_setexit:
+       .word   0x0000
+       movab   setsav,r0
+       movq    r6,(r0)+
+       movq    r8,(r0)+
+       movq    r10,(r0)+
+       movq    8(fp),(r0)+             # ap, fp
+       movab   4(ap),(r0)+             # sp
+       movl    16(fp),(r0)             # pc
+       clrl    r0
+       ret
+
+       .align  1
+_reset:
+       .word   0x0000
+       movl    4(ap),r0        # returned value
+       movab   setsav,r1
+       movq    (r1)+,r6
+       movq    (r1)+,r8
+       movq    (r1)+,r10
+       movq    (r1)+,r12
+       movl    (r1)+,sp
+       jmp     *(r1)
+
+       .data
+setsav:        .space  10*4
old mode 100644 (file)
new mode 100755 (executable)
index 78e15e0..3b79e16
@@ -1,45 +1,42 @@
-/old = sbrk(increment);
-/
-/sbrk gets increment more core, and returns a pointer
-/      to the beginning of the new core area
-/
-.globl _sbrk, _brk
-.globl _end, cerror
-.break = 17.
+#old = sbrk(increment);
+#
+#sbrk gets increment more core, and returns a pointer
+#      to the beginning of the new core area
+#
+       .set    break,17
+.globl _sbrk
+.globl _end
+.globl  cerror
 
 
+       .align  1
 _sbrk:
 _sbrk:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       beq     1f
-       add     nd,0f
-       sys     0; 9f
-       bec     1f
-       jmp     cerror
-1:
-       mov     nd,r0
-       add     4(r5),nd
-       mov     (sp)+,r5
-       rts     pc
+       .word   0x0000
+       addl3   nd,4(ap),-(sp)
+       pushl   $1
+       movl    ap,r3
+       movl    sp,ap
+       chmk    $break
+       bcc     noerr1
+       jmp     cerror
+noerr1:
+       movl    nd,r0
+       addl2   4(r3),nd
+       ret
 
 
-/ brk(value)
-/ as described in man2.
-/ returns 0 for ok, -1 for error.
+.globl _brk
+# brk(value)
+# as described in man2.
+# returns 0 for ok, -1 for error.
 
 _brk:
 
 _brk:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       sys     0; 9f
-       bec     1f
-       jmp     cerror
-1:
-       mov     4(r5),nd
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
+       .word   0x0000
+       chmk    $break
+       bcc     noerr2
+       jmp     cerror
+noerr2:
+       movl    4(ap),nd
+       clrl    r0
+       ret
 
 
-.data
-9:
-       sys     .break; 0:..
-nd:    _end
+       .data
+nd:    .long   _end
old mode 100644 (file)
new mode 100755 (executable)
index d781e6e..9e8e749
@@ -1,19 +1,16 @@
-/ C library -- setgid
+# C library -- setgid
 
 
-/ error = setgid(uid);
+# error = setgid(uid);
 
 
+       .set    setgid,46
 .globl _setgid
 .globl _setgid
-.globl cerror
-.setgid = 46.
+.globl  cerror
 
 _setgid:
 
 _setgid:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),r0
-       sys     .setgid
-       bec     1f
-       jmp     cerror
-1:
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
+       .word   0x0000
+       chmk    $setgid
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
diff --git a/usr/src/libc/sys/setjmp.s b/usr/src/libc/sys/setjmp.s
new file mode 100755 (executable)
index 0000000..798fc3e
--- /dev/null
@@ -0,0 +1,40 @@
+# C library -- setjmp, longjmp
+
+#      longjmp(a,v)
+# will generate a "return(v)" from
+# the last call to
+#      setjmp(a)
+# by restoring r6-pc from 'a'
+# and doing a return.
+#
+
+.globl _setjmp
+.globl _longjmp
+
+       .align  1
+_setjmp:
+       .word   0x0000
+       movl    4(ap),r0
+       movq    r6,(r0)+
+       movq    r8,(r0)+
+       movq    r10,(r0)+
+       movq    8(fp),(r0)+             # ap, fp
+       movab   8(ap),(r0)+             # sp
+       movl    16(fp),(r0)             # pc
+       clrl    r0
+       ret
+
+       .align  1
+_longjmp:
+       .word   0x0000
+       movl    4(ap),r1
+       movq    (r1)+,r6
+       movq    (r1)+,r8
+       movq    (r1)+,r10
+       movq    (r1)+,r12
+       movl    (r1)+,sp
+       movl    8(ap),r0  #  return(v)
+       bneq    L1
+       movzbl  $1,r0
+L1:
+       jmp     *(r1)
old mode 100644 (file)
new mode 100755 (executable)
index 25d2ef8..a866677
@@ -1,19 +1,16 @@
-/ C library -- setuid
+# C library -- setuid
 
 
-/ error = setuid(uid);
+# error = setuid(uid);
 
 
+       .set    setuid,23
 .globl _setuid
 .globl _setuid
-.globl cerror
-.setuid = 23.
+.globl  cerror
 
 _setuid:
 
 _setuid:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),r0
-       sys     .setuid
-       bec     1f
-       jmp     cerror
-1:
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
+       .word   0x0000
+       chmk    $setuid
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
index ee2896c..e365336 100644 (file)
@@ -1,89 +1,19 @@
-/ C library -- signal
+# C library -- signal
 
 
-/ signal(n, 0); /* default action on signal(n) */
-/ signal(n, odd); /* ignore signal(n) */
-/ signal(n, label); /* goto label on signal(n) */
-/ returns old label, only one level.
+# signal(n, 0); /* default action on signal(n) */
+# signal(n, odd); /* ignore signal(n) */
+# signal(n, label); /* goto label on signal(n) */
+# returns old label, only one level.
 
 
-rtt    = 6
-.signal        = 48.
-.globl _signal, cerror
+       .set    signal,48
+.globl _signal
+.globl  cerror
 
 
+       .align  1
 _signal:
 _signal:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),r1
-       cmp     r1,$NSIG
-       bhis    2f
-       mov     6(r5),r0
-       mov     r1,0f
-       asl     r1
-       mov     dvect(r1),-(sp)
-       mov     r0,dvect(r1)
-       mov     r0,0f+2
-       beq     1f
-       bit     $1,r0
-       bne     1f
-       asl     r1
-       add     $tvect,r1
-       mov     r1,0f+2
-1:
-       sys     0; 9f
-       bes     3f
-       bit     $1,r0
-       beq     1f
-       mov     r0,(sp)
-1:
-       mov     (sp)+,r0
-       mov     (sp)+,r5
-       rts     pc
-2:
-       mov     $22.,r0         / EINVAL
-3:
-       jmp     cerror
-
-NSIG = 0
-tvect:
-       jsr     r0,1f; NSIG=NSIG+1
-       jsr     r0,1f; NSIG=NSIG+1
-       jsr     r0,1f; NSIG=NSIG+1
-       jsr     r0,1f; NSIG=NSIG+1
-       jsr     r0,1f; NSIG=NSIG+1
-       jsr     r0,1f; NSIG=NSIG+1
-       jsr     r0,1f; NSIG=NSIG+1
-       jsr     r0,1f; NSIG=NSIG+1
-       jsr     r0,1f; NSIG=NSIG+1
-       jsr     r0,1f; NSIG=NSIG+1
-       jsr     r0,1f; NSIG=NSIG+1
-       jsr     r0,1f; NSIG=NSIG+1
-       jsr     r0,1f; NSIG=NSIG+1
-       jsr     r0,1f; NSIG=NSIG+1
-       jsr     r0,1f; NSIG=NSIG+1
-       jsr     r0,1f; NSIG=NSIG+1
-       jsr     r0,1f; NSIG=NSIG+1
-       jsr     r0,1f; NSIG=NSIG+1
-       jsr     r0,1f; NSIG=NSIG+1
-       jsr     r0,1f; NSIG=NSIG+1
-
-1:
-       mov     r1,-(sp)
-       mov     r2,-(sp)
-       mov     r3,-(sp)
-       mov     r4,-(sp)
-       sub     $tvect+4,r0
-       asr     r0
-       mov     r0,-(sp)
-       asr     (sp)
-       jsr     pc,*dvect(r0)
-       tst     (sp)+
-       mov     (sp)+,r4
-       mov     (sp)+,r3
-       mov     (sp)+,r2
-       mov     (sp)+,r1
-       mov     (sp)+,r0
-       rtt
-.data
-9:
-       sys     .signal; 0:..; ..
-.bss
-dvect: .=.+[NSIG*2]
+       .word   0x0000
+       chmk    $signal
+       bcc     noerror
+       jmp     cerror
+noerror:
+       ret
old mode 100644 (file)
new mode 100755 (executable)
index 1ed4cbc..3d59d7e
@@ -1,23 +1,18 @@
-/ C library -- stat
+# C library -- stat
 
 
-/ error = stat(string, statbuf);
+# error = stat(string, statbuf);
 
 
+# char statbuf[36]
+
+       .set    stat,18
 .globl _stat
 .globl _stat
-.globl cerror
-.stat = 18.
+.globl  cerror
 
 _stat:
 
 _stat:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       mov     6(r5),0f+2
-       sys     0; 9f
-       bec     1f
-       jmp     cerror
-1:
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .stat; 0:..; ..
+       .word   0x0000
+       chmk    $stat
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
old mode 100644 (file)
new mode 100755 (executable)
index beeb26d..294d0c5
@@ -1,19 +1,13 @@
-/ error = stime(&long)
-
+       .set    stime,25
 .globl _stime
 .globl _stime
-.globl cerror
-.stime = 25.
+.globl  cerror
 
 _stime:
 
 _stime:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(sp),r1
-       mov     (r1)+,r0
-       mov     (r1),r1
-       sys     .stime
-       bec     1f
-       jmp     cerror
-1:
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
+       .word   0x0000
+       movl    *4(ap),4(ap)    # copy time to set
+       chmk    $stime
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
old mode 100644 (file)
new mode 100755 (executable)
index a99cd2f..0617de7
@@ -1,9 +1,7 @@
+       .set    sync,36
 .globl _sync
 .globl _sync
-.sync = 36.
 
 _sync:
 
 _sync:
-       mov     r5,-(sp)
-       mov     sp,r5
-       sys     .sync
-       mov     (sp)+,r5
-       rts     pc
+       .word   0x0000
+       chmk    $sync
+       ret
diff --git a/usr/src/libc/sys/syscall.s b/usr/src/libc/sys/syscall.s
new file mode 100644 (file)
index 0000000..8beda64
--- /dev/null
@@ -0,0 +1,11 @@
+       .globl  _syscall
+       .globl  cerror
+_syscall:
+       .word   0x0000
+       movl    4(ap),r0                # syscall number
+       subl3   $1,(ap)+,(ap)   # one fewer arguments
+       chmk    r0                              # do it
+       bcs             L1
+       ret
+L1:
+       jmp             cerror
old mode 100644 (file)
new mode 100755 (executable)
index 3a56f6a..023d772
@@ -1,37 +1,26 @@
-/ C library -- time
+# C library -- time
 
 
-/ tvec = time(tvec);
-/
-/ tvec[0], tvec[1] contain the time
+# tvec = time(tvec);
+#
 
 
+       .set    time,13
 .globl _time
 .globl _time
-.time = 13.
-
 
 _time:
 
 _time:
-       mov     r5,-(sp)
-       mov     sp,r5
-       sys     .time
-       mov     r2,-(sp)
-       mov     4(r5),r2
-       beq     1f
-       mov     r0,(r2)+
-       mov     r1,(r2)+
-1:
-       mov     (sp)+,r2
-       mov     (sp)+,r5
-       rts     pc
+       .word   0x0000
+       chmk    $time
+       movl    4(ap),r1
+       beql    nostore
+       movl    r0,(r1)
+nostore:
+       ret
 
 
+# ftime
+#
+       .set    ftime,35
 .globl _ftime
 .globl _ftime
-.ftime = 35.
 
 _ftime:
 
 _ftime:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       sys     0; 9f
-       .data
-9:     sys     .ftime; 0:..
-       .text
-       mov     (sp)+,r5
-       rts     pc
+       .word   0x0000
+       chmk    $ftime
+       ret
old mode 100644 (file)
new mode 100755 (executable)
index 1ac8e4e..c761654
@@ -1,15 +1,9 @@
-/ C library -- times
+# C library -- times
 
 
+       .set    times,43
 .globl _times
 .globl _times
-.times = 43.
 
 _times:
 
 _times:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       sys     0; 9f
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .times; 0:..
+       .word   0x0000
+       chmk    $times
+       ret
index 4c88760..04d47ee 100644 (file)
@@ -1,21 +1,15 @@
-/ C library -- umask
-
-/ omask = umask(mode);
-
+#  C library -- umask
+#  omask = umask(mode);
+       .set    umask,60
 .globl _umask
 .globl cerror
 .globl _umask
 .globl cerror
-.umask = 60.
 
 _umask:
 
 _umask:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       sys     0; 9f
-       bec     1f
+       .word   0x0000
+       chmk    $umask
+       bcc     noerror
        jmp     cerror
        jmp     cerror
-1:
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .umask; 0:..
+noerror:
+       ret
old mode 100644 (file)
new mode 100755 (executable)
index a98a648..bd993a7
@@ -1,23 +1,15 @@
-/ C library -- umount
+# C library -- umount/
 
 
+       .set    umount,22
 .globl _umount
 .globl cerror
 .globl _umount
 .globl cerror
-indir  = 0
-.umount = 22.
-.comm  _errno,2
+.comm  _errno,4
 
 _umount:
 
 _umount:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(sp),0f
-       sys     indir; 9f
-       bec     1f
-       jmp     cerror
-1:
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
-
-.data
-9:
-       sys     .umount; 0:..
+       .word   0x0000
+       chmk    $umount
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
index 9aeb18a..1846a6e 100644 (file)
@@ -1,22 +1,17 @@
-/ C library -- unlink
+# C library -- unlink
 
 
-/ error = unlink(string);
+# error = unlink(string);
+#
 
 
-.globl _unlink,
-.globl cerror
-.unlink = 10.
+       .set    unlink,10
+.globl _unlink
+.globl  cerror
 
 _unlink:
 
 _unlink:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       sys     0; 9f
-       bec     1f
-       jmp     cerror
-1:
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .unlink; 0:..
+       .word   0x0000
+       chmk    $unlink
+       bcc     noerror
+       jmp     cerror
+noerror:
+       clrl    r0
+       ret
index 14a3071..4e6b235 100644 (file)
@@ -1,23 +1,15 @@
-/ C library -- utime
-
-/ error = utime(string, timev);
-
+# C library -- utime
+#  error = utime(string,timev);
 .globl _utime
 .globl cerror
 .globl _utime
 .globl cerror
-.utime = 30.
-
+       .set    utime,30
 _utime:
 _utime:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),0f
-       mov     6(r5),0f+2
-       sys     0; 9f
-       bec     1f
+       .word   0x0000
+       chmk    $utime
+       bcc     noerror
        jmp     cerror
        jmp     cerror
-1:
-       clr     r0
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .utime; 0:..; ..
+noerror:
+       ret
old mode 100644 (file)
new mode 100755 (executable)
index b4de107..94267fb
@@ -1,26 +1,25 @@
-/ C library -- wait
+# C library -- wait
 
 
-/ pid = wait(0);
-/   or,
-/ pid = wait(&status);
-/
-/ pid == -1 if error
-/ status indicates fate of process, if given
+# pid = wait(0);
+#   or,
+# pid = wait(&status);
+#
+# pid == -1 if error
+# status indicates fate of process, if given
 
 
+       .set    wait,7
 .globl _wait
 .globl _wait
-.globl cerror
-.wait = 7.
+.globl  cerror
 
 
+       .align  1
 _wait:
 _wait:
-       mov     r5,-(sp)
-       mov     sp,r5
-       sys     .wait
-       bec     1f
-       jmp     cerror
-1:
-       tst     4(r5)
-       beq     1f
-       mov     r1,*4(r5)       / status return
-1:
-       mov     (sp)+,r5
-       rts     pc
+       .word   0x0000
+       chmk    $wait
+       bcc     noerror
+       jmp     cerror
+noerror:
+       tstl    4(ap)           # status desired?
+       beql    nostatus        # no
+       movl    r1,*4(ap)       # store child's status
+nostatus:
+       ret
old mode 100644 (file)
new mode 100755 (executable)
index 505795c..2b6421f
@@ -1,25 +1,17 @@
-/ C library -- write
+# C library -- write
 
 
-/ nwritten = write(file, buffer, count);
-/
-/ nwritten == -1 means error
+# nwritten = write(file, buffer, count);
+#
+# nwritten == -1 means error
 
 
+       .set    write,4
 .globl _write
 .globl _write
-.globl cerror
-.write = 4.
+.globl  cerror
 
 _write:
 
 _write:
-       mov     r5,-(sp)
-       mov     sp,r5
-       mov     4(r5),r0
-       mov     6(r5),0f
-       mov     8(r5),0f+2
-       sys     0; 9f
-       bec     1f
-       jmp     cerror
-1:
-       mov     (sp)+,r5
-       rts     pc
-.data
-9:
-       sys     .write; 0:..; ..
+       .word   0x0000
+       chmk    $write
+       bcc     noerror
+       jmp     cerror
+noerror:
+       ret
diff --git a/usr/src/libc/v6/access.c b/usr/src/libc/v6/access.c
deleted file mode 100644 (file)
index bb4c968..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <sys/types.h>
-#include <sys/stat.h>
-
-access(name, mode)
-{
-       struct stat foo;
-
-       return(stat(name, &foo));
-}
diff --git a/usr/src/libc/v6/chown.c b/usr/src/libc/v6/chown.c
deleted file mode 100644 (file)
index ec0f9e8..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-chown(name, owner, group)
-char *name;
-int owner, group;
-{
-       return(syscall(16, 0, 0, name, (group<<8)|(owner&0377), 0));
-}
diff --git a/usr/src/libc/v6/execl.c b/usr/src/libc/v6/execl.c
deleted file mode 100644 (file)
index d19879e..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-execl(name, arg1, a2, a3, a4, a5)
-char *name, arg1, a2, a3, a4, a5;
-{
-       char *args[6];
-
-       args[0] = arg1;
-       args[1] = a2;
-       args[2] = a3;
-       args[3] = a4;
-       args[4] = a5;
-       args[5] = 0;
-
-       syscall(11, 0, 0, name, args, 0);
-}
diff --git a/usr/src/libc/v6/ftime.c b/usr/src/libc/v6/ftime.c
deleted file mode 100644 (file)
index 2a069e7..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <sys/types.h>
-#include <sys/timeb.h>
-
-static struct timeb gorp = {
-       0L,
-       0,
-       5*60,
-       1
-};
-
-ftime(gorpp)
-struct timeb *gorpp;
-{
-       *gorpp = gorp;
-       return(0);
-}
diff --git a/usr/src/libc/v6/gtty.c b/usr/src/libc/v6/gtty.c
deleted file mode 100644 (file)
index 62c2913..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-gtty(fd, buf)
-int fd;
-int *buf;
-{
-       if (syscall(32, fd, 0, buf, 0, 0) < 0)
-               return(-1);
-       return(0);
-}
diff --git a/usr/src/libc/v6/lseek.c b/usr/src/libc/v6/lseek.c
deleted file mode 100644 (file)
index c3f0e0a..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-lseek(fd, off, ptr)
-int fd, ptr;
-long off;
-{
-       unsigned a;
-
-       a = off;
-
-       if (a == off)
-               return (syscall(19, fd, 0, a, ptr, 0));
-       a = off/512;
-       syscall(19, fd, 0, a, ptr+3, 0);
-       return(syscall(19, fd, 0, (int) (off%512), ptr, 0));
-}
diff --git a/usr/src/libc/v6/stat.c b/usr/src/libc/v6/stat.c
deleted file mode 100644 (file)
index 2cefcd4..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#include <sys/types.h>
-#include <sys/stat.h>
-
-struct ostat {
-       short os_dev;
-       short os_inum;
-       short os_flags;
-       char  os_nlinks;
-       char  os_uid;
-       char  os_gid;
-       char  os_size0;
-       short os_size1;
-       short os_addr[8];
-       long  os_actime;
-       long  os_modtime;
-} osbuf;
-
-stat(name, buf)
-char *name;
-struct stat *buf;
-{
-       if (syscall(18, 0, 0, name, &osbuf, 0) < 0)
-               return(-1);
-
-       stcopyit(buf);
-       return(0);
-}
-
-fstat(fd, buf)
-int fd;
-struct stat *buf;
-{
-       if (syscall(28, fd, 0, &osbuf, 0, 0) < 0)
-               return(-1);
-       stcopyit(buf);
-       return(0);
-}
-
-static
-stcopyit(buf)
-struct stat *buf;
-{
-       buf->st_dev = osbuf.os_dev;
-       buf->st_ino = osbuf.os_inum;
-       buf->st_mode = osbuf.os_flags;
-       buf->st_mode &= 067777;
-       if ((buf->st_mode&060000) == 0)
-               buf->st_mode |= 0100000;
-       buf->st_nlink = osbuf.os_nlinks;
-       buf->st_uid = osbuf.os_uid;
-       buf->st_gid = osbuf.os_gid;
-       buf->st_rdev = 0;
-       buf->st_size = ( (long) osbuf.os_size0 << 16) | osbuf.os_size1;
-       buf->st_atime = osbuf.os_actime;
-       buf->st_mtime = osbuf.os_modtime;
-       buf->st_ctime = buf->st_mtime;
-}
diff --git a/usr/src/libc/v6/syscall.s b/usr/src/libc/v6/syscall.s
deleted file mode 100644 (file)
index d5ed33b..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/ syscall
-
-.globl _syscall,csv,cret,cerror
-_syscall:
-       jsr     r5,csv
-       mov     r5,r2
-       add     $04,r2
-       mov     $9f,r3
-       mov     (r2)+,r0
-       bic     $!0377,r0
-       bis     $sys,r0
-       mov     r0,(r3)+
-       mov     (r2)+,r0
-       mov     (r2)+,r1
-       mov     (r2)+,(r3)+
-       mov     (r2)+,(r3)+
-       mov     (r2)+,(r3)+
-       mov     (r2)+,(r3)+
-       mov     (r2)+,(r3)+
-       sys     0; 9f
-       bec     1f
-       jmp     cerror
-1:
-       jmp     cret
-
-       .data
-9:     .=.+12.
diff --git a/usr/src/libc/v6/time.s b/usr/src/libc/v6/time.s
deleted file mode 100644 (file)
index 29bfbc4..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/ C library -- time
-
-/ tvec = time(tvec);
-/
-/ tvec[0], tvec[1] contain the time
-
-.globl _time
-.time = 13.
-
-
-_time:
-       mov     r5,-(sp)
-       mov     sp,r5
-       sys     .time
-       mov     r2,-(sp)
-       mov     4(r5),r2
-       beq     1f
-       mov     r0,(r2)+
-       mov     r1,(r2)+
-1:
-       mov     (sp)+,r2
-       mov     (sp)+,r5
-       rts     pc
diff --git a/usr/src/libdbm/Makefile b/usr/src/libdbm/Makefile
new file mode 100644 (file)
index 0000000..7b86ece
--- /dev/null
@@ -0,0 +1,13 @@
+CFLAGS=-O
+
+libdbm.a: dbm.o
+       mv dbm.o libdbm.a
+
+dbm.o : dbm.h
+
+install:
+       install -c libdbm.a $(DESTDIR)/usr/lib
+       install -c dbm.h $(DESTDIR)/usr/include
+
+clean:
+       rm libdbm.a
diff --git a/usr/src/libdbm/compall b/usr/src/libdbm/compall
deleted file mode 100755 (executable)
index 7abd2bc..0000000
+++ /dev/null
@@ -1 +0,0 @@
-cc -c -O dbm.c
index aaafcc4..b594193 100644 (file)
@@ -321,12 +321,18 @@ datum d1, d2;
        return(0);
 }
 
        return(0);
 }
 
-int    hitab[16] = 
-{      61, 57, 53, 49, 45, 41, 37, 33,
+int    hitab[16]
+/* ken's
+{
+       055,043,036,054,063,014,004,005,
+       010,064,077,000,035,027,025,071,
+};
+*/
+ = {   61, 57, 53, 49, 45, 41, 37, 33,
        29, 25, 21, 17, 13,  9,  5,  1,
 };
        29, 25, 21, 17, 13,  9,  5,  1,
 };
-long   hltab[64] = 
-{
+long   hltab[64]
+ = {
        06100151277L,06106161736L,06452611562L,05001724107L,
        02614772546L,04120731531L,04665262210L,07347467531L,
        06735253126L,06042345173L,03072226605L,01464164730L,
        06100151277L,06106161736L,06452611562L,05001724107L,
        02614772546L,04120731531L,04665262210L,07347467531L,
        06735253126L,06042345173L,03072226605L,01464164730L,
@@ -377,7 +383,7 @@ datum item;
                f = item.dptr[i];
                for(j=0; j<BYTESIZ; j+=4) {
                        hashi += hitab[f&017];
                f = item.dptr[i];
                for(j=0; j<BYTESIZ; j+=4) {
                        hashi += hitab[f&017];
-                       hashl += hltab[hashi&077];
+                       hashl += hltab[hashi&63];
                        f >>= 4;
                }
        }
                        f >>= 4;
                }
        }
index ea5d5a3..2fb0a6c 100644 (file)
@@ -1,5 +1,5 @@
 #define        PBLKSIZ 512
 #define        PBLKSIZ 512
-#define        DBLKSIZ 8192
+#define        DBLKSIZ 4096
 #define        BYTESIZ 8
 #define        NULL    ((char *) 0)
 
 #define        BYTESIZ 8
 #define        NULL    ((char *) 0)
 
diff --git a/usr/src/libdbm/mklib b/usr/src/libdbm/mklib
deleted file mode 100755 (executable)
index 8b34035..0000000
+++ /dev/null
@@ -1 +0,0 @@
-mv dbm.o libdbm.a
diff --git a/usr/src/libfpsim/compall b/usr/src/libfpsim/compall
deleted file mode 100755 (executable)
index 9f6a739..0000000
+++ /dev/null
@@ -1 +0,0 @@
-as -o fpsim.o fp?.s
diff --git a/usr/src/libfpsim/fp1.s b/usr/src/libfpsim/fp1.s
deleted file mode 100644 (file)
index c5aad8e..0000000
+++ /dev/null
@@ -1,437 +0,0 @@
-/ fp1 -- floating point simulator
-
-rti    = 2
-bpt    = 3
-
-m.ext = 200            / long mode bit
-m.lngi = 100           / long integer mode
-
-.globl fptrap
-.globl ac0, ac1, ac2, ac3
-
-fptrap:
-       dec     reenter
-       bge     1f
-       4               / reentered!
-1:
-       mov     (sp)+,spc
-       mov     (sp)+,sps
-       mov     r0,sr0
-       mov     $sr1,r0
-       mov     r1,(r0)+
-       mov     r2,(r0)+
-       mov     r3,(r0)+
-       mov     r4,(r0)+
-       mov     r5,(r0)+
-       mov     sp,(r0)+
-       mov     (r0),r5         / pc
-       mov     -(r5),r5        / trapped instruction
-
-again:
-       sub     $8,sp           / room for double push
-       clr     trapins
-       mov     r5,r4
-       bic     $7777,r4
-       cmp     r4,$170000
-       beq     1f
-       jmp     badins
-1:
-       bic     $100000,fpsr    / clear fp error
-       bic     $170000,r5
-       mov     r5,r4
-       bit     $7000,r4
-       bne     class3
-       bit     $700,r4
-       bne     class2
-       cmp     r4,$12
-       blos    1f
-       jmp     badins
-1:
-       asl     r4
-       jmp     *1f(r4)
-
-       .data
-1:
-       i.cfcc          / 170000
-       i.setf          / 170001
-       i.seti          / 170002
-       badins
-       badins
-       badins
-       badins
-       badins
-       badins
-       i.setd          / 170011
-       i.setl          / 170012
-       .text
-
-class2:
-       cmp     r5,$400
-       bge     1f
-       jsr     r1,fsrc; mod0rx; mod242
-       br      2f
-1:
-       jsr     r1,fsrc; mod0f; mod24f
-2:
-       mov     r3,r5
-       asl     r4
-       asl     r4
-       clrb    r4
-       swab    r4
-       asl     r4
-       jsr     pc,*1f(r4)
-       jmp     sret
-
-       .data
-1:
-       badins          / 1700xx
-       i.ldfps         / 1701xx
-       i.stfps         / 1702xx
-       badins          / 1703xx - stst
-       i.clrx          / 1704xx
-       i.tstx          / 1705xx
-       i.absx          / 1706xx
-       i.negx          / 1707xx
-       .text
-
-class3:
-       cmp     r5,$5000
-       blt     1f
-       mov     r5,r2
-       clrb    r2
-       cmp     r2,$6400
-       blt     2f
-       sub     $1400,r2
-2:
-       cmp     r2,$5000
-       bne     2f
-       jsr     r1,fsrc; mod0rx; mod242
-       br      3f
-2:
-       cmp     r2,$5400
-       bne     2f
-       jsr     r1,fsrc; mod0ra; mod24i
-       br      3f
-2:
-       jsr     r1,fsrc; mod0f; mod24d
-       br      3f
-1:
-       jsr     r1,fsrc; mod0f; mod24f
-3:
-       jsr     pc,freg
-       mov     r2,r5
-       clrb    r4
-       swab    r4
-       asl     r4
-       jsr     pc,*1f(r4)
-       br      sret
-
-       .data
-1:
-       badins          / 1700xx
-       badins          / 1704xx
-       i.mulx          / 1710xx
-       i.modx          / 1714xx
-       i.addx          / 1720xx
-       i.ldx           / 1724xx
-       i.subx          / 1730xx
-       i.cmpx          / 1734xx
-       i.stx           / 1740xx
-       i.divx          / 1744xx
-       i.stexp         / 1750xx
-       i.stcxj         / 1754xx
-       i.stcxy         / 1760xx
-       i.ldexp         / 1764xx
-       i.ldcjx         / 1770xx
-       i.ldcyx         / 1774xx
-       .text
-
-i.cfcc:
-       mov     fpsr,r0
-       bic     $!17,r0
-       mov     r0,sps
-       br      ret
-
-i.setf:
-       bic     $m.ext,fpsr
-       br      ret
-
-i.setd:
-       bis     $m.ext,fpsr
-       br      ret
-
-i.seti:
-       bic     $m.lngi,fpsr
-       br      ret
-
-i.setl:
-       bis     $m.lngi,fpsr
-       br      ret
-
-badins:
-       inc     trapins
-       br      ret1
-
-sret:
-       mov     $fpsr,r0
-       bic     $17,(r0)
-       tstb    1(r5)
-       bpl     1f
-       bis     $10,(r0)
-       br      ret
-1:
-       bne     ret
-       bis     $4,(r0)
-
-ret:
-       mov     ssp,sp
-       mov     *spc,r5
-       cmp     r5,$170000
-       blo     ret1
-       add     $2,spc
-       jbr     again                   / if another fp, save trap
-
-ret1:
-       mov     $sr1,r0
-       mov     (r0)+,r1
-       mov     (r0)+,r2
-       mov     (r0)+,r3
-       mov     (r0)+,r4
-       mov     (r0)+,r5
-       mov     (r0)+,sp
-       mov     sr0,r0
-       mov     sps,-(sp)
-       mov     spc,-(sp)
-       tst     trapins
-       bne     1f
-       inc     reenter
-       rti
-1:
-       bpt
-
-freg:
-       mov     r5,r2
-       bic     $!300,r2
-       asr     r2
-       asr     r2
-       asr     r2
-       add     $ac0,r2
-       rts     pc
-
-fsrc:
-       mov     r5,r3
-       bic     $!7,r3                  / register
-       asl     r3
-       add     $sr0,r3
-       mov     r5,r0
-       bic     $!70,r0                 / mode
-       asr     r0
-       asr     r0
-       jmp     *1f(r0)
-
-       .data
-1:
-       mod0
-       mod1
-       mod2
-       mod3
-       mod4
-       mod5
-       mod6
-       mod7
-       .text
-
-mod24f:
-       mov     $4,r0
-       bit     $m.ext,fpsr
-       beq     1f
-       add     $4,r0
-1:
-       rts     pc
-
-mod24d:
-       mov     $8,r0
-       bit     $m.ext,fpsr
-       beq     1f
-       sub     $4,r0
-1:
-       rts     pc
-
-mod242:
-       mov     $2,r0
-       rts     pc
-
-mod24i:
-       mov     $2,r0
-       bit     $m.lngi,fpsr
-       beq     1f
-       add     $2,r0
-1:
-       rts     pc
-
-mod0:
-       jmp     *(r1)+
-
-mod0f:
-       sub     $sr0,r3                 / get fp ac
-       cmp     r3,$6*2
-       bhis    badi1
-       asl     r3
-       asl     r3
-       add     $ac0,r3
-       tst     (r1)+
-       rts     r1
-
-mod0ra:
-       bit     $m.lngi,fpsr
-       bne     badi1
-
-mod0r:
-       cmp     r3,$ssp
-       bhis    badi1
-mod0rx:
-       tst     (r1)+
-       rts     r1
-
-mod1:
-       cmp     r3,$spc
-       beq     badi1
-       mov     (r3),r3
-       br      check
-
-mod2:
-       mov     (r3),-(sp)
-       jsr     pc,*2(r1)
-       cmp     r3,$spc
-       bne     1f
-       mov     $2,r0
-       mov     *(r3),pctmp
-       mov     $pctmp,(sp)
-1:
-       add     r0,(r3)
-       mov     (sp)+,r3
-       br      check
-
-mod3:
-       mov     *(r3),-(sp)
-       add     $2,(r3)
-       mov     (sp)+,r3
-       br      check
-
-mod4:
-       cmp     r3,$spc         / test pc
-       beq     badi1
-       jsr     pc,*2(r1)
-       sub     r0,(r3)
-       mov     (r3),r3
-       br      check
-
-mod5:
-       cmp     r3,$spc
-       beq     badi1
-       sub     $2,(r3)
-       mov     *(r3),r3
-       br      check
-
-mod6:
-       mov     *spc,-(sp)
-       add     $2,spc
-       add     (r3),(sp)
-       mov     (sp)+,r3
-       br      check
-
-mod7:
-       jsr     r1,mod6; ..; ..
-       mov     (r3),r3
-       br      check
-
-badi1:
-       jmp     badins
-
-check:
-       bit     $1,r3
-       bne     badi1
-       cmp     (r1)+,(r1)+
-       rts     r1
-
-setab:
-       mov     $asign,r0
-       jsr     pc,seta
-       mov     r3,r2
-       mov     $bsign,r0
-
-seta:
-       clr     (r0)
-       mov     (r2)+,r1
-       mov     r1,-(sp)
-       beq     1f
-       blt     2f
-       inc     (r0)+
-       br      3f
-2:
-       dec     (r0)+
-3:
-       bic     $!177,r1
-       bis     $200,r1
-       br      2f
-1:
-       clr     (r0)+
-2:
-       mov     r1,(r0)+
-       mov     (r2)+,(r0)+
-       bit     $m.ext,fpsr
-       beq     2f
-       mov     (r2)+,(r0)+
-       mov     (r2)+,(r0)+
-       br      3f
-2:
-       clr     (r0)+
-       clr     (r0)+
-3:
-       mov     (sp)+,r1
-       asl     r1
-       clrb    r1
-       swab    r1
-       sub     $200,r1
-       mov     r1,(r0)+        / exp
-       rts     pc
-
-norm:
-       mov     $areg,r0
-       mov     (r0)+,r1
-       mov     r1,-(sp)
-       mov     (r0)+,r2
-       bis     r2,(sp)
-       mov     (r0)+,r3
-       bis     r3,(sp)
-       mov     (r0)+,r4
-       bis     r4,(sp)+
-       bne     1f
-       clr     asign
-       rts     pc
-1:
-       bit     $!377,r1
-       beq     1f
-       clc
-       ror     r1
-       ror     r2
-       ror     r3
-       ror     r4
-       inc     (r0)
-       br      1b
-1:
-       bit     $200,r1
-       bne     1f
-       asl     r4
-       rol     r3
-       rol     r2
-       rol     r1
-       dec     (r0)
-       br      1b
-1:
-       mov     r4,-(r0)
-       mov     r3,-(r0)
-       mov     r2,-(r0)
-       mov     r1,-(r0)
-       rts     pc
-
diff --git a/usr/src/libfpsim/fp2.s b/usr/src/libfpsim/fp2.s
deleted file mode 100644 (file)
index 244082d..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/ fp2 -- floating point simulation
-
-i.ldx:
-       mov     (r3)+,(r2)+
-       mov     (r3)+,(r2)+
-       bit     $m.ext,fpsr
-       beq     1f
-       mov     (r3)+,(r2)+
-       mov     (r3)+,(r2)+
-       rts     pc
-1:
-       clr     (r2)+
-       clr     (r2)+
-       rts     pc
-
-i.stx:
-       mov     (r2)+,(r3)+
-       mov     (r2)+,(r3)+
-       bit     $m.ext,fpsr
-       beq     1f
-       mov     (r2)+,(r3)+
-       mov     (r2)+,(r3)+
-1:
-       jmp     ret                     / does not set cc's
-
-i.clrx:
-       clr     (r3)+
-       clr     (r3)+
-       bit     $m.ext,fpsr
-       beq     1f
-       clr     (r3)+
-       clr     (r3)+
-1:
-       rts     pc
-
-i.negx:
-       tst     (r3)
-       beq     1f
-       add     $100000,(r3)
-1:
-       rts     pc
-
-i.absx:
-       bic     $!77777,(r3)
-       rts     pc
-
-i.tstx:
-       rts     pc
-
-i.cmpx:
-       mov     $areg,r5
-       tst     (r2)
-       bge     1f
-       tst     (r3)
-       bge     1f
-       cmp     (r2),(r3)
-       bgt     4f
-       blt     3f
-1:
-       cmp     (r2)+,(r3)+
-       bgt     3f
-       blt     4f
-       cmp     (r2)+,(r3)+
-       bne     1f
-       bit     $m.ext,fpsr
-       beq     2f
-       cmp     (r2)+,(r3)+
-       bne     1f
-       cmp     (r2)+,(r3)+
-       beq     2f
-1:
-       bhi     3f
-4:
-       movb    $1,1(r5)
-       rts     pc
-3:
-       mov     $-1,(r5)
-       rts     pc
-2:
-       clr     (r5)
-       rts     pc
-
-i.ldcyx:
-       mov     (r3)+,(r2)+
-       mov     (r3)+,(r2)+
-       bit     $m.ext,fpsr
-       bne     1f
-       mov     (r3)+,(r2)+
-       mov     (r3)+,(r2)+
-       rts     pc
-1:
-       clr     (r2)+
-       clr     (r2)+
-       rts     pc
-
-i.stcxy:
-       mov     (r2)+,(r3)+
-       mov     (r2)+,(r3)+
-       bit     $m.ext,fpsr
-       bne     1f
-       clr     (r3)+
-       clr     (r3)+
-1:
-       rts     pc
-
-i.ldcjx:
-       mov     $asign,r0
-       mov     $1,(r0)+
-       mov     (r3)+,(r0)+
-       bit     $m.lngi,fpsr
-       beq     1f
-       mov     (r3)+,(r0)+
-       clr     (r0)+
-       clr     (r0)+
-       mov     $32.-8,(r0)+
-       jmp     saret
-1:
-       clr     (r0)+
-       clr     (r0)+
-       clr     (r0)+
-       mov     $16.-8,(r0)
-       jmp     saret
-
-i.stcxj:
-       mov     r3,r5
-       mov     $asign,r0
-       jsr     pc,seta
-       clr     r4
-       mov     $areg,r0
-       mov     (r0)+,r1
-       mov     (r0)+,r2
-       mov     (r0)+,r3
-       mov     aexp,r0
-1:
-       cmp     r0,$48.-8
-       bge     1f
-       clc
-       ror     r1
-       ror     r2
-       ror     r3
-       inc     r0
-       br      1b
-1:
-       bgt     7f
-       tst     r1
-       beq     1f
-7:
-       bis     $1,r4                   / C-bit
-1:
-       bit     $m.lngi,fpsr
-       beq     1f
-       tst     asign
-       bge     2f
-       neg     r3
-       adc     r2
-       bcs     2f
-       neg     r2
-       bis     $10,r4                  / N-bit
-2:
-       mov     r2,(r5)
-       mov     r3,2(r5)
-       bis     r2,r3
-       br      8f
-1:
-       tst     r2
-       beq     1f
-       bis     $1,r4                   / C-bit
-1:
-       tst     asign
-       bge     2f
-       neg     r3
-       bis     $10,r4                  / N-bit
-2:
-       mov     r3,(r5)
-8:
-       bne     1f
-       bis     $4,r4                   / Z-bit
-1:
-       bic     $17,sps
-       bic     $17,fpsr
-       bis     r4,sps
-       bis     r4,fpsr
-       jmp     ret
-
-xoflo:
-       bis     $1,fpsr                 / set fixed overflow (carry)
-       jmp     ret
-
-i.ldexp:
-       mov     $asign,r0
-       jsr     pc,seta
-       mov     (r3),aexp
-       jsr     pc,reta
-       jmp     sret
-
-i.stexp:
-       mov     $asign,r0
-       jsr     pc,seta
-       mov     aexp,(r3)
-       mov     r3,r5
-       bic     $17,sps
-       tst     (r3)
-       bmi     1f
-       bne     2f
-       bis     $4,sps                  / Z-bit
-       br      2f
-1:
-       bis     $10,sps                 / N-bit
-2:
-       jmp     sret
-
-i.ldfps:
-       mov     (r3),fpsr
-       jmp     ret
-
-i.stfps:
-       mov     fpsr,(r3)
-       jmp     ret
-
diff --git a/usr/src/libfpsim/fp3.s b/usr/src/libfpsim/fp3.s
deleted file mode 100644 (file)
index 66ffecf..0000000
+++ /dev/null
@@ -1,335 +0,0 @@
-/ fp3 -- floating simulation
-
-i.addx:
-       jsr     pc,setab
-       br      1f
-
-i.subx:
-       jsr     pc,setab
-       neg     bsign
-1:
-       tst     bsign
-       beq     reta
-       tst     asign
-       beq     retb
-       mov     areg+8,r1
-       sub     breg+8,r1
-       blt     1f
-       beq     2f
-       cmp     r1,$56.
-       bge     reta
-       mov     $breg,r0
-       br      4f
-1:
-       neg     r1
-       cmp     r1,$56.
-       bge     retb
-       mov     $areg,r0
-4:
-       mov     r1,-(sp)
-       mov     (r0)+,r1
-       mov     (r0)+,r2
-       mov     (r0)+,r3
-       mov     (r0)+,r4
-       add     (sp),(r0)
-1:
-       clc
-       ror     r1
-       ror     r2
-       ror     r3
-       ror     r4
-       dec     (sp)
-       bgt     1b
-       mov     r4,-(r0)
-       mov     r3,-(r0)
-       mov     r2,-(r0)
-       mov     r1,-(r0)
-       tst     (sp)+
-2:
-       mov     $areg+8,r1
-       mov     $breg+8,r2
-       mov     $4,r0
-       cmp     asign,bsign
-       bne     4f
-       clc
-1:
-       adc     -(r1)
-       bcs     3f
-       add     -(r2),(r1)
-2:
-       dec     r0
-       bne     1b
-       br      5f
-3:
-       add     -(r2),(r1)
-       sec
-       br      2b
-       br      5f
-4:
-       clc
-1:
-       sbc     -(r1)
-       bcs     3f
-       sub     -(r2),(r1)
-2:
-       dec     r0
-       bne     1b
-       br      5f
-3:
-       sub     -(r2),(r1)
-       sec
-       br      2b
-
-saret:
-       mov     $areg,r1
-5:
-       tst     (r1)
-       bge     3f
-       mov     $areg+8,r1
-       mov     $4,r0
-       clc
-1:
-       adc     -(r1)
-       bcs     2f
-       neg     (r1)
-2:
-       dec     r0
-       bne     1b
-       neg     -(r1)
-3:
-       jsr     pc,norm
-       br      reta
-
-retb:
-       mov     $bsign,r1
-       mov     $asign,r2
-       mov     $6,r0
-1:
-       mov     (r1)+,(r2)+
-       dec     r0
-       bne     1b
-
-reta:
-       mov     r5,r2
-       mov     $asign,r0
-       tst     (r0)
-       beq     unflo
-       mov     aexp,r1
-       cmp     r1,$177
-       bgt     ovflo
-       cmp     r1,$-177
-       blt     unflo
-       add     $200,r1
-       swab    r1
-       clc
-       ror     r1
-       tst     (r0)+
-       bge     1f
-       bis     $100000,r1
-1:
-       bic     $!177,(r0)
-       bis     (r0)+,r1
-       mov     r1,(r2)+
-       mov     (r0)+,(r2)+
-       bit     $m.ext,fpsr
-       beq     1f
-       mov     (r0)+,(r2)+
-       mov     (r0)+,(r2)+
-1:
-       rts     pc
-
-unflo:
-       clr     (r2)+
-       clr     (r2)+
-       bit     $m.ext,fpsr
-       beq     1f
-       clr     (r2)+
-       clr     (r2)+
-1:
-       rts     pc
-
-ovflo:
-       bis     $2,fpsr                 / set v-bit (overflow)
-       jmp     ret
-
-i.mulx:
-       jsr     pc,i.mul
-       br      saret
-
-i.modx:
-       jsr     pc,i.mul
-       jsr     pc,norm
-       mov     $asign,r0
-       mov     $bsign,r1
-       mov     $6,r2
-1:
-       mov     (r0)+,(r1)+
-       dec     r2
-       bne     1b
-       clr     r0              / count
-       mov     $200,r1         / bit
-       clr     r2              / reg offset
-1:
-       cmp     r0,aexp
-       bge     2f              / in fraction
-       bic     r1,areg(r2)
-       br      3f
-2:
-       bic     r1,breg(r2)
-3:
-       inc     r0
-       clc
-       ror     r1
-       bne     1b
-       mov     $100000,r1
-       add     $2,r2
-       cmp     r2,$8
-       blt     1b
-       jsr     pc,norm
-       jsr     pc,reta
-       cmp     r5,$ac1
-       beq     1f
-       cmp     r5,$ac3
-       beq     1f
-       bit     $200,breg
-       bne     2f
-       clr     bsign
-2:
-       add     $8,r5
-       jsr     pc,retb
-       sub     $8,r5
-1:
-       rts     pc
-
-i.divx:
-       jsr     pc,setab
-       tst     bsign
-       beq     ovflo
-       sub     bexp,aexp
-       jsr     pc,xorsign
-       mov     r5,-(sp)
-       mov     $areg,r0
-       mov     (r0),r1
-       clr     (r0)+
-       mov     (r0),r2
-       clr     (r0)+
-       mov     (r0),r3
-       clr     (r0)+
-       mov     (r0),r4
-       clr     (r0)+
-       mov     $areg,r5
-       mov     $400,-(sp)
-1:
-       mov     $breg,r0
-       cmp     (r0)+,r1
-       blt     2f
-       bgt     3f
-       cmp     (r0)+,r2
-       blo     2f
-       bhi     3f
-       cmp     (r0)+,r3
-       blo     2f
-       bhi     3f
-       cmp     (r0)+,r4
-       bhi     3f
-2:
-       mov     $breg,r0
-       sub     (r0)+,r1
-       clr     -(sp)
-       sub     (r0)+,r2
-       adc     (sp)
-       clr     -(sp)
-       sub     (r0)+,r3
-       adc     (sp)
-       sub     (r0)+,r4
-       sbc     r3
-       adc     (sp)
-       sub     (sp)+,r2
-       adc     (sp)
-       sub     (sp)+,r1
-       bis     (sp),(r5)
-3:
-       asl     r4
-       rol     r3
-       rol     r2
-       rol     r1
-       clc
-       ror     (sp)
-       bne     1b
-       mov     $100000,(sp)
-       add     $2,r5
-       cmp     r5,$areg+8
-       blo     1b
-       tst     (sp)+
-       mov     (sp)+,r5
-       jmp     saret
-
-
-i.mul:
-       jsr     pc,setab
-       add     bexp,aexp
-       dec     aexp
-       jsr     pc,xorsign
-       mov     r5,-(sp)
-       mov     $breg+4,r5
-       bit     $m.ext,fpsr
-       beq     1f
-       add     $4,r5
-1:
-       clr     r0
-       clr     r1
-       clr     r2
-       clr     r3
-       clr     r4
-1:
-       asl     r0
-       bne     2f
-       inc     r0
-       tst     -(r5)
-2:
-       cmp     r0,$400
-       bne     2f
-       cmp     r5,$breg
-       bhi     2f
-       mov     $areg,r0
-       mov     r1,(r0)+
-       mov     r2,(r0)+
-       mov     r3,(r0)+
-       mov     r4,(r0)+
-       mov     (sp)+,r5
-       rts     pc
-2:
-       clc
-       ror     r1
-       ror     r2
-       ror     r3
-       ror     r4
-       bit     r0,(r5)
-       beq     1b
-       mov     r0,-(sp)
-       mov     $areg,r0
-       add     (r0)+,r1
-       clr     -(sp)
-       add     (r0)+,r2
-       adc     (sp)
-       clr     -(sp)
-       add     (r0)+,r3
-       adc     (sp)
-       add     (r0)+,r4
-       adc     r3
-       adc     (sp)
-       add     (sp)+,r2
-       adc     (sp)
-       add     (sp)+,r1
-       mov     (sp)+,r0
-       br      1b
-
-xorsign:
-       cmp     asign,bsign
-       beq     1f
-       mov     $-1,asign
-       rts     pc
-1:
-       mov     $1,asign
-       rts     pc
-
diff --git a/usr/src/libfpsim/fpx.s b/usr/src/libfpsim/fpx.s
deleted file mode 100644 (file)
index eaa1de2..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/ fpx -- floating point simulation
-
-.data
-reenter: 1
-
-.bss
-asign: .=.+2
-areg:  .=.+8
-aexp:  .=.+2
-bsign: .=.+2
-breg:  .=.+8
-bexp:  .=.+2
-
-fpsr:  .=.+2
-trapins: .=.+2
-
-ac0:   .=.+8.
-ac1:   .=.+8.
-ac2:   .=.+8.
-ac3:   .=.+8.
-ac4:   .=.+8.
-ac5:   .=.+8.
-
-sr0:   .=.+2
-sr1:   .=.+2
-       .=.+2
-       .=.+2
-       .=.+2
-       .=.+2
-ssp:   .=.+2
-spc:   .=.+2
-sps:   .=.+2
-pctmp: .=.+8
-
diff --git a/usr/src/libfpsim/mklib b/usr/src/libfpsim/mklib
deleted file mode 100755 (executable)
index 73897f7..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ar rb fakfp.o /lib/libc.a fpsim.o
diff --git a/usr/src/libg/Makefile b/usr/src/libg/Makefile
new file mode 100644 (file)
index 0000000..4577a5f
--- /dev/null
@@ -0,0 +1,2 @@
+libg.a:        dbxxx.s
+       as dbxxx.s -o libg.a
diff --git a/usr/src/libg/dbxxx.s b/usr/src/libg/dbxxx.s
new file mode 100644 (file)
index 0000000..a2f6757
--- /dev/null
@@ -0,0 +1,12 @@
+       .data
+       .comm   __dbargs,512
+       .text
+       .align  1
+       .globl  __dbsubc
+__dbsubc:
+       callg   __dbargs+4,*__dbargs
+       .globl  __dbsubn
+__dbsubn:
+       halt
+
+       .data
diff --git a/usr/src/libln/Makefile b/usr/src/libln/Makefile
new file mode 100644 (file)
index 0000000..3a6cbfa
--- /dev/null
@@ -0,0 +1,16 @@
+CFLAGS = -O
+
+all: libln.a
+
+libln.a:
+       cc -c -O allprint.c main.c reject.c yyless.c
+       cc -c -O yywrap.c
+       rm -f libln.a
+       ar rvc libln.a allprint.o main.o reject.o yyless.o yywrap.o
+       rm allprint.o main.o reject.o yyless.o yywrap.o
+
+install: all
+       install libln.a $(DESTDIR)/usr/lib
+
+clean:
+       rm -f *.o libln.a
diff --git a/usr/src/libln/allprint.c b/usr/src/libln/allprint.c
new file mode 100644 (file)
index 0000000..238cade
--- /dev/null
@@ -0,0 +1,37 @@
+# include <stdio.h>
+allprint(c)
+  char c; {
+       extern FILE *yyout;
+       switch(c){
+               case '\n':
+                       fprintf(yyout,"\\n");
+                       break;
+               case '\t':
+                       fprintf(yyout,"\\t");
+                       break;
+               case '\b':
+                       fprintf(yyout,"\\b");
+                       break;
+               case ' ':
+                       fprintf(yyout,"\\\bb");
+                       break;
+               default:
+                       if(!printable(c))
+                               fprintf(yyout,"\\%-3o",c);
+                       else 
+                               putc(c,yyout);
+                       break;
+               }
+       return;
+       }
+sprint(s)
+  char *s; {
+       while(*s)
+               allprint(*s++);
+       return;
+       }
+printable(c)
+  int c;
+       {
+       return(040 < c && c < 0177);
+       }
diff --git a/usr/src/libln/main.c b/usr/src/libln/main.c
new file mode 100644 (file)
index 0000000..123b665
--- /dev/null
@@ -0,0 +1,5 @@
+# include "stdio.h"
+main(){
+yylex();
+exit(0);
+}
diff --git a/usr/src/libln/reject.c b/usr/src/libln/reject.c
new file mode 100644 (file)
index 0000000..7fa9282
--- /dev/null
@@ -0,0 +1,41 @@
+# include <stdio.h>
+extern struct {int *yyaa, *yybb; int *yystops;} *yylstate [], **yylsp, **yyolsp;
+yyreject ()
+{
+extern FILE *yyout, *yyin;
+extern int yyprevious , *yyfnd;
+extern char yyextra[];
+extern char yytext[];
+extern int yyleng;
+for( ; yylsp < yyolsp; yylsp++)
+       yytext[yyleng++] = yyinput();
+if (*yyfnd > 0)
+       return(yyracc(*yyfnd++));
+while (yylsp-- > yylstate)
+       {
+       yyunput(yytext[yyleng-1]);
+       yytext[--yyleng] = 0;
+       if (*yylsp != 0 && (yyfnd= (*yylsp)->yystops) && *yyfnd > 0)
+               return(yyracc(*yyfnd++));
+       }
+if (yytext[0] == 0)
+       return(0);
+yyoutput(yyprevious = yyinput());
+yyleng=0;
+return(-1);
+}
+yyracc(m)
+{
+yyolsp = yylsp;
+if (yyextra[m])
+       {
+       while (yyback((*yylsp)->yystops, -m) != 1 && yylsp>yylstate)
+               {
+               yylsp--;
+               yyunput(yytext[--yyleng]);
+               }
+       }
+yyprevious = yytext[yyleng-1];
+yytext[yyleng] = 0;
+return(m);
+}
diff --git a/usr/src/libln/yyless.c b/usr/src/libln/yyless.c
new file mode 100644 (file)
index 0000000..5914bd9
--- /dev/null
@@ -0,0 +1,18 @@
+yyless(x)
+{
+extern char yytext[];
+register char *lastch, *ptr;
+extern int yyleng;
+extern int yyprevious;
+lastch = yytext+yyleng;
+if (x>=0 && x <= yyleng)
+       ptr = x + yytext;
+else
+       ptr = x;
+while (lastch > ptr)
+       yyunput(*--lastch);
+*lastch = 0;
+if (ptr >yytext)
+       yyprevious = *--lastch;
+yyleng = ptr-yytext;
+}
diff --git a/usr/src/libln/yywrap.c b/usr/src/libln/yywrap.c
new file mode 100644 (file)
index 0000000..0866993
--- /dev/null
@@ -0,0 +1,4 @@
+yywrap()
+{
+       return(1);
+}
diff --git a/usr/src/libm/Makefile b/usr/src/libm/Makefile
new file mode 100644 (file)
index 0000000..aeb116a
--- /dev/null
@@ -0,0 +1,7 @@
+CFLAGS=-O
+FILES=asin.o atan.o exp.o erf.o floor.o hypot.o j0.o j1.o \
+      jn.o log.o pow.o sin.o sinh.o sqrt.o tan.o tanh.o
+
+libm.a : $(FILES)
+       ar rc libm.a asin.o atan.o hypot.o jn.o j0.o j1.o pow.o fabs.o \
+               log.o sin.o sqrt.o tan.o tanh.o sinh.o erf.o exp.o floor.o
index cacb6b4..b742e95 100644 (file)
@@ -39,7 +39,10 @@ asin(arg) double arg; {
 double
 acos(arg) double arg; {
 
 double
 acos(arg) double arg; {
 
-       if((arg > 1.) || (arg < -1.)){
+       if(arg < 0)
+               arg = -arg;
+
+       if(arg > 1.){
                errno = EDOM;
                return(0.);
        }
                errno = EDOM;
                return(0.);
        }
diff --git a/usr/src/libm/compall b/usr/src/libm/compall
deleted file mode 100755 (executable)
index e246e0a..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-cc -c -O asin.c
-cc -c -O atan.c
-cc -c -O exp.c
-cc -c -O fabs.c
-cc -c -O floor.c
-cc -c -O hypot.c
-cc -c -O j0.c
-cc -c -O j1.c
-cc -c -O jn.c
-cc -c -O log.c
-cc -c -O pow.c
-cc -c -O sin.c
-cc -c -O sinh.c
-cc -c -O sqrt.c
-cc -c -O tan.c
-cc -c -O tanh.c
diff --git a/usr/src/libm/erf.c b/usr/src/libm/erf.c
new file mode 100644 (file)
index 0000000..b724b90
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+       C program for floating point error function
+
+       erf(x) returns the error function of its argument
+       erfc(x) returns 1.0-erf(x)
+
+       erf(x) is defined by
+       ${2 over sqrt(pi)} int from 0 to x e sup {-t sup 2} dt$
+
+       the entry for erfc is provided because of the
+       extreme loss of relative accuracy if erf(x) is
+       called for large x and the result subtracted
+       from 1. (e.g. for x= 10, 12 places are lost).
+
+       There are no error returns.
+
+       Calls exp.
+
+       Coefficients for large x are #5667 from Hart & Cheney (18.72D).
+*/
+
+#define M 7
+#define N 9
+int errno;
+static double torp = 1.1283791670955125738961589031;
+static double p1[] = {
+       0.804373630960840172832162e5,
+       0.740407142710151470082064e4,
+       0.301782788536507577809226e4,
+       0.380140318123903008244444e2,
+       0.143383842191748205576712e2,
+       -.288805137207594084924010e0,
+       0.007547728033418631287834e0,
+};
+static double q1[]  = {
+       0.804373630960840172826266e5,
+       0.342165257924628539769006e5,
+       0.637960017324428279487120e4,
+       0.658070155459240506326937e3,
+       0.380190713951939403753468e2,
+       0.100000000000000000000000e1,
+       0.0,
+};
+static double p2[]  = {
+       0.18263348842295112592168999e4,
+       0.28980293292167655611275846e4,
+       0.2320439590251635247384768711e4,
+       0.1143262070703886173606073338e4,
+       0.3685196154710010637133875746e3,
+       0.7708161730368428609781633646e2,
+       0.9675807882987265400604202961e1,
+       0.5641877825507397413087057563e0,
+       0.0,
+};
+static double q2[]  = {
+       0.18263348842295112595576438e4,
+       0.495882756472114071495438422e4,
+       0.60895424232724435504633068e4,
+       0.4429612803883682726711528526e4,
+       0.2094384367789539593790281779e4,
+       0.6617361207107653469211984771e3,
+       0.1371255960500622202878443578e3,
+       0.1714980943627607849376131193e2,
+       1.0,
+};
+
+double
+erf(arg) double arg;{
+       double erfc();
+       int sign;
+       double argsq;
+       double d, n;
+       int i;
+
+       errno = 0;
+       sign = 1;
+       if(arg < 0.){
+               arg = -arg;
+               sign = -1;
+       }
+       if(arg < 0.5){
+               argsq = arg*arg;
+               for(n=0,d=0,i=M-1; i>=0; i--){
+                       n = n*argsq + p1[i];
+                       d = d*argsq + q1[i];
+               }
+               return(sign*torp*arg*n/d);
+       }
+       if(arg >= 10.)
+               return(sign*1.);
+       return(sign*(1. - erfc(arg)));
+}
+
+double
+erfc(arg) double arg;{
+       double erf();
+       double exp();
+       double n, d;
+       int i;
+
+       errno = 0;
+       if(arg < 0.)
+               return(2. - erfc(-arg));
+/*
+       if(arg < 0.5)
+               return(1. - erf(arg));
+*/
+       if(arg >= 10.)
+               return(0.);
+
+       for(n=0,d=0,i=N-1; i>=0; i--){
+               n = n*arg + p2[i];
+               d = d*arg + q2[i];
+       }
+       return(exp(-arg*arg)*n/d);
+}
diff --git a/usr/src/libm/mklib b/usr/src/libm/mklib
deleted file mode 100755 (executable)
index 470ab14..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-ar rc libm.a \
-asin.o \
-atan.o \
-hypot.o \
-jn.o \
-j0.o \
-j1.o \
-pow.o \
-fabs.o \
-log.o \
-sin.o \
-sqrt.o \
-tan.o \
-tanh.o \
-sinh.o \
-exp.o \
-floor.o
diff --git a/usr/src/libnm/Makefile b/usr/src/libnm/Makefile
new file mode 100644 (file)
index 0000000..60ee10a
--- /dev/null
@@ -0,0 +1,12 @@
+OBJS=acos.o asin.o atan.o cbrt.o exp.o log.o sin.o \
+      sinh.o sqrt.o tan.o tanh.o
+
+libnm.a : $(OBJS)
+       ar r libnm.a $(OBJS)
+
+.s.o :
+       as -o $@ $<
+
+.c.o :
+       cc -O -c $*.c
+
diff --git a/usr/src/libnm/acos.c b/usr/src/libnm/acos.c
new file mode 100644 (file)
index 0000000..45905c5
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+acos(arg) return the arccos,
+       respectively of their arguments.
+
+       Arctan is called after appropriate range reduction.
+*/
+
+#include       <errno.h>
+int errno;
+double atan();
+double sqrt();
+static double pio2     = 1.570796326794896619;
+
+double
+acos(arg) double arg; {
+
+       if(arg < 0)
+               arg = -arg;
+
+       if(arg > 1.){
+               errno = EDOM;
+               return(0.);
+       }
+
+       return(pio2 - asin(arg));
+}
diff --git a/usr/src/libnm/asin.s b/usr/src/libnm/asin.s
new file mode 100644 (file)
index 0000000..1c2e023
--- /dev/null
@@ -0,0 +1,42 @@
+#double asin(arg)
+#double arg; -1.0<=arg<=1.0 or an out of range error return
+#method: call atan() after range reduction
+# calls: satan (internal entry point of atan.s), _sqrt
+# J F Jarvis August 8, 1078
+.globl _asin
+.globl _errno
+.globl _sqrt
+.globl satan
+.set   EDOM,33
+.text
+.align 1
+_asin:
+       .word   0x0c0
+       movd    4(ap),r6
+       jgtr    a1
+       mnegd   r6,r6
+a1:    cmpd    r6,$0d1.0e+0
+       jleq    a2
+       movl    $EDOM,_errno
+       clrd    r0
+       ret
+#
+a2:    muld3   r6,r6,r0
+       subd3   r0,$0d1.0e+0,-(sp)
+       calls   $2,_sqrt
+       cmpd    r6,$0d0.6875
+       jleq    a3
+       divd2   r6,r0
+       jsb     satan
+       subd3   r0,pio2,r0
+       jbr     a4
+a3:    divd3   r0,r6,r0
+       jsb     satan
+a4:    tstd    4(ap)
+       jleq    a5
+       ret
+a5:    mnegd   r0,r0
+       ret
+.data
+.align 3
+pio2: .double 0d1.57079632679489661923e+0
diff --git a/usr/src/libnm/atan.s b/usr/src/libnm/atan.s
new file mode 100644 (file)
index 0000000..aaa00ae
--- /dev/null
@@ -0,0 +1,104 @@
+# double atan(arg1); -pi/2 < atan < pi/2
+#double atan2(arg1,arg2); -pi< atan2<pi
+#double arg1,arg2
+#method: range reduction to [sqrt(2)-1,sqrt(2)+1]
+# followed by Hart&Cheney ARCTN 5076 D=17.55
+# J. F. Jarvis August 8, 1978
+.globl _atan
+.globl _atan2
+.text
+.align 1
+_atan:
+       .word   0x03c0
+       movd    4(ap),r0
+       jgtr    a1
+       mnegd   r0,r0   # atan(arg1), arg1<0
+       bsbb    satan
+       mnegd   r0,r0
+       ret
+a1:    bsbb    satan   # atan(arg1), arg1>=0
+       ret
+#
+.align 1
+_atan2:
+       .word   0x03c0
+       movd    4(ap),r0        # atan(arg1/arg2)
+       movd    12(ap),r2
+       addd3   r0,r2,r4
+       cmpd    r0,r4
+       jneq    b1
+       tstd    r0
+       jgeq    b2
+       mnegd   pio2,r0
+       ret
+b2:    movd    pio2,r0
+       ret
+#
+b1:    tstd    r2
+       jgeq    b3
+       divd2   r2,r0
+       jleq    b4
+       bsbb    satan   # arg1<0, arg2<0
+       subd2   pi,r0
+       ret
+b4:    mnegd   r0,r0   # arg1>0, arg2<0
+       bsbb    satan
+       subd3   r0,pi,r0
+       ret
+#
+b3:    divd2   r2,r0
+       jleq    b5
+       bsbb    satan   # arg1>0, arg2>0
+       ret
+b5:    mnegd   r0,r0   # arg1<0, arg2>0
+       bsbb    satan
+       mnegd   r0,r0
+       ret
+#
+.globl satan
+satan: # range reduction on positive arg(r0)
+       cmpd    r0,sq2m1
+       jgeq    c1
+       bsbb    xatan
+       rsb
+c1:    cmpd    r0,sq2p1
+       jleq    c2
+       divd3   r0,$0d1.0e+0,r0
+       bsbb    xatan
+       subd3   r0,pio2,r0
+       rsb
+c2:    addd3   $0d1.0e+0,r0,r2
+       subd2   $0d1.0e+0,r0
+       divd2   r2,r0
+       bsbb    xatan
+       addd2   pio4,r0
+       rsb
+#
+xatan: # compute arctan(r0) for:sqrt(2)-1<r0<sqrt(2)+1
+# Hart&Cheney ARCTN 5076 is evaluated
+       movd    r0,r8
+       muld3   r0,r0,r6
+       polyd   r6,$4,pcoef
+       muld2   r0,r8
+       polyd   r6,$4,qcoef
+       divd3   r0,r8,r0
+       rsb
+.data
+.align 3
+pcoef:
+       .double 0d0.1589740288482307048e+0
+       .double 0d0.66605790170092626575e+1
+       .double 0d0.40969264832102256374e+2
+       .double 0d0.77477687719204208616e+2
+       .double 0d0.44541340059290680319e+2
+qcoef:
+       .double 0d1.0e+0
+       .double 0d0.15503977551421987525e+2
+       .double 0d0.62835930511032376833e+2
+       .double 0d0.92324801072300974840e+2
+       .double 0d0.44541340059290680444e+2
+pio4: .double  0d0.78539816339744830961e+0
+pio2: .double  0d1.57079632679489661923e+0
+sq2p1: .double 0d2.41421356237309504880e+0
+sq2m1: .double 0d0.41421356237309504880e+0
+pi: .double 0d3.14159265358979323846e+0
diff --git a/usr/src/libnm/cbrt.s b/usr/src/libnm/cbrt.s
new file mode 100644 (file)
index 0000000..007f133
--- /dev/null
@@ -0,0 +1,53 @@
+# double cbrt(arg)
+# double arg
+# no error exits
+#method: range reduction to [1/8,1], poly appox, newtons method
+# J F Jarvis, August 10,1978
+.globl _cbrt
+.text
+.align 1
+_cbrt:
+       .word   0x00c0
+       clrl    r3
+       movd    4(ap),r4
+       jgtr    range
+       jeql    retz
+       mnegd   r4,r4   # |arg| in r0,r1
+       movl    $0x100,r3       # sign bit of result
+range:
+       extzv   $7,$8,r4,r6
+       insv    $128,$7,$8,r4   # 0.5<= frac: r4,r5 <1.0
+       clrl    r7
+       ediv    $3,r6,r6,r7     # r6= expnt/3; r7= expnt%3
+       addb2   $86,r6
+       bisl2   r3,r6   # sign,exponent of result
+       polyf   r4,$3,pcoef     # initial estimate is Hart&Cheney CBRT 0642
+                                               # D=4.1
+       muld3   r0,r0,r2        # Newtons method, iteration 1, H&C 6.1.10
+       divd3   r2,r4,r2
+       subd3   r2,r0,r2
+       muld2   third,r2
+       subd2   r2,r0   # D=8.2
+       muld3   r0,r0,r2        # iteration 2
+       divd3   r2,r4,r2
+       subd3   r2,r0,r2
+       muld2   third,r2
+       subd2   r2,r0
+       muld2   hc[r7],r0       # set range
+       insv    r6,$7,$9,r0     # set sign,exponent
+       ret
+retz:
+       clrd    r0
+       ret
+.data
+.align 3
+third: .double 0d0.33333333333333333333e+0
+hc:
+       .double 0d1.25992104989487316476e+0
+       .double 0d1.58740105196819947475e+0
+       .double 0d1.0e+0
+pcoef:
+       .float 0f0.1467073818e+0
+       .float 0f-0.5173964673e+0
+       .float 0f0.9319858515e+0
+       .float 0f0.4387762363e+0
diff --git a/usr/src/libnm/exp.s b/usr/src/libnm/exp.s
new file mode 100644 (file)
index 0000000..069e2fc
--- /dev/null
@@ -0,0 +1,78 @@
+# double exp(arg)
+# double arg; 0<= arg< 88
+# double exp10(arg)
+# method: range reduction to [-0.5,0.5], Hart&Chenet EXPB 1067
+# J F Jarvis, August 5, 1978
+.set   ERANGE,34
+.globl _exp
+.globl _exp10
+.globl _errno
+.text
+.align 1
+_exp10:
+       .word   0x07c0
+       muld3   4(ap),loge10,r0
+       jbr     argtst
+.align 1
+_exp:
+       .word   0x07c0
+       movd    4(ap),r0
+argtst:
+       jnequ   smlarg
+       movd    $0d1.0e+0,r0
+       ret
+smlarg:
+       cmpd    r0,minarg
+       jgeq    lrgarg
+       mnegd   huge,r0
+       ret
+lrgarg:
+       cmpd    r0,maxarg
+       jleq    range
+       movl    $ERANGE,_errno
+       movd    $huge,r0
+       ret
+range:
+       emodd   log2e,log2ex,r0,r10,r6  # r10=int(arg), r6=frac(arg)
+       tstd    r0
+       jgtr    l1
+       addd2   $0d0.5e+0,r6
+       subw2   $1,r10
+       jbr     l2
+l1:    subd2   $0d0.5e+0,r6
+l2:                    # Hart&Cheney EXPB 1067
+       muld3   r6,r6,r8        # range [-.5,.5] D=18.1
+       polyd   r8,$2,pcoef
+       muld2   r0,r6
+       polyd   r8,$2,qcoef
+       subd3   r6,r0,r2
+       addd2   r6,r0
+       divd2   r2,r0
+       muld2   sqrt2,r0
+       extzv $7,$8,r0,r2
+       addl2   r2,r10
+       insv    r10,$7,$8,r0    # load correct exponent
+       ret
+.data
+.align 3
+pcoef:
+       .double 0d0.23093347753750233624e-1
+       .double 0d0.20202065651286927227886e+2
+       .double 0d0.15139067990543389159e+4
+qcoef:
+       .double 0d0.1e+1
+       .double 0d0.23318421142748162379e+3
+       .double 0d0.43682116627275584985e+4
+minarg:
+       .double 0d-88.028e+0
+maxarg:
+       .double 0d88.028e+0
+huge:  .double 0d1.7e+38
+loge10:
+       .double 0d2.30258509299404568401e+0
+sqrt2:
+       .double 0d1.41421356237309504880e+0
+log2e:
+       .double 0d1.44269504088896340735e+0
+log2ex:
+       .byte   0xbb
diff --git a/usr/src/libnm/log.s b/usr/src/libnm/log.s
new file mode 100644 (file)
index 0000000..d1a09ae
--- /dev/null
@@ -0,0 +1,66 @@
+# double log(arg) ; natural logarithm
+# double log10(arg); base 10 log
+# double arg
+# if(arg<=0){ errno=EDOM; return(-1.7e+38); }
+# nat. log computed from Hart&Cheney LOGE 2706 D=22.1
+# J F Jarvis August 3, 1978
+.set   EDOM,33
+.globl _log
+.globl _log10
+.globl _errno
+.text
+.align 1
+_log10:
+       .word   0x0
+       movd    4(ap),-(sp)
+       calls   $2,_log
+       muld2   log10e,r0
+       ret
+.align 1
+_log:
+       .word   0x07c0
+       movd    4(ap),r0
+       jgtr    range
+       movl    $EDOM,_errno
+       movd    $0d-1.7e+38,r0  # machine dept max neg
+       ret
+range:
+       extzv   $7,$8,r0,r10    # r10 = exp(arg)+128
+       insv    $128,$7,$8,r0   # r0,r1: 0.5<=frac(arg)<1.0
+       cmpd    r0,sqrt2d2
+       jgeq    comp
+       insv    $129,$7,$8,r0   # frac *= 2
+       decl    r10                             # exp -= 1
+comp:
+       subl2   $128,r10        # signed exp for scaled arg
+       subd3   $0d1.0e+0,r0,r6 # Hart&cheney LOGE 2706
+       addd2   $0d1.0e+0,r0
+       divd2   r0,r6   # r6,r7= (frac-1)/(frac+1)
+       muld3   r6,r6,r8
+       polyd   r8,$3,pcoef
+       muld2   r0,r6
+       polyd   r8,$4,qcoef
+       divd3   r0,r6,r0
+       cvtld   r10,r2
+       muld2   log2,r2 # r2,r3= loge(2**exp)
+       addd2   r2,r0
+       ret
+.data
+.align 3
+pcoef:
+       .double 0d-0.24550691103445385056e+2
+       .double 0d0.23616053565907671809e+3
+       .double 0d-0.54904361859132995001e+3
+       .double 0d0.35621151669903912407e+3
+qcoef:
+       .double 0d0.10e+1
+       .double 0d-0.35526251110400238735e+2
+       .double 0d0.19375591463035879517e+3
+       .double 0d-0.33389039541217149928e+3
+       .double 0d0.17810575834951956204e+3
+log10e:
+       .double 0d0.43429448190325182765e+0
+sqrt2d2:
+       .double 0d0.70710678118654752440e+0
+log2:
+       .double 0d0.69314718055994530941e+0
diff --git a/usr/src/libnm/sin.s b/usr/src/libnm/sin.s
new file mode 100644 (file)
index 0000000..fb23982
--- /dev/null
@@ -0,0 +1,55 @@
+# double float sin(),cos()
+#coefficients are from Hart & Cheney  SIN3370 (18.80D)
+.text
+.align 1
+.globl _sin
+.globl _cos
+_sin:
+       .word 0x03c0
+       clrl    r9      
+       movd    4(ap),r0
+       jgeq    range
+       movl    $2,r9
+       jbr     negarg
+
+.align 1
+_cos:
+       .word   0x0fc0
+       movl    $1,r9
+       movd    4(ap),r0
+       jgeq    range
+negarg:
+       mnegd   r0,r0
+
+range:
+       emodd   twoopi,twoopix,r0,r8,r6
+       addl2   r9,r8
+       bicb2   $~03,r8
+       caseb   r8,$0,$3
+bse:   .word   qda-bse,qdb-bse,qdc-bse,qdd-bse
+qdb:   subd3   r6,$0d1.0e+0,r6
+       jbr     qda
+qdc:   mnegd   r6,r6
+       jbr     qda
+qdd:   subd2   $0d1.0e+0,r6
+qda:
+       muld3   r6,r6,r8
+       polyd   r8,$4,pcoef
+       muld2   r0,r6
+       polyd   r8,$4,qcoef
+       divd3   r0,r6,r0
+       ret
+.data
+.align 3
+twoopi:.double 0d6.36619772367581340000e-01
+qcoef:.double  0d1.00000000000000000000e+00
+ .double       0d1.32653490878613630000e+02
+ .double       0d9.46309610153820810000e+03
+ .double       0d4.08179225234329970000e+05
+ .double       0d8.64455865292253430000e+06
+pcoef:.double  0d1.45968840666576870000e+02
+ .double       0d-1.38472724998245280000e+04
+ .double       0d4.40103053537526640000e+05
+ .double       0d-4.94290810090284410000e+06
+ .double       0d1.35788409787737560000e+07
+twoopix: .byte 0x29
diff --git a/usr/src/libnm/sinh.s b/usr/src/libnm/sinh.s
new file mode 100644 (file)
index 0000000..14c01f2
--- /dev/null
@@ -0,0 +1,47 @@
+# double _sinh(arg)
+# double _cosh(arg)
+# double arg
+# method: compute from exp except for sinh where -.5<arg<.5
+# then a polynimial approx. is uded
+# JF Jarvis, August 12,1978
+.globl _sinh
+.globl _cosh
+.globl _exp
+.text
+.align 1
+_sinh:
+       .word   0x0c0
+       movd    4(ap),r6
+       cmpd    r6,$0d0.5e+0
+       jgeq    expfrm
+       cmpd    r6,$0d-0.5e+0
+       jleq    expfrm
+       muld3   r6,r6,r0        # Hart&Cheney SINH 1985
+       polyd   r0,$5,pcoef
+       muld2   r6,r0
+       ret
+expfrm:
+       movd    r6,-(sp)        # sinh(x)=(exp(x)-exp(-x))/2
+       calls   $2,_exp
+       divd3   r0,$0d1.0e+0,r2
+       subd2   r2,r0
+       muld2   $0d0.5e+0,r0
+       ret
+.align 1
+_cosh:
+       .word   0x0
+       movd    4(ap),-(sp)
+       calls   $2,_exp
+       divd3   r0,$0d1.0e+0,r2
+       addd2   r2,r0
+       muld2   $0d0.5e+0,r0
+       ret
+.data
+.align 3
+pcoef:
+       .double 0d0.251726188251e-7
+       .double 0d0.275569807356154e-5
+       .double 0d0.1984127027907999e-3
+       .double 0d0.833333333307759961e-2
+       .double 0d0.16666666666667212324e+0
+       .double 0d0.99999999999999998116e+0
diff --git a/usr/src/libnm/sqrt.s b/usr/src/libnm/sqrt.s
new file mode 100644 (file)
index 0000000..22b9f3e
--- /dev/null
@@ -0,0 +1,46 @@
+# double sqrt(arg)
+# double arg
+# if(arg<0.0) { _errno=EDOM; return(0.0) }
+# J. F. Jarvis August 2, 1978
+.set   EDOM,98
+.text
+.align 1
+.globl _sqrt
+.globl _errno
+_sqrt:
+       .word   0x0c0
+       movd    4(ap),r4
+       jgtr    range
+       jeql    retz
+       movl    $EDOM,_errno
+retz:
+       clrd    r0
+       ret
+#
+range:
+       extzv   $7,$8,r4,r6     # r6 is exponent of arg
+       insv    $128,$7,$8,r4   # r2: 0.5<=fraction(arg)<1.0
+       incl    r6
+       clrl    r7
+       ediv    $2,r6,r6,r7     # r6=(exp+1)/2; r7=(exp+1)%2
+       addb2   $64,r6  # r6 is correct exponent for result
+       polyf   r4,$4,pcoef     # init estimate of sqrt(frac)
+                                               # Hart&Cheney SQRT 0132 D=5.1
+       divd3   r0,r4,r2        # Newtons method, 2 iterations
+       addd2   r2,r0
+       muld2   $0d0.5e+0,r0
+       divd3   r0,r4,r2        # Hart&Cheney 6.1.7
+       addd2   r2,r0   #d=21 at exit
+       muld2   hc[r7],r0       # *sqrt(2) requ for even org exp.
+       insv    r6,$7,$8,r0     # insert correct exp.
+       ret
+.data
+.align 3
+pcoef:
+       .float 0f-0.1214683825e+0
+       .float 0f0.5010420763e+0
+       .float 0f-0.9093210498e+0
+       .float 0f0.1300669049e+1
+       .float 0f0.2290699453e+0
+hc:            .double 0d0.35355339059327376220e+0     # sqrt(2)/4
+               .double 0d0.5e+0
diff --git a/usr/src/libnm/tan.s b/usr/src/libnm/tan.s
new file mode 100644 (file)
index 0000000..b50e844
--- /dev/null
@@ -0,0 +1,57 @@
+# double tan(arg)
+# double arg;
+#method: range reduction to [0,pi/4] followed by polynomial
+# approximation:  Hart&Cheney TAN 4285 D=19.74
+.globl _tan
+.text
+.align 1
+_tan:
+       .word   0x07c0
+       clrl    r10     # sign flag, !=0 negate result
+       movd    4(ap),r0
+       jgeq    c1
+       xorw2   $0x8000,r10
+       mnegd   r0,r0
+c1:
+       emodd   fopi,fopix,r0,r2,r6
+       bicl2   $~3,r2
+       caseb   r2,$0,$3
+a0:    .word   a1-a0,a2-a0,a3-a0,a4-a0
+a2:    subd3   r6,$0d1.0e+0,r6
+       jbr     b1
+a3: xorw2      $0x8000,r10
+b1:    bsbb    rtan
+       jneq    b2      # tests final result cmptd in rtan
+       movd    $0d1.7e+38,r0
+       jbr     b3
+b2:    divd3   r0,$0d1.0e+0,r0
+b3:    xorw2   r10,r0  # negate result if flag != 0 
+       ret
+a4:    subd3   r6,$0d1.0e+0,r6
+       xorw2   $0x8000,r10
+a1:    bsbb    rtan
+       xorw2   r10,r0
+       ret
+rtan:
+       muld3   r6,r6,r8
+       polyd   r8,$4,pcoef
+       muld2   r0,r6
+       polyd   r8,$3,qcoef
+       divd3   r0,r6,r0
+       rsb
+.data
+.align 3
+pcoef:
+       .double 0d0.33866386426771720960e-4
+       .double 0d0.34225543872410034353e-1
+       .double 0d-0.15506856534832663769e+2
+       .double 0d0.10559709017149531936e+4
+       .double 0d-0.13068202647548256682e+5
+qcoef:
+       .double 0d1.0e+0
+       .double 0d-0.15550331640317099669e+3
+       .double 0d0.47657513629164836989e+4
+       .double 0d-0.16638952389471190018e+5
+fopi:
+       .double 0d1.27323954473516268e+0
+fopix: .byte 0x29
diff --git a/usr/src/libnm/tanh.s b/usr/src/libnm/tanh.s
new file mode 100644 (file)
index 0000000..fb6af55
--- /dev/null
@@ -0,0 +1,48 @@
+# double tanh(arg)
+# double arg
+# method: tanh(arg)=sinh(arg)/cosh(arg); if |arg|<0.5 sinh(9 is computed from
+# a polynomial approx otherwise from exp().
+# Only 1 call to exp(9 is made.
+# J F Jarvis, August 17, 1978
+.globl _tanh
+.globl _exp
+.text
+.align 1
+_tanh:
+       .word   0x7c0
+       clrl    r10     # sign bit
+       movd    4(ap),r6
+       jgeq    t1
+       movw    $0x8000,r10
+       xorw2   r10,r6  # co|arg|
+t1:    cmpd    r6,$0d2.0e+1
+       jleq    t2
+       movd    $0d1.0e+0,r0
+       xorw2   r10,r0
+       ret
+t2:    movd    r6,-(sp)
+       calls   $2,_exp
+       movd    r0,r8
+       divd3   r8,$0d1.0e+0,-(sp)      # exp(-|arg|)
+       cmpd    r6,$0d0.5e+0
+       jgeq    t3
+       muld3   r6,r6,r0        # |arg|<0.5, sinh() from poly approx
+       polyd   r0,$5,pcoef
+       muld2   r6,r0
+       muld2   $0d2.0e+0,r0    
+       jbr     t4
+t3:    subd3   (sp),r8,r0
+t4:                            # r0,1 = 2*sinh(|arg|)
+       addd3   (sp),r8,r2      # r2,3 = cosh(|arg|);
+       divd2   r2,r0   # r0,1 = tanh(|arg|)
+       xorw2   r10,r0  # r0,1 = tanh(arg)
+       ret
+.data
+.align 3
+pcoef:
+       .double 0d0.251726188251e-7
+       .double 0d0.275569807356154e-5
+       .double 0d0.1984127027907999e-3
+       .double 0d0.833333333307759961e-2
+       .double 0d0.16666666666667212324e+0
+       .double 0d0.99999999999999998116e+0
diff --git a/usr/src/libplot/Makefile b/usr/src/libplot/Makefile
new file mode 100644 (file)
index 0000000..50ed1e6
--- /dev/null
@@ -0,0 +1,47 @@
+all: plot.a t4014.a t300.a t300s.a t450.a
+
+plot.a:        plot.c.a
+       mkdir xplot
+       cd xplot;ar x ../plot.c.a
+       cd xplot;cc -c -O *.c
+       cd xplot;ar rc plot.a *.o
+       mv xplot/plot.a .
+       rm -r xplot
+t4014.a:       t4014.c.a
+       mkdir xplot
+       cd xplot;ar x ../t4014.c.a
+       cd xplot;cc -c -O *.c
+       cd xplot;ar rc t4014.a *.o
+       mv xplot/t4014.a .
+       rm -r xplot
+t300.a:        t300.c.a
+       mkdir xplot
+       cd xplot;ar x ../t300.c.a
+       cd xplot;cc -c -O *.c
+       cd xplot;ar rc t300.a *.o
+       mv xplot/t300.a .
+       rm -r xplot
+t300s.a:       t300s.c.a
+       mkdir xplot
+       cd xplot;ar x ../t300s.c.a
+       cd xplot;cc -c -O *.c
+       cd xplot;ar rc t300s.a *.o
+       mv xplot/t300s.a .
+       rm -r xplot
+t450.a:        t450.c.a
+       mkdir xplot
+       cd xplot;ar x ../t450.c.a
+       cd xplot;cc -c -O *.c
+       cd xplot;ar rc t450.a *.o
+       mv xplot/t450.a .
+       rm -r xplot
+
+install: all
+       install plot.a $(DESTDIR)/usr/lib/libplot.a
+       install t4014.a $(DESTDIR)/usr/lib/lib4014.a
+       install t300.a $(DESTDIR)/usr/lib/lib300.a
+       install t300s.a $(DESTDIR)/usr/lib/lib300s.a
+       install t450.a $(DESTDIR)/usr/lib/lib450.a
+
+clean:
+       rm -f plot.a t4014.a t300.a t300s.a t450.a
diff --git a/usr/src/libplot/con.h b/usr/src/libplot/con.h
deleted file mode 100644 (file)
index c9500f2..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-/* gsi plotting output routines */
-# define DOWN 012
-# define UP 013
-# define LEFT 010
-# define RIGHT 040
-# define BEL 007
-# define ESC 033
-# define ACK 006
-#define PLOTIN 063
-#define PLOTOUT 064
-# define CR 015
-# define FF 014
-# define VERTRESP 48
-# define HORZRESP 60.
-# define VERTRES 8.
-# define HORZRES 6.
-/* down is line feed, up is reverse line feed,
-   left is backspace, right is space.  48 points per inch
-   vertically, 60 horizontally */
-
-extern int xnow, ynow;
-extern int ITTY[3], PTTY[3], OUTF;
-extern float HEIGHT, WIDTH, OFFSET;
-extern int xscale, xoffset, yscale;
-extern float botx, boty, obotx, oboty, scalex,scaley;
-
diff --git a/usr/src/libplot/makefile b/usr/src/libplot/makefile
deleted file mode 100644 (file)
index 096c13b..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-all:   libplot.a libt4014.a libt300.a libt300s.a libt450.a
-
-cp:    all
-       cp lib*.a /lib
-libplot.a:     plot.c.a
-       ar x plot.c.a
-       cc -c -O *.c
-       ar rc libplot.a *.o
-       rm *.c *.o
-libt4014.a:    t4014.c.a
-       ar x t4014.c.a
-       cc -c -O *.c
-       ar rc libt4014.a *.o
-       rm *.c *.o
-libt300.a:     t300.c.a
-       ar x t300.c.a
-       cc -c -O *.c
-       ar rc libt300.a *.o
-       rm *.c *.o
-libt300s.a:    t300s.c.a
-       ar x t300s.c.a
-       cc -c -O *.c
-       ar rc libt300s.a *.o
-       rm *.c *.o
-libt450.a:     t450.c.a
-       ar x t450.c.a
-       cc -c -O *.c
-       ar rc libt450.a *.o
-       rm *.c *.o
diff --git a/usr/src/mdec/mboot.s b/usr/src/mdec/mboot.s
new file mode 100644 (file)
index 0000000..3298307
--- /dev/null
@@ -0,0 +1,264 @@
+#
+# Tape boot program to load and transfer
+#   to a program on a 9-tr mag tape in 
+#    UNIX 'tp' format on the VAX machine.
+#  This program is the boot block on the mag tape.
+#
+#  Entry is made to the desired file via 'calls $0,entrypt'
+#    so return can be 'ret'.
+#
+       .set    core,50  #  assume 50 K words avail.
+       .set    BOOBLK,1 #  no. tape blocks for boot
+       .set    RELOC,0x50000
+       .set    HDRSIZ,040  #  size of file header for VAX
+       .set    MAGIC,0410  #  file type id in header
+       .set    ENTSIZ,64  #  size of 1 TP dir entry, bytes
+       .set    PTHSIZ,32  #  size of TP path name, bytes
+       .set    BLKSIZ,512  #  tape block size, bytes
+       .set    NUMDIR,24  #  no. of dir blocks on tape
+       .set    ENTBLK,8  #  no. of dir entries per tape block
+       .set    NL,012  #  new-line char
+       .set    CR,015  # carriage-return char
+       .set    MAXC,65535  #  max. count for 'movc' op
+       .set    TSIZ,4          # text size
+       .set    DSIZ,8          # data size
+       .set    BSIZ,12         # bss size
+       .set    TENT,024  #  task header entry loc
+#
+       .set    RXCS,32
+       .set    RXDB,33
+       .set    TXCS,34
+       .set    TXDB,35
+       .set    RXCS_DONE,0x80
+       .set    TXCS_RDY,0x80
+       .set    TXCS_pr,7  #  bit position of TXCS ready bit
+       .set    RXCS_pd,7  #  bit position of RXCS done bit
+#
+       .set    FILSIZ,38  #  dir offset for file size
+       .set    BNUM,44  #  dir offset for start block no.
+#
+#  MBA registers
+       .set    MBA1,0x20012000  #  MBA 1 device reg's
+       .set    M_cfg,0  # MBA config reg
+       .set    M_cr,4  #  MBA control reg
+       .set    M_stat,8  #  MBA status reg
+       .set    M_var,12  #  MBA virt addr reg
+       .set    M_bc,16  #  MBA byte count reg
+       .set    M_map,0x800  #  start of MBA map reg's
+       .set    MBAinit,1  #  MBA init bit in MBA control reg
+#
+#  TM02  registers
+       .set    TM02,MBA1+0x400   #  start of TM02 reg's
+       .set    TM_cs1,0  #  TM02 control 1 reg
+       .set    TM_ds,4  #  status reg
+       .set    TM_er,8  #  error reg
+       .set    TM_as,16  #  attention summary
+       .set    TM_fc,20  #  frame count
+       .set    TM_tc,36  #  TM02 tape control
+#  Function codes for TM02 control reg 1
+       .set    GO,1  #  GO bit
+       .set    RWND,6  # rewind, on-line
+       .set    DCLR,010  #  drive clear
+       .set    SFWD,030  #  space forward
+       .set    SREV,032  # space reverse
+       .set    WRIF,060  # write forward
+       .set    REDF,070  #  read forward
+#  misc bits
+       .set    ERR,040000  #  composite error bit in status reg
+       .set    TCHAR,011700  #  drive 0, odd parity, PDP11,
+#                              800 BPI NRZ, abort on error - for
+#                              tape control reg
+       .set    DRDY,0200  #  TM02/drive ready in status reg
+       .set    TM_pd,7  #  bit position of TM DRDY bit
+       .set    TM_pe,14  #  bit position of TM ERROR bit
+#
+       .set    tapa,-4         # desired tape addr
+       .set    mtapa,-8        # current tape addr
+       .set    name,-8-PTHSIZ  # operator-typed file name
+#
+       .set    rMBA,r10
+       .set    rTM,r11
+#  system initialization
+init:
+       movl    $RELOC,fp       # core loc to which to move this program
+       addl3   $name,fp,sp     # set stack pointer, leaving room for locals
+       clrl    r0
+       cmpl    (r0),$MAGIC
+       bneq    rel
+       movl    $HDRSIZ,r0      #  skip header
+rel :
+       movc3   $end,(r0),(fp)  #  move boot up to relocated position
+       jmp     start+RELOC  #  jump to relocated code
+#
+start :
+       movab   *$MBA1,%rMBA
+       movl    $MBAinit,M_cr(%rMBA)  #  MBA initialize
+       movab   *$TM02,%rTM
+       movl    $TCHAR,TM_tc(%rTM)  #  drive no., etc.
+       movl    $DCLR+GO,TM_cs1(%rTM)  #  drive clear
+       bsbw    rew     # rewind input tape
+       movab   name(fp),r4  #  start of filename storage
+       movzbl  $'=,r0  #  prompt character
+       bsbw    putc    # output char to main console
+#
+gfil :
+       movl    r4,r1   # loc at which to store user-specified file name
+nxtc :
+       bsbw    getc    # get input char's in file name
+       cmpb    r0,$NL  #  terminator ?
+       beql    nullc
+       cmpb    r0,$'@  # r0 = return character
+       beql    gfil
+       movb    r0,(r1)+
+       cmpb    r0,$'#
+       bneq    nxtc
+       tstw    -(r1)   # subl2 $2,r1
+       cmpl    r1,r4
+       blss    gfil
+       brb     nxtc
+nullc:
+       subl3   r4,r1,r9        # size of path name
+       beql    start           # dumb operator
+#
+#  user-specified TP filename has been stored at name(fp)
+#
+#  read in entire tp directory contents into low core
+#  'cmpc[35]' instruction uses reg's 0-3
+#
+dirred :
+       movl    $BOOBLK,tapa(fp)        # desired tape block no.
+       movl    $(NUMDIR*BLKSIZ),r6     # no. bytes in total dir
+       bsbw    taper   # read no. bytes indicated
+#
+#  search entire directory for user-specified file name
+       clrl    r5      # dir buff loc = 0
+nxtdir :
+       cmpc3   r9,(r5),(r4)  #  see if dir entry matches filename
+       beql    fndfil  # found match
+       acbl    $NUMDIR*BLKSIZ-1,$ENTSIZ,r5,nxtdir  #  see if done with tp dir
+#
+       brb             start   # entry not in directory - start all over
+#
+#  found desired tp dir entry
+fndfil :
+       movzwl  BNUM(r5),tapa(fp)       #  start block no., 2 bytes
+       movzwl  FILSIZ(r5),r6  #  low 2 bytes file size
+       insv    FILSIZ-1(r5),$16,$8,r6  #  file size, high byte
+       cmpl    r6,$RELOC-512  #  check if file fits below stack
+       blss    filok  #  file o.k.
+       brw             start  #  file too large
+#
+#  time to read in desired file from tape
+filok :
+       movl    r6,r7  #  save r6
+       bsbb    taper
+       bsbw    rew
+#
+#  if load module header exists, move down rest of load
+#    module to 0
+       clrl    r5  #  entry loc 
+       cmpl    (r5),$MAGIC             # unix a.out?
+       bneq    clrcor
+#  move start of exec image down to 0
+       clrl    r0
+       movq    TSIZ(r0),r1  #  text size and data size
+       movq    BSIZ(r0),r3  #  bss size, symbol table size
+       movl    TENT(r0),r5  #  entry loc
+       movl    r7,r6  # restore file size
+movtxt:
+       movb    HDRSIZ(r0),(r0)+
+       sobgtr  r6,movtxt
+#  move data up to page boundary
+       extzv   $0,$9,r1,r0             # byte-in-page of last text byte
+       beql    clrcor
+       subl3   r0,$512,r0              # room needed
+       addl2   r2,r1                   # current end+1 of data
+       addl2   r1,r0                   # new end+1 of data
+       movl    r0,r7                   # start here on bssz clearing
+movdat:
+       movb    -(r1),-(r0)
+       sobgtr  r2,movdat
+#
+#  clear core up to stack
+clrcor :
+       subl3   r7,$RELOC-4,r0  #  no. bytes to clear
+clrit :
+       clrb    (r7)+
+       sobgtr  r0,clrit
+#
+#  time to jump to start of file & execute
+       calls   $0,(r5)
+       brw     start   # returned from execution - start all over
+#
+#
+#  taper: movcTAPE (r6),tapa(fp),0
+#
+rew2 :
+       bsbb    rew             # beginning of tape
+taper0:
+       bsbb    rrec    # advance 1 block; (we never want block 0)
+taper :
+       clrl    r0  #  SBI page no.
+       cmpl    mtapa(fp),tapa(fp)      # current position .vs. desired
+       bgtr    rew2
+       blss    taper0
+rloop :
+       bsbb    rrec
+       acbl    $1,$-BLKSIZ,r6,rloop
+       rsb
+#
+#  subr to read 1 block from mag tape into page (r0)
+#
+rrec :
+       movl    TM_ds(%rTM),r2
+       bbc     $TM_pd,r2,rrec  #  TM02 & drive ready ?
+       movl    $-BLKSIZ,M_bc(%rMBA)  #  byte count
+       bisl3   $0x80000000,r0,M_map(%rMBA)  #  MBA map entry = valid bit + phys page no.
+       clrl    M_var(%rMBA)  #  MBA virt addr reg = map reg no. + byte offset
+       movl    $REDF+GO,TM_cs1(%rTM)  #  read forward
+tmrdy :
+       movl    TM_ds(%rTM),r2
+       bbc     $TM_pd,r2,tmrdy  #  TM02 & device ready ?
+       movl    TM_er(%rTM),r2
+       bbc     $TM_pe,r2,donred  #  any read errors ?
+       clrl    TM_ds(%rTM)  # clear status - try to recover
+       mnegl   $1,TM_fc(%rTM)  # frame count for backspace
+       movl    $SREV+GO,TM_cs1(%rTM)  #  space reverse
+       brb     rrec
+donred :
+       incl    r0  #  next SBI page no.
+       incl    mtapa(fp)       # mag tape block position
+       rsb
+#
+#  subr to rewind mag tape
+#
+rew :
+       movl    $RWND+GO,TM_cs1(%rTM)  # rewind
+       clrl    mtapa(fp)  #  current position
+       rsb
+#
+#  subroutines to do char i-o with main tty console
+#
+getc :
+       mfpr    $RXCS,r0
+       bbc     $RXCS_pd,r0,getc  #  receiver ready ?
+       mfpr    $RXDB,r0
+       cmpb    r0,$CR
+       bneq    putc
+       movb    $NL,r0
+#
+putc:
+       mfpr    $TXCS,r2
+       bbc     $TXCS_pr,r2,putc  #  transmitter ready ?
+       cmpb    r0,$NL
+       bneq    wbyt
+       movb    $CR,r0
+       bsbb    putc
+       clrb    r0
+       bsbb    putc
+       movb    $NL,r0
+wbyt :
+       extzv   $0,$7,r0,r0
+       mtpr    r0,$TXDB
+       rsb
+end :
diff --git a/usr/src/mdec/uboot.s b/usr/src/mdec/uboot.s
new file mode 100644 (file)
index 0000000..f3c9b95
--- /dev/null
@@ -0,0 +1,226 @@
+#
+# RP06/RM03 disk boot program to load "/fboot" from
+#    a UNIX filesystem (starting at block 1 on pack on
+#    drive 0) into low core and to execute that file.
+#  This program can only read regular small version 7 files
+#    from the root of a UNIX filesystem.
+#
+#
+       .set    BLKSIZ,512  #  disc block size
+       .set    RELOC,0x50000
+       .set    HDRSIZ,040  #  size of file header for VAX
+       .set    MAGIC,0410  #  file type id in header
+       .set    INOSIZ,64  #  no. bytes/inode entry
+       .set    INOBLK,BLKSIZ/INOSIZ  # no. inodes/disc block
+       .set    INOMSK,0xfffffff8  #  changes with inode size
+       .set    NAMSIZ,14  #  no. bytes in name field of dir entry
+       .set    ENTADR,024  #  offset to entry addr in task header
+       .set    DIRSIZ,16  #  size of directory entry, bytes
+       .set    ROOTINO,2  #  root dir inode no.
+       .set    NBOO,1
+       .set    NSUP,1
+       .set    NL,012  #  new-line char
+       .set    CR,015  # carriage-return char
+       .set    SLASH,057  #  '/'
+       .set    NMASK,0177
+       .set    NNMASK,037777777600  #  ~NMASK
+#  MBA registers
+       .set    MBA0,0x20010000  #  MBA 0 device reg's
+       .set    M_cr,MBA0+4  #  MBA control reg
+       .set    M_var,MBA0+12  #  MBA virt addr reg
+       .set    M_bc,MBA0+16  #  MBA byte count reg
+       .set    M_map,MBA0+0x800  #  start of MBA map reg's
+       .set    MBAinit,1  #  MBA init bit in MBA control reg
+#
+#  RM03
+       .set    RM3SEC,32
+       .set    RM3TRK,5
+#
+       .set    RP6typ,022
+       .set    RM3typ,024
+#
+#  RP06  registers
+       .set    RP6TRK,19  #  no. tracks/cylinder
+       .set    RP6SEC,22  #  no. sectors/track
+       .set    RP,MBA0+0x400   #  start of RP06 drive 0  reg's
+       .set    RP_cr,RP+0  # RP06 control reg, drive 0
+       .set    RP_sr,RP+4  #  status reg
+       .set    RP_stk,RP+0x14  #  desired track/sector reg
+       .set    RP_dt,RP+0x18  #  drive type reg
+       .set    RP_off,RP+0x24  #  RP offset reg
+       .set    RP_cyl,RP+0x28  #  desired cyl reg
+#  RP06 function codes, status bits 
+       .set    RP_GO,1  #  GO bit
+       .set    RP_RED,070  # read data
+       .set    RP_DC,010  #  drive clear function code
+       .set    RP_RIP,020  #  Read-In Preset function code
+       .set    RP_FMT,0x1000  #  format bit for offset reg
+       .set    RP_MOL,0x1000  #  medium online in status reg
+       .set    RP_DRY,0200  #  drive ready, staus reg
+       .set    RP_ERR,040000  #  composite error, staus reg
+       .set    RP_pDRY,7  #  bit position of RP_DRY
+       .set    RP_pERR,14  #  bit position of RP_ERR
+#
+#
+init :
+#  system initialization - executed once per boot load
+       halt  #  entry mask required by DEC monitor software
+       halt
+       movl    $MBAinit,*$M_cr  #  MBA initialize
+       movl    $RP_RIP+RP_GO,*$RP_cr  # read-in preset
+       movl    $RP_FMT,*$RP_off  #  format bit in RP offset reg
+#
+       movl    *$RP_dt,r0
+       cmpb    $RP6typ,r0
+       bneq    rm3
+       movl    $RP6SEC,*$rpsec
+       movl    $RP6TRK,*$rptrk
+       brb     domul
+rm3:
+       movl    $RM3SEC,*$rpsec
+       movl    $RM3TRK,*$rptrk
+domul:
+       mull3   *$rpsec,*$rptrk,*$rpst
+#  move boot image up to higher core
+start :
+       movl    $RELOC,sp
+#  'uboot' must have no header
+       movc3   $end,*$0,(sp)  #  move boot to relocated position
+#
+#  jump to re-located code at 'start2' - done once per boot load
+       jmp     *$RELOC+start2
+#
+#  execution starts here only after boot has been re-located
+start2 :
+#
+#  search inodes for pathname specified in 'names'
+#
+#  Must preserve r6  &  r7
+#  'cmpc[35]' instruction uses reg's 0 - 3
+#  'movc[35]' instruction uses reg's 0-5
+       movl    $names+RELOC,r6  #  start of input filename
+       movzbl  $ROOTINO,r0  #  start at root inode for search
+nxti :
+       clrw    *$bno  #  'bno' is index into 'iaddr[]' in inode entry
+       bsbw    iget  #  get inode into core
+       tstb    (r6)  #  r6 -> empty pathname component if end of pathname
+       beql    getfil
+get1b :
+       bsbw    rmblk  #  read in 1 of blocks in 'addr[]' in inode entry
+       beql start2  # file not found if zero cc set
+#
+       movl    $buf,r7  #  buffer holds directory block
+nxtent :
+       tstw    (r7)  #  null dir entry (inode # field = 0)
+       beql    dirchk
+       cmpc3   $NAMSIZ,(r6),2(r7)  #  compare 'names' against
+#                      dir entry - both null-filled
+       bneq    dirchk  #  branch if dir entry is not the one
+#  found component in a dir entry
+       movzwl  (r7),r0  #  2-byte inode no. from 1st 2 bytes of dir entry
+       addl2   $NAMSIZ,r6  #  point to next pathname component in 'names[]'
+       brb     nxti  #  now go get inode whose no. is in r0
+#
+dirchk :               #  no pathname match
+       acbl    $buf+BLKSIZ-1,$DIRSIZ,r7,nxtent  #  loop if
+#                      more dir entries in this buffer
+       brb     get1b  #  get another dir block into buffer
+#
+#  here if inode for desired file has been read in
+getfil :
+       clrl    bufptr  #  new buffer ptr is low core
+getlop :
+       bsbb    rmblk  #  get a block in the file
+       beql clear  #  branch if no more file blocks to read
+#  skip above branch if more file blocks to read in
+       addl2   $BLKSIZ,bufptr  #  next page in low core
+       brb     getlop  #  go get next block of input file
+#
+#  clear core
+#
+clear :
+       movl    *$size,r3
+clrcor :
+       clrq    (r3)
+       acbl    $RELOC,$8,r3,clrcor
+#
+#  go execute file
+#
+       calls   $0,*$0
+       brw     start2
+#
+#
+#  subroutine to get the inode whose no. is in r0
+#
+iget :
+       addl3   $(INOBLK*(NBOO+NSUP))-1,r0,r8  #  have to add in 2 blocks (boot and super)
+#                      worth of dummy inodes to calculate proper inode block
+       divl3   $INOBLK,r8,r4  #  calculate inode block , put in r4
+       bsbw    rblk  #  read in block containing desired inode
+       bicl2   $INOMSK,r8
+       mull2   $INOSIZ,r8  #  x inode size = offset in block
+       addl2   $buf,r8  #  buffer loc of inode entry
+#  move inode entry to separate buffer
+       movc3   $time-inode,(r8),*$inode
+       rsb
+#
+#  subr to read in 1 of blocks (bno) in 'addr[]'
+#
+rmblk :
+       movzwl  *$bno,r0
+       addw2   $3,*$bno  #  index into 'addr[]' array in inode entry
+       addl2   $addr,r0
+#  this boot assumes only small files(<11 blocks)
+       extzv   $0,$24,(r0),r4  #  get low 2 bytes of block no. -> r4
+       bneq    rblk  #  read in block if non-zero
+#  zero cc is set on return
+       rsb
+#
+#  subr to read disc block no. specified in r4 from RP06, drive 0
+#
+rblk :
+       clrl    r5
+       ediv    *$rpst,r4,*$RP_cyl,r1
+#  (r4 = block no.)/(no. blocks per cyl) -> cyl no.
+#  r1 = remainder = block offset with in cylinder
+       clrl    r2
+       ediv    *$rpsec,r1,r1,r0
+#  r1 = track no. ; ; sector no. in low part RP_stk
+       insv    r1,$8,$5,r0  #  move track no. into RP_stk
+       movl    r0,*$RP_stk  #  track-sector
+       movl    $-BLKSIZ,*$M_bc  #  byte count
+       ashl    $-9,bufptr,r0  #  start page no. of buffer
+       bisl3   $0x80000000,r0,*$M_map  #  MBA map reg =
+#                      valid bit + phys page no.
+       clrl    *$M_var  #  buffer has been 512-byte aligned + map reg 0
+       movl    $RP_RED+RP_GO,*$RP_cr  #  disc read function code
+rprdy :
+       movl    *$RP_sr,r0
+       bbc     $RP_pDRY,r0,rprdy  #  loop unitl ready
+       bbs     $RP_pERR,r0,rperr  #  branch if error
+       bicpsw  $2  #  set zero cc for caller success
+       rsb     #  normal return
+  rperr :      #  disc i/o error
+       halt            #  halt on error
+#
+#
+bufptr :  .long  buf
+names :
+       .byte   'f,'b,'o,'o,'t,0,0,0,0,0,0,0,0,0
+       .byte  0
+#
+end:
+#
+       .set    buf,RELOC-1024
+       .set    inode,RELOC-512
+       .set    mode,inode
+       .set    nlink,mode+2
+       .set    uid,nlink+2
+       .set    gid,uid+2
+       .set    size,gid+2
+       .set    addr,size+4
+       .set    time,addr+40
+       .set    bno,time+12
+       .set    rptrk,bno+4
+       .set    rpsec,rptrk+4
+       .set    rpst,rpsec+4
diff --git a/usr/src/slowsys/h/acct.h b/usr/src/slowsys/h/acct.h
new file mode 100644 (file)
index 0000000..8a7d7c6
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Accounting structures
+ */
+
+typedef        unsigned short comp_t;  /* "floating pt": 3 bits base 8 exp, 13 bits fraction */
+struct acct
+{
+       char    ac_comm[10];            /* Accounting command name */
+       comp_t  ac_utime;               /* Accounting user time */
+       comp_t  ac_stime;               /* Accounting system time */
+       comp_t  ac_etime;               /* Accounting elapsed time */
+       time_t  ac_btime;               /* Beginning time */
+       short   ac_uid;                 /* Accounting user ID */
+       short   ac_gid;                 /* Accounting group ID */
+       short   ac_mem;                 /* average memory usage */
+       comp_t  ac_io;                  /* number of disk IO blocks */
+       dev_t   ac_tty;                 /* control typewriter */
+       char    ac_flag;                /* Accounting flag */
+};
+
+extern struct  acct    acctbuf;
+extern struct  inode   *acctp;         /* inode of accounting file */
+
+#define        AFORK   01              /* has executed fork, but no exec */
+#define        ASU     02              /* used super-user privileges */
diff --git a/usr/src/slowsys/h/buf.h b/usr/src/slowsys/h/buf.h
new file mode 100644 (file)
index 0000000..83df8b5
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Each buffer in the pool is usually doubly linked into 2 lists:
+ * the device with which it is currently associated (always)
+ * and also on a list of blocks available for allocation
+ * for other use (usually).
+ * The latter list is kept in last-used order, and the two
+ * lists are doubly linked to make it easy to remove
+ * a buffer from one list when it was found by
+ * looking through the other.
+ * A buffer is on the available list, and is liable
+ * to be reassigned to another disk block, if and only
+ * if it is not marked BUSY.  When a buffer is busy, the
+ * available-list pointers can be used for other purposes.
+ * Most drivers use the forward ptr as a link in their I/O
+ * active queue.
+ * A buffer header contains all the information required
+ * to perform I/O.
+ * Most of the routines which manipulate these things
+ * are in bio.c.
+ */
+struct buf
+{
+       int     b_flags;                /* see defines below */
+       struct  buf *b_forw;            /* headed by d_tab of conf.c */
+       struct  buf *b_back;            /*  "  */
+       struct  buf *av_forw;           /* position on free list, */
+       struct  buf *av_back;           /*     if not BUSY*/
+       dev_t   b_dev;                  /* major+minor device name */
+       unsigned b_bcount;              /* transfer count */
+       union {
+           caddr_t b_addr;             /* low order core address */
+           int *b_words;               /* words for clearing */
+           struct filsys *b_filsys;    /* superblocks */
+           struct dinode *b_dino;      /* ilist */
+           daddr_t *b_daddr;           /* indirect block */
+       } b_un;
+       daddr_t b_blkno;                /* block # on device */
+       char    b_xmem;                 /* high order core address */
+       char    b_error;                /* returned after I/O */
+       unsigned int b_resid;           /* words not transferred after error */
+};
+
+extern struct buf buf[];               /* The buffer pool itself */
+extern struct buf bfreelist;           /* head of available list */
+
+/*
+ * These flags are kept in b_flags.
+ */
+#define        B_WRITE 0       /* non-read pseudo-flag */
+#define        B_READ  01      /* read when I/O occurs */
+#define        B_DONE  02      /* transaction finished */
+#define        B_ERROR 04      /* transaction aborted */
+#define        B_BUSY  010     /* not on av_forw/back list */
+#define        B_PHYS  020     /* Physical IO potentially using UNIBUS map */
+#define        B_MAP   040     /* This block has the UNIBUS map allocated */
+#define        B_WANTED 0100   /* issue wakeup when BUSY goes off */
+#define        B_AGE   0200    /* delayed write for correct aging */
+#define        B_ASYNC 0400    /* don't wait for I/O completion */
+#define        B_DELWRI 01000  /* don't write till block leaves available list */
+#define        B_TAPE 02000    /* this is a magtape (no bdwrite) */
+
+/*
+ * special redeclarations for
+ * the head of the queue per
+ * device driver.
+ */
+#define        b_actf  av_forw
+#define        b_actl  av_back
+#define        b_active b_bcount
+#define        b_errcnt b_resid
diff --git a/usr/src/slowsys/h/callo.h b/usr/src/slowsys/h/callo.h
new file mode 100644 (file)
index 0000000..f66e5bb
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * The callout structure is for
+ * a routine arranging
+ * to be called by the clock interrupt
+ * (clock.c) with a specified argument,
+ * in a specified amount of time.
+ * Used, for example, to time tab
+ * delays on typewriters.
+ */
+
+struct callo
+{
+       int     c_time;         /* incremental time */
+       caddr_t c_arg;          /* argument to routine */
+       int     (*c_func)();    /* routine */
+};
+struct callo   callout[NCALL];
diff --git a/usr/src/slowsys/h/chan.h b/usr/src/slowsys/h/chan.h
new file mode 100644 (file)
index 0000000..84cb425
--- /dev/null
@@ -0,0 +1,100 @@
+#define NGROUPS                10
+#define        NCHANS          20
+
+
+struct chan {
+       int     c_flags;
+       char    c_index;
+       char    c_msg;
+       struct  group *c_group;
+       struct  tty     *c_ttyp;
+       int     c_pgrp;
+       union {
+               struct  clist   datq;
+       } cx;
+       union {
+               struct  clist   datq;
+               struct  chan    *c_chan;
+       } cy;
+       struct  clist   c_ctlx;
+       struct  clist   c_ctly;
+};
+
+
+struct group {
+       char    g_state;
+       char    g_mindex;
+       short   g_index;
+       short   g_count;
+       struct  inode   *g_inode;
+       struct  group   *g_master;
+       struct  clist   g_cntl;
+       struct  clist   g_datq;
+};
+
+/*
+ * flags
+ */
+#define        INUSE   01
+#define        XGRP    04
+#define        YGRP    010
+#define        WCLOSE  020
+#define        TTYO    040
+#define        SUBGRP  0100
+#define        BLOCK   0200
+#define        BLOCK1  0400
+#define        SIGBLK  01000
+#define        BLKMSG  01000
+#define        ENAMSG  02000
+#define        WFLUSH  04000
+
+
+/*
+ * mpxchan command codes
+ */
+#define        GROUP   5
+#define        GROUPN  6
+#define        CHAN    1
+#define JOIN   2
+#define EXTR   3
+#define        ATTACH  4
+#define        CONNECT 7
+#define        DETACH  8
+#define        DISCON  9
+#define DEBUG  10
+#define        NPGRP   11
+#define        CSIG    12
+
+#define NDEBUGS        30
+/*
+ * control channel message codes
+ */
+#define        WATTCH  1
+#define        SCLOSE  2
+#define        UID     3
+#define        M_BLK   4
+#define        M_UBLK  5
+#define        DO_BLK  6
+#define        DO_UBLK 7
+
+
+/*
+ * debug codes other than mpxchan cmds
+ */
+#define MCCLOSE 29
+#define MCOPEN 28
+#define        ALL     27
+#define SCON   26
+#define        MSREAD  25
+#define        SDATA   24
+#define        MCREAD  23
+#define MCWRITE        22
+
+union u_index {
+       short val;
+       struct {
+               char byte0;
+               char byte1;
+       };
+};
+typedef union u_index index_t;
diff --git a/usr/src/slowsys/h/clock.h b/usr/src/slowsys/h/clock.h
new file mode 100644 (file)
index 0000000..96c9505
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+  VAX clock registers
+ */
+
+#define ICCS_RUN 0x1
+#define ICCS_TRANS 0x10
+#define ICCS_SS 0x20
+#define ICCS_IE 0x40
+#define ICCS_INT 0x80
+#define ICCS_ERR 0x80000000
+# define YRCURR  1979  /*  current year */
+# define YRREF   1970  /*  reference year for time */
+# define SECHR  (60*60)  /* seconds/hr */
+# define SECDAY  (24*SECHR)  /* seconds/day */
+# define SECYR  (365*SECDAY) /* seconds/common year */
diff --git a/usr/src/slowsys/h/clock.m b/usr/src/slowsys/h/clock.m
new file mode 100644 (file)
index 0000000..375598e
--- /dev/null
@@ -0,0 +1,10 @@
+#
+# VAX clock registers
+#
+
+       .set    ICCS_RUN,0x1
+       .set    ICCS_TRANS,0x10
+       .set    ICCS_SS,0x20
+       .set    ICCS_IE,0x40
+       .set    ICCS_INT,0x80
+       .set    ICCS_ERR,0x80000000
diff --git a/usr/src/slowsys/h/conf.h b/usr/src/slowsys/h/conf.h
new file mode 100644 (file)
index 0000000..25a0ed9
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Declaration of block device
+ * switch. Each entry (row) is
+ * the only link between the
+ * main unix code and the driver.
+ * The initialization of the
+ * device switches is in the
+ * file conf.c.
+ */
+extern struct bdevsw
+{
+       int     (*d_open)();
+       int     (*d_close)();
+       int     (*d_strategy)();
+       struct buf *d_tab;
+} bdevsw[];
+
+/*
+ * Character device switch.
+ */
+extern struct cdevsw
+{
+       int     (*d_open)();
+       int     (*d_close)();
+       int     (*d_read)();
+       int     (*d_write)();
+       int     (*d_ioctl)();
+       struct tty *d_ttys;
+} cdevsw[];
+
+/*
+ * tty line control switch.
+ */
+extern struct linesw
+{
+       int     (*l_open)();
+       int     (*l_close)();
+       int     (*l_read)();
+       int     (*l_write)();
+       int     (*l_ioctl)();
+       int     (*l_rint)();
+       int     (*l_start)();
+} linesw[];
diff --git a/usr/src/slowsys/h/cons.h b/usr/src/slowsys/h/cons.h
new file mode 100644 (file)
index 0000000..b0a22dc
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+  VAX console interface registers
+ */
+
+#define RXCS_IE 0x40   /* receiver interrupt enable */
+#define RXCS_DONE 0x80 /* receiver done */
+#define RXDB_DATA 0xff /* received character */
+#define RXDB_ID 0xf00  /* channel id */
+#define RXDB_ERR 0x80000000    /* receiver error */
+
+#define TXCS_IE 0x40   /* transmitter interrupt enable */
+#define TXCS_RDY 0x80  /* transmitter ready for next char */
+#define TXDB_DATA 0xff /* transmitter byte */
+#define TXDB_ID 0xf00  /* channel id */
diff --git a/usr/src/slowsys/h/cons.m b/usr/src/slowsys/h/cons.m
new file mode 100644 (file)
index 0000000..9fedd92
--- /dev/null
@@ -0,0 +1,15 @@
+#
+# VAX console interface registers
+#
+
+       .set    RXCS_IE,0x40    # receiver interrupt enable
+       .set    RXCS_DONE,0x80  # receiver done
+       .set    RXDB_DATA,0xff  # received character
+       .set    RXDB_ID,0xf00   # channel id
+       .set    RXDB_ERR,0x80000000     # receiver error
+
+       .set    TXCS_IE,0x40    # transmitter interrupt i"enable
+       .set    TXCS_RDY,0x80   # transmitter ready for next char
+       .set    TXCS_BRDY,7             # bit number of TXCS_RDY
+       .set    TXDB_DATA,0xff  # transmitter byte
+       .set    TXDB_ID,0xf00   # channel id
diff --git a/usr/src/slowsys/h/dir.h b/usr/src/slowsys/h/dir.h
new file mode 100644 (file)
index 0000000..737a3a6
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef        DIRSIZ
+#define        DIRSIZ  14
+#endif
+struct direct
+{
+       ino_t   d_ino;
+       char    d_name[DIRSIZ];
+};
diff --git a/usr/src/slowsys/h/fblk.h b/usr/src/slowsys/h/fblk.h
new file mode 100644 (file)
index 0000000..9a1ba29
--- /dev/null
@@ -0,0 +1,5 @@
+struct fblk
+{
+       int     df_nfree;
+       daddr_t df_free[NICFREE];
+};
diff --git a/usr/src/slowsys/h/file.h b/usr/src/slowsys/h/file.h
new file mode 100644 (file)
index 0000000..99b3124
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * One file structure is allocated
+ * for each open/creat/pipe call.
+ * Main use is to hold the read/write
+ * pointer associated with each open
+ * file.
+ */
+struct file
+{
+       char    f_flag;
+       char    f_count;        /* reference count */
+       struct inode *f_inode;  /* pointer to inode structure */
+       union {
+               off_t   f_offset;       /* read/write character pointer */
+               struct chan *f_chan;    /* mpx channel pointer */
+       } f_un;
+};
+
+extern struct file file[];     /* The file table itself */
+
+/* flags */
+#define        FREAD   01
+#define        FWRITE  02
+#define        FPIPE   04
+#define FMPX   010
+#define        FMPY    020
+#define        FMP     030
diff --git a/usr/src/slowsys/h/filsys.h b/usr/src/slowsys/h/filsys.h
new file mode 100644 (file)
index 0000000..19ebcee
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Structure of the super-block
+ */
+struct filsys {
+       unsigned short s_isize; /* size in blocks of i-list */
+       daddr_t s_fsize;        /* size in blocks of entire volume */
+       short   s_nfree;        /* number of addresses in s_free */
+       daddr_t s_free[NICFREE];/* free block list */
+       short   s_ninode;       /* number of i-nodes in s_inode */
+       ino_t   s_inode[NICINOD];/* free i-node list */
+       char    s_flock;        /* lock during free list manipulation */
+       char    s_ilock;        /* lock during i-list manipulation */
+       char    s_fmod;         /* super block modified flag */
+       char    s_ronly;        /* mounted read-only flag */
+       time_t  s_time;         /* last super block update */
+       /* remainder not maintained by this version of the system */
+       daddr_t s_tfree;        /* total free blocks*/
+       ino_t   s_tinode;       /* total free inodes */
+       short   s_m;            /* interleave factor */
+       short   s_n;            /* " " */
+       char    s_fname[6];     /* file system name */
+       char    s_fpack[6];     /* file system pack name */
+};
diff --git a/usr/src/slowsys/h/ino.h b/usr/src/slowsys/h/ino.h
new file mode 100644 (file)
index 0000000..90579cb
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Inode structure as it appears on
+ * a disk block.
+ */
+struct dinode
+{
+       unsigned short  di_mode;        /* mode and type of file */
+       short   di_nlink;       /* number of links to file */
+       short   di_uid;         /* owner's user id */
+       short   di_gid;         /* owner's group id */
+       off_t   di_size;        /* number of bytes in file */
+       char    di_addr[40];    /* disk block addresses */
+       time_t  di_atime;       /* time last accessed */
+       time_t  di_mtime;       /* time last modified */
+       time_t  di_ctime;       /* time created */
+};
+#define        INOPB   8       /* 8 inodes per block */
+/*
+ * the 40 address bytes:
+ *     39 used; 13 addresses
+ *     of 3 bytes each.
+ */
diff --git a/usr/src/slowsys/h/inode.h b/usr/src/slowsys/h/inode.h
new file mode 100644 (file)
index 0000000..cfe5753
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * The I node is the focus of all
+ * file activity in unix. There is a unique
+ * inode allocated for each active file,
+ * each current directory, each mounted-on
+ * file, text file, and the root. An inode is 'named'
+ * by its dev/inumber pair. (iget/iget.c)
+ * Data, from mode on, is read in
+ * from permanent inode on volume.
+ */
+
+#define        NADDR   13
+#define        NINDEX  16
+
+struct group {
+       short   g_state;
+       char    g_index;
+       char    g_rot;
+       struct  group   *g_group;
+       struct  inode   *g_inode;
+       short   g_rotmask;
+       short   g_datq;
+       struct  chan *g_chans[NINDEX];
+};
+
+struct inode
+{
+       char    i_flag;
+       char    i_count;        /* reference count */
+       dev_t   i_dev;          /* device where inode resides */
+       ino_t   i_number;       /* i number, 1-to-1 with device address */
+       unsigned short  i_mode;
+       short   i_nlink;        /* directory entries */
+       short   i_uid;          /* owner */
+       short   i_gid;          /* group of owner */
+       off_t   i_size;         /* size of file */
+       union {
+               struct {
+                       daddr_t i_addr[NADDR];  /* if normal file/directory */
+                       daddr_t i_lastr;        /* last logical block read (for read-ahead) */
+               };
+               struct  {
+                       daddr_t i_rdev;                 /* i_addr[0] */
+                       struct  group   i_group;        /*  multiplexor group file */
+               };
+       } i_un;
+};
+
+
+extern struct inode inode[];   /* The inode table itself */
+
+/* flags */
+#define        ILOCK   01              /* inode is locked */
+#define        IUPD    02              /* file has been modified */
+#define        IACC    04              /* inode access time to be updated */
+#define        IMOUNT  010             /* inode is mounted on */
+#define        IWANT   020             /* some process waiting on lock */
+#define        ITEXT   040             /* inode is pure text prototype */
+#define        ICHG    0100            /* inode has been changed */
+
+/* modes */
+#define        IFMT    0170000         /* type of file */
+#define                IFDIR   0040000 /* directory */
+#define                IFCHR   0020000 /* character special */
+#define                IFBLK   0060000 /* block special */
+#define                IFREG   0100000 /* regular */
+#define                IFMPC   0030000 /* multiplexed char special */
+#define                IFMPB   0070000 /* multiplexed block special */
+#define        ISUID   04000           /* set user id on execution */
+#define        ISGID   02000           /* set group id on execution */
+#define ISVTX  01000           /* save swapped text even after use */
+#define        IREAD   0400            /* read, write, execute permissions */
+#define        IWRITE  0200
+#define        IEXEC   0100
diff --git a/usr/src/slowsys/h/map.h b/usr/src/slowsys/h/map.h
new file mode 100644 (file)
index 0000000..02b507a
--- /dev/null
@@ -0,0 +1,14 @@
+struct map
+{
+       short   m_size;
+       unsigned short m_addr;
+};
+
+struct map coremap[CMAPSIZ];   /* space for core allocation */
+struct map swapmap[SMAPSIZ];   /* space for swap allocation */
+/*
+       uba
+*/
+char bdpwant , umrwant ;
+struct map ubamap[UAMSIZ];
+struct map bdpmap[15];
diff --git a/usr/src/slowsys/h/mba.h b/usr/src/slowsys/h/mba.h
new file mode 100644 (file)
index 0000000..4eef220
--- /dev/null
@@ -0,0 +1,31 @@
+/* VAX Massbus adapter registers
+ */
+
+struct mba_regs {
+       int mba_csr,
+           mba_cr,
+           mba_sr,
+           mba_var,
+           mba_bcr;
+};
+
+/* NOTE:
+       mba_erb at displacement 0x400
+       mba_as at displacement 0x410
+       mba_map at displacement 0x800
+ */
+
+#define MBA0 0x80028000
+#define MBA1 0x8002a000
+
+#define MBA_ERB 0x400
+#define MBA_MAP 0x800
+
+#define MBA0_MAP MBA0 + 0x800
+#define MBA1_MAP MBA1 + 0x800
+
+#define MBAEBITS 0xe0770
+
+
+#define MBAIE 0x4
+
diff --git a/usr/src/slowsys/h/mba.m b/usr/src/slowsys/h/mba.m
new file mode 100644 (file)
index 0000000..1afda57
--- /dev/null
@@ -0,0 +1,15 @@
+#
+#      VAX massbus adapter registers
+#
+
+       .set    MBA0_CSR,0x80028000             # virtual address of mba0
+       .set    MBA1_CSR,0x8002a000             # ditto mba1
+
+       .set    MBA_CSR,0       # configuration and status register
+       .set    MBA_CR,4        # control register
+       .set    MBA_SR,8        # status register
+       .set    MBA_VAR,12      # virtual address register
+       .set    MBA_BCR,16      # byte count register
+       .set    MBA_ERB,0x400   # ???
+       .set    MBA_AS,0x410    # attention summary
+
diff --git a/usr/src/slowsys/h/mount.h b/usr/src/slowsys/h/mount.h
new file mode 100644 (file)
index 0000000..dfdbc90
--- /dev/null
@@ -0,0 +1,11 @@
+/*
+ * Mount structure.
+ * One allocated on every mount.
+ * Used to find the super block.
+ */
+struct mount
+{
+       dev_t   m_dev;          /* device mounted */
+       struct buf *m_bufp;     /* pointer to superblock */
+       struct inode *m_inodp;  /* pointer to mounted on inode */
+} mount[NMOUNT];
diff --git a/usr/src/slowsys/h/mpx.h b/usr/src/slowsys/h/mpx.h
new file mode 100644 (file)
index 0000000..1ba6c13
--- /dev/null
@@ -0,0 +1,70 @@
+#define        M       3
+#define        C       100
+
+/*
+ * character Q structure
+ */
+struct clist
+{
+       int     c_cc;
+       int     c_cf;
+       int     c_cl;
+};
+
+struct chan
+{
+       char    cflag;
+       char    m, c;
+       struct  chan    *dest;
+       struct  clist   ioq;
+};
+
+/* c flags */
+#define        BLOCK   01
+
+struct line
+{
+       char    xbuf[24+2];
+       char    rbuf[100+2];
+       char    rseq;
+       char    xseq;
+       char    ackf;
+       char    xflag;
+       char    state;
+       char    time;
+       int     sum;
+       char    *ip;
+       char    *ep;
+};
+#define        WWAIT   02
+#define        CRUN    04
+#define        RWAIT   010
+#define        ALLOC   020
+#define        DIS     040
+#define        DLY     0100
+
+/*
+ * machine structure
+ */
+struct mach
+{
+       char    mflag;
+       char    rchan;
+       char    rcount;
+       char    xchan;
+       char    xcount;
+       struct  clist   ackq;
+       struct  clist   datq;
+       struct  clist   disq;
+       struct  chan    *chanp[128];
+};
+
+/* m flags */
+#define        RNEXT   01
+#define        MRUN    04
+#define        XNEXT   010
+
+/*
+ * trace buffer
+ */
+#define        TBSIZ   100
diff --git a/usr/src/slowsys/h/mtpr.h b/usr/src/slowsys/h/mtpr.h
new file mode 100644 (file)
index 0000000..c27dd35
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+       VAX processor register numbers
+ */
+
+#define KSP 0          /* kernal stack pointer */
+#define ESP 1          /* exec stack pointer */
+#define SSP 2          /* supervisor stack pointer */
+#define USP 3          /* user stack pointer */
+#define ISP 4          /* interrupt stack pointer */
+#define P0BR 8         /* p0 base register */
+#define P0LR 9         /* p0 length register */
+#define P1BR 10                /* p1 base register */
+#define P1LR 11                /* p1 length register */
+#define SBR 12         /* system segment base register */
+#define SLR 13         /* system segment length register */
+#define PCBB 16                /* process control block base */
+#define SCBB 17                /* system control block base */
+#define IPL 18         /* interrupt priority level */
+#define ASTLVL 19      /* async. system trap level */
+#define SIRR 20                /* software interrupt request */
+#define SISR 21                /* software interrupt summary */
+#define ICCS 24                /* interval clock control */
+#define NICR 25                /* next interval count */
+#define ICR 26         /* interval count */
+#define TODR 27                /* time of year (day) */
+#define RXCS 32                /* console receiver control and status */
+#define RXDB 33                /* console receiver data buffer */
+#define TXCS 34                /* console transmitter control and status */
+#define TXDB 35                /* console transmitter data buffer */
+#define MAPEN 56       /* memory management enable */
+#define TBIA 57                /* translation buffer invalidate all */
+#define TBIS 58                /* translation buffer invalidate single */
+#define PMR 61         /* performance monitor enable */
+#define SID 62         /* system identification */
+/*
+       VAX-11/780 specific registers
+ */
+#define ACCS 40                /* accelerator control and status */
+#define ACCR 41                /* accelerator maintenance */
+#define WCSA 44                /* WCS address */
+#define WCSD 45                /* WCS data */
+#define SBIFS 48       /* SBI fault and status */
+#define SBIS 49                /* SBI silo */
+#define SBISC 50       /* SBI silo comparator */
+#define SBIMT 51       /* SBI maintenance */
+#define SBIER 52       /* SBI error register */
+#define SBITA 53       /* SBI timeout address */
+#define SBIQC 54       /* SBI quadword clear */
+#define MBRK 60                /* micro-program breakpoint */
diff --git a/usr/src/slowsys/h/mtpr.m b/usr/src/slowsys/h/mtpr.m
new file mode 100644 (file)
index 0000000..e8211ee
--- /dev/null
@@ -0,0 +1,48 @@
+#
+#      VAX processor register numbers
+#
+       .set    KSP,0           # kernal stack pointer
+       .set    ESP,1           # exec stack pointer
+       .set    SSP,2           # supervisor stack pointer
+       .set    USP,3           # user stack pointer
+       .set    ISP,4           # interrupt stack pointer
+       .set    P0BR,8          # p0 base register
+       .set    P0LR,9          # p0 length register
+       .set    P1BR,10         # p1 base register
+       .set    P1LR,11         # p1 length register
+       .set    SBR,12          # system segment base register
+       .set    SLR,13          # system segment length register
+       .set    PCBB,16         # process control block base
+       .set    SCBB,17         # system control block base
+       .set    IPL,18          # interrupt priority level
+       .set    ASTLVL,19       # async. system trap level
+       .set    SIRR,20         # software interrupt request
+       .set    SISR,21         # software interrupt summary
+       .set    ICCS,24         # interval clock control
+       .set    NICR,25         # next interval count
+       .set    ICR,26          # interval count
+       .set    TODR,27         # time of year (day)
+       .set    RXCS,32         # console receiver control and status
+       .set    RXDB,33         # console receiver data buffer
+       .set    TXCS,34         # console transmitter control and status
+       .set    TXDB,35         # console transmitter data buffer
+       .set    MAPEN,56        # memory management enable
+       .set    TBIA,57         # translation buffer invalidate all
+       .set    TBIS,58         # translation buffer invalidate single
+       .set    PMR,61          # performance monitor enable
+       .set    SID,62          # system identification
+#
+#      VAX-11/780 specific registers
+#
+       .set    ACCS,40         # accelerator control and status
+       .set    ACCR,41         # accelerator maintenance
+       .set    WCSA,44         # WCS address
+       .set    WCSD,45         # WCS data
+       .set    SBIFS,48        # SBI fault and status
+       .set    SBIS,49         # SBI silo
+       .set    SBISC,50        # SBI silo comparator
+       .set    SBIMT,51        # SBI maintenance
+       .set    SBIER,52        # SBI error register
+       .set    SBITA,53        # SBI timeout address
+       .set    SBIQC,54        # SBI quadword clear
+       .set    MBRK,60         # micro-program breakpoint
diff --git a/usr/src/slowsys/h/mx.h b/usr/src/slowsys/h/mx.h
new file mode 100644 (file)
index 0000000..8551dab
--- /dev/null
@@ -0,0 +1,106 @@
+#define NGROUPS                10
+#define        NCHANS          20
+
+
+struct chan {
+       short   c_flags;
+       char    c_index;
+       char    c_iline;
+       struct  group   *c_group;
+       struct  tty     *c_ittyp;
+       struct  tty     *c_ottyp;
+       struct  file    *c_fy;
+       int     c_pgrp;
+       char    c_oline;
+       union {
+               struct  clist   datq;
+       } cx;
+       union {
+               struct  clist   datq;
+               struct  chan    *c_chan;
+       } cy;
+       struct  clist   c_ctlx;
+       struct  clist   c_ctly;
+};
+
+
+
+
+struct header {
+       short   index;
+       short   count;
+       short   ccount;
+       caddr_t addr;
+};
+
+
+
+
+/*
+ * flags
+ */
+#define        INUSE   01
+#define COPEN  02
+#define        XGRP    04
+#define        YGRP    010
+#define        WCLOSE  020
+#define        TTYO    040
+#define        ISGRP   0100
+#define        BLOCK   0200
+#define        BLOCK1  0400
+#define        SIGBLK  01000
+#define        BLKMSG  01000
+#define        ENAMSG  02000
+#define        WFLUSH  04000
+#define        RZERO   010000
+
+
+/*
+ * mpxchan command codes
+ */
+#define        MPX     5
+#define        MPXN    6
+#define        CHAN    1
+#define JOIN   2
+#define EXTR   3
+#define        ATTACH  4
+#define        CONNECT 7
+#define        DETACH  8
+#define        DISCON  9
+#define DEBUG  10
+#define        NPGRP   11
+#define        CSIG    12
+#define PACK   13
+
+#define NDEBUGS        30
+/*
+ * control channel message codes
+ */
+#define M_WATCH 1
+#define M_CLOSE 2
+#define        M_ATTACH 3
+#define        M_BLK   4
+#define        M_UBLK  5
+#define        DO_BLK  6
+#define        DO_UBLK 7
+#define        M_XINT  8
+#define        M_RINT  9
+#define        M_ACK   10
+#define        M_NAK\e  11
+
+
+/*
+ * debug codes other than mpxchan cmds
+ */
+#define MCCLOSE 29
+#define MCOPEN 28
+#define        ALL     27
+#define SCON   26
+#define        MSREAD  25
+#define        SDATA   24
+#define        MCREAD  23
+#define MCWRITE        22
+
+#define        HDRSIZE         4
+#define        CNTLSIZ         10
+#define        NLEVELS         4
diff --git a/usr/src/slowsys/h/page.h b/usr/src/slowsys/h/page.h
new file mode 100644 (file)
index 0000000..c2a719e
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+  VAX page table entry
+ */
+
+struct pt_entry {
+       int pg_pfnum:21,
+               :2,
+               pg_type:2,
+               :1,
+           pg_m:1,
+           pg_prot:4,
+           pg_v:1;
+};
+
+#define PG_PFNUM 0x1fffff
+#define PG_M 0x4000000
+#define PG_PROT 0x78000000
+#define PG_V 0x80000000
+
+#define PG_NOACC 0
+#define PG_KR 0x18000000
+#define PG_KW 0x10000000
+#define PG_UW 0x20000000
+#define PGURKW 0x60000000
+#define PG_URKR 0x78000000
+
+#define PG_TXT 0x01800000
diff --git a/usr/src/slowsys/h/page.m b/usr/src/slowsys/h/page.m
new file mode 100644 (file)
index 0000000..8a0be04
--- /dev/null
@@ -0,0 +1,15 @@
+#
+# VAX page table entry
+#
+
+       .set    PG_PFNUM,0x1fffff
+       .set    PG_M,0x4000000
+       .set    PG_PROT,0x78000000
+       .set    PG_V,0x80000000
+
+       .set    PG_NOACC,0
+       .set    PG_KR,0x18000000
+       .set    PG_KW,0x10000000
+       .set    PG_UW,0x20000000
+       .set    PGURKW,0x60000000
+       .set    PG_URKR,0x78000000
diff --git a/usr/src/slowsys/h/param.h b/usr/src/slowsys/h/param.h
new file mode 100644 (file)
index 0000000..5b49357
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * tunable variables
+ */
+
+#define        NBUF    32              /* size of buffer cache */
+#define        NINODE  125             /* number of in core inodes */
+#define        NFILE   125             /* number of in core file structures */
+#define        NMOUNT  8               /* number of mountable file systems */
+#define        MAXMEM  1024            /* max core in 512-byte clicks */
+#define        MAXUPRC 25              /* max processes per user */
+#define        SSIZE   4               /* initial stack size (*512 bytes) */
+#define        SINCR   4               /* increment of stack (*512 bytes) */
+#define        NOFILE  20              /* max open files per process */
+#define        CANBSIZ 256             /* max size of typewriter line */
+#define        CMAPSIZ 50              /* size of core allocation area */
+#define        SMAPSIZ 50              /* size of swap allocation area */
+#define        NCALL   20              /* max simultaneous time callouts */
+#define        NPROC   65              /* max number of processes */
+#define        NTEXT   40              /* max number of pure texts */
+#define        NCLIST  150             /* max total clist size */
+#define        HZ      60              /* Ticks/second of the clock */
+#define        TIMEZONE        (5*60)          /* Minutes westward from Greenwich */
+#define        DSTFLAG 1               /* Daylight Saving Time applies in this locality */
+#define        MSGBUFS 128             /* Characters saved from error messages */
+#define        NCARGS  5120            /* # characters in exec arglist */
+#define        USRSTACK 0x80000000     /* Start of user stack */
+#define PHYSPAGES 1024 /* number of real memory pages */
+
+/*
+ * priorities
+ * probably should not be
+ * altered too much
+ */
+
+#define        PSWP    0
+#define        PINOD   10
+#define        PRIBIO  20
+#define        PZERO   25
+#define NZERO  20
+#define        PPIPE   26
+#define        PWAIT   30
+#define        PSLEP   40
+#define        PUSER   50
+
+/*
+ * signals
+ * dont change
+ */
+
+#define        NSIG    17
+/*
+ * No more than 16 signals (1-16) because they are
+ * stored in bits in a word.
+ */
+#define        SIGHUP  1       /* hangup */
+#define        SIGINT  2       /* interrupt (rubout) */
+#define        SIGQUIT 3       /* quit (FS) */
+#define        SIGINS  4       /* illegal instruction */
+#define        SIGTRC  5       /* trace or breakpoint */
+#define        SIGIOT  6       /* iot */
+#define        SIGEMT  7       /* emt */
+#define        SIGFPT  8       /* floating exception */
+#define        SIGKIL  9       /* kill, uncatchable termination */
+#define        SIGBUS  10      /* bus error */
+#define        SIGSEG  11      /* segmentation violation */
+#define        SIGSYS  12      /* bad system call */
+#define        SIGPIPE 13      /* end of pipe */
+#define        SIGCLK  14      /* alarm clock */
+#define        SIGTRM  15      /* Catchable termination */
+
+/*
+ * fundamental constants of the implementation--
+ * cannot be changed easily
+ */
+
+#define        NBPW    sizeof(int)     /* number of bytes in an integer */
+#define        BSIZE   512             /* size of secondary block (bytes) */
+/* BSLOP can be 0 unless you have a TIU/Spider */
+# define BSLOP 0       /* In case some device needs bigger buffers */
+#define        NINDIR  (BSIZE/sizeof(daddr_t))
+#define        BMASK   0777            /* BSIZE-1 */
+#define        BSHIFT  9               /* LOG2(BSIZE) */
+#define        NMASK   0177            /* NINDIR-1 */
+#define        NSHIFT  7               /* LOG2(NINDIR) */
+#define USIZE  (4 + u.u_pcb.pcb_szpt)  /* size of user block (*512) */
+#define        UBASE   (0x80000000 + PHYSPAGES*512)    /* abs. addr of user block */
+#define        NULL    0
+#define CMASK  0       /* default mask for file creation */
+#define        NODEV   (dev_t)(-1)
+#define        ROOTINO ((ino_t)2)      /* i number of all roots */
+#define        SUPERB  ((daddr_t)1)    /* block number of the super block */
+#define        DIRSIZ  14              /* max characters per directory */
+#define        NICINOD 100             /* number of superblock inodes */
+#define        NICFREE 50              /* number of superblock free blocks */
+#define        CBSIZE  12              /* number of chars in a clist block */
+#define        CROUND  0xF             /* clist rounding; sizeof(int *) + CBSIZE -1*/
+#define CLKTICK        16667           /* microseconds in a  clock tick */
+
+/*
+ * Some macros for units conversion
+ */
+/* Core clicks (512 bytes) to segments and vice versa */
+#define        ctos(x) (x)
+#define        stoc(x) (x)
+
+/* Core clicks (512 bytes) to disk blocks */
+#define        ctod(x) (x)
+
+/* inumber to disk address */
+#define        itod(x) (daddr_t)((((unsigned)x+15)>>3))
+
+/* inumber to disk offset */
+#define        itoo(x) (int)((x+15)&07)
+
+/* clicks to bytes */
+#define        ctob(x) (x<<9)
+
+/* bytes to clicks */
+#define        btoc(x) ((((unsigned)x+511)>>9))
+
+/* major part of a device */
+#define        major(x)        (int)(((unsigned)x>>8)&0377)
+
+/* minor part of a device */
+#define        minor(x)        (int)(x&0377)
+
+/* make a device number */
+#define        makedev(x,y)    (dev_t)(((x)<<8) | (y))
+
+typedef        struct { int r[1]; } *  physadr;
+typedef        int             daddr_t;
+typedef char *         caddr_t;
+typedef        unsigned short          ino_t;
+typedef        int             time_t;
+typedef        int             label_t[10];
+typedef        short           dev_t;
+typedef        int             off_t;
+
+/*
+ * Machine-dependent bits and macros
+ */
+#define        UMODE   PSL_CURMOD              /* usermode bits */
+#define        USERMODE(ps)    ((ps & UMODE) == UMODE)
+
+#define        BASEPRI(ps)     ((ps & PSL_IPL) != 0)
diff --git a/usr/src/slowsys/h/pcb.h b/usr/src/slowsys/h/pcb.h
new file mode 100644 (file)
index 0000000..a28f6a6
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+   VAX process control block
+ */
+
+struct pcb {
+       int
+       pcb_ksp,        /* kernal stack pointer */
+       pcb_esp,        /* exec stack pointer */
+       pcb_ssp,        /* supervisor stack pointer */
+       pcb_usp,        /* user stack pointer */
+       pcb_r0, 
+       pcb_r1, 
+       pcb_r2, 
+       pcb_r3, 
+       pcb_r4, 
+       pcb_r5, 
+       pcb_r6, 
+       pcb_r7, 
+       pcb_r8, 
+       pcb_r9, 
+       pcb_r10, 
+       pcb_r11, 
+       pcb_r12, 
+       pcb_r13, 
+       pcb_pc,         /* program counter */
+       pcb_psl,        /* program status longword */
+       pcb_p0br,       /* seg 0 base register */
+       pcb_p0lr,       /* seg 0 length register and astlevel */
+       pcb_p1br,       /* seg 1 base register */
+       pcb_p1lr,       /* seg 1 length register and pme */
+
+/*
+   Software pcb (extension)
+ */
+
+       pcb_szpt;       /* number of pages of user page table */
+
+};
diff --git a/usr/src/slowsys/h/pcb.m b/usr/src/slowsys/h/pcb.m
new file mode 100644 (file)
index 0000000..cf6b4eb
--- /dev/null
@@ -0,0 +1,35 @@
+#
+#      VAX process control block
+#
+
+       .set    PCB_KSP,0       # kernal stack pointer
+       .set    PCB_ESP,4       # exec stack pointer
+       .set    PCB_SSP,8       # supervisor stack pointer
+       .set    PCB_USP,12      # user stack pointer
+       .set    PCB_R0,16
+       .set    PCB_R1,20
+       .set    PCB_R2,24
+       .set    PCB_R3,28
+       .set    PCB_R4,32
+       .set    PCB_R5,36
+       .set    PCB_R6,40
+       .set    PCB_R7,44
+       .set    PCB_R8,48
+       .set    PCB_R9,52
+       .set    PCB_R10,56
+       .set    PCB_R11,60
+       .set    PCB_R12,64
+       .set    PCB_R13,68
+       .set    PCB_PC,72       # program counter
+       .set    PCB_PSL,76      # program status longword
+       .set    PCB_P0BR,80     # seg 0 base register
+       .set    PCB_P0LR,84     # seg 0 length register and astlevel
+       .set    PCB_P1BR,88     # seg 1 base register
+       .set    PCB_P1LR,92     # seg 1 length register and pme
+
+#
+#      software pcb (extension)
+#
+
+       .set    PCB_SZPT,96     # number of pages of user page table
+
diff --git a/usr/src/slowsys/h/proc.h b/usr/src/slowsys/h/proc.h
new file mode 100644 (file)
index 0000000..7d6c1b1
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * One structure allocated per active
+ * process. It contains all data needed
+ * about the process while the
+ * process may be swapped out.
+ * Other per process data (user.h)
+ * is swapped with the process.
+ */
+struct proc {
+       char    p_stat;
+       char    p_flag;
+       char    p_pri;          /* priority, negative is high */
+       char    p_time;         /* resident time for scheduling */
+       char    p_cpu;          /* cpu usage for scheduling */
+       char    p_nice;         /* nice for cpu usage */
+       short   p_sig;          /* signals pending to this process */
+       short   p_uid;          /* user id, used to direct tty signals */
+       short   p_pgrp;         /* name of process group leader */
+       short   p_pid;          /* unique process id */
+       short   p_ppid;         /* process id of parent */
+       short   p_addr;         /* address of swappable image */
+       short   p_size;         /* size of swappable image (clicks) */
+       caddr_t p_wchan;        /* event process is awaiting */
+       struct text *p_textp;   /* pointer to text structure */
+       struct proc *p_link;    /* linked list of running processes */
+       int     p_clktim;       /* time to alarm clock signal */
+};
+
+extern struct proc proc[];     /* the proc table itself */
+
+/* stat codes */
+#define        SSLEEP  1               /* awaiting an event */
+#define        SWAIT   2               /* (abandoned state) */
+#define        SRUN    3               /* running */
+#define        SIDL    4               /* intermediate state in process creation */
+#define        SZOMB   5               /* intermediate state in process termination */
+#define        SSTOP   6               /* process being traced */
+
+/* flag codes */
+#define        SLOAD   01              /* in core */
+#define        SSYS    02              /* scheduling process */
+#define        SLOCK   04              /* process cannot be swapped */
+#define        SSWAP   010             /* process is being swapped out */
+#define        STRC    020             /* process is being traced */
+#define        SWTED   040             /* another tracing flag */
+#define        SULOCK  0100            /* user settable lock in core */
+
+/*
+ * parallel proc structure
+ * to replace part with times
+ * to be passed to parent process
+ * in ZOMBIE state.
+ */
+struct xproc {
+       char    xp_stat;
+       char    xp_flag;
+       char    xp_pri;         /* priority, negative is high */
+       char    xp_time;        /* resident time for scheduling */
+       char    xp_cpu;         /* cpu usage for scheduling */
+       char    xp_nice;        /* nice for cpu usage */
+       short   xp_sig;         /* signals pending to this process */
+       short   xp_uid;         /* user id, used to direct tty signals */
+       short   xp_pgrp;        /* name of process group leader */
+       short   xp_pid;         /* unique process id */
+       short   xp_ppid;        /* process id of parent */
+       short   xp_xstat;       /* Exit status for wait */
+       time_t  xp_utime;       /* user time, this proc */
+       time_t  xp_stime;       /* system time, this proc */
+};
diff --git a/usr/src/slowsys/h/psl.h b/usr/src/slowsys/h/psl.h
new file mode 100644 (file)
index 0000000..3f0e26b
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+       VAX program status longword
+ */
+
+#define PSL_C 0x1              /* carry bit */
+#define PSL_V 0x2              /* overflow bit */
+#define PSL_Z 0x4              /* zero bit */
+#define PSL_N 0x8              /* negative bit */
+#define PSL_T 0x10             /* trace enable bit */
+#define PSL_IV 0x20            /* integer overflow enable bit */
+#define PSL_FU 0x40            /* floating point underflow enable bit */
+#define PSL_DV 0x80            /* decimal overflow enable bit */
+#define PSL_IPL 0x1f0000       /* interrupt priority level */
+#define PSL_PRVMOD 0xc00000    /* previous mode */
+#define PSL_CURMOD 0x3000000   /* current mode */
+#define PSL_IS 0x4000000       /* interrupt stack */
+#define PSL_FPD 0x8000000      /* first part done */
+#define PSL_TP 0x40000000      /* trace pending */
+#define PSL_CM 0x80000000      /* compatibility mode */
+
diff --git a/usr/src/slowsys/h/psl.m b/usr/src/slowsys/h/psl.m
new file mode 100644 (file)
index 0000000..75f9c6e
--- /dev/null
@@ -0,0 +1,20 @@
+#
+#      VAX program status longword
+#
+
+       .set    PSL_C,0x1               # carry bit
+       .set    PSL_V,0x2               # overflow bit
+       .set    PSL_Z,0x4               # zero bit
+       .set    PSL_N,0x8               # negative bit
+       .set    PSL_T,0x10              # trace enable bit
+       .set    PSL_IV,0x20             # integer overflow enable bit
+       .set    PSL_FU,0x40             # floating point underflow enable bit
+       .set    PSL_DV,0x80             # decimal overflow enable bit
+       .set    PSL_IPL,0x1f0000        # interrupt priority level
+       .set    PSL_PRVMOD,0xc00000     # previous mode
+       .set    PSL_CURMOD,0x3000000    # current mode
+       .set    PSL_IS,0x4000000        # interrupt stack
+       .set    PSL_FPD,0x8000000       # first part done
+       .set    PSL_TP,0x40000000       # trace pending
+       .set    PSL_CM,0x80000000       # compatibility mode
+
diff --git a/usr/src/slowsys/h/reg.h b/usr/src/slowsys/h/reg.h
new file mode 100644 (file)
index 0000000..f967548
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Location of the users' stored
+ * registers relative to R0.
+ * Usage is u.u_ar0[XX].
+ */
+#define        R0      0
+#define        R1      1
+#define        R2      2
+#define        R3      3
+#define        R4      4
+#define        R5      5
+#define        R6      6
+#define        R7      7
+#define        R8      8
+#define        R9      9
+#define        R10     10
+#define        R11     11
+#define        R12     12
+#define        R13     13
+
+#define AP     12
+#define        FP      13
+#define        SP      14
+#define        PS      18
+#define        PC      17
diff --git a/usr/src/slowsys/h/seg.h b/usr/src/slowsys/h/seg.h
new file mode 100644 (file)
index 0000000..ab0437d
--- /dev/null
@@ -0,0 +1,6 @@
+/*
+ * Mapper addresses and bits
+ */
+
+#define        RO      PG_URKR         /* access abilities */
+#define        RW      PG_UW
diff --git a/usr/src/slowsys/h/stat.h b/usr/src/slowsys/h/stat.h
new file mode 100644 (file)
index 0000000..8101f5e
--- /dev/null
@@ -0,0 +1,28 @@
+struct stat
+{
+       dev_t   st_dev;
+       ino_t   st_ino;
+       unsigned short st_mode;
+       short           st_nlink;
+       short           st_uid;
+       short           st_gid;
+       dev_t   st_rdev;
+       off_t   st_size;
+       time_t  st_atime;
+       time_t  st_mtime;
+       time_t  st_ctime;
+};
+
+#define        S_IFMT  0170000         /* type of file */
+#define                S_IFDIR 0040000 /* directory */
+#define                S_IFCHR 0020000 /* character special */
+#define                S_IFBLK 0060000 /* block special */
+#define                S_IFREG 0100000 /* regular */
+#define                S_IFMPC 0030000 /* multiplexed char special */
+#define                S_IFMPB 0070000 /* multiplexed block special */
+#define        S_ISUID 0004000         /* set user id on execution */
+#define        S_ISGID 0002000         /* set group id on execution */
+#define        S_ISVTX 0001000         /* save swapped text even after use */
+#define        S_IREAD 0000400         /* read permission, owner */
+#define        S_IWRITE        0000200         /* write permission, owner */
+#define        S_IEXEC 0000100         /* execute/search permission, owner */
diff --git a/usr/src/slowsys/h/systm.h b/usr/src/slowsys/h/systm.h
new file mode 100644 (file)
index 0000000..c642336
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Random set of variables
+ * used by more than one
+ * routine.
+ */
+char   canonb[CANBSIZ];        /* buffer for erase and kill (#@) */
+struct inode *rootdir;         /* pointer to inode of root directory */
+struct proc *runq;             /* head of linked list of running processes */
+int    cputype;                /* type of cpu =40, 45, or 70 */
+int    lbolt;                  /* time of day in 60th not in time */
+time_t time;                   /* time in sec from 1970 */
+int    time64[2];              /* microseconds since system was booted */
+
+/*
+ * Nblkdev is the number of entries
+ * (rows) in the block switch. It is
+ * set in binit/bio.c by making
+ * a pass over the switch.
+ * Used in bounds checking on major
+ * device numbers.
+ */
+int    nblkdev;
+
+/*
+ * Number of character switch entries.
+ * Set by cinit/tty.c
+ */
+int    nchrdev;
+
+int    mpid;                   /* generic for unique process id's */
+char   runin;                  /* scheduling flag */
+char   runout;                 /* scheduling flag */
+char   runrun;                 /* scheduling flag */
+char   curpri;                 /* more scheduling */
+int    maxmem;                 /* actual max memory per process */
+daddr_t        swplo;                  /* block number of swap space */
+int    nswap;                  /* size of swap space */
+int    updlock;                /* lock for sync */
+daddr_t        rablock;                /* block to be read ahead */
+extern char    regloc[];       /* locs. of saved user registers (trap.c) */
+char   msgbuf[MSGBUFS];        /* saved "printf" characters */
+int    intstack[512];          /* stack for interrupts */
+dev_t  rootdev;                /* device of the root */
+dev_t  swapdev;                /* swapping device */
+dev_t  pipedev;                /* pipe device */
+extern int     icode[];        /* user init code */
+extern int     szicode;        /* its size */
+
+dev_t getmdev();
+daddr_t        bmap();
+struct inode *ialloc();
+struct inode *iget();
+struct inode *owner();
+struct inode *maknode();
+struct inode *namei();
+struct buf *alloc();
+struct buf *getblk();
+struct buf *geteblk();
+struct buf *bread();
+struct buf *breada();
+struct filsys *getfs();
+struct file *getf();
+struct file *falloc();
+int    uchar();
+caddr_t        realaddr();
+caddr_t        checkio();
+/*
+ * Instrumentation
+ */
+int    dk_busy;
+long   dk_time[32];
+long   dk_numb[3];
+long   dk_wds[3];
+long   tk_nin;
+long   tk_nout;
+
+/*
+ * Structure of the system-entry table
+ */
+extern struct sysent {
+       char    sy_narg;                /* total number of arguments */
+       char    sy_nrarg;               /* number of args in registers */
+       int     (*sy_call)();           /* handler */
+} sysent[];
diff --git a/usr/src/slowsys/h/text.h b/usr/src/slowsys/h/text.h
new file mode 100644 (file)
index 0000000..3e3b69e
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Text structure.
+ * One allocated per pure
+ * procedure on swap device.
+ * Manipulated by text.c
+ */
+struct text
+{
+       short   x_daddr;        /* disk address of segment (relative to swplo) */
+       short   x_caddr;        /* core address, if loaded */
+       short   x_size;         /* size (clicks) */
+       struct inode *x_iptr;   /* inode of prototype */
+       char    x_count;        /* reference count */
+       char    x_ccount;       /* number of loaded references */
+       char    x_flag;         /* traced, written flags */
+};
+
+extern struct text text[];
+
+#define        XTRC    01              /* Text may be written, exclusive use */
+#define        XWRIT   02              /* Text written into, must swap out */
+#define        XLOAD   04              /* Currently being read from file */
+#define        XLOCK   010             /* Being swapped in or out */
+#define        XWANT   020             /* Wanted for swapping */
diff --git a/usr/src/slowsys/h/timeb.h b/usr/src/slowsys/h/timeb.h
new file mode 100644 (file)
index 0000000..23c850c
--- /dev/null
@@ -0,0 +1,9 @@
+/*
+ * Structure returned by ftime system call
+ */
+struct timeb {
+       time_t  time;
+       unsigned short millitm;
+       short   timezone;
+       short   dstflag;
+};
diff --git a/usr/src/slowsys/h/trap.h b/usr/src/slowsys/h/trap.h
new file mode 100644 (file)
index 0000000..108a37b
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+       Trap type values
+ */
+
+#define RESADFLT 0             /* reserved addressing fault */
+#define PRIVINFLT 1            /* privileged instruction fault */
+#define BPTFLT 2               /* bpt instruction fault */
+#define XFCFLT 3               /* xfc instruction fault */
+#define RESOPFLT 4             /* reserved operand fault */
+#define SYSCALL 5              /* chmk instruction (syscall trap) */
+#define ARITHTRAP 6            /* arithmetic trap */
+#define RESCHED 7              /* software level 1 trap (reschedule trap) */
+#define SEGFLT 8               /* segmentation fault */
+#define PROTFLT 9              /* protection fault */
+#define TRCTRAP 10             /* trace trap */
+
diff --git a/usr/src/slowsys/h/trap.m b/usr/src/slowsys/h/trap.m
new file mode 100644 (file)
index 0000000..4d2ebb1
--- /dev/null
@@ -0,0 +1,16 @@
+#
+#      Trap,type values
+#
+
+       .set    RESADFLT,0              # reserved addressing fault
+       .set    PRIVINFLT,1             # privileged instruction fault
+       .set    BPTFLT,2                # bpt instruction fault
+       .set    XFCFLT,3                # xfc instruction fault
+       .set    RESOPFLT,4              # reserved operand fault
+       .set    SYSCALL,5               # chmk instruction (syscall trap)
+       .set    ARITHTRAP,6             # arithmetic trap
+       .set    RESCHED,7               # software level 1 trap (reschedule trap)
+       .set    SEGFLT,8                # segmentation fault
+       .set    PROTFLT,9               # protection fault
+
+       .set    TRCTRAP,10              # trace trap
diff --git a/usr/src/slowsys/h/tty.h b/usr/src/slowsys/h/tty.h
new file mode 100644 (file)
index 0000000..f329133
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * A clist structure is the head
+ * of a linked list queue of characters.
+ * The characters are stored in 4-word
+ * blocks containing a link and several characters.
+ * The routines getc and putc
+ * manipulate these structures.
+ */
+struct clist
+{
+       int     c_cc;           /* character count */
+       char    *c_cf;          /* pointer to first char */
+       char    *c_cl;          /* pointer to last char */
+};
+
+/*
+ * A tty structure is needed for
+ * each UNIX character device that
+ * is used for normal terminal IO.
+ * The routines in tty.c handle the
+ * common code associated with
+ * these structures.
+ * The definition and device dependent
+ * code is in each driver. (kl.c dc.c dh.c)
+ */
+struct tty
+{
+       struct  clist t_rawq;   /* input chars right off device */
+       struct  clist t_canq;   /* input chars after erase and kill */
+       struct  clist t_outq;   /* output list to device */
+       int     (* t_oproc)();  /* routine to start output */
+       int     (* t_iproc)();  /* routine to start input */
+       struct chan *t_chan;    /* destination channel */
+       caddr_t t_linep;        /* aux line discipline pointer */
+       caddr_t t_addr;         /* device address */
+       short   t_flags;        /* mode, settable by ioctl call */
+       short   t_state;        /* internal state, not visible externally */
+       short   t_pgrp;         /* process group name */
+       char    t_delct;        /* number of delimiters in raw q */
+       char    t_line;         /* line discipline */
+       char    t_col;          /* printing column of device */
+       char    t_erase;        /* erase character */
+       char    t_kill;         /* kill character */
+       char    t_char;         /* character temporary */
+       char    t_ispeed;       /* input speed */
+       char    t_ospeed;       /* output speed */
+};
+
+/*
+ * structure of arg for ioctl
+ */
+struct ttiocb {
+       char    ioc_ispeed;
+       char    ioc_ospeed;
+       char    ioc_erase;
+       char    ioc_kill;
+       int     ioc_flags;
+};
+
+#define        TTIPRI  28
+#define        TTOPRI  29
+
+#define        CERASE  '#'             /* default special characters */
+#define        CEOT    004
+#define        CKILL   '@'
+#define        CQUIT   034             /* FS, cntl shift L */
+#define        CINTR   0177            /* DEL */
+#define        CSTOP   023             /* Stop output: ctl-s */
+#define        CSTART  021             /* Start output: ctl-q */
+
+/* limits */
+#define        TTHIWAT 100
+#define        TTLOWAT 50
+#define        TTYHOG  256
+
+/* modes */
+#define        TANDEM  01
+#define        CBREAK  02
+#define        LCASE   04
+#define        ECHO    010
+#define        CRMOD   020
+#define        RAW     040
+#define        ODDP    0100
+#define        EVENP   0200
+#define        NLDELAY 001400
+#define        TBDELAY 006000
+#define        XTABS   006000
+#define        CRDELAY 030000
+#define        VTDELAY 040000
+
+/* Hardware bits */
+#define        DONE    0200
+#define        IENABLE 0100
+
+/* Internal state bits */
+#define        TIMEOUT 01              /* Delay timeout in progress */
+#define        WOPEN   02              /* Waiting for open to complete */
+#define        ISOPEN  04              /* Device is open */
+#define        CARR_ON 020             /* Software copy of carrier-present */
+#define        BUSY    040             /* Output in progress */
+#define        ASLEEP  0100            /* Wakeup when output done */
+#define        XCLUDE  0200            /* exclusive-use flag against open */
+#define        TTSTOP  0400            /* Output stopped by ctl-s */
+#define        HUPCLS  01000           /* Hang up upon last close */
+#define        TBLOCK  02000           /* tandem queue blocked */
+
+/*
+ * tty ioctl commands
+ */
+#define        TIOCGETD        (('t'<<8)|0)
+#define        TIOCSETD        (('t'<<8)|1)
+#define        TIOCHPCL        (('t'<<8)|2)
+#define        TIOCMODG        (('t'<<8)|3)
+#define        TIOCMODS        (('t'<<8)|4)
+#define        TIOCGETP        (('t'<<8)|8)
+#define        TIOCSETP        (('t'<<8)|9)
+#define        TIOCSETN        (('t'<<8)|10)
+#define        TIOCEXCL        (('t'<<8)|13)
+#define        TIOCNXCL        (('t'<<8)|14)
+#define        TIOCTSTP        (('t'<<8)|16)
+#define        DIOCLSTN        (('d'<<8)|1)
+#define        DIOCGETP        (('d'<<8)|8)
+#define        DIOCSETP        (('d'<<8)|9)
+#define        FIOCLEX         (('f'<<8)|1)
+#define        FIONCLEX        (('f'<<8)|2)
diff --git a/usr/src/slowsys/h/uba.h b/usr/src/slowsys/h/uba.h
new file mode 100644 (file)
index 0000000..9bb6cd0
--- /dev/null
@@ -0,0 +1,94 @@
+# define UBA0 0x80024000 /* sys virt i/o for UBA 0 */
+# define UBA0_DEV UBA0 + 0x2000 - 0160000      /* sys virt of device regs */
+# define UNIBASE 0760000 /* UNIBUS phys base of i/o reg's */
+/* UBA Configuration Register, CNFGR */
+# define PARFLT 0x80000000 /* SBI Parity Fault */
+# define WSQFLT 0x40000000 /* SBI Write Sequence Fault */
+# define URDFLT 0x20000000 /* SBI Unexpected Read Fault */
+# define ISQFLT 0x10000000 /* SBI Interlock Sequence Fault */
+# define MXTFLT 0x8000000 /* SBI Multiple Transmitter Fault */
+# define XMTFLT 0x4000000 /* UBA is transmit faulter */
+# define ADPDN 0x800000 /* Adapter Power Down */
+# define ADPUP 0x400000 /* Adapter Power Up */
+# define UBINIT 0x40000 /* UNIBUS INIT is asserted */
+# define UBPDN 0x20000 /* UNIBUS Power Down */
+# define UBIC 0x10000 /* UNIBUS Initialization */
+                       /* UNIBUS Ready */
+# define UBACOD 0xff  /*  UBA Code bits */
+/* UBA Control Register, UBACR  */
+# define MRD16 0x40000000  /* Map Reg Disable Bit 4  */
+# define MRD8 0x20000000  /* Map Reg Disable Bit 3  */
+# define MRD4 0x10000000  /* Map Rg Disable Bit 2  */
+# define MRD2 0x8000000  /* Map Reg Disable Bit 1 */
+# define MRD1 0x4000000  /* Map Reg Disable Bit 0 */
+# define IFS 0x40  /*  Interrupt Field Switch */
+# define BRIE 0x20  /* BR Interrupt Enable  */
+# define USEFIE 0x10  /* UNIBUS to SBI Error Field IE */
+# define SUEFIE 0x8  /* SBI to UNIBUS Error Field IE */
+# define CNFIE 0x4  /* Configuration IE  */
+# define UPF 0x2  /* UNIBUS Power Fail  */
+# define ADINIT 0x1  /* Adapter Init */
+/*  UBA Status Register, UASR  */
+# define BR7FULL 0x8000000  /* BR7 Receive Vector Rg Full  */
+# define BR6FULL 0x4000000  /* BR6 Receive Vector Reg Full */
+# define BR5FULL 0x2000000  /* BR5 Receive Vector Reg Full */
+# define BR4FULL 0x1000000  /* BR4 Receive Vector Reg Full */
+# define RDTO 0x400  /* UNIBUS to SBI Read Data Timeout */
+# define RDS 0x200  /* Read Data Substitute  */
+# define CRD 0x100  /* Corrected Read Data */
+# define CXTER 0x80  /* Command Transmit Error */
+# define CXTMO 0x40  /* Command Transmit Timeout */
+# define DPPE 0x20  /* Data Path Parity Error */
+# define IVMR 0x10  /* Invalid Map Register */
+# define MRPF 0x8  /* Map Register Parity Failure */
+# define LEB 0x4  /*  Lost Error  */
+# define UBSTO 0x2  /* UNIBUS Select Timeout */
+# define UBSSTO 0x1  /* UNIBUS Slave Sync Timeout */
+/* Failed Map Entry Register, FMER  */
+# define FMRN 0x1ff  /* Failed Map Reg. No. Field */
+/*  Failed UNIBUS Address Register, FUBAR  */
+# define FUA 0xffff  /* Failed UNIBUS Address Field */
+/*  BR Receive Vector register, BRRVR  */
+# define AIRI 0x80000000  /* Adapter Interrupt Request */
+# define DIV 0xffff  /* Device Interrupt Vector Field */
+/*  Data Path Register, DPR  */
+# define BNE 0x80000000  /*  Buffer Not Empty - Purge */
+# define BTE 0x40000000  /*  Buffer Transfer Error  */
+# define DPF 0x20000000  /* DP Function (RO)  */
+# define BS 0x7f0000  /*  Buffer State Field */
+# define BUBA 0xffff  /*  Buffered UNIBUS Address  */
+/*  Map Register, MR  */
+# define MRV 0x80000000  /*  Map Register Valid  */
+# define BO 0x2000000  /*  Byte Offset Bit  */
+# define DPDB 0x1e00000  /* Data Path Designator Field  */
+# define SBIPFN 0xfffff  /* SBI Page Address Field  */
+# define UAMSIZ 50
+/*
+*  UBA registers
+*/
+
+struct uba_regs {
+       int uba_cnfgr,
+           uba_cr,
+           uba_sr,
+           uba_dcr,
+           uba_fmer,
+           uba_fubar,
+           pad1[2],
+           uba_brsvr[4],
+           uba_brrvr[4],
+           uba_dpr[16],
+           pad2[480],
+           uba_map[496];
+       };
+
diff --git a/usr/src/slowsys/h/uba.m b/usr/src/slowsys/h/uba.m
new file mode 100644 (file)
index 0000000..30b5bd9
--- /dev/null
@@ -0,0 +1,14 @@
+#
+#      VAX unibus adapter registers
+#
+
+       .set    UBA,0x80024000          # virtual address of unibus registers
+       .set    UBA0,0x80024000
+       .set    UBR_OFF,0x30  #  UBA  offset to BRRVR regs
+       .set    CFGFLT,0xfc000000  #  SBI fault bits in UBA config reg
+       .set    UCN_OFF,4  #  UBA offset to config reg
+       .set    UST_OFF,8  #  UBA  offset to status reg
+
+       .set    UBA_SR,UBA + 0x8
+       .set    UBA_BR4,UBA + 0x30      # virtual address of interrupt vector registers
+
diff --git a/usr/src/slowsys/h/user.h b/usr/src/slowsys/h/user.h
new file mode 100644 (file)
index 0000000..9638dd4
--- /dev/null
@@ -0,0 +1,129 @@
+#include "../h/pcb.h"
+/*
+ * The user structure.
+ * One allocated per process.
+ * Contains all per process data
+ * that doesn't need to be referenced
+ * while the process is swapped.
+ * The user block is USIZE*512 bytes
+ * long; resides at virtual kernel
+ * loc 140000; contains the system
+ * stack per user; is cross referenced
+ * with the proc structure for the
+ * same process.
+ */
+#define        EXCLOSE 01
+struct user
+{
+       struct pcb u_pcb;               /* pcb, save area when exchanging stacks */
+       label_t u_rsav;
+       char    u_segflg;               /* IO flag: 0:user D; 1:system; 2:user I */
+       char    u_error;                /* return error code */
+       short   u_uid;                  /* effective user id */
+       short   u_gid;                  /* effective group id */
+       short   u_ruid;                 /* real user id */
+       short   u_rgid;                 /* real group id */
+       struct proc *u_procp;           /* pointer to proc structure */
+       int     *u_ap;                  /* pointer to arglist */
+       union {                         /* syscall return values */
+               struct  {
+                       int     r_val1;
+                       int     r_val2;
+               };
+               off_t   r_off;
+               time_t  r_time;
+       } u_r;
+       caddr_t u_base;                 /* base address for IO */
+       unsigned int u_count;           /* bytes remaining for IO */
+       off_t   u_offset;               /* offset in file for IO */
+       struct inode *u_cdir;           /* pointer to inode of current directory */
+       struct inode *u_rdir;           /* root directory of current process */
+       char    u_dbuf[DIRSIZ];         /* current pathname component */
+       caddr_t u_dirp;                 /* pathname pointer */
+       struct direct u_dent;           /* current directory entry */
+       struct inode *u_pdir;           /* inode of parent directory of dirp */
+       struct file *u_ofile[NOFILE];   /* pointers to file structures of open files */
+       char    u_pofile[NOFILE];       /* per-process flags of open files */
+       int     u_arg[5];               /* arguments to current system call */
+       unsigned u_tsize;               /* text size (clicks) */
+       unsigned u_dsize;               /* data size (clicks) */
+       unsigned u_ssize;               /* stack size (clicks) */
+       label_t u_qsav;                 /* label variable for quits and interrupts */
+       label_t u_ssav;                 /* label variable for swapping */
+       int     u_signal[NSIG];         /* disposition of signals */
+       time_t  u_utime;                /* this process user time */
+       time_t  u_stime;                /* this process system time */
+       time_t  u_cutime;               /* sum of childs' utimes */
+       time_t  u_cstime;               /* sum of childs' stimes */
+       int     *u_ar0;                 /* address of users saved R0 */
+       struct {                        /* profile arguments */
+               short   *pr_base;       /* buffer base */
+               unsigned pr_size;       /* buffer size */
+               unsigned pr_off;        /* pc offset */
+               unsigned pr_scale;      /* pc scaling */
+       } u_prof;
+       char    u_intflg;               /* catch intr from sys */
+       char    u_sep;                  /* flag for I and D separation */
+       struct tty *u_ttyp;             /* controlling tty pointer */
+       dev_t   u_ttyd;                 /* controlling tty dev */
+       struct {                        /* header of executable file */
+               int     ux_mag;         /* magic number */
+               unsigned ux_tsize;      /* text size */
+               unsigned ux_dsize;      /* data size */
+               unsigned ux_bsize;      /* bss size */
+               unsigned ux_ssize;      /* symbol table size */
+               unsigned ux_entloc;     /* entry location */
+               unsigned ux_unused;
+               unsigned ux_relflg;
+       } u_exdata;
+       char    u_comm[DIRSIZ];
+       time_t  u_start;
+       char    u_acflag;
+       short   u_fpflag;               /* unused now, will be later */
+       short   u_cmask;                /* mask for file creation */
+       int     u_stack[1];
+                                       /* kernel stack per user
+                                        * extends from u + USIZE*64
+                                        * backward not to reah here
+                                        */
+};
+
+extern struct user u;
+/* u_error codes */
+#define        EPERM   1
+#define        ENOENT  2
+#define        ESRCH   3
+#define        EINTR   4
+#define        EIO     5
+#define        ENXIO   6
+#define        E2BIG   7
+#define        ENOEXEC 8
+#define        EBADF   9
+#define        ECHILD  10
+#define        EAGAIN  11
+#define        ENOMEM  12
+#define        EACCES  13
+#define        EFAULT  14
+#define        ENOTBLK 15
+#define        EBUSY   16
+#define        EEXIST  17
+#define        EXDEV   18
+#define        ENODEV  19
+#define        ENOTDIR 20
+#define        EISDIR  21
+#define        EINVAL  22
+#define        ENFILE  23
+#define        EMFILE  24
+#define        ENOTTY  25
+#define        ETXTBSY 26
+#define        EFBIG   27
+#define        ENOSPC  28
+#define        ESPIPE  29
+#define        EROFS   30
+#define        EMLINK  31
+#define        EPIPE   32
+#define EDOM   33
+#define        ERANGE  34
diff --git a/usr/src/slowsys/sys/acct.c b/usr/src/slowsys/sys/acct.c
new file mode 100644 (file)
index 0000000..ec3f04f
--- /dev/null
@@ -0,0 +1,127 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/acct.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/inode.h"
+#include "../h/proc.h"
+#include "../h/seg.h"
+
+/*
+ * Perform process accounting functions.
+ */
+
+sysacct()
+{
+       register struct inode *ip;
+       register struct a {
+               char    *fname;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       if (suser()) {
+               if (uap->fname==NULL) {
+                       if (acctp) {
+                               plock(acctp);
+                               iput(acctp);
+                               acctp = NULL;
+                       }
+                       return;
+               }
+               if (acctp) {
+                       u.u_error = EBUSY;
+                       return;
+               }
+               ip = namei(uchar, 0);
+               if(ip == NULL)
+                       return;
+               if((ip->i_mode & IFMT) != IFREG) {
+                       u.u_error = EACCES;
+                       iput(ip);
+                       return;
+               }
+               acctp = ip;
+               prele(ip);
+       }
+}
+
+/*
+ * On exit, write a record on the accounting file.
+ */
+acct()
+{
+       register i;
+       register struct inode *ip;
+       off_t siz;
+
+       if ((ip=acctp)==NULL)
+               return;
+       plock(ip);
+       for (i=0; i<sizeof(acctbuf.ac_comm); i++)
+               acctbuf.ac_comm[i] = u.u_comm[i];
+       acctbuf.ac_utime = compress(u.u_utime);
+       acctbuf.ac_stime = compress(u.u_stime);
+       acctbuf.ac_etime = compress(time - u.u_start);
+       acctbuf.ac_btime = u.u_start;
+       acctbuf.ac_uid = u.u_ruid;
+       acctbuf.ac_gid = u.u_rgid;
+       acctbuf.ac_mem = 0;
+       acctbuf.ac_io = 0;
+       acctbuf.ac_tty = u.u_ttyd;
+       acctbuf.ac_flag = u.u_acflag;
+       siz = ip->i_size;
+       u.u_offset = siz;
+       u.u_base = (caddr_t)&acctbuf;
+       u.u_count = sizeof(acctbuf);
+       u.u_segflg = 1;
+       u.u_error = 0;
+       writei(ip);
+       if(u.u_error)
+               ip->i_size = siz;
+       prele(ip);
+}
+
+/*
+ * Produce a pseudo-floating point representation
+ * with 3 bits base-8 exponent, 13 bits fraction.
+ */
+compress(t)
+register time_t t;
+{
+       register exp = 0, round = 0;
+
+       while (t >= 8192) {
+               exp++;
+               round = t&04;
+               t >>= 3;
+       }
+       if (round) {
+               t++;
+               if (t >= 8192) {
+                       t >>= 3;
+                       exp++;
+               }
+       }
+       return((exp<<13) + t);
+}
+
+/*
+ * lock user into core as much
+ * as possible. swapping may still
+ * occur if core grows.
+ */
+syslock()
+{
+       register struct proc *p;
+       register struct a {
+               int     flag;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       if(suser()) {
+               p = u.u_procp;
+               p->p_flag &= ~SULOCK;
+               if(uap->flag)
+                       p->p_flag |= SULOCK;
+       }
+}
diff --git a/usr/src/slowsys/sys/alloc.c b/usr/src/slowsys/sys/alloc.c
new file mode 100644 (file)
index 0000000..e3b1818
--- /dev/null
@@ -0,0 +1,317 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/mount.h"
+#include "../h/filsys.h"
+#include "../h/fblk.h"
+#include "../h/conf.h"
+#include "../h/buf.h"
+#include "../h/inode.h"
+#include "../h/ino.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+typedef        struct fblk *FBLKP;
+
+/*
+ * alloc will obtain the next available
+ * free disk block from the free list of
+ * the specified device.
+ * The super block has up to NICFREE remembered
+ * free blocks; the last of these is read to
+ * obtain NICFREE more . . .
+ *
+ * no space on dev x/y -- when
+ * the free list is exhausted.
+ */
+struct buf *
+alloc(dev)
+dev_t dev;
+{
+       daddr_t bno;
+       register struct filsys *fp;
+       register struct buf *bp;
+
+       fp = getfs(dev);
+       while(fp->s_flock)
+               sleep((caddr_t)&fp->s_flock, PINOD);
+       do {
+               if(fp->s_nfree <= 0)
+                       goto nospace;
+               if (fp->s_nfree > NICFREE) {
+                       prdev("Bad free count", dev);
+                       goto nospace;
+               }
+               bno = fp->s_free[--fp->s_nfree];
+               if(bno == 0)
+                       goto nospace;
+       } while (badblock(fp, bno, dev));
+       if(fp->s_nfree <= 0) {
+               fp->s_flock++;
+               bp = bread(dev, bno);
+               if ((bp->b_flags&B_ERROR) == 0) {
+                       fp->s_nfree = ((FBLKP)(bp->b_un.b_addr))->df_nfree;
+                       bcopy((caddr_t)((FBLKP)(bp->b_un.b_addr))->df_free,
+                           (caddr_t)fp->s_free, sizeof(fp->s_free));
+               }
+               brelse(bp);
+               fp->s_flock = 0;
+               wakeup((caddr_t)&fp->s_flock);
+               if (fp->s_nfree <=0)
+                       goto nospace;
+       }
+       bp = getblk(dev, bno);
+       clrbuf(bp);
+       fp->s_fmod = 1;
+       return(bp);
+
+nospace:
+       fp->s_nfree = 0;
+       prdev("no space", dev);
+       u.u_error = ENOSPC;
+       return(NULL);
+}
+
+/*
+ * place the specified disk block
+ * back on the free list of the
+ * specified device.
+ */
+free(dev, bno)
+dev_t dev;
+daddr_t bno;
+{
+       register struct filsys *fp;
+       register struct buf *bp;
+
+       fp = getfs(dev);
+       fp->s_fmod = 1;
+       while(fp->s_flock)
+               sleep((caddr_t)&fp->s_flock, PINOD);
+       if (badblock(fp, bno, dev))
+               return;
+       if(fp->s_nfree <= 0) {
+               fp->s_nfree = 1;
+               fp->s_free[0] = 0;
+       }
+       if(fp->s_nfree >= NICFREE) {
+               fp->s_flock++;
+               bp = getblk(dev, bno);
+               ((FBLKP)(bp->b_un.b_addr))->df_nfree = fp->s_nfree;
+               bcopy((caddr_t)fp->s_free,
+                       (caddr_t)((FBLKP)(bp->b_un.b_addr))->df_free,
+                       sizeof(fp->s_free));
+               fp->s_nfree = 0;
+               bwrite(bp);
+               fp->s_flock = 0;
+               wakeup((caddr_t)&fp->s_flock);
+       }
+       fp->s_free[fp->s_nfree++] = bno;
+       fp->s_fmod = 1;
+}
+
+/*
+ * Check that a block number is in the
+ * range between the I list and the size
+ * of the device.
+ * This is used mainly to check that a
+ * garbage file system has not been mounted.
+ *
+ * bad block on dev x/y -- not in range
+ */
+badblock(fp, bn, dev)
+register struct filsys *fp;
+daddr_t bn;
+dev_t dev;
+{
+
+       if (bn < fp->s_isize || bn >= fp->s_fsize) {
+               prdev("bad block", dev);
+               return(1);
+       }
+       return(0);
+}
+
+/*
+ * Allocate an unused I node
+ * on the specified device.
+ * Used with file creation.
+ * The algorithm keeps up to
+ * NICINOD spare I nodes in the
+ * super block. When this runs out,
+ * a linear search through the
+ * I list is instituted to pick
+ * up NICINOD more.
+ */
+struct inode *
+ialloc(dev)
+dev_t dev;
+{
+       register struct filsys *fp;
+       register struct buf *bp;
+       register struct inode *ip;
+       int i;
+       struct dinode *dp;
+       ino_t ino;
+       daddr_t adr;
+
+       fp = getfs(dev);
+       while(fp->s_ilock)
+               sleep((caddr_t)&fp->s_ilock, PINOD);
+loop:
+       if(fp->s_ninode > 0) {
+               ino = fp->s_inode[--fp->s_ninode];
+               ip = iget(dev, ino);
+               if(ip == NULL)
+                       return(NULL);
+               if(ip->i_mode == 0) {
+                       for (i=0; i<NADDR; i++)
+                               ip->i_un.i_addr[i] = 0;
+                       fp->s_fmod = 1;
+                       return(ip);
+               }
+               /*
+                * Inode was allocated after all.
+                * Look some more.
+                */
+               iput(ip);
+               goto loop;
+       }
+       fp->s_ilock++;
+       ino = 1;
+       for(adr = SUPERB+1; adr < fp->s_isize; adr++) {
+               bp = bread(dev, adr);
+               if (bp->b_flags & B_ERROR) {
+                       brelse(bp);
+                       ino += INOPB;
+                       continue;
+               }
+               dp = bp->b_un.b_dino;
+               for(i=0; i<INOPB; i++) {
+                       if(dp->di_mode != 0)
+                               goto cont;
+                       for(ip = &inode[0]; ip < &inode[NINODE]; ip++)
+                       if(dev==ip->i_dev && ino==ip->i_number)
+                               goto cont;
+                       fp->s_inode[fp->s_ninode++] = ino;
+                       if(fp->s_ninode >= NICINOD)
+                               break;
+               cont:
+                       ino++;
+                       dp++;
+               }
+               brelse(bp);
+               if(fp->s_ninode >= NICINOD)
+                       break;
+       }
+       fp->s_ilock = 0;
+       wakeup((caddr_t)&fp->s_ilock);
+       if(fp->s_ninode > 0)
+               goto loop;
+       prdev("Out of inodes", dev);
+       u.u_error = ENOSPC;
+       return(NULL);
+}
+
+/*
+ * Free the specified I node
+ * on the specified device.
+ * The algorithm stores up
+ * to NICINOD I nodes in the super
+ * block and throws away any more.
+ */
+ifree(dev, ino)
+dev_t dev;
+ino_t ino;
+{
+       register struct filsys *fp;
+
+       fp = getfs(dev);
+       if(fp->s_ilock)
+               return;
+       if(fp->s_ninode >= NICINOD)
+               return;
+       fp->s_inode[fp->s_ninode++] = ino;
+       fp->s_fmod = 1;
+}
+
+/*
+ * getfs maps a device number into
+ * a pointer to the incore super
+ * block.
+ * The algorithm is a linear
+ * search through the mount table.
+ * A consistency check of the
+ * in core free-block and i-node
+ * counts.
+ *
+ * bad count on dev x/y -- the count
+ *     check failed. At this point, all
+ *     the counts are zeroed which will
+ *     almost certainly lead to "no space"
+ *     diagnostic
+ * panic: no fs -- the device is not mounted.
+ *     this "cannot happen"
+ */
+struct filsys *
+getfs(dev)
+dev_t dev;
+{
+       register struct mount *mp;
+       register struct filsys *fp;
+
+       for(mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
+       if(mp->m_bufp != NULL && mp->m_dev == dev) {
+               fp = mp->m_bufp->b_un.b_filsys;
+               if(fp->s_nfree > NICFREE || fp->s_ninode > NICINOD) {
+                       prdev("bad count", dev);
+                       fp->s_nfree = 0;
+                       fp->s_ninode = 0;
+               }
+               return(fp);
+       }
+       panic("no fs");
+       return(NULL);
+}
+
+/*
+ * update is the internal name of
+ * 'sync'. It goes through the disk
+ * queues to initiate sandbagged IO;
+ * goes through the I nodes to write
+ * modified nodes; and it goes through
+ * the mount table to initiate modified
+ * super blocks.
+ */
+update()
+{
+       register struct inode *ip;
+       register struct mount *mp;
+       register struct buf *bp;
+       struct filsys *fp;
+
+       if(updlock)
+               return;
+       updlock++;
+       for(mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
+               if(mp->m_bufp != NULL) {
+                       fp = mp->m_bufp->b_un.b_filsys;
+                       if(fp->s_fmod==0 || fp->s_ilock!=0 ||
+                          fp->s_flock!=0 || fp->s_ronly!=0)
+                               continue;
+                       bp = getblk(mp->m_dev, SUPERB);
+                       if (bp->b_flags & B_ERROR)
+                               continue;
+                       fp->s_fmod = 0;
+                       fp->s_time = time;
+                       bcopy((caddr_t)fp, bp->b_un.b_addr, BSIZE);
+                       bwrite(bp);
+               }
+       for(ip = &inode[0]; ip < &inode[NINODE]; ip++)
+               if((ip->i_flag&ILOCK)==0 && ip->i_count) {
+                       ip->i_flag |= ILOCK;
+                       ip->i_count++;
+                       iupdat(ip, &time, &time);
+                       iput(ip);
+               }
+       updlock = 0;
+       bflush(NODEV);
+}
diff --git a/usr/src/slowsys/sys/bio.c b/usr/src/slowsys/sys/bio.c
new file mode 100644 (file)
index 0000000..82cc3f0
--- /dev/null
@@ -0,0 +1,531 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/buf.h"
+#include "../h/conf.h"
+#include "../h/proc.h"
+#include "../h/seg.h"
+
+#define        DISKMON 1
+
+#ifdef DISKMON
+struct {
+       int     nbuf;
+       long    nread;
+       long    nreada;
+       long    ncache;
+       long    nwrite;
+       long    bufcount[NBUF];
+} io_info;
+#endif
+
+/*
+ * swap IO headers.
+ * they are filled in to point
+ * at the desired IO operation.
+ */
+struct buf     swbuf1;
+struct buf     swbuf2;
+
+/*
+ * The following several routines allocate and free
+ * buffers with various side effects.  In general the
+ * arguments to an allocate routine are a device and
+ * a block number, and the value is a pointer to
+ * to the buffer header; the buffer is marked "busy"
+ * so that no one else can touch it.  If the block was
+ * already in core, no I/O need be done; if it is
+ * already busy, the process waits until it becomes free.
+ * The following routines allocate a buffer:
+ *     getblk
+ *     bread
+ *     breada
+ * Eventually the buffer must be released, possibly with the
+ * side effect of writing it out, by using one of
+ *     bwrite
+ *     bdwrite
+ *     bawrite
+ *     brelse
+ */
+
+/*
+ * Read in (if necessary) the block and return a buffer pointer.
+ */
+struct buf *
+bread(dev, blkno)
+dev_t dev;
+daddr_t blkno;
+{
+       register struct buf *bp;
+
+       bp = getblk(dev, blkno);
+       if (bp->b_flags&B_DONE) {
+#ifdef DISKMON
+               io_info.ncache++;
+#endif
+               return(bp);
+       }
+       bp->b_flags |= B_READ;
+       bp->b_bcount = BSIZE;
+       (*bdevsw[major(dev)].d_strategy)(bp);
+#ifdef DISKMON
+       io_info.nread++;
+#endif
+       iowait(bp);
+       return(bp);
+}
+
+/*
+ * Read in the block, like bread, but also start I/O on the
+ * read-ahead block (which is not allocated to the caller)
+ */
+struct buf *
+breada(dev, blkno, rablkno)
+dev_t dev;
+daddr_t blkno, rablkno;
+{
+       register struct buf *bp, *rabp;
+
+       bp = NULL;
+       if (!incore(dev, blkno)) {
+               bp = getblk(dev, blkno);
+               if ((bp->b_flags&B_DONE) == 0) {
+                       bp->b_flags |= B_READ;
+                       bp->b_bcount = BSIZE;
+                       (*bdevsw[major(dev)].d_strategy)(bp);
+#ifdef DISKMON
+                       io_info.nread++;
+#endif
+               }
+       }
+       if (rablkno && !incore(dev, rablkno)) {
+               rabp = getblk(dev, rablkno);
+               if (rabp->b_flags & B_DONE)
+                       brelse(rabp);
+               else {
+                       rabp->b_flags |= B_READ|B_ASYNC;
+                       rabp->b_bcount = BSIZE;
+                       (*bdevsw[major(dev)].d_strategy)(rabp);
+#ifdef DISKMON
+                       io_info.nreada++;
+#endif
+               }
+       }
+       if(bp == NULL)
+               return(bread(dev, blkno));
+       iowait(bp);
+       return(bp);
+}
+
+/*
+ * Write the buffer, waiting for completion.
+ * Then release the buffer.
+ */
+bwrite(bp)
+register struct buf *bp;
+{
+       register flag;
+
+       flag = bp->b_flags;
+       bp->b_flags &= ~(B_READ | B_DONE | B_ERROR | B_DELWRI | B_AGE);
+       bp->b_bcount = BSIZE;
+#ifdef DISKMON
+       io_info.nwrite++;
+#endif
+       (*bdevsw[major(bp->b_dev)].d_strategy)(bp);
+       if ((flag&B_ASYNC) == 0) {
+               iowait(bp);
+               brelse(bp);
+       } else if (flag & B_DELWRI)
+               bp->b_flags |= B_AGE;
+       else
+               geterror(bp);
+}
+
+/*
+ * Release the buffer, marking it so that if it is grabbed
+ * for another purpose it will be written out before being
+ * given up (e.g. when writing a partial block where it is
+ * assumed that another write for the same block will soon follow).
+ * This can't be done for magtape, since writes must be done
+ * in the same order as requested.
+ */
+bdwrite(bp)
+register struct buf *bp;
+{
+       register struct buf *dp;
+
+       dp = bdevsw[major(bp->b_dev)].d_tab;
+       if(dp->b_flags & B_TAPE)
+               bawrite(bp);
+       else {
+               bp->b_flags |= B_DELWRI | B_DONE;
+               brelse(bp);
+       }
+}
+
+/*
+ * Release the buffer, start I/O on it, but don't wait for completion.
+ */
+bawrite(bp)
+register struct buf *bp;
+{
+
+       bp->b_flags |= B_ASYNC;
+       bwrite(bp);
+}
+
+/*
+ * release the buffer, with no I/O implied.
+ */
+brelse(bp)
+register struct buf *bp;
+{
+       register struct buf **backp;
+       register s;
+
+       if (bp->b_flags&B_WANTED)
+               wakeup((caddr_t)bp);
+       if (bfreelist.b_flags&B_WANTED) {
+               bfreelist.b_flags &= ~B_WANTED;
+               wakeup((caddr_t)&bfreelist);
+       }
+       if (bp->b_flags&B_ERROR)
+               bp->b_dev = NODEV;  /* no assoc. on error */
+       s = spl6();
+       if(bp->b_flags & B_AGE) {
+               backp = &bfreelist.av_forw;
+               (*backp)->av_back = bp;
+               bp->av_forw = *backp;
+               *backp = bp;
+               bp->av_back = &bfreelist;
+       } else {
+               backp = &bfreelist.av_back;
+               (*backp)->av_forw = bp;
+               bp->av_back = *backp;
+               *backp = bp;
+               bp->av_forw = &bfreelist;
+       }
+       bp->b_flags &= ~(B_WANTED|B_BUSY|B_ASYNC|B_AGE);
+       splx(s);
+}
+
+/*
+ * See if the block is associated with some buffer
+ * (mainly to avoid getting hung up on a wait in breada)
+ */
+incore(dev, blkno)
+dev_t dev;
+daddr_t blkno;
+{
+       register struct buf *bp;
+       register struct buf *dp;
+
+       dp = bdevsw[major(dev)].d_tab;
+       for (bp=dp->b_forw; bp != dp; bp = bp->b_forw)
+               if (bp->b_blkno==blkno && bp->b_dev==dev)
+                       return(1);
+       return(0);
+}
+
+/*
+ * Assign a buffer for the given block.  If the appropriate
+ * block is already associated, return it; otherwise search
+ * for the oldest non-busy buffer and reassign it.
+ */
+struct buf *
+getblk(dev, blkno)
+dev_t dev;
+daddr_t blkno;
+{
+       register struct buf *bp;
+       register struct buf *dp;
+#ifdef DISKMON
+       register i;
+#endif
+
+       if(major(dev) >= nblkdev)
+               panic("blkdev");
+
+    loop:
+       spl0();
+       dp = bdevsw[major(dev)].d_tab;
+       if(dp == NULL)
+               panic("devtab");
+       for (bp=dp->b_forw; bp != dp; bp = bp->b_forw) {
+               if (bp->b_blkno!=blkno || bp->b_dev!=dev)
+                       continue;
+               spl6();
+               if (bp->b_flags&B_BUSY) {
+                       bp->b_flags |= B_WANTED;
+                       sleep((caddr_t)bp, PRIBIO+1);
+                       goto loop;
+               }
+               spl0();
+#ifdef DISKMON
+               i = 0;
+               dp = bp->av_forw;
+               while (dp != &bfreelist) {
+                       i++;
+                       dp = dp->av_forw;
+               }
+               if (i<NBUF)
+                       io_info.bufcount[i]++;
+#endif
+               notavail(bp);
+               return(bp);
+       }
+       spl6();
+       if (bfreelist.av_forw == &bfreelist) {
+               bfreelist.b_flags |= B_WANTED;
+               sleep((caddr_t)&bfreelist, PRIBIO+1);
+               goto loop;
+       }
+       spl0();
+       notavail(bp = bfreelist.av_forw);
+       if (bp->b_flags & B_DELWRI) {
+               bp->b_flags |= B_ASYNC;
+               bwrite(bp);
+               goto loop;
+       }
+       bp->b_flags = B_BUSY;
+       bp->b_back->b_forw = bp->b_forw;
+       bp->b_forw->b_back = bp->b_back;
+       bp->b_forw = dp->b_forw;
+       bp->b_back = dp;
+       dp->b_forw->b_back = bp;
+       dp->b_forw = bp;
+       bp->b_dev = dev;
+       bp->b_blkno = blkno;
+       return(bp);
+}
+
+/*
+ * get an empty block,
+ * not assigned to any particular device
+ */
+struct buf *
+geteblk()
+{
+       register struct buf *bp;
+       register struct buf *dp;
+
+loop:
+       spl6();
+       while (bfreelist.av_forw == &bfreelist) {
+               bfreelist.b_flags |= B_WANTED;
+               sleep((caddr_t)&bfreelist, PRIBIO+1);
+       }
+       spl0();
+       dp = &bfreelist;
+       notavail(bp = bfreelist.av_forw);
+       if (bp->b_flags & B_DELWRI) {
+               bp->b_flags |= B_ASYNC;
+               bwrite(bp);
+               goto loop;
+       }
+       bp->b_flags = B_BUSY;
+       bp->b_back->b_forw = bp->b_forw;
+       bp->b_forw->b_back = bp->b_back;
+       bp->b_forw = dp->b_forw;
+       bp->b_back = dp;
+       dp->b_forw->b_back = bp;
+       dp->b_forw = bp;
+       bp->b_dev = (dev_t)NODEV;
+       return(bp);
+}
+
+/*
+ * Wait for I/O completion on the buffer; return errors
+ * to the user.
+ */
+iowait(bp)
+register struct buf *bp;
+{
+
+       spl6();
+       while ((bp->b_flags&B_DONE)==0)
+               sleep((caddr_t)bp, PRIBIO);
+       spl0();
+       geterror(bp);
+}
+
+/*
+ * Unlink a buffer from the available list and mark it busy.
+ * (internal interface)
+ */
+notavail(bp)
+register struct buf *bp;
+{
+       register s;
+
+       s = spl6();
+       bp->av_back->av_forw = bp->av_forw;
+       bp->av_forw->av_back = bp->av_back;
+       bp->b_flags |= B_BUSY;
+       splx(s);
+}
+
+/*
+ * Mark I/O complete on a buffer, release it if I/O is asynchronous,
+ * and wake up anyone waiting for it.
+ */
+iodone(bp)
+register struct buf *bp;
+{
+
+       bp->b_flags |= B_DONE;
+       if (bp->b_flags&B_ASYNC)
+               brelse(bp);
+       else {
+               bp->b_flags &= ~B_WANTED;
+               wakeup((caddr_t)bp);
+       }
+}
+
+/*
+ * Zero the core associated with a buffer.
+ */
+clrbuf(bp)
+struct buf *bp;
+{
+       register *p;
+       register c;
+
+       p = bp->b_un.b_words;
+       c = BSIZE/sizeof(int);
+       do
+               *p++ = 0;
+       while (--c);
+       bp->b_resid = 0;
+}
+
+/*
+ * swap I/O
+ */
+swap(blkno, coreaddr, count, rdflg)
+{
+       register struct buf *bp;
+       register int c;
+
+       bp = &swbuf1;
+       if(bp->b_flags & B_BUSY)
+               if((swbuf2.b_flags&B_WANTED) == 0)
+                       bp = &swbuf2;
+       spl6();
+       while (bp->b_flags&B_BUSY) {
+               bp->b_flags |= B_WANTED;
+               sleep((caddr_t)bp, PSWP+1);
+       }
+       while (count > 0){
+               bp->b_flags = B_BUSY | B_PHYS | rdflg;
+               bp->b_dev = swapdev;
+               bp->b_bcount = ctob((c=count>120?120:count));
+               bp->b_blkno = swplo+blkno;
+               bp->b_un.b_addr = (caddr_t)ctob(coreaddr);
+               (*bdevsw[major(swapdev)].d_strategy)(bp);
+               spl6();
+               while((bp->b_flags&B_DONE)==0)
+                       sleep((caddr_t)bp, PSWP);
+               if (bp->b_flags&B_WANTED)
+                       wakeup((caddr_t)bp);
+               spl0();
+               bp->b_flags &= ~(B_BUSY|B_WANTED);
+               if (bp->b_flags & B_ERROR)
+                       panic("IO err in swap");
+               count -= c;
+               blkno += c;
+               coreaddr += c;
+       }
+       bp->b_flags &= ~(B_BUSY|B_WANTED|B_PHYS);
+}
+
+/*
+ * make sure all write-behind blocks
+ * on dev (or NODEV for all)
+ * are flushed out.
+ * (from umount and update)
+ */
+bflush(dev)
+dev_t dev;
+{
+       register struct buf *bp;
+
+loop:
+       spl6();
+       for (bp = bfreelist.av_forw; bp != &bfreelist; bp = bp->av_forw) {
+               if (bp->b_flags&B_DELWRI && (dev == NODEV||dev==bp->b_dev)) {
+                       bp->b_flags |= B_ASYNC;
+                       notavail(bp);
+                       bwrite(bp);
+                       goto loop;
+               }
+       }
+       spl0();
+}
+
+/*
+ * Raw I/O. The arguments are
+ *     The strategy routine for the device
+ *     A buffer, which will always be a special buffer
+ *       header owned exclusively by the device for this purpose
+ *     The device number
+ *     Read/write flag
+ * Essentially all the work is computing physical addresses and
+ * validating them.
+ */
+physio(strat, bp, dev, rw)
+register struct buf *bp;
+int (*strat)();
+{
+       register caddr_t base;
+       register int c;
+
+       if ((base = checkio(rw)) == NULL)
+               return;
+       spl6();
+       while (bp->b_flags&B_BUSY) {
+               bp->b_flags |= B_WANTED;
+               sleep((caddr_t)bp, PRIBIO+1);
+       }
+       bp->b_error = 0;
+       while (u.u_count > 0 && bp->b_error==0) {
+               bp->b_flags = B_BUSY | B_PHYS | rw;
+               bp->b_dev = dev;
+               bp->b_un.b_addr = base;
+               bp->b_blkno = u.u_offset >> BSHIFT;
+               bp->b_bcount = c = u.u_count>60*1024 ? 60*1024 : u.u_count;
+               u.u_procp->p_flag |= SLOCK;
+               (*strat)(bp);
+               spl6();
+               while ((bp->b_flags&B_DONE) == 0)
+                       sleep((caddr_t)bp, PRIBIO);
+               u.u_procp->p_flag &= ~SLOCK;
+               if (bp->b_flags&B_WANTED)
+                       wakeup((caddr_t)bp);
+               spl0();
+               base += c;
+               u.u_count -= c;
+               u.u_offset += c;
+       }
+       bp->b_flags &= ~(B_BUSY|B_WANTED|B_PHYS);
+       u.u_count = bp->b_resid;
+       geterror(bp);
+       return;
+}
+
+/*
+ * Pick up the device's error number and pass it to the user;
+ * if there is an error but the number is 0 set a generalized
+ * code.  Actually the latter is always true because devices
+ * don't yet return specific errors.
+ */
+geterror(bp)
+register struct buf *bp;
+{
+
+       if (bp->b_flags&B_ERROR)
+               if ((u.u_error = bp->b_error)==0)
+                       u.u_error = EIO;
+}
diff --git a/usr/src/slowsys/sys/clock.c b/usr/src/slowsys/sys/clock.c
new file mode 100644 (file)
index 0000000..926ea84
--- /dev/null
@@ -0,0 +1,187 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/callo.h"
+#include "../h/seg.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/proc.h"
+#include "../h/reg.h"
+#include "../h/psl.h"
+
+#define        SCHMAG  8/10
+
+/*
+ * clock is called straight from
+ * the real time clock interrupt.
+ *
+ * Functions:
+ *     copy *switches to display
+ *     implement callouts
+ *     maintain user/system times
+ *     maintain date
+ *     profile
+ *     lightning bolt wakeup (every second)
+ *     alarm clock signals
+ *     jab the scheduler
+ */
+
+clock(pc, ps)
+caddr_t pc;
+{
+       register struct callo *p1, *p2;
+       register struct proc *pp;
+       int a;
+       extern caddr_t waitloc, ewaitloc;
+
+       /*
+        * reprime clock
+        */
+       clkreld();
+
+       /*
+        * keep the microsecond clock
+       */
+       add64(CLKTICK,&time64[0],&time64[1]);
+       /*
+        * display register
+        */
+       display();
+
+
+
+       /*
+        * callouts
+        * if none, just continue
+        * else update first non-zero time
+        */
+
+       if(callout[0].c_func == NULL)
+               goto out;
+       p2 = &callout[0];
+       while(p2->c_time<=0 && p2->c_func!=NULL)
+               p2++;
+       p2->c_time--;
+
+       /*
+        * if ps is high, just return
+        */
+       if (BASEPRI(ps))
+               goto out;
+
+       /*
+        * callout
+        */
+
+       if(callout[0].c_time <= 0) {
+               p1 = &callout[0];
+               while(p1->c_func != 0 && p1->c_time <= 0) {
+                       (*p1->c_func)(p1->c_arg);
+                       p1++;
+               }
+               p2 = &callout[0];
+               while(p2->c_func = p1->c_func) {
+                       p2->c_time = p1->c_time;
+                       p2->c_arg = p1->c_arg;
+                       p1++;
+                       p2++;
+               }
+       }
+
+       /*
+        * lightning bolt time-out
+        * and time of day
+        */
+out:
+       a = dk_busy&07;
+       if (USERMODE(ps)) {
+               u.u_utime++;
+               if(u.u_prof.pr_scale)
+                       addupc(pc, &u.u_prof, 1);
+               if(u.u_procp->p_nice > NZERO)
+                       a += 8;
+       } else {
+               a += 16;
+               if (pc == waitloc || pc == ewaitloc )
+                       a += 8;
+               u.u_stime++;
+       }
+       dk_time[a] += 1;
+       pp = u.u_procp;
+       if(++pp->p_cpu == 0)
+               pp->p_cpu--;
+       if(++lbolt >= HZ) {
+               if (BASEPRI(ps))
+                       return;
+               lbolt -= HZ;
+               ++time;
+               runrun++;
+               wakeup((caddr_t)&lbolt);
+               for(pp = &proc[0]; pp < &proc[NPROC]; pp++)
+               if (pp->p_stat && pp->p_stat<SZOMB) {
+                       if(pp->p_time != 127)
+                               pp->p_time++;
+                       if(pp->p_clktim)
+                               if(--pp->p_clktim == 0)
+                                       psignal(pp, SIGCLK);
+                       a = (pp->p_cpu & 0377)*SCHMAG + pp->p_nice - NZERO;
+                       if(a < 0)
+                               a = 0;
+                       if(a > 255)
+                               a = 255;
+                       pp->p_cpu = a;
+                       if(pp->p_pri >= PUSER)
+                               setpri(pp);
+               }
+               if(runin!=0) {
+                       runin = 0;
+                       wakeup((caddr_t)&runin);
+               }
+       }
+}
+
+/*
+ * timeout is called to arrange that
+ * fun(arg) is called in tim/HZ seconds.
+ * An entry is sorted into the callout
+ * structure. The time in each structure
+ * entry is the number of HZ's more
+ * than the previous entry.
+ * In this way, decrementing the
+ * first entry has the effect of
+ * updating all entries.
+ *
+ * The panic is there because there is nothing
+ * intelligent to be done if an entry won't fit.
+ */
+timeout(fun, arg, tim)
+int (*fun)();
+caddr_t arg;
+{
+       register struct callo *p1, *p2;
+       register int t;
+       int s;
+
+       t = tim;
+       p1 = &callout[0];
+       s = spl7();
+       while(p1->c_func != 0 && p1->c_time <= t) {
+               t -= p1->c_time;
+               p1++;
+       }
+       if (p1 >= &callout[NCALL-1])
+               panic("Timeout table overflow");
+       p1->c_time -= t;
+       p2 = p1;
+       while(p2->c_func != 0)
+               p2++;
+       while(p2 >= p1) {
+               (p2+1)->c_time = p2->c_time;
+               (p2+1)->c_func = p2->c_func;
+               (p2+1)->c_arg = p2->c_arg;
+               p2--;
+       }
+       p1->c_time = t;
+       p1->c_func = fun;
+       p1->c_arg = arg;
+       splx(s);
+}
diff --git a/usr/src/slowsys/sys/conf.c b/usr/src/slowsys/sys/conf.c
new file mode 100644 (file)
index 0000000..b5aaaa4
--- /dev/null
@@ -0,0 +1,96 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/buf.h"
+#include "../h/tty.h"
+#include "../h/conf.h"
+#include "../h/proc.h"
+#include "../h/text.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/file.h"
+#include "../h/inode.h"
+#include "../h/acct.h"
+#include "../h/mba.h"
+
+int    nulldev();
+int    nodev();
+int    random();
+
+int    hpstrategy(),hpread(),hpwrite(),hpintr();
+struct buf     hptab;
+int    htopen(),htclose(),htstrategy(),htread(),htwrite();
+struct buf     httab;
+
+struct bdevsw  bdevsw[] =
+{
+/* 0 */        nulldev,        nulldev,        hpstrategy,     &hptab,
+/* 1 */        htopen,         htclose,        htstrategy,     &httab,
+       0,
+};
+
+int    consopen(),consclose(),consread(),conswrite(),consioctl();
+int    dzopen(),dzclose(),dzread(),dzwrite(),dzioctl();
+struct tty     dz_tty[];
+int    syopen(),syread(),sywrite(),sysioctl();
+int    mmread(),mmwrite();
+struct cdevsw  cdevsw[] =
+{
+/* 0 */ consopen, consclose, consread, conswrite, consioctl, 0,
+/* 1 */ dzopen, dzclose, dzread, dzwrite, dzioctl, dz_tty,
+/* 2 */ syopen,                nulldev,        syread, sywrite,        sysioctl, 0,
+/* 3 */        nulldev,        nulldev,        mmread, mmwrite,        nodev, 0,
+/* 4 */        nulldev,        nulldev,        hpread, hpwrite,        nodev, 0,
+/* 5 */ htopen,                htclose,        htread, htwrite,        nodev, 0,
+       0,
+};
+
+int ttyopen(),ttyclose(),ttread(),ttwrite();
+int ttyinput(),ttstart() ;
+struct linesw linesw[] =
+{
+/* 0 */ ttyopen, nulldev, ttread, ttwrite, nodev, ttyinput,
+       ttstart,
+       0
+};
+int nldisp = 1;
+dev_t  rootdev = makedev(0, 0);
+dev_t  swapdev = makedev(0, 0);
+dev_t  pipedev = makedev(0, 0);
+daddr_t swplo = 4600;
+int nswap = 5000;
+struct buf     buf[NBUF];
+struct file    file[NFILE];
+struct inode   inode[NINODE];
+struct text    text[NTEXT];
+struct proc    proc[NPROC];
+struct buf     bfreelist;
+struct acct    acctbuf;
+struct inode   *acctp;
+int *usrstack = (int *)USRSTACK;
+/*tbl*/ int mem_no = 3;        /* major device number of memory special file */
+
+
+extern int Sysmap[];
+int *mmap = {Sysmap + 256 + 16 + 2};
+extern struct user u;
+int *vmmap  = (int *)((char *)&u + 16*512 + 2*512);
+
+int mbanum[] = {       /* mba number of major device */
+       0,              /* disk */
+       1,              /* tape */
+       9999999,        /* unused */
+       9999999,        /* unused */
+       0,              /* disk, raw */
+       1,              /* tape, raw */
+       };
+
+int *mbaloc[] = { /* virtual location of mba */
+       (int *)MBA0,
+       (int *)MBA1,
+       };
diff --git a/usr/src/slowsys/sys/cons.c b/usr/src/slowsys/sys/cons.c
new file mode 100644 (file)
index 0000000..bb3075a
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ *   KL/DL-11 driver
+ */
+#include "../h/param.h"
+#include "../h/conf.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/tty.h"
+#include "../h/systm.h"
+#include "../h/cons.h"
+#include "../h/mtpr.h"
+
+#define        NL1     000400
+#define        NL2     001000
+#define        CR2     020000
+#define        FF1     040000
+#define        TAB1    002000
+
+struct tty cons;
+int    consstart();
+int    ttrstrt();
+char   partab[];
+
+consopen(dev, flag)
+dev_t dev;
+{
+       register struct device *addr;
+       register struct tty *tp;
+       register d;
+
+       tp = &cons;
+       tp->t_oproc = consstart;
+       tp->t_iproc = NULL;
+       if ((tp->t_state&ISOPEN) == 0) {
+               tp->t_state = ISOPEN|CARR_ON;
+               tp->t_flags = EVENP|ECHO|XTABS|CRMOD;
+               tp->t_erase = CERASE;
+               tp->t_kill = CKILL;
+       }
+       mtpr(RXCS, mfpr(RXCS)|RXCS_IE);
+       mtpr(TXCS, mfpr(TXCS)|TXCS_IE);
+       ttyopen(dev, tp);
+}
+
+consclose(dev)
+dev_t dev;
+{
+       register struct tty *tp;
+
+       tp = &cons;
+       wflushtty(tp);
+       tp->t_state = 0;
+}
+
+consread(dev)
+dev_t dev;
+{
+       ttread(&cons);
+}
+
+conswrite(dev)
+dev_t dev;
+{
+       ttwrite(&cons);
+}
+
+consxint(dev)
+dev_t dev;
+{
+       register struct tty *tp;
+
+       tp = &cons;
+       ttstart(tp);
+       if (tp->t_outq.c_cc == 0 || tp->t_outq.c_cc == TTLOWAT)
+               wakeup((caddr_t)&tp->t_outq);
+}
+
+consrint(dev)
+dev_t dev;
+{
+       register int c;
+       register struct device *addr;
+       register struct tty *tp;
+
+       c = mfpr(RXDB);
+       ttyinput(c, &cons);
+}
+
+consioctl(dev,cmd,addr,flag)
+dev_t dev;
+caddr_t addr;
+{
+       register struct tty *tp;
+       tp = &cons;
+       if (ttioccom(cmd,tp,addr,dev) ==0)
+               u.u_error = ENOTTY;
+}
+
+consstart(tp)
+register struct tty *tp;
+{
+       register c;
+       register struct device *addr;
+
+       if( (mfpr(TXCS)&TXCS_RDY) == 0)
+               return;
+       if ((c=getc(&tp->t_outq)) >= 0) {
+               if (tp->t_flags&RAW)
+                       mtpr(TXDB, c&0xff);
+               else if (c<=0177)
+                       mtpr(TXDB, (c | (partab[c]&0200))&0xff);
+               else {
+                       timeout(ttrstrt, (caddr_t)tp, (c&0177));
+                       tp->t_state |= TIMEOUT;
+               }
+       }
+}
+
+char   *msgbufp = msgbuf;      /* Next saved printf character */
+/*
+ * Print a character on console.
+ * Attempts to save and restore device
+ * status.
+ * If the switches are 0, all
+ * printing is inhibited.
+ *
+ * Whether or not printing is inhibited,
+ * the last MSGBUFS characters
+ * are saved in msgbuf for inspection later.
+ */
+putchar(c)
+register c;
+{
+       register s, timo;
+
+       if (c != '\0' && c != '\r' && c != 0177) {
+               *msgbufp++ = c;
+               if(msgbufp >= &msgbuf[MSGBUFS])
+                       msgbufp = msgbuf;
+       }
+       timo = 30000;
+       /*
+        * Try waiting for the console tty to come ready,
+        * otherwise give up after a reasonable time.
+        */
+       while((mfpr(TXCS)&TXCS_RDY) == 0)
+               if(--timo == 0)
+                       break;
+       if(c == 0)
+               return;
+       s = mfpr(TXCS);
+       mtpr(TXCS,0);
+       mtpr(TXDB, c&0xff);
+       if(c == '\n') {
+               putchar('\r');
+       }
+       putchar(0);
+       mtpr(TXCS, s);
+}
diff --git a/usr/src/slowsys/sys/dkleave.c b/usr/src/slowsys/sys/dkleave.c
new file mode 100644 (file)
index 0000000..7cd7a7d
--- /dev/null
@@ -0,0 +1,29 @@
+#include "../h/param.h"
+#include "../h/buf.h"
+
+daddr_t
+dkblock(bp)
+register struct buf *bp;
+{
+       register int dminor;
+
+       if (((dminor=minor(bp->b_dev))&0100) == 0)
+               return(bp->b_blkno);
+       dminor >>= 3;
+       dminor &= 07;
+       dminor++;
+       return(bp->b_blkno/dminor);
+}
+
+dkunit(bp)
+register struct buf *bp;
+{
+       register int dminor;
+
+       dminor = minor(bp->b_dev) >> 3;
+       if ((dminor&010) == 0)
+               return(dminor);
+       dminor &= 07;
+       dminor++;
+       return(bp->b_blkno%dminor);
+}
diff --git a/usr/src/slowsys/sys/dsort.c b/usr/src/slowsys/sys/dsort.c
new file mode 100644 (file)
index 0000000..5a90c1e
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * generalized seek sort for disk
+ */
+
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/buf.h"
+
+#define        b_cylin b_resid
+
+disksort(dp, bp)
+register struct buf *dp, *bp;
+{
+       register struct buf *ap;
+       struct buf *tp;
+
+       ap = dp->b_actf;
+       if(ap == NULL) {
+               dp->b_actf = bp;
+               dp->b_actl = bp;
+               bp->av_forw = NULL;
+               return;
+       }
+       tp = NULL;
+       for(; ap != NULL; ap = ap->av_forw) {
+               if ((bp->b_flags&B_READ) && (ap->b_flags&B_READ) == 0) {
+                       if (tp == NULL)
+                               tp = ap;
+                       break;
+               }
+               if ((bp->b_flags&B_READ) == 0 && (ap->b_flags&B_READ))
+                       continue;
+               if(ap->b_cylin <= bp->b_cylin)
+                       if(tp == NULL || ap->b_cylin >= tp->b_cylin)
+                               tp = ap;
+       }
+       if(tp == NULL)
+               tp = dp->b_actl;
+       bp->av_forw = tp->av_forw;
+       tp->av_forw = bp;
+       if(tp == dp->b_actl)
+               dp->b_actl = bp;
+}
diff --git a/usr/src/slowsys/sys/dz.c b/usr/src/slowsys/sys/dz.c
new file mode 100644 (file)
index 0000000..9fd7462
--- /dev/null
@@ -0,0 +1,319 @@
+/*
+*  DZ-11 Driver
+*/
+# include "../h/param.h"
+# include "../h/tty.h"
+# include "../h/uba.h"
+# include "../h/proc.h"
+# include "../h/dir.h"
+# include "../h/file.h"
+# include "../h/inode.h"
+# include "../h/user.h"
+# include "../h/conf.h"
+# define DZADDR  (UBA0_DEV + 0160100)
+# define NDZ (1*8)
+# define  BITS7  020
+# define  BITS8  030
+# define  TWOSB  040
+# define  PENABLE  0100
+# define  OPAR  0200
+# define  MSE  040  /* Master Scan Enable */
+# define  RIE  0100  /* Receiver Interrupt Enable */
+# define  TIE  040000  /*  Transmit interrupt enable */
+# define  DZ_IEN  (MSE+RIE+TIE)
+# define  PERROR  010000
+# define  FRERROR  020000
+# define SSPEED  7  /* std speed = 300 baud */
+
+# define dzlpr  dzrbuf
+# define dzmsr  dzbrk
+# define  ON  1
+# define  OFF  0
+struct tty dz_tty[NDZ] ;
+int dz_cnt = { NDZ }  ;
+struct dzregs {
+       short dzcsr ;
+       short dzrbuf ;
+       char  dztcr ;
+       char  dzdtr ;
+       char  dztbuf ;
+       char  dzbrk ;
+       } ;
+struct dzregs *dz_addr[] = {
+       (struct dzregs *)(DZADDR),
+       (struct dzregs *)(DZADDR+010),
+       (struct dzregs *)(DZADDR+020),
+       (struct dzregs *)(DZADDR+030)
+       } ;
+char dz_timer ;
+char dz_speeds[] = {
+       0, 020 , 021 , 022 , 023 , 024 , 0, 025,
+       026 , 027 , 030 , 032 , 034 , 036 , 0 , 0,
+       } ;
+dzopen(d,flag)
+{
+       register struct tty *tp ;
+       register dev ;
+       extern dzstart() , dzscan() ;
+       dev = minor(d);
+       if (dev >= dz_cnt) {
+               u.u_error = ENXIO ;
+               return ;
+               }
+       if (dz_timer == 0) {
+               dz_timer++ ;
+               timeout(dzscan,0,60) ;
+               }
+       tp = &dz_tty[dev] ;
+       tp->t_addr = ((struct dzregs *)DZADDR) + (dev>>3);
+       tp->t_oproc = dzstart ;
+       tp->t_iproc = NULL;
+       tp->t_state |= WOPEN ;
+       if ((tp->t_state & ISOPEN) == 0) {
+               tp->t_erase = CERASE ;
+               tp->t_kill = CKILL ;
+               tp->t_ospeed = tp->t_ispeed = SSPEED ;
+               tp->t_flags = ODDP|EVENP|ECHO|HUPCLS ;
+               dzparam(dev) ;
+               }
+       else
+               if (tp->t_state&XCLUDE && u.u_uid != 0) {
+                       u.u_error = EBUSY ;
+                       return ;
+                       }
+       dzmodem(dev,ON) ;
+       spl5() ;
+       while ((tp->t_state & CARR_ON) == 0) {
+               tp->t_state |= WOPEN ;
+               sleep(&tp->t_rawq,TTIPRI) ;
+               }
+       spl0() ;
+       (*linesw[tp->t_line].l_open)(d,tp);
+}
+/*             */
+dzclose(d)
+{
+       register struct tty *tp ;
+       register dev ;
+       dev = minor(d);
+       tp = &dz_tty[dev] ;
+       (*linesw[tp->t_line].l_close)(tp);
+       if (tp->t_flags & HUPCLS)
+               dzmodem(dev,OFF) ;
+       ttyclose(tp);
+}
+/*             */
+dzread(d)
+{
+       register struct tty *tp;
+       tp = &dz_tty[minor(d)];
+       (*linesw[tp->t_line].l_read)(tp);
+}
+/*             */
+dzwrite(d)
+{
+       register struct tty *tp;
+       tp = &dz_tty[minor(d)];
+       (*linesw[tp->t_line].l_write)(tp);
+}
+/*             */
+dzrint(dev)
+{
+       register struct tty *tp ;
+       register int c ;
+       register struct dzregs *dzaddr ;
+       dzaddr = dz_addr[dev] ;
+       while ((c = dzaddr->dzrbuf) < 0) { /* char present */
+               tp = &dz_tty[((c>>8)&07)|(dev<<3)] ;
+               if (tp >= &dz_tty[dz_cnt]) continue ;
+               if ((tp->t_state & ISOPEN) == 0) {
+                       wakeup(&tp->t_rawq) ;
+                       continue ;
+                       }
+               if (c & FRERROR) /* framing error = break */
+                       if (tp->t_flags & RAW) c = 0 ; /* null for getty */
+                       else c = 0177 ; /* DEL = interrupt */
+               if (c & PERROR) /* parity error */
+                       if (((tp->t_flags & (EVENP|ODDP)) == EVENP)
+                         || ((tp->t_flags & (EVENP|ODDP)) == ODDP))
+                               continue ;
+               (*linesw[tp->t_line].l_rint)(c,tp);
+               }
+}
+/*             */
+dzioctl(dev,cmd,addr,flag)
+caddr_t addr;
+dev_t dev;
+{
+       register struct tty *tp;
+       tp = &dz_tty[minor(dev)];
+       if (ttioccomm(cmd,tp,addr,dev)) {
+               if (cmd==TIOCSETP || cmd==TIOCSETN)
+                       dzparam(minor(dev));
+       } else
+               u.u_error = ENOTTY;
+}
+/*             */
+dzparam(dev)
+{
+       register struct tty *tp ;
+       register struct dzregs *dzaddr ;
+       register short lpr ;
+       tp = &dz_tty[dev] ;
+       dzaddr = dz_addr[dev>>3] ;
+       dzaddr->dzcsr = DZ_IEN ;
+       if (tp->t_ispeed == 0) { /* hang up line */
+               dzmodem(dev,OFF) ;
+               return ;
+               }
+       lpr = (dz_speeds[tp->t_ispeed]<<8) | (dev & 07) ;
+       if (tp->t_flags & RAW) lpr |= BITS8 ;
+       else lpr |= (BITS7|PENABLE) ;
+       if ((tp->t_flags & EVENP) == 0) lpr |= OPAR ;
+       if (tp->t_ispeed == 3)  /*  110 baud */
+               lpr |= TWOSB ; /* 2 stop bits */
+       dzaddr->dzlpr = lpr ;
+}
+/*             */
+dzxint(dev)
+dev_t dev;
+{
+       register struct tty *tp ;
+       register struct dzregs *dzaddr ;
+       register unit ;
+       dzaddr = dz_addr[dev] ;
+       while (dzaddr->dzcsr < 0) { /* Transmit Ready is on */
+               unit = (dzaddr->dzcsr >> 8) & 07 ;
+               tp = &dz_tty[(dev<<3) | unit] ;
+               /* the following is an attempt to fix what appears
+                  to be a DZ hardware bug which causes the system
+                  to loop here.  Transmitting the NUL should not
+                  cause too many problems.... */
+               if ((dzaddr->dztcr & (1<<unit)) == 0 ) {
+                       printf("dzxint,line=%d\n", unit);
+                       dzaddr->dztbuf = 0;
+                       continue;
+               }
+               if (tp->t_state & BUSY) {
+                       dzaddr->dztbuf = tp->t_char ; /* output the char */
+                       tp->t_state &= ~BUSY ;
+                       if (tp->t_line)
+                               (*linesw[tp->t_line].l_start)(tp);
+                       else
+                               dzstart(tp);
+                       continue ;
+                       }
+               unit = (1<<unit) ;
+               dzaddr->dztcr &= (~unit) ; /* Transmit enable off */
+               }
+}
+/*             */
+dzstart(tp)
+register struct tty *tp ;
+{
+       register unit , c ;
+       register struct dzregs *dzaddr ;
+       extern ttrstrt() ;
+       int sps ;
+       unit = tp - dz_tty ;
+       dzaddr = dz_addr[unit>>3] ;
+       unit = 1<<(unit&07) ;
+       sps = spl5() ;
+       if (tp->t_state & (TIMEOUT|BUSY|TTSTOP)) {
+               splx(sps) ;
+               return ;
+               }
+       if ((c = getc(&tp->t_outq)) >= 0) {
+               if (c >= 0200 && (tp->t_flags&RAW) == 0) {
+                       dzaddr->dztcr &= ~unit ;
+                       tp->t_state |= TIMEOUT ;
+                       timeout(ttrstrt,tp,(c&0177)+6) ;
+                       }
+               else {
+                       tp->t_char = c ;
+                       tp->t_state |= BUSY ;
+                       dzaddr->dztcr |= unit ;
+                       }
+               if (tp->t_outq.c_cc <= TTLOWAT && tp->t_state&ASLEEP) {
+                       tp->t_state &= ~ASLEEP ;
+                       wakeup(&tp->t_outq) ;
+                       }
+               }
+               splx(sps) ;
+}
+/*             */
+dzmodem(dev,flag)
+register int dev;
+{
+       register struct dzregs *dzaddr ;
+       register char bit ;
+       dzaddr = dz_addr[dev>>3] ;
+       bit = 1<<(dev&07) ;
+       if (flag == OFF) dzaddr->dzdtr &= ~bit ;
+       else dzaddr->dzdtr |= bit ;
+}
+/*             */
+dzscan()
+{
+       register i ;
+       register struct dzregs *dzaddr ;
+       register bit ;
+       register struct tty *tp ;
+       extern dzscan() ;
+       for (i = 0 ; i < dz_cnt ; i++) {
+               dzaddr = dz_addr[i>>3] ;
+               tp = &dz_tty[i] ;
+               bit = 1<<(i&07) ;
+               if (dzaddr->dzmsr & bit) { /* carrier present */
+                       if ((tp->t_state & CARR_ON) == 0) {
+                               wakeup(&tp->t_rawq) ;
+                               tp->t_state |= CARR_ON ;
+                               }
+                       }
+               else {
+                       if ((tp->t_state & CARR_ON)) { /* carrier lost */
+                               signal(tp->t_pgrp,SIGHUP) ;
+                               dzaddr->dzdtr &= ~bit ;
+                               flushtty(tp) ;
+                               }
+                       tp->t_state &= ~CARR_ON ;
+                       }
+               }
+               timeout(dzscan,0,2*60) ;
+}
diff --git a/usr/src/slowsys/sys/fio.c b/usr/src/slowsys/sys/fio.c
new file mode 100644 (file)
index 0000000..3d0bd7c
--- /dev/null
@@ -0,0 +1,260 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/filsys.h"
+#include "../h/file.h"
+#include "../h/conf.h"
+#include "../h/inode.h"
+#include "../h/reg.h"
+#include "../h/acct.h"
+
+/*
+ * Convert a user supplied
+ * file descriptor into a pointer
+ * to a file structure.
+ * Only task is to check range
+ * of the descriptor.
+ */
+struct file *
+getf(f)
+register int f;
+{
+       register struct file *fp;
+
+       if(0 <= f && f < NOFILE) {
+               fp = u.u_ofile[f];
+               if(fp != NULL)
+                       return(fp);
+       }
+       u.u_error = EBADF;
+       return(NULL);
+}
+
+/*
+ * Internal form of close.
+ * Decrement reference count on
+ * file structure.
+ * Also make sure the pipe protocol
+ * does not constipate.
+ *
+ * Decrement reference count on the inode following
+ * removal to the referencing file structure.
+ * On the last close switch out to the device handler for
+ * special files.  Note that the handler is called
+ * on every open but only the last close.
+ */
+closef(fp)
+register struct file *fp;
+{
+       register struct inode *ip;
+       int flag;
+       dev_t dev;
+       register int (*cfunc)();
+
+       if(fp == NULL)
+               return;
+       if (fp->f_count > 1) {
+               fp->f_count--;
+               return;
+       }
+       ip = fp->f_inode;
+       plock(ip);
+       flag = fp->f_flag&FWRITE;
+       fp->f_count = 0;
+       if(fp->f_flag & FPIPE) {
+               ip->i_mode &= ~(IREAD|IWRITE);
+               wakeup((caddr_t)ip+1);
+               wakeup((caddr_t)ip+2);
+       }
+       iput(ip);
+       dev = (dev_t)ip->i_un.i_rdev;
+       switch(ip->i_mode&IFMT) {
+
+       case IFCHR:
+       case IFMPC:
+               cfunc = cdevsw[major(dev)].d_close;
+               break;
+
+       case IFBLK:
+       case IFMPB:
+               cfunc = bdevsw[major(dev)].d_close;
+               break;
+
+       default:
+               return;
+       }
+       if (fp->f_flag&FMP) {
+               (*cfunc)(dev, fp->f_un.f_chan);
+       } else {
+               for (fp=file; fp < &file[NFILE]; fp++)
+                       if (fp->f_count && fp->f_inode==ip)
+                               return;
+               (*cfunc)(dev, flag);
+       }
+}
+
+/*
+ * openi called to allow handler
+ * of special files to initialize and
+ * validate before actual IO.
+ */
+openi(ip, rw)
+register struct inode *ip;
+{
+       dev_t dev;
+       register unsigned int maj;
+
+       dev = (dev_t)ip->i_un.i_rdev;
+       maj = major(dev);
+       switch(ip->i_mode&IFMT) {
+
+       case IFCHR:
+       case IFMPC:
+               if(maj >= nchrdev)
+                       goto bad;
+               (*cdevsw[maj].d_open)(dev, rw);
+               break;
+
+       case IFBLK:
+       case IFMPB:
+               if(maj >= nblkdev)
+                       goto bad;
+               (*bdevsw[maj].d_open)(dev, rw);
+       }
+       return;
+
+bad:
+       u.u_error = ENXIO;
+}
+
+/*
+ * Check mode permission on inode pointer.
+ * Mode is READ, WRITE or EXEC.
+ * In the case of WRITE, the
+ * read-only status of the file
+ * system is checked.
+ * Also in WRITE, prototype text
+ * segments cannot be written.
+ * The mode is shifted to select
+ * the owner/group/other fields.
+ * The super user is granted all
+ * permissions.
+ */
+access(ip, mode)
+register struct inode *ip;
+{
+       register m;
+
+       m = mode;
+       if(m == IWRITE) {
+               if(getfs(ip->i_dev)->s_ronly != 0) {
+                       u.u_error = EROFS;
+                       return(1);
+               }
+               if (ip->i_flag&ITEXT)           /* try to free text */
+                       xrele(ip);
+               if(ip->i_flag & ITEXT) {
+                       u.u_error = ETXTBSY;
+                       return(1);
+               }
+       }
+       if(u.u_uid == 0)
+               return(0);
+       if(u.u_uid != ip->i_uid) {
+               m >>= 3;
+               if(u.u_gid != ip->i_gid)
+                       m >>= 3;
+       }
+       if((ip->i_mode&m) != 0)
+               return(0);
+
+       u.u_error = EACCES;
+       return(1);
+}
+
+/*
+ * Look up a pathname and test if
+ * the resultant inode is owned by the
+ * current user.
+ * If not, try for super-user.
+ * If permission is granted,
+ * return inode pointer.
+ */
+struct inode *
+owner()
+{
+       register struct inode *ip;
+
+       ip = namei(uchar, 0);
+       if(ip == NULL)
+               return(NULL);
+       if(u.u_uid == ip->i_uid)
+               return(ip);
+       if(suser())
+               return(ip);
+       iput(ip);
+       return(NULL);
+}
+
+/*
+ * Test if the current user is the
+ * super user.
+ */
+suser()
+{
+
+       if(u.u_uid == 0) {
+               u.u_acflag |= ASU;
+               return(1);
+       }
+       u.u_error = EPERM;
+       return(0);
+}
+
+/*
+ * Allocate a user file descriptor.
+ */
+ufalloc()
+{
+       register i;
+
+       for(i=0; i<NOFILE; i++)
+               if(u.u_ofile[i] == NULL) {
+                       u.u_r.r_val1 = i;
+                       u.u_pofile[i] = 0;
+                       return(i);
+               }
+       u.u_error = EMFILE;
+       return(-1);
+}
+
+/*
+ * Allocate a user file descriptor
+ * and a file structure.
+ * Initialize the descriptor
+ * to point at the file structure.
+ *
+ * no file -- if there are no available
+ *     file structures.
+ */
+struct file *
+falloc()
+{
+       register struct file *fp;
+       register i;
+
+       i = ufalloc();
+       if(i < 0)
+               return(NULL);
+       for(fp = &file[0]; fp < &file[NFILE]; fp++)
+               if(fp->f_count == 0) {
+                       u.u_ofile[i] = fp;
+                       fp->f_count++;
+                       fp->f_un.f_offset = 0;
+                       return(fp);
+               }
+       printf("no file\n");
+       u.u_error = ENFILE;
+       return(NULL);
+}
diff --git a/usr/src/slowsys/sys/hp.c b/usr/src/slowsys/sys/hp.c
new file mode 100644 (file)
index 0000000..f8c87ff
--- /dev/null
@@ -0,0 +1,327 @@
+/*
+ * RP04/RP06 disk driver
+ */
+
+#include "../h/param.h"
+#include "../h/uba.h"
+#include "../h/systm.h"
+#include "../h/buf.h"
+#include "../h/conf.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/map.h"
+#include "../h/mba.h"
+
+#define        DK_N    0
+
+struct device
+{
+       int     hpcs1;          /* control and Status register 1 */
+       int     hpds;           /* Drive Status */
+       int     hper1;          /* Error register 1 */
+       int     hpmr;           /* Maintenance */ 
+       int     hpas;           /* Attention Summary */
+       int     hpda;           /* Desired address register */
+       int     hpdt;           /* Drive type */
+       int     hpla;           /* Look ahead */
+       int     hpsn;           /* serial number */
+       int     hpof;           /* Offset register */
+       int     hpdc;           /* Desired Cylinder address register */
+       int     hpcc;           /* Current Cylinder */
+       int     hper2;          /* Error register 2 */
+       int     hper3;          /* Error register 3 */
+       int     hpec1;          /* Burst error bit position */
+       int     hpec2;          /* Burst error bit pattern */
+};
+
+#define        HPADDR  ((struct device *)(MBA0 + MBA_ERB))
+#define        NHP     1
+#define        NSECT   22
+#define        NTRAC   19
+#define        SDIST   2
+#define        RDIST   6
+
+struct size
+{
+       daddr_t nblocks;
+       int     cyloff;
+} hp_sizes[8] =
+{
+       9614,   0,              /* cyl 0 thru 23 */
+       65536,  44,             /* cyl 44 thru 200 */
+       65536,  201,            /* cyl 201 thru 514 */
+       65536,  515,            /* cyl 515 thru 671 */
+       65536,  358,            /* cyl 358 thru 407 */
+       0,      0,
+       328548, 25,             /* cyl 25 thru 810 */
+       322278, 44,             /* cyl 44 thru 717 */
+};
+
+#define        P400    020
+#define        M400    0220
+#define        P800    040
+#define        M800    0240
+#define        P1200   060
+#define        M1200   0260
+int    hp_offset[16] =
+{
+       P400, M400, P400, M400,
+       P800, M800, P800, M800,
+       P1200, M1200, P1200, M1200,
+       0, 0, 0, 0,
+};
+
+struct buf     hptab;
+struct buf     rhpbuf;
+struct buf     hputab[NHP];
+
+#define        GO      01
+#define        PRESET  020
+#define        RTC     016
+#define        OFFSET  014
+#define        SEARCH  030
+#define        RECAL   06
+#define DCLR   010
+#define        WCOM    060
+#define        RCOM    070
+
+#define        IE      0100
+#define        PIP     020000
+#define        DRY     0200
+#define        ERR     040000
+#define        TRE     040000
+#define        DCK     0100000
+#define        WLE     04000
+#define        ECH     0100
+#define VV     0100
+#define DPR 0400
+#define MOL 010000
+#define FMT22  010000
+
+#define b_cylin b_resid
+daddr_t dkblock();
+hpstrategy(bp)
+register struct buf *bp;
+{
+       register struct buf *dp;
+       register unit;
+       long sz, bn;
+
+       unit = minor(bp->b_dev) & 077;
+       sz = bp->b_bcount;
+       sz = (sz+511) >> 9;
+       if (unit >= (NHP<<3) ||
+           bp->b_blkno < 0 ||
+           (bn = dkblock(bp))+sz > hp_sizes[unit&07].nblocks) {
+               bp->b_flags |= B_ERROR;
+               iodone(bp);
+               return;
+       }
+       bp->b_cylin = bn/(NSECT*NTRAC) + hp_sizes[unit&07].cyloff;
+       unit = dkunit(bp);
+       dp = &hputab[unit];
+       spl5();
+       disksort(dp, bp);
+       if (dp->b_active == 0) {
+               hpustart(unit);
+               if(hptab.b_active == 0)
+                       hpstart();
+       }
+       spl0();
+}
+
+hpustart(unit)
+register unit;
+{
+       register struct buf *bp, *dp;
+       register struct device *hpaddr;
+       daddr_t bn;
+       int sn, cn, csn;
+
+       ((struct mba_regs *)MBA0)->mba_cr |= MBAIE;
+       HPADDR->hpas = 1<<unit;
+
+       if(unit >= NHP)
+               return;
+       dk_busy &= ~(1<<(unit+DK_N));
+       dp = &hputab[unit];
+       if((bp=dp->b_actf) == NULL)
+               return;
+       hpaddr = (struct device *)((int *)HPADDR + 32*unit);
+       if((hpaddr->hpds & VV) == 0) {
+               hpaddr->hpcs1 = PRESET|GO;
+               hpaddr->hpof = FMT22;
+       }
+       if(dp->b_active)
+               goto done;
+       dp->b_active++;
+       if ((hpaddr->hpds & (DPR|MOL)) != (DPR|MOL))
+               goto done;
+
+       bn = dkblock(bp);
+       cn = bp->b_cylin;
+       sn = bn%(NSECT*NTRAC);
+       sn = (sn+NSECT-SDIST)%NSECT;
+
+       if((hpaddr->hpcc & 0xffff) != cn)
+               goto search;
+       csn = ((hpaddr->hpla & 0xffff)>>6) - sn + SDIST - 1;
+       if(csn < 0)
+               csn += NSECT;
+       if(csn > NSECT-RDIST)
+               goto done;
+
+search:
+       hpaddr->hpdc = cn;
+       hpaddr->hpda = sn;
+       hpaddr->hpcs1 = SEARCH|GO;
+       unit += DK_N;
+       dk_busy |= 1<<unit;
+       dk_numb[unit] += 1;
+       return;
+
+done:
+       dp->b_forw = NULL;
+       if(hptab.b_actf == NULL)
+               hptab.b_actf = dp; else
+               hptab.b_actl->b_forw = dp;
+       hptab.b_actl = dp;
+}
+
+hpstart()
+{
+       register struct buf *bp, *dp;
+       register unit;
+       register struct device *hpaddr;
+       daddr_t bn;
+       int dn, sn, tn, cn;
+
+loop:
+       if ((dp = hptab.b_actf) == NULL)
+               return;
+       if ((bp = dp->b_actf) == NULL) {
+               hptab.b_actf = dp->b_forw;
+               goto loop;
+       }
+       hptab.b_active++;
+       unit = minor(bp->b_dev) & 077;
+       dn = dkunit(bp);
+       bn = dkblock(bp);
+       cn = bn/(NSECT*NTRAC) + hp_sizes[unit&07].cyloff;
+       sn = bn%(NSECT*NTRAC);
+       tn = sn/NSECT;
+       sn = sn%NSECT;
+
+       hpaddr =  (struct device *)((int *)HPADDR + 32*dn);
+       if ((hpaddr->hpds & (DPR|MOL)) != (DPR|MOL)) {
+               hptab.b_active = 0;
+               hptab.b_errcnt = 0;
+               dp->b_actf = bp->av_forw;
+               bp->b_flags |= B_ERROR;
+               iodone(bp);
+               goto loop;
+       }
+       if(hptab.b_errcnt >= 16) {
+               hpaddr->hpof = hp_offset[hptab.b_errcnt & 017] | FMT22;
+               ((struct mba_regs *)MBA0)->mba_cr &= ~MBAIE;
+               hpaddr->hpcs1 = OFFSET|GO;
+               while(hpaddr->hpds & PIP)
+                       ;
+               ((struct mba_regs *)MBA0)->mba_cr |= MBAIE;
+       }
+       hpaddr->hpdc = cn;
+       hpaddr->hpda = (tn << 8) + sn;
+       mbastart(bp, hpaddr);
+
+       dk_busy |= 1<<(DK_N+NHP);
+       dk_numb[DK_N+NHP] += 1;
+       unit = bp->b_bcount>>6;
+       dk_wds[DK_N+NHP] += unit;
+}
+
+hpintr(mbastat, as)
+{
+       register struct buf *bp, *dp;
+       register unit;
+       register struct device *hpaddr;
+       int i, j;
+
+       if(hptab.b_active) {
+               dk_busy &= ~(1<<(DK_N+NHP));
+               dp = hptab.b_actf;
+               bp = dp->b_actf;
+               unit = dkunit(bp);
+               hpaddr = (struct device *)((int *)HPADDR + 32*unit);
+               if (hpaddr->hpds & ERR || mbastat & MBAEBITS) {         /* error bit */
+                       while((hpaddr->hpds & DRY) == 0)
+                               ;
+                       if(++hptab.b_errcnt > 28 || hpaddr->hper1&WLE)
+                               bp->b_flags |= B_ERROR; else
+                               hptab.b_active = 0;
+                       if(hptab.b_errcnt > 27)
+                               deverror(bp, mbastat, hpaddr->hper1);
+                       if((bp->b_flags&B_PHYS) == 0 &&
+                          (hpaddr->hper1 & (DCK|ECH)) == DCK) {
+                               i = (hpaddr->hpec1 & 0xffff) - 1;
+                               j = i&037;
+                               i =>> 5;
+                               if(i >= 0 && i <128) {
+                                       bp->b_un.b_words[i] =^ (hpaddr->hpec2 & 0xffff) << j;
+                                       bp->b_un.b_words[i+1] =^ (hpaddr->hpec2 & 0xffff) >> (32-j);
+                               }
+                               hptab.b_active++;
+                               printf("%D ", bp->b_blkno);
+                               prdev("ECC", bp->b_dev);
+                       }
+                       hpaddr->hpcs1 = DCLR|GO;
+                       if((hptab.b_errcnt&07) == 4) {
+                               ((struct mba_regs *)MBA0)->mba_cr &= ~MBAIE;
+                               hpaddr->hpcs1 = RECAL|GO;
+                               while(hpaddr->hpds & PIP)
+                                       ;
+                               ((struct mba_regs *)MBA0)->mba_cr |= MBAIE;
+                       }
+               }
+               if(hptab.b_active) {
+                       if(hptab.b_errcnt) {
+                               ((struct mba_regs *)MBA0)->mba_cr &= ~MBAIE;
+                               hpaddr->hpcs1 = RTC|GO;
+                               while(hpaddr->hpds & PIP)
+                                       ;
+                               ((struct mba_regs *)MBA0)->mba_cr |= MBAIE;
+                       }
+                       hptab.b_active = 0;
+                       hptab.b_errcnt = 0;
+                       hptab.b_actf = dp->b_forw;
+                       dp->b_active = 0;
+                       dp->b_errcnt = 0;
+                       dp->b_actf = bp->av_forw;
+                       bp->b_resid = -(((struct mba_regs *)MBA0)->mba_bcr) & 0xffff;
+                       iodone(bp);
+                       if(dp->b_actf)
+                               hpustart(unit);
+               }
+               as &= ~(1<<unit);
+       } else {
+               if(as == 0)
+                       ((struct mba_regs *)MBA0)->mba_cr |= MBAIE;
+       }
+       for(unit=0; unit<NHP; unit++)
+               if(as & (1<<unit))
+                       hpustart(unit);
+       hpstart();
+}
+
+hpread(dev)
+{
+
+       physio(hpstrategy, &rhpbuf, dev, B_READ);
+}
+
+hpwrite(dev)
+{
+
+       physio(hpstrategy, &rhpbuf, dev, B_WRITE);
+}
diff --git a/usr/src/slowsys/sys/ht.c b/usr/src/slowsys/sys/ht.c
new file mode 100644 (file)
index 0000000..a75f797
--- /dev/null
@@ -0,0 +1,347 @@
+/*
+ * TJU16 tape driver
+ */
+
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/buf.h"
+#include "../h/conf.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/uba.h"
+#include "../h/map.h"
+#include "../h/mba.h"
+
+struct device
+{
+       int     htcs1;
+       int     htds;
+       int     hter;
+       int     htmr;
+       int     htas;
+       int     htfc;
+       int     htdt;
+       int     htck;
+       int     htsn;
+       int     httc;
+};
+
+struct buf     httab;
+struct buf     rhtbuf;
+struct buf     chtbuf;
+
+#define        NUNIT   1
+#define        BUNIT   2
+#define        INF     1000000
+
+char   h_openf[NUNIT];
+daddr_t        h_blkno[NUNIT];
+daddr_t        h_nxrec[NUNIT];
+
+#define        HTADDR  ((struct device *)(MBA1 + MBA_ERB))
+
+#define        GO      01
+#define        WCOM    060
+#define        RCOM    070
+#define        NOP     0
+#define        WEOF    026
+#define        SFORW   030
+#define        SREV    032
+#define        ERASE   024
+#define        REW     06
+#define        DCLR    010
+#define P800   01700           /* 800 + pdp11 mode */
+#define        P1600   02300           /* 1600 + pdp11 mode */
+#define        IENABLE 0100
+#define        RDY     0200
+#define        TM      04
+#define        DRY     0200
+#define EOT    02000
+#define CS     02000
+#define COR    0100000
+#define PES    040
+#define WRL    04000
+#define MOL    010000
+#define ERR    040000
+#define FCE    01000
+#define        TRE     040000
+#define HARD   064023  /* UNS|OPI|NEF|FMT|RMR|ILR|ILF */
+
+#define        SIO     1
+#define        SSFOR   2
+#define        SSREV   3
+#define SRETRY 4
+#define SCOM   5
+#define SOK    6
+
+htopen(dev, flag)
+{
+       register unit, ds;
+
+       httab.b_flags |= B_TAPE;
+       unit = minor(dev) & 03;
+       if (unit >= NUNIT || h_openf[unit]) {
+               u.u_error = ENXIO;
+               return;
+       }
+       h_blkno[unit] = 0;
+       h_nxrec[unit] = INF;
+       ds = hcommand(dev, NOP);
+       if ((ds&MOL)==0 || (flag && (ds&WRL)))
+               u.u_error = ENXIO;
+       if (u.u_error==0)
+               h_openf[unit]++;
+}
+
+htclose(dev, flag)
+{
+       register int unit;
+
+       unit = minor(dev) & 03;
+       if (flag) {
+               hcommand(dev, WEOF);
+               hcommand(dev, WEOF);
+       }
+/*     hcommand(dev, REW);     */
+/* for 'mtm' file positioning */
+       if((minor(dev)&4) == 0) /* no 4 -> rewind */
+               hcommand(dev,REW) ;
+       else if(flag)  /* no rewind - backup over last EOF */
+               hcommand(dev&(~4),SREV) ;
+       h_openf[unit] = 0;
+}
+
+hcommand(dev, com)
+{
+       register struct buf *bp;
+
+       bp = &chtbuf;
+       spl5();
+       while(bp->b_flags&B_BUSY) {
+               bp->b_flags |= B_WANTED;
+               sleep(bp, PRIBIO);
+       }
+       spl0();
+       bp->b_dev = dev;
+       bp->b_resid = com;
+       bp->b_blkno = 0;
+       bp->b_flags = B_BUSY|B_READ;
+       htstrategy(bp);
+       iowait(bp);
+       if(bp->b_flags&B_WANTED)
+               wakeup(bp);
+       bp->b_flags = 0;
+       return(bp->b_resid);
+}
+
+htstrategy(bp)
+register struct buf *bp;
+{
+       register daddr_t *p;
+
+       if(bp != &chtbuf) {
+               p = &h_nxrec[minor(bp->b_dev)&03];
+               if(bp->b_blkno > *p) {
+                       bp->b_flags |= B_ERROR;
+                       bp->b_error = ENXIO;
+                       iodone(bp);
+                       return;
+               }
+               if(bp->b_blkno == *p && bp->b_flags&B_READ) {
+                       bp->b_resid = bp->b_bcount;
+                       clrbuf(bp);
+                       iodone(bp);
+                       return;
+               }
+               if ((bp->b_flags&B_READ)==0)
+                       *p = bp->b_blkno + 1;
+       }
+       bp->av_forw = NULL;
+       spl5();
+       if (httab.b_actf == NULL)
+               httab.b_actf = bp;
+       else
+               httab.b_actl->av_forw = bp;
+       httab.b_actl = bp;
+       if (httab.b_active==0)
+               htstart();
+       spl0();
+}
+
+htstart()
+{
+       register struct buf *bp;
+       register unit, den;
+       daddr_t blkno;
+
+    loop:
+       if ((bp = httab.b_actf) == NULL)
+               return;
+       unit = minor(bp->b_dev);
+       den = P800 | (unit&03);
+       if(unit >= 8)
+               den = P1600 | (unit&03);
+       if((HTADDR->httc&03777) != den)
+               HTADDR->httc = den;
+       unit &= 03;
+       blkno = h_blkno[unit];
+       if (bp == &chtbuf) {
+               if (bp->b_resid==NOP) {
+                       bp->b_resid = HTADDR->htds & 0xffff;
+                       goto next;
+               }
+               httab.b_active = SCOM;
+               HTADDR->htfc = 0;
+               HTADDR->htcs1 = bp->b_resid|GO;
+               return;
+       }
+       if (h_openf[unit] < 0 || bp->b_blkno > h_nxrec[unit])
+               goto abort;
+       if (blkno == bp->b_blkno) {
+               httab.b_active = SIO;
+               HTADDR->htfc = -bp->b_bcount;
+               mbastart(bp, HTADDR);
+       } else {
+               if (blkno < bp->b_blkno) {
+                       httab.b_active = SSFOR;
+                       HTADDR->htfc = blkno - bp->b_blkno;
+                       HTADDR->htcs1 = SFORW|GO;
+               } else {
+                       httab.b_active = SSREV;
+                       HTADDR->htfc = bp->b_blkno - blkno;
+                       HTADDR->htcs1 = SREV|GO;
+               }
+       }
+       return;
+
+    abort:
+       bp->b_flags |= B_ERROR;
+
+    next:
+       httab.b_actf = bp->av_forw;
+       iodone(bp);
+       goto loop;
+}
+
+htintr(mbastat, as)
+{
+       register struct buf *bp;
+       register int unit, state;
+       int     err;
+
+       if ((bp = httab.b_actf)==NULL)
+               return;
+       unit = minor(bp->b_dev) & 03;
+       state = httab.b_active;
+       httab.b_active = 0;
+       if (HTADDR->htds&(ERR|EOT|TM) || mbastat & MBAEBITS) {
+               err = HTADDR->hter & 0xffff;
+/*
+printf("ht2:mbas=%x, ds=%x, err=%x\n", mbastat, HTADDR->htds, err);
+*/
+               if ((mbastat & MBAEBITS) || (err&HARD))
+                       state = 0;
+               if (bp == &rhtbuf)
+                       err &= ~FCE;
+               if ((bp->b_flags&B_READ) && (HTADDR->htds&PES))
+                       err &= ~(CS|COR);
+               if(HTADDR->htds&EOT || (HTADDR->htds&MOL)==0) {
+                       if(h_openf[unit])
+                               h_openf[unit] = -1;
+               }
+               else if(HTADDR->htds&TM) {
+                       HTADDR->htfc = 0;
+                       h_nxrec[unit] = bp->b_blkno;
+                       state = SOK;
+               }
+               else if(state && err == 0)
+                       state = SOK;
+               if(httab.b_errcnt > 4) {
+                       deverror(bp, HTADDR->hter, mbastat);
+                       }
+               ((struct mba_regs *)MBA1)->mba_cr &= ~MBAIE;
+               HTADDR->htcs1 = DCLR|GO;
+               ((struct mba_regs *)MBA1)->mba_cr |= MBAIE;
+               if (state==SIO && ++httab.b_errcnt < 10) {
+                       httab.b_active = SRETRY;
+                       h_blkno[unit]++;
+                       HTADDR->htfc = -1;
+                       HTADDR->htcs1 = SREV|GO;
+                       return;
+               }
+               if (state!=SOK) {
+                       bp->b_flags |= B_ERROR;
+                       state = SIO;
+               }
+       } else if (HTADDR->htcs1 < 0) { /* SC */
+               if(HTADDR->htds & ERR) {
+                       ((struct mba_regs *)MBA1)->mba_cr &= ~MBAIE;
+                       HTADDR->htcs1 = DCLR|GO;
+                       ((struct mba_regs *)MBA1)->mba_cr |= MBAIE;
+               }
+       }
+       switch(state) {
+       case SIO:
+       case SOK:
+               h_blkno[unit]++;
+
+       case SCOM:
+               httab.b_errcnt = 0;
+               httab.b_actf = bp->av_forw;
+               bp->b_resid = - (HTADDR->htfc & 0xffff);
+               if (bp->b_flags & B_READ)
+                       bp->b_resid += bp->b_bcount;
+               iodone(bp);
+               break;
+
+       case SRETRY:
+               if((bp->b_flags&B_READ)==0) {
+                       httab.b_active = SSFOR;
+                       HTADDR->htcs1 = ERASE|GO;
+                       return;
+               }
+
+       case SSFOR:
+       case SSREV:
+               if(HTADDR->htds & TM) {
+                       if(state == SSREV) {
+                               h_nxrec[unit] = bp->b_blkno - (HTADDR->htfc&0xffff);
+                               h_blkno[unit] = h_nxrec[unit];
+                       } else {
+                               h_nxrec[unit] = bp->b_blkno + (HTADDR->htfc & 0xffff) - 1;
+                               h_blkno[unit] = bp->b_blkno + (HTADDR->htfc & 0xffff);
+                       }
+               } else
+                       h_blkno[unit] = bp->b_blkno;
+               break;
+
+       default:
+               return;
+       }
+       htstart();
+}
+
+htread(dev)
+{
+       htphys(dev);
+       physio(htstrategy, &rhtbuf, dev, B_READ);
+}
+
+htwrite(dev)
+{
+       htphys(dev);
+       physio(htstrategy, &rhtbuf, dev, B_WRITE);
+}
+
+htphys(dev)
+{
+       register unit;
+       daddr_t a;
+
+       unit = minor(dev) & 03;
+       if(unit < NUNIT) {
+               a = u.u_offset >> 9;
+               h_blkno[unit] = a;
+               h_nxrec[unit] = a+1;
+       }
+}
diff --git a/usr/src/slowsys/sys/iget.c b/usr/src/slowsys/sys/iget.c
new file mode 100644 (file)
index 0000000..c0337a1
--- /dev/null
@@ -0,0 +1,316 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/mount.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/inode.h"
+#include "../h/ino.h"
+#include "../h/filsys.h"
+#include "../h/conf.h"
+#include "../h/buf.h"
+
+/*
+ * Look up an inode by device,inumber.
+ * If it is in core (in the inode structure),
+ * honor the locking protocol.
+ * If it is not in core, read it in from the
+ * specified device.
+ * If the inode is mounted on, perform
+ * the indicated indirection.
+ * In all cases, a pointer to a locked
+ * inode structure is returned.
+ *
+ * printf warning: no inodes -- if the inode
+ *     structure is full
+ * panic: no imt -- if the mounted file
+ *     system is not in the mount table.
+ *     "cannot happen"
+ */
+struct inode *
+iget(dev, ino)
+dev_t dev;
+ino_t ino;
+{
+       register struct inode *ip;
+       register struct mount *mp;
+       register struct inode *oip;
+       register struct buf *bp;
+       register struct dinode *dp;
+
+loop:
+       oip = NULL;
+       for(ip = &inode[0]; ip < &inode[NINODE]; ip++) {
+               if(ino == ip->i_number && dev == ip->i_dev) {
+                       if((ip->i_flag&ILOCK) != 0) {
+                               ip->i_flag |= IWANT;
+                               sleep((caddr_t)ip, PINOD);
+                               goto loop;
+                       }
+                       if((ip->i_flag&IMOUNT) != 0) {
+                               for(mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
+                               if(mp->m_inodp == ip) {
+                                       dev = mp->m_dev;
+                                       ino = ROOTINO;
+                                       goto loop;
+                               }
+                               panic("no imt");
+                       }
+                       ip->i_count++;
+                       ip->i_flag |= ILOCK;
+                       return(ip);
+               }
+               if(oip==NULL && ip->i_count==0)
+                       oip = ip;
+       }
+       ip = oip;
+       if(ip == NULL) {
+               printf("Inode table overflow\n");
+               u.u_error = ENFILE;
+               return(NULL);
+       }
+       ip->i_dev = dev;
+       ip->i_number = ino;
+       ip->i_flag = ILOCK;
+       ip->i_count++;
+       ip->i_un.i_lastr = 0;
+       bp = bread(dev, itod(ino));
+       /*
+        * Check I/O errors
+        */
+       if((bp->b_flags&B_ERROR) != 0) {
+               brelse(bp);
+               iput(ip);
+               return(NULL);
+       }
+       dp = bp->b_un.b_dino;
+       dp += itoo(ino);
+       iexpand(ip, dp);
+       brelse(bp);
+       return(ip);
+}
+
+iexpand(ip, dp)
+register struct inode *ip;
+register struct dinode *dp;
+{
+       register char *p1;
+       char *p2;
+       int i;
+
+       ip->i_mode = dp->di_mode;
+       ip->i_nlink = dp->di_nlink;
+       ip->i_uid = dp->di_uid;
+       ip->i_gid = dp->di_gid;
+       ip->i_size = dp->di_size;
+       p1 = (char *)ip->i_un.i_addr;
+       p2 = (char *)dp->di_addr;
+       for(i=0; i<NADDR; i++) {
+               *p1++ = *p2++;
+               *p1++ = *p2++;
+               *p1++ = *p2++;
+               *p1++ = 0;
+       }
+}
+
+/*
+ * Decrement reference count of
+ * an inode structure.
+ * On the last reference,
+ * write the inode out and if necessary,
+ * truncate and deallocate the file.
+ */
+iput(ip)
+register struct inode *ip;
+{
+
+       if(ip->i_count == 1) {
+               ip->i_flag |= ILOCK;
+               if(ip->i_nlink <= 0) {
+                       itrunc(ip);
+                       ip->i_mode = 0;
+                       ip->i_flag |= IUPD|ICHG;
+                       ifree(ip->i_dev, ip->i_number);
+               }
+               iupdat(ip, &time, &time);
+               prele(ip);
+               ip->i_flag = 0;
+               ip->i_number = 0;
+       }
+       ip->i_count--;
+       prele(ip);
+}
+
+/*
+ * Check accessed and update flags on
+ * an inode structure.
+ * If either is on, update the inode
+ * with the current time.
+ */
+iupdat(ip, ta, tm)
+register struct inode *ip;
+time_t *ta, *tm;
+{
+       register struct buf *bp;
+       struct dinode *dp;
+       register char *p1;
+       char *p2;
+       int i;
+
+       if((ip->i_flag&(IUPD|IACC|ICHG)) != 0) {
+               if(getfs(ip->i_dev)->s_ronly)
+                       return;
+               bp = bread(ip->i_dev, itod(ip->i_number));
+               if (bp->b_flags & B_ERROR) {
+                       brelse(bp);
+                       return;
+               }
+               dp = bp->b_un.b_dino;
+               dp += itoo(ip->i_number);
+               dp->di_mode = ip->i_mode;
+               dp->di_nlink = ip->i_nlink;
+               dp->di_uid = ip->i_uid;
+               dp->di_gid = ip->i_gid;
+               dp->di_size = ip->i_size;
+               p1 = (char *)dp->di_addr;
+               p2 = (char *)ip->i_un.i_addr;
+               for(i=0; i<NADDR; i++) {
+                       *p1++ = *p2++;
+                       *p1++ = *p2++;
+                       *p1++ = *p2++;
+                       if(*p2++ != 0 && (ip->i_mode&IFMT)!=IFMPC
+                          && (ip->i_mode&IFMT)!=IFMPB)
+                               printf("iaddress > 2^24\n");
+               }
+               if(ip->i_flag&IACC)
+                       dp->di_atime = *ta;
+               if(ip->i_flag&IUPD)
+                       dp->di_mtime = *tm;
+               if(ip->i_flag&ICHG)
+                       dp->di_ctime = time;
+               ip->i_flag &= ~(IUPD|IACC|ICHG);
+               bdwrite(bp);
+       }
+}
+
+/*
+ * Free all the disk blocks associated
+ * with the specified inode structure.
+ * The blocks of the file are removed
+ * in reverse order. This FILO
+ * algorithm will tend to maintain
+ * a contiguous free list much longer
+ * than FIFO.
+ */
+itrunc(ip)
+register struct inode *ip;
+{
+       register i;
+       dev_t dev;
+       daddr_t bn;
+
+       i = ip->i_mode & IFMT;
+       if (i!=IFREG && i!=IFDIR)
+               return;
+       dev = ip->i_dev;
+       for(i=NADDR-1; i>=0; i--) {
+               bn = ip->i_un.i_addr[i];
+               if(bn == (daddr_t)0)
+                       continue;
+               ip->i_un.i_addr[i] = (daddr_t)0;
+               switch(i) {
+
+               default:
+                       free(dev, bn);
+                       break;
+
+               case NADDR-3:
+                       tloop(dev, bn, 0, 0);
+                       break;
+
+               case NADDR-2:
+                       tloop(dev, bn, 1, 0);
+                       break;
+
+               case NADDR-1:
+                       tloop(dev, bn, 1, 1);
+               }
+       }
+       ip->i_size = 0;
+       ip->i_flag |= ICHG|IUPD;
+}
+
+tloop(dev, bn, f1, f2)
+dev_t dev;
+daddr_t bn;
+{
+       register i;
+       register struct buf *bp;
+       register daddr_t *bap;
+       daddr_t nb;
+
+       bp = NULL;
+       for(i=NINDIR-1; i>=0; i--) {
+               if(bp == NULL) {
+                       bp = bread(dev, bn);
+                       if (bp->b_flags & B_ERROR) {
+                               brelse(bp);
+                               return;
+                       }
+                       bap = bp->b_un.b_daddr;
+               }
+               nb = bap[i];
+               if(nb == (daddr_t)0)
+                       continue;
+               if(f1) {
+                       brelse(bp);
+                       bp = NULL;
+                       tloop(dev, nb, f2, 0);
+               } else
+                       free(dev, nb);
+       }
+       if(bp != NULL)
+               brelse(bp);
+       free(dev, bn);
+}
+
+/*
+ * Make a new file.
+ */
+struct inode *
+maknode(mode)
+{
+       register struct inode *ip;
+
+       ip = ialloc(u.u_pdir->i_dev);
+       if(ip == NULL) {
+               iput(u.u_pdir);
+               return(NULL);
+       }
+       ip->i_flag |= IACC|IUPD|ICHG;
+       if((mode&IFMT) == 0)
+               mode |= IFREG;
+       ip->i_mode = mode & ~u.u_cmask;
+       ip->i_nlink = 1;
+       ip->i_uid = u.u_uid;
+       ip->i_gid = u.u_gid;
+       wdir(ip);
+       return(ip);
+}
+
+/*
+ * Write a directory entry with
+ * parameters left as side effects
+ * to a call to namei.
+ */
+wdir(ip)
+struct inode *ip;
+{
+
+       u.u_dent.d_ino = ip->i_number;
+       bcopy((caddr_t)u.u_dbuf, (caddr_t)u.u_dent.d_name, DIRSIZ);
+       u.u_count = sizeof(struct direct);
+       u.u_segflg = 1;
+       u.u_base = (caddr_t)&u.u_dent;
+       writei(u.u_pdir);
+       iput(u.u_pdir);
+}
diff --git a/usr/src/slowsys/sys/loadall b/usr/src/slowsys/sys/loadall
new file mode 100644 (file)
index 0000000..ae1c318
--- /dev/null
@@ -0,0 +1,2 @@
+ld -o unix -e start -x -T 80000000 locore.o acct.o alloc.o bio.o clock.o conf.o cons.o dkleave.o dsort.o dz.o fio.o hp.o ht.o iget.o machdep.o main.o malloc.o mba.o mem.o mx1.o mx2.o  nami.o partab.o pipe.o prf.o prim.o rdwri.o sig.o slp.o subr.o sys.o sys1.o sys2.o sys3.o sys4.o sysent.o tdump.o text.o trap.o tty.o uba.o ureg.o univec.o
+ls -l unix
diff --git a/usr/src/slowsys/sys/locore.s b/usr/src/slowsys/sys/locore.s
new file mode 100644 (file)
index 0000000..2a1a698
--- /dev/null
@@ -0,0 +1,1185 @@
+       .set    HIGH,31         # mask for total disable
+       .set    SZPT,4          # number of pages of user page table allocated per user
+       .set    MCKVEC,4        # offset into Scbbase of machine check vector
+
+# Trap vectors and C interface for Vax
+
+#
+#
+#
+# System control block
+#
+
+       .set    INTSTK,1        # handle this interrupt on the interrupt stack
+       .set    HALT,3          # halt if this interrupt occurs
+       .align  9
+       .globl  Scbbase
+Scbbase:
+       .long   Xrandom + HALT  # unused
+       .long   Xmachcheck + HALT       # machine check interrupt
+       .long   Xkspnotval + HALT       # kernal stack not valid
+       .long   Xpowfail + HALT # power fail
+       .long   Xprivinflt      # privileged instruction 
+       .long   Xxfcflt         # xfc instruction 
+       .long   Xresopflt       # reserved operand 
+       .long   Xresadflt       # reserved addressing 
+       .long   Xprotflt        # protection 
+       .long   Xsegflt         # segmentation 
+       .long   Xtracep         # trace pending
+       .long   Xbptflt         # bpt instruction
+       .long   Xrandom + HALT  # compatibility mode fault
+       .long   Xarithtrap      # arithmetic trap
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xsyscall        # chmk
+       .long   Xchme+HALT              # chme
+       .long   Xchms+HALT              # chms
+       .long   Xchmu+HALT              # chmu
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # software level 1
+       .long   Xrandom + HALT  # software level 2 (asts)
+       .long   Xresched        # reschedule nudge
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+ubabase:
+       .long   Xclockint + INTSTK      # clock
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xconsrint + INTSTK      # console receiver 
+       .long   Xconsxint + INTSTK      # console transmitter
+
+#      I/O vectors
+
+# IPL 14
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xua0int + INTSTK        # UBA 0 br4
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+
+# IPL 15
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xua0int + INTSTK        # UBA 0 br5
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xmba0int + INTSTK       # mass bus adapter 0
+       .long   Xmba1int + INTSTK       # mass bus adapter 1
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+
+# IPL 16
+       .long   Xrandom + HALT          # unused
+       .long   Xrandom + HALT          # unused
+       .long   Xrandom + HALT          # unused
+       .long   Xua0int + INTSTK        # UBA 0 br6
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+
+# IPL 17
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+
+
+#  0x200
+# Produce a core image dump on mag tape
+       .globl  doadump
+doadump:
+       movl    sp,dumpstack    # save stack pointer
+       movab   dumpstack,sp    # reinit sp 
+       mfpr    $PCBB,-(sp)             # save u-area pointer
+       mfpr    $MAPEN,-(sp)    # save value
+       mfpr    $IPL,-(sp)              # ...
+       mtpr    $0,$MAPEN               # turn off memory mapping
+       mtpr    $HIGH,$IPL              # disable interrupts
+       pushr   $0x3fff                 # save regs 0 - 13
+       calls   $0,_dump        # produce dump
+       halt
+
+       .data
+       .align  2
+       .space  58*4            # seperate stack for tape dumps
+       .globl  dumpstack
+dumpstack: 
+       .space  4
+       .text
+
+
+# I/O interrupt vector routines
+#
+
+# Catch random or unexpected interrupts
+
+       .align  2
+Xrandom:
+Xmachcheck:
+Xkspnotval:
+Xpowfail:
+Xchme:
+Xchms:
+Xchmu:
+       halt
+
+# Massbus 0 adapter interrupts
+
+       .align  2
+Xmba0int:
+       pushr   $0x3f           # save r0 - r5
+       movab   MBA0_CSR,r0     # point at mba regs
+       movl    MBA_AS(r0),r1           # get attn summary bits
+       cvtwl   r1,-(sp)                # push attn summary as arg
+       pushl   MBA_SR(r0)      # pass sr as argument
+       mnegl   $1,MBA_SR(r0)   # clear attention bit
+       calls   $2,_hpintr      # call rp06 interrupt dispatcher
+       brw     int_ret         # merge with common interrupt code
+
+
+# Massbus 1 adapter interrupts
+
+       .align  2
+Xmba1int:
+       pushr   $0x3f
+       movab   MBA1_CSR,r0
+       pushl   MBA_AS(r0)
+       mnegl   $1,MBA_AS(r0)
+       pushl   MBA_SR(r0)              # pass cr as argument_
+       mnegl   $1,MBA_SR(r0)   # clear attention bit
+       calls   $2,_htintr      # call te16 interrupt dispatcher
+       brw     int_ret         # return from interrupt
+
+
+# Unibus adapter interrupts
+
+       .align  2
+Xua0int:       #  UBA 0 interrupts
+       pushr   $0x3f  #  save regs 0-5
+       pushab  UBA0  # save UBA base addr
+       brb     Xuacom  #  jump to common code
+Xua1int :      #  UBA 1 interrupts
+Xuacom :       #  common code for UBA interrupts
+       popr    $1              # UBA base addr
+       mfpr    $IPL,r2         # get br level
+       movl    UBR_OFF-20*4(r0)[r2],r3 # get unibus device vector
+       bleq    ubasrv  # branch if zero vector or UBA service required
+#  normal UBA interrupt point - device on a UBA has generated an
+#    interrupt - r3 holds interrupt vector
+ubanorm :
+       movl    _UNIvec(r3),r1  #  get interrupt service routine address
+#                      and controller code from UNIBUS vector area
+       extzv   $27,$4,r1,-(sp)  #  controller code is in 4 most
+#                              significant bits-1 of ISR addr
+       bicl2   $0x78000000,r1  #  clear code
+       calls   $1,(r1)  #  call ISR
+       brw     int_ret  #  go to common interrupt return
+#  here for zero or negative UBA interrupt vector.
+#  negative vector -> UBA requires service
+ubasrv :
+       beql    ubapass
+#
+#  UBA service required
+#  The following 'printf' calls should probably be replaced
+#    with calls to an error logger and/or some corrective action.
+       bitl    $CFGFLT,UCN_OFF(r0)  #  any SBI faults ?
+       beql    UBAflt
+       pushab  SBImsg
+       calls   $1,_printf
+       halt
+#
+#  no SBI fault bits set in UBA config reg - must be
+#    some error bits set in UBA status reg
+UBAflt :
+       movl    UST_OFF(r0),r2  #  UBA status reg
+       pushr   r2
+       pushab  UBAmsg
+       calls   $2,_printf
+       movl    r2,UST_OFF(r0)  #  clear error bits
+       bicl2   $0x80000000,r1  #  clear neg bit in vector
+       bneq    ubanorm  #  branch if normal UBA interrupt to process
+       brb     int_ret         # restore regs and return
+#
+#  zero interrupt vector - print message & continue
+ubapass :
+       pushab  ZERmsg
+       calls   $1,_printf
+       brb     int_ret
+
+
+# Console receiver interrupt
+
+       .align  2
+Xconsrint:
+       pushr   $0x3f           # save registers 0 - 5
+       calls   $0,_consrint
+       brb     int_ret         # merge
+
+
+# Console transmit interrupt
+       .align  2
+Xconsxint:
+       pushr   $0x3f           # save registers 0 - 5
+       calls   $0,_consxint
+       brb     int_ret
+
+
+# Clock interrupt
+       .align  2
+Xclockint:
+       pushr   $0x3f           # save regs 0 - 5
+       pushl   4+6*4(sp)       # push psl
+       pushl   4+6*4(sp)       # push pc
+       calls   $2,_clock
+       brb     int_ret
+
+
+#
+# Common code for interrupts
+# At this point, the interrupt stack looks like:
+#
+#               ___________
+#              |    r0     | :isp
+#              |-----------|
+#              |    ...    |
+#              |-----------|
+#              |    r13    |
+#              |-----------|
+#              |    pc     |
+#              |-----------|
+#              |    psl    |
+#              |___________|
+
+
+int_ret:
+       bbssi   $0,idleflag,int_r0              # set idle escape flag (no wait instr)
+int_r0:
+       popr    $0x3f           # restore regs 0 - 5
+       bitl    $PSL_CURMOD,4(sp)       # interrupt from user mode?
+       beql    int_r1          # no, from kernal, just rei
+       tstb    _runrun         # should we reschedule?
+       beql    int_r1          # no, just rei
+#
+# If here, interrupt from user mode, and time to reschedule.
+#      to do this, we set a software level 3 interrupt to
+#      change to kernal mode, switch stacks,
+#      and format kernal stack for a `qswitch' trap to force
+#      a reschedule.
+#
+       mtpr    $3,$SIRR        # request level 1 software interrupt
+int_r1:
+       rei                     # return to interrupted process
+
+#
+# Trap and fault vector routines
+#
+
+#      Reschedule trap (Software level 3 interrupt)
+       .align  2
+Xresched:
+       movpsl  -(sp)   # get ps
+       bicl2   $PSL_IPL,(sp)   # lower ipl
+       pushab  resc1           # push pc
+       rei                     # lower ipl, jump to resc1
+
+resc1:
+       pushl   $0                      # dummy code
+       pushl   $RESCHED        # type
+       brb     alltraps        # merge
+
+
+#      privileged instruction fault
+       .align  2
+Xprivinflt:
+       pushl   $0              # push dummy code
+       pushl   $PRIVINFLT      # push type
+       brb     alltraps        # merge
+
+
+
+#      xfc instruction fault
+       .align  2
+Xxfcflt:
+       pushl   $0              # push dummy code value
+       pushl   $XFCFLT         # push type value
+       brb     alltraps        # merge
+
+
+#      reserved operand fault
+       .align  2
+Xresopflt:
+       pushl   $0              # push dummy code value
+       pushl   $RESOPFLT       # push type value
+       brb     alltraps        # merge
+
+
+#      reserved addressing mode fault
+       .align  2
+Xresadflt:
+       pushl   $0              # push dummy code value
+       pushl   $RESADFLT       # push type value
+       brb     alltraps        # merge with common code
+
+
+#      bpt instruction fault
+       .align  2
+Xbptflt:
+       pushl   $0              # push dummy code value
+       pushl   $BPTFLT         # push type value
+       brb     alltraps        # merge with common code
+
+#      Trace trap
+
+       .align  2
+Xtracep:
+       pushl   $0              # push dummy code value
+       pushl   $TRCTRAP        # push type value
+       brb     alltraps        # go do it
+
+#      Arithmitic trap
+       .align  2
+Xarithtrap:
+       pushl   $ARITHTRAP      # push type value
+       brb     alltraps        # merge with common code
+
+
+#      Protection  fault
+
+       .align  2
+Xprotflt:
+       blbs    (sp),Xsegflt            # check for pt length violation
+       addl2   $4,sp           # pop fault param word 
+       pushl   $PROTFLT
+       brb     alltraps
+
+#      Segmentation fault
+
+       .align  2
+Xsegflt:
+       addl2   $4,sp
+       pushl   $SEGFLT
+       brb     alltraps
+
+
+
+
+#
+# CHMK trap (syscall trap)
+#      on entry, kernal stack:
+#
+#               ___________ 
+#              |    code   | :ksp
+#              |-----------|
+#              |    pc     |
+#              |-----------|
+#              |    psl    |
+#              |___________|
+#
+#
+#
+#      stack (parameters) at calls to _trap:
+#
+#               ___________ 
+#              |    ap     | :ksp
+#              |-----------|
+#              |    r0     |
+#              |-----------|
+#              |    ...    |
+#              |-----------|
+#              |    r13    |
+#              |-----------|
+#              |    usp    |
+#              |-----------|
+#              |    type   |
+#              |-----------|
+#              |    code   |
+#              |-----------|
+#              |    pc     |
+#              |-----------|
+#              |    psl    |
+#              |___________|
+#
+
+       .align  2
+Xsyscall:
+       pushl   $SYSCALL        # push type value
+alltraps:
+       movq    8(sp),_u+PCB_PC # save pc
+       bitl    $PSL_CURMOD,12(sp)      # from user mode?
+       beql    sysc1           # no
+# Prepare arguments to _trap, note that type has already been pushed
+       mfpr    $USP,-(sp)      # get usp
+       pushr   $0x3fff         # registers 0 - 13
+       pushl   ap              # ptr to syscall parameters
+#
+# Call _trap with wrong number of arguments
+#   so args not popped by ret
+#
+       calls   $1,_trap
+# Restore
+       popr    $0x3fff         # restore regs 0 - 13
+       mtpr    (sp)+,$USP      # restore usp
+       addl2   $8,sp           # pop type, code
+#
+       bitl    $PSL_CURMOD,4(sp)               # are we returning to user mode?
+       beql    sysc2           # no
+# Return
+       rei
+
+sysc1:
+       movab   emsg1,eptr      # set message pointer
+       brb     err_print       # print message and halt
+
+sysc2:
+       movab   emsg2,eptr      # pointer to error message
+       brb     err_print       # print msg and halt
+
+#
+# err_print
+#      print message on console and die
+#      message pointed to by eptr, terminated by zero byte.
+#
+
+err_print:
+       mtpr    $HIGH,$IPL      # disable all interrupts
+       mtpr    $0,$TXCS        # disable interrupts on console transmitter
+eloop1:
+       mfpr    $TXCS,ewk1      # get transmitter status
+       bbc     $TXCS_BRDY,ewk1,eloop1  # loop if not ready to transmit
+       tstb    *eptr           # end of message?
+       beql    eout            # yes, out of loop
+       movzbl  *eptr,ewk1      # get byte of message
+       incl    eptr            # bump pointer
+       mtpr    ewk1,$TXDB      # give byte to transmitter
+       brb     eloop1          # loop
+
+eout:
+       halt
+
+       .data
+eptr:  .long   0
+ewk1:  .long   0
+       .text
+
+
+
+#
+# Initialization
+
+#
+#      IPL == 1F
+#      MAPEN == off
+#      SCBB, PCBB not set
+#      SBR, SLR not set
+#      ISP, KSP not set
+#
+       .globl  start
+start:
+       .word   0x0000
+       mtpr    $HIGH,$IPL              # no interrupts yet
+       mtpr    $Scbbase,$SCBB  # set SCBB
+       mtpr    $_Sysmap,$SBR   # set SBR
+       mtpr    $Syssize,$SLR   # set SLR
+       mtpr    $_Sysmap,$P0BR  # set temp P0BR
+       mtpr    $Syssize,$P0LR  # set temp P0LR
+       movl    $_intstack+2048,sp      # set ISP
+# initialize i/o adatpers
+       movl    $1,PHYSMBA0+4   # init & interrupt enable
+       movl    $4,PHYSMBA0+4   # init & interrupt enable
+       movl    $1,PHYSMBA1+4   # init  interrupt enable
+       movl    $4,PHYSMBA1+4   # init  interrupt enable
+       movl    $1,PHYSUBA+4    # init  interrupt enable
+       movl    $0x78,PHYSUBA+4 # init  interrupt enable
+
+       movl    Scbbase+MCKVEC,r5       # save machine check entry
+       movab   startint+INTSTK,Scbbase+MCKVEC  # set new vector address
+#
+# will now see how much memory there really is
+#      in 64kb chunks, save number of bytes in r7
+#
+       mtpr    $HIGH-1,$IPL    # allow machine check interrupts
+       clrl    r7
+startlp:
+       tstl    (r7)            # this chunk really there?
+       acbl    $8096*1024-1,$64*1024,r7,startlp        # loop till machine check
+       brb     startint        # full load of memory, avoid .align
+       .align  2
+startint:
+       mtpr    $0,$SBIFS               # clear sbi fault status
+       movl    r5,Scbbase+MCKVEC       # restore machine check vector
+       movl    $_intstack+2048,sp      # reset interrupt stack pointer
+
+#      clear memory starting with unitialized data (kernal)
+       movab   _edata,r6
+       movab   _end+8096,r5    # clear uninitialized data and some slop
+strtclr:
+       clrq    (r6)
+       acbl    r5,$8,r6,strtclr
+
+#
+#      initialize system page table
+#
+       movab   _etext+511,r1   # end of kernal text segment
+       bbcc    $31,r1,strt1    # turn off high order bit
+strt1:
+       ashl    $-9,r1,r1       # last page of kernal text
+       clrl    r2              # point at first kernal text page
+strtlp1:
+       bisl3   $PG_V|PG_KR,r2,_Sysmap[r2]      # initialize page table entry
+       aoblss  r1,r2,strtlp1   # fill text entries
+       movab   _end+511,r1     # end of kernal data segment
+       bbcc    $31,r1,strt2    # turn off high order bit
+strt2:
+       ashl    $-9,r1,r1       # last page of kernal data
+strtlp2:
+       bisl3   $PG_V|PG_KW,r2,_Sysmap[r2]      # fill data entries
+       aoblss  r1,r2,strtlp2
+
+#      init i/o space page table entries
+       movl    $PHYSUBA/512,r1         # page frame number for uba
+       movab   _Sysmap+uba_offset,r2   # page table address
+       movab   15(r1),r3       # last pt entry
+strtlp3:
+       bisl3   $PG_V|PG_KW,r1,(r2)+    # init pt entry
+       aobleq  r3,r1,strtlp3
+       movl    $PHYSUMEM/512,r1
+       movab   _Sysmap+umem_offset,r2  # page table address
+       movab   15(r1),r3               # limit
+strtlp4:
+       bisl3   $PG_V|PG_KW,r1,(r2)+
+       aobleq  r3,r1,strtlp4
+       movl    $PHYSMBA0/512,r1
+       movab   _Sysmap+mba0_offset,r2
+       movab   15(r1),r3
+strtlp5:
+       bisl3   $PG_V|PG_KW,r1,(r2)+
+       aobleq  r3,r1,strtlp5
+       movl    $PHYSMBA1/512,r1
+       movab   _Sysmap+mba1_offset,r2
+       movab   15(r1),r3
+strtlp6:
+       bisl3   $PG_V|PG_KW,r1,(r2)+
+       aobleq  r3,r1,strtlp6
+
+       mtpr    $1,$TBIA        # invalidate all trans buffer entries
+       mtpr    $1,$MAPEN       # turn on memory mapping
+       jmp     *$startmap      # put system virtual address in pc
+
+startmap:
+# set maxmem = btoc(r7)
+       ashl    $-9,r7,_maxmem
+
+#
+# Setup context for proc[0] == Scheduler
+#
+# address first page past _end
+#      this will be u area for proc[0].
+#      initialize u area page table entries.
+#      initialize (slightly) the pcb.
+
+       movab   _end+511,r6
+       bicl2   $0x1ff,r6       # make page boundary
+
+# set up u area page table
+       bbcc    $31,r6,strt3
+strt3:
+       ashl    $-9,r6,r3               # r3 = btoc(r6)
+       bisl3   $PG_V|PG_KW,r3,_Sysmap+u_ptoffset       # init first u pt entry
+       movab   _u,r1           # point at _u area
+       mtpr    r1,$TBIS
+       movab   usize*512(r1),PCB_KSP(r1)       # init ksp
+       mnegl   $1,PCB_ESP(r1)          # invalidate esp
+       mnegl   $1,PCB_SSP(r1)          # invalidate ssp
+       movl    $0x80000000,PCB_USP(r1)         # set user sp
+       movab   _u+usize*512,PCB_P0BR(r1)       # p0 page table pointer
+       clrl    PCB_P0LR(r1)            # size zero page table
+       movb    $4,PCB_P0LR+3(r1)       # disable ast
+       movab   _u+(usize+SZPT)*512-0x800000,PCB_P1BR(r1)               # p1 page table pointer
+       movl    $0x200000,PCB_P1LR(r1)          # invalid p1 p t length
+       movl    $SZPT,PCB_SZPT(r1)              # init number pages usr page table
+       ashl    $-9,r6,-(sp)    # push arg for setupu
+       pushl   $1              # ditto
+       movl    sp,ap   # set up arg pointer
+       bsbw    setupu
+       addl2   $8,sp           # pop stack
+
+       mtpr    r6,$PCBB                # first pcb
+
+       ldpctx                  # set regs, p0br, p0lr, p1br, p1lr, 
+#                              astlvl, ksp, and change to kernal mode
+       addl2   $8,sp           # pop dummy pc, psl
+       mtpr    $0,$IPL         # enable interrupts
+       movab   _end+511,r0     # calculate firstaddr
+       bbcc    $31,r0,strt4
+strt4:
+       ashl    $-9,r0,-(sp)    # convert to clicks and stack
+       calls   $1,_main        # startup, fork off /etc/init
+#
+# proc[1] == /etc/init now running here.
+# execute code at location 0, in user mode.
+#
+       pushl   $PSL_CURMOD|PSL_PRVMOD  # psl, user mode, ipl= 0
+       pushl   $0              # pc, $location 0
+       rei                     # do /etc/init
+
+
+#
+# Primitives
+#
+
+_display:      .globl  _display
+_savfp:        .globl  _savfp
+_restfp:       .globl  _restfp
+       .word   0x0000
+       ret
+
+_addupc:       .globl  _addupc
+       .word   0x0000
+       movl    8(ap),r2        # &u.u_prof
+       subl3   8(r2),4(ap),r0  # corrected pc
+       blss    addret
+       extzv   $1,$31,r0,r0    # logical right shift
+       extzv   $1,$31,12(r2),r1        # ditto for scale
+       mull2   r1,r0
+       ashl    $-14,r0,r0
+       incl    r0
+       bicb2   $1,r0
+       cmpl    r0,4(r2)        # length
+       bgequ   addret
+       addl2   (r2),r0         # base
+       probew  $3,$2,(r0)
+       beql    adderr
+       addw2   12(ap),(r0)
+addret:
+       ret
+adderr:
+       clrl    12(r2)
+       ret
+
+
+_fubyte:       .globl  _fubyte
+_fuibyte:.globl        _fuibyte
+       .word   0x0000
+       prober  $3,$1,*4(ap)    # byte accessible ?
+       beql    eret                    # no
+       movzbl  *4(ap),r0
+       ret
+
+_subyte:       .globl  _subyte
+_suibyte:.globl        _suibyte
+       .word   0x0000
+       probew  $3,$1,*4(ap)    # byte accessible ?
+       beql    eret                    # no
+       movb    8(ap),*4(ap)
+       clrl    r0
+       ret
+
+_fuword:       .globl  _fuword
+_fuiword:.globl        _fuiword
+       .word   0x0000
+       prober  $3,$4,*4(ap)
+       beql    eret
+       movl    *4(ap),r0
+       ret
+
+_suword:       .globl  _suword
+_suiword:.globl        _suiword
+       .word   0x0000
+       probew  $3,$4,*4(ap)
+       beql    eret
+       movl    8(ap),*4(ap)
+       clrl    r0
+       ret
+eret:
+       mnegl   $1,r0                   # error return
+       ret
+
+_copyin:       .globl  _copyin
+_copyiin:.globl        _copyiin
+       .word   0x0000
+       movl    12(ap),r0       # copy length
+       movl    4(ap),r1        # copy user address
+       cmpl    $512,r0         # probing one page or less ?
+       bgeq    cishort         # yes
+ciloop:
+       prober  $3,$512,(r1)    # bytes accessible ?
+       beql    eret            # no
+       addl2   $512,r1         # incr user address ptr
+       acbl    $513,$-512,r0,ciloop    # reduce count and loop
+cishort:
+       prober  $3,r0,(r1)      # bytes accessible ?
+       beql    eret            # no
+       movc3   12(ap),*4(ap),*8(ap)
+       clrl    r0
+       ret
+
+_copyout: .globl       _copyout
+_copyiout:.globl       _copyiout
+       .word   0x0000
+       movl    12(ap),r0       # get count
+       movl    8(ap),r1        # get user address
+       cmpl    $512,r0         # can do in one probew?
+       bgeq    coshort         # yes
+coloop:
+       probew  $3,$512,(r1)    # bytes accessible?
+       beql    eret            # no 
+       addl2   $512,r1         # increment user address
+       acbl    $513,$-512,r0,coloop    # reduce count and loop
+coshort:
+       probew  $3,r0,(r1)      # bytes accessible?
+       beql    eret            # no
+       movc3   12(ap),*4(ap),*8(ap)
+       clrl    r0
+       ret
+
+_idle: .globl  _idle
+       .word   0x0000
+       mtpr    $0,$IPL         # enable interrupts
+waitloc:       blbc    idleflag,waitloc        # loop until interrupt
+ewaitloc:      bbcci   $0,idleflag,idle1       # clear idle escape flag
+idle1:
+       ret
+       .data
+       .globl  _waitloc
+       .globl  _ewaitloc
+       .align  2
+_waitloc:      .long   waitloc
+_ewaitloc:     .long   ewaitloc
+idleflag:      .long   0
+       .text
+
+
+# save reg's and ret loc into save area - return 0
+       .globl  _save
+_save :                # save(save_area)
+       .word   0x0
+       mtpr    $HIGH,$IPL
+       movl    4(ap),r0  #  save area addr
+       movab   2*4(ap),sp  #  restore stack to val before 'save' call
+       movl    8(fp),ap  #  restore ap "       "       "
+       movl    16(fp),r1  #  restore pc        "       "       "
+       movl    12(fp),fp  #  restore fp        "       "       "
+       movq    r6,(r0)+
+       movq    r8,(r0)+
+       movq    r10,(r0)+
+       movq    ap,(r0)+  #  ap & fp
+       movl    sp,(r0)+
+       movl    r1,(r0)+  #  ret loc of call to 'save'
+       movpsl  -(sp)
+       pushl   r1
+       svpctx  # save reg's -> PCB
+       movpsl  -(sp)  # set up for return
+       bicl2   $PSL_IS|PSL_IPL,(sp)  #  undo SVPCTX
+       pushl   r1  #  ret loc
+       clrl    r0  #  return val
+       rei
+#
+#
+#  switch to another process's '_u' area - return val 1
+       .globl  _resume
+_resume :              #  resume(proc_addr,save_addr)
+       .word   0x0
+       mtpr    $HIGH,$IPL  # inhibit interrupts
+       ashl    $9,4(ap),r5  # proc byte addr
+                       #   area of proc argument
+       movl    8(ap),retloc
+       bsbw    setupu  #  set up '_sysmap' PTE's to map into '_u'
+       movl    _u,sp           # KSP from u-area
+       mtpr    r5,$PCBB
+       ldpctx
+       addl2   $8,sp           # clear ps,pc from stack
+       movl    retloc,r1  #  'ssav' or 'qsav' addr
+       movq    (r1)+,r6
+       movq    (r1)+,r8
+       movq    (r1)+,r10
+       movq    (r1)+,ap
+       movl    (r1)+,sp
+       movl    $1,r0  # return val
+       mtpr    $0,$IPL
+       jmp     *(r1)+  #  return to caller at 'save' address
+#
+       .data
+       .align  2
+retloc:        .space  1*4
+       .text
+
+
+# initialize u area page table entries
+
+setupu:
+       movl    (sp)+,r0                # get return pc
+       addl3   $PG_V|PG_KW,4(ap),r1    # first pt entry of user area
+       movab   usize(r1),r2    # one past last pt entry of user
+       movab   _Sysmap+u_ptoffset,r3   # addr for 1st user pt entry
+       movab   _u,r4
+       mtpr    r4,$TBIS        # invalidate old trans buffer entry
+       movl    r1,(r3)+        # store page table entry
+       addl2   _u+PCB_SZPT,r2  # add on size of user page table
+       brb     setulp1
+setulp:
+       mtpr    r4,$TBIS        # ivalidate page table entry
+       movl    r1,(r3)+        # store page table entry
+setulp1:
+       addl2   $512,r4
+       aoblss  r2,r1,setulp    # -> till done
+       jmp     (r0)            # funny return in case of changing stacks
+
+
+# disable interrupts
+_spl1: .globl  _spl1
+       .word   0x0000
+       mfpr    $IPL,r0         # get IPL value
+       mtpr    $2,$IPL         # disable RESCHED & AST interrupts
+       ret
+
+_spl4: .globl  _spl4
+       .word   0x0000
+       mfpr    $IPL,r0
+       mtpr    $0x14,$IPL              # disable bus level 4 interrupts
+       ret
+
+_spl5: .globl  _spl5
+       .word   0x0000
+       mfpr    $IPL,r0
+       mtpr    $0x15,$IPL              # disable bus level 5 interrupts
+       ret
+
+_spl6: .globl  _spl6
+_spl7: .globl  _spl7
+       .word   0x0000
+       mfpr    $IPL,r0
+       mtpr    $0x18,$IPL              # disable bus level 7 and clock interrupts
+       ret
+
+# enable interrupts
+_spl0: .globl  _spl0
+       .word   0x0000
+       mfpr    $IPL,r0
+       mtpr    $0,$IPL
+       ret
+
+# restore interrupt state
+_splx: .globl  _splx
+       .word   0x0000
+       mfpr    $IPL,r0
+       mtpr    4(ap),$IPL
+       ret
+
+#
+# Copy 1 relocation unit (512 bytes)
+# from one physical address to another
+_copyseg: .globl       _copyseg
+       .word   0x0000
+       mfpr    $IPL,r0         # get current pri level
+       mtpr    $HIGH,$IPL      # turn off interrupts
+       bisl3   $PG_V|PG_KR,4(ap),_Sysmap+CMAP1
+       bisl3   $PG_V|PG_KW,8(ap),_Sysmap+CMAP2
+       mtpr    $CADDR1,$TBIS   # invalidate entry for copy 
+       mtpr    $CADDR2,$TBIS
+       movc3   $512,CADDR1,CADDR2
+       mtpr    r0,$IPL # restore pri level
+       ret
+
+# zero out physical memory
+# specified in relocation units (512 bytes)
+_clearseg: .globl      _clearseg
+       .word   0x0000
+       mfpr    $IPL,r0         # get current pri level
+       mtpr    $HIGH,$IPL      # extreme pri level
+       bisl3   $PG_V|PG_KW,4(ap),_Sysmap+CMAP1
+       mtpr    $CADDR1,$TBIS
+       movc5   $0,(r0),$0,$512,CADDR1
+       mtpr    r0,$IPL         # restore pri level
+       ret
+
+# Check address
+# given virtual address, byte count, and rw flag
+#  returns 0 on no access
+_useracc:      .globl  _useracc
+       .word   0x0000
+       movl    4(ap),r0                # get va
+       movl    8(ap),r1                # count
+       tstl    12(ap)          # test for read access ?
+       bneq    userar  # yes
+       cmpl    $512,r1 # can we do it in one probe ?
+       bgeq    uaw2            # yes
+uaw1:
+       probew  $3,$512,(r0)
+       beql    uaerr           # no access
+       addl2   $512,r0
+       acbl    $513,$-512,r1,uaw1
+uaw2:
+       probew  $3,r1,(r0)
+       beql    uaerr
+       movl    $1,r0
+       ret
+
+userar:
+       cmpl    $512,r1
+       bgeq    uar2
+uar1:
+       prober  $3,$512,(r0)
+       beql    uaerr
+       addl2   $512,r0
+       acbl    $513,$-512,r1,uar1
+uar2:
+       prober  $3,r1,(r0)
+       beql    uaerr
+       movl    $1,r0
+       ret
+
+uaerr:
+       clrl    r0
+       ret
+
+#      kernacc
+#              check for kernal access privileges
+#
+
+       .globl  _kernacc
+_kernacc:
+       .word   0x0000
+
+       movl    4(ap),r0        # virtual address
+       bbcc    $31,r0,kacc1
+       mfpr    $SBR,r2 # address and length of page table (system)
+       mfpr    $SLR,r3
+       brb     kacc2
+kacc1:
+       bbsc    $30,r0,kacc3
+       mfpr    $P0BR,r2        # user P0
+       mfpr    $P0LR,r3
+       brb     kacc2
+kacc3:
+       mfpr    $P1BR,r2        # user P1 (stack)
+       mfpr    $P1LR,r3
+kacc2:
+       addl3   8(ap),r0,r1     # ending virtual address
+       ashl    $-9,r0,r0       # page number
+       ashl    $-9,r1,r1
+       bbc     $30,4(ap),kacc6
+       cmpl    r0,r3           # user stack
+       blss    kacerr          # address too low
+       brb     kacc4
+kacc6: cmpl    r1,r3           # compare last page to P0LR or SLR
+       bgeq    kacerr          # address too high
+kacc4: 
+       movl    (r2)[r0],r1
+       bbc     $31,r1,kacerr   # valid bit is off
+       cmpzv   $27,$4,r1,$1    # check protection code
+       bleq    kacerr          # no access allowed
+       tstb    12(ap)
+       bneq    kacc5           # only check read access
+       cmpzv   $27,$2,r1,$3    # check low 2 bits of prot code
+       beql    kacerr          # no write access
+kacc5:
+       aobleq  r1,r0,kacc4     # next page
+       movl    $1,r0           # no errors
+       ret
+kacerr:
+       clrl    r0              # error
+       ret
+
+# calculate physical address of user virtual address
+_realaddr:     .globl  _realaddr
+       .word   0x0000
+       movl    4(ap),r0        # virtual address
+       blss    raerr           # we don't map kernal virtual addresses
+       bbsc    $30,r0,rasseg           # stack segment address
+       mfpr    $P0BR,r1
+       mfpr    $P0LR,r2
+       ashl    $-9,r0,r3               # get page number
+       cmpl    r3,r2           # valid page number?
+       bgeq    raerr           # no
+ra1:
+       movl    (r1)[r3],r4     # get page table entry
+       bbc     $31,r4,raerr    # valid bit off - error
+       ashl    $9,r4,r5                # construct physical address
+       extzv   $0,$9,r0,r0             # offset within page
+       bisl2   r5,r0           # final physical address
+       ret
+rasseg:
+       mfpr    $P1BR,r1
+       mfpr    $P1LR,r2
+       ashl    $-9,r0,r3
+       cmpl    r3,r2
+       bgeq    ra1
+raerr:
+       clrl    r0
+       ret
+
+#
+#  unsigned int divide :
+#              (int) i = udiv( (int)dvdnd , (int) divis)
+#
+#  unsigned int remainder :
+#              (int) j = urem( (int)dvdnd , (int) divis)
+#
+       .text
+       .align  1
+       .globl  _udiv
+       .globl  _urem
+#
+_udiv :
+       .word   0  #  no reg save
+       movl    4(ap),r0  #  dividend
+       clrl    r1
+       ediv    8(ap),r0,r0,r1  #  quotient in r0
+       ret
+#
+       .align  1
+_urem :
+       .word   0
+       movl    4(ap),r0
+       clrl    r1
+       ediv    8(ap),r0,r1,r0  #  remainder in r0
+       ret
+# define user area virtual address
+       .set    physpages,1024
+       .set    kernsize,256     # number of page table entries allocated to kernal
+       .globl  _u
+       .set    usize,4         # size of user area, in pages
+       .set    _u,0x80000000 + kernsize*512
+       .set    u_ptoffset,256*4        # offset into _Sysmap of ptentries of _u
+       .set    CMAP1,u_ptoffset + 16*4 # offset into _Sysmap of 1st seg copy entry
+       .set    CMAP2,CMAP1+4   # ditto 2ed entry
+       .set    CADDR1,_u + 16*512      # virtual address of 1st copy segment
+       .set    CADDR2,CADDR1+512       # ditto second segment
+       .set    PHYSUBA,0x20006000      # real address of uba
+       .set    PHYSMBA0,0x20010000     # real addr of mba 0
+       .set    PHYSMBA1,0x20012000     # real addre of mba1
+       .set    PHYSUMEM,0x2013e000             # real address of unibus memory
+       .set    uba_offset,CMAP1+16*4   # offset in Sysmap of uba entries
+       .set    umem_offset,uba_offset+16*4     # ... unibus device registers
+       .set    mba0_offset,umem_offset+16*4    # ... massbus 0
+       .set    mba1_offset,mba0_offset+16*4    # ... massbus 1
+       .set    mba2_offset,mba1_offset+16*4    # ... massbus 2
+       .set    mba3_offset,mba2_offset+16*4    # ... massbus 3
+
+       .set    qsoff,0x140  #  offset to 'qsav' pcb in 'u' area
+       .set    ssoff,360       #offset to "ssav' in u_area
+
+
+#
+# Error messages
+#
+       .data
+
+emsg1:
+       .byte   0xa,0xa,0xa,0xd,0x54,0x52,0x41,0x50,0x20
+       .byte   0x46,0x52,0x4f,0x4d,0x20
+       .byte   0x4b,0x45,0x52,0x4e,0x41,0x4c,0x20
+       .byte   0x4d,0x4f,0x44,0x45,0xa,0xa,0xd,0x0
+
+emsg2:
+       .byte   0xa,0xa,0xa,0xd,0x54,0x52,0x41,0x50,0x20
+       .byte   0x52,0x45,0x54,0x55,0x52,0x4e,0x20
+       .byte   0x44,0x4f,0x20
+       .byte   0x4b,0x45,0x52,0x4e,0x41,0x4c,0x20
+       .byte   0x4d,0x4f,0x44,0x45,0xa,0xa,0xd,0x0
+
+SBImsg :
+       .byte   'S,'B,'I,' ,'f,'a,'u,'l,'t,' ,012,0
+UBAmsg :
+       .byte   'U,'B,'A,' ,'e,'r,'r,'o,'r,' ,'%,'x,012,0
+ZERmsg :
+       .byte   'Z,'e,'r,'o,' ,'V,'e,'c,'t,'o,'r,012,0
+#
+#      _Sysmap:
+#              system page table
+#
+#      structure:
+#              2 pages of page table entries
+#                      reserved for kernal text and data.
+#              1 additional page of page table entries
+#                      used in mapping the u area (16 entries),
+#                      utility entries (16 entries),
+#                      unibus adapter (16 entries),
+#                      unibus device memory (16 entries),
+#                      massbus adapter 0 (16 entries),
+#                      massbus adapter 1 (16 entries),
+#                      massbus adapter 2 (16 entries),
+#                      massbus adapter 3 (16 entries).
+#
+#
+
+       .align  2
+       .globl  _Sysmap
+_Sysmap:
+       .space  3*128*4         # 3 pages of page table entries for kernal
+       .set    Syssize,3*128           # number pt entries in sys page table
diff --git a/usr/src/slowsys/sys/machdep.c b/usr/src/slowsys/sys/machdep.c
new file mode 100644 (file)
index 0000000..c49822a
--- /dev/null
@@ -0,0 +1,185 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/acct.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/inode.h"
+#include "../h/proc.h"
+#include "../h/seg.h"
+#include "../h/uba.h"
+#include "../h/map.h"
+#include "../h/reg.h"
+#include "../h/mtpr.h"
+#include "../h/clock.h"
+#include "../h/buf.h"
+
+long   icode[] =
+{
+       0x9f19af9f,     /* pushab [&"init",0]; pushab */
+       0x02dd09af,     /* "/etc/init"; pushl $2 */
+       0xbc5c5ed0,     /* movl sp,ap; chmk */
+       0x2ffe110b,     /* $exec; brb .; "/ */
+       0x2f637465,     /* etc/ */
+       0x74696e69,     /* init */
+       0x00000000,     /* ";  0 */
+       0x00000014,     /* [&"init", */
+       0x00000000,     /* 0] */
+};
+int    szicode = sizeof(icode);
+/*
+ * Machine-dependent startup code
+ */
+startup(firstaddr)
+{
+       /*
+        * zero and free all of core
+        */
+
+       printf("real mem  = %d\n", maxmem*ctob(1) );
+       maxmem -= (firstaddr+USIZE);
+       mfree(coremap, maxmem, firstaddr+USIZE);
+       printf("avail mem = %d\n", maxmem*ctob(1));
+       if(MAXMEM < maxmem)
+               maxmem = MAXMEM;
+       mfree(swapmap, nswap, 1);
+       swplo--;
+       mbainit();              /* setup mba mapping regs map */
+       ubainit();              /* setup uba mapping regs map */
+}
+
+/*
+ * set up a physical address
+ * into users virtual address space.
+ */
+sysphys()
+{
+       register i, s, d;
+
+       if(!suser())
+               return;
+       u.u_error = EINVAL;
+}
+
+/*
+ * Start clock
+ */
+clkstart()
+{
+       mtpr(NICR, -16667);     /* 16.667 milli-seconds */
+       mtpr(ICCS,ICCS_RUN+ICCS_IE+ICCS_TRANS+ICCS_INT+ICCS_ERR);
+}
+
+clkreld()
+{
+       mtpr(ICCS, ICCS_RUN + ICCS_IE +ICCS_INT + ICCS_ERR);
+}
+
+
+/*
+ * Send an interrupt to process
+ */
+sendsig(p, n)
+{
+       register int *usp, *regs;
+       register int mask, r, spa, t;
+       int *s;
+
+       regs = u.u_ar0;
+       usp = (int *)regs[SP];
+       grow((unsigned)(usp-20));
+       mask = (fuword(p) & 0xfff) | 0x3f; /* get register save mask (save r0-r5) */
+       suword( (caddr_t) --usp, n);    /* sig # as param */
+       suword( (caddr_t) --usp, 1);    /* one parameters */
+       s = usp;
+       spa = ((int) usp) & 0x3;
+       if (spa) usp = (int *)((int) (usp - 1) & ~ 0x3);
+       t = 11;
+       for (r=0x800; r; r>>=1)
+               {
+               if (mask & r) suword((caddr_t) --usp, regs[t]);
+               t--;
+               }
+       suword( (caddr_t) --usp, regs[PC]);
+       suword( (caddr_t) --usp, regs[FP]);
+       suword( (caddr_t) --usp, regs[AP]);
+       suword( (caddr_t) --usp, (spa << 30) | (0x2 << 28)
+                               | (mask << 16) | (regs[PS] & 0xfff1));
+       suword( (caddr_t) --usp, 0);
+
+       regs[SP] = (int)usp;
+       regs[FP] = (int)usp;
+       regs[AP] = (int)s;
+       regs[PC] = p + 2;
+       regs[PS] &= ~ 0x1f;
+}
+
+caddr_t
+checkio(rw)
+register rw;
+{
+       register caddr_t realbase;
+
+       rw = ! rw;                      /* read disk => write core */
+       realbase = realaddr(u.u_base, rw, 3);           /* calculate physical address */
+       if (realbase == NULL)
+               goto bad;
+       if( useracc(u.u_base, u.u_count, rw))
+               return(realbase);
+    bad:
+       u.u_error = EFAULT;
+       return(NULL);
+}
+
+mtpr(regno, value)
+{
+       asm("   mtpr    8(ap),4(ap)");
+}
+
+mfpr(regno)
+{
+       asm("   mfpr    4(ap),r0");
+}
+
+/*
+ * Copy bytes within kernel
+ */
+bcopy(from,to,count)
+{
+       asm("   movc3   12(ap),*4(ap),*8(ap)");
+}
+
+/*
+ * Add a long word to a quad word
+ */
+add64(increment,lowtotal,hitotal)
+{
+       asm("   addl2   4(ap),*8(ap)");
+       asm("   adwc    $0,*12(ap)");
+}
+/*
+*  UNIBUS Address Space <-->  User Space transfer
+*/
+UNIcpy(uniadd,usradd,bknt,direct)
+short *uniadd , *usradd;
+{
+register short *from , *to;
+register int i;
+if (direct == B_READ) {
+       from = uniadd;
+       to = usradd ;
+       }
+else {
+       if (direct == B_WRITE) {
+               from = usradd;
+               to = uniadd ;
+               }
+       }
+for (i = (bknt>>1) ; i>0 ; i--)
+       (*to++) = (*from++);
+return(0);
+}
diff --git a/usr/src/slowsys/sys/main.c b/usr/src/slowsys/sys/main.c
new file mode 100644 (file)
index 0000000..5427cd3
--- /dev/null
@@ -0,0 +1,168 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/filsys.h"
+#include "../h/mount.h"
+#include "../h/uba.h"
+#include "../h/map.h"
+#include "../h/proc.h"
+#include "../h/inode.h"
+#include "../h/seg.h"
+#include "../h/conf.h"
+#include "../h/buf.h"
+#include "../h/mtpr.h"
+#include "../h/page.h"
+# include "../h/clock.h"
+
+
+/*
+ * Initialization code.
+ * Called from cold start routine as
+ * soon as a stack and segmentation
+ * have been established.
+ * Functions:
+ *     clear and free user core
+ *     turn on clock
+ *     hand craft 0th process
+ *     call all initialization routines
+ *     fork - process 0 to schedule
+ *          - process 1 execute bootstrap
+ *
+ * loop at loc 13 (0xd) in user mode -- /etc/init
+ *     cannot be executed.
+ */
+main(firstaddr)
+{
+
+       startup(firstaddr);
+
+       /*
+        * set up system process
+        */
+
+       proc[0].p_addr = firstaddr;
+       proc[0].p_size = USIZE;
+       proc[0].p_stat = SRUN;
+       proc[0].p_flag |= SLOAD|SSYS;
+       proc[0].p_nice = NZERO;
+       u.u_procp = &proc[0];
+       u.u_cmask = CMASK;
+       estabur(0, 0, 0, 0, 0);
+       clkstart();
+
+       /*
+        * Initialize devices and
+        * set up 'known' i-nodes
+        */
+
+       cinit();
+       binit();
+       iinit();
+       rootdir = iget(rootdev, (ino_t)ROOTINO);
+       rootdir->i_flag &= ~ILOCK;
+       u.u_cdir = iget(rootdev, (ino_t)ROOTINO);
+       u.u_cdir->i_flag &= ~ILOCK;
+       u.u_rdir = NULL;
+
+       /*
+        * make init process
+        * enter scheduling loop
+        * with system process
+        */
+
+       if(newproc()) {
+               expand(USIZE + btoc(szicode));
+               u.u_dsize = btoc(szicode);
+               estabur(0, btoc(szicode), 0, 0, RO);
+               copyout((caddr_t)icode, (caddr_t)0, szicode);
+               /*
+                * Return goes to loc. 0 of user init
+                * code just copied out.
+                */
+               return;
+       }
+       sched();
+}
+
+/*
+ * iinit is called once (from main)
+ * very early in initialization.
+ * It reads the root's super block
+ * and initializes the current date
+ * from the last modified date.
+ *
+ * panic: iinit -- cannot read the super
+ * block. Usually because of an IO error.
+ */
+iinit()
+{
+       register struct buf *cp, *bp;
+       register struct filsys *fp;
+       register unsigned i , j ;
+
+       (*bdevsw[major(rootdev)].d_open)(rootdev, 1);
+       bp = bread(rootdev, SUPERB);
+       cp = geteblk();
+       if(u.u_error)
+               panic("iinit");
+       bcopy(bp->b_un.b_addr, cp->b_un.b_addr, sizeof(struct filsys));
+       brelse(bp);
+       mount[0].m_bufp = cp;
+       mount[0].m_dev = rootdev;
+       fp = cp->b_un.b_filsys;
+       fp->s_flock = 0;
+       fp->s_ilock = 0;
+       fp->s_ronly = 0;
+       /* on boot, read VAX TODR register (GMT 10 ms.
+       *       clicks into current year) and set software time
+       *       in 'int time' (GMT seconds since year YRREF)
+       */
+       for (i = 0 , j = YRREF ; j < YRCURR ; j++)
+               i += (SECYR + (j%4?0:SECDAY)) ;
+       time = udiv(mfpr(TODR),100) + i ;
+}
+
+/*
+ * This is the set of buffers proper, whose heads
+ * were declared in buf.h.  There can exist buffer
+ * headers not pointing here that are used purely
+ * as arguments to the I/O routines to describe
+ * I/O to be done-- e.g. swbuf for
+ * swapping.
+ */
+char   buffers[NBUF][BSIZE+BSLOP];
+
+/*
+ * Initialize the buffer I/O system by freeing
+ * all buffers and setting all device buffer lists to empty.
+ */
+binit()
+{
+       register struct buf *bp;
+       register struct buf *dp;
+       register int i;
+       struct bdevsw *bdp;
+
+       bfreelist.b_forw = bfreelist.b_back =
+           bfreelist.av_forw = bfreelist.av_back = &bfreelist;
+       for (i=0; i<NBUF; i++) {
+               bp = &buf[i];
+               bp->b_dev = NODEV;
+               bp->b_un.b_addr = buffers[i];
+               bp->b_back = &bfreelist;
+               bp->b_forw = bfreelist.b_forw;
+               bfreelist.b_forw->b_back = bp;
+               bfreelist.b_forw = bp;
+               bp->b_flags = B_BUSY;
+               brelse(bp);
+       }
+       for (bdp = bdevsw; bdp->d_open; bdp++) {
+               dp = bdp->d_tab;
+               if(dp) {
+                       dp->b_forw = dp;
+                       dp->b_back = dp;
+               }
+               nblkdev++;
+       }
+}
diff --git a/usr/src/slowsys/sys/makefile b/usr/src/slowsys/sys/makefile
new file mode 100644 (file)
index 0000000..5972d18
--- /dev/null
@@ -0,0 +1,410 @@
+CFLAGS=-O
+AHEADS = ../h/mtpr.m ../h/trap.m ../h/psl.m ../h/pcb.m ../h/clock.m \
+               ../h/cons.m ../h/page.m ../h/mba.m ../h/uba.m
+FILES=\
+locore.o \
+acct.o \
+alloc.o \
+bio.o \
+clock.o \
+conf.o \
+cons.o \
+dkleave.o \
+dsort.o \
+dz.o \
+fio.o \
+hp.o \
+ht.o \
+iget.o \
+machdep.o \
+main.o \
+malloc.o \
+mba.o \
+mem.o \
+mx1.o \
+mx2.o \
+nami.o \
+partab.o \
+pipe.o \
+prf.o \
+prim.o \
+rdwri.o \
+sig.o \
+slp.o \
+subr.o \
+sys.o \
+sys1.o \
+sys2.o \
+sys3.o \
+sys4.o \
+sysent.o \
+tdump.o \
+text.o \
+trap.o \
+tty.o \
+uba.o \
+univec.o \
+ureg.o 
+
+
+unix: $(FILES)
+       sh loadall
+
+
+dz.o hp.o ht.o mba.o tdump.o uba.o:
+       cc -c -S $*.c
+       /lib/c2 -i $*.s $*.os
+       as -o $*.o $*.os
+       rm $*.s $*.os
+
+locore.o: $(AHEADS)
+       cat $(AHEADS) locore.s | as -o locore.o
+
+
+acct.o:../h/param.h
+acct.o:../h/systm.h
+acct.o:../h/acct.h
+acct.o:../h/dir.h
+acct.o:../h/user.h
+acct.o:../h/inode.h
+acct.o:../h/proc.h
+acct.o:../h/seg.h
+alloc.o:../h/param.h
+alloc.o:../h/systm.h
+alloc.o:../h/mount.h
+alloc.o:../h/filsys.h
+alloc.o:../h/fblk.h
+alloc.o:../h/conf.h
+alloc.o:../h/buf.h
+alloc.o:../h/inode.h
+alloc.o:../h/ino.h
+alloc.o:../h/dir.h
+alloc.o:../h/user.h
+bio.o:../h/param.h
+bio.o:../h/systm.h
+bio.o:../h/dir.h
+bio.o:../h/user.h
+bio.o:../h/buf.h
+bio.o:../h/conf.h
+bio.o:../h/proc.h
+bio.o:../h/seg.h
+clock.o:../h/param.h
+clock.o:../h/systm.h
+clock.o:../h/callo.h
+clock.o:../h/seg.h
+clock.o:../h/dir.h
+clock.o:../h/user.h
+clock.o:../h/proc.h
+clock.o:../h/reg.h
+clock.o:../h/psl.h
+conf.o:../h/param.h
+conf.o:../h/systm.h
+conf.o:../h/buf.h
+conf.o:../h/tty.h
+conf.o:../h/conf.h
+conf.o:../h/proc.h
+conf.o:../h/text.h
+conf.o:../h/dir.h
+conf.o:../h/user.h
+conf.o:../h/file.h
+conf.o:../h/inode.h
+conf.o:../h/acct.h
+conf.o:../h/mba.h
+cons.o:../h/param.h
+cons.o:../h/conf.h
+cons.o:../h/dir.h
+cons.o:../h/user.h
+cons.o:../h/tty.h
+cons.o:../h/systm.h
+cons.o:../h/cons.h
+cons.o:../h/mtpr.h
+dkleave.o:../h/param.h
+dkleave.o:../h/buf.h
+dsort.o:../h/param.h
+dsort.o:../h/systm.h
+dsort.o:../h/buf.h
+dz.o:../h/param.h
+dz.o:../h/tty.h
+dz.o:../h/uba.h
+dz.o:../h/proc.h
+dz.o:../h/dir.h
+dz.o:../h/file.h
+dz.o:../h/inode.h
+dz.o:../h/user.h
+dz.o:../h/conf.h
+fio.o:../h/param.h
+fio.o:../h/systm.h
+fio.o:../h/dir.h
+fio.o:../h/user.h
+fio.o:../h/filsys.h
+fio.o:../h/file.h
+fio.o:../h/conf.h
+fio.o:../h/inode.h
+fio.o:../h/reg.h
+fio.o:../h/acct.h
+hp.o:../h/param.h
+hp.o:../h/uba.h
+hp.o:../h/systm.h
+hp.o:../h/buf.h
+hp.o:../h/conf.h
+hp.o:../h/dir.h
+hp.o:../h/user.h
+hp.o:../h/map.h
+hp.o:../h/mba.h
+ht.o:../h/param.h
+ht.o:../h/systm.h
+ht.o:../h/buf.h
+ht.o:../h/conf.h
+ht.o:../h/dir.h
+ht.o:../h/user.h
+ht.o:../h/uba.h
+ht.o:../h/map.h
+ht.o:../h/mba.h
+iget.o:../h/param.h
+iget.o:../h/systm.h
+iget.o:../h/mount.h
+iget.o:../h/dir.h
+iget.o:../h/user.h
+iget.o:../h/inode.h
+iget.o:../h/ino.h
+iget.o:../h/filsys.h
+iget.o:../h/conf.h
+iget.o:../h/buf.h
+machdep.o:../h/param.h
+machdep.o:../h/systm.h
+machdep.o:../h/acct.h
+machdep.o:../h/dir.h
+machdep.o:../h/user.h
+machdep.o:../h/inode.h
+machdep.o:../h/proc.h
+machdep.o:../h/seg.h
+machdep.o:../h/uba.h
+machdep.o:../h/map.h
+machdep.o:../h/reg.h
+machdep.o:../h/mtpr.h
+machdep.o:../h/clock.h
+main.o:../h/param.h
+main.o:../h/systm.h
+main.o:../h/dir.h
+main.o:../h/user.h
+main.o:../h/filsys.h
+main.o:../h/mount.h
+main.o:../h/uba.h
+main.o:../h/map.h
+main.o:../h/proc.h
+main.o:../h/inode.h
+main.o:../h/seg.h
+main.o:../h/conf.h
+main.o:../h/buf.h
+main.o:../h/mtpr.h
+main.o:../h/page.h
+main.o:../h/clock.h
+malloc.o:../h/param.h
+malloc.o:../h/systm.h
+malloc.o:../h/uba.h
+malloc.o:../h/map.h
+mba.o:../h/param.h
+mba.o:../h/buf.h
+mba.o:../h/conf.h
+mba.o:../h/systm.h
+mba.o:../h/dir.h
+mba.o:../h/user.h
+mba.o:../h/proc.h
+mba.o:../h/seg.h
+mba.o:../h/page.h
+mba.o:../h/uba.h
+mba.o:../h/map.h
+mba.o:../h/mba.h
+mba.o:../h/mtpr.h
+mem.o:../h/param.h
+mem.o:../h/dir.h
+mem.o:../h/user.h
+mem.o:../h/conf.h
+mem.o:../h/buf.h
+mem.o:../h/systm.h
+mem.o:../h/page.h
+mem.o:../h/mtpr.h
+mx1.o:../h/param.h
+mx1.o:../h/systm.h
+mx1.o:../h/dir.h
+mx1.o:../h/user.h
+mx1.o:../h/reg.h
+mx1.o:../h/proc.h
+mx1.o:../h/inode.h
+mx1.o:../h/file.h
+mx1.o:../h/tty.h
+mx1.o:../h/mx.h
+mx1.o:../h/conf.h
+mx2.o:../h/param.h
+mx2.o:../h/systm.h
+mx2.o:../h/dir.h
+mx2.o:../h/user.h
+mx2.o:../h/proc.h
+mx2.o:../h/inode.h
+mx2.o:../h/file.h
+mx2.o:../h/tty.h
+mx2.o:../h/mx.h
+mx2.o:../h/conf.h
+mx2.o:../h/buf.h
+nami.o:../h/param.h
+nami.o:../h/systm.h
+nami.o:../h/inode.h
+nami.o:../h/mount.h
+nami.o:../h/dir.h
+nami.o:../h/user.h
+nami.o:../h/buf.h
+pipe.o:../h/param.h
+pipe.o:../h/systm.h
+pipe.o:../h/dir.h
+pipe.o:../h/user.h
+pipe.o:../h/inode.h
+pipe.o:../h/file.h
+pipe.o:../h/reg.h
+prf.o:../h/param.h
+prf.o:../h/systm.h
+prf.o:../h/seg.h
+prf.o:../h/buf.h
+prf.o:../h/conf.h
+prim.o:../h/param.h
+prim.o:../h/tty.h
+prim.o:../h/systm.h
+prim.o:../h/conf.h
+prim.o:../h/buf.h
+rdwri.o:../h/param.h
+rdwri.o:../h/systm.h
+rdwri.o:../h/inode.h
+rdwri.o:../h/dir.h
+rdwri.o:../h/user.h
+rdwri.o:../h/buf.h
+rdwri.o:../h/conf.h
+sig.o:../h/param.h
+sig.o:../h/systm.h
+sig.o:../h/dir.h
+sig.o:../h/user.h
+sig.o:../h/proc.h
+sig.o:../h/inode.h
+sig.o:../h/reg.h
+sig.o:../h/text.h
+sig.o:../h/seg.h
+sig.o:../h/mtpr.h
+sig.o:../h/page.h
+slp.o:../h/param.h
+slp.o:../h/systm.h
+slp.o:../h/dir.h
+slp.o:../h/user.h
+slp.o:../h/proc.h
+slp.o:../h/text.h
+slp.o:../h/uba.h
+slp.o:../h/map.h
+slp.o:../h/file.h
+slp.o:../h/inode.h
+slp.o:../h/buf.h
+subr.o:../h/param.h
+subr.o:../h/systm.h
+subr.o:../h/conf.h
+subr.o:../h/inode.h
+subr.o:../h/dir.h
+subr.o:../h/user.h
+subr.o:../h/buf.h
+sys.o:../h/param.h
+sys.o:../h/conf.h
+sys.o:../h/dir.h
+sys.o:../h/user.h
+sys.o:../h/tty.h
+sys.o:../h/proc.h
+sys1.o:../h/param.h
+sys1.o:../h/systm.h
+sys1.o:../h/uba.h
+sys1.o:../h/map.h
+sys1.o:../h/dir.h
+sys1.o:../h/user.h
+sys1.o:../h/proc.h
+sys1.o:../h/buf.h
+sys1.o:../h/reg.h
+sys1.o:../h/inode.h
+sys1.o:../h/seg.h
+sys1.o:../h/acct.h
+sys1.o:../h/page.h
+sys2.o:../h/param.h
+sys2.o:../h/systm.h
+sys2.o:../h/dir.h
+sys2.o:../h/user.h
+sys2.o:../h/reg.h
+sys2.o:../h/file.h
+sys2.o:../h/inode.h
+sys3.o:../h/param.h
+sys3.o:../h/systm.h
+sys3.o:../h/mount.h
+sys3.o:../h/ino.h
+sys3.o:../h/reg.h
+sys3.o:../h/buf.h
+sys3.o:../h/filsys.h
+sys3.o:../h/dir.h
+sys3.o:../h/user.h
+sys3.o:../h/inode.h
+sys3.o:../h/file.h
+sys3.o:../h/conf.h
+sys3.o:../h/stat.h
+sys4.o:../h/param.h
+sys4.o:../h/systm.h
+sys4.o:../h/dir.h
+sys4.o:../h/user.h
+sys4.o:../h/reg.h
+sys4.o:../h/inode.h
+sys4.o:../h/proc.h
+sys4.o:../h/clock.h
+sys4.o:../h/mtpr.h
+sys4.o:../h/timeb.h
+sysent.o:../h/param.h
+sysent.o:../h/systm.h
+text.o:../h/param.h
+text.o:../h/systm.h
+text.o:../h/uba.h
+text.o:../h/map.h
+text.o:../h/dir.h
+text.o:../h/user.h
+text.o:../h/proc.h
+text.o:../h/text.h
+text.o:../h/inode.h
+text.o:../h/buf.h
+text.o:../h/seg.h
+text.o:../h/page.h
+trap.o:../h/param.h
+trap.o:../h/systm.h
+trap.o:../h/dir.h
+trap.o:../h/user.h
+trap.o:../h/proc.h
+trap.o:../h/reg.h
+trap.o:../h/seg.h
+trap.o:../h/trap.h
+trap.o:../h/psl.h
+tty.o:../h/param.h
+tty.o:../h/systm.h
+tty.o:../h/dir.h
+tty.o:../h/user.h
+tty.o:../h/tty.h
+tty.o:../h/proc.h
+tty.o:../h/chan.h
+tty.o:../h/inode.h
+tty.o:../h/file.h
+tty.o:../h/reg.h
+tty.o:../h/conf.h
+uba.o:../h/param.h
+uba.o:../h/uba.h
+uba.o:../h/map.h
+univec.o:../h/param.h
+ureg.o:../h/param.h
+ureg.o:../h/systm.h
+ureg.o:../h/dir.h
+ureg.o:../h/user.h
+ureg.o:../h/proc.h
+ureg.o:../h/text.h
+ureg.o:../h/seg.h
+ureg.o:../h/mtpr.h
+ureg.o:../h/page.h
+v45lnk.o:../h/param.h
+v45lnk.o:../h/dir.h
+v45lnk.o:../h/user.h
+v45lnk.o:../h/proc.h
+v45lnk.o:../h/uba.h
+v45lnk.o:../h/buf.h
diff --git a/usr/src/slowsys/sys/malloc.c b/usr/src/slowsys/sys/malloc.c
new file mode 100644 (file)
index 0000000..af71008
--- /dev/null
@@ -0,0 +1,81 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/uba.h"
+#include "../h/map.h"
+
+/*
+ * Allocate 'size' units from the given
+ * map. Return the base of the allocated
+ * space.
+ * In a map, the addresses are increasing and the
+ * list is terminated by a 0 size.
+ * The core map unit is 512 bytes; the swap map unit
+ * is 512 bytes.
+ * Algorithm is first-fit.
+ */
+malloc(mp, size)
+struct map *mp;
+{
+       register unsigned int a;
+       register struct map *bp;
+
+       for (bp=mp; bp->m_size; bp++) {
+               if (bp->m_size >= size) {
+                       a = bp->m_addr;
+                       bp->m_addr += size;
+                       if ((bp->m_size -= size) == 0) {
+                               do {
+                                       bp++;
+                                       (bp-1)->m_addr = bp->m_addr;
+                               } while ((bp-1)->m_size = bp->m_size);
+                       }
+                       return(a);
+               }
+       }
+       return(0);
+}
+
+/*
+ * Free the previously allocated space aa
+ * of size units into the specified map.
+ * Sort aa into map and combine on
+ * one or both ends if possible.
+ */
+mfree(mp, size, a)
+struct map *mp;
+register unsigned int a;
+{
+       register struct map *bp;
+       register unsigned int t;
+
+       if ((bp = mp)==coremap && runin) {
+               runin = 0;
+               wakeup((caddr_t)&runin);        /* Wake scheduler when freeing core */
+       }
+       for (; bp->m_addr<=a && bp->m_size!=0; bp++);
+       if (bp>mp && (bp-1)->m_addr+(bp-1)->m_size == a) {
+               (bp-1)->m_size += size;
+               if (a+size == bp->m_addr) {
+                       (bp-1)->m_size += bp->m_size;
+                       while (bp->m_size) {
+                               bp++;
+                               (bp-1)->m_addr = bp->m_addr;
+                               (bp-1)->m_size = bp->m_size;
+                       }
+               }
+       } else {
+               if (a+size == bp->m_addr && bp->m_size) {
+                       bp->m_addr -= size;
+                       bp->m_size += size;
+               } else if (size) {
+                       do {
+                               t = bp->m_addr;
+                               bp->m_addr = a;
+                               a = t;
+                               t = bp->m_size;
+                               bp->m_size = size;
+                               bp++;
+                       } while (size = t);
+               }
+       }
+}
diff --git a/usr/src/slowsys/sys/mba.c b/usr/src/slowsys/sys/mba.c
new file mode 100644 (file)
index 0000000..a1b00ac
--- /dev/null
@@ -0,0 +1,79 @@
+#
+/*
+ */
+
+#include "../h/param.h"
+#include "../h/buf.h"
+#include "../h/conf.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/proc.h"
+#include "../h/seg.h"
+#include "../h/page.h"
+#include "../h/uba.h"
+#include "../h/map.h"
+#include "../h/mba.h"
+#include "../h/mtpr.h"
+
+/*
+ * startup routine for MBA controllers.
+ */
+#define        MBAWCOM 0x30
+#define        MBARCOM 0x38
+#define        GO      01
+
+int mbaboff;
+
+mbastart(bp, adcr)
+register struct buf *bp;
+int *adcr;
+{
+       register int vaddr, com, *io, num;
+       register struct mba_regs *mbap;
+       int *pt, pf;
+       extern int mbanum[], *mbaloc[];
+       extern char buffers[][];
+
+       mbap = (struct mba_regs *)(mbaloc[mbanum[major(bp->b_dev)]]);
+       if ( (bp->b_flags & B_PHYS) == 0 ) {
+               vaddr = (bp->b_un.b_addr - (char *)buffers) + mbaboff;
+       } else {
+               io = (int *)mbap;
+               io += (MBA_MAP + 128*4)/4;
+               num = btoc(bp->b_bcount) + 1;
+               pf = (int)bp->b_un.b_addr >> 9;
+               while ( num-->0)
+                       *io++ = 0x80000000 | pf++;
+               vaddr = (128 << 9) | ((int)bp->b_un.b_addr & 0x1ff);
+       }
+       mbap->mba_sr = -1;      /* clear status (error) bits */
+       mbap->mba_bcr = -bp->b_bcount;
+       mbap->mba_var = vaddr;
+       if (bp->b_flags & B_READ)
+               com = MBARCOM | GO;
+       else
+               com = MBAWCOM | GO;
+
+       *adcr = com;            /* set cmd in device control and status register */
+}
+
+mbainit()
+{
+       register int *io0, *io1, *b, t, j;
+       extern int Sysmap[], *mbaloc[];
+       extern char buffers[][];
+
+       io0 = mbaloc[0] + (MBA_MAP/4);
+       io1 = mbaloc[1] + (MBA_MAP/4);
+       b = Sysmap + ((((int) buffers)>>9)&0x1fffff);
+       j = NBUF + ((int)buffers & 0x1ff ? 1 : 0);
+       do {
+               t = 0x80000000 | (*b++ & 0x1fffff);
+               *io0++ = t;
+               *io1++ = t;
+       } while (--j>0);
+       *io0 = 0;               /* invalidate next entry */
+       *io1 = 0;
+       mbaboff = (int)buffers & 0x1ff;
+}
diff --git a/usr/src/slowsys/sys/mem.c b/usr/src/slowsys/sys/mem.c
new file mode 100644 (file)
index 0000000..a2b8137
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ *     Memory special file
+ *     minor device 0 is physical memory
+ *     minor device 1 is kernel memory 
+ *     minor device 2 is EOF/RATHOLE
+ */
+
+#include "../h/param.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/conf.h"
+#include "../h/buf.h"
+#include "../h/systm.h"
+#include "../h/page.h"
+#include "../h/mtpr.h"
+
+int mmapinuse, mmapwant;
+
+mmread(dev)
+{
+       register char *p;
+       register c;
+       extern int *mmap;
+       extern char *vmmap;
+
+       if(minor(dev) == 2)
+               return;
+       if( minor(dev) == 1 ) {
+               if( kernacc(u.u_offset, u.u_count, B_READ)
+           && !copyout(u.u_offset, u.u_base, u.u_count) ) {
+               c = u.u_count;
+               u.u_count = 0;
+               u.u_base += c;
+               u.u_offset += c;
+       } else 
+               u.u_error = EFAULT;
+       return;
+       }
+
+       if( minor(dev) == 0) {
+
+               spl7();
+               while( mmapinuse ) {
+                       mmapwant++;
+                       sleep(&mmapwant, PRIBIO);
+               }
+               mmapinuse = 1;
+               spl0();
+               while (u.u_count > 0 && u.u_error == 0) {
+                       c = (int) u.u_offset >> 9;
+                       if( c < 0 || c > PHYSPAGES ) {
+                               u.u_error = EFAULT;
+                               break;
+                       }
+                       *mmap = c | (PG_V | PG_KR);
+                       mtpr(TBIS, vmmap);
+                       copyout(vmmap+((int)u.u_offset & 0x1ff), u.u_base, c=min(512-((int)u.u_offset & 0x1ff), u.u_count));
+                       u.u_count -= c;
+                       u.u_base += c;
+                       u.u_offset += c;
+               }
+               spl7();
+               mmapinuse = 0;
+               if( mmapwant ) {
+                       mmapwant = 0;
+                       wakeup( &mmapwant );
+               }
+               spl0();
+       return;
+       }
+if (minor(dev) == 3) { /* UNIBUS access */
+       if ((!kernacc(u.u_offset,u.u_count,B_READ)) ||
+       (!useracc(u.u_base,u.u_count,B_READ)) ||
+       UNIcpy(u.u_offset,u.u_base,u.u_count,B_READ))
+               u.u_error = EFAULT;
+       else {
+               u.u_offset += u.u_count;
+               u.u_base += u.u_count;
+               u.u_count = 0;
+               }
+       return;
+       }
+}
+
+mmwrite(dev)
+{
+       register char *p;
+       register c;
+
+       if(minor(dev) == 2) {
+               c = u.u_count;
+               u.u_count = 0;
+               u.u_offset += c;
+               return;
+       }
+       /*  kernel virt mem */
+       if (minor(dev) == 1) {
+               if ((!kernacc(u.u_offset,u.u_count,B_WRITE)) || copyin(u.u_base,u.u_offset,u.u_count))
+                       u.u_error = EFAULT;
+               else {
+                       u.u_offset += u.u_count;
+                       u.u_base += u.u_count;
+                       u.u_count = 0 ;
+                       }
+               return;
+               }
+       if (minor(dev) == 3) { /* UNIBUS access */
+               if ((!kernacc(u.u_offset,u.u_count,B_WRITE)) ||
+               (!useracc(u.u_base,u.u_count,B_WRITE)) ||
+               UNIcpy(u.u_offset,u.u_base,u.u_count,B_WRITE))
+                       u.u_error = EFAULT;
+               else {
+                       u.u_offset += u.u_count;
+                       u.u_base += u.u_count;
+                       u.u_count = 0;
+                       }
+               return;
+               }
+}
diff --git a/usr/src/slowsys/sys/mx1.c b/usr/src/slowsys/sys/mx1.c
new file mode 100644 (file)
index 0000000..657389f
--- /dev/null
@@ -0,0 +1,363 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/reg.h"
+#include "../h/proc.h"
+#include "../h/tty.h"
+#include "../h/inode.h"
+#include "../h/mx.h"
+#include "../h/file.h"
+#include "../h/conf.h"
+
+struct chan    chans[NCHANS];
+struct group   *groups[NGROUPS];
+int    mpxline;
+struct chan *xcp();
+dev_t  mpxdev  = -1;
+
+
+char   mcdebugs[NDEBUGS];
+
+
+struct chan *
+challoc(index)
+register index;
+{
+register s;
+register struct chan *cp;
+
+       s = spl6();
+       for(cp=chans; cp< &chans[NCHANS]; cp++)
+               if(cp->c_group==NULL) {
+                       cp->c_index = index;
+                       cp->c_pgrp = 0;
+                       splx(s);
+                       return(cp);
+               }
+       splx(s);
+       return(NULL);
+}
+
+
+gpalloc()
+{
+register i,s;
+
+       s = spl6();
+       for(i = NGROUPS-1; i>=0; i--)
+               if (groups[i]==NULL) {
+                       groups[i]++;
+                       break;
+               }
+       splx(s);
+       return(i);
+}
+
+struct chan *
+addch(ip)
+struct inode *ip;
+{
+register struct chan *cp;
+register struct group *gp;
+register i;
+
+       plock(ip);
+       gp = &ip->i_un.i_group;
+       for(i=0;i<NINDEX;i++) {
+               cp = (struct chan *)gp->g_chans[i];
+               if (cp == NULL) {
+                       if ((cp=challoc(i)) != NULL) {
+                               gp->g_chans[i] = cp;
+                               cp->c_group = gp;
+                       }
+                       break;
+               }
+               cp = NULL;
+       }
+       prele(ip);
+       return(cp);
+}
+
+
+
+
+/*
+ * mpxchan system call
+ */
+mpxchan()
+{
+struct inode *ip,*gip;
+register int i;
+extern mxopen(), mcread();
+extern struct chan *addch();
+dev_t  dev;
+struct tty *tp;
+struct file *fp,*chfp,*gfp;
+struct chan *cp;
+struct group *gp;
+
+       /*
+        * common setup code.
+        */
+       i = u.u_arg[3];
+       gp = NULL;
+       switch(i) {
+       case NPGRP:
+               if (u.u_arg[1] < 0)
+                       goto sw;
+       case CHAN:
+       case JOIN:
+       case EXTR:
+       case ATTACH:
+       case DETACH:
+       case CSIG:
+               gfp = getf(u.u_arg[1]);
+               if (gfp==NULL)
+                       goto bad;
+               gip = gfp->f_inode;
+               gp = &gip->i_un.i_group;
+               if (gp->g_inode != gip)
+                       goto bad;
+       }
+
+sw:
+       switch(i) {
+       /*
+        * creat a null group
+        * return a file descriptor
+        */
+       case MPX:
+       case MPXN:
+               if (mpxdev < 0) {
+                       for(i=0; linesw[i].l_open; i++) 
+                               if (linesw[i].l_read == mcread) {
+                                       mpxline = i;
+                                       goto found1;
+                               }
+                       goto bad;
+
+               found1:
+                       for(i=0; cdevsw[i].d_open; i++) {
+                               if (cdevsw[i].d_open == mxopen)
+                                       goto found2;
+                       }
+               bad:
+                       u.u_error = ENXIO;
+                       return;
+               found2:
+                       mpxdev = (dev_t)(i<<8);
+                       i = u.u_arg[3];
+               }
+               if (i==MPXN) {
+                       if ((ip=ialloc(rootdev))==NULL)
+                               goto bad;
+                       ip->i_mode = (u.u_arg[1]&0777)+IFCHR;
+                       ip->i_flag = IACC|IUPD|ICHG;
+                       ip->i_nlink = 1;
+                       goto merge;
+               }
+               ip = namei(uchar,1);
+               if (ip != NULL) {
+                       u.u_error = EEXIST;
+                       iput(ip);
+                       return;
+               }
+               if (u.u_error)
+                       return;
+               ip = maknode((u.u_arg[1]&0777)+IFCHR);
+               if (ip == NULL)
+                       return;
+       merge:
+               if ((i = gpalloc()) < 0) {
+                       iput(ip);
+                       goto bad;
+               }
+               ip->i_un.i_rdev = (daddr_t)(mpxdev+i);
+               gp = &ip->i_un.i_group;
+               groups[i] = gp;
+               gp->g_inode = ip;
+               gp->g_state = COPEN;
+               gp->g_group = NULL;
+               gp->g_index = 0;
+               gp->g_rotmask = 1;
+               gp->g_rot = 0;
+               gp->g_datq = 0;
+               open1(ip,FREAD+FWRITE,2);
+               if (u.u_error) {
+                       groups[i] = NULL;
+                       iput(ip);
+                       goto bad;
+               }
+               ip->i_mode |= IFMPC;
+               ip->i_count++;
+               fp = u.u_ofile[u.u_r.r_val1];
+               fp->f_flag |= FMP;
+               fp->f_un.f_chan = NULL;
+               for(i=0;i<NINDEX;)
+                       gp->g_chans[i++] = NULL;
+               return;
+       /*
+        * join file descriptor (arg 0) to group (arg 1)
+        * return channel number
+        */
+       case JOIN:
+               if ((fp=getf(u.u_arg[0]))==NULL)
+                       goto bad;
+               ip = fp->f_inode;
+               i = ip->i_mode & IFMT;
+               if (i == IFMPC) {
+                       mlink(fp->f_inode, gp);
+                       return;
+               }
+               if (i != IFCHR) 
+                       goto bad;
+               dev = (dev_t)ip->i_un.i_rdev;
+               tp = &cdevsw[major(dev)].d_ttys[minor(dev)];
+               if (tp==NULL || tp->t_chan)
+                       goto bad;
+               if ((cp=addch(gip))==NULL)
+                       goto bad;
+               tp->t_chan = cp;
+               cp->c_ottyp = cp->c_ittyp = tp;
+               cp->c_iline = cp->c_oline = tp->t_line;
+               cp->c_flags = XGRP+TTYO;
+               u.u_r.r_val1 = cp->c_index;
+               return;
+       /*
+        * attach channel (arg 0) to group (arg 1)
+        */
+       case ATTACH:
+               cp = xcp(gp, u.u_arg[0]);
+               if (cp==NULL)
+                       goto bad;
+               u.u_r.r_val1 = cpx(cp);
+               wakeup((caddr_t)cp);
+               return;
+       case DETACH:
+               cp = xcp(gp, u.u_arg[0]);
+               if (cp==NULL)
+                       goto bad;
+               cp->c_flags |= WCLOSE;
+               wakeup((caddr_t)cp);
+               return;
+       /*
+        * extract channel (arg 0) from group (arg 1)
+        * using X side (arg 2 zero) otherwise Y side
+        */
+       case EXTR:
+               cp = xcp(gp, u.u_arg[0]);
+               if (cp==NULL) {
+                       goto bad;
+               }
+               if ((fp = falloc()) == NULL) {
+                       return;
+               }
+               fp->f_inode = gip;
+               fp->f_un.f_chan = cp;
+               fp->f_flag = (u.u_arg[2]) ? (FREAD+FWRITE+FMPY) : (FREAD+FWRITE+FMPX);
+               return;
+       /*
+        * make new chan on group (arg 1)
+        */
+       case CHAN:
+               if ((cp=addch(gip))==NULL)
+                       goto bad;
+               cp->c_flags = XGRP;
+               cp->c_ittyp = cp->c_ottyp = (struct tty *)cp;
+               cp->c_iline = cp->c_oline = mpxline;
+               u.u_r.r_val1 = cp->c_index;
+               return;
+       /*
+        * connect fd (arg 0) to channel fd (arg 1)
+        * (arg 2 <  0) => fd to chan only
+        * (arg 2 >  0) => chan to fd only
+        * (arg 2 == 0) => both directions
+        */
+       case CONNECT:
+               if ((fp=getf(u.u_arg[0]))==NULL)
+                       goto bad;
+               if ((chfp=getf(u.u_arg[1]))==NULL)
+                       goto bad;
+               ip = fp->f_inode;
+               i = ip->i_mode&IFMT;
+               if (i!=IFMPC)
+                       goto bad;
+               dev = (dev_t)ip->i_un.i_rdev;
+               tp = &cdevsw[major(dev)].d_ttys[minor(dev)];
+               if (tp==NULL)
+                       goto bad;
+               if (!(chfp->f_flag&FMPY)) {
+                       goto bad;
+               }
+               cp = chfp->f_un.f_chan;
+               if (cp==NULL) {
+                       goto bad;
+               }
+               i = u.u_arg[2];
+               if (i>=0) {
+                       cp->c_ottyp = tp;
+                       cp->c_oline = tp->t_line;
+               }
+               if (i<=0)  {
+                       tp->t_chan = cp;
+                       cp->c_ittyp = tp;
+                       cp->c_iline = tp->t_line;
+               }
+               return;
+       case NPGRP: {
+               register struct proc *pp;
+
+               if (gp != NULL) {
+                       cp = xcp(gp, u.u_arg[0]);
+                       if (cp==NULL)
+                               goto bad;
+               }
+               pp = u.u_procp;
+               pp->p_pgrp = pp->p_pid;
+               if (u.u_arg[2])
+                       pp->p_pgrp = u.u_arg[2];
+               if (gp != NULL)
+                       cp->c_pgrp = pp->p_pgrp;
+               return;
+       }
+       case CSIG:
+               cp = xcp(gp, u.u_arg[0]);
+               if (cp==NULL)
+                       goto bad;
+               signal(cp->c_pgrp, u.u_arg[2]);
+               return;
+       case DEBUG:
+               i = u.u_arg[0];
+               if (i<0 || i>NDEBUGS)
+                       return;
+               mcdebugs[i] = u.u_arg[1];
+               if (i==ALL)
+                       for(i=0;i<NDEBUGS;i++)
+                               mcdebugs[i] = u.u_arg[1];
+               return;
+       default:
+               goto bad;
+       }
+}
+
+
+
+mlink(sub,master)
+struct group *sub, *master;
+{
+register i;
+
+
+       for(i=0;i<NINDEX;i++) {
+               if (master->g_chans[i] != NULL)
+                       continue;
+               master->g_chans[i] = (struct chan *)sub;
+               sub->g_group = master;
+               sub->g_index = i;
+               u.u_r.r_val1 = i;
+               return;
+       }
+       u.u_error = ENXIO;
+       return;
+}
diff --git a/usr/src/slowsys/sys/mx2.c b/usr/src/slowsys/sys/mx2.c
new file mode 100644 (file)
index 0000000..05ad549
--- /dev/null
@@ -0,0 +1,693 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/proc.h"
+#include "../h/tty.h"
+#include "../h/inode.h"
+#include "../h/mx.h"
+#include "../h/file.h"
+#include "../h/conf.h"
+#include "../h/buf.h"
+
+/*
+ * multiplexor driver
+ */
+struct chan    chans[NCHANS];
+struct group   *groups[NGROUPS];
+int    mpxline;
+struct chan *xcp();
+struct chan *addch();
+struct chan *nextcp();
+
+int    chzero;
+short  cmask[16]       ={
+       01,     02,     04,
+       010,    020,    040,
+       0100,   0200,   0400,
+       01000,  02000,  04000,
+       010000, 020000, 040000, 0100000
+};
+
+char mcdebugs[NDEBUGS];
+mxopen(dev,flag)
+{
+register struct group *gp;
+register struct file *fp;
+register struct chan *cp;
+int d;
+
+struct inode *ip;
+       d = minor(dev);
+       if (d>=NGROUPS) {
+       bad:
+               u.u_error = ENXIO;
+               printf("bad mxopen\n");
+               return;
+       }
+       gp = groups[d];
+       if (gp->g_state == COPEN) {
+               gp->g_state = INUSE+ISGRP;
+               return;
+       }
+       if (!(gp->g_state&INUSE)) 
+               goto bad;
+       fp = u.u_ofile[u.u_r.r_val1];
+       if (fp->f_inode != gp->g_inode) 
+               goto bad;
+       if ((cp=addch(gp->g_inode))==NULL)
+               goto bad;
+       cp->c_flags = XGRP;
+       cp->c_ottyp = cp->c_ittyp = (struct tty *)cp;
+       cp->c_iline = cp->c_oline = mpxline;
+       fp->f_flag |= FMPY;
+       fp->f_flag |= FREAD+FWRITE;
+       fp->f_un.f_chan = cp;
+       cp->c_pgrp = u.u_procp->p_pgrp;
+#ifdef CTRACE
+       printf("open pgrp %d\n",cp->c_pgrp);
+#endif
+       scontrol(cp, M_WATCH+(cp->c_index<<8), u.u_uid);
+       sleep((caddr_t)cp,TTIPRI);
+       if (cp->c_flags & WCLOSE) {
+               printf("WCLOSE on %o\n",cp);
+               chfree(cp,0);
+               goto bad;
+       }
+       cp->c_fy = fp;
+}
+
+
+mxclose(dev,cp)
+dev_t  dev;
+struct chan *cp;
+{
+register i;
+register struct group *gp;
+register struct inode *ip;
+
+       gp = groups[minor(dev)];
+       ip = gp->g_inode;
+       if (ip==NULL) {
+               if (cp==NULL || (int)cp==FWRITE)
+               printf("bad close gp %o gpi %o ip %o ipg %o\n",
+                       gp,gp->g_inode,ip,ip->i_un.i_group);
+               if (cp==NULL)
+                       return;
+       }
+       if (cp!=NULL && (int)cp!=FWRITE) {
+               i = cp->c_index;
+               if (!cp->c_flags&WCLOSE) {
+                       chfree(cp,1);
+                       scontrol(cp, M_CLOSE, 0);
+printf("x1 close\n");
+               } else {
+                       chfree(cp,0);
+#ifdef CTRACE
+                       printf("WC close\n");
+#endif
+               }
+               gp->g_chans[i] = NULL;
+               cp->c_pgrp = 0;
+               cp->c_group = NULL;
+               cp->c_flags |= WCLOSE;
+               return;
+       }
+       if ((ip->i_mode&IFMT)!=IFMPC) {
+               printf("close on inode %o\n",ip);
+               return;
+       }
+       for(i=0;i<NINDEX;i++) {
+               if ((cp=gp->g_chans[i])!=NULL) {
+                       if (cp->c_flags&ISGRP) {
+                               ((struct group *)cp)->g_state &= ~ISGRP;
+                               ((struct group *)cp)->g_group = NULL;
+                               continue;
+                       }
+                       cp->c_flags |= WCLOSE;
+                       wakeup((caddr_t)cp);
+                       signal(cp->c_pgrp,SIGHUP);
+                       chfree(cp,0);
+                       if (gp->g_chans[i])
+                               printf("chfree didn't clear inode\n");
+               }
+       }
+       gp->g_state = NULL;
+       groups[minor(dev)] = NULL;
+       i = ip->i_mode;
+       i &= ~IFMT;
+       i |= IFCHR;
+       ip->i_mode = i;
+       ip->i_flag |= IUPD|ICHG;
+       iput(ip);
+}
+
+
+mxread(dev)
+{
+register struct group *gp;
+struct clist *q;
+struct chan *cp;
+register i;
+struct file *fp;
+struct header h;
+caddr_t        base;
+unsigned count;
+int    s,xfr,more;
+int esc;
+
+       i = minor(dev);
+       if (i>=NGROUPS) {
+               u.u_error = ENXIO;
+               return;
+       }
+       gp = groups[i];
+       fp = getf(u.u_arg[0]);
+       if ((fp->f_flag&FMP)!=FMP) {
+               msread(fp,gp);
+               return;
+       }
+
+       s = spl6();
+       while (gp->g_datq == 0) {
+
+               sleep((caddr_t)&gp->g_datq, TTIPRI);
+       }
+
+       while (gp->g_datq && u.u_count >= CNTLSIZ) {
+               splx(s);
+               esc = 0;
+               cp = nextcp(gp);
+               if (cp==NULL) {
+                       continue;
+               }
+               if (cp->c_ctlx.c_cc)
+                       esc = 2;
+               base = u.u_base;
+               count = u.u_count;
+               u.u_base += HDRSIZE + esc;
+               u.u_count -= HDRSIZE + esc;
+               xfr = u.u_count;
+               more = (*linesw[cp->c_iline].l_read)(cp->c_ittyp);
+               if (esc || more > 0) {
+                       sdata(cp);
+               }
+               if (more<0) {
+printf("m<0\n");
+printf("x2 close\n");
+                       scontrol(cp, M_CLOSE, 0);
+               }
+               xfr -= u.u_count;
+               if (xfr==0) {
+                       u.u_base = base;
+                       u.u_count = count;
+                       chzero++;
+                       continue;
+               }
+               h.index = cpx(cp);
+               if (esc) {
+                       h.count = 0;
+                       h.ccount = xfr;
+               } else
+                       h.count = xfr;
+               if (xfr&1) {
+                       u.u_base++;
+                       u.u_count--;
+               }
+               copyout(&h, base, HDRSIZE+esc);
+
+               q = &cp->cx.datq;
+               if (cp->c_flags&BLOCK && esc==0) {
+                       if (q->c_cc<25) {
+                               wakeup((caddr_t)q+1);
+                               cp->c_flags &= ~BLOCK;
+                       } else {
+                       }
+               }
+               if (cp->c_flags&WFLUSH)
+                       wakeup((caddr_t)q+2);
+               s = spl6();
+       }
+}
+
+
+mcread(cp)
+register struct chan *cp;
+{
+register struct clist *q;
+register c;
+
+
+       if (cp->c_ctlx.c_cc)
+               q = &cp->c_ctlx; else
+               q = &cp->cx.datq;
+
+       while( (c=getc(q)) >= 0) {
+               passc(c);
+       }
+       return(q->c_cc);
+
+}
+
+msread(fp, gp)
+struct file *fp;
+struct group *gp;
+{
+register struct clist *q;
+register struct chan *cp;
+register i;
+
+       cp = fp->f_un.f_chan;
+       q = (fp->f_flag&FMPX) ? &cp->cx.datq : &cp->cy.datq;
+       i = spl6();
+       if (!q->c_cc) {
+               if (cp->c_flags&WCLOSE) {
+                       printf("ms sees it %o\n",cp);
+                       u.u_error = ENXIO;
+                       return;
+               }
+               sleep((caddr_t)q,TTIPRI);
+       }
+       splx(i);
+       i = 0;
+       while(u.u_count && q->c_cc) {
+               passc(getc(q));
+               i++;
+       }
+       if (cp->c_flags&SIGBLK && q->c_cc < 20) {
+               cp->c_flags &= ~SIGBLK;
+               if (cp->c_flags&ENAMSG) 
+                       scontrol(cp, M_UBLK, 0); else
+                       wakeup((caddr_t)q);
+       }
+       if (cp->c_flags&WFLUSH)
+               wakeup((caddr_t)q+2);
+}
+
+
+mxwrite(dev)
+{
+register i;
+register struct chan *cp;
+struct header h;
+struct file *fp;
+struct group *gp;
+int    ucount;
+caddr_t        ubase;
+
+       i = minor(dev);
+       if (i>=NGROUPS) {
+               u.u_error = ENXIO;
+               return;
+       }
+       gp = groups[i];
+       fp = getf(u.u_arg[0]);
+       if ((fp->f_flag&FMP)!=FMP) {
+               ucount = mswrite(fp,gp);
+               return;
+       }
+       while (u.u_count) {
+               iomove(&h, sizeof(struct header), B_WRITE);
+/*
+               if (count==0) {
+                       esc++;
+                       h.count = h.ccount;
+               }
+*/
+               cp = xcp(gp, h.index);
+               if (cp==NULL)  {
+printf("nullo %o %o\n",cp,chans);
+                       u.u_count -= h.count;
+                       u.u_base += h.count;
+                       continue;
+               }
+               ucount = u.u_count;
+               ubase = u.u_base;
+               u.u_count = h.count;
+               u.u_base = h.addr;
+               (*linesw[cp->c_oline].l_write)(cp->c_ottyp);
+               u.u_count = ucount;
+               u.u_base = ubase;
+       }
+}
+
+
+mcwrite(cp)
+register struct chan *cp;
+{
+register struct clist *q;
+register c;
+int    s;
+
+       q = &cp->cy.datq;
+
+       while ((c=cpass())>=0) {
+               s = spl6();
+               while (q->c_cc > 100) {
+                       cp->c_flags |= SIGBLK;
+                       splx(s);
+                       if (cp->c_flags&ENAMSG) {
+                               scontrol(cp, M_BLK, (short)u.u_count);
+                               wakeup((caddr_t)q);
+                               while (cpass()>=0);
+                               return;
+                       } else
+                               sleep((caddr_t)q, TTOPRI);
+
+               }
+               splx(s);
+               putc(c, q);
+       }
+       wakeup((caddr_t)q);
+}
+
+
+mcttwrite(tp,cc)
+register struct tty *tp;
+register cc;
+{
+register c;
+struct chan *cp;
+
+       if ((tp->t_state&CARR_ON)==0)
+               return;
+       while (cc && (c=cpass())>=0) {
+               spl5();
+               if (tp->t_outq.c_cc > 10) {
+                       ttstart(tp);
+                       spl0();
+                       cp = tp->t_chan;
+                       cp->c_flags |= SIGBLK;
+                       scontrol(cp, M_BLK, cc);
+                       while (cc-- && cpass()>=0);
+                       return;
+               }
+               spl0();
+               ttyoutput(c,tp);
+               cc--;
+       }
+       ttstart(tp);
+}
+mcttstart(tp)
+struct tty *tp;
+{
+register struct chan *cp;
+
+       cp = tp->t_chan;
+       if (cp->c_flags&(BLKMSG+ENAMSG)) {
+               cp->c_flags &= ~BLKMSG;
+               scontrol(cp, M_UBLK, 0);
+       }
+}
+mswrite(fp,gp)
+struct file *fp;
+struct group *gp;
+{
+register struct clist *q;
+struct chan *cp;
+register c;
+int cc;
+
+       cp = fp->f_un.f_chan;
+       q = (fp->f_flag&FMPX) ? &cp->cy.datq : &cp->cx.datq;
+       cc = 0;
+       while((c=cpass())>=0) {
+               spl6();
+               if (cp->c_flags&WCLOSE) {
+               bad:
+                       u.u_error = ENXIO;
+                       printf("ms write sees it %o\n",cp);
+                       return(cc);
+               }
+               while (q->c_cc>100) {
+                       if (cp->c_flags&WCLOSE)
+                               goto bad;
+                       sdata(cp);
+/*
+                       if (q->c_cc) {
+                               printf("choops\n");
+                               sdata(cp);
+                               printf("sent\n");
+                       }
+*/
+                       cc = 0;
+                       cp->c_flags |= BLOCK;
+                       sleep((caddr_t)q+1,TTOPRI);
+               }
+               spl0();
+               if (putc(c,q)>=0)
+                       cc++; else
+                       printf("qe\n");
+       }
+       if (fp->f_flag&FMPX) {
+               if (cp->c_flags&YGRP) 
+                       sdata(cp); else
+                       wakeup((caddr_t)q);
+       } else {
+               if (cp->c_flags&XGRP) 
+                       sdata(cp); else
+                       wakeup((caddr_t)q);
+       }
+       return(cc);
+}
+
+
+
+mxioctl(dev, cmd, addr, flag)
+caddr_t addr;
+{
+/*
+       u.u_error = ENOTTY;
+*/
+}
+
+
+
+
+chfree(cp, flag)
+register struct chan *cp;
+{
+register struct tty *tp;
+struct group *gp;
+struct inode *ip;
+
+       if (chclear(cp))
+               goto out;
+       tp = cp->c_ittyp;
+       if (tp->t_chan == cp) {
+               cp->c_ittyp = NULL;
+               tp->t_chan = NULL;
+               if (flag && cp->c_iline==0)
+                       wflushtty(tp); else
+                       flushtty(tp);
+       }
+       if (flag) 
+               wflush(cp,&cp->cx.datq); else
+               flush(&cp->cx.datq);
+       if (!(cp->c_flags&YGRP)) {
+               flush(&cp->cy.datq);
+       }
+       cp->c_flags = NULL;
+out:
+       if (!flag) {
+               gp = cp->c_group;
+               cp->c_group = NULL;
+               ip = gp->g_inode;
+               if (ip==NULL || (ip->i_mode&IFMT)!=IFMPC) {
+                       printf("chfree on %o\n",ip);
+                       return;
+               }
+               gp->g_chans[cp->c_index] = NULL;
+       }
+}
+
+chclear(cp)
+register struct chan *cp;
+{
+register char *p;
+
+#ifdef CTRACE
+register struct file *fp;
+       fp = cp->c_fy;
+       if (fp) {
+               printf(" count %d on cp %o\n",fp->f_count,cp);
+       }
+#endif
+       p = (char *)&cp->cx.datq;
+       wakeup(p); wakeup(++p); wakeup(++p);
+       p = (char *)&cp->cy.datq;
+       wakeup(p); wakeup(++p); wakeup(++p);
+       return(0);
+}
+
+
+
+flush(q)
+register struct clist *q;
+{
+
+       while(q->c_cc)
+               getc(q);
+}
+
+
+wflush(cp,q)
+register struct chan *cp;
+register struct clist *q;
+{
+register s;
+
+       s = spl6();
+       while(q->c_cc) {
+               if (cp->c_flags & WCLOSE) {
+                       flush(q);
+                       goto out;
+               }
+               cp->c_flags |= WFLUSH;
+               sdata(cp);
+               sleep((caddr_t)q+2,TTOPRI);
+       }
+out:
+       cp->c_flags &= ~WFLUSH;
+       splx(s);
+}
+
+
+scontrol(cp,event,value)
+register struct chan *cp;
+short event,value;
+{
+register struct clist *q;
+int s;
+
+       q = &cp->c_ctlx;
+       s = spl6();
+       putw(event,q);
+       putw(value,q);
+       splx(s);
+       sdata(cp);
+}
+
+sdata(cp)
+register struct chan *cp;
+{
+register struct group *gp;
+register short x;
+register struct group *lgp;
+int s;
+
+       gp = cp->c_group;
+       x = cp->c_index;
+
+       s = spl6();
+       while (gp) {
+               gp->g_datq |= cmask[x];
+               x = gp->g_index;
+               lgp = gp;
+               gp = gp->g_group;
+       }
+       gp =  lgp;
+       splx(s);
+       wakeup((caddr_t)&gp->g_datq);
+}
+
+
+
+struct chan *
+xcp(gp, x)
+register struct group *gp;
+register short x;
+{
+register i;
+
+       i = 0;
+       while (i<NLEVELS && gp->g_state&ISGRP) {
+               gp = (struct group *)gp->g_chans[x&017];
+               x >>= 4;
+       }
+       return((struct chan *)gp);
+}
+
+cpx(cp)
+register struct chan *cp;
+{
+register x;
+register struct group *gp;
+
+       x = cp->c_index;
+       gp = cp->c_group;
+       gp = gp->g_group;
+       while (gp) {
+               x <<= 4;
+               x |= gp->g_index;
+               gp = gp->g_group;
+       }
+       return(x);
+}
+
+
+
+struct chan *
+nextcp(gp)
+register struct group *gp;
+{
+
+       if (gp->g_datq == 0) {
+               gp = NULL;
+               goto out;
+       }
+
+       while (gp != NULL && gp->g_state&ISGRP) {
+               while ( (gp->g_datq & gp->g_rotmask) == 0) {
+                       gp->g_rot++;
+                       gp->g_rot &= 017;
+                       if (gp->g_rot)
+                               gp->g_rotmask <<= 1; else
+                               gp->g_rotmask = 1;
+               }
+               gp = (struct group *)gp->g_chans[gp->g_rot];
+       }
+       if (gp)
+               rmdata(gp);
+out:
+       return((struct chan *)gp);
+}
+
+rmdata(cp)
+register struct chan *cp;
+{
+register struct group *gp;
+register short x;
+
+       gp = cp->c_group;
+       x = cp->c_index;
+
+       while (gp) {
+               gp->g_datq &= ~cmask[x];
+               if (gp->g_datq)
+                       return;
+               x = gp->g_index;
+               gp = gp->g_group;
+       }
+}
+
+
+
+
+
+mcrint(c, tp)
+struct tty *tp;
+{
+}
+
+mcxint(tp)
+struct tty *tp;
+{
+}
+prstuff(s,cc)
+register char *s;
+register cc;
+{
+       while (cc--)
+               printf("%o ",*s++&0377);
+}
diff --git a/usr/src/slowsys/sys/nami.c b/usr/src/slowsys/sys/nami.c
new file mode 100644 (file)
index 0000000..1e0c4e6
--- /dev/null
@@ -0,0 +1,216 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/inode.h"
+#include "../h/mount.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/buf.h"
+
+/*
+ * Convert a pathname into a pointer to
+ * an inode. Note that the inode is locked.
+ *
+ * func = function called to get next char of name
+ *     &uchar if name is in user space
+ *     &schar if name is in system space
+ * flag = 0 if name is sought
+ *     1 if name is to be created
+ *     2 if name is to be deleted
+ */
+struct inode *
+namei(func, flag)
+int (*func)();
+{
+       register struct inode *dp;
+       register c;
+       register char *cp;
+       struct buf *bp;
+       int i;
+       dev_t d;
+       off_t eo;
+
+       /*
+        * If name starts with '/' start from
+        * root; otherwise start from current dir.
+        */
+
+       dp = u.u_cdir;
+       if((c=(*func)()) == '/')
+               if ((dp = u.u_rdir) == NULL)
+                       dp = rootdir;
+       iget(dp->i_dev, dp->i_number);
+       while(c == '/')
+               c = (*func)();
+       if(c == '\0' && flag != 0)
+               u.u_error = ENOENT;
+
+cloop:
+       /*
+        * Here dp contains pointer
+        * to last component matched.
+        */
+
+       if(u.u_error)
+               goto out;
+       if(c == '\0')
+               return(dp);
+
+       /*
+        * If there is another component,
+        * Gather up name into
+        * users' dir buffer.
+        */
+
+       cp = &u.u_dbuf[0];
+       while(c != '/' && c != '\0' && u.u_error == 0) {
+               if(cp < &u.u_dbuf[DIRSIZ])
+                       *cp++ = c;
+               c = (*func)();
+       }
+       while(cp < &u.u_dbuf[DIRSIZ])
+               *cp++ = '\0';
+       while(c == '/')
+               c = (*func)();
+
+seloop:
+       /*
+        * dp must be a directory and
+        * must have X permission.
+        */
+
+       if((dp->i_mode&IFMT) != IFDIR)
+               u.u_error = ENOTDIR;
+       access(dp, IEXEC);
+       if(u.u_error)
+               goto out;
+
+       /*
+        * set up to search a directory
+        */
+       u.u_offset = 0;
+       u.u_segflg = 1;
+       eo = 0;
+       bp = NULL;
+
+eloop:
+
+       /*
+        * If at the end of the directory,
+        * the search failed. Report what
+        * is appropriate as per flag.
+        */
+
+       if(u.u_offset >= dp->i_size) {
+               if(bp != NULL)
+                       brelse(bp);
+               if(flag==1 && c=='\0') {
+                       if(access(dp, IWRITE))
+                               goto out;
+                       u.u_pdir = dp;
+                       if(eo)
+                               u.u_offset = eo-sizeof(struct direct);
+                       else
+                               dp->i_flag |= IUPD|ICHG;
+                       return(NULL);
+               }
+               u.u_error = ENOENT;
+               goto out;
+       }
+
+       /*
+        * If offset is on a block boundary,
+        * read the next directory block.
+        * Release previous if it exists.
+        */
+
+       if((u.u_offset&BMASK) == 0) {
+               if(bp != NULL)
+                       brelse(bp);
+               bp = bread(dp->i_dev,
+                       bmap(dp, (daddr_t)(u.u_offset>>BSHIFT), B_READ));
+               if (bp->b_flags & B_ERROR) {
+                       brelse(bp);
+                       goto out;
+               }
+       }
+
+       /*
+        * Note first empty directory slot
+        * in eo for possible creat.
+        * String compare the directory entry
+        * and the current component.
+        * If they do not match, go back to eloop.
+        */
+
+       bcopy(bp->b_un.b_addr+(u.u_offset&BMASK), (caddr_t)&u.u_dent,
+               sizeof(struct direct));
+       u.u_offset += sizeof(struct direct);
+       if(u.u_dent.d_ino == 0) {
+               if(eo == 0)
+                       eo = u.u_offset;
+               goto eloop;
+       }
+       for(i=0; i<DIRSIZ; i++)
+               if(u.u_dbuf[i] != u.u_dent.d_name[i])
+                       goto eloop;
+
+       /*
+        * Here a component matched in a directory.
+        * If there is more pathname, go back to
+        * cloop, otherwise return.
+        */
+
+       if(bp != NULL)
+               brelse(bp);
+       if(flag==2 && c=='\0') {
+               if(access(dp, IWRITE))
+                       goto out;
+               return(dp);
+       }
+       d = dp->i_dev;
+       if(u.u_dent.d_ino == ROOTINO)
+       if(dp->i_number == ROOTINO)
+       if(u.u_dent.d_name[1] == '.')
+               for(i=1; i<NMOUNT; i++)
+                       if(mount[i].m_bufp != NULL)
+                       if(mount[i].m_dev == d) {
+                               iput(dp);
+                               dp = mount[i].m_inodp;
+                               dp->i_count++;
+                               plock(dp);
+                               goto seloop;
+                       }
+       iput(dp);
+       dp = iget(d, u.u_dent.d_ino);
+       if(dp == NULL)
+               return(NULL);
+       goto cloop;
+
+out:
+       iput(dp);
+       return(NULL);
+}
+
+/*
+ * Return the next character from the
+ * kernel string pointed at by dirp.
+ */
+schar()
+{
+
+       return(*u.u_dirp++ & 0377);
+}
+
+/*
+ * Return the next character from the
+ * user string pointed at by dirp.
+ */
+uchar()
+{
+       register c;
+
+       c = fubyte(u.u_dirp++);
+       if(c == -1)
+               u.u_error = EFAULT;
+       return(c);
+}
diff --git a/usr/src/slowsys/sys/partab.c b/usr/src/slowsys/sys/partab.c
new file mode 100644 (file)
index 0000000..44628c4
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ */
+
+char partab[] = {
+       0001,0201,0201,0001,0201,0001,0001,0201,
+       0202,0004,0003,0201,0005,0206,0201,0001,
+       0201,0001,0001,0201,0001,0201,0201,0001,
+       0001,0201,0201,0001,0201,0001,0001,0201,
+       0200,0000,0000,0200,0000,0200,0200,0000,
+       0000,0200,0200,0000,0200,0000,0000,0200,
+       0000,0200,0200,0000,0200,0000,0000,0200,
+       0200,0000,0000,0200,0000,0200,0200,0000,
+       0200,0000,0000,0200,0000,0200,0200,0000,
+       0000,0200,0200,0000,0200,0000,0000,0200,
+       0000,0200,0200,0000,0200,0000,0000,0200,
+       0200,0000,0000,0200,0000,0200,0200,0000,
+       0000,0200,0200,0000,0200,0000,0000,0200,
+       0200,0000,0000,0200,0000,0200,0200,0000,
+       0200,0000,0000,0200,0000,0200,0200,0000,
+       0000,0200,0200,0000,0200,0000,0000,0201
+};
diff --git a/usr/src/slowsys/sys/pipe.c b/usr/src/slowsys/sys/pipe.c
new file mode 100644 (file)
index 0000000..1ca26ba
--- /dev/null
@@ -0,0 +1,216 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/inode.h"
+#include "../h/file.h"
+#include "../h/reg.h"
+
+/*
+ * Max allowable buffering per pipe.
+ * This is also the max size of the
+ * file created to implement the pipe.
+ * If this size is bigger than 5120,
+ * pipes will be implemented with large
+ * files, which is probably not good.
+ */
+#define        PIPSIZ  4096
+
+/*
+ * The sys-pipe entry.
+ * Allocate an inode on the root device.
+ * Allocate 2 file structures.
+ * Put it all together with flags.
+ */
+pipe()
+{
+       register struct inode *ip;
+       register struct file *rf, *wf;
+       int r;
+
+       ip = ialloc(pipedev);
+       if(ip == NULL)
+               return;
+       rf = falloc();
+       if(rf == NULL) {
+               iput(ip);
+               return;
+       }
+       r = u.u_r.r_val1;
+       wf = falloc();
+       if(wf == NULL) {
+               rf->f_count = 0;
+               u.u_ofile[r] = NULL;
+               iput(ip);
+               return;
+       }
+       u.u_r.r_val2 = u.u_r.r_val1;
+       u.u_r.r_val1 = r;
+       wf->f_flag = FWRITE|FPIPE;
+       wf->f_inode = ip;
+       rf->f_flag = FREAD|FPIPE;
+       rf->f_inode = ip;
+       ip->i_count = 2;
+       ip->i_mode = IFREG;
+       ip->i_flag = IACC|IUPD|ICHG;
+}
+
+/*
+ * Read call directed to a pipe.
+ */
+readp(fp)
+register struct file *fp;
+{
+       register struct inode *ip;
+
+       ip = fp->f_inode;
+
+loop:
+       /*
+        * Very conservative locking.
+        */
+
+       plock(ip);
+       /*
+        * If nothing in the pipe, wait.
+        */
+       if (ip->i_size == 0) {
+               /*
+                * If there are not both reader and
+                * writer active, return without
+                * satisfying read.
+                */
+               prele(ip);
+               if(ip->i_count < 2)
+                       return;
+               ip->i_mode |= IREAD;
+               sleep((caddr_t)ip+2, PPIPE);
+               goto loop;
+       }
+
+       /*
+        * Read and return
+        */
+
+       u.u_offset = fp->f_un.f_offset;
+       readi(ip);
+       fp->f_un.f_offset = u.u_offset;
+       /*
+        * If reader has caught up with writer, reset
+        * offset and size to 0.
+        */
+       if (fp->f_un.f_offset == ip->i_size) {
+               fp->f_un.f_offset = 0;
+               ip->i_size = 0;
+               if(ip->i_mode & IWRITE) {
+                       ip->i_mode &= ~IWRITE;
+                       wakeup((caddr_t)ip+1);
+               }
+       }
+       prele(ip);
+}
+
+/*
+ * Write call directed to a pipe.
+ */
+writep(fp)
+register struct file *fp;
+{
+       register c;
+       register struct inode *ip;
+
+       ip = fp->f_inode;
+       c = u.u_count;
+
+loop:
+
+       /*
+        * If all done, return.
+        */
+
+       plock(ip);
+       if(c == 0) {
+               prele(ip);
+               u.u_count = 0;
+               return;
+       }
+
+       /*
+        * If there are not both read and
+        * write sides of the pipe active,
+        * return error and signal too.
+        */
+
+       if(ip->i_count < 2) {
+               prele(ip);
+               u.u_error = EPIPE;
+               psignal(u.u_procp, SIGPIPE);
+               return;
+       }
+
+       /*
+        * If the pipe is full,
+        * wait for reads to deplete
+        * and truncate it.
+        */
+
+       if(ip->i_size >= PIPSIZ) {
+               ip->i_mode |= IWRITE;
+               prele(ip);
+               sleep((caddr_t)ip+1, PPIPE);
+               goto loop;
+       }
+
+       /*
+        * Write what is possible and
+        * loop back.
+        * If writing less than PIPSIZ, it always goes.
+        * One can therefore get a file > PIPSIZ if write
+        * sizes do not divide PIPSIZ.
+        */
+
+       u.u_offset = ip->i_size;
+       u.u_count = min((unsigned)c, (unsigned)PIPSIZ);
+       c -= u.u_count;
+       writei(ip);
+       prele(ip);
+       if(ip->i_mode&IREAD) {
+               ip->i_mode &= ~IREAD;
+               wakeup((caddr_t)ip+2);
+       }
+       goto loop;
+}
+
+/*
+ * Lock a pipe.
+ * If its already locked,
+ * set the WANT bit and sleep.
+ */
+plock(ip)
+register struct inode *ip;
+{
+
+       while(ip->i_flag&ILOCK) {
+               ip->i_flag |= IWANT;
+               sleep((caddr_t)ip, PINOD);
+       }
+       ip->i_flag |= ILOCK;
+}
+
+/*
+ * Unlock a pipe.
+ * If WANT bit is on,
+ * wakeup.
+ * This routine is also used
+ * to unlock inodes in general.
+ */
+prele(ip)
+register struct inode *ip;
+{
+
+       ip->i_flag &= ~ILOCK;
+       if(ip->i_flag&IWANT) {
+               ip->i_flag &= ~IWANT;
+               wakeup((caddr_t)ip);
+       }
+}
diff --git a/usr/src/slowsys/sys/prf.c b/usr/src/slowsys/sys/prf.c
new file mode 100644 (file)
index 0000000..1b12141
--- /dev/null
@@ -0,0 +1,115 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/seg.h"
+#include "../h/buf.h"
+#include "../h/conf.h"
+
+/*
+ * In case console is off,
+ * panicstr contains argument to last
+ * call to panic.
+ */
+
+char   *panicstr;
+
+/*
+ * Scaled down version of C Library printf.
+ * Only %s %u %d (==%u) %o %x %D are recognized.
+ * Used to print diagnostic information
+ * directly on console tty.
+ * Since it is not interrupt driven,
+ * all system activities are pretty much
+ * suspended.
+ * Printf should not be used for chit-chat.
+ */
+/* VARARGS */
+printf(fmt, x1)
+register char *fmt;
+unsigned x1;
+{
+       register c;
+       register unsigned int *adx;
+       char *s;
+
+       adx = &x1;
+loop:
+       while((c = *fmt++) != '%') {
+               if(c == '\0')
+                       return;
+               putchar(c);
+       }
+       c = *fmt++;
+       if(c == 'd' || c == 'u' || c == 'o' || c == 'x')
+               printn((long)*adx, c=='o'? 8: (c=='x'? 16:10));
+       else if(c == 's') {
+               s = (char *)*adx;
+               while(c = *s++)
+                       putchar(c);
+       } else if (c == 'D') {
+               printn(*(long *)adx, 10);
+               adx += (sizeof(long) / sizeof(int)) - 1;
+       }
+       adx++;
+       goto loop;
+}
+
+/*
+ * Print an unsigned integer in base b.
+ */
+printn(n, b)
+long n;
+{
+       register long a;
+
+       if (n<0) {      /* shouldn't happen */
+               putchar('-');
+               n = -n;
+       }
+       if(a = n/b)
+               printn(a, b);
+       putchar("0123456789ABCDEF"[(int)(n%b)]);
+}
+
+/*
+ * Panic is called on unresolvable
+ * fatal errors.
+ * It syncs, prints "panic: mesg" and
+ * then loops.
+ */
+panic(s)
+char *s;
+{
+       panicstr = s;
+       update();
+       printf("panic: %s\n", s);
+       for(;;)
+               idle();
+}
+
+/*
+ * prdev prints a warning message of the
+ * form "mesg on dev x/y".
+ * x and y are the major and minor parts of
+ * the device argument.
+ */
+prdev(str, dev)
+char *str;
+dev_t dev;
+{
+
+       printf("%s on dev %u/%u\n", str, major(dev), minor(dev));
+}
+
+/*
+ * deverr prints a diagnostic from
+ * a device driver.
+ * It prints the device, block number,
+ * and an octal word (usually some error
+ * status register) passed as argument.
+ */
+deverror(bp, o1, o2)
+register struct buf *bp;
+{
+
+       prdev("err", bp->b_dev);
+}
diff --git a/usr/src/slowsys/sys/prim.c b/usr/src/slowsys/sys/prim.c
new file mode 100644 (file)
index 0000000..43d5997
--- /dev/null
@@ -0,0 +1,136 @@
+#include "../h/param.h"
+#include "../h/tty.h"
+#include "../h/systm.h"
+#include "../h/conf.h"
+#include "../h/buf.h"
+
+struct cblock {
+       struct cblock *c_next;
+       char    c_info[CBSIZE];
+};
+
+struct cblock  cfree[NCLIST];
+struct cblock  *cfreelist;
+
+/*
+ * Character list get/put
+ */
+getc(p)
+register struct clist *p;
+{
+       register struct cblock *bp;
+       register int c, s;
+
+       s = spl6();
+       if (p->c_cc <= 0) {
+               c = -1;
+               p->c_cc = 0;
+               p->c_cf = p->c_cl = NULL;
+       } else {
+               c = *p->c_cf++ & 0377;
+               if (--p->c_cc<=0) {
+                       bp = (struct cblock *)(p->c_cf-1);
+                       bp = (struct cblock *) ((int)bp & ~CROUND);
+                       p->c_cf = NULL;
+                       p->c_cl = NULL;
+                       bp->c_next = cfreelist;
+                       cfreelist = bp;
+               } else if (((int)p->c_cf & CROUND) == 0){
+                       bp = (struct cblock *)(p->c_cf);
+                       bp--;
+                       p->c_cf = bp->c_next->c_info;
+                       bp->c_next = cfreelist;
+                       cfreelist = bp;
+               }
+       }
+       splx(s);
+       return(c);
+}
+
+putc(c, p)
+register struct clist *p;
+{
+       register struct cblock *bp;
+       register char *cp;
+       register s;
+
+       s = spl6();
+       if ((cp = p->c_cl) == NULL || p->c_cc < 0 ) {
+               if ((bp = cfreelist) == NULL) {
+                       splx(s);
+                       return(-1);
+               }
+               cfreelist = bp->c_next;
+               bp->c_next = NULL;
+               p->c_cf = cp = bp->c_info;
+       } else if (((int)cp & CROUND) == 0) {
+               bp = (struct cblock *)cp - 1;
+               if ((bp->c_next = cfreelist) == NULL) {
+                       splx(s);
+                       return(-1);
+               }
+               bp = bp->c_next;
+               cfreelist = bp->c_next;
+               bp->c_next = NULL;
+               cp = bp->c_info;
+       }
+       *cp++ = c;
+       p->c_cc++;
+       p->c_cl = cp;
+       splx(s);
+       return(0);
+}
+
+/*
+ * Initialize clist by freeing all character blocks, then count
+ * number of character devices. (Once-only routine)
+ */
+cinit()
+{
+       register int ccp;
+       register struct cblock *cp;
+       register struct cdevsw *cdp;
+
+       ccp = (int)cfree;
+       ccp = (ccp+CROUND) & ~CROUND;
+       for(cp=(struct cblock *)ccp; cp <= &cfree[NCLIST-1]; cp++) {
+               cp->c_next = cfreelist;
+               cfreelist = cp;
+       }
+       ccp = 0;
+       for(cdp = cdevsw; cdp->d_open; cdp++)
+               ccp++;
+       nchrdev = ccp;
+}
+
+
+/*
+ * integer (2-byte) get/put
+ * using clists
+ */
+getw(p)
+register struct clist *p;
+{
+       register int s;
+
+       if (p->c_cc <= 1)
+               return(-1);
+       s = getc(p);
+       return(s | (getc(p)<<8));
+}
+
+putw(c, p)
+register struct clist *p;
+{
+       register s;
+
+       s = spl6();
+       if (cfreelist==NULL) {
+               splx(s);
+               return(-1);
+       }
+       putc(c, p);
+       putc(c>>8, p);
+       splx(s);
+       return(0);
+}
diff --git a/usr/src/slowsys/sys/rdwri.c b/usr/src/slowsys/sys/rdwri.c
new file mode 100644 (file)
index 0000000..acb8670
--- /dev/null
@@ -0,0 +1,197 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/inode.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/buf.h"
+#include "../h/conf.h"
+
+/*
+ * Read the file corresponding to
+ * the inode pointed at by the argument.
+ * The actual read arguments are found
+ * in the variables:
+ *     u_base          core address for destination
+ *     u_offset        byte offset in file
+ *     u_count         number of bytes to read
+ *     u_segflg        read to kernel/user/user I
+ */
+readi(ip)
+register struct inode *ip;
+{
+       struct buf *bp;
+       dev_t dev;
+       daddr_t lbn, bn;
+       off_t diff;
+       register on, n;
+       register type;
+       extern int mem_no;
+
+       if(u.u_count == 0)
+               return;
+       dev = (dev_t)ip->i_un.i_rdev;
+       if(u.u_offset < 0 && ((ip->i_mode&IFMT) != IFCHR || mem_no != major(dev)) ) {
+               u.u_error = EINVAL;
+               return;
+       }
+       ip->i_flag |= IACC;
+       type = ip->i_mode&IFMT;
+       if (type==IFCHR || type==IFMPC) {
+               (*cdevsw[major(dev)].d_read)(dev);
+               return;
+       }
+
+       do {
+               lbn = bn = u.u_offset >> BSHIFT;
+               on = u.u_offset & BMASK;
+               n = min((unsigned)(BSIZE-on), u.u_count);
+               if(type!=IFBLK && type!=IFMPB) {
+                       diff = ip->i_size - u.u_offset;
+                       if(diff <= 0)
+                               return;
+                       if(diff < n)
+                               n = diff;
+                       bn = bmap(ip, bn, B_READ);
+                       if(u.u_error)
+                               return;
+                       dev = ip->i_dev;
+               } else
+                       rablock = bn+1;
+               if ((long)bn<0) {
+                       bp = geteblk();
+                       clrbuf(bp);
+               } else if (ip->i_un.i_lastr+1 == lbn)
+                       bp = breada(dev, bn, rablock);
+               else
+                       bp = bread(dev, bn);
+               ip->i_un.i_lastr = lbn;
+               n = min((unsigned)n, BSIZE-bp->b_resid);
+               if (n!=0)
+                       {
+                       iomove(bp->b_un.b_addr+on, n, B_READ);
+                       }
+               brelse(bp);
+       } while(u.u_error==0 && u.u_count!=0 && n>0);
+}
+
+/*
+ * Write the file corresponding to
+ * the inode pointed at by the argument.
+ * The actual write arguments are found
+ * in the variables:
+ *     u_base          core address for source
+ *     u_offset        byte offset in file
+ *     u_count         number of bytes to write
+ *     u_segflg        write to kernel/user/user I
+ */
+writei(ip)
+register struct inode *ip;
+{
+       struct buf *bp;
+       dev_t dev;
+       daddr_t bn;
+       register n, on;
+       register type;
+       extern int mem_no;
+
+       dev = (dev_t)ip->i_un.i_rdev;
+       if(u.u_offset < 0 && ((ip->i_mode&IFMT) != IFCHR || mem_no != major(dev)) ) {
+               u.u_error = EINVAL;
+               return;
+       }
+       type = ip->i_mode&IFMT;
+       if (type==IFCHR || type==IFMPC) {
+               ip->i_flag |= IUPD|ICHG;
+               (*cdevsw[major(dev)].d_write)(dev);
+               return;
+       }
+       if (u.u_count == 0)
+               return;
+
+       do {
+               bn = u.u_offset >> BSHIFT;
+               on = u.u_offset & BMASK;
+               n = min((unsigned)BSIZE-on, u.u_count);
+               if(type!=IFBLK && type!=IFMPB) {
+                       bn = bmap(ip, bn, B_WRITE);
+                       if((long)bn<0)
+                               return;
+                       dev = ip->i_dev;
+               }
+               if(n == BSIZE) 
+                       bp = getblk(dev, bn);
+               else
+                       bp = bread(dev, bn);
+               iomove(bp->b_un.b_addr+on, n, B_WRITE);
+               if(u.u_error != 0)
+                       brelse(bp);
+               else
+                       bdwrite(bp);
+               if(u.u_offset > ip->i_size &&
+                       (type==IFDIR || type==IFREG))
+                        ip->i_size = u.u_offset;
+               ip->i_flag |= IUPD|ICHG;
+       } while(u.u_error==0 && u.u_count!=0);
+}
+
+/*
+ * Return the logical maximum
+ * of the 2 arguments.
+ */
+max(a, b)
+unsigned a, b;
+{
+
+       if(a > b)
+               return(a);
+       return(b);
+}
+
+/*
+ * Return the logical minimum
+ * of the 2 arguments.
+ */
+min(a, b)
+unsigned a, b;
+{
+
+       if(a < b)
+               return(a);
+       return(b);
+}
+
+/*
+ * Move n bytes at byte location
+ * &bp->b_un.b_addr[o] to/from (flag) the
+ * user/kernel (u.segflg) area starting at u.base.
+ * Update all the arguments by the number
+ * of bytes moved.
+ */
+iomove(cp, n, flag)
+register caddr_t cp;
+register n;
+{
+       register t;
+
+       if (n==0)
+               return;
+       if(u.u_segflg != 1)  {
+               if (flag==B_WRITE)
+                       t = copyin(u.u_base, (caddr_t)cp, n);
+               else
+                       t = copyout((caddr_t)cp, u.u_base, n);
+               if (t) {
+                       u.u_error = EFAULT;
+                       return;
+               }
+       }
+       else
+               if (flag == B_WRITE)
+                       bcopy(u.u_base,(caddr_t)cp,n);
+               else
+                       bcopy((caddr_t)cp,u.u_base,n);
+       u.u_base += n;
+       u.u_offset += n;
+       u.u_count -= n;
+       return;
+}
diff --git a/usr/src/slowsys/sys/sig.c b/usr/src/slowsys/sys/sig.c
new file mode 100644 (file)
index 0000000..3306248
--- /dev/null
@@ -0,0 +1,415 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/proc.h"
+#include "../h/inode.h"
+#include "../h/reg.h"
+#include "../h/text.h"
+#include "../h/seg.h"
+#include "../h/mtpr.h"
+#include "../h/page.h"
+#include "../h/psl.h"
+
+/*
+ * Priority for tracing
+ */
+#define        IPCPRI  PZERO
+
+/*
+ * Tracing variables.
+ * Used to pass trace command from
+ * parent to child being traced.
+ * This data base cannot be
+ * shared and is locked
+ * per user.
+ */
+struct
+{
+       int     ip_lock;
+       int     ip_req;
+       int     *ip_addr;
+       int     ip_data;
+} ipc;
+
+/*
+ * Send the specified signal to
+ * all processes with 'pgrp' as
+ * process group.
+ * Called by tty.c for quits and
+ * interrupts.
+ */
+signal(pgrp, sig)
+register pgrp;
+{
+       register struct proc *p;
+
+       if(pgrp == 0)
+               return;
+       for(p = &proc[0]; p < &proc[NPROC]; p++)
+               if(p->p_pgrp == pgrp)
+                       psignal(p, sig);
+}
+
+/*
+ * Send the specified signal to
+ * the specified process.
+ */
+psignal(p, sig)
+register struct proc *p;
+register unsigned sig;
+{
+
+       if((unsigned)sig >= NSIG)
+               return;
+       if(sig)
+               p->p_sig |= 1<<(sig-1);
+       if(p->p_pri > PUSER)
+               p->p_pri = PUSER;
+       if(p->p_stat == SSLEEP && p->p_pri > PZERO)
+               setrun(p);
+}
+
+/*
+ * Returns true if the current
+ * process has a signal to process.
+ * This is asked at least once
+ * each time a process enters the
+ * system.
+ * A signal does not do anything
+ * directly to a process; it sets
+ * a flag that asks the process to
+ * do something to itself.
+ */
+issig()
+{
+       register n;
+       register struct proc *p;
+
+       p = u.u_procp;
+       while(p->p_sig) {
+               n = fsig(p);
+               if((u.u_signal[n]&1) == 0 || (p->p_flag&STRC))
+                       return(n);
+               p->p_sig &= ~(1<<(n-1));
+       }
+       return(0);
+}
+
+/*
+ * Enter the tracing STOP state.
+ * In this state, the parent is
+ * informed and the process is able to
+ * receive commands from the parent.
+ */
+stop()
+{
+       register struct proc *pp, *cp;
+
+loop:
+       cp = u.u_procp;
+       if(cp->p_ppid != 1)
+       for (pp = &proc[0]; pp < &proc[NPROC]; pp++)
+               if (pp->p_pid == cp->p_ppid) {
+                       wakeup((caddr_t)pp);
+                       cp->p_stat = SSTOP;
+                       swtch();
+                       if ((cp->p_flag&STRC)==0 || procxmt())
+                               return;
+                       goto loop;
+               }
+       exit(fsig(u.u_procp));
+}
+
+/*
+ * Perform the action specified by
+ * the current signal.
+ * The usual sequence is:
+ *     if(issig())
+ *             psig();
+ */
+psig()
+{
+       register n, p;
+       register struct proc *rp;
+
+       rp = u.u_procp;
+       if (rp->p_flag&STRC)
+               stop();
+       n = fsig(rp);
+       if (n==0)
+               return;
+       rp->p_sig &= ~(1<<(n-1));
+       if((p=u.u_signal[n]) != 0) {
+               u.u_error = 0;
+               if(n != SIGINS && n != SIGTRC)
+                       u.u_signal[n] = 0;
+               sendsig(p, n);
+               return;
+       }
+       switch(n) {
+
+       case SIGQUIT:
+       case SIGINS:
+       case SIGTRC:
+       case SIGIOT:
+       case SIGEMT:
+       case SIGFPT:
+       case SIGBUS:
+       case SIGSEG:
+       case SIGSYS:
+               if(core())
+                       n += 0200;
+       }
+       exit(n);
+}
+
+/*
+ * find the signal in bit-position
+ * representation in p_sig.
+ */
+fsig(p)
+struct proc *p;
+{
+       register n, i;
+
+       n = p->p_sig;
+       for(i=1; i<NSIG; i++) {
+               if(n & 1)
+                       return(i);
+               n >>= 1;
+       }
+       return(0);
+}
+
+/*
+ * Create a core image on the file "core"
+ * If you are looking for protection glitches,
+ * there are probably a wealth of them here
+ * when this occurs to a suid command.
+ *
+ * It writes USIZE block of the
+ * user.h area followed by the entire
+ * data+stack segments.
+ */
+core()
+{
+       register struct inode *ip;
+       register s;
+       extern schar();
+
+       u.u_error = 0;
+       u.u_dirp = "core";
+       ip = namei(schar, 1);
+       if(ip == NULL) {
+               if(u.u_error)
+                       return(0);
+               ip = maknode(0666);
+               if (ip==NULL)
+                       return(0);
+       }
+       if(!access(ip, IWRITE) &&
+          (ip->i_mode&IFMT) == IFREG &&
+          u.u_uid == u.u_ruid) {
+               itrunc(ip);
+               u.u_offset = 0;
+               u.u_base = (caddr_t)&u;
+               u.u_count = ctob(USIZE);
+               u.u_segflg = 1;
+               writei(ip);
+               s = u.u_procp->p_size - USIZE;
+               estabur((unsigned)0, s, (unsigned)0, 0, RO);
+               u.u_base = 0;
+               u.u_count = ctob(s);
+               u.u_segflg = 0;
+               writei(ip);
+       }
+       iput(ip);
+       return(u.u_error==0);
+}
+
+/*
+ * grow the stack to include the SP
+ * true return if successful.
+ */
+
+grow(sp)
+unsigned sp;
+{
+       register si, i;
+       register struct proc *p;
+       register a;
+
+       if(sp >= USRSTACK-ctob(u.u_ssize))
+               return(0);
+       si = btoc((USRSTACK-sp)) - u.u_ssize + SINCR;
+       if(si <= 0)
+               return(0);
+       if(estabur(u.u_tsize, u.u_dsize, u.u_ssize+si, u.u_sep, RO))
+               return(0);
+       p = u.u_procp;
+       expand(p->p_size+si);
+       a = p->p_addr + p->p_size;
+       for(i=u.u_ssize; i; i--) {
+               a--;
+               copyseg(a-si, a);
+       }
+       for(i=si; i; i--)
+               clearseg(--a);
+       u.u_ssize += si;
+       return(1);
+}
+
+/*
+ * sys-trace system call.
+ */
+ptrace()
+{
+       register struct proc *p;
+       register struct a {
+               int     req;
+               int     pid;
+               int     *addr;
+               int     data;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       if (uap->req <= 0) {
+               u.u_procp->p_flag |= STRC;
+               return;
+       }
+       for (p=proc; p < &proc[NPROC]; p++) 
+               if (p->p_stat==SSTOP
+                && p->p_pid==uap->pid
+                && p->p_ppid==u.u_procp->p_pid)
+                       goto found;
+       u.u_error = ESRCH;
+       return;
+
+    found:
+       while (ipc.ip_lock)
+               sleep((caddr_t)&ipc, IPCPRI);
+       ipc.ip_lock = p->p_pid;
+       ipc.ip_data = uap->data;
+       ipc.ip_addr = uap->addr;
+       ipc.ip_req = uap->req;
+       p->p_flag &= ~SWTED;
+       setrun(p);
+       while (ipc.ip_req > 0)
+               sleep((caddr_t)&ipc, IPCPRI);
+       u.u_r.r_val1 = ipc.ip_data;
+       if (ipc.ip_req < 0)
+               u.u_error = EIO;
+       ipc.ip_lock = 0;
+       wakeup((caddr_t)&ipc);
+}
+
+int ipcreg[] = {R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, AP, FP, SP, PC};
+/*
+ * Code that the child process
+ * executes to implement the command
+ * of the parent process in tracing.
+ */
+procxmt()
+{
+       register int i;
+       register *p;
+       register struct text *xp;
+
+       if (ipc.ip_lock != u.u_procp->p_pid)
+               return(0);
+       i = ipc.ip_req;
+       ipc.ip_req = 0;
+       wakeup((caddr_t)&ipc);
+       switch (i) {
+
+       /* read user I */
+       case 1:
+               if ( !useracc((caddr_t)ipc.ip_addr, 4, 1))
+                       goto error;
+               ipc.ip_data = fuiword((caddr_t)ipc.ip_addr);
+               break;
+
+       /* read user D */
+       case 2:
+               if ( !useracc((caddr_t)ipc.ip_addr, 4, 1))
+                       goto error;
+               ipc.ip_data = fuword((caddr_t)ipc.ip_addr);
+               break;
+
+       /* read u */
+       case 3:
+               i = (int)ipc.ip_addr;
+               if (i<0 || i >= ctob(USIZE))
+                       goto error;
+               ipc.ip_data = ((physadr)&u)->r[i>>2];
+               break;
+
+       /* write user I */
+       /* Must set up to allow writing */
+       case 4:
+               /*
+                * If text, must assure exclusive use
+                */
+               if (xp = u.u_procp->p_textp) {
+                       if (xp->x_count!=1 || xp->x_iptr->i_mode&ISVTX)
+                               goto error;
+                       xp->x_iptr->i_flag &= ~ITEXT;
+               }
+               estabur(u.u_tsize, u.u_dsize, u.u_ssize, u.u_sep, RW);
+               i = suiword((caddr_t)ipc.ip_addr, 0);
+               suiword((caddr_t)ipc.ip_addr, ipc.ip_data);
+               estabur(u.u_tsize, u.u_dsize, u.u_ssize, u.u_sep, RO);
+               if (i<0)
+                       goto error;
+               if (xp)
+                       xp->x_flag |= XWRIT;
+               break;
+
+       /* write user D */
+       case 5:
+               if (suword((caddr_t)ipc.ip_addr, 0) < 0)
+                       goto error;
+               suword((caddr_t)ipc.ip_addr, ipc.ip_data);
+               break;
+
+       /* write u */
+       case 6:
+               i = (int)ipc.ip_addr;
+               p = (int *)&((physadr)&u)->r[i>>2];
+               for (i=0; i<16; i++)
+                       if (p == &u.u_ar0[ipcreg[i]])
+                               goto ok;
+               if (p == &u.u_ar0[PS]) {
+                       ipc.ip_data |= 0x3c00000; /* modes == user */
+                       ipc.ip_data &=  ~0x3c20ff00; /* IS, FPD,  ... */
+                       goto ok;
+               }
+               goto error;
+
+       ok:
+               *p = ipc.ip_data;
+               break;
+
+       /* set signal and continue */
+       /*  one version causes a trace-trap */
+       case 9:
+               u.u_ar0[PS] |= PSL_T;
+       case 7:
+               if ((int)ipc.ip_addr != 1)
+                       u.u_ar0[PC] = (int)ipc.ip_addr;
+               u.u_procp->p_sig = 0;
+               if (ipc.ip_data)
+                       psignal(u.u_procp, ipc.ip_data);
+               return(1);
+
+       /* force exit */
+       case 8:
+               exit(fsig(u.u_procp));
+
+       default:
+       error:
+               ipc.ip_req = -1;
+       }
+       return(0);
+}
diff --git a/usr/src/slowsys/sys/slp.c b/usr/src/slowsys/sys/slp.c
new file mode 100644 (file)
index 0000000..2c231cd
--- /dev/null
@@ -0,0 +1,547 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/proc.h"
+#include "../h/text.h"
+#include "../h/uba.h"
+#include "../h/map.h"
+#include "../h/file.h"
+#include "../h/inode.h"
+#include "../h/buf.h"
+
+/*
+ * Give up the processor till a wakeup occurs
+ * on chan, at which time the process
+ * enters the scheduling queue at priority pri.
+ * The most important effect of pri is that when
+ * pri<=PZERO a signal cannot disturb the sleep;
+ * if pri>PZERO signals will be processed.
+ * Callers of this routine must be prepared for
+ * premature return, and check that the reason for
+ * sleeping has gone away.
+ */
+sleep(chan, pri)
+caddr_t chan;
+{
+       register struct proc *rp;
+       register s;
+
+       rp = u.u_procp;
+       s = spl6();
+       rp->p_stat = SSLEEP;
+       rp->p_wchan = chan;
+       rp->p_pri = pri;
+       if(pri > PZERO) {
+               if(issig()) {
+                       rp->p_wchan = 0;
+                       rp->p_stat = SRUN;
+                       spl0();
+                       goto psig;
+               }
+               spl0();
+               if(runin != 0) {
+                       runin = 0;
+                       wakeup((caddr_t)&runin);
+               }
+               swtch();
+               if(issig())
+                       goto psig;
+       } else {
+               spl0();
+               swtch();
+       }
+       splx(s);
+       return;
+
+       /*
+        * If priority was low (>PZERO) and
+        * there has been a signal,
+        * execute non-local goto to
+        * the qsav location.
+        * (see trap1/trap.c)
+        */
+psig:
+       resume(u.u_procp->p_addr, u.u_qsav);
+}
+
+/*
+ * Wake up all processes sleeping on chan.
+ */
+wakeup(chan)
+register caddr_t chan;
+{
+       register struct proc *p;
+       register i;
+       int s;
+
+       p = &proc[0];
+       i = NPROC;
+       do {
+               if(p->p_wchan==chan && p->p_stat!=SZOMB) {
+                       /*
+                        * this code looks dumb, but
+                        * there is a possible race due
+                        * to interrupts.
+                        */
+                       s = spl6();
+                       if(p->p_wchan == chan)
+                               setrun(p);
+                       splx(s);
+               }
+               p++;
+       } while(--i);
+}
+
+/*
+ * when you are sure that it
+ * is impossible to get the
+ * 'proc on q' diagnostic, the
+ * diagnostic loop can be removed.
+ */
+setrq(p)
+struct proc *p;
+{
+       register struct proc *q;
+       register s;
+
+       s = spl6();
+       for(q=runq; q!=NULL; q=q->p_link)
+               if(q == p) {
+                       printf("proc on q\n");
+                       goto out;
+               }
+       p->p_link = runq;
+       runq = p;
+out:
+       splx(s);
+}
+
+/*
+ * Set the process running;
+ * arrange for it to be swapped in if necessary.
+ */
+setrun(p)
+register struct proc *p;
+{
+
+       if (p->p_stat==0 || p->p_stat==SZOMB)
+               panic("Running a dead proc");
+       p->p_wchan = 0;
+       p->p_stat = SRUN;
+       setrq(p);
+       if(p->p_pri < curpri)
+               runrun++;
+       if(runout != 0 && (p->p_flag&SLOAD) == 0) {
+               runout = 0;
+               wakeup((caddr_t)&runout);
+       }
+}
+
+/*
+ * Set user priority.
+ * The rescheduling flag (runrun)
+ * is set if the priority is better
+ * than the currently running process.
+ */
+setpri(pp)
+register struct proc *pp;
+{
+       register p;
+
+       p = (pp->p_cpu & 0377)/16;
+       p += PUSER + pp->p_nice - NZERO;
+       if(p > 127)
+               p = 127;
+       if(p < curpri)
+               runrun++;
+       pp->p_pri = p;
+       return(p);
+}
+
+/*
+ * The main loop of the scheduling (swapping)
+ * process.
+ * The basic idea is:
+ *  see if anyone wants to be swapped in;
+ *  swap out processes until there is room;
+ *  swap him in;
+ *  repeat.
+ * The runout flag is set whenever someone is swapped out.
+ * Sched sleeps on it awaiting work.
+ *
+ * Sched sleeps on runin whenever it cannot find enough
+ * core (by swapping out or otherwise) to fit the
+ * selected swapped process.  It is awakened when the
+ * core situation changes and in any case once per second.
+ */
+sched()
+{
+       register struct proc *rp, *p;
+       register outage, inage;
+       int maxsize;
+
+       /*
+        * find user to swap in;
+        * of users ready, select one out longest
+        */
+
+loop:
+       spl6();
+       outage = -20000;
+       for (rp = &proc[0]; rp < &proc[NPROC]; rp++)
+       if (rp->p_stat==SRUN && (rp->p_flag&SLOAD)==0 &&
+           rp->p_time - (rp->p_nice-NZERO)*8 > outage) {
+               p = rp;
+               outage = rp->p_time - (rp->p_nice-NZERO)*8;
+       }
+       /*
+        * If there is no one there, wait.
+        */
+       if (outage == -20000) {
+               runout++;
+               sleep((caddr_t)&runout, PSWP);
+               goto loop;
+       }
+       spl0();
+
+       /*
+        * See if there is core for that process;
+        * if so, swap it in.
+        */
+
+       if (swapin(p))
+               goto loop;
+
+       /*
+        * none found.
+        * look around for core.
+        * Select the largest of those sleeping
+        * at bad priority; if none, select the oldest.
+        */
+
+       spl6();
+       p = NULL;
+       maxsize = -1;
+       inage = -1;
+       for (rp = &proc[0]; rp < &proc[NPROC]; rp++) {
+               if (rp->p_stat==SZOMB
+                || (rp->p_flag&(SSYS|SLOCK|SULOCK|SLOAD))!=SLOAD)
+                       continue;
+               if (rp->p_textp && rp->p_textp->x_flag&XLOCK)
+                       continue;
+               if (rp->p_stat==SSLEEP&&rp->p_pri>=PZERO || rp->p_stat==SSTOP) {
+                       if (maxsize < rp->p_size) {
+                               p = rp;
+                               maxsize = rp->p_size;
+                       }
+               } else if (maxsize<0 && (rp->p_stat==SRUN||rp->p_stat==SSLEEP)) {
+                       if (rp->p_time+rp->p_nice-NZERO > inage) {
+                               p = rp;
+                               inage = rp->p_time+rp->p_nice-NZERO;
+                       }
+               }
+       }
+       spl0();
+       /*
+        * Swap found user out if sleeping at bad pri,
+        * or if he has spent at least 2 seconds in core and
+        * the swapped-out process has spent at least 3 seconds out.
+        * Otherwise wait a bit and try again.
+        */
+       if (maxsize>=0 || (outage>=3 && inage>=2)) {
+               p->p_flag &= ~SLOAD;
+               xswap(p, 1, 0);
+               goto loop;
+       }
+       spl6();
+       runin++;
+       sleep((caddr_t)&runin, PSWP);
+       goto loop;
+}
+
+/*
+ * Swap a process in.
+ * Allocate data and possible text separately.
+ * It would be better to do largest first.
+ */
+swapin(p)
+register struct proc *p;
+{
+       register struct text *xp;
+       register int a;
+       int x;
+
+       if ((a = malloc(coremap, p->p_size)) == NULL)
+               return(0);
+       if (xp = p->p_textp) {
+               xlock(xp);
+               if (xp->x_ccount==0) {
+                       if ((x = malloc(coremap, xp->x_size)) == NULL) {
+                               xunlock(xp);
+                               mfree(coremap, p->p_size, a);
+                               return(0);
+                       }
+                       xp->x_caddr = x;
+                       if ((xp->x_flag&XLOAD)==0)
+                               swap(xp->x_daddr,x,xp->x_size,B_READ);
+               }
+               xp->x_ccount++;
+               xunlock(xp);
+       }
+       swap(p->p_addr, a, p->p_size, B_READ);
+       mfree(swapmap, ctod(p->p_size), p->p_addr);
+       p->p_addr = a;
+       p->p_flag |= SLOAD;
+       p->p_time = 0;
+       return(1);
+}
+
+/*
+ * put the current process on
+ * the Q of running processes and
+ * call the scheduler.
+ */
+qswtch()
+{
+
+       setrq(u.u_procp);
+       swtch();
+}
+
+/*
+ * This routine is called to reschedule the CPU.
+ * if the calling process is not in RUN state,
+ * arrangements for it to restart must have
+ * been made elsewhere, usually by calling via sleep.
+ * There is a race here. A process may become
+ * ready after it has been examined.
+ * In this case, idle() will be called and
+ * will return in at most 1HZ time.
+ * i.e. its not worth putting an spl() in.
+ */
+swtch()
+{
+       register n;
+       register struct proc *p, *q, *pp, *pq;
+
+       /*
+        * If not the idle process, resume the idle process.
+        */
+       if (u.u_procp != &proc[0]) {
+               if (save(u.u_rsav)) {
+                       sureg();
+                       return;
+               }
+               resume(proc[0].p_addr, u.u_qsav);
+       }
+       /*
+        * The first save returns nonzero when proc 0 is resumed
+        * by another process (above); then the second is not done
+        * and the process-search loop is entered.
+        *
+        * The first save returns 0 when swtch is called in proc 0
+        * from sched().  The second save returns 0 immediately, so
+        * in this case too the process-search loop is entered.
+        * Thus when proc 0 is awakened by being made runnable, it will
+        * find itself and resume itself at rsav, and return to sched().
+        */
+       if (save(u.u_qsav)==0 && save(u.u_rsav))
+               return;
+loop:
+       spl6();
+       runrun = 0;
+       pp = NULL;
+       q = NULL;
+       n = 128;
+       /*
+        * Search for highest-priority runnable process
+        */
+       for(p=runq; p!=NULL; p=p->p_link) {
+               if((p->p_stat==SRUN) && (p->p_flag&SLOAD)) {
+                       if(p->p_pri < n) {
+                               pp = p;
+                               pq = q;
+                               n = p->p_pri;
+                       }
+               }
+               q = p;
+       }
+       /*
+        * If no process is runnable, idle.
+        */
+       p = pp;
+       if(p == NULL) {
+               idle();
+               goto loop;
+       }
+       q = pq;
+       if(q == NULL)
+               runq = p->p_link;
+       else
+               q->p_link = p->p_link;
+       curpri = n;
+       spl0();
+       /*
+        * The rsav (ssav) contents are interpreted in the new address space
+        */
+       n = p->p_flag&SSWAP;
+       p->p_flag &= ~SSWAP;
+       resume(p->p_addr, n? u.u_ssav: u.u_rsav);
+}
+
+/*
+ * Create a new process-- the internal version of
+ * sys fork.
+ * It returns 1 in the new process, 0 in the old.
+ */
+newproc()
+{
+       int a1, a2;
+       struct proc *p, *up;
+       register struct proc *rpp, *rip;
+       register n;
+
+       p = NULL;
+       /*
+        * First, just locate a slot for a process
+        * and copy the useful info from this process into it.
+        * The panic "cannot happen" because fork has already
+        * checked for the existence of a slot.
+        */
+retry:
+       mpid++;
+       if(mpid >= 30000) {
+               mpid = 0;
+               goto retry;
+       }
+       for(rpp = &proc[0]; rpp < &proc[NPROC]; rpp++) {
+               if(rpp->p_stat == NULL && p==NULL)
+                       p = rpp;
+               if (rpp->p_pid==mpid || rpp->p_pgrp==mpid)
+                       goto retry;
+       }
+       if ((rpp = p)==NULL)
+               panic("no procs");
+
+       /*
+        * make proc entry for new proc
+        */
+
+       rip = u.u_procp;
+       up = rip;
+       rpp->p_stat = SRUN;
+       rpp->p_clktim = 0;
+       rpp->p_flag = SLOAD;
+       rpp->p_uid = rip->p_uid;
+       rpp->p_pgrp = rip->p_pgrp;
+       rpp->p_nice = rip->p_nice;
+       rpp->p_textp = rip->p_textp;
+       rpp->p_pid = mpid;
+       rpp->p_ppid = rip->p_pid;
+       rpp->p_time = 0;
+       rpp->p_cpu = 0;
+
+       /*
+        * make duplicate entries
+        * where needed
+        */
+
+       for(n=0; n<NOFILE; n++)
+               if(u.u_ofile[n] != NULL)
+                       u.u_ofile[n]->f_count++;
+       if(up->p_textp != NULL) {
+               up->p_textp->x_count++;
+               up->p_textp->x_ccount++;
+       }
+       u.u_cdir->i_count++;
+       if (u.u_rdir)
+               u.u_rdir->i_count++;
+       /*
+        * Partially simulate the environment
+        * of the new process so that when it is actually
+        * created (by copying) it will look right.
+        */
+       rpp = p;
+       u.u_procp = rpp;
+       rip = up;
+       n = rip->p_size;
+       a1 = rip->p_addr;
+       rpp->p_size = n;
+       /*
+        * When the resume is executed for the new process,
+        * here's where it will resume.
+        */
+       if (save(u.u_ssav)) {
+               sureg();
+               return(1);
+       }
+       a2 = malloc(coremap, n);
+       /*
+        * If there is not enough core for the
+        * new process, swap out the current process to generate the
+        * copy.
+        */
+       if(a2 == NULL) {
+               rip->p_stat = SIDL;
+               rpp->p_addr = a1;
+               xswap(rpp, 0, 0);
+               rip->p_stat = SRUN;
+       } else {
+               /*
+                * There is core, so just copy.
+                */
+               rpp->p_addr = a2;
+               while(n--)
+                       copyseg(a1++, a2++);
+       }
+       u.u_procp = rip;
+       setrq(rpp);
+       rpp->p_flag |= SSWAP;
+       return(0);
+}
+
+/*
+ * Change the size of the data+stack regions of the process.
+ * If the size is shrinking, it's easy-- just release the extra core.
+ * If it's growing, and there is core, just allocate it
+ * and copy the image, taking care to reset registers to account
+ * for the fact that the system's stack has moved.
+ * If there is no core, arrange for the process to be swapped
+ * out after adjusting the size requirement-- when it comes
+ * in, enough core will be allocated.
+ *
+ * After the expansion, the caller will take care of copying
+ * the user's stack towards or away from the data area.
+ */
+expand(newsize)
+{
+       register i, n;
+       register struct proc *p;
+       register a1, a2;
+
+       p = u.u_procp;
+       n = p->p_size;
+       p->p_size = newsize;
+       a1 = p->p_addr;
+       if(n >= newsize) {
+               mfree(coremap, n-newsize, a1+newsize);
+               return;
+       }
+       if (save(u.u_ssav)) {
+               sureg();
+               return;
+       }
+       a2 = malloc(coremap, newsize);
+       if(a2 == NULL) {
+               xswap(p, 1, n);
+               p->p_flag |= SSWAP;
+               qswtch();
+               /* no return */
+       }
+       p->p_addr = a2;
+       for(i=0; i<n; i++)
+               copyseg(a1+i, a2+i);
+       mfree(coremap, n, a1);
+       resume(a2, u.u_ssav);
+}
diff --git a/usr/src/slowsys/sys/subr.c b/usr/src/slowsys/sys/subr.c
new file mode 100644 (file)
index 0000000..23958ba
--- /dev/null
@@ -0,0 +1,188 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/conf.h"
+#include "../h/inode.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/buf.h"
+
+/*
+ * Bmap defines the structure of file system storage
+ * by returning the physical block number on a device given the
+ * inode and the logical block number in a file.
+ * When convenient, it also leaves the physical
+ * block number of the next block of the file in rablock
+ * for use in read-ahead.
+ */
+daddr_t
+bmap(ip, bn, rwflg)
+register struct inode *ip;
+daddr_t bn;
+{
+       register i;
+       struct buf *bp, *nbp;
+       int j, sh;
+       daddr_t nb, *bap;
+       dev_t dev;
+
+       if(bn < 0) {
+               u.u_error = EFBIG;
+               return((daddr_t)0);
+       }
+       dev = ip->i_dev;
+       rablock = 0;
+
+       /*
+        * blocks 0..NADDR-4 are direct blocks
+        */
+       if(bn < NADDR-3) {
+               i = bn;
+               nb = ip->i_un.i_addr[i];
+               if(nb == 0) {
+                       if(rwflg==B_READ || (bp = alloc(dev))==NULL)
+                               return((daddr_t)-1);
+                       nb = bp->b_blkno;
+                       bdwrite(bp);
+                       ip->i_un.i_addr[i] = nb;
+                       ip->i_flag |= IUPD|ICHG;
+               }
+               if(i < NADDR-4)
+                       rablock = ip->i_un.i_addr[i+1];
+               return(nb);
+       }
+
+       /*
+        * addresses NADDR-3, NADDR-2, and NADDR-1
+        * have single, double, triple indirect blocks.
+        * the first step is to determine
+        * how many levels of indirection.
+        */
+       sh = 0;
+       nb = 1;
+       bn -= NADDR-3;
+       for(j=3; j>0; j--) {
+               sh += NSHIFT;
+               nb <<= NSHIFT;
+               if(bn < nb)
+                       break;
+               bn -= nb;
+       }
+       if(j == 0) {
+               u.u_error = EFBIG;
+               return((daddr_t)0);
+       }
+
+       /*
+        * fetch the address from the inode
+        */
+       nb = ip->i_un.i_addr[NADDR-j];
+       if(nb == 0) {
+               if(rwflg==B_READ || (bp = alloc(dev))==NULL)
+                       return((daddr_t)-1);
+               nb = bp->b_blkno;
+               bdwrite(bp);
+               ip->i_un.i_addr[NADDR-j] = nb;
+               ip->i_flag |= IUPD|ICHG;
+       }
+
+       /*
+        * fetch through the indirect blocks
+        */
+       for(; j<=3; j++) {
+               bp = bread(dev, nb);
+               if(bp->b_flags & B_ERROR) {
+                       brelse(bp);
+                       return((daddr_t)0);
+               }
+               bap = bp->b_un.b_daddr;
+               sh -= NSHIFT;
+               i = (bn>>sh) & NMASK;
+               nb = bap[i];
+               if(nb == 0) {
+                       if(rwflg==B_READ || (nbp = alloc(dev))==NULL) {
+                               brelse(bp);
+                               return((daddr_t)-1);
+                       }
+                       nb = nbp->b_blkno;
+                       bdwrite(nbp);
+                       bap[i] = nb;
+                       bdwrite(bp);
+               } else
+                       brelse(bp);
+       }
+
+       /*
+        * calculate read-ahead.
+        */
+       if(i < NINDIR-1)
+               rablock = bap[i+1];
+       return(nb);
+}
+
+/*
+ * Pass back  c  to the user at his location u_base;
+ * update u_base, u_count, and u_offset.  Return -1
+ * on the last character of the user's read.
+ * u_base is in the user address space unless u_segflg is set.
+ */
+passc(c)
+register c;
+{
+       register id;
+
+       if((id = u.u_segflg) == 1)
+               *u.u_base = c;
+       else
+               if(id?suibyte(u.u_base, c):subyte(u.u_base, c) < 0) {
+                       u.u_error = EFAULT;
+                       return(-1);
+               }
+       u.u_count--;
+       u.u_offset++;
+       u.u_base++;
+       return(u.u_count == 0? -1: 0);
+}
+
+/*
+ * Pick up and return the next character from the user's
+ * write call at location u_base;
+ * update u_base, u_count, and u_offset.  Return -1
+ * when u_count is exhausted.  u_base is in the user's
+ * address space unless u_segflg is set.
+ */
+cpass()
+{
+       register c, id;
+
+       if(u.u_count == 0)
+               return(-1);
+       if((id = u.u_segflg) == 1)
+               c = *u.u_base;
+       else
+               if((c = id==0?fubyte(u.u_base):fuibyte(u.u_base)) < 0) {
+                       u.u_error = EFAULT;
+                       return(-1);
+               }
+       u.u_count--;
+       u.u_offset++;
+       u.u_base++;
+       return(c&0377);
+}
+
+/*
+ * Routine which sets a user error; placed in
+ * illegal entries in the bdevsw and cdevsw tables.
+ */
+nodev()
+{
+
+       u.u_error = ENODEV;
+}
+
+/*
+ * Null routine; placed in insignificant entries
+ * in the bdevsw and cdevsw tables.
+ */
+nulldev()
+{
+}
diff --git a/usr/src/slowsys/sys/sys.c b/usr/src/slowsys/sys/sys.c
new file mode 100644 (file)
index 0000000..80c77f9
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ *     indirect driver for controlling tty.
+ */
+#include "../h/param.h"
+#include "../h/conf.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/tty.h"
+#include "../h/proc.h"
+
+syopen(dev, flag)
+{
+
+       if(u.u_ttyp == NULL) {
+               u.u_error = ENXIO;
+               return;
+       }
+       (*cdevsw[major(u.u_ttyd)].d_open)(u.u_ttyd, flag);
+}
+
+syread(dev)
+{
+
+       (*cdevsw[major(u.u_ttyd)].d_read)(u.u_ttyd);
+}
+
+sywrite(dev)
+{
+
+       (*cdevsw[major(u.u_ttyd)].d_write)(u.u_ttyd);
+}
+
+sysioctl(dev, cmd, addr, flag)
+caddr_t addr;
+{
+
+       (*cdevsw[major(u.u_ttyd)].d_ioctl)(u.u_ttyd, cmd, addr, flag);
+}
diff --git a/usr/src/slowsys/sys/sys1.c b/usr/src/slowsys/sys/sys1.c
new file mode 100644 (file)
index 0000000..5abb6ed
--- /dev/null
@@ -0,0 +1,515 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/uba.h"
+#include "../h/map.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/proc.h"
+#include "../h/buf.h"
+#include "../h/reg.h"
+#include "../h/inode.h"
+#include "../h/seg.h"
+#include "../h/acct.h"
+#include "../h/page.h"
+
+/*
+ * exec system call, with and without environments.
+ */
+struct execa {
+       char    *fname;
+       char    **argp;
+       char    **envp;
+};
+
+exec()
+{
+       ((struct execa *)u.u_ap)->envp = NULL;
+       exece();
+}
+
+exece()
+{
+       register nc;
+       register char *cp;
+       register struct buf *bp;
+       register struct execa *uap;
+       int na, ne, bno, ucp, ap, c;
+       struct inode *ip;
+
+       if ((ip = namei(uchar, 0)) == NULL)
+               return;
+       bno = 0;
+       bp = 0;
+       if(access(ip, IEXEC))
+               goto bad;
+       if((ip->i_mode & IFMT) != IFREG ||
+          (ip->i_mode & (IEXEC|(IEXEC>>3)|(IEXEC>>6))) == 0) {
+               u.u_error = EACCES;
+               goto bad;
+       }
+       /*
+        * Collect arguments on "file" in swap space.
+        */
+       na = 0;
+       ne = 0;
+       nc = 0;
+       uap = (struct execa *)u.u_ap;
+       if ((bno = malloc(swapmap,(NCARGS+BSIZE-1)/BSIZE)) == 0)
+               panic("Out of swap");
+       if (uap->argp) for (;;) {
+               ap = NULL;
+               if (uap->argp) {
+                       ap = fuword((caddr_t)uap->argp);
+                       uap->argp++;
+               }
+               if (ap==NULL && uap->envp) {
+                       uap->argp = NULL;
+                       if ((ap = fuword((caddr_t)uap->envp)) == NULL)
+                               break;
+                       uap->envp++;
+                       ne++;
+               }
+               if (ap==NULL)
+                       break;
+               na++;
+               if(ap == -1)
+                       u.u_error = EFAULT;
+               do {
+                       if (nc >= NCARGS-1)
+                               u.u_error = E2BIG;
+                       if ((c = fubyte((caddr_t)ap++)) < 0)
+                               u.u_error = EFAULT;
+                       if (u.u_error)
+                               goto bad;
+                       if ((nc&BMASK) == 0) {
+                               if (bp)
+                                       bawrite(bp);
+                               bp = getblk(swapdev, swplo+bno+(nc>>BSHIFT));
+                               cp = bp->b_un.b_addr;
+                       }
+                       nc++;
+                       *cp++ = c;
+               } while (c>0);
+       }
+       if (bp)
+               bawrite(bp);
+       bp = 0;
+       nc = (nc + NBPW-1) & ~(NBPW-1);
+       if (getxfile(ip, nc) || u.u_error)
+               goto bad;
+
+       /*
+        * copy back arglist
+        */
+
+       ucp = USRSTACK - nc - NBPW;
+       ap = ucp - na*NBPW - 3*NBPW;
+       u.u_ar0[SP] = ap;
+       suword((caddr_t)ap, na-ne);
+       nc = 0;
+       for (;;) {
+               ap += NBPW;
+               if (na==ne) {
+                       suword((caddr_t)ap, 0);
+                       ap += NBPW;
+               }
+               if (--na < 0)
+                       break;
+               suword((caddr_t)ap, ucp);
+               do {
+                       if ((nc&BMASK) == 0) {
+                               if (bp)
+                                       brelse(bp);
+                               bp = bread(swapdev, swplo+bno+(nc>>BSHIFT));
+                               cp = bp->b_un.b_addr;
+                       }
+                       subyte((caddr_t)ucp++, (c = *cp++));
+                       nc++;
+               } while(c&0377);
+       }
+       suword((caddr_t)ap, 0);
+       suword((caddr_t)ucp, 0);
+       setregs();
+bad:
+       if (bp)
+               brelse(bp);
+       if(bno)
+               mfree(swapmap, (NCARGS+BSIZE-1)/BSIZE, bno);
+       iput(ip);
+}
+
+/*
+ * Read in and set up memory for executed file.
+ * Zero return is normal;
+ * non-zero means only the text is being replaced
+ */
+getxfile(ip, nargc)
+register struct inode *ip;
+{
+       register unsigned ds;
+       register sep;
+       register unsigned ts, ss;
+       register i, overlay;
+
+       /*
+        * read in first few bytes
+        * of file for segment
+        * sizes:
+        * ux_mag = 407/410/411/405
+        *  407 is plain executable
+        *  410 is RO text
+        *  411 is separated ID
+        *  405 is overlaid text
+        */
+
+       u.u_base = (caddr_t)&u.u_exdata;
+       u.u_count = sizeof(u.u_exdata);
+       u.u_offset = 0;
+       u.u_segflg = 1;
+       readi(ip);
+       u.u_segflg = 0;
+       if(u.u_error)
+               goto bad;
+       if (u.u_count!=0) {
+               u.u_error = ENOEXEC;
+               goto bad;
+       }
+       sep = 0;
+       overlay = 0;
+       if(u.u_exdata.ux_mag == 0407) {
+               u.u_exdata.ux_dsize += u.u_exdata.ux_tsize;
+               u.u_exdata.ux_tsize = 0;
+       } else if (u.u_exdata.ux_mag == 0411)
+               sep++;
+       else if (u.u_exdata.ux_mag == 0405)
+               overlay++;
+       else if (u.u_exdata.ux_mag != 0410) {
+               u.u_error = ENOEXEC;
+               goto bad;
+       }
+       if(u.u_exdata.ux_tsize!=0 && (ip->i_flag&ITEXT)==0 && ip->i_count!=1) {
+               u.u_error = ETXTBSY;
+               goto bad;
+       }
+
+       /*
+        * find text and data sizes
+        * try them out for possible
+        * exceed of max sizes
+        */
+
+       ts = btoc(u.u_exdata.ux_tsize);
+       ds = btoc(u.u_exdata.ux_dsize + u.u_exdata.ux_bsize);
+       ss = SSIZE + btoc(nargc);
+       if (overlay) {
+               if (u.u_sep==0 && ctos(ts) != ctos(u.u_tsize) || nargc) {
+                       u.u_error = ENOMEM;
+                       goto bad;
+               }
+               ds = u.u_dsize;
+               ss = u.u_ssize;
+               sep = u.u_sep;
+               xfree();
+               xalloc(ip);
+               u.u_ar0[PC] = u.u_exdata.ux_entloc + 2; /* skip over entry mask */
+       } else {
+               if(estabur(ts, ds, ss, sep, RO))
+                       goto bad;
+       
+               /*
+                * allocate and clear core
+                * at this point, committed
+                * to the new image
+                */
+       
+               u.u_prof.pr_scale = 0;
+               xfree();
+               i = USIZE+ds+ss;
+               expand(i);
+               while(--i >= USIZE)
+                       clearseg(u.u_procp->p_addr+i);
+               xalloc(ip);
+       
+               /*
+                * read in data segment
+                */
+       
+               estabur((unsigned)0, ds, (unsigned)0, 0, RO);
+               u.u_base = 0;
+               u.u_offset = sizeof(u.u_exdata)+u.u_exdata.ux_tsize;
+               u.u_count = u.u_exdata.ux_dsize;
+               readi(ip);
+               /*
+                * set SUID/SGID protections, if no tracing
+                */
+               if ((u.u_procp->p_flag&STRC)==0) {
+                       if(ip->i_mode&ISUID)
+                               if(u.u_uid != 0) {
+                                       u.u_uid = ip->i_uid;
+                                       u.u_procp->p_uid = ip->i_uid;
+                               }
+                       if(ip->i_mode&ISGID)
+                               u.u_gid = ip->i_gid;
+               } else
+                       psignal(u.u_procp, SIGTRC);
+       }
+       u.u_tsize = ts;
+       u.u_dsize = ds;
+       u.u_ssize = ss;
+       u.u_sep = sep;
+       estabur(ts, ds, ss, sep, RO);
+bad:
+       return(overlay);
+}
+
+/*
+ * Clear registers on exec
+ */
+setregs()
+{
+       register int *rp;
+       register char *cp;
+       register i;
+
+       for(rp = &u.u_signal[0]; rp < &u.u_signal[NSIG]; rp++)
+               if((*rp & 1) == 0)
+                       *rp = 0;
+/*
+       for(rp = &u.u_ar0[0]; rp < &u.u_ar0[16];)
+               *rp++ = 0;
+*/
+       u.u_ar0[PC] = u.u_exdata.ux_entloc + 2; /* skip over entry mask */
+       for(i=0; i<NOFILE; i++) {
+               if (u.u_pofile[i]&EXCLOSE) {
+                       closef(u.u_ofile[i]);
+                       u.u_ofile[i] = NULL;
+               }
+       }
+       /*
+        * Remember file name for accounting.
+        */
+       u.u_acflag &= ~AFORK;
+       bcopy((caddr_t)u.u_dbuf, (caddr_t)u.u_comm, DIRSIZ);
+}
+
+/*
+ * exit system call:
+ * pass back caller's arg
+ */
+rexit()
+{
+       register struct a {
+               int     rval;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       exit((uap->rval & 0377) << 8);
+}
+
+/*
+ * Release resources.
+ * Save u. area for parent to look at.
+ * Enter zombie state.
+ * Wake up parent and init processes,
+ * and dispose of children.
+ */
+exit(rv)
+{
+       register int i;
+       register struct proc *p, *q;
+       register struct file *f;
+
+       p = u.u_procp;
+       p->p_flag &= ~(STRC|SULOCK);
+       p->p_clktim = 0;
+       for(i=0; i<NSIG; i++)
+               u.u_signal[i] = 1;
+       for(i=0; i<NOFILE; i++) {
+               f = u.u_ofile[i];
+               u.u_ofile[i] = NULL;
+               closef(f);
+       }
+       plock(u.u_cdir);
+       iput(u.u_cdir);
+       if (u.u_rdir) {
+               plock(u.u_rdir);
+               iput(u.u_rdir);
+       }
+       xfree();
+       acct();
+       mfree(coremap, p->p_size, p->p_addr);
+       p->p_stat = SZOMB;
+       ((struct xproc *)p)->xp_xstat = rv;
+       ((struct xproc *)p)->xp_utime = u.u_cutime + u.u_utime;
+       ((struct xproc *)p)->xp_stime = u.u_cstime + u.u_stime;
+       for(q = &proc[0]; q < &proc[NPROC]; q++)
+               if(q->p_ppid == p->p_pid) {
+                       wakeup((caddr_t)&proc[1]);
+                       q->p_ppid = 1;
+                       if (q->p_stat==SSTOP)
+                               setrun(q);
+               }
+       for(q = &proc[0]; q < &proc[NPROC]; q++)
+               if(p->p_ppid == q->p_pid) {
+                       wakeup((caddr_t)q);
+                       swtch();
+                       /* no return */
+               }
+       swtch();
+}
+
+/*
+ * Wait system call.
+ * Search for a terminated (zombie) child,
+ * finally lay it to rest, and collect its status.
+ * Look also for stopped (traced) children,
+ * and pass back status from them.
+ */
+wait()
+{
+       register f;
+       register struct proc *p;
+
+       f = 0;
+
+loop:
+       for(p = &proc[0]; p < &proc[NPROC]; p++)
+       if(p->p_ppid == u.u_procp->p_pid) {
+               f++;
+               if(p->p_stat == SZOMB) {
+                       u.u_r.r_val1 = p->p_pid;
+                       u.u_r.r_val2 = ((struct xproc *)p)->xp_xstat;
+                       u.u_cutime += ((struct xproc *)p)->xp_utime;
+                       u.u_cstime += ((struct xproc *)p)->xp_stime;
+                       p->p_stat = NULL;
+                       p->p_pid = 0;
+                       p->p_ppid = 0;
+                       p->p_sig = 0;
+                       p->p_pgrp = 0;
+                       p->p_flag = 0;
+                       p->p_wchan = 0;
+                       return;
+               }
+               if(p->p_stat == SSTOP) {
+                       if((p->p_flag&SWTED) == 0) {
+                               p->p_flag |= SWTED;
+                               u.u_r.r_val1 = p->p_pid;
+                               u.u_r.r_val2 = (fsig(p)<<8) | 0177;
+                               return;
+                       }
+                       continue;
+               }
+       }
+       if(f) {
+               sleep((caddr_t)u.u_procp, PWAIT);
+               goto loop;
+       }
+       u.u_error = ECHILD;
+}
+
+/*
+ * fork system call.
+ */
+fork()
+{
+       register struct proc *p1, *p2;
+       register a;
+
+       /*
+        * Make sure there's enough swap space for max
+        * core image, thus reducing chances of running out
+        */
+       if ((a = malloc(swapmap, ctod(MAXMEM))) == 0) {
+               u.u_error = ENOMEM;
+               goto out;
+       }
+       mfree(swapmap, ctod(MAXMEM), a);
+       a = 0;
+       p2 = NULL;
+       for(p1 = &proc[0]; p1 < &proc[NPROC]; p1++) {
+               if (p1->p_stat==NULL && p2==NULL)
+                       p2 = p1;
+               else {
+                       if (p1->p_uid==u.u_uid && p1->p_stat!=NULL)
+                               a++;
+               }
+       }
+       /*
+        * Disallow if
+        *  No processes at all;
+        *  not su and too many procs owned; or
+        *  not su and would take last slot.
+        */
+       if (p2==NULL || (u.u_uid!=0 && (p2==&proc[NPROC-1] || a>MAXUPRC))) {
+               u.u_error = EAGAIN;
+               goto out;
+       }
+       p1 = u.u_procp;
+       if(newproc()) {
+               u.u_r.r_val1 = p1->p_pid;
+               u.u_r.r_val2 = 1;  /* child */
+               u.u_start = time;
+               u.u_cstime = 0;
+               u.u_stime = 0;
+               u.u_cutime = 0;
+               u.u_utime = 0;
+               u.u_acflag = AFORK;
+               return;
+       }
+       u.u_r.r_val1 = p2->p_pid;
+
+out:
+       u.u_r.r_val2 = 0;
+}
+
+/*
+ * break system call.
+ *  -- bad planning: "break" is a dirty word in C.
+ */
+sbreak()
+{
+       struct a {
+               char    *nsiz;
+       };
+       register a, n, d;
+       int i;
+
+       /*
+        * set n to new data size
+        * set d to new-old
+        * set n to new total size
+        */
+
+       n = btoc((int)((struct a *)u.u_ap)->nsiz);
+       if(!u.u_sep)
+               n -= ctos(u.u_tsize) * stoc(1);
+       if(n < 0)
+               n = 0;
+       d = n - u.u_dsize;
+       n += USIZE+u.u_ssize;
+       if(estabur(u.u_tsize, u.u_dsize+d, u.u_ssize, u.u_sep, RO))
+               return;
+       u.u_dsize += d;
+       if(d > 0)
+               goto bigger;
+       a = u.u_procp->p_addr + n - u.u_ssize;
+       i = n;
+       n = u.u_ssize;
+       while(n--) {
+               copyseg(a-d, a);
+               a++;
+       }
+       expand(i);
+       return;
+
+bigger:
+       expand(n);
+       a = u.u_procp->p_addr + n;
+       n = u.u_ssize;
+       while(n--) {
+               a--;
+               copyseg(a-d, a);
+       }
+       while(d--)
+               clearseg(--a);
+}
diff --git a/usr/src/slowsys/sys/sys2.c b/usr/src/slowsys/sys/sys2.c
new file mode 100644 (file)
index 0000000..01e14c1
--- /dev/null
@@ -0,0 +1,317 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/reg.h"
+#include "../h/file.h"
+#include "../h/inode.h"
+
+/*
+ * read system call
+ */
+read()
+{
+       rdwr(FREAD);
+}
+
+/*
+ * write system call
+ */
+write()
+{
+       rdwr(FWRITE);
+}
+
+/*
+ * common code for read and write calls:
+ * check permissions, set base, count, and offset,
+ * and switch out to readi, writei, or pipe code.
+ */
+rdwr(mode)
+register mode;
+{
+       register struct file *fp;
+       register struct inode *ip;
+       register struct a {
+               int     fdes;
+               char    *cbuf;
+               unsigned count;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       fp = getf(uap->fdes);
+       if(fp == NULL)
+               return;
+       if((fp->f_flag&mode) == 0) {
+               u.u_error = EBADF;
+               return;
+       }
+       u.u_base = (caddr_t)uap->cbuf;
+       u.u_count = uap->count;
+       u.u_segflg = 0;
+       if((fp->f_flag&FPIPE) != 0) {
+               if(mode == FREAD)
+                       readp(fp);
+               else
+                       writep(fp);
+       } else {
+               ip = fp->f_inode;
+               if (fp->f_flag&FMP)
+                       u.u_offset = 0;
+               else
+                       u.u_offset = fp->f_un.f_offset;
+               if((ip->i_mode&(IFCHR&IFBLK)) == 0)
+                       plock(ip);
+               if(mode == FREAD)
+                       readi(ip);
+               else
+                       writei(ip);
+               if((ip->i_mode&(IFCHR&IFBLK)) == 0)
+                       prele(ip);
+               if ((fp->f_flag&FMP) == 0)
+                       fp->f_un.f_offset += uap->count-u.u_count;
+       }
+       u.u_r.r_val1 = uap->count-u.u_count;
+}
+
+/*
+ * open system call
+ */
+open()
+{
+       register struct inode *ip;
+       register struct a {
+               char    *fname;
+               int     rwmode;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       ip = namei(uchar, 0);
+       if(ip == NULL)
+               return;
+       open1(ip, ++uap->rwmode, 0);
+}
+
+/*
+ * creat system call
+ */
+creat()
+{
+       register struct inode *ip;
+       register struct a {
+               char    *fname;
+               int     fmode;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       ip = namei(uchar, 1);
+       if(ip == NULL) {
+               if(u.u_error)
+                       return;
+               ip = maknode(uap->fmode&07777&(~ISVTX));
+               if (ip==NULL)
+                       return;
+               open1(ip, FWRITE, 2);
+       } else
+               open1(ip, FWRITE, 1);
+}
+
+/*
+ * common code for open and creat.
+ * Check permissions, allocate an open file structure,
+ * and call the device open routine if any.
+ */
+open1(ip, mode, trf)
+register struct inode *ip;
+register mode;
+{
+       register struct file *fp;
+       int i;
+
+       if(trf != 2) {
+               if(mode&FREAD)
+                       access(ip, IREAD);
+               if(mode&FWRITE) {
+                       access(ip, IWRITE);
+                       if((ip->i_mode&IFMT) == IFDIR)
+                               u.u_error = EISDIR;
+               }
+       }
+       if(u.u_error)
+               goto out;
+       if(trf == 1)
+               itrunc(ip);
+       prele(ip);
+       if ((fp = falloc()) == NULL)
+               goto out;
+       fp->f_flag = mode&(FREAD|FWRITE);
+       fp->f_inode = ip;
+       i = u.u_r.r_val1;
+       openi(ip, mode&FWRITE);
+       if(u.u_error == 0)
+               return;
+       u.u_ofile[i] = NULL;
+       fp->f_count--;
+
+out:
+       iput(ip);
+}
+
+/*
+ * close system call
+ */
+close()
+{
+       register struct file *fp;
+       register struct a {
+               int     fdes;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       fp = getf(uap->fdes);
+       if(fp == NULL)
+               return;
+       u.u_ofile[uap->fdes] = NULL;
+       closef(fp);
+}
+
+/*
+ * seek system call
+ */
+seek()
+{
+       register struct file *fp;
+       register struct a {
+               int     fdes;
+               off_t   off;
+               int     sbase;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       fp = getf(uap->fdes);
+       if(fp == NULL)
+               return;
+       if(fp->f_flag&(FPIPE|FMP)) {
+               u.u_error = ESPIPE;
+               return;
+       }
+       if(uap->sbase == 1)
+               uap->off += fp->f_un.f_offset;
+       else if(uap->sbase == 2)
+               uap->off += fp->f_inode->i_size;
+       fp->f_un.f_offset = uap->off;
+       u.u_r.r_off = uap->off;
+}
+
+
+/*
+ * link system call
+ */
+link()
+{
+       register struct inode *ip, *xp;
+       register struct a {
+               char    *target;
+               char    *linkname;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       ip = namei(uchar, 0);
+       if(ip == NULL)
+               return;
+       if((ip->i_mode&IFMT)==IFDIR && !suser())
+               goto out;
+       /*
+        * Unlock to avoid possibly hanging the namei.
+        * Sadly, this means races. (Suppose someone
+        * deletes the file in the meantime?)
+        * Nor can it be locked again later
+        * because then there will be deadly
+        * embraces.
+        */
+       prele(ip);
+       u.u_dirp = (caddr_t)uap->linkname;
+       xp = namei(uchar, 1);
+       if(xp != NULL) {
+               u.u_error = EEXIST;
+               iput(xp);
+               goto out;
+       }
+       if (u.u_error)
+               goto out;
+       if(u.u_pdir->i_dev != ip->i_dev) {
+               iput(u.u_pdir);
+               u.u_error = EXDEV;
+               goto out;
+       }
+       wdir(ip);
+       if (u.u_error==0) {
+               ip->i_nlink++;
+               ip->i_flag |= ICHG;
+       }
+
+out:
+       iput(ip);
+}
+
+/*
+ * mknod system call
+ */
+mknod()
+{
+       register struct inode *ip;
+       register struct a {
+               char    *fname;
+               int     fmode;
+               int     dev;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       if(suser()) {
+               ip = namei(uchar, 1);
+               if(ip != NULL) {
+                       u.u_error = EEXIST;
+                       goto out;
+               }
+       }
+       if(u.u_error)
+               return;
+       ip = maknode(uap->fmode);
+       if (ip == NULL)
+               return;
+       ip->i_un.i_rdev = (dev_t)uap->dev;
+
+out:
+       iput(ip);
+}
+
+/*
+ * access system call
+ */
+saccess()
+{
+       register svuid, svgid;
+       register struct inode *ip;
+       register struct a {
+               char    *fname;
+               int     fmode;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       svuid = u.u_uid;
+       svgid = u.u_gid;
+       u.u_uid = u.u_ruid;
+       u.u_gid = u.u_rgid;
+       ip = namei(uchar, 0);
+       if (ip != NULL) {
+               if (uap->fmode&(IREAD>>6))
+                       access(ip, IREAD);
+               if (uap->fmode&(IWRITE>>6))
+                       access(ip, IWRITE);
+               if (uap->fmode&(IEXEC>>6))
+                       access(ip, IEXEC);
+               iput(ip);
+       }
+       u.u_uid = svuid;
+       u.u_gid = svgid;
+}
diff --git a/usr/src/slowsys/sys/sys3.c b/usr/src/slowsys/sys/sys3.c
new file mode 100644 (file)
index 0000000..1523d25
--- /dev/null
@@ -0,0 +1,255 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/mount.h"
+#include "../h/ino.h"
+#include "../h/reg.h"
+#include "../h/buf.h"
+#include "../h/filsys.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/inode.h"
+#include "../h/file.h"
+#include "../h/conf.h"
+#include "../h/stat.h"
+
+/*
+ * the fstat system call.
+ */
+fstat()
+{
+       register struct file *fp;
+       register struct a {
+               int     fdes;
+               struct stat *sb;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       fp = getf(uap->fdes);
+       if(fp == NULL)
+               return;
+       stat1(fp->f_inode, uap->sb, fp->f_flag&FPIPE? fp->f_un.f_offset: 0);
+}
+
+/*
+ * the stat system call.
+ */
+stat()
+{
+       register struct inode *ip;
+       register struct a {
+               char    *fname;
+               struct stat *sb;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       ip = namei(uchar, 0);
+       if(ip == NULL)
+               return;
+       stat1(ip, uap->sb, (off_t)0);
+       iput(ip);
+}
+
+/*
+ * The basic routine for fstat and stat:
+ * get the inode and pass appropriate parts back.
+ */
+stat1(ip, ub, pipeadj)
+register struct inode *ip;
+struct stat *ub;
+off_t pipeadj;
+{
+       register struct dinode *dp;
+       register struct buf *bp;
+       struct stat ds;
+
+       iupdat(ip, &time, &time);
+       /*
+        * first copy from inode table
+        */
+       ds.st_dev = ip->i_dev;
+       ds.st_ino = ip->i_number;
+       ds.st_mode = ip->i_mode;
+       ds.st_nlink = ip->i_nlink;
+       ds.st_uid = ip->i_uid;
+       ds.st_gid = ip->i_gid;
+       ds.st_rdev = (dev_t)ip->i_un.i_rdev;
+       ds.st_size = ip->i_size - pipeadj;
+       /*
+        * next the dates in the disk
+        */
+       bp = bread(ip->i_dev, itod(ip->i_number));
+       dp = bp->b_un.b_dino;
+       dp += itoo(ip->i_number);
+       ds.st_atime = dp->di_atime;
+       ds.st_mtime = dp->di_mtime;
+       ds.st_ctime = dp->di_ctime;
+       brelse(bp);
+       if (copyout((caddr_t)&ds, (caddr_t)ub, sizeof(ds)) < 0)
+               u.u_error = EFAULT;
+}
+
+/*
+ * the dup system call.
+ */
+dup()
+{
+       register struct file *fp;
+       register struct a {
+               int     fdes;
+               int     fdes2;
+       } *uap;
+       register i, m;
+
+       uap = (struct a *)u.u_ap;
+       m = uap->fdes & ~077;
+       uap->fdes &= 077;
+       fp = getf(uap->fdes);
+       if(fp == NULL)
+               return;
+       if ((m&0100) == 0) {
+               if ((i = ufalloc()) < 0)
+                       return;
+       } else {
+               i = uap->fdes2;
+               if (i<0 || i>=NOFILE) {
+                       u.u_error = EBADF;
+                       return;
+               }
+               u.u_r.r_val1 = i;
+       }
+       if (i!=uap->fdes) {
+               if (u.u_ofile[i]!=NULL)
+                       closef(u.u_ofile[i]);
+               u.u_ofile[i] = fp;
+               fp->f_count++;
+       }
+}
+
+/*
+ * the mount system call.
+ */
+smount()
+{
+       dev_t dev;
+       register struct inode *ip;
+       register struct mount *mp;
+       struct mount *smp;
+       register struct filsys *fp;
+       struct buf *bp;
+       register struct a {
+               char    *fspec;
+               char    *freg;
+               int     ronly;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       dev = getmdev();
+       if(u.u_error)
+               return;
+       u.u_dirp = (caddr_t)uap->freg;
+       ip = namei(uchar, 0);
+       if(ip == NULL)
+               return;
+       if(ip->i_count!=1 || (ip->i_mode&(IFBLK&IFCHR))!=0)
+               goto out;
+       smp = NULL;
+       for(mp = &mount[0]; mp < &mount[NMOUNT]; mp++) {
+               if(mp->m_bufp != NULL) {
+                       if(dev == mp->m_dev)
+                               goto out;
+               } else
+               if(smp == NULL)
+                       smp = mp;
+       }
+       mp = smp;
+       if(mp == NULL)
+               goto out;
+       (*bdevsw[major(dev)].d_open)(dev, !uap->ronly);
+       if(u.u_error)
+               goto out;
+       bp = bread(dev, SUPERB);
+       if(u.u_error) {
+               brelse(bp);
+               goto out1;
+       }
+       mp->m_inodp = ip;
+       mp->m_dev = dev;
+       mp->m_bufp = geteblk();
+       bcopy((caddr_t)bp->b_un.b_addr, mp->m_bufp->b_un.b_addr, BSIZE);
+       fp = mp->m_bufp->b_un.b_filsys;
+       fp->s_ilock = 0;
+       fp->s_flock = 0;
+       fp->s_ronly = uap->ronly & 1;
+       brelse(bp);
+       ip->i_flag |= IMOUNT;
+       prele(ip);
+       return;
+
+out:
+       u.u_error = EBUSY;
+out1:
+       iput(ip);
+}
+
+/*
+ * the umount system call.
+ */
+sumount()
+{
+       dev_t dev;
+       register struct inode *ip;
+       register struct mount *mp;
+       struct buf *bp;
+       register struct a {
+               char    *fspec;
+       };
+
+       dev = getmdev();
+       if(u.u_error)
+               return;
+       xumount(dev);   /* remove unused sticky files from text table */
+       update();
+       for(mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
+               if(mp->m_bufp != NULL && dev == mp->m_dev)
+                       goto found;
+       u.u_error = EINVAL;
+       return;
+
+found:
+       for(ip = &inode[0]; ip < &inode[NINODE]; ip++)
+               if(ip->i_number != 0 && dev == ip->i_dev) {
+                       u.u_error = EBUSY;
+                       return;
+               }
+       (*bdevsw[major(dev)].d_close)(dev, 0);
+       ip = mp->m_inodp;
+       ip->i_flag &= ~IMOUNT;
+       plock(ip);
+       iput(ip);
+       bp = mp->m_bufp;
+       mp->m_bufp = NULL;
+       brelse(bp);
+}
+
+/*
+ * Common code for mount and umount.
+ * Check that the user's argument is a reasonable
+ * thing on which to mount, and return the device number if so.
+ */
+dev_t
+getmdev()
+{
+       dev_t dev;
+       register struct inode *ip;
+
+       ip = namei(uchar, 0);
+       if(ip == NULL)
+               return(NODEV);
+       if((ip->i_mode&IFMT) != IFBLK)
+               u.u_error = ENOTBLK;
+       dev = (dev_t)ip->i_un.i_rdev;
+       if(major(dev) >= nblkdev)
+               u.u_error = ENXIO;
+       iput(ip);
+       return(dev);
+}
diff --git a/usr/src/slowsys/sys/sys4.c b/usr/src/slowsys/sys/sys4.c
new file mode 100644 (file)
index 0000000..c454a9e
--- /dev/null
@@ -0,0 +1,459 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/reg.h"
+#include "../h/inode.h"
+#include "../h/proc.h"
+#include "../h/clock.h"
+#include "../h/mtpr.h"
+#include "../h/timeb.h"
+
+/*
+ * Everything in this file is a routine implementing a system call.
+ */
+
+/*
+ * return the current time (old-style entry)
+ */
+gtime()
+{
+       u.u_r.r_time = time;
+}
+
+/*
+ * New time entry-- return TOD with milliseconds, timezone,
+ * DST flag
+ */
+ftime()
+{
+       register struct a {
+               struct  timeb   *tp;
+       } *uap;
+       struct timeb t;
+       register unsigned ms;
+
+       uap = (struct a *)u.u_ap;
+       spl7();
+       t.time = time;
+       ms = lbolt;
+       spl0();
+       if (ms > HZ) {
+               ms -= HZ;
+               t.time++;
+       }
+       t.millitm = (1000*ms)/HZ;
+       t.timezone = TIMEZONE;
+       t.dstflag = DSTFLAG;
+       if (copyout((caddr_t)&t, (caddr_t)uap->tp, sizeof(t)) < 0)
+               u.u_error = EFAULT;
+}
+
+/*
+ * Set the time
+ */
+stime()
+{
+       register unsigned int i , j ;
+       register struct a {
+               time_t  time;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       if(suser()) {
+               time = uap->time;
+               /* In addition to setting software time (GMT seconds
+               *  since YRREF), also set VAX TODR reg (10 ms. clicks
+               *  into current year YRCURR
+               */
+               for (i = time , j = YRREF ; j < YRCURR ; j++)
+                       i -= (SECYR + (j%4?0:SECDAY)) ;
+               mtpr(TODR,i*100) ; /* 10 ms. clicks */
+       }
+}
+
+setuid()
+{
+       register uid;
+       register struct a {
+               int     uid;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       uid = uap->uid;
+       if(u.u_ruid == uid || suser()) {
+               u.u_uid = uid;
+               u.u_procp->p_uid = uid;
+               u.u_ruid = uid;
+       }
+}
+
+getuid()
+{
+
+       u.u_r.r_val1 = u.u_ruid;
+       u.u_r.r_val2 = u.u_uid;
+}
+
+setgid()
+{
+       register gid;
+       register struct a {
+               int     gid;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       gid = uap->gid;
+       if(u.u_rgid == gid || suser()) {
+               u.u_gid = gid;
+               u.u_rgid = gid;
+       }
+}
+
+getgid()
+{
+
+       u.u_r.r_val1 = u.u_rgid;
+       u.u_r.r_val2 = u.u_gid;
+}
+
+getpid()
+{
+       u.u_r.r_val1 = u.u_procp->p_pid;
+       u.u_r.r_val2 = u.u_procp->p_ppid;
+}
+
+sync()
+{
+
+       update();
+}
+
+nice()
+{
+       register n;
+       register struct a {
+               int     niceness;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       n = uap->niceness;
+       if(n < 0 && !suser())
+               n = 0;
+       n += u.u_procp->p_nice;
+       if(n >= 2*NZERO)
+               n = 2*NZERO -1;
+       if(n < 0)
+               n = 0;
+       u.u_procp->p_nice = n;
+}
+
+/*
+ * Unlink system call.
+ * Hard to avoid races here, especially
+ * in unlinking directories.
+ */
+unlink()
+{
+       register struct inode *ip, *pp;
+       struct a {
+               char    *fname;
+       };
+
+       pp = namei(uchar, 2);
+       if(pp == NULL)
+               return;
+       /*
+        * Check for unlink(".")
+        * to avoid hanging on the iget
+        */
+       if (pp->i_number == u.u_dent.d_ino) {
+               ip = pp;
+               ip->i_count++;
+       } else
+               ip = iget(pp->i_dev, u.u_dent.d_ino);
+       if(ip == NULL)
+               goto out1;
+       if((ip->i_mode&IFMT)==IFDIR && !suser())
+               goto out;
+       /*
+        * Don't unlink a mounted file.
+        */
+       if (ip->i_dev != pp->i_dev) {
+               u.u_error = EBUSY;
+               goto out;
+       }
+       if (ip->i_flag&ITEXT)
+               xrele(ip);      /* try once to free text */
+       if (ip->i_flag&ITEXT && ip->i_nlink==1) {
+               u.u_error = ETXTBSY;
+               goto out;
+       }
+       u.u_offset -= sizeof(struct direct);
+       u.u_base = (caddr_t)&u.u_dent;
+       u.u_count = sizeof(struct direct);
+       u.u_dent.d_ino = 0;
+       writei(pp);
+       ip->i_nlink--;
+       ip->i_flag |= ICHG;
+
+out:
+       iput(ip);
+out1:
+       iput(pp);
+}
+chdir()
+{
+       chdirec(&u.u_cdir);
+}
+
+chroot()
+{
+       chdirec(&u.u_rdir);
+}
+
+chdirec(ipp)
+register struct inode **ipp;
+{
+       register struct inode *ip;
+       struct a {
+               char    *fname;
+       };
+
+       ip = namei(uchar, 0);
+       if(ip == NULL)
+               return;
+       if((ip->i_mode&IFMT) != IFDIR) {
+               u.u_error = ENOTDIR;
+               goto bad;
+       }
+       if(access(ip, IEXEC))
+               goto bad;
+       prele(ip);
+       if (*ipp) {
+               plock(*ipp);
+               iput(*ipp);
+       }
+       *ipp = ip;
+       return;
+
+bad:
+       iput(ip);
+}
+
+chmod()
+{
+       register struct inode *ip;
+       register struct a {
+               char    *fname;
+               int     fmode;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       if ((ip = owner()) == NULL)
+               return;
+       ip->i_mode &= ~07777;
+       if (u.u_uid)
+               uap->fmode &= ~ISVTX;
+       ip->i_mode |= uap->fmode&07777;
+       ip->i_flag |= ICHG;
+       if (ip->i_flag&ITEXT && (ip->i_mode&ISVTX)==0)
+               xrele(ip);
+       iput(ip);
+}
+
+chown()
+{
+       register struct inode *ip;
+       register struct a {
+               char    *fname;
+               int     uid;
+               int     gid;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       if (!suser() || (ip = owner()) == NULL)
+               return;
+       ip->i_uid = uap->uid;
+       ip->i_gid = uap->gid;
+       ip->i_flag |= ICHG;
+       iput(ip);
+}
+
+ssig()
+{
+       register a;
+       struct a {
+               int     signo;
+               int     fun;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       a = uap->signo;
+       if(a<=0 || a>=NSIG || a==SIGKIL) {
+               u.u_error = EINVAL;
+               return;
+       }
+       u.u_r.r_val1 = u.u_signal[a];
+       u.u_signal[a] = uap->fun;
+       u.u_procp->p_sig &= ~(1<<(a-1));
+}
+
+kill()
+{
+       register struct proc *p, *q;
+       register a;
+       register struct a {
+               int     pid;
+               int     signo;
+       } *uap;
+       int f, priv;
+
+       uap = (struct a *)u.u_ap;
+       f = 0;
+       a = uap->pid;
+       priv = 0;
+       if (a==-1 && u.u_uid==0) {
+               priv++;
+               a = 0;
+       }
+       q = u.u_procp;
+       for(p = &proc[0]; p < &proc[NPROC]; p++) {
+               if(p->p_stat == NULL)
+                       continue;
+               if(a != 0 && p->p_pid != a)
+                       continue;
+               if(a==0 && ((p->p_pgrp!=q->p_pgrp&&priv==0) || p<=&proc[1]))
+                       continue;
+               if(u.u_uid != 0 && u.u_uid != p->p_uid)
+                       continue;
+               f++;
+               psignal(p, uap->signo);
+       }
+       if(f == 0)
+               u.u_error = ESRCH;
+}
+
+times()
+{
+       register struct a {
+               time_t  (*times)[4];
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       if (copyout((caddr_t)&u.u_utime, (caddr_t)uap->times, sizeof(*uap->times)) < 0)
+               u.u_error = EFAULT;
+}
+
+profil()
+{
+       register struct a {
+               short   *bufbase;
+               unsigned bufsize;
+               unsigned pcoffset;
+               unsigned pcscale;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       u.u_prof.pr_base = uap->bufbase;
+       u.u_prof.pr_size = uap->bufsize;
+       u.u_prof.pr_off = uap->pcoffset;
+       u.u_prof.pr_scale = uap->pcscale;
+}
+
+/*
+ * alarm clock signal
+ */
+alarm()
+{
+       register struct proc *p;
+       register c;
+       register struct a {
+               int     deltat;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       p = u.u_procp;
+       c = p->p_clktim;
+       p->p_clktim = uap->deltat;
+       u.u_r.r_val1 = c;
+}
+
+/*
+ * indefinite wait.
+ * no one should wakeup(&u)
+ */
+pause()
+{
+
+       for(;;)
+               sleep((caddr_t)&u, PSLEP);
+}
+
+/*
+ * mode mask for creation of files
+ */
+umask()
+{
+       register struct a {
+               int     mask;
+       } *uap;
+       register t;
+
+       uap = (struct a *)u.u_ap;
+       t = u.u_cmask;
+       u.u_cmask = uap->mask & 0777;
+       u.u_r.r_val1 = t;
+}
+
+/*
+ * Set IUPD and IACC times on file.
+ * Can't set ICHG.
+ */
+utime()
+{
+       register struct a {
+               char    *fname;
+               time_t  *tptr;
+       } *uap;
+       register struct inode *ip;
+       time_t tv[2];
+
+       uap = (struct a *)u.u_ap;
+       if ((ip = owner()) == NULL)
+               return;
+       if (copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof(tv))) {
+               u.u_error = EFAULT;
+               return;
+       }
+       ip->i_flag |= IACC|IUPD|ICHG;
+       iupdat(ip, &tv[0], &tv[1]);
+       iput(ip);
+}
+
+/*
+ * Get microseconds since system boot
+ */
+microtime()
+{
+       register struct a {
+               int     (*times)[2];
+       } *uap;
+
+       register int    clkcnt,clkstat,pri;
+       int     total[2];
+
+       uap = (struct a *)u.u_ap;
+       pri = spl7();
+       total[0] = time64[0];
+       total[1] = time64[1];
+       clkcnt = mfpr(ICR);
+       clkstat = mfpr(ICCS);
+       splx(pri);
+       clkcnt += CLKTICK;      /* microseconds since last tick */
+       if (clkstat & ICCS_ERR)
+               clkcnt += CLKTICK;      /* account for overflow */
+       add64(clkcnt,&total[0],&total[1]);
+       if (copyout((caddr_t)total,(caddr_t)uap->times,8))
+               u.u_error = EFAULT;
+}
diff --git a/usr/src/slowsys/sys/sysent.c b/usr/src/slowsys/sys/sysent.c
new file mode 100644 (file)
index 0000000..b62ca3f
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * This table is the switch used to transfer
+ * to the appropriate routine for processing a system call.
+ * Each row contains the number of arguments expected
+ * and a pointer to the routine.
+ */
+
+#include "../h/param.h"
+#include "../h/systm.h"
+
+int    alarm();
+int    chdir();
+int    chmod();
+int    chown();
+int    chroot();
+int    close();
+int    creat();
+int    dup();
+int    exec();
+int    exece();
+int    fork();
+int    fstat();
+int    getgid();
+int    getpid();
+int    getuid();
+int    gtime();
+int    gtty();
+int    ioctl();
+int    kill();
+int    link();
+int    mknod();
+int    mpxchan();
+int    nice();
+int    ftime();
+int    nosys();
+int    nullsys();
+int    open();
+int    pause();
+int    pipe();
+int    profil();
+int    ptrace();
+int    read();
+int    rexit();
+int    saccess();
+int    sbreak();
+int    seek();
+int    setgid();
+int    setuid();
+int    smount();
+int    ssig();
+int    stat();
+int    stime();
+int    stty();
+int    sumount();
+int    sync();
+int    sysacct();
+int    syslock();
+int    sysphys();
+int    times();
+int    umask();
+int    unlink();
+int    utime();
+int    wait();
+int    write();
+
+struct sysent sysent[64] =
+{
+       0, 0, nosys,                    /* 0 = indir */
+       1, 0, rexit,                    /*  1 = exit */
+       0, 0, fork,                     /*  2 = fork */
+       3, 0, read,                     /*  3 = read */
+       3, 0, write,                    /*  4 = write */
+       2, 0, open,                     /*  5 = open */
+       1, 0, close,                    /*  6 = close */
+       0, 0, wait,                     /*  7 = wait */
+       2, 0, creat,                    /*  8 = creat */
+       2, 0, link,                     /*  9 = link */
+       1, 0, unlink,                   /* 10 = unlink */
+       2, 0, exec,                     /* 11 = exec */
+       1, 0, chdir,                    /* 12 = chdir */
+       0, 0, gtime,                    /* 13 = time */
+       3, 0, mknod,                    /* 14 = mknod */
+       2, 0, chmod,                    /* 15 = chmod */
+       3, 0, chown,                    /* 16 = chown; now 3 args */
+       1, 0, sbreak,                   /* 17 = break */
+       2, 0, stat,                     /* 18 = stat */
+       3, 0, seek,                     /* 19 = seek */
+       0, 0, getpid,                   /* 20 = getpid */
+       3, 0, smount,                   /* 21 = mount */
+       1, 0, sumount,                  /* 22 = umount */
+       1, 0, setuid,                   /* 23 = setuid */
+       0, 0, getuid,                   /* 24 = getuid */
+       1, 0, stime,                    /* 25 = stime */
+       4, 0, ptrace,                   /* 26 = ptrace */
+       1, 0, alarm,                    /* 27 = alarm */
+       2, 0, fstat,                    /* 28 = fstat */
+       0, 0, pause,                    /* 29 = pause */
+       2, 0, utime,                    /* 30 = utime */
+       2, 0, stty,                     /* 31 = stty */
+       2, 0, gtty,                     /* 32 = gtty */
+       2, 0, saccess,                  /* 33 = access */
+       1, 0, nice,                     /* 34 = nice */
+       1, 0, ftime,                    /* 35 = ftime; formally sleep;  */
+       0, 0, sync,                     /* 36 = sync */
+       2, 0, kill,                     /* 37 = kill */
+       0, 0, nullsys,                  /* 38 = switch; inoperative */
+       0, 0, nullsys,                  /* 39 = setpgrp (not in yet) */
+       0, 0, nosys,                    /* 40 = tell - obsolete */
+       2, 0, dup,                              /* 41 = dup */
+       0, 0, pipe,                     /* 42 = pipe */
+       1, 0, times,                    /* 43 = times */
+       4, 0, profil,                   /* 44 = prof */
+       0, 0, nosys,                    /* 45 = tiu */
+       1, 0, setgid,                   /* 46 = setgid */
+       0, 0, getgid,                   /* 47 = getgid */
+       2, 0, ssig,                     /* 48 = sig */
+       0, 0, nosys,                    /* 49 = reserved for USG */
+       0, 0, nosys,                    /* 50 = reserved for USG */
+       1, 0, sysacct,                  /* 51 = turn acct off/on */
+       3, 0, sysphys,                  /* 52 = set user physical addresses */
+       1, 0, syslock,                  /* 53 = lock user in core */
+       3, 0, ioctl,                    /* 54 = ioctl */
+       0, 0, nosys,                    /* 55 = reboot */
+       4, 0, mpxchan,                  /* 56 = creat mpx comm channel */
+       0, 0, nosys,                    /* 57 = reserved for USG */
+       0, 0, nosys,                    /* 58 = reserved for USG */
+       3, 0, exece,                    /* 59 = exece */
+       1, 0, umask,                    /* 60 = umask */
+       1, 0, chroot,                   /* 61 = chroot */
+       1, 0, nosys,            /* 62 = unused */
+       0, 0, nosys                     /* 63 = used internally */
+};
diff --git a/usr/src/slowsys/sys/tdump.c b/usr/src/slowsys/sys/tdump.c
new file mode 100644 (file)
index 0000000..77f39fa
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * Dump core to magtape
+ * Assumes memory mapping has been disabled
+ * and IPL has be set high ( > 0x15 )
+ */
+
+
+#define PHYSPAGES 1024
+#define UBA 0x20006000
+#define mba0 0x20010000
+#define mba1 0x20012000
+
+struct mba_regs {
+       int mba_csr,
+           mba_cr,
+           mba_sr,
+           mba_var,
+           mba_bcr;
+};
+
+struct device
+{
+       int     htcs1;
+       int     htds;
+       int     hter;
+       int     htmr;
+       int     htas;
+       int     htfc;
+       int     htdt;
+       int     htck;
+       int     htsn;
+       int     httc;
+};
+
+#define        HTADDR  ((struct device *)(mba1 + 0x400))
+#define HTMAP ((int *) (mba1 + 0x800))
+
+#define        GO      01
+#define        WCOM    060
+#define        RCOM    070
+#define        NOP     0
+#define        WEOF    026
+#define        SFORW   030
+#define        SREV    032
+#define        ERASE   024
+#define        REW     06
+#define        DCLR    010
+#define P800   01300           /* 800 + pdp11 mode */
+#define        P1600   02300           /* 1600 + pdp11 mode */
+#define        IENABLE 0100
+#define        RDY     0200
+#define        TM      04
+#define        DRY     0200
+#define EOT    02000
+#define CS     02000
+#define COR    0100000
+#define PES    040
+#define WRL    04000
+#define MOL    010000
+#define ERR    040000
+#define FCE    01000
+#define        TRE     040000
+#define HARD   064023  /* UNS|OPI|NEF|FMT|RMR|ILR|ILF */
+
+#define        SIO     1
+#define        SSFOR   2
+#define        SSREV   3
+#define SRETRY 4
+#define SCOM   5
+#define SOK    6
+
+dump()
+{
+
+       HTADDR->httc = P800;    /* set 800 bpi mode */
+
+       twall((char *)0, PHYSPAGES);    /* write out memory */
+
+       teof();
+       teof();
+       rewind();
+}
+
+twall(start, num)
+       char *start;
+       int num;
+{
+       HTADDR->htcs1 = DCLR | GO;
+       while (num--) {
+               twrite(start);
+               start += 512;
+               }
+}
+
+twrite(buf)
+char *buf;
+{
+
+       twait();
+       HTADDR->htfc = -512;
+       *HTMAP = (((int)buf)>>9) | 0x80000000;  /* map entry */
+       ((struct mba_regs *)mba1)->mba_sr = -1;
+       ((struct mba_regs *)mba1)->mba_bcr = -512;
+       ((struct mba_regs *)mba1)->mba_var = 0;
+       HTADDR->htcs1 = WCOM | GO;
+       return;
+}
+
+twait()
+{
+       register s;
+
+       do
+               s = HTADDR->htds;
+       while ((s & RDY) == 0);
+}
+
+rewind()
+{
+       twait();
+       HTADDR->htcs1 = REW | GO;
+}
+
+teof()
+{
+       twait();
+       HTADDR->htcs1 = WEOF | GO;
+}
diff --git a/usr/src/slowsys/sys/text.c b/usr/src/slowsys/sys/text.c
new file mode 100644 (file)
index 0000000..0e71464
--- /dev/null
@@ -0,0 +1,266 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/uba.h"
+#include "../h/map.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/proc.h"
+#include "../h/text.h"
+#include "../h/inode.h"
+#include "../h/buf.h"
+#include "../h/seg.h"
+#include "../h/page.h"
+
+/*
+ * Swap out process p.
+ * The ff flag causes its core to be freed--
+ * it may be off when called to create an image for a
+ * child process in newproc.
+ * Os is the old size of the data area of the process,
+ * and is supplied during core expansion swaps.
+ *
+ * panic: out of swap space
+ */
+xswap(p, ff, os)
+register struct proc *p;
+{
+       register a;
+
+       if(os == 0)
+               os = p->p_size;
+       a = malloc(swapmap, ctod(p->p_size));
+       if(a == NULL)
+               panic("out of swap space");
+       p->p_flag |= SLOCK;
+       xccdec(p->p_textp);
+       swap(a, p->p_addr, os, B_WRITE);
+       if(ff)
+               mfree(coremap, os, p->p_addr);
+       p->p_addr = a;
+       p->p_flag &= ~(SLOAD|SLOCK);
+       p->p_time = 0;
+       if(runout) {
+               runout = 0;
+               wakeup((caddr_t)&runout);
+       }
+}
+
+/*
+ * relinquish use of the shared text segment
+ * of a process.
+ */
+xfree()
+{
+       register struct text *xp;
+       register struct inode *ip;
+
+       if((xp=u.u_procp->p_textp) == NULL)
+               return;
+       xlock(xp);
+       xp->x_flag &= ~XLOCK;
+       u.u_procp->p_textp = NULL;
+       ip = xp->x_iptr;
+       if(--xp->x_count==0 && (ip->i_mode&ISVTX)==0) {
+               xp->x_iptr = NULL;
+               mfree(swapmap, ctod(xp->x_size), xp->x_daddr);
+               mfree(coremap, xp->x_size, xp->x_caddr);
+               ip->i_flag &= ~ITEXT;
+               if (ip->i_flag&ILOCK)
+                       ip->i_count--;
+               else
+                       iput(ip);
+       } else
+               xccdec(xp);
+}
+
+/*
+ * Attach to a shared text segment.
+ * If there is no shared text, just return.
+ * If there is, hook up to it:
+ * if it is not currently being used, it has to be read
+ * in from the inode (ip); the written bit is set to force it
+ * to be written out as appropriate.
+ * If it is being used, but is not currently in core,
+ * a swap has to be done to get it back.
+ */
+xalloc(ip)
+register struct inode *ip;
+{
+       register struct text *xp;
+       register unsigned ts;
+       register struct text *xp1;
+
+       if(u.u_exdata.ux_tsize == 0)
+               return;
+       xp1 = NULL;
+       for (xp = &text[0]; xp < &text[NTEXT]; xp++) {
+               if(xp->x_iptr == NULL) {
+                       if(xp1 == NULL)
+                               xp1 = xp;
+                       continue;
+               }
+               if(xp->x_iptr == ip) {
+                       xlock(xp);
+                       xp->x_count++;
+                       u.u_procp->p_textp = xp;
+                       if (xp->x_ccount == 0)
+                               xexpand(xp);
+                       else
+                               xp->x_ccount++;
+                       xunlock(xp);
+                       return;
+               }
+       }
+       if((xp=xp1) == NULL) {
+               printf("out of text");
+               psignal(u.u_procp, SIGKIL);
+               return;
+       }
+       xp->x_flag = XLOAD|XLOCK;
+       xp->x_count = 1;
+       xp->x_ccount = 0;
+       xp->x_iptr = ip;
+       ip->i_flag |= ITEXT;
+       ip->i_count++;
+       ts = btoc(u.u_exdata.ux_tsize);
+       xp->x_size = ts;
+       if((xp->x_daddr = malloc(swapmap, ctod(ts))) == NULL)
+               panic("out of swap space");
+       u.u_procp->p_textp = xp;
+       xexpand(xp);
+       estabur(ts, (unsigned)0, (unsigned)0, 0, RW);
+       u.u_count = u.u_exdata.ux_tsize;
+       u.u_offset = sizeof(u.u_exdata);
+       u.u_base = 0;
+       u.u_segflg = 2;
+       u.u_procp->p_flag |= SLOCK;
+       readi(ip);
+       u.u_procp->p_flag &= ~SLOCK;
+       u.u_segflg = 0;
+       xp->x_flag = XWRIT;
+}
+
+/*
+ * Assure core for text segment
+ * Text must be locked to keep someone else from
+ * freeing it in the meantime.
+ * x_ccount must be 0.
+ */
+xexpand(xp)
+register struct text *xp;
+{
+       if ((xp->x_caddr = malloc(coremap, xp->x_size)) != NULL) {
+               if ((xp->x_flag&XLOAD)==0)
+                       swap(xp->x_daddr, xp->x_caddr, xp->x_size, B_READ);
+               xp->x_ccount++;
+               xunlock(xp);
+               return;
+       }
+       if (save(u.u_ssav)) {
+               sureg();
+               return;
+       }
+       xswap(u.u_procp, 1, 0);
+       xunlock(xp);
+       u.u_procp->p_flag |= SSWAP;
+       qswtch();
+       /* no return */
+}
+
+/*
+ * Lock and unlock a text segment from swapping
+ */
+xlock(xp)
+register struct text *xp;
+{
+
+       while(xp->x_flag&XLOCK) {
+               xp->x_flag |= XWANT;
+               sleep((caddr_t)xp, PSWP);
+       }
+       xp->x_flag |= XLOCK;
+}
+
+xunlock(xp)
+register struct text *xp;
+{
+
+       if (xp->x_flag&XWANT)
+               wakeup((caddr_t)xp);
+       xp->x_flag &= ~(XLOCK|XWANT);
+}
+
+/*
+ * Decrement the in-core usage count of a shared text segment.
+ * When it drops to zero, free the core space.
+ */
+xccdec(xp)
+register struct text *xp;
+{
+
+       if (xp==NULL || xp->x_ccount==0)
+               return;
+       xlock(xp);
+       if (--xp->x_ccount==0) {
+               if (xp->x_flag&XWRIT) {
+                       xp->x_flag &= ~XWRIT;
+                       swap(xp->x_daddr,xp->x_caddr,xp->x_size,B_WRITE);
+               }
+               mfree(coremap, xp->x_size, xp->x_caddr);
+       }
+       xunlock(xp);
+}
+
+/*
+ * free the swap image of all unused saved-text text segments
+ * which are from device dev (used by umount system call).
+ */
+xumount(dev)
+register dev;
+{
+       register struct text *xp;
+
+       for (xp = &text[0]; xp < &text[NTEXT]; xp++) 
+               if (xp->x_iptr!=NULL && dev==xp->x_iptr->i_dev)
+                       xuntext(xp);
+}
+
+/*
+ * remove a shared text segment from the text table, if possible.
+ */
+xrele(ip)
+register struct inode *ip;
+{
+       register struct text *xp;
+
+       if (ip->i_flag&ITEXT==0)
+               return;
+       for (xp = &text[0]; xp < &text[NTEXT]; xp++)
+               if (ip==xp->x_iptr)
+                       xuntext(xp);
+}
+
+/*
+ * remove text image from the text table.
+ * the use count must be zero.
+ */
+xuntext(xp)
+register struct text *xp;
+{
+       register struct inode *ip;
+
+       xlock(xp);
+       if (xp->x_count) {
+               xunlock(xp);
+               return;
+       }
+       ip = xp->x_iptr;
+       xp->x_flag &= ~XLOCK;
+       xp->x_iptr = NULL;
+       mfree(swapmap, ctod(xp->x_size), xp->x_daddr);
+       ip->i_flag &= ~ITEXT;
+       if (ip->i_flag&ILOCK)
+               ip->i_count--;
+       else
+               iput(ip);
+}
diff --git a/usr/src/slowsys/sys/trap.c b/usr/src/slowsys/sys/trap.c
new file mode 100644 (file)
index 0000000..ac5d34b
--- /dev/null
@@ -0,0 +1,150 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/proc.h"
+#include "../h/reg.h"
+#include "../h/seg.h"
+#include "../h/trap.h"
+#include "../h/psl.h"
+
+#define        USER    040             /* user-mode flag added to type */
+
+struct sysent  sysent[64];
+
+/*
+ * Called from the trap handler when a processor trap occurs.
+ */
+trap(params, r0, r1, r2, r3, r4, r5 ,r6, r7, r8, r9, r10,
+       r11, r12, r13, sp, type, code, pc, psl)
+caddr_t params;
+{
+       register i, a;
+       register struct sysent *callp;
+       register caddr_t errorp;
+       register time_t syst;
+       register int *locr0;
+
+       locr0 = &r0;
+       syst = u.u_stime;
+       u.u_ar0 = locr0;
+       if (USERMODE(locr0[PS]))
+               type |= USER;
+       u.u_ar0 = locr0;
+       switch (type) {
+
+       /*
+        * Trap not expected.
+        * Usually a kernel mode bus error.
+        */
+       default:
+               printf("user = %x\n", ctob(u.u_procp->p_addr + 1));
+               printf("ps = %x\n", locr0[PS]);
+               printf("pc = %x\n", locr0[PC]);
+               printf("trap type %x\n", type);
+               printf("code = %x\n", code);
+               panic("trap");
+
+       case PROTFLT + USER:    /* protection fault */
+               i = SIGBUS;
+               break;
+
+       case PRIVINFLT + USER:  /* privileged instruction fault */
+       case RESADFLT + USER:   /* reserved addressing fault */
+       case RESOPFLT + USER:   /* resereved operand fault */
+               i = SIGINS;
+               break;
+
+       case RESCHED + USER:    /* Allow process switch */
+               goto out;
+
+       case SYSCALL + USER: /* sys call */
+               params += NBPW;         /* skip word with param count */
+               u.u_error = 0;
+               callp = &sysent[code&077];
+               if (callp == sysent) { /* indirect */
+                       a = fuword(params);
+                       params += NBPW;
+                       callp = &sysent[a&077];
+               }
+               for(i=0; i<callp->sy_narg; i++) {
+                       u.u_arg[i] = fuword(params);
+                       params += NBPW;
+               }
+               u.u_ap = u.u_arg;
+               locr0[PS] &= ~PSL_C;
+               u.u_dirp = (caddr_t)u.u_arg[0];
+               u.u_r.r_val1 = 0;
+               u.u_r.r_val2 = locr0[R1];
+               if(save(u.u_qsav)){
+                       if(u.u_error==0)
+                               u.u_error = EINTR;
+               } else {
+                       (*(callp->sy_call))();
+               }
+               if(u.u_error) {
+                       locr0[R0] = u.u_error;
+                       locr0[PS] |= PSL_C;     /* carry bit */
+                } else {
+                       locr0[R0] = u.u_r.r_val1;
+                       locr0[R1] = u.u_r.r_val2;
+               }
+               goto out;
+
+       case ARITHTRAP + USER:
+               i = SIGFPT;
+               break;
+
+       /*
+        * If the user SP is above the stack segment,
+        * grow the stack automatically.
+        */
+       case SEGFLT + USER: /* segmentation exception */
+               if(grow(locr0[SP]) || grow(code))
+                       goto out;
+               i = SIGSEG;
+               break;
+
+       case BPTFLT + USER:     /* bpt instruction fault */
+       case TRCTRAP + USER:    /* trace trap */
+               locr0[PS] &= ~PSL_T;    /* turn off trace bit */
+               i = SIGTRC;
+               break;
+
+       case XFCFLT + USER:     /* xfc instruction fault */
+               i = SIGEMT;
+               break;
+
+       }
+       psignal(u.u_procp, i);
+
+out:
+       if(issig())
+               psig();
+       curpri = setpri(u.u_procp);
+       if (runrun)
+               qswtch();
+       if(u.u_prof.pr_scale)
+               addupc((caddr_t)locr0[PC], &u.u_prof, (int)(u.u_stime-syst));
+       return;
+}
+
+/*
+ * nonexistent system call-- set fatal error code.
+ */
+nosys()
+{
+       u.u_error = 100;
+}
+
+/*
+ * Ignored system call
+ */
+nullsys()
+{
+}
+
+random(dev, stat, ps, pc, ccb)
+{
+       printf("Random interrupt, device %x\n", dev);
+}
diff --git a/usr/src/slowsys/sys/tty.c b/usr/src/slowsys/sys/tty.c
new file mode 100644 (file)
index 0000000..ec18108
--- /dev/null
@@ -0,0 +1,598 @@
+#
+/*
+ * general TTY subroutines
+ */
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/tty.h"
+#include "../h/proc.h"
+#include "../h/mx.h"
+#include "../h/inode.h"
+#include "../h/file.h"
+#include "../h/reg.h"
+#include "../h/conf.h"
+
+char   partab[];
+
+/*
+ * Input mapping table-- if an entry is non-zero, when the
+ * corresponding character is typed preceded by "\" the escape
+ * sequence is replaced by the table value.  Mostly used for
+ * upper-case only terminals.
+ */
+char   maptab[] =
+{
+       000,000,000,000,CEOT,00,000,000,
+       000,000,000,000,000,000,000,000,
+       000,000,000,000,000,000,000,000,
+       000,000,000,000,000,000,000,000,
+       000,'|',000,000,000,000,000,'`',
+       '{','}',000,000,000,000,000,000,
+       000,000,000,000,000,000,000,000,
+       000,000,000,000,000,000,000,000,
+       000,000,000,000,000,000,000,000,
+       000,000,000,000,000,000,000,000,
+       000,000,000,000,000,000,000,000,
+       000,000,000,000,000,000,'~',000,
+       000,'A','B','C','D','E','F','G',
+       'H','I','J','K','L','M','N','O',
+       'P','Q','R','S','T','U','V','W',
+       'X','Y','Z',000,000,000,000,000,
+};
+
+/*
+ * routine called on first teletype open.
+ * establishes a process group for distribution
+ * of quits and interrupts from the tty.
+ */
+ttyopen(dev, tp)
+dev_t dev;
+register struct tty *tp;
+{
+       register struct proc *pp;
+
+       pp = u.u_procp;
+       if(pp->p_pgrp == 0) {
+               u.u_ttyp = tp;
+               u.u_ttyd = dev;
+               if (tp->t_pgrp==0)
+                       tp->t_pgrp = pp->p_pid;
+               pp->p_pgrp = tp->t_pgrp;
+       }
+       tp->t_state &= ~WOPEN;
+       tp->t_state |= ISOPEN;
+}
+
+/*
+ * clean tp on last close
+ */
+ttyclose(tp)
+register struct tty *tp;
+{
+
+       tp->t_pgrp = 0;
+       wflushtty(tp);
+       tp->t_state = 0;
+}
+
+/*
+ * stty/gtty writearound
+ */
+stty()
+{
+       u.u_arg[2] = u.u_arg[1];
+       u.u_arg[1] = TIOCSETP;
+       ioctl();
+}
+
+gtty()
+{
+       u.u_arg[2] = u.u_arg[1];
+       u.u_arg[1] = TIOCGETP;
+       ioctl();
+}
+
+/*
+ * ioctl system call
+ * Check legality, execute common code, and switch out to individual
+ * device routine.
+ */
+ioctl()
+{
+       register struct file *fp;
+       register struct inode *ip;
+       register struct a {
+               int     fdes;
+               int     cmd;
+               caddr_t cmarg;
+       } *uap;
+       register dev_t dev;
+       register fmt;
+
+       uap = (struct a *)u.u_ap;
+       if ((fp = getf(uap->fdes)) == NULL)
+               return;
+       if (uap->cmd==FIOCLEX) {
+               u.u_pofile[uap->fdes] |= EXCLOSE;
+               return;
+       }
+       if (uap->cmd==FIONCLEX) {
+               u.u_pofile[uap->fdes] &= ~EXCLOSE;
+               return;
+       }
+       ip = fp->f_inode;
+       fmt = ip->i_mode & IFMT;
+       if (fmt != IFCHR && fmt != IFMPC) {
+               u.u_error = ENOTTY;
+               return;
+       }
+       dev = (dev_t)ip->i_un.i_rdev;
+       (*cdevsw[major(dev)].d_ioctl)(dev, uap->cmd, uap->cmarg, fp->f_flag&(FREAD|FWRITE));
+}
+
+/*
+ * Common code for several tty ioctl commands
+ */
+ttioccomm(com, tp, addr, dev)
+register struct tty *tp;
+caddr_t addr;
+{
+       unsigned t;
+       struct ttiocb iocb;
+       extern int nldisp;
+
+       switch(com) {
+
+       /*
+        * get discipline number
+        */
+       case TIOCGETD:
+               t = tp->t_line;
+               if (copyout((caddr_t)&t, addr, sizeof(t)))
+                       u.u_error = EFAULT;
+               break;
+
+       /*
+        * set line discipline
+        */
+       case TIOCSETD:
+               if (copyin(addr, (caddr_t)&t, sizeof(t))) {
+                       u.u_error = EFAULT;
+                       break;
+               }
+               if (t >= nldisp) {
+                       u.u_error = ENXIO;
+                       break;
+               }
+               if (tp->t_line)
+                       (*linesw[tp->t_line].l_close)(tp);
+               if (t)
+                       (*linesw[t].l_open)(dev, tp, addr);
+               if (u.u_error==0)
+                       tp->t_line = t;
+               break;
+
+       /*
+        * prevent more opens on channel
+        */
+       case TIOCEXCL:
+               tp->t_state |= XCLUDE;
+               break;
+       case TIOCNXCL:
+               tp->t_state &= ~XCLUDE;
+               break;
+
+       /*
+        * Set new parameters
+        */
+       case TIOCSETP:
+               wflushtty(tp);
+       case TIOCSETN:
+               if (copyin(addr, (caddr_t)&iocb, sizeof(iocb))) {
+                       u.u_error = EFAULT;
+                       return(1);
+               }
+               tp->t_ispeed = iocb.ioc_ispeed;
+               tp->t_ospeed = iocb.ioc_ospeed;
+               tp->t_erase = iocb.ioc_erase;
+               tp->t_kill = iocb.ioc_kill;
+               tp->t_flags = iocb.ioc_flags;
+               break;
+
+       /*
+        * send current parameters to user
+        */
+       case TIOCGETP:
+               iocb.ioc_ispeed = tp->t_ispeed;
+               iocb.ioc_ospeed = tp->t_ospeed;
+               iocb.ioc_erase = tp->t_erase;
+               iocb.ioc_kill = tp->t_kill;
+               iocb.ioc_flags = tp->t_flags;
+               if (copyout((caddr_t)&iocb, addr, sizeof(iocb)))
+                       u.u_error = EFAULT;
+               break;
+
+       /*
+        * Hang up line on last close
+        */
+
+       case TIOCHPCL:
+               tp->t_state |= HUPCLS;
+               break;
+
+       /*
+        * ioctl entries to line discipline
+        */
+       case DIOCSETP:
+       case DIOCGETP:
+               (*linesw[tp->t_line].l_ioctl)(com, tp, addr);
+               break;
+       default:
+               return(0);
+       }
+       return(1);
+}
+
+/*
+ * Wait for output to drain, then flush input waiting.
+ */
+wflushtty(tp)
+register struct tty *tp;
+{
+
+       spl5();
+       while (tp->t_outq.c_cc && tp->t_state&CARR_ON) {
+               (*tp->t_oproc)(tp);
+               tp->t_state |= ASLEEP;
+               sleep((caddr_t)&tp->t_outq, TTOPRI);
+       }
+       flushtty(tp);
+       spl0();
+}
+
+/*
+ * flush all TTY queues
+ */
+flushtty(tp)
+register struct tty *tp;
+{
+       register s;
+
+       while (getc(&tp->t_canq) >= 0)
+               ;
+       while (getc(&tp->t_outq) >= 0)
+               ;
+       wakeup((caddr_t)&tp->t_rawq);
+       wakeup((caddr_t)&tp->t_outq);
+       s = spl5();
+       while (getc(&tp->t_rawq) >= 0)
+               ;
+       tp->t_delct = 0;
+       splx(s);
+}
+
+/*
+ * transfer raw input list to canonical list,
+ * doing erase-kill processing and handling escapes.
+ * It waits until a full line has been typed in cooked mode,
+ * or until any character has been typed in raw mode.
+ */
+canon(tp)
+register struct tty *tp;
+{
+       register char *bp;
+       char *bp1;
+       register int c;
+       int mc;
+
+       spl5();
+       while ((tp->t_flags&(RAW|CBREAK))==0 && tp->t_delct==0
+           || (tp->t_flags&(RAW|CBREAK))!=0 && tp->t_rawq.c_cc==0) {
+               if ((tp->t_state&CARR_ON)==0)
+                       return(0);
+               sleep((caddr_t)&tp->t_rawq, TTIPRI);
+       }
+       spl0();
+loop:
+       bp = &canonb[2];
+       while ((c=getc(&tp->t_rawq)) >= 0) {
+               if ((tp->t_flags&(RAW|CBREAK))==0) {
+                       if (c==0377) {
+                               tp->t_delct--;
+                               break;
+                       }
+                       if (bp[-1]!='\\') {
+                               if (c==tp->t_erase) {
+                                       if (bp > &canonb[2])
+                                               bp--;
+                                       continue;
+                               }
+                               if (c==tp->t_kill)
+                                       goto loop;
+                               if (c==CEOT)
+                                       continue;
+                       } else {
+                               mc = maptab[c];
+                               if (c==tp->t_erase || c==tp->t_kill)
+                                       mc = c;
+                               if (mc && (mc==c || (tp->t_flags&LCASE))) {
+                                       if (bp[-2] != '\\')
+                                               c = mc;
+                                       bp--;
+                               }
+                       }
+               }
+               *bp++ = c;
+               if (bp>=canonb+CANBSIZ)
+                       break;
+       }
+       bp1 = bp;
+       bp = &canonb[2];
+       while (bp<bp1)
+               putc(*bp++, &tp->t_canq);
+       return(bp1 - &canonb[2]);
+}
+
+/*
+ * Place a character on raw TTY input queue, putting in delimiters
+ * and waking up top half as needed.
+ * Also echo if required.
+ * The arguments are the character and the appropriate
+ * tty structure.
+ */
+ttyinput(c, tp)
+register c;
+register struct tty *tp;
+{
+       register int t_flags;
+       register struct chan *cp;
+
+       tk_nin += 1;
+       c &= 0377;
+       t_flags = tp->t_flags;
+       if ((t_flags&RAW)==0) {
+               c &= 0177;
+               if (c==CSTOP) {
+                       tp->t_state ^= TTSTOP;
+                       ttstart(tp);
+                       return;
+               }
+               tp->t_state &= ~TTSTOP;
+               if (c==CQUIT || c==CINTR) {
+                       signal(tp->t_pgrp, c==CINTR? SIGINT:SIGQUIT);
+                       flushtty(tp);
+                       return;
+               }
+               if (c=='\r' && t_flags&CRMOD)
+                       c = '\n';
+       }
+       if (tp->t_rawq.c_cc>TTYHOG) {
+               flushtty(tp);
+               return;
+       }
+       if (t_flags&LCASE && c>='A' && c<='Z')
+               c += 'a'-'A';
+       putc(c, &tp->t_rawq);
+       if (t_flags&(RAW|CBREAK) || (c=='\n' || c==CEOT)) {
+               if ((t_flags&(RAW|CBREAK))==0 && putc(0377, &tp->t_rawq)==0)
+                       tp->t_delct++;
+               if (cp = tp->t_chan)
+                       sdata(cp);
+               else
+                       wakeup((caddr_t)&tp->t_rawq);
+       }
+       if (t_flags&ECHO) {
+               ttyoutput(c, tp);
+               if (c==tp->t_kill && (t_flags&(RAW|CBREAK))==0)
+                       ttyoutput('\n', tp);
+               ttstart(tp);
+       }
+}
+
+/*
+ * put character on TTY output queue, adding delays,
+ * expanding tabs, and handling the CR/NL bit.
+ * It is called both from the top half for output, and from
+ * interrupt level for echoing.
+ * The arguments are the character and the tty structure.
+ */
+ttyoutput(c, tp)
+register c;
+register struct tty *tp;
+{
+       register char *colp;
+       register ctype;
+
+       tk_nout += 1;
+       /*
+        * Ignore EOT in normal mode to avoid hanging up
+        * certain terminals.
+        * In raw mode dump the char unchanged.
+        */
+
+       if ((tp->t_flags&RAW)==0) {
+               c &= 0177;
+               if (c==CEOT)
+                       return;
+       } else {
+               putc(c, &tp->t_outq);
+               return;
+       }
+       /*
+        * Turn tabs to spaces as required
+        */
+       if (c=='\t' && (tp->t_flags&TBDELAY)==XTABS) {
+               c = 8;
+               do
+                       ttyoutput(' ', tp);
+               while (--c >= 0 && tp->t_col&07);
+               return;
+       }
+       /*
+        * for upper-case-only terminals,
+        * generate escapes.
+        */
+       if (tp->t_flags&LCASE) {
+               colp = "({)}!|^~'`";
+               while(*colp++)
+                       if(c == *colp++) {
+                               ttyoutput('\\', tp);
+                               c = colp[-2];
+                               break;
+                       }
+               if ('a'<=c && c<='z')
+                       c += 'A' - 'a';
+       }
+       /*
+        * turn <nl> to <cr><lf> if desired.
+        */
+       if (c=='\n' && tp->t_flags&CRMOD)
+               ttyoutput('\r', tp);
+       putc(c, &tp->t_outq);
+       /*
+        * Calculate delays.
+        * The numbers here represent clock ticks
+        * and are not necessarily optimal for all terminals.
+        * The delays are indicated by characters above 0200.
+        * In raw mode there are no delays and the
+        * transmission path is 8 bits wide.
+        */
+       colp = &tp->t_col;
+       ctype = partab[c];
+       c = 0;
+       switch (ctype&077) {
+
+       /* ordinary */
+       case 0:
+               (*colp)++;
+
+       /* non-printing */
+       case 1:
+               break;
+
+       /* backspace */
+       case 2:
+               if (*colp)
+                       (*colp)--;
+               break;
+
+       /* newline */
+       case 3:
+               ctype = (tp->t_flags >> 8) & 03;
+               if(ctype == 1) { /* tty 37 */
+                       if (*colp)
+                               c = max(((unsigned)*colp>>4) + 3, (unsigned)6);
+               } else
+               if(ctype == 2) { /* vt05 */
+                       c = 6;
+               }
+               *colp = 0;
+               break;
+
+       /* tab */
+       case 4:
+               ctype = (tp->t_flags >> 10) & 03;
+               if(ctype == 1) { /* tty 37 */
+                       c = 1 - (*colp | ~07);
+                       if(c < 5)
+                               c = 0;
+               }
+               *colp |= 07;
+               (*colp)++;
+               break;
+
+       /* vertical motion */
+       case 5:
+               if(tp->t_flags & VTDELAY) /* tty 37 */
+                       c = 0177;
+               break;
+
+       /* carriage return */
+       case 6:
+               ctype = (tp->t_flags >> 12) & 03;
+               if(ctype == 1) { /* tn 300 */
+                       c = 5;
+               } else if(ctype == 2) { /* ti 700 */
+                       c = 10;
+               }
+               *colp = 0;
+       }
+       if(c)
+               putc(c|0200, &tp->t_outq);
+}
+
+/*
+ * Restart typewriter output following a delay
+ * timeout.
+ * The name of the routine is passed to the timeout
+ * subroutine and it is called during a clock interrupt.
+ */
+ttrstrt(tp)
+register struct tty *tp;
+{
+
+       tp->t_state &= ~TIMEOUT;
+       ttstart(tp);
+}
+
+/*
+ * Start output on the typewriter. It is used from the top half
+ * after some characters have been put on the output queue,
+ * from the interrupt routine to transmit the next
+ * character, and after a timeout has finished.
+ */
+ttstart(tp)
+register struct tty *tp;
+{
+       register s;
+
+       s = spl5();
+       if((tp->t_state&(TIMEOUT|TTSTOP|BUSY)) == 0)
+               (*tp->t_oproc)(tp);
+       splx(s);
+}
+
+/*
+ * Called from device's read routine after it has
+ * calculated the tty-structure given as argument.
+ */
+ttread(tp)
+register struct tty *tp;
+{
+       struct chan *chan;
+
+       if ((tp->t_state&CARR_ON)==0)
+               return;
+       chan = tp->t_chan;
+       tp->t_chan = NULL;
+       if (tp->t_canq.c_cc || canon(tp))
+               while (tp->t_canq.c_cc && passc(getc(&tp->t_canq))>=0)
+                       ;
+       tp->t_chan = chan;
+}
+
+/*
+ * Called from the device's write routine after it has
+ * calculated the tty-structure given as argument.
+ */
+ttwrite(tp)
+register struct tty *tp;
+{
+       register c;
+
+       if ((tp->t_state&CARR_ON)==0)
+               return;
+       while ((c=cpass())>=0) {
+               spl5();
+               while (tp->t_outq.c_cc > TTHIWAT) {
+                       ttstart(tp);
+                       tp->t_state |= ASLEEP;
+                       sleep((caddr_t)&tp->t_outq, TTOPRI);
+               }
+               spl0();
+               ttyoutput(c, tp);
+       }
+       ttstart(tp);
+}
diff --git a/usr/src/slowsys/sys/uba.c b/usr/src/slowsys/sys/uba.c
new file mode 100644 (file)
index 0000000..e93e39a
--- /dev/null
@@ -0,0 +1,107 @@
+# include "../h/param.h"
+#include "../h/uba.h"
+# include "../h/map.h"
+int uballoc(baddr,bcnt,bdpflg)
+char  bdpflg ;
+char * baddr ;
+unsigned short bcnt;
+{
+/*
+*  Allocate as many contiguous UBA mapping registers
+*  as are necessary to do transfer of 'bcnt' bytes
+*  to/from location 'baddr'.
+*  Wait for enough map registers.
+*  'bdpflg' is non-zero if a "buffered data path" (BDP) is
+*  to be used, else 0 -> use direct data path (DDP) .
+*  Return
+*
+*    |31 - - 28|27 - - 18|17 - - - 9|8 - - 0|
+*    |         |         |          |       |
+*    |  BDP    |   no.   |  start   | byte  |
+*    |   no.   | mapping |   map    | offset|
+*    |         |  reg's  | reg. no. |       |
+*    |         |         |          |       |
+*
+*/
+register regnum , nmreg , bdp , pfn , j ;
+/* calculate no. of mapping reg's required */
+nmreg = btoc(bcnt) + 2;
+pfn = ((int)baddr>>9) & 0xfff ; /* start page frame no. */
+spl6() ;
+while ((regnum = malloc(ubamap,nmreg) - 1) < 0) {
+       /* wait for no. of mapping reg's requested */
+       umrwant++ ;
+       sleep(ubamap,PSWP) ;
+       }
+if (bdpflg)  /* buffered data path BDP 1-15 */
+       while ( (bdp=malloc(bdpmap,1)) == NULL)
+               {
+               bdpwant++;
+               sleep(bdpmap, PSWP);
+               }
+else { /* BDP 0 = DDP */
+       bdp = 0 ;
+       }
+spl0() ;
+j = (bdp<<28) | (nmreg<<18) | (regnum<<9) | ((int)baddr & 0x01ff) ;
+pfn |= (MRV | (bdp<<21)) ; /* map reg entry */
+if (bdp && ((int)baddr & 01)) pfn |= BO ; /* byte offset */
+while (--nmreg)  /* fill the memory mapping reg's */
+       ((struct uba_regs *)UBA0)->uba_map[regnum++] = pfn++ ;
+((struct uba_regs *)UBA0)->uba_map[regnum] = 0 ; /* last entry is invalid */
+return(j) ;
+}
+/*                                                     */
+ubafree(mr)
+int mr ;
+{
+/*
+*  Free UBA memory mapping reg's and a BDP no..
+*    mr :
+*              bits 0 - 3 :  bdp no.
+*               4 - 15 : start map reg. no.
+*                      16 - 31 : no. of mapping reg's
+*
+*/
+register bdp , nmreg , regnum ;
+spl6();
+bdp = (mr>>28) & 0x0f ;  /* BDP no. */
+if (bdp)
+       {
+       ((struct uba_regs *)UBA0)->uba_dpr[bdp] |= BNE ; /* purge */
+       mfree(bdpmap, 1, bdp);
+       if (bdpwant) {
+               bdpwant = 0;
+               wakeup(bdpmap);
+       }
+}
+
+nmreg = (mr>>18) & 0x3ff ; /* no. of mapping reg's */
+regnum = (mr>>9) & 0x1ff ; /* 1st map reg. no. */
+/* free mapping reg's */
+mfree(ubamap,nmreg,regnum+1) ;
+if (umrwant) {
+       umrwant = 0;
+       wakeup(ubamap);
+}
+spl0() ;
+}
+
+ubainit()
+{
+       mfree(ubamap, 496, 1);
+       mfree(bdpmap, 15, 1);
+}
diff --git a/usr/src/slowsys/sys/univec.c b/usr/src/slowsys/sys/univec.c
new file mode 100644 (file)
index 0000000..cb4b757
--- /dev/null
@@ -0,0 +1,175 @@
+# include "../h/param.h"
+/* controller no.'s for bits 27-31 of ISR addr */
+# define DEV_1  0x08000000
+# define DEV_2  0x10000000
+/* Interrupt Service Routine (ISR) addresses */
+extern ubastray() ;
+extern  dzrint() , dzxint() ;
+int *UNIvec[BSIZE/NBPW] = {
+/* 0x0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x10 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x20 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x30 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x40 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x50 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x60 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x70 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x80 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x90 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0xa0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0xb0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0xc0 */
+       (int *)dzrint,  /* DZ-11 # 0 */
+       (int *)dzxint,
+       (int *)((int)dzrint+DEV_1),     /*  DZ-11  # 1 */
+       (int *)((int)dzxint+DEV_1),
+/* 0xd0 */
+       (int *)ubastray, /* DR-11B, VAX-11/45 link */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0xe0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0xf0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x100 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x110 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x120 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x130 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x140 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x150 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x160 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x170 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x180 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x190 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x1a0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x1b0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x1c0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x1d0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x1e0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x1f0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       } ;
+ubastray()
+{
+printf("stray UBA interrupt\n") ;
+}
diff --git a/usr/src/slowsys/sys/ureg.c b/usr/src/slowsys/sys/ureg.c
new file mode 100644 (file)
index 0000000..0a5be2d
--- /dev/null
@@ -0,0 +1,88 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/proc.h"
+#include "../h/text.h"
+#include "../h/seg.h"
+#include "../h/mtpr.h"
+#include "../h/page.h"
+
+/*
+ * Create absolutized user-map
+ * register image from the software prototype.
+ * The software registers must have
+ * been setup prior by estabur.
+ */
+sureg()
+{
+       register int tpfnum, dpfnum;
+       register struct pt_entry *ptaddr, *end_ptaddr;
+       struct text *tp;
+
+       ptaddr = (struct pt_entry *)mfpr(P0BR);
+       tpfnum = dpfnum = u.u_procp->p_addr + USIZE;
+       if ((tp=u.u_procp->p_textp) != NULL)
+               tpfnum = tp->x_caddr;
+       end_ptaddr = (struct pt_entry *)(((int)ptaddr) + u.u_pcb.pcb_szpt*512);
+
+       do
+               ptaddr->pg_pfnum = (ptaddr->pg_v ? ((*(int *)ptaddr)&PG_TXT ? tpfnum++ : dpfnum++) : 0);
+       while ( ++ptaddr < end_ptaddr);
+
+       mtpr(P0LR, u.u_pcb.pcb_p0lr & 0xffffff);        /* set seg 0 size */
+       mtpr(P1LR, u.u_pcb.pcb_p1lr);
+       mtpr(TBIA,1);           /* conserative */
+}
+
+/*
+ * Set up software prototype segmentation
+ * registers to implement the 3 pseudo
+ * text,data,stack segment sizes passed
+ * as arguments.
+ * The argument sep specifies if the
+ * text and data+stack segments are to
+ * be separated.
+ * (Not possible on Interdata)
+ * The last argument determines whether the text
+ * segment is read-write or read-only.
+ */
+estabur(nt, nd, ns, sep, xrw)
+register int nt, nd, ns;
+{
+       register *a, *ap;
+       int nnt, nnd, nns;
+
+       nnt = nt;
+       nnd = nd;
+       nns = ns;
+       if(ctos(nt)+ctos(nd)+ctos(ns) > u.u_pcb.pcb_szpt*128)
+               goto err;
+       if(nt+nd+ns+USIZE > maxmem)
+               goto err;
+       ap = (int *)mfpr(P0BR);
+       a = (int *)(((int)ap) + u.u_pcb.pcb_szpt*512 - ns*4);
+       while(nt > 0) {
+               *ap++ = PG_V | PG_TXT | xrw ;
+               nt--;
+       }
+       while(nd > 0) {
+               *ap++ = PG_V | RW ;
+               nd--;
+       }
+       while(ap < a) {
+               *ap++ = RW;
+       }
+       while(ns > 0) {
+               *ap++ = PG_V | RW ;
+               ns--;
+       }
+       u.u_pcb.pcb_p0lr = 0x4000000 | (nnt + nnd);
+       u.u_pcb.pcb_p1lr = 0x200000 - nns;
+       sureg();
+       return(0);
+
+err:
+       u.u_error = ENOMEM;
+       return(-1);
+}
diff --git a/usr/src/slowsys/sys/v45lnk.c b/usr/src/slowsys/sys/v45lnk.c
new file mode 100644 (file)
index 0000000..cbd7940
--- /dev/null
@@ -0,0 +1,216 @@
+# include "../h/param.h"
+# include "../h/dir.h"
+# include "../h/user.h"
+# include "../h/proc.h"
+# include "../h/uba.h"
+# include "../h/buf.h"
+/*             */
+# define LNKADR (UBA0_DEV+0172410) /* DR11-B devive reg's */
+/*
+*  UBA0_DEV = 0x80018000
+*  LNKADR = 0x80027508
+*/
+/*  DA11-B  DR-11B Status & Command reg */
+# define ERR  0x8000  /*  error bit */
+# define NEX  0x4000  /*  non-existent memory */
+# define IIR  0x800  /*  Input Interrupt Request */
+# define ID  0x400  /*  Input direction */
+# define IM  0x200  /*  Input mode */
+# define CYCLE  0x100  /* Cycle */
+# define RDY  0x80  /* Ready */
+# define IE  0x40  /*  Interrupt Enable */
+# define OIR  8  /*  Output interrupt request */
+# define OD  4  /* Output direction */
+# define OM  2  /* output mode */
+# define GO  1  /* Go bit */
+/*     states  */
+# define CLOSED 0  /*  closed */
+# define  OPEN  1  /* open  */
+# define  S1  2  /* write state 1 */
+# define  S2  4  /* write state 2 */
+# define  R1  8  /* read state 1 */
+# define  R2  16  /* read state 2 */
+# define L_NOT 128  /*  send OIR to other end link */
+# define IPEND 256
+# define PREread  512  /*  'lnkmon' wait */
+# define L_MON 1024  /* 'lnkmon' decr V11opn */
+# define L_WAKE  2048
+# define BUSY (S1|S2|R1|R2)  /* i-o in progress for driver */
+# define S_ERR  0x8000
+/*             */
+# define  V11PRI  0
+# define BUFSIZ  512
+# define VSPEC  0100000
+/*             */
+struct lnkreg {
+       short drwc , drba , drst , drdb ;
+       } ;
+struct {
+       short state ;
+       struct buf *bp ;
+       } V11tab ;
+char V11opn ;
+/*             */
+V11open(dev,flag)
+{
+struct buf *geteblk() ;
+if (V11opn) {
+       u.u_error = EBUSY;
+       return;
+       }
+V11opn++;
+if (V11tab.bp == 0) /* grab system buffer */
+       V11tab.bp = geteblk() ;  /*  VAX call */
+((struct lnkreg *)LNKADR)->drst |= IE ;
+V11tab.state |= OPEN ;
+}
+/*             */
+V11close(dev,flag) /* called on last close only ! ! */
+{
+V11opn = 0;
+V11tab.state = CLOSED ;
+((struct lnkreg *)LNKADR)->drst = 0 ; /* IE off */
+if (V11tab.bp) brelse(V11tab.bp) ; /* release system buffer */
+V11tab.bp = 0 ;
+}
+/*             */
+V11write(dev)
+{
+register int i , j  , k ;
+/*  INIT clears OUTPUT DIR bit = transmitter */
+spl5() ;
+V11tab.state |= S1 ;
+/* setup for transmit */
+((struct lnkreg *)LNKADR)->drst &= ~(OD) ; /* 0 -> transmitter */
+spl0() ;
+i = uballoc(V11tab.bp->b_un.b_addr,BUFSIZ,1) ; /* get UBA map entry for
+       system buffer and set valid bit & BDP no. & BO bit & load map */
+j = i & 0x3ffff ; /* start map no. & byte offset */
+/* write loop, until done or error */
+while ((u.u_count > 0) && (u.u_error == 0)) {
+       iomove(V11tab.bp->b_un.b_addr,min(BUFSIZ,u.u_count),B_WRITE) ; /* move
+               data from user space to system buffer */
+       ((struct lnkreg *)LNKADR)->drwc = (-(BUFSIZ>>1)) ; /* word count */
+       ((struct lnkreg *)LNKADR)->drba = j ; /* map no. (SBI page) & byte offset */
+       spl5() ;
+       ((struct lnkreg *)LNKADR)->drst |= GO ; /* setup for transfer */
+       sleep(LNKADR,V11PRI) ; /* wait for transfer to finish(interrupt) */
+       spl0() ;
+       if (V11tab.state & S_ERR)
+               u.u_error = ENXIO ;
+       }
+ubafree(i) ;
+((struct lnkreg *)LNKADR)->drst &= (~OM);
+V11tab.state &= (~BUSY) ;
+}
+/*             */
+V11read(dev)
+{
+register i , j  ;
+spl5() ;
+V11tab.state |= R1 ;
+((struct lnkreg *)LNKADR)->drst |= OD ; /* receiver */
+spl0() ;
+i = uballoc(V11tab.bp->b_un.b_addr,BUFSIZ,1) ;
+j = i & 0x3ffff ; /* start map no. & byte offset */
+while ((u.u_count>0) && (u.u_error == 0)) {
+       ((struct lnkreg *)LNKADR)->drwc = (-(BUFSIZ>>1)) ;
+       ((struct lnkreg *)LNKADR)->drba = j ;
+       spl5() ;
+       ((struct lnkreg *)LNKADR)->drst |= GO ;
+       /* wait for i-o to finish */
+       sleep(LNKADR,V11PRI) ;
+       spl0() ;
+       if (V11tab.state & S_ERR) {
+               u.u_error = ENXIO ;
+               continue ;
+               }
+       iomove(V11tab.bp->b_un.b_addr,min(BUFSIZ,u.u_count),B_READ) ;
+       }
+ubafree(i) ;
+V11tab.state &= (~BUSY) ;
+}
+/*             */
+V11int(dev)
+{
+register unsigned short state ;
+register int i ;
+extern int V11ioctl() ;
+if ((i = ((struct lnkreg *)LNKADR)->drst) & ERR)
+       V11tab.state |= S_ERR ;
+state = V11tab.state ;
+if (state&BUSY) {
+       wakeup(LNKADR) ;
+       return ;
+       }
+if (i&IM) {
+       if (state&PREread) {
+               wakeup(V11ioctl);
+               return;
+               }
+       if (((state&BUSY) == 0) && (state&OPEN))
+               V11tab.state |= IPEND ;
+       return;
+       }
+}
+/*             */
+V11ioctl(dev,cmd,addr,flag)
+dev_t dev;
+caddr_t addr;
+{
+if (cmd & VSPEC) {
+       switch (cmd & 077777) {
+               case L_WAKE : { /* debug wakeup */
+                       wakeup(LNKADR);
+                       break;
+                       }
+               case L_NOT : { /* send OIR to other end of link */
+                       spl5();
+                       ((struct lnkreg *)LNKADR)->drst |= (OIR|OM) ;
+                       ((struct lnkreg *)LNKADR)->drst &= (~OIR);
+                       spl0();
+                       break;
+                       }
+               case L_MON : { /* 'lnkmon' decr 'V11opn' */
+                       V11opn--;
+                       break;
+                       }
+               case PREread : { /* 'lnkmon' wait */
+                       spl5();
+                       if (V11tab.state&IPEND) {
+                               V11tab.state &= (~IPEND);
+                               }
+                       else {
+                               V11tab.state |= PREread;
+                               sleep(V11ioctl,PZERO+1);
+                               V11tab.state &= (~PREread);
+                               }
+                       spl0();
+                       break;
+                       }
+               }
+       }
+else {
+       *((short *)addr) = V11tab.state;
+       }
+}
diff --git a/usr/src/standalone/CON.h b/usr/src/standalone/CON.h
new file mode 100644 (file)
index 0000000..e5da329
--- /dev/null
@@ -0,0 +1,9 @@
+# define KSP  0
+# define RXCS  32
+# define RXDB  33
+# define TXCS  34
+# define TXDB  35
+# define RXCS_DONE  0x80
+# define TXCS_RDY  0x80
+# define NL  012  /* new-line char */
+# define CR  015  /* carriage-return char */
diff --git a/usr/src/standalone/EMES.h b/usr/src/standalone/EMES.h
new file mode 100644 (file)
index 0000000..6557fae
--- /dev/null
@@ -0,0 +1,26 @@
+char *RPemes[] = {
+       "ILF ","ILR ","RMR ","PAR ",
+       "FER ","WCF ","ECH ","HCE ",
+       "HCRC ","AOE ","IAE ","WLE ",
+       "DTE ","OPI ","UNS ","DCK "
+       } ;
+char *MBAsmes[] = {
+       "RDT ","IST ","RDS ","EC ","IM ","MPE ",
+       "MDPE ","ME ","MT ","WCL ","WCU ",
+       "DTL ","DTA ","DTC ","? ","? ","MA ",
+       "MCPE ","NED ","PE ","? ","? ","? ","? ",
+       "? ","? ","? ","? ","? ","CRD ","NRC ","DTB "
+       } ;
+char *TMemes[] = {
+       "ILF ","ILR ","RMR ","CPAR ","FMT ","DPAR ",
+       "INC/VPE ","PEF/LRC ","NSG ","FCE ","CS/ITM ",
+       "NEF ","DTE ","OPI ","UNS ","COR/CRC "
+       } ;
+char *TMsmes[] = {
+       "SLA ","BOT ","TM ","IDB ","SDWN ","PES ","SSC ",
+       "DRY ","? ","EOT ","WRL ","MOL ","PIP ","ERR ",
+       "ATA "
+       } ;
diff --git a/usr/src/standalone/FL.h b/usr/src/standalone/FL.h
new file mode 100644 (file)
index 0000000..d88e461
--- /dev/null
@@ -0,0 +1,13 @@
+# define FL_FFC 0x200  /* floppy function complete */
+# define FL_ERR 0x80  /* error bit in floppy status byte */
+# define FL_PERR  0x905  /* Floppy protocol error */
+# define FL_DATA  0x100  /*  floppy data select code */
+# define FL_RS 0x900  /* floppy read sector command */
+# define FL_WS  0x901  /*  floppy write sector command */
+# define FL_STAT  0x902  /* floppy get status command */
+/*             */
+# define BLKSIZ 512  /*  tape block size */
+# define RXFTRK  77  /* no. tracks/floppy */
+# define RXSTRK  26  /*  no. sectors/track */
+# define RXBYSEC  128  /*  no. bytes/sector  */
+# define MAXSEC (RXFTRK*RXSTRK)  /* no. sectors/floppy */
diff --git a/usr/src/standalone/MBA.h b/usr/src/standalone/MBA.h
new file mode 100644 (file)
index 0000000..c537638
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+*      MBA  definitions
+*/
+/*
+*      register  offsets
+*/
+# define M_csr  0  /*  configuration/staus reg */
+# define M_cr  1  /* control reg */
+# define M_sr  2  /* status reg */
+# define M_var  3  /* virtual address reg */
+# define M_bc  4  /* byte count reg */
+# define M_map  0x200  /* start of map regs-longword offset */
+/*
+*  misc
+*/
+# define M_BASE  0x20010000  /* phys addr MBA 0 */
+# define NEXSPC  0x2000  /*  no.bytes/NEXUS space */
+# define MAXMBA 4  /*  max. no. of MBA's */
+# define MBAinit  1  /* MBA init in cr */
+# define M_extern  0x400  /*  offset from MBA base to extern reg's */
+# define EXTSIZ 0x80  /*  extern reg space size/device */
+# define M_BCMAX  65536  /* max byte transfer by MBA */
+/*
+*  Status  Reg
+*/
+# define M_RDT  1  /* Read Data Timeout */
+# define M_IST  2  /* Interface Sequence Timeout */
+# define M_RDS  4  /* Read Data Substitute */
+# define M_EC  8  /* Error Confirmation */
+# define M_IM 0x10  /* Invalid Map */
+# define M_MPE  0x20  /* Map Parity Error */
+# define M_MDPE  0x40  /* Massbus Data Parity Error */
+# define M_ME  0x80  /* Massbus Exception */
+# define M_MT  0x100  /* Missed Transfer */
+# define M_WCKL  0x200  /* Write Check Lower */
+# define M_WCKU  0x400  /* Write Check Upper */
+# define M_DTL  0x800  /* Data Transfer Late */
+# define M_DTA  0x1000  /* Data Transfer Abort */
+# define M_DTC  0x2000  /* Data Transfer Complete */
+# define M_MA  0x10000  /*  Massbus Attention */
+# define M_MCPE  0x20000  /* Massbus Control Parity Error */
+# define M_NED  0x40000  /* Non-Existent Drive */
+# define M_PE  0x80000  /* Programming Error */
+# define M_CRD  0x20000000  /* Corrected Read Data */
+# define M_NRC  0x40000000  /* No Response Confirmation */
+# define M_DTB  0x80000000  /* Data Transfer Busy */
diff --git a/usr/src/standalone/README b/usr/src/standalone/README
new file mode 100644 (file)
index 0000000..c72ec7e
--- /dev/null
@@ -0,0 +1,20 @@
+This directory contains all the source code needed to create the
+stand-alone utilites normally found in '/sys'.
+Originally, the source code for each utility was contained
+in one source file per utility. Most of the utilites remain that way
+and much code is duplicated in each of the utilites. Some of the
+utilites, because of changes and improvements, reference
+a few routines which are found in library 'ulib.a'.
+The newer utilities, and eventually all the utilities, are built
+from a relatively small source file and from several routines
+in 'ulib.a' and 'iolib.a'. The newer utilities also refernece
+the '.h' files in this directory.
+The '.h' files contain the 'define' statements necessary to
+define all the device register offsets, function codes, status
+and error code bits, etc. for the various devices.
+'ulib.a' contains the object code
+for all the non-i/o-related functions common to the
+utilities; 'iolib.a' contains the object code for i/o-related
+functions common to the utilities.
+'iosrc.a' contains the source code for the objects in 'iolib.a'.
+'src.a' contains the source for the objects in 'ulib.a'.
diff --git a/usr/src/standalone/RP.h b/usr/src/standalone/RP.h
new file mode 100644 (file)
index 0000000..c4c186a
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+*      *  RP06  Definitions  *
+*/
+/*
+*      RP06  Device  Register  Offsets
+*/
+# define RP_cr  0  /* control reg */
+# define RP_sr  1  /* status reg */
+# define RP_er1  2  /*  Err reg 1 */
+# define RP_mr  3  /* Maintenance reg */
+# define RP_as  4  /* attention summary */
+# define RP_stk  5  /* desired track/sector */
+# define RP_dt  6  /* drive type */
+# define RP_la  7  /* look ahead */
+# define RP_sn  8  /*  serial no. */
+# define RP_off  9  /* offset reg */
+# define RP_cyl  10  /* desired cyl */
+# define RP_cca  11  /* current cyl addr */
+# define RP_er2  12  /* err reg 2 */
+# define RP_er3  13  /*  err reg 3 */
+# define RP_Epos  14  /*  ECC position reg */
+# define RP_Epat  15  /*  ECC pattern reg */
+/*
+*      RP06  Function  Codes
+*/
+# define RP_GO  1  /*  go bit */
+# define RP_NOP  /* no-op function code in control reg */
+# define RP_UNL  2  /* Unload */
+# define RP_RCAL  6  /* Recalibrate */
+# define RP_DC  010  /*  Drive Clear */
+# define RP_REL  012  /* Release */
+# define RP_SRCH  030  /* Search */
+# define RP_WCD  050 /* Write Check Data */
+# define RP_WCH  052  /* Write Check Header & Data */
+# define RP_WR  060  /* Write Data */
+# define RP_WHD  062 /* Write Header & Data (Format) */
+# define RP_RED  070  /* Read */
+# define RP_RHD  072  /* Read Header & Data */
+# define RP_SEEK  4  /* Seek */
+# define RP_OFF  014  /* Centerline Offset */
+# define RP_RTC  016  /* Return to Centerline */
+# define RP_PA  022  /* Pack Acknowledge */
+# define RP_RIP  020  /* Read-in Preset */
+/*
+*      RP06 Offset Register
+*/
+# define RP_HCI  0x400  /*  Header Compare Inhibit */
+# define RP_ECI  0x800  /*  ECC Inhibit */
+/*
+*      RP06  Status Reg
+*/
+# define RP_ATA  0x8000  /* Attention Active */
+# define RP_ERR  0x4000  /* Composite Error */
+# define RP_PIP  0x2000  /* Positioning Operation in Progress */
+# define RP_MOL  0x1000  /* Medium On-Line */
+# define RP_WRL  0x800  /*  Write Lock */
+# define RP_LST  0x400  /* Last Sector Transferred */
+# define RP_PGM  0x200  /* Programmable (Dual Port) */
+# define RP_DRP  0x100  /* Drive Preset (Dual Port) */
+# define RP_DRY  0x80  /*  Drive Ready */
+# define RP_VV  0x40  /* Volume Valid */
+/*
+*  RP06  Error  Register
+*/
+# define RP_DCK  0x8000  /*  Data Check */
+# define RP_UNS  0x4000  /* Drive Unsafe */
+# define RP_OPI  0x2000  /* Operation Incomplete */
+# define RP_DTE  0x1000  /* Drive Timing Error */
+# define RP_WLE  0x800  /* Write LOck Error */
+# define RP_IAE  0x400  /* Invalid Address */
+# define RP_ADE  0x200  /* Address Overflow */
+# define RP_HCRC  0x100  /* Header CRC Error */
+# define RP_HCE  0x80  /* Header Compare Error */
+# define RP_ECH  0x40  /* ECC Hard Error */
+# define RP_WCF  0x20  /* Write Clock Fail */
+# define RP_FER  0x10  /* Format Error */
+# define RP_PAR  8  /* Parity Error */
+# define RP_RMR  4  /* Register Modification Refused */
+# define RP_ILR  2  /* Illegal Register */
+# define RP_ILF  1  /* Illegal Function */
+/*
+*  misc
+*/
+# define RP_BASE  0x400  /* start of external reg's on MBA */
+# define RP6CYL  815  /* no. RP06 cylinders/pack */
+# define RP6TRK  19  /* no. tracks/cyl */
+# define RP6SEC  22  /* no. sectors/track */
+# define RP6ST  (rptrk*rpsec)  /* no. sectors/cyl */
+# define MAXSEC  (rpcyl*rptrk*rpsec)  /* no. sectors/pack */
+# define RP_FMT  0x1000  /* format bit in offset reg */
+/*             */
+# define RM3CYL  823  /*  RM03 */
+# define RM3TRK  5
+# define RM3SEC  32
+# define RP6typ  022
+# define RM3typ  024
+# define RP6HD  8  /* no. bytes RP06 sector header */
+# define RM3HD  4  /*  no. bytes  RM03 sector header */
+# define RM_BSB  0xc000  /*  bad sector bits for format */
diff --git a/usr/src/standalone/TEboot.s b/usr/src/standalone/TEboot.s
new file mode 100644 (file)
index 0000000..0bf96be
--- /dev/null
@@ -0,0 +1,29 @@
+#  Stand-alone code to boot TE16 mag tape - read in
+#    1st block from tape to core loc 0 and halt
+       .set    MBA1,0x20012000
+       .set    M_var,MBA1+12  #  MBA 1 virt addr reg
+       .set    M_bc,MBA1+16  #  MBA 1 byte count reg
+       .set    M_map,MBA1+0x800  #  MBA 1 1st map reg
+       .set    M_cr,MBA1+4  #  MBA 1 control reg
+       .set    MBAinit,1  #  MBA init bit
+#
+       .set    TM02,MBA1+0x400  #  TM02 reg's are 1st set of
+#                      external reg's on MBA 1
+       .set    TM_cs1,TM02+0  #  TM02 control reg
+       .set    TM_tc,TM02+36  #  TM02 tape control reg
+       .set    TM_fc,TM02+0x14
+#
+       .set    GO,1  #  go bit
+       .set    REDF,070  # read fwd function code
+       .set    TCHAR,011700  #  drive 0, odd parity, PDP11,
+#                              800 BPI  NRZI, abort on error - for
+#                              tape control reg
+#
+#
+       movl    $MBAinit,*$M_cr  #  initialize MBA
+       movl    $TCHAR,*$TM_tc  #  set drive characteristics
+       clrl    *$M_var  #  virt addr reg = map reg no. + byte offset
+       movl    $0x80000000,*$M_map  #  map reg = valid bit + mem page no.
+       movl    $-512,*$M_bc  #  byte count = 512
+       movl    $REDF+GO,*$TM_cs1  #  read 1 block
+       halt
diff --git a/usr/src/standalone/TM.h b/usr/src/standalone/TM.h
new file mode 100644 (file)
index 0000000..d2bf958
--- /dev/null
@@ -0,0 +1,36 @@
+/*     TM02  register  definitions     */
+# define TM_cs1  0  /*  TM2 control 1 reg */
+# define TM_ds  1  /*  TM02 status reg */
+# define TM_er  2  /*  TM02 error reg */
+# define TM_mr  3  /*  TM02 maint. reg */
+# define TM_as  4  /*  TM02 attention summary reg */
+# define TM_fc 5  /*  TM02 frame count reg */
+# define TM_dt  6  /*  TM02 drive type reg */
+# define TM_ck  7  /* TM02 check char. reg. */
+# define TM_sn  8  /*  TM02 serial no. reg. */
+# define TM_tc  9  /*  TM02 tape control reg */
+/*             */
+# define TM_GO  1  /*  TM2 go bit */
+# define TM_RWND  06  /*  TM2 Rewind  */
+# define TM_DCLR  010  /*  TM2 drive clear function code */
+# define TM_RIP  020  /*  TM02 Read-In Preset command */
+# define TM_ERAS  024  /*  TM02 erase command */
+# define TM_WTM  026  /*  TM02 write-tape-mark command */
+# define TM_SFWD  030  /*  space forward function code */
+# define TM_SREV  032  /*  TM02 space reverse command */
+# define TM_WRTF       060     /* write forward function code */
+# define TM_REDF  070  /*  read forward function code */
+# define TM_RREV  076  /*  TM02 read reverse command */
+/*             */
+# define TM_DRDY  0x80  /*  TM2/drive ready,status reg */
+# define TM_ERR 0x4000  /*  TM2 composite error, status reg */
+# define TM_MOL  0x1000  /* TM02 medium-on-line status bit */
+# define TM_TM  0x4  /* tape mark bit in TM02 status reg */
+# define TM_EOT  0x400  /*  end-of-tape bit in status reg */
+# define TM_FCE  0x200  /* TM02 frame count error bit */
+/*             */
+# define TM_EPAR  0x8  /* even parity bit in TM02 control reg */
+# define TM_PNOR  0xc0  /*  PDP11 normal mode for tape control reg */
+# define TM_D800  0x300  /* TM02 800BPI for tc reg */
+# define TM_D1600  0x400  /*  TM02 1600BPI PE for tc reg */
+# define TM_EABO  0x1000  /*  TM02 enable abort bit in tc reg */
diff --git a/usr/src/standalone/d2dcpy.c b/usr/src/standalone/d2dcpy.c
new file mode 100644 (file)
index 0000000..c8d34ce
--- /dev/null
@@ -0,0 +1,699 @@
+# define RP6CYL  815  /*  no. RP06 cylinders/pack */
+# define RP6TRK  19  /*  no. tracks/cyl  */
+# define RP6SEC  22  /*  no. sectors/track  */
+# define RP6ST  (rptrk*rpsec)  /*  no. sectors/cyl  */
+# define MAXSEC  (rpcyl*rptrk*rpsec)  /*  sectors/pack  */
+# define M0  0x20010000  /* phys addr MBA 0  */
+# define M_st  2  /*  offset for MBA status reg */
+# define M0_cr  (M0+4)  /*  MBA 0 control reg addr */
+# define M0_map  (M0+0x800)  /* start MBA 0 map reg's */
+# define M0_var  (M0+0xc)  /* MBA 0 virt addr reg */
+# define M0_bc  (M0+0x10)  /*  MBA 0 byte count reg */
+# define MBAinit 01  /*  MBA init bit */
+# define M_DTC  0x2000  /* Data Transfer Complete */
+/*             */
+# define RP  (M0+0x400)  /*  base for RP06 reg's, drive 0  */
+/*             */
+# define RP_cr  0  /* RP06 control reg offset, longword */
+# define RP_sr  1  /*  RP06 status reg offset */
+# define RP_er1  2  /*  RP06 error reg 1 */
+# define RP_stk  5  /*  RP06 sector/track reg offset */
+# define RP_typ  06  /*  disk type reg */
+# define RP_off  011  /*  RP offset reg */
+# define RP_cyl  10  /*  RP06 cylinder reg offset */
+# define RP_Epos 016  /*  RP ECC position reg */
+# define RP_Epat 017  /*  RP ECC pattern reg */
+/*             */
+# define RP_GO  1  /*  go bit */
+# define RP_RD 070     /* RP06 read function code */
+# define RP_WR  060  /*  RP06 write function code */
+# define RP_DC  010  /*  drive clear function code */
+# define RP_FMT  0x1000  /*  format bit in RP offset reg */
+# define RP_RIP  020  /*  Read-in Preset function code */
+# define RP_MOL  0x1000  /*  medium online bit in status */
+# define RP_DRY  0200  /*  drive ready, status reg */
+# define RP_ERR 040000  /* composite error, status reg */
+# define RP_DCK  0x8000  /*  Data Check Error in ERR1 reg */
+# define RP_ECH  0x40  /*  ECC hard error */
+/*             */
+# define RXCS  32  /*  receiver control/staus */
+# define RXDB  33  /*  receiver data */
+# define TXCS  34  /*  transmitter control/status */
+# define TXDB  35  /*  transmitter data */
+# define RXCS_DONE  0x80  /*  receiver done */
+# define TXCS_RDY  0x80  /*  transmitter ready */
+/*             */
+# define BLKSIZ 512
+# define NB 128  /*  max. byte transfer = 64K bytes */
+# define BUFSIZ (NB*BLKSIZ)
+# define MAXUNI  1
+# define MAXERR 10  /*  max. no. i/o errors allowed */
+# define NL  012
+# define CR 015
+# define CDEL  0x23
+# define LDEL  0x40
+/*             */
+# define RM3CYL  823  /* RM03 */
+# define RM3TRK  5
+# define RM3SEC  32
+# define RP6typ  022
+# define RM3typ  024
+struct { int reg ; } ;
+int dinoff , douoff  , dblks , count  , ecount , daterr ;
+char *bufptr ;
+unsigned int page ;
+int *RPin , *RPout ;
+int rpsec,rptrk,rpcyl;
+char input[132] ;
+main() {
+/*
+*  Stand-alone program to copy rp06/RM03 disk to rp06/RM03 disk, same or
+*  different drives. User specifies input and output disk, no.
+*  of 512-byte blocks, and disk offsets.
+*/
+register int i , error ;
+
+putlin("d2dcpy : Disk-to-Disk Copy") ;
+putnl() ;
+d1u :
+putstr("input disk unit : ") ;
+getcon(input) ;
+i = a2l(input) ;
+if (i < 0) goto fini ;
+if (i > MAXUNI) goto d1u ;
+RPin = RP + (i * 32 * 4) ;
+dof1 :
+putstr("offset : ") ;
+getcon(input) ;
+dinoff = a2l(input) ;
+d2u :
+putstr("output disk unit : ") ;
+getcon(input) ;
+i = a2l(input) ;
+if ((i > MAXUNI) || (i < 0)) goto d2u ;
+RPout = RP + (i * 32 * 4) ;
+dof2 :
+putstr("offset : ") ;
+getcon(input) ;
+douoff = a2l(input) ;
+gknt :
+putstr("no. 512-byte blocks : ") ;
+getcon(input) ;
+count = a2l(input) ;
+error = 0 ;
+if (init()) {
+       putlin("init error") ;
+       goto d1u ;
+       }
+if ((dinoff < 0) || (dinoff > MAXSEC-1)) goto dof1 ;
+if ((douoff < 0) || (douoff > MAXSEC-1)) goto dof2 ;
+if (count < 0) goto gknt ;
+if (count == 0) count = MAXSEC ;
+ecount = daterr = 0 ;
+while ((error == 0) && (count>0)) {
+       if (dread()) {
+               dioerr :
+                       putlin("disc i/o error") ;
+                       error++ ;
+                       continue ;
+                       }
+       if (dwrite()) goto dioerr ;
+       count -= dblks ;/*  dec no. blocks read */
+       }
+fini :
+putstr("# Data Check Errors : ") ;
+l2x(daterr,input) ;
+putlin(input) ;
+putstr("# Other errors : ") ;
+l2x(ecount,input) ;
+putlin(input) ;
+return(0) ;
+}
+/*             */
+putstr(csp)
+register char *csp ;
+{
+if (putcon(csp)) return(-1) ;
+return(0) ;
+}
+/*             */
+putlin(sptr)
+register char *sptr ;
+{
+if (putcon(sptr)) return(-1) ;
+if (putnl()) return(-1) ;
+return(0) ;
+}
+/*             */
+putnl()
+{
+if (putcon("\r\n")) return(-1) ;
+return(0) ;
+}
+/*             */
+putcon(csp)
+register char *csp ;
+{
+/*
+*  Function to output null-terminated string pointed to 
+*  by 'csp' to the VAX LSI terminal.
+*/
+register c ;
+c = 0 ;
+while (c = (*csp++)) putc(c) ;
+return(0) ;
+}
+/*             */
+putc(c)
+{
+/*  wait for LSI printer to be ready */
+while ((mfpr(TXCS) & TXCS_RDY) == 0) ;
+/*  output character */
+mtpr(TXDB,c&0177) ;
+}
+/*             */
+getcon(cs)
+register char *cs ;
+{
+/*
+*  Function to return char's from VAX LSI keyboard to
+*  char array 'cs' - input stops when CR or LF received -
+*  null char appended to end of input
+*/
+register int c , c2 ;
+int getc() ;
+char *ocs;
+       ocs=cs;
+inloop :
+       c = getc() ; /* get 1 char from terminal */
+       putc(c) ;  /*  echo char */
+       if (c==CDEL) { --cs; goto inloop; }
+       if (c==LDEL){ putc(NL);putc(0);putc(CR);cs=ocs;goto inloop;}
+       if ((c == NL) || (c == CR)) {
+               putc(CR) ;
+               putc(0) ;
+               putc(NL) ;
+               (*cs++) = '\0' ;
+               return(0) ;
+               }
+       else {
+               (*cs++) = c ;
+               goto inloop ;
+               }
+}
+/*             */
+getc()
+{
+/*
+*  Return char from VAX LSI terminal char buffer
+*/
+int mfpr() ;
+/*  Wait for receiver done (user entered char)
+*/
+while ((mfpr(RXCS) & RXCS_DONE) == 0) ;
+return (mfpr(RXDB) & 0177) ;  /* return char from receiver buffer */
+}
+/*             */
+mtpr(regno,value)
+{
+       asm("   mtpr    8(ap),4(ap)") ;
+}
+/*             */
+mfpr(regno)
+{
+       asm("   mfpr    4(ap),r0") ;
+}
+/*             */
+a2l(as)
+register char *as ;
+{
+/*
+*  Convert null-terminated ascii string to binary
+*  and return value.
+*  1st char in string :
+*      0 -> octal
+*      x -> hex
+*      else decimal
+*/
+register value , base , sign , digit ;
+digit = value = sign = 0 ;
+base = 10 ;  /* default base */
+aloop :
+if ((digit = (*as++)) == 0) return(value) ; /* null */
+if (digit == '-') {
+       sign++ ;
+       goto aloop ;
+       }
+if (digit == '0') base = 8 ;  /* octal base  */
+else { if (digit == 'x') base = 16 ;  /* hex base */
+       else value = (digit-060) ; /* 060 = '0' */
+       }
+while (digit = (*as++)) {
+       if (digit < '0') return(0) ;
+       switch (base) {
+               case 8 : {
+                       if (digit > '7') return(0) ;
+                       digit -= 060 ;
+                       break ;
+                       }
+               case 10 : {
+                       if (digit > '9') return(0) ;
+                       digit -= 060 ;
+                       break ;
+                       }
+               case 16 : {
+                       if (digit <= '9') {
+                               digit -= 060 ;
+                               break ;
+                               }
+                       if ((digit >= 'A') && (digit <= 'F')) {
+                               digit = (digit - 0101 + 10) ;
+                                       break ;
+                               }
+                       if ((digit >= 'a') && (digit <= 'f')) {
+                               digit = digit - 0141 + 10 ;
+                               break ;
+                               }
+                       return(0) ;
+                       break ;
+                       }
+               }
+       value = (value * base) + digit ;
+       }
+return (sign ? -value : value) ;
+}
+/*             */
+init() {
+/*
+*  Initialization.
+*  Initialize MBA 0 for disk i/o.
+*  Set up MBA 0 map registers to map a max.
+*    transfer of 'BUFSIZ' bytes.
+*/
+register int *mp0 , i ;
+extern char *end ;
+M0_cr->reg = MBAinit ;
+dblks = BUFSIZ/BLKSIZ ; /* no. of disk blocks / input buffer */
+if ((*(RPin+RP_sr) & RP_MOL) == 0) {
+       putlin("input unit not online") ;
+       return(-1) ;
+       }
+*(RPin+RP_cr) = RP_RIP | RP_GO ; /* preset */
+*(RPin+RP_off) = RP_FMT ; /* set format bit */
+if (RPin != RPout) {
+       if ((*(RPout + RP_sr) & RP_MOL) == 0) {
+               putlin("output unit not online") ;
+               return(-1) ;
+               }
+       *(RPout+RP_cr) = RP_RIP | RP_GO ;
+       *(RPout+RP_off) = RP_FMT ;
+       }
+i = *(RPout+RP_typ)&0777 ;  /* get disk type */
+if (i==RP6typ) { /* RP06 */
+       rpsec=RP6SEC; rpcyl=RP6CYL; rptrk=RP6TRK;
+       }
+else {
+       if (i==RM3typ) {
+               rpsec=RM3SEC; rpcyl=RM3CYL; rptrk=RM3TRK;
+               }
+       else return(-1);
+       }
+bufptr = (int)(&end + 511) & 017777777000 ;
+page = (int)((int)bufptr>>9) & 017777777 ;
+mp0 = M0_map ; /* phys addr of MBA 0 map reg base */
+i = NB ;
+while (i--)
+       (*mp0++)= 0x80000000 | page++ ; /* map entry */
+
+return(0);
+}
+/*             */
+dread()
+{
+/*
+*  Function to read 'BUFSIZ' bytes (512 multiple) from disc
+*  to buffer .
+*/
+register int i , j ;
+*(RPin+RP_cyl) = dinoff/RP6ST ; /* cylinder no. */
+i = dinoff%RP6ST ;
+j = (i/rpsec)<<8 ; /* track */
+*(RPin+RP_stk) = j | (i%rpsec) ; /* sector : track */
+dinoff += dblks ;  /*  point to next disc sector */
+M0_bc->reg = (count<dblks?-(count*512):(-BUFSIZ)) ; /* byte count */
+M0_var->reg = 0 ; /* virt addr reg = map no. + byte off */
+rbit :
+*(RPin+RP_cr) = RP_DC | RP_GO ; /* drive clear */
+dwait(RPin) ;
+*(RPin+RP_cr) = RP_RD | RP_GO ; /* read */
+dwait(RPin) ; /* wait for i/o to finish */
+if (i = mbaerr(M0)) {
+       /* don't abort on MBA errors - 'mbaerr()' has cleared
+       MBA status reg */
+    }
+if (i = derror(RPin)) { /*  error  */
+       putlin("- - - - - -") ;
+       putstr("read error") ;
+       stmes(i) ;
+       dadmes(RPin) ;
+       if (i & RP_DCK) { /* Data Check Error */
+               daterr++ ;
+               putlin("Data Check") ;
+               if (i & RP_ECH) { /*  ECC Hard Error */
+                       putlin("ECC non-recov") ;
+                       ecount++ ;
+                       }
+               else { /*  ECC Recoverable */
+                       ECCrcv(RPin) ;
+                       }
+               if (M0_bc->reg) { /* more i-o to finish ? */
+                       j = (*(RPin+RP_stk));
+                       i = (j>>8) & 0x1f;
+                       j = j & 0x1f;
+                       if (j>=rpsec) /*sector */
+                               j = 0;
+                       if (i>=rptrk) /* track */
+                               i = 0;
+                       *(RPin+RP_stk) = (i<<8) | j;
+                       goto rbit ; /* staus reg cleared by 'Drive Clear' */
+                       }
+               else {
+               *(RPin+RP_cr) = RP_DC | RP_GO;
+                       mbaerr(M0);
+                       }
+               }
+       else { /* non-Data Check error */
+               ecount++ ;
+               }
+       if (ecount > MAXERR) return(-1) ;
+       }
+return(0) ; /* normal return */
+}
+/*             */
+dwrite()
+{
+/*
+*  Function to write 'BUFSIZ' bytes (512 multiple) to disc
+*  from buffer .
+*/
+register int i , j ;
+*(RPout+RP_cr) = RP_DC | RP_GO ;
+*(RPout+RP_cyl) = douoff/RP6ST;
+i = douoff%RP6ST ;
+j = (i/rpsec)<<8 ; /* track */
+*(RPout+RP_stk) = j | (i%rpsec) ; /* sector : track */
+M0_bc->reg = (count<dblks?-(count*512):(-BUFSIZ)) ; /* byte count */
+M0_var->reg = 0 ; /* virt addr reg = map no. + byte off */
+*(RPout+RP_cr) = RP_WR | RP_GO ; /* write */
+douoff += dblks ;  /*  point to next disc sector */
+dwait(RPout) ; /* wait for i/o to finish */
+if (i = mbaerr(M0)) {
+  return(-1) ;
+  }
+if (i = derror(RPout)) {
+       putstr("write error") ;
+       stmes(i) ;
+       dadmes(RPout) ;
+       if (++ecount > MAXERR) return(-1) ;
+  }
+return(0) ; /* normal return */
+}
+/*             */
+dwait(dptr)
+register int *dptr ;
+{
+/*
+* Function to wait MBA 0 RP06 disc unit to be ready.
+*/
+while ((*(dptr+RP_sr)&RP_DRY) == 0) ;
+}
+/*             */
+derror(dptr)
+register int *dptr ;
+{
+/*
+*  Function to check for MBA 0 RP06 error.
+*/
+if (*(dptr+RP_sr) & RP_ERR) return(*(dptr+RP_er1) & 0177777) ;
+return(0) ;
+}
+/*             */
+halt()
+{
+asm("  halt") ;
+}
+/*             */
+stmes(code)
+int code ;
+{
+putstr(" : err reg : ") ;
+RPE_print(code) ;
+}
+/*             */
+dadmes(dptr)
+register int *dptr ;
+{
+register char *mesp ;
+register int i ;
+mesp = " cyl     trk     sec    " ;
+i = l2x(*(dptr+RP_cyl) & 01777,&mesp[5]) ;
+blnkit(&mesp[5+i],4-i) ;
+i = l2x((*(dptr+RP_stk)>>8) & 037 , &mesp[13]) ;
+blnkit(&mesp[13+i],3-i) ;
+i = l2x(*(dptr+RP_stk)&037,&mesp[21]) ;
+blnkit(&mesp[21+i],3-i) ;
+putlin(mesp) ;
+}
+/*             */
+blnkit(mp,cc)
+register char *mp ;
+register int cc ;
+{
+while (cc--)
+       (*mp++) = ' ' ;
+}
+/*             */
+mbaerr(mba)
+register int *mba ;
+{
+register int i ;
+if ((i = (*(mba+M_st))) != M_DTC) {
+       putlin("- - - - - -") ;
+       putstr("MBA error : status reg = ") ;
+       MBAS_print(i) ;
+       *(mba+M_st) = (-1) ;
+       return(i) ;
+  }
+return(0) ;
+}
+/*             */
+l2x(val,rptr)
+register int val ;
+register char *rptr ;
+{
+register int i , j ;
+register char *tp ;
+int knt ;
+char tmp[20] , sign ;
+knt = sign = 0 ;
+if (val < 0) {
+       sign++ ;
+       val = (-val) ;
+       }
+tp = tmp ;
+loop :
+       knt++ ;
+       i = val/16  ;  /*  quotient & base 16 */
+       j = val%16 ;
+       (*tp++) = j + (j<10?0x30:0x57) ;
+       val = i ;
+       if (val == 0) {
+               /*  done  dividing  */
+               if (sign) { knt++ ; (*tp++) = '-' ; }
+               for (i = knt ; i ; i--)
+                       (*rptr++) = tmp[i-1] ;
+               (*rptr++) = '\0' ;
+               return(knt) ;
+               }
+       else goto loop ;
+}
+/*             */
+ECCrcv(dptr)
+register int *dptr ;
+{
+/*
+*  Do ECC error recovery on disk whose register set is pointed
+*  to by 'dptr'.
+*  'mbaerr()' has cleared MBA status reg.
+*  With ECC enabled, disk read has stopped after sector with bad
+*  data. After correction of data, return to 'dread()' which will
+*  continue read of track if more sectors to do.
+*  Return 0.
+*/
+register unsigned int pos , pat ;
+register unsigned short *wordp ;
+unsigned int ll ;
+struct { short wlo , whi ; } ;
+char tmp[50] ;
+pat = (*(dptr+RP_Epat)) & 0xffff ; /* ECC pattern reg */
+pos = (*(dptr+RP_Epos)) & 0xffff ; /* ECC position reg */
+putstr("pat : ") ;
+ul2x(pat,tmp) ;
+putlin(tmp) ;
+putstr("pos : ") ;
+ul2x(pos,tmp) ;
+putlin(tmp) ;
+wordp = bufptr ;   /* ptr to buffer */
+/*
+*  'BUFSIZ' bytes are read on each read into buffer pointed to
+*  by 'bufptr'. MBA byte count reg has neg. no. of bytes remaining
+*  in read if this read error was not in the last sector to be
+*  read.
+*/
+/* calculate buffer location of faulty data */
+wordp = (char *)wordp + (BUFSIZ + ((M0_bc->reg)>>16) - BLKSIZ) ; /* sector in buffer */
+wordp = wordp +  ((pos-1)>>4) ; /* word within sector */
+/* burst pattern may be across word boundary */
+ll = (*wordp) + ((*(wordp+1))<<16) ;
+putstr("bad data  : ") ;
+ul2x(ll,tmp) ;
+putlin(tmp) ;
+pat = pat<<((pos%16)-1) ;
+ll = ll^pat ; /* correction */
+putstr("good data : ") ;
+ul2x(ll,tmp) ;
+putlin(tmp) ;
+/* put good data back in buffer */
+*wordp = ll.wlo ;
+*(wordp+1) = ll.whi ;
+return(0) ;
+}
+/*             */
+ul2x(val,rptr)
+register unsigned int val ;
+register char *rptr ;
+{
+register unsigned int i , j ;
+register char *tp ;
+int knt ;
+char tmp[20] ;
+unsigned int udiv() , urem() ;
+knt =  0 ;
+tp = tmp ;
+loop :
+       knt++ ;
+       /* use unsigned integer divide & remainder routines */
+       i = udiv(val,16)  ;  /*  quotient & base 16 */
+       j = urem(val,16) ;
+       (*tp++) = j + (j<10?0x30:0x57) ;
+       val = i ;
+       if (val == 0) {
+               /*  done  dividing  */
+               for (i = knt ; i ; i--)
+                       (*rptr++) = tmp[i-1] ;
+               (*rptr++) = '\0' ;
+               return(knt) ;
+               }
+       else goto loop ;
+}
diff --git a/usr/src/standalone/d2tcpy.c b/usr/src/standalone/d2tcpy.c
new file mode 100644 (file)
index 0000000..dc7d30c
--- /dev/null
@@ -0,0 +1,542 @@
+# define MIN(a,b) (a<b?a:b)
+# define RP6CYL  815  /*  no. RP06 cylinders/pack */
+# define RP6TRK  19  /*  no. tracks/cyl  */
+# define RP6SEC  22  /*  no. sectors/track  */
+# define RP6ST  (RP6TRK*RP6SEC)  /*  no. sectors/cyl  */
+# define MAXSEC  (RP6CYL*RP6TRK*RP6SEC)  /*  sectors/pack  */
+# define M0  0x20010000  /* phys addr MBA 0  */
+# define M1  0x20012000  /*  phys addr MBA 1  */
+# define M0_cr  (M0+4)  /*  MBA 0 control reg addr */
+# define M1_cr  (M1+4)  /*  MBA 1 control reg addr  */
+# define M0_map  (M0+0x800)  /* start MBA 0 map reg's */
+# define M1_map  (M1+0x800)  /* start MBA 1 map reg's  */
+# define M0_var  (M0+0xc)  /* MBA 0 virt addr reg */
+# define M1_var  (M1+0xc)  /*  MBA 1 virt addr reg  */
+# define M0_bc  (M0+0x10)  /*  MBA 0 byte count reg */
+# define M1_bc  (M1+0x10)  /*  MBA 1 byte count reg  */
+# define MBAinit 01  /*  MBA init bit */
+/*             */
+# define TM  (M1+0x400)  /*  base for TM02/TE16 reg's */
+# define RP  (M0+0x400)  /*  base for RP06 reg's, drive 0  */
+/*             */
+# define TM_tc  (TM+0x24)  /*  TM02 tape control reg */
+# define TM_cs1  (TM+0)  /*  TM02 control 1 reg */
+# define TM_ds  (TM+4)  /*  status reg */
+# define TM_fc  (TM+0x14)  /*  TM02 frame count reg */
+/*             */
+# define RP_cr  0  /* RP06 control reg offset, longword */
+# define RP_sr  1  /*  RP06 status reg offset */
+# define RP_stk  5  /*  RP06 sector/track reg offset */
+# define RP_off  011  /*  RP offset reg */
+# define RP_cyl  10  /*  RP06 cylinder reg offset */
+/*             */
+# define RP_GO  1  /*  go bit */
+# define RP_RD 070     /* RP06 read function code */
+# define RP_WR  060  /*  RP06 write function code */
+# define RP_DC  010  /*  drive clear function code */
+# define RP_FMT  0x1000  /*  format bit in RP offset reg */
+# define RP_RIP  020  /*  Read-in Preset function code */
+# define RP_MOL  0x1000  /*  medium online bit in status */
+# define RP_DRY  0200  /*  drive ready, status reg */
+# define RP_ERR 040000  /* composite error, status reg */
+/*             */
+# define TM_GO  1  /*  TM02 go bit */
+# define TM_DCLR  010  /*  TM02 drive clear function code */
+# define TM_SFWD  030  /*  space forward function code */
+# define TM_WRTF       060     /* write forward function code */
+# define TM_REDF  070  /*  read forward function code */
+# define TM_RWND  06  /*  TM02 Rewind  */
+# define TM_WEOF       026     /* write end of file function */
+# define TCHAR 01300  /*  TM02/TE16 drive 0 ,800 BPI,PDP11,etc. */
+# define TM_DRDY  0200  /*  TM02/drive ready,status reg */
+# define TM_ERR 040000  /*  TM02 composite error, status reg */
+/*             */
+# define RXCS  32  /*  receiver control/staus */
+# define RXDB  33  /*  receiver data */
+# define TXCS  34  /*  transmitter control/status */
+# define TXDB  35  /*  transmitter data */
+# define RXCS_DONE  0x80  /*  receiver done */
+# define TXCS_RDY  0x80  /*  transmitter ready */
+/*             */
+# define BUFSIZ 5120  /*  max tape block size = input buffer size */
+# define MAXUNI  1
+# define NL  012
+# define CR 015
+/*             */
+char input[BUFSIZ]  ;  /*  tape input buffer */
+struct { int reg ; } ;
+int blksiz ,tapoff , dskoff ,  wsize , dblks ;
+int count;
+unsigned int ins , outs ;
+unsigned short nread  , bytoff , error ;
+int *RPptr , dunit ; /* ptr to start of RP reg's for desired drive */
+main() {
+/*
+*  Stand-alone program to copy TM02/TE16 drive 0 mag tape to
+*  RP06 disc.
+*  User specifies tape block size (must be multiple of 512), tape
+*  offset (tape blocks), disc unit no., disc offset (512-byte
+*  blocks) and count of tape blocks to be transferred.
+*/
+int getcon() , putstr() , a2l() , l2a() ;
+
+putlin("d2tcpy : Disk-to-Tape Copy") ;
+putnl() ;
+bsize :
+if (putstr("tape block size : ")) goto fini ;
+if (getcon(input)) goto fini ;
+putnl() ;
+blksiz = a2l(input) ;
+if ((blksiz <= 0) || (blksiz > BUFSIZ)) goto bsize ;
+if (blksiz%512) goto bsize ;  /*  block size must be 512 multiple */
+M0_cr->reg = MBAinit ; /* MBA 0 init */
+M1_cr->reg = MBAinit ; /* MBA 1 init */
+TM_tc->reg = TCHAR ; /* TE16,drive 0 ,800 BPI, PDP11, odd parity,
+                       abort on error */
+TM_cs1->reg = TM_DCLR | TM_GO ; /* clear tape drive 0 */
+if (terror()) goto taperr ;
+toff :
+if (putstr("tape offset : ")) goto fini ;
+if (getcon(input)) goto fini ;
+putnl() ;
+tapoff = a2l(input) ;
+if (tapoff < 0) goto toff ;
+if (taprew()) goto taperr ;
+if (tapspc(tapoff)) goto taperr ;
+dun :
+if (putstr("disk unit : ")) goto fini ;
+if (getcon(input)) goto fini ;
+putnl() ;
+dunit = a2l(input) ;
+if ((dunit > MAXUNI) || (dunit < 0)) goto dun ;
+doff :
+if (putstr("disc offset : ")) goto fini ;
+if (getcon(input)) goto fini ;
+putnl() ;
+dskoff = a2l(input) ;
+if ((dskoff < 0) || (dskoff > MAXSEC-1)) goto doff ;
+gknt :
+if (putstr("no. of input blocks : ")) goto fini ;
+if (getcon(input)) goto fini ;
+putnl() ;
+count = a2l(input) ;
+if (count < 0) goto gknt ;
+error = 0 ;
+if (init()) goto bsize ;
+while ((error == 0) && (count>0)) {
+       if (dread()) {
+               putlin("disc i/o error") ;
+               goto ioerr ;
+               }
+       ins++ ;  /*  count of disk blocks input */
+       if (twrite()) {
+               taperr :
+                       putlin("tape i/o error") ;
+                       ioerr :
+                               error++ ;
+                               continue ;
+                       }
+       outs =+ dblks ;  /*  count of tape blocks output */
+       count -= nread ;/*  dec no. blocks read */
+}
+fini :
+TM_cs1->reg = TM_WEOF | TM_GO;
+twait();
+TM_cs1->reg = TM_RWND | TM_GO;
+twait();
+return(0) ;
+}
+/*             */
+putstr(csp)
+register char *csp ;
+{
+if (putcon(csp)) return(-1) ;
+return(0) ;
+}
+/*             */
+putlin(sptr)
+register char *sptr ;
+{
+if (putcon(sptr)) return(-1) ;
+if (putnl()) return(-1) ;
+return(0) ;
+}
+/*             */
+putnl()
+{
+if (putcon("\r\n")) return(-1) ;
+return(0) ;
+}
+/*             */
+putcon(csp)
+register char *csp ;
+{
+/*
+*  Function to output null-terminated string pointed to 
+*  by 'csp' to the VAX LSI terminal.
+*/
+register c ;
+c = 0 ;
+while (c = (*csp++)) putc(c) ;
+return(0) ;
+}
+/*             */
+putc(c)
+{
+/*  wait for LSI printer to be ready */
+while ((mfpr(TXCS) & TXCS_RDY) == 0) ;
+/*  output character */
+mtpr(TXDB,c&0177) ;
+}
+/*             */
+getcon(cs)
+register char *cs ;
+{
+/*
+*  Function to return char's from VAX LSI keyboard to
+*  char array 'cs' - input stops when CR or LF received -
+*  null char appended to end of input
+*/
+register int c , c2 ;
+int getc() ;
+inloop :
+       c = getc() ; /* get 1 char from terminal */
+       putc(c) ;  /*  echo char */
+       if ((c == NL) || (c == CR)) {
+               putc(CR) ;
+               putc(0) ;
+               putc(NL) ;
+               (*cs++) = '\0' ;
+               return(0) ;
+               }
+       else {
+               (*cs++) = c ;
+               goto inloop ;
+               }
+}
+/*             */
+getc()
+{
+/*
+*  Return char from VAX LSI terminal char buffer
+*/
+int mfpr() ;
+/*  Wait for receiver done (user entered char)
+*/
+while ((mfpr(RXCS) & RXCS_DONE) == 0) ;
+return (mfpr(RXDB) & 0177) ;  /* return char from receiver buffer */
+}
+/*             */
+mtpr(regno,value)
+{
+       asm("   mtpr    8(ap),4(ap)") ;
+}
+/*             */
+mfpr(regno)
+{
+       asm("   mfpr    4(ap),r0") ;
+}
+/*             */
+a2l(as)
+register char *as ;
+{
+/*
+*  Convert null-terminated ascii string to binary
+*  and return value.
+*  1st char in string :
+*      0 -> octal
+*      x -> hex
+*      else decimal
+*/
+register value , base , sign , digit ;
+digit = value = sign = 0 ;
+base = 10 ;  /* default base */
+aloop :
+if ((digit = (*as++)) == 0) return(value) ; /* null */
+if (digit == '-') {
+       sign++ ;
+       goto aloop ;
+       }
+if (digit == '0') base = 8 ;  /* octal base  */
+else { if (digit == 'x') base = 16 ;  /* hex base */
+       else value = (digit-060) ; /* 060 = '0' */
+       }
+while (digit = (*as++)) {
+       if (digit < '0') return(0) ;
+       switch (base) {
+               case 8 : {
+                       if (digit > '7') return(0) ;
+                       digit -= 060 ;
+                       break ;
+                       }
+               case 10 : {
+                       if (digit > '9') return(0) ;
+                       digit -= 060 ;
+                       break ;
+                       }
+               case 16 : {
+                       if (digit <= '9') {
+                               digit -= 060 ;
+                               break ;
+                               }
+                       if ((digit >= 'A') && (digit <= 'F')) {
+                               digit = (digit - 0101 + 10) ;
+                                       break ;
+                               }
+                       if ((digit >= 'a') && (digit <= 'f')) {
+                               digit = digit - 0141 + 10 ;
+                               break ;
+                               }
+                       return(0) ;
+                       break ;
+                       }
+               }
+       value = (value * base) + digit ;
+       }
+return (sign ? -value : value) ;
+}
+/*             */
+taprew()
+{
+/*
+*  Function to rewind TM02/TE16 drive
+*/
+TM_cs1->reg = TM_RWND | TM_GO ;
+twait() ;
+if (terror()) return(-1) ;
+return(0) ;
+}
+/*             */
+tapspc(fblk)
+{
+/*
+*  Function to space forward 'fblk' blocks on TM02/TE16 drive
+*/
+if (fblk) {
+       TM_fc->reg = (-fblk) ; /* no. blocks */
+       TM_cs1->reg = TM_SFWD | TM_GO ;   /* space forward */
+       twait() ;
+       if (terror()) return(-1) ;
+       }
+return(0) ;
+}
+/*             */
+twait()
+{
+/*
+*  Function to wait until TM02/TE16 is not busy
+*/
+while ((TM_ds->reg & TM_DRDY) == 0) ;
+}
+/*             */
+terror()
+{
+/*
+*  Function to check for TM02 error
+*  Return (-1) if error,
+*      esle return (0).
+*/
+if (TM_ds->reg & TM_ERR) return(-1) ;
+return(0) ;
+}
+/*             */
+init() {
+/*
+*  Initialization.
+*  Initialize MBA 0 (disk) and MBA 1 (tape).
+*  Initialize TM02/TE16 for drive 0 , 800 BPI, PDP11, etc.
+*  Set up MBA 0 and MBA 1 map registers to map a max.
+*    transfer of 'BUFSIZ' bytes.
+*/
+register int *mp0 , *mp1 , i , page ;
+nread = BUFSIZ/blksiz ; /* no. of tape reads to fill input buffer */
+wsize = nread * blksiz ; /* no. bytes each write to disc */
+dblks = wsize/512 ; /* no. of disc blocks on each write */
+RPptr = RP + (dunit * 32 * 4) ; /* start of RP reg's for drive */
+if ((*(RPptr+RP_sr) & RP_MOL) == 0) {
+       putlin("unit not online") ;
+       return(-1) ;
+       }
+*(RPptr+RP_cr) = RP_RIP | RP_GO ; /* preset :/
+*(RPptr+RP_off) = RP_FMT ; /* set format bit */
+bytoff = (int)(&input[0])&0777 ; /* byte offset of buffer addr */
+page = ((int)&input[0] >> 9) & 07777777 ; /* start page of buffer */
+mp0 = M0_map ; /* phys addr of MBA 0 map reg base */
+mp1 = M1_map ; /*  "   "       "  1    "       " */
+i = (((BUFSIZ+511)>>9)&0777) + 1 ; /* max. no. of pages */
+while (i--)
+       (*mp0++) = (*mp1++) = 0x80000000 | page++ ; /* map entry */
+}
+/*             */
+twrite()
+{
+/*
+*  Function to write TM02/TE16 tape drive, 'blksiz' bytes each
+*  write, and 'nread' writes.
+*/
+register int i, j ;
+j = 0;
+for (i = MIN(nread,count) ; i ; i--) {
+       M1_var->reg = bytoff + j++ * blksiz;
+       M1_bc->reg = (-blksiz) ; /* MBA 1 byte count reg */
+       TM_fc->reg = (-blksiz); /* tape frame counter register */
+       TM_cs1->reg = TM_WRTF | TM_GO ; /* write forward */
+       twait() ; /* wait for ready */
+       if (terror()) return(-1) ; /* return on error */
+       }
+return(0) ; /* normal return */
+}
+/*             */
+dread()
+{
+/*
+*  Function to read 'wsize' bytes (512 multiple) from disc
+*  to buffer 'input[]".
+*/
+register int i , j ;
+*(RPptr+RP_cr) = RP_DC | RP_GO ; /* drive clear */
+*(RPptr+RP_cyl) = dskoff/RP6ST ; /* cylinder no. */
+i = dskoff%RP6ST ;
+j = (i/RP6SEC)<<8 ; /* track */
+*(RPptr+RP_stk) = j | (i%RP6SEC) ; /* sector : track */
+M0_bc->reg = (count<nread?-(count*512):(-wsize)) ; /* byte count */
+M0_var->reg = bytoff ; /* virt addr reg = map no. + byte off */
+*(RPptr+RP_cr) = RP_RD | RP_GO ; /* write */
+dskoff =+ dblks ;  /*  point to next disc sector */
+dwait() ; /* wait for i/o to finish */
+if (derror()) return(-1) ; /* error */
+return(0) ; /* normal return */
+}
+/*             */
+dwait() {
+/*
+* Function to wait MBA 0 RP06 disc unit to be ready.
+*/
+while ((*(RPptr+RP_sr)&RP_DRY) == 0) ;
+}
+/*             */
+derror()
+{
+/*
+*  Function to check for MBA 0 RP06 error.
+*/
+if (*(RPptr+RP_sr) & RP_ERR) return(-1) ;
+return(0) ;
+}
+/*             */
+halt()
+{
+asm("  halt") ;
+}
+/*             */
+l2a(val,rptr)
+register int val ;
+register char *rptr ;
+{
+register int i ;
+register char *tp ;
+int knt ;
+char tmp[20] , sign ;
+knt = sign = 0 ;
+if (val < 0) {
+       sign++ ;
+       val = (-val) ;
+       }
+tp = tmp ;
+loop :
+       knt++ ;
+       i = val/10  ;  /*  quotient & base 10 */
+       (*tp++) = val%10 + '0' ; /*  ascii remainder  */
+       val = i ;
+       if (val == 0) {
+               /*  done  dividing  */
+               if (sign) { knt++ ; (*tp++) = '-' ; }
+               for (i = knt ; i ; i--)
+                       (*rptr++) = tmp[i-1] ;
+               (*rptr++) = '\0' ;
+               return(knt) ;
+               }
+       else goto loop ;
+}
+/*             */
+echo(lngword)
+register int lngword ;
+{
+char tmp[30] ;
+l2a(lngword,tmp) ;
+putlin(tmp) ;
+}
diff --git a/usr/src/standalone/dadmes.c b/usr/src/standalone/dadmes.c
new file mode 100644 (file)
index 0000000..45ce74c
--- /dev/null
@@ -0,0 +1,19 @@
+# include "RP.h"
+dadmes(dptr)
+register int *dptr ;
+{
+register char *mesp ;
+register int i ;
+mesp = " cyl     trk     sec    " ;
+i = l2x(*(dptr+RP_cyl) & 01777,&mesp[5]) ;
+blnkit(&mesp[5+i],4-i) ;
+i = l2x((*(dptr+RP_stk)>>8) & 037 , &mesp[13]) ;
+blnkit(&mesp[13+i],3-i) ;
+i = l2x(*(dptr+RP_stk)&037,&mesp[21]) ;
+blnkit(&mesp[21+i],3-i) ;
+putlin(mesp) ;
+}
diff --git a/usr/src/standalone/ddump.c b/usr/src/standalone/ddump.c
new file mode 100644 (file)
index 0000000..5651218
--- /dev/null
@@ -0,0 +1,495 @@
+# define RP6CYL  815  /*  no. RP06 cylinders/pack */
+# define RP6TRK  19  /*  no. tracks/cyl  */
+# define RP6SEC  22  /*  no. sectors/track  */
+# define RP6ST  (RP6SEC*RP6TRK)  /*  no. sectors/cyl  */
+# define MAXSEC  (RP6CYL*RP6TRK*RP6SEC)  /*  sectors/pack  */
+# define M0  0x20010000  /* phys addr MBA 0  */
+# define M0_cr  (M0+4)  /*  MBA 0 control reg addr */
+# define M0_sr (M0+8)  /* mba 0 status reg */
+# define M0_map  (M0+0x800)  /* start MBA 0 map reg's */
+# define M0_var  (M0+0xc)  /* MBA 0 virt addr reg */
+# define M0_bc  (M0+0x10)  /*  MBA 0 byte count reg */
+# define MBAinit 01  /*  MBA init bit */
+/*             */
+# define RP  (M0+0x400)  /*  base for RP06 reg's, drive 0  */
+/*             */
+# define RP_cr  0  /* RP06 control reg offset, longword */
+# define RP_sr  1  /*  RP06 status reg offset */
+# define RP_er1  02  /*  RP error reg 1 */
+# define RP_stk  5  /*  RP06 sector/track reg offset */
+# define RP_er2 010  /* RP error reg 2 */
+# define RP_off  011  /*  RP offset reg */
+# define RP_cyl  012  /*  RP06 cylinder reg offset */
+# define RP_er3 015  /*  RP error reg 3 */
+/*             */
+# define RP_GO  1  /*  go bit */
+# define RP_RED  070  /*  RP06 read function code */
+# define RP_DC  010  /*  drive clear function code */
+# define RP_FMT  0x1000  /*  format bit for offset reg */
+# define RP_RIP 020  /*  Read-in Preset RP06 function code */
+# define RP_DRY  0200  /*  drive ready, status reg */
+# define RP_ERR 040000  /* composite error, status reg */
+# define RP_MOL 0x1000  /*  medium-online bit in status reg */
+/*             */
+# define RXCS  32  /*  receiver control/staus */
+# define RXDB  33  /*  receiver data */
+# define TXCS  34  /*  transmitter control/status */
+# define TXDB  35  /*  transmitter data */
+# define RXCS_DONE  0x80  /*  receiver done */
+# define TXCS_RDY  0x80  /*  transmitter ready */
+/*             */
+# define BLKSIZ 512
+# define MAXUNI  1
+# define NL  012
+# define CR 015
+/*             */
+char input[BLKSIZ]  ;  /*  disc input buffer */
+struct { int reg , reg2 , reg3 ; } ;
+int count , dskoff , dunit , error , numbyt ;
+unsigned short bytoff ;
+int *RPptr ; /* ptr to start of RP reg's for desired drive */
+main() {
+/*
+*  Stand-alone program to dump RP06 disk to VAX LSI console
+*  printer in hex format.
+*  User specifies disk unit, start disk block and no. of blocks.
+*/
+int getcon() , putstr() , a2l() , l2a() ;
+
+putlin("ddump : disk-to-console hex dump") ;
+putnl() ;
+dun :
+putstr("disk unit : ");
+getcon(input) ;
+dunit = a2l(input) ;
+if ((dunit > MAXUNI) || (dunit < 0)) goto dun ;
+doff :
+putstr("start disk block : ") ;
+if (getcon(input)) goto fini ;
+dskoff = a2l(input) ;
+if (dskoff < 0) goto fini ;
+if (dskoff > MAXSEC-1) goto doff ;
+gknt :
+putstr("no. blocks : ") ;
+if (getcon(input)) goto fini ;
+count = a2l(input) ;
+if (count < 0) goto gknt ;
+if (count == 0) count = 1 ;
+gbyt :
+putstr("no. bytes : ") ;
+if (getcon(input)) goto fini ;
+numbyt = a2l(input) ;
+if ((numbyt < 0) || (numbyt > BLKSIZ)) goto gbyt ;
+if (numbyt == 0) numbyt = BLKSIZ ;
+error = 0 ;
+if (init()) goto dun ;
+putlin("                      HI  < - -  LO") ;
+nullcon(3) ;
+putnl() ;
+while ((error == 0) && (count--)) {
+       if (dread()) {
+                       putlin("disk i/o error") ;
+                       ioerr :
+                               error++ ;
+                               continue ;
+                       }
+       if (prblk()) {
+               putlin("console i/o error") ;
+               goto ioerr ;
+               }
+       putnl() ;
+       putnl() ;
+       dskoff++ ; /* next sector */
+}
+goto doff ;
+fini :
+return(0) ;
+}
+/*             */
+putstr(csp)
+register char *csp ;
+{
+if (putcon(csp)) return(-1) ;
+return(0) ;
+}
+/*             */
+putlin(sptr)
+register char *sptr ;
+{
+if (putcon(sptr)) return(-1) ;
+if (putnl()) return(-1) ;
+return(0) ;
+}
+/*             */
+nullcon(nn)
+register nn ;
+{
+/*
+*  Output 'nn' nulls to console terminal -
+*  used for delay.
+*/
+while (nn--) putc(0) ;
+}
+/*             */
+putnl()
+{
+if (putcon("\r\n")) return(-1) ;
+return(0) ;
+}
+/*             */
+putcon(csp)
+register char *csp ;
+{
+/*
+*  Function to output null-terminated string pointed to 
+*  by 'csp' to the VAX LSI terminal.
+*/
+register c ;
+c = 0 ;
+while (c = (*csp++)) putc(c) ;
+return(0) ;
+}
+/*             */
+putc(c)
+{
+/*  wait for LSI printer to be ready */
+while ((mfpr(TXCS) & TXCS_RDY) == 0) ;
+/*  output character */
+mtpr(TXDB,c&0177) ;
+}
+/*             */
+getcon(cs)
+register char *cs ;
+{
+/*
+*  Function to return char's from VAX LSI keyboard to
+*  char array 'cs' - input stops when CR or LF received -
+*  null char appended to end of input
+*/
+register int c , c2 ;
+int getc() ;
+inloop :
+       c = getc() ; /* get 1 char from terminal */
+       putc(c) ;  /*  echo char */
+       if ((c == NL) || (c == CR)) {
+               putc(CR) ;
+               putc(0) ;
+               putc(NL) ;
+               (*cs++) = '\0' ;
+               return(0) ;
+               }
+       else {
+               (*cs++) = c ;
+               goto inloop ;
+               }
+}
+/*             */
+getc()
+{
+/*
+*  Return char from VAX LSI terminal char buffer
+*/
+int mfpr() ;
+/*  Wait for receiver done (user entered char)
+*/
+while ((mfpr(RXCS) & RXCS_DONE) == 0) ;
+return (mfpr(RXDB) & 0177) ;  /* return char from receiver buffer */
+}
+/*             */
+mtpr(regno,value)
+{
+       asm("   mtpr    8(ap),4(ap)") ;
+}
+/*             */
+mfpr(regno)
+{
+       asm("   mfpr    4(ap),r0") ;
+}
+/*             */
+a2l(as)
+register char *as ;
+{
+/*
+*  Convert null-terminated ascii string to binary
+*  and return value.
+*  1st char in string :
+*      0 -> octal
+*      x -> hex
+*      else decimal
+*/
+register value , base , sign , digit ;
+digit = value = sign = 0 ;
+base = 10 ;  /* default base */
+aloop :
+if ((digit = (*as++)) == 0) return(value) ; /* null */
+if (digit == '-') {
+       sign++ ;
+       goto aloop ;
+       }
+if (digit == '0') base = 8 ;  /* octal base  */
+else { if (digit == 'x') base = 16 ;  /* hex base */
+       else value = (digit-060) ; /* 060 = '0' */
+       }
+while (digit = (*as++)) {
+       if (digit < '0') return(0) ;
+       switch (base) {
+               case 8 : {
+                       if (digit > '7') return(0) ;
+                       digit -= 060 ;
+                       break ;
+                       }
+               case 10 : {
+                       if (digit > '9') return(0) ;
+                       digit -= 060 ;
+                       break ;
+                       }
+               case 16 : {
+                       if (digit <= '9') {
+                               digit -= 060 ;
+                               break ;
+                               }
+                       if ((digit >= 'A') && (digit <= 'F')) {
+                               digit = (digit - 0101 + 10) ;
+                                       break ;
+                               }
+                       if ((digit >= 'a') && (digit <= 'f')) {
+                               digit = digit - 0141 + 10 ;
+                               break ;
+                               }
+                       return(0) ;
+                       break ;
+                       }
+               }
+       value = (value * base) + digit ;
+       }
+return (sign ? -value : value) ;
+}
+/*             */
+init() {
+/*
+*  Initialization.
+*  Initialize MBA 0 (disk) .
+*  Set up MBA 0  map register to map a 
+*    transfer of 'BLKSIZ' bytes.
+*/
+register int page , *mp0 ;
+M0_cr->reg = MBAinit ; /* MBA 0 init */
+RPptr = RP + (dunit * 32 * 4) ; /* start of RP reg's for drive */
+if ((*(RPptr+RP_sr) & RP_MOL) == 0) {
+       putlin("unit not online") ;
+       return(-1) ;
+       }
+*(RPptr+RP_cr) = RP_RIP | RP_GO ; /* drive preset - sets vv */
+*(RPptr+RP_off) = RP_FMT ; /* set format bit */
+bytoff = (int)(&input[0])&0777 ; /* byte offset of buffer addr */
+page = ((int)&input[0] >> 9) & 07777777 ; /* start page of buffer */
+mp0 = M0_map ;
+(*mp0++) = 0x80000000 | page++ ;
+(*mp0++) = 0x80000000 | page++ ;
+(*mp0++) = 0 ;
+return(0) ;
+}
+/*             */
+dread()
+{
+/*
+*  Function to read 'BLKSIZ' bytes to buffer 'input[]'.
+*/
+register int i , j ;
+*(RPptr+RP_cr) = RP_DC | RP_GO ; /*  RP06 drive clear function code */
+*(RPptr+RP_cyl) = dskoff/RP6ST ; /* cylinder no. */
+i = dskoff%RP6ST ;
+j = (i/RP6SEC)<<8 ; /* track */
+*(RPptr+RP_stk) = j | (i%RP6SEC) ; /* sector : track */
+M0_bc->reg = (-BLKSIZ) ;
+M0_var->reg = bytoff ; /* virt addr reg = map no. + byte off */
+*(RPptr+RP_cr) = RP_RED | RP_GO ; /* read */
+dwait() ; /* wait for i/o to finish */
+if (derror()) return(-1) ; /* error */
+return(0) ; /* normal return */
+}
+/*             */
+dwait() {
+/*
+* Function to wait MBA 0 RP06 disc unit to be ready.
+*/
+while ((*(RPptr+RP_sr)&RP_DRY) == 0) ;
+}
+/*             */
+derror()
+{
+/*
+*  Function to check for MBA 0 RP06 error.
+*/
+if (*(RPptr+RP_sr) & RP_ERR) return(-1) ;
+return(0) ;
+}
+/*             */
+halt()
+{
+asm("  halt") ;
+}
+/*             */
+l2a(val,rptr)
+register int val ;
+register char *rptr ;
+{
+register int i ;
+register char *tp ;
+int knt ;
+char tmp[20] , sign ;
+knt = sign = 0 ;
+if (val < 0) {
+       sign++ ;
+       val = (-val) ;
+       }
+tp = tmp ;
+loop :
+       knt++ ;
+       i = val/10  ;  /*  quotient & base 10 */
+       (*tp++) = val%10 + '0' ; /*  ascii remainder  */
+       val = i ;
+       if (val == 0) {
+               /*  done  dividing  */
+               if (sign) { knt++ ; (*tp++) = '-' ; }
+               for (i = knt ; i ; i--)
+                       (*rptr++) = tmp[i-1] ;
+               (*rptr++) = '\0' ;
+               return(knt) ;
+               }
+       else goto loop ;
+}
+/*             */
+echo(lngword)
+register int lngword ;
+{
+char tmp[30] ;
+l2a(lngword,tmp) ;
+putlin(tmp) ;
+}
+/*             */
+prblk()
+{
+/*
+*  Print 512 bytes on VAX LSI console as hex
+*  characters.
+*  Translate bytes in 'input[]' to hex char's
+*  and out to console, 64 char's per line.
+*/
+register int i , j ;
+int k ;
+char c , *hp , *fr ;
+char tmp[1025] , ltmp[65] ;
+ltmp[64] = '\0' ;
+hp = "block # \0\0\0\0\0\0\0" ;
+l2a(dskoff,&hp[8]) ;
+putstr(hp) ;
+putnl() ;
+putnl() ;
+hxcnvt(input,512,tmp) ; /* convert bytes to hex char's */
+j = numbyt ;
+for (i = 0 ; (i < 1024) && (j > 0) ; i=+64 ) {
+       hp = ltmp ;
+       fr = (&tmp[i+63]) ;
+       for ( k = 32 ; k ; k--) {
+               (*hp++) = *(fr-1) ;
+               (*hp++) = (*fr--) ;
+               fr-- ;
+               }
+       putstr(ltmp) ;
+       putc(CR) ;
+       nullcon(5) ;
+       putc(NL) ;
+       j -= 32 ;
+       }
+return(0) ;
+}
+/*             */
+hxcnvt(in,knt,out)
+register char *in , *out ;
+int knt ;
+{
+/*
+*  Convert 'knt' bytes in char array 'in' to 'knt*2'
+*  hex char's and store in char array 'out'.
+*/
+register unsigned int bit4 , byte ;
+byte = 0 ;
+while (knt--) {
+       byte = (*in++) ;
+       bit4 = (byte>>4) & 017 ;
+       (*out++) = (bit4<10?bit4+0x30:bit4+0x57) ;
+       bit4 = byte & 017 ;
+       (*out++) = (bit4<10?bit4+0x30:bit4+0x57) ;
+       }
+return(0) ;
+}
diff --git a/usr/src/standalone/fboot.c b/usr/src/standalone/fboot.c
new file mode 100644 (file)
index 0000000..aa15934
--- /dev/null
@@ -0,0 +1,878 @@
+# include "rel.h"
+# define RP6CYL  815  /*  no. RP06 cylinders/pack */
+# define RP6TRK  19  /*  no. tracks/cyl  */
+# define RP6SEC  22  /*  no. sectors/track  */
+# define RM3CYL 823  /*  RM03  */
+#define RM3TRK 5
+#define RM3SEC 32
+# define RP6ST  (rptrk*rpsec)
+# define MAXSEC  (rpcyl*rptrk*rpsec)  /*  sectors/pack  */
+# define M0  0x20010000  /* phys addr MBA 0  */
+# define M1  0x20012000  /*  phys addr MBA 1  */
+# define M_cr  1  /*  MBA 0 control reg addr , longword offset */
+# define M_sr 2  /* MBA 0 status reg offset */
+# define M_map  0x200  /* start MBA 0 map reg's longword offset */
+# define M_var  3  /* MBA 0 virt addr reg offset */
+# define M_bc  4  /*  MBA 0 byte count reg offset */
+# define MBAinit 01  /*  MBA init bit */
+/*             */
+# define EXTREG  0x400  /*  base for external reg's on MBA  */
+/*             */
+# define RP_cr  0  /* RP06 control reg offset, longword */
+# define RP_sr  1  /*  RP06 status reg offset */
+# define RP_stk  5  /*  RP06 sector/track reg offset */
+# define RP_typ 06  /* drive type reg */
+# define RP_off  011  /*  RP offset reg */
+# define RP_cyl  10  /*  RP06 cylinder reg offset */
+/*             */
+# define RP_GO  1  /*  go bit */
+# define RP_RED  070  /*  RP06 read function code */
+# define RP_DC  010  /*  drive clear function code */
+# define RP_DRY  0200  /*  drive ready, status reg */
+# define RP_ERR 040000  /* composite error, status reg */
+# define RP_RIP 020  /* RP readin preset function code */
+# define RP_FMT  0x1000  /* format bit in RP offset reg */
+# define RP_MOL  0x1000  /* medium on-line bit in RP status reg */
+/*             */
+# define RXCS  32  /*  receiver control/staus */
+# define RXDB  33  /*  receiver data */
+# define TXCS  34  /*  transmitter control/status */
+# define TXDB  35  /*  transmitter data */
+# define RXCS_DONE  0x80  /*  receiver done */
+# define TXCS_RDY  0x80  /*  transmitter ready */
+/*             */
+# define MAG410 0410
+# define MAG411 0411
+# define MAXUNI  1
+# define NL  012
+# define CR 015
+# define CDEL 0x23
+# define LDEL 0x40
+# define BLKSIZ 512
+# define HDRSIZ 040  /*  task header size  */
+# define INOSIZ  64  /*  no. bytes per inode entry */
+# define INOBLK  (BLKSIZ/INOSIZ)  /*  no. inodes/disk block */
+# define NAMSIZ 14  /*  no. char's in dir name field */
+# define DIRSIZ  16  /*  no. bytes/directory entry */
+# define SLASH  057  /* '/'  */
+# define NADDR  13  /* no. addr blocks in inode entry */
+# define KSP 0
+/*             */
+# define IFMT 0170000
+# define IFDIR 040000
+# define IFREG 0100000
+# define ROOTINO  2  /*  root dir inode no. */
+
+/*             */
+#define RP6typ  022  /*  RP06 */
+#define RM3typ  024  /*  RM03 type */
+struct dirent { short ino ; char dname[NAMSIZ] ; } ;
+struct inod {
+       short i_mode ;
+       short fill1[3] ;
+       int i_size ;
+       char i_addr[40] ;
+       int fill2[3] ;
+       } ;
+struct thdr {
+       int hmagic ;
+       int htsiz ;
+       int hdsiz ;
+       int hbsiz ;
+       int hsmsiz ;
+       int hentry ;
+       int hrelb ;
+       int hrflg ;
+       } ;
+int filsiz ;
+char *entry ;
+char buf[BLKSIZ] , *namep ;
+char dbuf[BLKSIZ] ;
+short mode ;
+int addr[NADDR] ;
+int *mbap ; /* MBA ptr */
+int *RPptr ; /* RP06 ptr */
+int rpsec,rpcyl,rptrk; /* get set up in 'init' for RP06 or RM03 */
+char *bufloc;
+int dtmp1[128] , dtmp2[128] , dtmp3[128] ;
+/*
+*  This program, '/fboot', is always read in by code in the RP
+*  boot block (block 0). It boots in the file specified by the
+*  user.
+*/
+main()
+{
+/* set stack ptr and move code up to high end of core */
+reloc() ;
+/* jump to re-located code */
+asm("  .text") ;
+asm("  .globl  _main1") ;
+asm("  jmp     *$(_main1+2)") ;
+asm("  .align  2") ;
+}
+/*             */
+main1()
+{
+char ntmp[10*NAMSIZ] ;
+register int inum ;
+register struct inod *inp ;
+struct inod *getiblk() ;
+struct dirent *dsearch() , *pde ;
+int j ;
+floop :
+putnl() ;
+putstr("file : ") ;
+getcon(ntmp) ; /* null-terminated filename */
+putnl() ;
+namep = ntmp ;
+inum = ROOTINO ; /* root dir inode no. */
+while ((*namep) == SLASH) namep++ ;
+if ((*namep) == '\0') goto floop ;
+mbap = M0 ;
+RPptr = M0 + EXTREG ;
+if (init()) {
+       putlin("init error") ;
+       return(-1) ;
+       }
+giblk :
+/* get disk block that has inode entry for inode no. 'inum' */
+inp = getiblk(inum) ; /* 'cp' = ptr. to inode entry in 'buf[]' */
+if (inp == (-1)) {
+       ioerr :
+               putlin("disk i/o error") ;
+               goto floop ;
+       }
+/* Get 'mode' and 'addr[]' entries for selected inode & save off */
+iexpand(inp) ;
+/*  inode mode is in 'mode'.
+*   block no.'s are in 'addr[]'.
+*   If inode is a directory, search all its blocks for pathname
+*    component pointed to by 'namep'.
+*   If inode is regular file, load blocks of file into core
+*    for execution.
+*/
+if ((j = mode&IFMT) == IFDIR) { /* Directory */
+       if (*namep == '\0') goto floop ; /* no more pathname */
+       pde = dsearch() ; /* search all directory blocks */
+       if (pde == (-1)) goto ioerr ; /* i/o error */
+       if (pde == 0) goto floop ; /* pathname component not found */
+       /* Found pathname component (directory or file) - go get
+         its inode and continue search.
+       */
+       inum = pde->ino ;
+       goto giblk ;
+       }
+else {
+       if (j == IFREG) { /* regular file */
+               if (*namep != '\0') goto floop ; /* should have been
+                       last component in pathname */
+               if (lodfil()) goto floop ; /* load file whose
+                 inode 'addr' blocks are in 'addr[]' */
+/*
+*  Code to check for task header, move code down to 0,
+*  get task entry address, clear core, etc.
+*/
+               fexec() ;
+               goto floop ; /* returned from execution - go to loop */
+               }
+       }
+goto floop ; /* wasn't directory or file */
+}
+/*             */
+struct inod *getiblk(in)
+register int in ;
+{
+/*
+*  Read in disk inode block which contains inode
+*  no. 'in' - return ptr. to start of inode entry.
+*/
+register i ;
+i = (in + (INOBLK*2) - 1)/INOBLK ;
+if (dread(i,buf)) /*  read block 'i' into 'buf[]' */
+       return(-1) ; /* i/o error */
+return((int)buf + (((in-1) & (INOBLK-1))*INOSIZ)) ;
+}
+/*             */
+iexpand(ip)
+register struct inod *ip ;
+{
+/*
+*  Get mode, file size and block no.'s from disk inode and store
+*  away.
+*  'ip' = ptr. to inode entry.
+*/
+register int i ;
+register char *f , *t ;
+mode = ip->i_mode ;
+filsiz = ip->i_size ;
+f = (&ip->i_addr[0]) ;
+t = (&addr[0]) ;
+for (i = NADDR ; i ; i--) {
+       (*t++) = (*f++) ;
+       (*t++) = (*f++) ;
+       (*t++) = (*f++) ;
+       (*t++) = '\0' ;
+       }
+return(0) ;
+}
+/*             */
+struct dirent *dsearch()
+{
+/*
+*  Search blocks of directory inode 'inum', whose block
+*  no.'s are in 'addr[]', for pathname component pointed
+*  to by 'namep'.
+*  Return (-1) for error.
+*  Return (0)  for no match.
+*  Return ptr. to directory entry for match.
+*/
+register char c ;
+register struct dirent *cp ;
+register int i , j ;
+struct dirent *pfind() ;
+/*  direct  */
+cp = pfind(addr,NADDR-3) ; /* search 'NADDR-3' blocks(in 'naddr[]') */
+if (cp == (-1)) return(-1) ; /* i/o error */
+if (cp == 0) return(0) ;  /* zero block encountered - no more blocks */
+if (cp == 1) goto level1 ; /* more blocks to search */
+/* 'cp' must be ptr. to matched directory */
+found :
+       /*  point to next pathname component */
+while (((c = (*namep)) != '/') && (c !='\0')) namep++ ;
+if (c == '/') while (*namep == '/') namep++ ;
+return(cp) ;
+/*
+*/
+level1 : /*  1st level indirection */
+if ((j = addr[NADDR-3]) == 0) return(0) ;
+if (dread(j,dtmp1)) return(-1) ; /* i/o error */
+cp = pfind(dtmp1,128) ;
+if (cp == (-1)) return(-1) ;
+if (cp == 0) return(0) ;
+if (cp == 1) goto level2 ;
+goto found ;
+level2 :
+if ((j = addr[NADDR-2]) == 0) return(0) ;
+if (dread(j,dtmp1)) return(-1) ;
+for (i = 0 ; i < 128 ; i++) {
+       if (dtmp1[i] == 0) return(0) ;
+       if (dread(dtmp1[i],dtmp2)) return(-1) ;
+       cp = pfind(dtmp2,128) ;
+       if (cp == (-1)) return(-1) ;
+       if (cp == 0) return(0) ;
+       if (cp == 1) continue ;
+       goto found ;
+       }
+level3 :
+if ((j = addr[NADDR-1]) == 0) return(0) ;
+if (dread(j,dtmp1)) return(-1) ;
+for (i = 0 ; i < 128 ; i++) {
+       if (dread(dtmp1[i],dtmp2)) return(-1) ;
+       for (j = 0 ; j < 128 ; j++) {
+               if (dread(dtmp2[i],dtmp3)) return(-1) ;
+               cp = pfind(dtmp3,128) ;
+               if (cp == (-1)) return(-1) ;
+               if (cp == 0) return(0) ;
+               if (cp == 1) continue ;
+               goto found ;
+               }
+       }
+return(0) ;
+}
+/*             */
+struct dirent *pfind(ia,knt)
+int ia[] ;
+register int knt ;
+{
+/*
+*  'ia' :  array of integer block no.'s.
+*  'knt' :  no. entries in 'ia'
+*  A zero block in 'ia[]' -> no match -> return(0) .
+*  Return (-1) on i/o error.
+*  Return (1) if no zero blocks and all blocks searched but
+*    no match.
+*  Return ptr. to directory entry for match.
+*/
+register int *bp , bn ;
+register struct dirent *ix ;
+bp = ia ;
+while (knt--) {
+       if ((bn = (*bp++)) == 0) return(0) ;
+       if (dread(bn,dbuf)) return(-1) ;
+       for (ix = dbuf ; ix < &dbuf[BLKSIZ] ; ix++) {
+               if (dnmatch(ix->dname,namep)) return(ix) ;
+               }
+       }
+return(1) ;
+}
+/*             */
+dnmatch(p1,p2)
+register char *p1 , *p2 ;
+{
+/*
+*  'p1' : ptr. to directory filename field
+*  'p2' : ptr. to null-terminated file pathname
+*  Return(1) if match,
+*   else, return(0).
+*/
+register int i ;
+register char c1 , c2 ;
+for (i = NAMSIZ ; i ; i--) {
+       c1 = (*p1++) ;
+       c2 = (*p2++) ;
+       if (((c1 == '\0') && (c2 == '\0')) || (c2 == SLASH)) return(1) ;
+       if (c1 != c2) return(0) ;
+       }
+if ((c2 == '\0') || (c2 == SLASH)) return(1) ;
+return(0) ;
+}
+/*             */
+dread(dbn,cbuf)
+char *cbuf ;
+{
+/*
+*  Read physical block no. 'dbn' from disk and
+*    load into array 'cbuf[]'.
+*  Return (-1) for i/o error.
+*  Else return (0).
+*/
+register int i , j ;
+*(RPptr+RP_cr) = RP_DC | RP_GO ; /*  RP06 drive clear function code */
+*(RPptr+RP_cyl) = dbn/RP6ST ; /* cylinder no. */
+i = dbn%RP6ST ;
+j = (i/rpsec)<<8 ; /* track */
+*(RPptr+RP_stk) = j | (i%rpsec) ; /* sector : track */
+*(mbap+M_bc) = (-BLKSIZ) ;
+i = (int)cbuf&0777;
+*(mbap+M_var) = i ;
+*(mbap+M_map) = (i = 0x80000000 | ((int)((int)cbuf>>9)&07777777)) ;
+*(mbap+M_map+1) = (++i) ;
+*(RPptr+RP_cr) = RP_RED | RP_GO ; /* read */
+dwait() ; /* wait for i/o to finish */
+if (derror()) { /* error */
+       putlin("fboot : disk read error");
+       return(-1);
+       }
+return(0) ; /* normal return */
+}
+/*             */
+dwait() {
+/*
+* Function to wait MBA 0 RP06 disc unit to be ready.
+*/
+while ((*(RPptr+RP_sr)&RP_DRY) == 0) ;
+}
+/*             */
+derror()
+{
+/*
+*  Function to check for MBA 0 RP06 error.
+*/
+if (*(RPptr+RP_sr) & RP_ERR) return(-1) ;
+return(0) ;
+}
+/*             */
+init()
+{
+/*
+*  Initialization.
+*/
+register int i;
+*(mbap+M_cr) = MBAinit ; /* MBA initialize */
+if ((*(RPptr+RP_sr) & RP_MOL) == 0 ){
+       putlin("unit not online") ;
+       return(-1) ;
+       }
+*(RPptr+RP_cr) = RP_RIP | RP_GO ; /* readin preset */
+*(RPptr+RP_off) = RP_FMT ; /* format bit in offset reg */
+bufloc = 0 ;
+i = *(RPptr+RP_typ)&0777 ;  /* get disk type */
+if (i==RP6typ) { /* RP06 */
+       rpsec=RP6SEC; rpcyl=RP6CYL; rptrk=RP6TRK;
+       }
+else {
+       if (i==RM3typ) {
+               rpsec=RM3SEC; rpcyl=RM3CYL; rptrk=RM3TRK;
+               }
+       else return(-1);
+       }
+return(0) ;
+}
+/*             */
+lodfil()
+{
+/*
+*  Function to load a file into low core - disk blocks no.'s
+*  which comprise file are in 'addr[]'.
+*  Return (-1) if i/o error,
+*  else return (0).
+*/
+register int i , j , k , n ;
+int dtmp1[128] , dtmp2[128] ;
+/*  direct  */
+for (i = 0 ; i < NADDR-3 ; i++) {
+       if ((j = addr[i]) == 0) return(0) ;
+       if (dread(j,bufloc)) return(-1) ;
+       bufloc += BLKSIZ ;
+       }
+level1 : /*  1st level indirection */
+if ((j = addr[NADDR-3]) == 0) return(0) ;
+/*  read in <=128 blocks into low core */
+if ((k = r128(j)) < 0) return(-1) ; /* i/o error */
+if (k > 0) return(0) ; /* no more blocks */
+level2 :
+if ((j = addr[NADDR-2]) == 0) return(0) ;
+if (dread(j,dtmp1)) return(-1) ;
+for (i = 0 ; i < 128 ; i++) {
+       if ((j = dtmp1[i]) == 0) return(0) ;
+       if ((k = r128(j)) < 0) return(-1) ;
+       if (k > 0) return(0) ;
+       }
+level3 :
+if ((j = addr[NADDR-1]) == 0) return(0) ;
+if (dread(j,dtmp1)) return(-1) ;
+for (i = 0 ; i < 128 ; i++) {
+       if ((k = dtmp1[i]) == 0) return(0) ;
+       if (dread(k,dtmp2)) return(-1) ;
+       for (j = 0 ; j < 128 ; j++) {
+               if ((k = dtmp2[j]) == 0) return(0) ;
+               if ((n = r128(k)) < 0) return(-1) ;
+               if (n > 0) return(0) ;
+               }
+       }
+return(0) ;
+}
+/*             */
+r128(blk)
+int blk ;
+{
+/*
+*  Read in disk block no. 'blk' into buffer.
+*  Then read in the 128 disk blocks whose block no.'s are
+*  in the buffer into low core.
+*  Stop on a zero block no. - return(1).
+*  Return(-1) on i/o error.
+*  Return(0) if all 128 blocks read.
+*/
+int btmp[128] ;
+register int i , j ;
+if (dread(blk,btmp)) return(-1) ;
+for (i = 0 ; i < 128 ; i++) {
+       if ((j = btmp[i]) == 0) return(1) ; /* no more blocks */
+       if (dread(j,bufloc)) return(-1) ; /* i/o error */
+       bufloc += BLKSIZ ; /* next core block loc */
+       }
+return(0) ;
+}
+/*             */
+halt() {
+       asm("   halt") ;
+}
+/*             */
+putstr(csp)
+register char *csp ;
+{
+if (putcon(csp)) return(-1) ;
+return(0) ;
+}
+/*             */
+putlin(sptr)
+register char *sptr ;
+{
+if (putcon(sptr)) return(-1) ;
+if (putnl()) return(-1) ;
+return(0) ;
+}
+/*             */
+nullcon(nn)
+register nn ;
+{
+/*
+*  Output 'nn' nulls to console terminal -
+*  used for delay.
+*/
+while (nn--) putc(0) ;
+}
+/*             */
+putnl()
+{
+if (putcon("\r\n")) return(-1) ;
+return(0) ;
+}
+/*             */
+putcon(csp)
+register char *csp ;
+{
+/*
+*  Function to output null-terminated string pointed to 
+*  by 'csp' to the VAX LSI terminal.
+*/
+register c ;
+c = 0 ;
+while (c = (*csp++)) putc(c) ;
+return(0) ;
+}
+/*             */
+putc(c)
+{
+/*  wait for LSI printer to be ready */
+while ((mfpr(TXCS) & TXCS_RDY) == 0) ;
+/*  output character */
+mtpr(TXDB,c&0177) ;
+}
+/*             */
+getcon(cs)
+register char *cs ;
+{
+/*
+*  Function to return char's from VAX LSI keyboard to
+*  char array 'cs' - input stops when CR or LF received -
+*  null char appended to end of input
+*/
+register int c , c2 ;
+int getc() ;
+char *ocs;
+       ocs=cs;
+inloop :
+       c = getc() ; /* get 1 char from terminal */
+       putc(c) ;  /*  echo char */
+       if (c==CDEL) {cs--; goto inloop;}
+       if (c==LDEL) {putc(CR);putc(0);putc(NL);cs=ocs; goto inloop;}
+       if ((c == NL) || (c == CR)) {
+               putc(CR) ;
+               putc(0);
+               putc(NL) ;
+               (*cs++) = '\0' ;
+               return(0) ;
+               }
+       else {
+               (*cs++) = c ;
+               goto inloop ;
+               }
+}
+/*             */
+getc()
+{
+/*
+*  Return char from VAX LSI terminal char buffer
+*/
+int mfpr() ;
+/*  Wait for receiver done (user entered char)
+*/
+while ((mfpr(RXCS) & RXCS_DONE) == 0) ;
+return (mfpr(RXDB) & 0177) ;  /* return char from receiver buffer */
+}
+/*             */
+mtpr(regno,value)
+{
+       asm("   mtpr    8(ap),4(ap)") ;
+}
+/*             */
+mfpr(regno)
+{
+       asm("   mfpr    4(ap),r0") ;
+}
+/*             */
+a2l(as)
+register char *as ;
+{
+/*
+*  Convert null-terminated ascii string to binary
+*  and return value.
+*  1st char in string :
+*      0 -> octal
+*      x -> hex
+*      else decimal
+*/
+register value , base , sign , digit ;
+digit = value = sign = 0 ;
+base = 10 ;  /* default base */
+aloop :
+if ((digit = (*as++)) == 0) return(value) ; /* null */
+if (digit == '-') {
+       sign++ ;
+       goto aloop ;
+       }
+if (digit == '0') base = 8 ;  /* octal base  */
+else { if (digit == 'x') base = 16 ;  /* hex base */
+       else value = (digit-060) ; /* 060 = '0' */
+       }
+while (digit = (*as++)) {
+       if (digit < '0') return(0) ;
+       switch (base) {
+               case 8 : {
+                       if (digit > '7') return(0) ;
+                       digit -= 060 ;
+                       break ;
+                       }
+               case 10 : {
+                       if (digit > '9') return(0) ;
+                       digit -= 060 ;
+                       break ;
+                       }
+               case 16 : {
+                       if (digit <= '9') {
+                               digit -= 060 ;
+                               break ;
+                               }
+                       if ((digit >= 'A') && (digit <= 'F')) {
+                               digit = (digit - 0101 + 10) ;
+                                       break ;
+                               }
+                       if ((digit >= 'a') && (digit <= 'f')) {
+                               digit = digit - 0141 + 10 ;
+                               break ;
+                               }
+                       return(0) ;
+                       break ;
+                       }
+               }
+       value = (value * base) + digit ;
+       }
+return (sign ? -value : value) ;
+}
+/*             */
+l2a(val,rptr)
+register int val ;
+register char *rptr ;
+{
+register int i ;
+register char *tp ;
+int knt ;
+char tmp[20] , sign ;
+knt = sign = 0 ;
+if (val < 0) {
+       sign++ ;
+       val = (-val) ;
+       }
+tp = tmp ;
+loop :
+       knt++ ;
+       i = val/10  ;  /*  quotient & base 10 */
+       (*tp++) = val%10 + '0' ; /*  ascii remainder  */
+       val = i ;
+       if (val == 0) {
+               /*  done  dividing  */
+               if (sign) { knt++ ; (*tp++) = '-' ; }
+               for (i = knt ; i ; i--)
+                       (*rptr++) = tmp[i-1] ;
+               (*rptr++) = '\0' ;
+               return(knt) ;
+               }
+       else goto loop ;
+}
+/*             */
+fexec()
+{
+/*
+*  Part of stand-alone programs that load programs into low core
+*  and execute them.
+*  This function :
+*      1) Checks if user specified file has a header - if so,
+*         move start of exec. file down to 0. If file is 0410,
+*         move data up to page boundary.
+*      2) Clear core.
+*      3) Jump to user task (calls).
+*/
+register struct thdr *hdp ;
+register char *corep1 , * corep2 ;
+register int k ;
+int i , stxt , sdat , sbss , clrmin ;
+register char *clrmax ;
+hdp = 0 ;
+clrmax = RELOC - 0x400 ; /* last addr+1 to clear */
+i = hdp->hmagic ; /* task type code from task header */
+entry = 0 ; /* default entry addr if no header */
+clrmin = filsiz ;
+if ((i != MAG410) && (i != MAG411)) goto clrcor ; /* NO HEADER */
+/* file has task header */
+entry = hdp->hentry & 017777777777 ;
+stxt = hdp->htsiz ; /* no. of text bytes in file */
+sdat = hdp->hdsiz ; /* no. data bytes */
+sbss = hdp->hbsiz ; /* no. bytes in bss area */
+filsiz = stxt + sdat ; /* file size = text + data */
+clrmax = filsiz + sbss ; /* new upper limit to clear */
+/*  move file down to loc 0 */
+corep1 = 0 ;
+corep2 = sizeof(struct thdr) ;
+for (k = filsiz ; k ; k--)
+       (*corep1++) = (*corep2++) ;
+clrmin = stxt ;
+/* If 0410 file , move data up to page boundary */
+if ((i == MAG410) && sdat ) { /*  0410  */
+       i = corep2 = ((stxt + 511) & 017777777000) ; /* page boundary */
+       corep2 += sdat ; /* end+1 of new data area */
+       corep1 = filsiz ; /* end+1 of current data area */
+       for (k = sdat ; k ; k--) /* move data up */
+               *(--corep2) = *(--corep1) ;
+       clrmax += (i-stxt) ; /* adjust upper limit for moved data */
+       clrmin = i + sdat ;
+       }
+/*  clear  core  */
+clrcor :
+for (corep1 = clrmin ; corep1 < clrmax ; corep1++)
+       *corep1 = 0 ;
+/*  execute  user  task  */
+asm("  .globl  _entry") ;
+asm("  calls   $0,*_entry") ;
+/*             */
+return(0) ;
+}
+/*             */
+reloc()
+{
+extern edata ;
+register int *to , *from , i ;
+mtpr(KSP,RELOC) ; /* set stack */
+from = 0 ;
+to = RELOC ;
+for (i = (int)&edata-RELOC ; i > 0 ; i -= (sizeof *from))
+       (*to++) = (*from++) ;
+}
+/*             */
+l2x(val,rptr)
+register int val ;
+register char *rptr ;
+{
+register int i , j ;
+register char *tp ;
+int knt ;
+char tmp[20] , sign ;
+knt = sign = 0 ;
+if (val < 0) {
+       sign++ ;
+       val = (-val) ;
+       }
+tp = tmp ;
+loop :
+       knt++ ;
+       i = val/16  ;  /*  quotient & base 16 */
+       j = val%16 ;
+       (*tp++) = j + (j<10?0x30:0x57) ;
+       val = i ;
+       if (val == 0) {
+               /*  done  dividing  */
+               if (sign) { knt++ ; (*tp++) = '-' ; }
+               for (i = knt ; i ; i--)
+                       (*rptr++) = tmp[i-1] ;
+               (*rptr++) = '\0' ;
+               return(knt) ;
+               }
+       else goto loop ;
+}
diff --git a/usr/src/standalone/fdump.c b/usr/src/standalone/fdump.c
new file mode 100644 (file)
index 0000000..0a65802
--- /dev/null
@@ -0,0 +1,134 @@
+# include "CON.h"
+# include "FL.h"
+/*             */
+char input[130]  ;  /*  term input buffer */
+int count , dskoff  , error ;
+char *bufptr ;
+/*             */
+main() {
+/*
+*  Stand-alone program to dump RX11 floppy  disk to VAX LSI console
+*  printer in hex format.
+*  Use specifies start sector(from 0) and no. of sectors.
+*/
+
+putlin("fdump : floppy-to-console hex dump") ;
+putnl() ;
+doff :
+putstr("start 128-byte block no. : ") ;
+getcon(input) ;
+dskoff = a2l(input) ;
+if (dskoff < 0) goto fini ;
+if (dskoff > MAXSEC-1) goto doff ;
+gknt :
+putstr("no. blocks : ") ;
+getcon(input) ;
+count = a2l(input) ;
+if (count < 0) goto gknt ;
+if (count == 0) count = 1 ;
+error = 0 ;
+if (init()) {
+       putlin("init error") ;
+       return(-1) ;
+       }
+putlin("                      HI  < - -  LO") ;
+putnl() ;
+while ((error == 0) && (count--)) {
+       if (flrs(dskoff,bufptr)) {
+               putlin("floppy i/o error") ;
+                       ioerr :
+                               error++ ;
+                               continue ;
+                       }
+       if (prsec()) {
+               goto ioerr ;
+               }
+       putnl() ;
+       putnl() ;
+       dskoff++ ; /* next block */
+}
+goto doff ;
+fini :
+return(0) ;
+}
+/*             */
+init()
+{
+extern char *end ;
+
+bufptr = (char *)(((int)&end+511) & 017777777000) ;
+return(0) ;
+}
+/*             */
+prsec()
+{
+/*
+*  Print 128 bytes on VAX LSI console as hex
+*  characters.
+*  Translate bytes in 'bufptr[]' to hex char's
+*  and out to console, 64 char's per line.
+*  (32 bytes per line)
+*/
+register int i , j ;
+int k , addr ;
+char c , *hp , *fr ;
+char tmp[258] , ltmp[65] ;
+ltmp[64] = '\0' ;
+hp = "block # \0\0\0\0\0\0\0" ;
+l2a(dskoff-1,&hp[8]) ;
+putlin(hp) ;
+putnl() ;
+hxcnvt(bufptr,128,tmp) ; /* convert bytes to hex char's */
+for (i = 0,addr = 0 ; (i < 256); i+=64,addr +=64 ) {
+       hp = ltmp ;
+       fr = (&tmp[i+63]) ;
+       for ( k = 32 ; k ; k--) {
+               (*hp++) = *(fr-1) ;
+               (*hp++) = (*fr--) ;
+               fr-- ;
+               }
+       putstr(ltmp) ;
+       l2x(addr,input) ;
+       putstr("  : ") ;
+       putlin(input) ;
+       }
+return(0) ;
+}
+/*             */
+hxcnvt(in,knt,out)
+register char *in , *out ;
+int knt ;
+{
+/*
+*  Convert 'knt' bytes in char array 'in' to 'knt*2'
+*  hex char's and store in char array 'out'.
+*/
+register unsigned int bit4 , byte ;
+byte = 0 ;
+while (knt--) {
+       byte = (*in++) ;
+       bit4 = (byte>>4) & 017 ;
+       (*out++) = (bit4<10?bit4+0x30:bit4+0x57) ;
+       bit4 = byte & 017 ;
+       (*out++) = (bit4<10?bit4+0x30:bit4+0x57) ;
+       }
+return(0) ;
+}
diff --git a/usr/src/standalone/flpcpy.c b/usr/src/standalone/flpcpy.c
new file mode 100644 (file)
index 0000000..94f7e9b
--- /dev/null
@@ -0,0 +1,148 @@
+# include "CON.h"
+# include "FL.h"
+/*             */
+# define BLKSIZ 512  /*  tape block size */
+int count , sector , isector , icount ;
+char *bufptr , input[128] , *ibufptr ;
+int wo = 0 ;
+/*             */
+main() {
+/*
+*  Stand-alone program to copy VAX LSI RX11 floppy diskette to
+*  memory and back to floppy.
+*  Floppy sector no.'s start at 1 for controller - start at 0
+*      for user input.
+*  Floppy track no.'s start at 0.
+*/
+register int kk ;
+
+putlin("flpcpy : Floppy-to-Memory-to-Floppy Copy") ;
+putnl() ;
+doff :
+putstr("floppy sector offset : ") ;
+getcon(input) ;
+sector = a2l(input) ;
+if ((sector < 0) || (sector >= MAXSEC)) goto doff ;
+gknt :
+putstr("no. of input sectors : ") ;
+getcon(input) ;
+count = a2l(input) ;
+if (count < 0) goto gknt ;
+if (count == 0) count = MAXSEC ;
+if (init()) {
+       putlin("init error") ;
+       return(-1) ;
+       }
+isector = sector ;
+icount = count ;
+if (wo) goto wflop ;
+while (count>0) {
+if ((count%100) == 0)  {
+       kk = count/100 ;
+       l2a(kk,input) ;
+       putstr(input) ;
+       putstr(" ") ;
+       }
+       if (flio(FL_RS)) { /* read */
+               putlin("floppy input error") ;
+               return(-1) ;
+               }
+       }
+putnl() ;
+putlin("floppy read complete") ;
+wflop :
+putlin("mount new floppy - type any key when ready") ;
+getcon(input) ;
+count = icount ;
+sector = isector ;
+bufptr = ibufptr ;
+while (count > 0) {
+if ((count%100) == 0)  {
+       kk = count/100 ;
+       l2a(kk,input) ;
+       putstr(input) ;
+       putstr(" ") ;
+       }
+       if (flio(FL_WS)) {
+               putlin("floppy output error") ;
+               return(-1) ;
+               }
+       }
+putnl() ;
+putlin("floppy write complete") ;
+end :
+return(0) ;
+}
+/*             */
+init() {
+/*
+*  Initialization.
+*/
+extern char *end ;
+ibufptr = bufptr = (char *)(((int)&end+511) & 017777777000) ;
+return(0) ;
+}
+/*             */
+flio(func)
+int func ;
+{
+/*
+*  Function to read/write 1 sector from floppy disc.
+*  'sector' is sector no.-1 to read into 'input[]'.
+*  Return (-1) for error, else return (0) .
+*/
+register int j , s , t ;
+register unsigned int c ;
+/* compute start track & sector from current sector 'sector'. */
+t = sector/RXSTRK ; /* track no. */
+s = sector%RXSTRK + 1 ; /* sector */
+sector++ ;
+fltwait() ;
+mtpr(TXDB,func) ; /* Floppy Read/Write Sector command */
+fltwait() ;
+mtpr(TXDB,s|FL_DATA) ; /* supply sector no. to floppy interface */
+fltwait() ;
+mtpr(TXDB,t|FL_DATA) ; /* track no. */
+if (func == FL_RS) { /* Read Sector */
+       /* wait for read to complete */
+       if (fldone()) return(-1) ;
+       /* loop to read sector bytes from interface */
+       for (j = 0 ; j < RXBYSEC ; j++) {
+               flrwait() ; /* wait till ready */
+               (*bufptr++) = mfpr(RXDB) ; /*get data byte-assume from floppy*/
+               }
+       }
+else {
+       if (func == FL_WS) { /* Write Sector */
+               for (j = 0 ; j < RXBYSEC ; j++) {
+                       /* send byte over interface */
+                       fltwait() ;
+                       c = (*bufptr++) & 0xff ;
+                       mtpr(TXDB,(c|FL_DATA)) ;
+                       }
+               fltwait() ;
+               if (fldone()) return(-1) ;
+               }
+       }
+count-- ;
+return(0) ;
+}
diff --git a/usr/src/standalone/makefile b/usr/src/standalone/makefile
new file mode 100644 (file)
index 0000000..f7981d1
--- /dev/null
@@ -0,0 +1,88 @@
+RELOC=50000
+d2dcpy: d2dcpy.o
+       ld d2dcpy.o ulib.a
+       vrmhead a.out d2dcpy
+       rm d2dcpy.o a.out
+       ls -l d2dcpy
+d2dcpy.o: d2dcpy.c
+       cc -c d2dcpy.c
+d2tcpy: d2tcpy.o
+       ld d2tcpy.o ulib.a
+       vrmhead a.out d2tcpy
+       rm d2tcpy.o a.out
+       ls -l d2tcpy
+d2tcpy.o: d2tcpy.c
+       cc -c d2tcpy.c
+ddump: ddump.o
+       ld ddump.o ulib.a
+       vrmhead a.out ddump
+       rm a.out ddump.o
+       ls -l ddump
+ddump.o: ddump.c
+       cc -c ddump.c
+fboot: fboot.o
+       ld -T $(RELOC) fboot.o
+       vrmhead a.out fboot
+       rm a.out fboot.o
+       ls -l fboot
+fboot.o: fboot.c
+       cc -c fboot.c
+fdump: fdump.o
+       ld fdump.o iolib.a ulib.a
+       vrmhead a.out fdump
+       rm a.out fdump.o
+       ls -l fdump
+fdump.o: fdump.c
+       cc -c fdump.c
+flpcpy: flpcpy.o
+       ld flpcpy.o iolib.a ulib.a
+       vrmhead a.out flpcpy
+       rm a.out flpcpy.o
+       ls -l flpcpy
+flpcpy.o: flpcpy.c
+       cc -c flpcpy.c
+rp6fmt: rp6fmt.o
+       ld rp6fmt.o ulib.a
+       vrmhead a.out rp6fmt
+       rm rp6fmt.o a.out
+       ls -l rp6fmt
+rp6fmt.o: rp6fmt.c
+       cc -c rp6fmt.c
+rpboot: rpboot.o
+       ld rpboot.o
+       vrmhead a.out rpboot
+       rm a.out rpboot.o
+       ls -l rpboot
+rpboot.o: rpboot.s
+       as -o rpboot.o rpboot.s
+rpread: rpread.o
+       ld rpread.o ulib.a
+       vrmhead a.out rpread
+       rm a.out rpread.o
+       ls -l rpread
+rpread.o: rpread.c
+       cc -c rpread.c
+tdcopy : tdcopy.o
+       ld tdcopy.o iolib.a ulib.a
+       vrmhead a.out tdcopy
+       rm a.out tdcopy.o
+       ls -l tdcopy
+tdcopy.o : tdcopy.c
+       cc -c tdcopy.c
+vrmhead : vrmhead.o
+       cc -o vrmhead vrmhead.o
+       rm vrmhead.o
+       ls -l vrmhead
+vrmhead.o : vrmhead.c
+       cc -c vrmhead.c
diff --git a/usr/src/standalone/rel.h b/usr/src/standalone/rel.h
new file mode 100644 (file)
index 0000000..d0b600c
--- /dev/null
@@ -0,0 +1 @@
+# define RELOC 0x50000
diff --git a/usr/src/standalone/rp6fmt.c b/usr/src/standalone/rp6fmt.c
new file mode 100644 (file)
index 0000000..5207e55
--- /dev/null
@@ -0,0 +1,646 @@
+# include "MBA.h"
+# include "RP.h"
+# include "CON.h"
+# define LOW(i)((short)i)
+# define HIGH(i)(i>>16)
+# define BLKSIZ 512
+# define BUFSIZ ((rpsec*BLKSIZ) + (rpsec*hdsiz))
+# define MAXUNI  7 /* max. no. units on MBA */
+# define MAXERR  20
+# define MB_ERR  0x3080  /*  normal error bits  */
+# define HDcoff 0
+# define HDtoff  3
+int track , cylndr , dunit , ecount , daterr , wcerr ;
+int badsec , hdsiz , dtype , bsize , bufsiz;
+char input[132] ;
+int *RPptr ; /* ptr to start of RP reg's for desired drive */
+int *Mptr ; /* ptr to MBA reg set */
+int rptrk,rpcyl,rpsec;
+char wcrflg ;
+char *ibuf , *obuf ; /*  buffer pointers */
+int Offset[] = {  /*  Centerline offsets  */
+       0 , 0x08 , 0x88 , 0x10 , 0x90 , 0x18 , 0x98 , -1
+       } ;
+main() {
+/*
+*  Stand-alone program to format RP06/RM03 disk.
+*  User specifies disk unit.
+*/
+register int bb;
+
+putlin("format : Format RP06/RM03 Disk") ;
+putnl() ;
+gmba :
+putstr("MBA no. : ") ;
+getcon(input) ;
+dunit = a2l(input) ;
+if (dunit < 0) goto fini ;
+if (dunit > MAXMBA) goto gmba ;
+Mptr = RPptr =  (int *)(M_BASE + (dunit*NEXSPC)) ;
+dun :
+putstr("unit : ");
+getcon(input) ;
+dunit = a2l(input) ;
+if (dunit < 0) goto fini ;
+if (dunit > MAXUNI) goto dun ;
+if (init()) {
+       putlin("init error") ;
+       goto dun ;
+       }
+bb = bsize = BUFSIZ;
+for (cylndr = 0 ; cylndr < rpcyl ; cylndr++) {
+       for (track = 0 ; track < rptrk ; track++) {
+               if (format(0,bb,0)) return(1) ;
+               if (wcheck(0,bb,0)) return(1) ;
+               trkinc() ;
+               }
+       cylinc() ;
+       trkclr() ;
+       }
+putnl() ;
+putstr("# Bad Sectors : ") ;
+l2x(badsec,input) ;
+putlin(input) ;
+putstr("# Write Check errors : ") ;
+l2x(wcerr,input) ;
+putlin(input) ;
+putstr("# Data Check errors : ") ;
+l2x(daterr,input) ;
+putlin(input) ;
+putstr("# Other errors : ") ;
+l2x(ecount,input) ;
+putlin(input) ;
+putnl() ;
+goto dun ;
+fini :
+return(0) ;
+}
+/*             */
+init() {
+/*
+*  Initialization.
+*  Initialize MBA (disk) .
+*  Set up MBA  map register to map a 
+*    transfer of 'BUFSIZ' bytes.
+*/
+extern char *end ;
+register int *mp0 , i , page;
+register short *shp;
+short flg;
+*(Mptr+M_cr) = MBAinit ; /* MBA init */
+/*  start of RP reg's for drive */
+/*  get ptr. to RP ext reg set */
+RPptr = (int *)((int)RPptr + (dunit*EXTSIZ) + M_extern) ;
+if (((page = (*(RPptr+RP_sr))) & RP_MOL) == 0) {
+       putlin("unit not online") ;
+       return(-1) ;
+       }
+if (page & RP_WRL) {
+       putlin("unit write-protected") ;
+       return(1) ;
+       }
+*(RPptr+RP_cr) = RP_RIP | RP_GO ; /* drive preset - sets vv */
+dwait(RPptr) ;
+*(RPptr+RP_off) = RP_FMT | RP_ECI ; /* set format and ECC inhibit */
+i = *(RPptr+RP_dt)&0777 ;  /* get disk type */
+if (i==RP6typ) { /* RP06 */
+       rpsec=RP6SEC; rpcyl=RP6CYL; rptrk=RP6TRK;
+       hdsiz = RP6HD;
+       dtype = RP6typ;
+       }
+else {
+       if (i==RM3typ) {
+               rpsec=RM3SEC; rpcyl=RM3CYL; rptrk=RM3TRK;
+               hdsiz = RM3HD;
+               dtype = RM3typ;
+               }
+       else return(-1);
+       }
+/*  output buffer */
+obuf = (char *)((((int)&end)+511)&017777777000) ;
+/*  input buffer */
+ibuf = (char *)(((int)obuf + BUFSIZ + 511) & 017777777000) ;
+/*  output buffer uses 1st 128 map reg's -
+  input buffer uses last 128 map reg's */
+page = (int)((int)obuf>>9) & 017777777 ;
+page |= 0x80000000;
+mp0 = (int *)((int)Mptr + (int)(M_map*4)) ;
+for (i = 0 ; i < 128 ; i++)
+       (*mp0++) = page++ ;
+page = (int)((int)ibuf>>9) & 017777777 ;
+page |= 0x80000000;
+for (i = 0 ; i<128 ; i++ )
+       (*mp0++) = page++ ;
+/*  initialize output buffer with sector header and data :
+       4 sector header words :
+               cylinder
+               track/sector
+               key word 1 (not on RM03)
+               key word 2 (not on RM03)
+       256 data words
+*/
+flg = (dtype==RM3typ?RM_BSB:0);
+for (shp = (short *)obuf , i = 0 ; i<rpsec ; i++) {
+       *(shp++) = RP_FMT|flg ;
+       *(shp++) = i;  /*  sect/trk  */
+       if (dtype == RP6typ) {
+               *(shp++) = 0;
+               *(shp++) = 0;
+               }
+       for (page = 0 ; page < 256 ; page++)
+               (*shp++) = page;
+       }
+
+ecount = daterr = wcerr = badsec = 0 ;
+bufsiz=BLKSIZ;
+return(0) ;
+}
+/*             */
+rshd(baddr,nb,s)
+int baddr , nb , s ;
+{
+/*
+*  Function to read 'nb' bytes into buffer pointed to
+*    by map and offset in 'baddr' - start at sector 's'
+*/
+register int i , j ;
+register int *M , *R ;
+R = RPptr ;
+M = Mptr ;
+*(R+RP_cyl) = cylndr ; /* cylinder no. */
+*(R+RP_stk) = (track<<8) | s ; /* track:sector */
+*(M+M_bc) = (-nb) ;
+*(M+M_var) = baddr ; /* virt addr reg = map no. + byte off */
+rini :
+*(R+RP_cr) = RP_DC | RP_GO ; /*  RP06 drive clear function code */
+dwait(R) ;
+*(R+RP_cr) = RP_RHD | RP_GO ; /* read sector header and data */
+dwait(R) ; /* wait for i/o to finish */
+if (i = mbaerr(M)) {
+       return(-1) ;
+       }
+if (i = derror(R)) { /* error */
+       putlin("- - - - - - -") ;
+       putstr("read SHD error") ;
+       stmes(i) ;
+       dadmes(R) ;
+       /* return if any header errors */
+       if (i & (RP_HCRC|RP_HCE|RP_FER)) return(-1) ; /* error */
+       }
+/* normal return is to return header-error-free status */
+return(i) ;
+}
+/*             */
+hcheck(insec,ousec)
+register short *insec , *ousec ;
+{
+/*
+* Compare sector header and data info on disk against that which
+*  was written from output buffer
+*/
+register int j ;
+/*  cyl and sect/track */
+if (((*insec++)!=(*ousec++)) ||
+  ((*insec++)!=(*ousec++)) ) return(1);
+/* if RP06,  keywords */
+if ((dtype==RP6typ) && ( ((*insec++)!=(*ousec++)) ||
+  ((*insec++)!=(*ousec++)) )) return(1);
+for (j = 0 ; j < 256 ; j++)
+       if ((*insec++) != (*ousec++))
+               return(1) ;
+return(0) ;
+}
+/*             */
+format(baddr,nb,s)
+int baddr , nb , s ;
+{
+/*
+*  Function to write 'nb' bytes worth of sector and data info
+*  from buffer whose map/offset is 'baddr' to disk.
+*/
+register int i , j ;
+register int *R , *M ;
+R = RPptr ;
+M = Mptr ;
+*(R+RP_cr) = RP_DC | RP_GO ;
+dwait(R) ;
+*(R+RP_cyl) = cylndr ;
+*(R+RP_stk) = (track<<8) | s ; /* sector : track */
+*(M+M_bc) = (-nb) ; /* byte count */
+*(M+M_var) = baddr ; /* virt addr reg = map no. + byte off */
+*(R+RP_cr) = RP_WHD | RP_GO ; /* write sector header and data */
+dwait(R) ; /* wait for i/o to finish */
+if (i = mbaerr(M)) {
+       return(1) ;
+       }
+if (i = derror(R)) {
+       putlin("- - - - - -") ;
+       putstr("write SHD error") ;
+       stmes(i) ;
+       dadmes(R) ;
+       if (wcrflg) return(1) ; /* return if in 'write check' recovery */
+       if (++ecount > MAXERR) return(-1) ;
+       }
+return(0) ; /* normal return */
+}
+/*             */
+trkinc()
+{
+/*
+*  Increment track no. in output buffer sector headers.
+*/
+register char *sp ;
+register int i , j;
+j = hdsiz + 512;
+for (i = 0 , sp = obuf ; i < rpsec ; i++ ,  sp += j)
+       sp[HDtoff]++ ;
+}
+/*             */
+cylinc() {
+/*
+*  Increment cylinder no. in output buffer sector headers.
+*/
+register short *sp ;
+register int i , j;
+j = hdsiz + 512;
+for (i = 0 , sp = (short *)obuf ; i < rpsec ; i++ , sp = (short *)((int)sp +  j))
+       sp[HDcoff]++ ;
+}
+/*             */
+trkclr()
+{
+/*
+*  Clear track no. in output buffer sector headers.
+*/
+register char *sp ;
+register int i , j;
+j = hdsiz + 512;
+for (i = 0 , sp = obuf ; i < rpsec ; i++ , sp += j)
+       *(sp+HDtoff) = 0;
+}
+/*             */
+wcheck(baddr,nb,s)
+int baddr , nb , s ;
+{
+/*
+*  Function to write check 'nb' bytes worth of sector and data info
+*  from buffer whose map reg is 'baddr' - start at sector 's'.
+*/
+register int i , j ;
+register int *R , *M ;
+R = RPptr ;
+M = Mptr ;
+*(R+RP_cr) = RP_DC | RP_GO ;
+dwait(R) ;
+*(R+RP_cyl) = cylndr ;
+*(R+RP_stk) = (track<<8) | s ; /* sector : track */
+*(M+M_bc) = (-nb) ; /* byte count */
+*(M+M_var) = baddr ; /* virt addr reg = map no. + byte off */
+*(R+RP_cr) = RP_WCH | RP_GO ; /* write check sector header and data */
+dwait(R) ; /* wait for i/o to finish */
+if (i = mbaerr(M)) {
+       if (i & (M_WCKU | M_WCKL)) { /* Write Check Error */
+               wcerr++ ;
+               putlin("* Write Check Error *") ;
+               dadmes(R) ;
+               i = *(M+M_bc) | 0xffff0000 ;
+               l2x(nb+i,input) ;
+               putstr("no. bytes read : ") ;
+               putlin(input) ;
+               if (wcrflg) return(1) ;
+               wckrcv() ;
+               }
+       }
+if (i = derror(R)) {
+       putlin("- - - - - -") ;
+       putstr("write error") ;
+       stmes(i) ;
+       dadmes(R) ;
+       ecount++ ;
+       }
+if (ecount > MAXERR) return(-1) ;
+return(0) ; /* normal return */
+}
+/*             */
+wckrcv()
+{
+/*
+*  Try to recover from a 'write check' error during a
+*  'Write Check Header and Data' function.
+*  'RPptr' is ptr to RP register set.
+*  'Mptr' is ptr to MBA reg set.
+*  MBA byte count reg has neg. no. bytes remaining - transfer stops
+*  on error, even in middle of a sector.
+*  Loop with a 'Write Sector Header and Data' followed by a 'Read
+*  Sector Header and Data' - each loop iteration uses a different head 
+*  centerline offset.
+*  If all fails, report irrecoverable error and finish off the
+*  'write check data and header' on the rest of the track.
+*/
+register int i , j , k , l , m ;
+wcrflg++ ;  /*  flag says 'write check' recovery i-o is in progress */
+/* If no. bytes read thus far is a multiple of 'BLKSIZ+RPHEAD', then
+*  error was in last byte of sector and sector has to be backed up
+*  by 1.
+*/
+j = curpos() ; /* return current cyl , trk ,sector */
+i = ((*(Mptr+M_bc))>>16) + bsize ;  /*  no. bytes read by 'write check' */
+if ((i%(BLKSIZ+hdsiz)) == 0) {
+       putlin("wckrcv : backup 1 sector") ;
+       j = backup(j) ;
+       }
+j = j & 0x1f ; /* sector only */
+m = j * (BLKSIZ+hdsiz) ; /* page no. and offset */
+/*
+*  Loop with a 'Write Sector Header and Data' followed by a
+*  'Read Sector Header and Data' - each iteration uses a
+*  different centerline offset - 1st offset is 0.
+*/
+for (i = 0 ; (l = Offset[i]) >= 0 ; i++) {
+       k = *(RPptr+RP_off) & 0xff00 ;
+       *(RPptr+RP_off) = k | l ;
+       *(RPptr+RP_cr) = RP_DC | RP_GO ;
+       dwait(RPptr) ;
+       *(RPptr+RP_cr) = RP_OFF | RP_GO ;
+       dwait(RPptr) ;
+       /*  Format 1 sector */
+       if (format(m,BLKSIZ+hdsiz,j)) {
+               putlin("wckrcv: format error");
+               continue;
+               }
+       /*  Format was successful
+           Read sector. */
+       if (rshd(128<<9,BLKSIZ+hdsiz,j) < 0) {
+               putlin("wckrcv: rshd() error");
+               continue ;
+               }
+       /*  successful 'Read Sector Header and Data' */
+       /*  Compare sector written from output buffer
+               against sector just read */
+       if (hcheck(ibuf,obuf+m)) {
+               putlin("wckrcv : sector compare failure") ;
+               continue ;
+               }
+       /*  good read and good compare */
+       putstr("    head offset : ") ;
+       l2x(l,input) ;
+       putlin(input) ;
+       goto wckfin ;
+       }
+putlin("wckrcv : bad sector") ;
+badsec++ ;
+wckfin :
+*(RPptr+RP_cr) = RP_RTC | RP_GO ; /* return to centerline */
+dwait(RPptr) ;
+/*  Cyl , trk and sector are set to values to continue where
+*  original 'Write Check Header and Data' left off
+*/
+j = curpos() & 0xff ;  /*  sector  */
+wcrflg = 0 ;
+i = j * (BLKSIZ+hdsiz) ; /* offset */
+/*  continue rest of 'wcheck89' */
+wcheck(i,(rpsec-j)*(BLKSIZ+hdsiz),j) ;
+return(0) ;
+}
+/*             */
+curpos()
+{
+/*
+*  Function to return current cyl, trk and sector for RP whose
+*  register set is pointed to by 'RPptr'.
+*/
+register int i , j ;
+i = *(RPptr+RP_cyl)<<16 ;
+j = *(RPptr+RP_stk) & 0x1f1f ;
+return(i|j) ;
+}
+/*             */
+backup(cts)
+register int cts ;
+{
+/*
+*  Function to backup 1 sector.
+*  Cyl, track and sector are in 'cts' .
+*/
+register int trk , sec ;
+sec = cts & 0x1f ;  /*  sector */
+if (sec > 0) return(--cts) ;
+cts = cts & 0xffffff00 ;
+cts = cts | (rpsec-1) ;
+trk = (cts>>16) & 0x1f ;  /*  track */
+if (trk>0) return(cts-0x100) ;  /*  dec track */
+cts = cts & 0xffff00ff ;
+cts = cts | ((rptrk-1)<<8) ;
+return(cts-0x10000) ;  /*  dec cyl no.  */
+}
+/*             */
+dread(baddr,nb,s)
+int baddr , nb , s ;
+{
+/*
+*  Function to read 'nb' bytes into buffer pointed to
+*    by map 'baddr' - start at sector 's'.
+*/
+register int i , *R , *M , j;
+R = RPptr ;
+M = Mptr ;
+*(R+RP_cyl) = cylndr ; /* cylinder no. */
+*(R+RP_stk) = (track<<8) | s ;  /* track:sector */
+*(M+M_bc) = (-nb) ;
+*(M+M_var) = baddr ; /* virt addr reg = map no. + byte off */
+rini :
+*(R+RP_cr) = RP_DC | RP_GO ; /*  RP06 drive clear function code */
+dwait(R) ;
+i = *(R+RP_off) & (~(RP_ECI)) ; /* enable ECC */
+*(R+RP_off) = i ;
+*(R+RP_cr) = RP_RED | RP_GO ; /* read */
+dwait(R) ; /* wait for i/o to finish */
+*(R+RP_off) = *(R+RP_off) | RP_ECI ; /* ECC inhibit on */
+if (i = mbaerr(M)) {
+       return(-1) ;
+       }
+if (i = derror(R)) { /* error */
+       putlin("- - - - - - -") ;
+       putstr("read error") ;
+       stmes(i) ;
+       dadmes(R) ;
+       if (wcrflg)
+               if (i & (RP_HCE|RP_HCRC|RP_FER|RP_PAR))
+                       return(1) ;
+       if (i & (~(RP_DCK))) {
+               ecount++ ;
+               }
+       if (i & RP_DCK) { /* Data Check Error */
+               daterr++ ;
+               putlin("* Data Check *") ;
+               if (i & RP_ECH) { /* ECC Hard Error */
+                       putlin("ECC non-recov") ;
+                       if (wcrflg) return(1) ;
+                       ecount++ ;
+                       }
+               else { /* ECC recoverable */
+                       ECCrcv(R) ;
+                       }
+               if (*(M+M_bc)) { /* more i-o to complete */
+                       j = (*(R+RP_stk));
+                       i = (j>>8) & 0x1f;
+                       j = j & 0x1f;
+                       if (j>=rpsec) /*sector */
+                               j = 0;
+                       if (i>=rptrk) /* track */
+                               i = 0;
+                       *(R+RP_stk) = (i<<8) | j;
+                       goto rini ;
+                       /* status reg cleared by Drive Clear */
+                       }
+               }
+       if (wcrflg) return(0) ;
+       if (ecount > MAXERR) return(-1) ;
+       }
+return(0) ; /* normal return */
+}
+/*             */
+ECCrcv(dptr)
+register int *dptr ;
+{
+/*
+*  Do ECC error recovery on disk whose register set is pointed
+*  to by 'dptr'.
+*  'mbaerr()' has cleared MBA status reg.
+*  With ECC enabled, disk read has stopped after sector with bad
+*  data. After correction of data, return to read routine which will
+*  continue read of track if more sectors to do.
+*  Return 0.
+*/
+register unsigned int pos , pat , ll;
+register unsigned short *wordp ;
+struct www {
+       union {
+               int x123;
+               short wlo , whi ;
+               } sss;
+       };
+char tmp[50] ;
+pat = (*(dptr+RP_Epat)) & 0xffff ; /* ECC pattern reg */
+pos = (*(dptr+RP_Epos)) & 0xffff ; /* ECC position reg */
+putstr("pat : ") ;
+ul2x(pat,tmp) ;
+putlin(tmp) ;
+putstr("pos : ") ;
+ul2x(pos,tmp) ;
+putlin(tmp) ;
+wordp = (unsigned short *)ibuf ;   /* ptr to input buffer */
+/*
+*  'bufsiz' bytes are read on each read into buffer pointed to
+*  by 'ibuf'. MBA byte count reg has neg. no. of bytes remaining
+*  in read if this read error was not in the last sector to be
+*  read.
+*/
+/* calculate buffer location of faulty data */
+wordp = (unsigned short *)((int)wordp + (bufsiz + ((*(Mptr+M_bc))>>16) - BLKSIZ)) ; /* sector in buffer */
+wordp = (unsigned short *)((int)wordp + ((pos-1)>>4)) ; /* word within sector */
+/* burst pattern may be across word boundary */
+ll = (*wordp) + ((*(wordp+1))<<16) ;
+putstr("bad data  : ") ;
+ul2x(ll,tmp) ;
+putlin(tmp) ;
+pat = pat<<((pos%16)-1) ;
+ll = ll^pat ; /* correction */
+putstr("good data : ") ;
+ul2x(ll,tmp) ;
+putlin(tmp) ;
+/* put good data back in buffer */
+*wordp = LOW(ll);
+*(wordp+1) = HIGH(ll);
+return(0) ;
+}
+/*             */
+mbaerr(mba)
+register int *mba ;
+{
+register int i ;
+if (i = (*(mba+M_sr))) {
+       if (i == 0x2000) return(0) ;
+       if (i != MB_ERR) {
+               putlin("- - - - - -") ;
+               putstr("MBA error") ;
+               stmes(i) ;
+               *(mba+M_sr) = (-1) ;
+               return(i) ;
+               }
+       }
+return(0) ;
+}
diff --git a/usr/src/standalone/rpboot.s b/usr/src/standalone/rpboot.s
new file mode 100644 (file)
index 0000000..f3c9b95
--- /dev/null
@@ -0,0 +1,226 @@
+#
+# RP06/RM03 disk boot program to load "/fboot" from
+#    a UNIX filesystem (starting at block 1 on pack on
+#    drive 0) into low core and to execute that file.
+#  This program can only read regular small version 7 files
+#    from the root of a UNIX filesystem.
+#
+#
+       .set    BLKSIZ,512  #  disc block size
+       .set    RELOC,0x50000
+       .set    HDRSIZ,040  #  size of file header for VAX
+       .set    MAGIC,0410  #  file type id in header
+       .set    INOSIZ,64  #  no. bytes/inode entry
+       .set    INOBLK,BLKSIZ/INOSIZ  # no. inodes/disc block
+       .set    INOMSK,0xfffffff8  #  changes with inode size
+       .set    NAMSIZ,14  #  no. bytes in name field of dir entry
+       .set    ENTADR,024  #  offset to entry addr in task header
+       .set    DIRSIZ,16  #  size of directory entry, bytes
+       .set    ROOTINO,2  #  root dir inode no.
+       .set    NBOO,1
+       .set    NSUP,1
+       .set    NL,012  #  new-line char
+       .set    CR,015  # carriage-return char
+       .set    SLASH,057  #  '/'
+       .set    NMASK,0177
+       .set    NNMASK,037777777600  #  ~NMASK
+#  MBA registers
+       .set    MBA0,0x20010000  #  MBA 0 device reg's
+       .set    M_cr,MBA0+4  #  MBA control reg
+       .set    M_var,MBA0+12  #  MBA virt addr reg
+       .set    M_bc,MBA0+16  #  MBA byte count reg
+       .set    M_map,MBA0+0x800  #  start of MBA map reg's
+       .set    MBAinit,1  #  MBA init bit in MBA control reg
+#
+#  RM03
+       .set    RM3SEC,32
+       .set    RM3TRK,5
+#
+       .set    RP6typ,022
+       .set    RM3typ,024
+#
+#  RP06  registers
+       .set    RP6TRK,19  #  no. tracks/cylinder
+       .set    RP6SEC,22  #  no. sectors/track
+       .set    RP,MBA0+0x400   #  start of RP06 drive 0  reg's
+       .set    RP_cr,RP+0  # RP06 control reg, drive 0
+       .set    RP_sr,RP+4  #  status reg
+       .set    RP_stk,RP+0x14  #  desired track/sector reg
+       .set    RP_dt,RP+0x18  #  drive type reg
+       .set    RP_off,RP+0x24  #  RP offset reg
+       .set    RP_cyl,RP+0x28  #  desired cyl reg
+#  RP06 function codes, status bits 
+       .set    RP_GO,1  #  GO bit
+       .set    RP_RED,070  # read data
+       .set    RP_DC,010  #  drive clear function code
+       .set    RP_RIP,020  #  Read-In Preset function code
+       .set    RP_FMT,0x1000  #  format bit for offset reg
+       .set    RP_MOL,0x1000  #  medium online in status reg
+       .set    RP_DRY,0200  #  drive ready, staus reg
+       .set    RP_ERR,040000  #  composite error, staus reg
+       .set    RP_pDRY,7  #  bit position of RP_DRY
+       .set    RP_pERR,14  #  bit position of RP_ERR
+#
+#
+init :
+#  system initialization - executed once per boot load
+       halt  #  entry mask required by DEC monitor software
+       halt
+       movl    $MBAinit,*$M_cr  #  MBA initialize
+       movl    $RP_RIP+RP_GO,*$RP_cr  # read-in preset
+       movl    $RP_FMT,*$RP_off  #  format bit in RP offset reg
+#
+       movl    *$RP_dt,r0
+       cmpb    $RP6typ,r0
+       bneq    rm3
+       movl    $RP6SEC,*$rpsec
+       movl    $RP6TRK,*$rptrk
+       brb     domul
+rm3:
+       movl    $RM3SEC,*$rpsec
+       movl    $RM3TRK,*$rptrk
+domul:
+       mull3   *$rpsec,*$rptrk,*$rpst
+#  move boot image up to higher core
+start :
+       movl    $RELOC,sp
+#  'uboot' must have no header
+       movc3   $end,*$0,(sp)  #  move boot to relocated position
+#
+#  jump to re-located code at 'start2' - done once per boot load
+       jmp     *$RELOC+start2
+#
+#  execution starts here only after boot has been re-located
+start2 :
+#
+#  search inodes for pathname specified in 'names'
+#
+#  Must preserve r6  &  r7
+#  'cmpc[35]' instruction uses reg's 0 - 3
+#  'movc[35]' instruction uses reg's 0-5
+       movl    $names+RELOC,r6  #  start of input filename
+       movzbl  $ROOTINO,r0  #  start at root inode for search
+nxti :
+       clrw    *$bno  #  'bno' is index into 'iaddr[]' in inode entry
+       bsbw    iget  #  get inode into core
+       tstb    (r6)  #  r6 -> empty pathname component if end of pathname
+       beql    getfil
+get1b :
+       bsbw    rmblk  #  read in 1 of blocks in 'addr[]' in inode entry
+       beql start2  # file not found if zero cc set
+#
+       movl    $buf,r7  #  buffer holds directory block
+nxtent :
+       tstw    (r7)  #  null dir entry (inode # field = 0)
+       beql    dirchk
+       cmpc3   $NAMSIZ,(r6),2(r7)  #  compare 'names' against
+#                      dir entry - both null-filled
+       bneq    dirchk  #  branch if dir entry is not the one
+#  found component in a dir entry
+       movzwl  (r7),r0  #  2-byte inode no. from 1st 2 bytes of dir entry
+       addl2   $NAMSIZ,r6  #  point to next pathname component in 'names[]'
+       brb     nxti  #  now go get inode whose no. is in r0
+#
+dirchk :               #  no pathname match
+       acbl    $buf+BLKSIZ-1,$DIRSIZ,r7,nxtent  #  loop if
+#                      more dir entries in this buffer
+       brb     get1b  #  get another dir block into buffer
+#
+#  here if inode for desired file has been read in
+getfil :
+       clrl    bufptr  #  new buffer ptr is low core
+getlop :
+       bsbb    rmblk  #  get a block in the file
+       beql clear  #  branch if no more file blocks to read
+#  skip above branch if more file blocks to read in
+       addl2   $BLKSIZ,bufptr  #  next page in low core
+       brb     getlop  #  go get next block of input file
+#
+#  clear core
+#
+clear :
+       movl    *$size,r3
+clrcor :
+       clrq    (r3)
+       acbl    $RELOC,$8,r3,clrcor
+#
+#  go execute file
+#
+       calls   $0,*$0
+       brw     start2
+#
+#
+#  subroutine to get the inode whose no. is in r0
+#
+iget :
+       addl3   $(INOBLK*(NBOO+NSUP))-1,r0,r8  #  have to add in 2 blocks (boot and super)
+#                      worth of dummy inodes to calculate proper inode block
+       divl3   $INOBLK,r8,r4  #  calculate inode block , put in r4
+       bsbw    rblk  #  read in block containing desired inode
+       bicl2   $INOMSK,r8
+       mull2   $INOSIZ,r8  #  x inode size = offset in block
+       addl2   $buf,r8  #  buffer loc of inode entry
+#  move inode entry to separate buffer
+       movc3   $time-inode,(r8),*$inode
+       rsb
+#
+#  subr to read in 1 of blocks (bno) in 'addr[]'
+#
+rmblk :
+       movzwl  *$bno,r0
+       addw2   $3,*$bno  #  index into 'addr[]' array in inode entry
+       addl2   $addr,r0
+#  this boot assumes only small files(<11 blocks)
+       extzv   $0,$24,(r0),r4  #  get low 2 bytes of block no. -> r4
+       bneq    rblk  #  read in block if non-zero
+#  zero cc is set on return
+       rsb
+#
+#  subr to read disc block no. specified in r4 from RP06, drive 0
+#
+rblk :
+       clrl    r5
+       ediv    *$rpst,r4,*$RP_cyl,r1
+#  (r4 = block no.)/(no. blocks per cyl) -> cyl no.
+#  r1 = remainder = block offset with in cylinder
+       clrl    r2
+       ediv    *$rpsec,r1,r1,r0
+#  r1 = track no. ; ; sector no. in low part RP_stk
+       insv    r1,$8,$5,r0  #  move track no. into RP_stk
+       movl    r0,*$RP_stk  #  track-sector
+       movl    $-BLKSIZ,*$M_bc  #  byte count
+       ashl    $-9,bufptr,r0  #  start page no. of buffer
+       bisl3   $0x80000000,r0,*$M_map  #  MBA map reg =
+#                      valid bit + phys page no.
+       clrl    *$M_var  #  buffer has been 512-byte aligned + map reg 0
+       movl    $RP_RED+RP_GO,*$RP_cr  #  disc read function code
+rprdy :
+       movl    *$RP_sr,r0
+       bbc     $RP_pDRY,r0,rprdy  #  loop unitl ready
+       bbs     $RP_pERR,r0,rperr  #  branch if error
+       bicpsw  $2  #  set zero cc for caller success
+       rsb     #  normal return
+  rperr :      #  disc i/o error
+       halt            #  halt on error
+#
+#
+bufptr :  .long  buf
+names :
+       .byte   'f,'b,'o,'o,'t,0,0,0,0,0,0,0,0,0
+       .byte  0
+#
+end:
+#
+       .set    buf,RELOC-1024
+       .set    inode,RELOC-512
+       .set    mode,inode
+       .set    nlink,mode+2
+       .set    uid,nlink+2
+       .set    gid,uid+2
+       .set    size,gid+2
+       .set    addr,size+4
+       .set    time,addr+40
+       .set    bno,time+12
+       .set    rptrk,bno+4
+       .set    rpsec,rptrk+4
+       .set    rpst,rpsec+4
diff --git a/usr/src/standalone/rpread.c b/usr/src/standalone/rpread.c
new file mode 100644 (file)
index 0000000..b4ddbd0
--- /dev/null
@@ -0,0 +1,673 @@
+# define min(ii,jj) (ii<jj?ii:jj)
+# define RP6CYL  815  /*  no. RP06 cylinders/pack */
+# define RP6TRK  19  /*  no. tracks/cyl  */
+# define RP6SEC  22  /*  no. sectors/track  */
+# define RP6ST  (rpsec*rptrk)  /*  no. sectors/cyl  */
+# define MAXSEC  (rpcyl*rptrk*rpsec)  /*  sectors/pack  */
+# define M0  0x20010000  /* phys addr MBA 0  */
+# define M_st  2  /* offset for MBA status reg */
+# define M0_cr  (M0+4)  /*  MBA 0 control reg addr */
+# define M0_sr (M0+8)  /* mba 0 status reg */
+# define M0_map  (M0+0x800)  /* start MBA 0 map reg's */
+# define M0_var  (M0+0xc)  /* MBA 0 virt addr reg */
+# define M0_bc  (M0+0x10)  /*  MBA 0 byte count reg */
+# define MBAinit 01  /*  MBA init bit */
+# define MBA_DTC  0x2000  /* MBA date transfer complete, status reg */
+/*             */
+# define RP  (M0+0x400)  /*  base for RP06 reg's, drive 0  */
+/*             */
+# define RP_cr  0  /* RP06 control reg offset, longword */
+# define RP_sr  1  /*  RP06 status reg offset */
+# define RP_er1  02  /*  RP error reg 1 */
+# define RP_stk  5  /*  RP06 sector/track reg offset */
+# define RP_dt  06   /* drive type reg */
+# define RP_er2 010  /* RP error reg 2 */
+# define RP_off  011  /*  RP offset reg */
+# define RP_cyl  012  /*  RP06 cylinder reg offset */
+# define RP_er3 015  /*  RP error reg 3 */
+# define RP_Epos  016  /* RP ECC position reg */
+# define RP_Epat  017  /*  RP ECC pattern reg */
+/*             */
+# define RP_GO  1  /*  go bit */
+# define RP_RED  070  /*  RP06 read function code */
+# define RP_DC  010  /*  drive clear function code */
+# define RP_FMT  0x1000  /*  format bit for offset reg */
+# define RP_RIP 020  /*  Read-in Preset RP06 function code */
+# define RP_DRY  0200  /*  drive ready, status reg */
+# define RP_ERR 040000  /* composite error, status reg */
+# define RP_MOL 0x1000  /*  medium-online bit in status reg */
+# define RP_ECH 0x40  /* ECC Hard Error */
+# define RP_DCK 0x8000  /*  Data Check error */
+/*             */
+# define RXCS  32  /*  receiver control/staus */
+# define RXDB  33  /*  receiver data */
+# define TXCS  34  /*  transmitter control/status */
+# define TXDB  35  /*  transmitter data */
+# define RXCS_DONE  0x80  /*  receiver done */
+# define TXCS_RDY  0x80  /*  transmitter ready */
+/*             */
+# define BLKSIZ 512
+# define NB  128
+# define BUFSIZ (NB*BLKSIZ) /* buffer 1 track */
+# define MAXUNI  1
+# define MAXERR  20
+# define NL  012
+# define CR 015
+# define CDEL 0x23
+# define LDEL 0x40
+/*             */
+# define RP6typ  022
+# define RM3typ  024
+# define RM3CYL  823
+# define RM3TRK  5
+# define RM3SEC  32
+/*             */
+struct { int reg , reg2 , reg3 ; } ;
+int count , dskoff , dunit , ecount , daterr ;
+int *RPptr ; /* ptr to start of RP reg's for desired drive */
+int rpcyl,rptrk,rpsec;
+char *bufptr ;
+main() {
+/*
+*  Stand-alone program to read disk (error checker).
+*  User specifies disk unit, start disk block and no. of blocks.
+*/
+int getcon() , putstr() , a2l() , l2a() ;
+char input[132] ;
+
+putlin("dread : Read RP06/RM03 Disk") ;
+putnl() ;
+dun :
+putstr("disk unit : ");
+getcon(input) ;
+dunit = a2l(input) ;
+if (dunit < 0) goto fini ;
+if (dunit > MAXUNI) goto dun ;
+doff :
+putstr("start block : ") ;
+if (getcon(input)) goto fini ;
+dskoff = a2l(input) ;
+if (dskoff < 0) goto doff ;
+gknt :
+putstr("no. blocks : ") ;
+if (getcon(input)) goto fini ;
+count = a2l(input) ;
+if (count < 0) goto gknt ;
+putnl() ;
+if (init()) {
+       putlin("init error") ;
+       goto dun ;
+       }
+if (dskoff > MAXSEC-1) goto doff ;
+if (count == 0) count = MAXSEC ;
+while (count > 0) {
+       if (dread()) {
+               putstr("disk read error") ;
+               dadmes(RPptr) ;
+               }
+       dskoff += NB ; /* next start place */
+       count -= NB ;
+}
+putstr("# Data Check errors : ") ;
+l2x(daterr,input) ;
+putlin(input) ;
+putstr("# Other errors : ") ;
+l2x(ecount,input) ;
+putlin(input) ;
+goto dun ;
+fini :
+return(0) ;
+}
+/*             */
+putstr(csp)
+register char *csp ;
+{
+if (putcon(csp)) return(-1) ;
+return(0) ;
+}
+/*             */
+putlin(sptr)
+register char *sptr ;
+{
+if (putcon(sptr)) return(-1) ;
+if (putnl()) return(-1) ;
+return(0) ;
+}
+/*             */
+nullcon(nn)
+register nn ;
+{
+/*
+*  Output 'nn' nulls to console terminal -
+*  used for delay.
+*/
+while (nn--) putc(0) ;
+}
+/*             */
+putnl()
+{
+if (putcon("\r\n")) return(-1) ;
+return(0) ;
+}
+/*             */
+putcon(csp)
+register char *csp ;
+{
+/*
+*  Function to output null-terminated string pointed to 
+*  by 'csp' to the VAX LSI terminal.
+*/
+register c ;
+c = 0 ;
+while (c = (*csp++)) putc(c) ;
+return(0) ;
+}
+/*             */
+putc(c)
+{
+/*  wait for LSI printer to be ready */
+while ((mfpr(TXCS) & TXCS_RDY) == 0) ;
+/*  output character */
+mtpr(TXDB,c&0177) ;
+}
+/*             */
+getcon(cs)
+register char *cs ;
+{
+/*
+*  Function to return char's from VAX LSI keyboard to
+*  char array 'cs' - input stops when CR or LF received -
+*  null char appended to end of input
+*/
+register int c , c2 ;
+int getc() ;
+char *ocs;
+       ocs=cs;
+inloop :
+       c = getc() ; /* get 1 char from terminal */
+       putc(c) ;  /*  echo char */
+       if (c==CDEL) {cs--; goto inloop;}
+       if (c==LDEL) {cs=ocs;putc(CR);putc(0);putc(NL);goto inloop;}
+       if ((c == NL) || (c == CR)) {
+               putc(CR) ;
+               putc(0) ;
+               putc(NL) ;
+               (*cs++) = '\0' ;
+               return(0) ;
+               }
+       else {
+               (*cs++) = c ;
+               goto inloop ;
+               }
+}
+/*             */
+getc()
+{
+/*
+*  Return char from VAX LSI terminal char buffer
+*/
+int mfpr() ;
+/*  Wait for receiver done (user entered char)
+*/
+while ((mfpr(RXCS) & RXCS_DONE) == 0) ;
+return (mfpr(RXDB) & 0177) ;  /* return char from receiver buffer */
+}
+/*             */
+mtpr(regno,value)
+{
+       asm("   mtpr    8(ap),4(ap)") ;
+}
+/*             */
+mfpr(regno)
+{
+       asm("   mfpr    4(ap),r0") ;
+}
+/*             */
+a2l(as)
+register char *as ;
+{
+/*
+*  Convert null-terminated ascii string to binary
+*  and return value.
+*  1st char in string :
+*      0 -> octal
+*      x -> hex
+*      else decimal
+*/
+register value , base , sign , digit ;
+digit = value = sign = 0 ;
+base = 10 ;  /* default base */
+aloop :
+if ((digit = (*as++)) == 0) return(value) ; /* null */
+if (digit == '-') {
+       sign++ ;
+       goto aloop ;
+       }
+if (digit == '0') base = 8 ;  /* octal base  */
+else { if (digit == 'x') base = 16 ;  /* hex base */
+       else value = (digit-060) ; /* 060 = '0' */
+       }
+while (digit = (*as++)) {
+       if (digit < '0') return(0) ;
+       switch (base) {
+               case 8 : {
+                       if (digit > '7') return(0) ;
+                       digit -= 060 ;
+                       break ;
+                       }
+               case 10 : {
+                       if (digit > '9') return(0) ;
+                       digit -= 060 ;
+                       break ;
+                       }
+               case 16 : {
+                       if (digit <= '9') {
+                               digit -= 060 ;
+                               break ;
+                               }
+                       if ((digit >= 'A') && (digit <= 'F')) {
+                               digit = (digit - 0101 + 10) ;
+                                       break ;
+                               }
+                       if ((digit >= 'a') && (digit <= 'f')) {
+                               digit = digit - 0141 + 10 ;
+                               break ;
+                               }
+                       return(0) ;
+                       break ;
+                       }
+               }
+       value = (value * base) + digit ;
+       }
+return (sign ? -value : value) ;
+}
+/*             */
+init() {
+/*
+*  Initialization.
+*  Initialize MBA 0 (disk) .
+*  Set up MBA 0  map register to map a 
+*    transfer of 'BUFSIZ' bytes.
+*/
+extern char end ;
+register int page , *mp0 , i ;
+M0_cr->reg = MBAinit ; /* MBA 0 init */
+RPptr = RP + (dunit * 32 * 4) ; /* start of RP reg's for drive */
+if ((*(RPptr+RP_sr) & RP_MOL) == 0) {
+       putlin("unit not online") ;
+       return(-1) ;
+       }
+*(RPptr+RP_cr) = RP_RIP | RP_GO ; /* drive preset - sets vv */
+*(RPptr+RP_off) = RP_FMT ; /* set format bit */
+i = *(RPptr+RP_dt)&0777 ;  /* get disk type */
+if (i==RP6typ) { /* RP06 */
+       rpsec=RP6SEC; rpcyl=RP6CYL; rptrk=RP6TRK;
+       }
+else {
+       if (i==RM3typ) {
+               rpsec=RM3SEC; rpcyl=RM3CYL; rptrk=RM3TRK;
+               }
+       else return(-1);
+       }
+bufptr = (int)(&end+511)&017777777000 ; /* buffer ptr */
+page = (int)((int)bufptr>>9) & 017777777 ;
+mp0 = M0_map ;
+for (i = 0 ; i < NB ; i++)
+       (*mp0++) = 0x80000000 | page++ ;
+(*mp0++)=0;
+ecount = daterr = 0 ;
+return(0) ;
+}
+/*             */
+dread()
+{
+/*
+*  Function to read 'BUFSIZ' bytes to buffer pointed to
+*    by 'bufptr'.
+*/
+register int i , j ;
+*(RPptr+RP_cyl) = dskoff/RP6ST ; /* cylinder no. */
+i = dskoff%RP6ST ;
+j = (i/rpsec)<<8 ; /* track */
+*(RPptr+RP_stk) = j | (i%rpsec) ; /* sector : track */
+i = min(NB,count);
+M0_bc->reg = (-(i*BLKSIZ)) ;
+M0_var->reg = 0 ; /* virt addr reg = map no. + byte off */
+rini :
+*(RPptr+RP_cr) = RP_DC | RP_GO ; /*  RP06 drive clear function code */
+dwait() ;
+*(RPptr+RP_cr) = RP_RED | RP_GO ; /* read */
+dwait() ; /* wait for i/o to finish */
+if (i = mbaerr(M0)) {
+       /* don't abort on MBA errors - stat reg has been cleared */
+       }
+if (i = derror(RPptr)) { /* error */
+       putlin("- - - - - - -") ;
+       putstr("read error") ;
+       stmes(i) ;
+       dadmes(RPptr) ;
+       if (i & RP_DCK) { /* Data Check Error */
+               daterr++ ;
+               putlin("Data Check") ;
+               if (i & RP_ECH) { /* ECC Hard Error */
+                       putlin("ECC non-recov") ;
+                       ecount++ ;
+                       }
+               else { /* ECC recoverable */
+                       ECCrcv(RPptr) ;
+                       }
+               if (M0_bc->reg) { /* more i-o to complete */
+                       j = (*(RPptr+RP_stk));
+                       i = (j>>8) & 0x1f;
+                       j = j & 0x1f;
+                       if (j>=rpsec) /*sector */
+                               j = 0;
+                       if (i>=rptrk) /* track */
+                               i = 0;
+                       *(RPptr+RP_stk) = (i<<8) | j;
+                       goto rini ;
+                       /* status reg cleared by Drive Clear */
+                       }
+               }
+       else { /* non-Data Check error */
+               ecount++ ;
+               }
+       if (ecount > MAXERR) return(-1) ;
+       }
+return(0) ; /* normal return */
+}
+/*             */
+dwait() {
+/*
+* Function to wait MBA 0 RP06 disc unit to be ready.
+*/
+while ((*(RPptr+RP_sr)&RP_DRY) == 0) ;
+}
+/*             */
+derror()
+{
+/*
+*  Function to check for MBA 0 RP06 error.
+*/
+if (*(RPptr+RP_sr) & RP_ERR) return(*(RPptr+RP_er1) & 0177777) ;
+return(0) ;
+}
+/*             */
+halt()
+{
+asm("  halt") ;
+}
+/*             */
+l2a(val,rptr)
+register int val ;
+register char *rptr ;
+{
+register int i ;
+register char *tp ;
+int knt ;
+char tmp[20] , sign ;
+knt = sign = 0 ;
+if (val < 0) {
+       sign++ ;
+       val = (-val) ;
+       }
+tp = tmp ;
+loop :
+       knt++ ;
+       i = val/10  ;  /*  quotient & base 10 */
+       (*tp++) = val%10 + '0' ; /*  ascii remainder  */
+       val = i ;
+       if (val == 0) {
+               /*  done  dividing  */
+               if (sign) { knt++ ; (*tp++) = '-' ; }
+               for (i = knt ; i ; i--)
+                       (*rptr++) = tmp[i-1] ;
+               (*rptr++) = '\0' ;
+               return(knt) ;
+               }
+       else goto loop ;
+}
+/*             */
+dadmes(dptr)
+register int *dptr ;
+{
+register char *mesp ;
+register int i ;
+mesp = " cyl     trk     sec    " ;
+i = l2x(*(dptr+RP_cyl) & 01777,&mesp[5]) ;
+blnkit(&mesp[5+i],4-i) ;
+i = l2x((*(dptr+RP_stk)>>8) & 037 , &mesp[13]) ;
+blnkit(&mesp[13+i],3-i) ;
+i = l2x(*(dptr+RP_stk)&037,&mesp[21]) ;
+blnkit(&mesp[21+i],3-i) ;
+putlin(mesp) ;
+}
+/*             */
+l2x(val,rptr)
+register int val ;
+register char *rptr ;
+{
+register int i , j ;
+register char *tp ;
+int knt ;
+char tmp[20] , sign ;
+knt = sign = 0 ;
+if (val < 0) {
+       sign++ ;
+       val = (-val) ;
+       }
+tp = tmp ;
+loop :
+       knt++ ;
+       i = val/16  ;  /*  quotient & base 16 */
+       j = val%16 ;
+       (*tp++) = j + (j<10?0x30:0x57) ;
+       val = i ;
+       if (val == 0) {
+               /*  done  dividing  */
+               if (sign) { knt++ ; (*tp++) = '-' ; }
+               for (i = knt ; i ; i--)
+                       (*rptr++) = tmp[i-1] ;
+               (*rptr++) = '\0' ;
+               return(knt) ;
+               }
+       else goto loop ;
+}
+/*             */
+blnkit(mp,cc)
+register char *mp ;
+register int cc ;
+{
+while (cc--)
+       (*mp++) = ' ' ;
+}
+/*             */
+stmes(code)
+int code ;
+{
+putstr(" : err reg : ") ;
+RPE_print(code) ;
+}
+/*             */
+mbaerr(mba)
+register int *mba ;
+{
+register int i ;
+if ((i = (*(mba+M_st))) != MBA_DTC) {
+       putlin("- - - - - -") ;
+       putstr("MBA error : status reg : ") ;
+       MBAS_print(i) ;
+       *(mba+M_st) = (-1) ;
+       return(i) ;
+       }
+return(0) ;
+}
+/*             */
+ECCrcv(dptr)
+register int *dptr ;
+{
+/*
+*  Do ECC error recovery on disk whose register set is pointed
+*  to by 'dptr'.
+*  'mbaerr()' has cleared MBA status reg.
+*  With ECC enabled, disk read has stopped after sector with bad
+*  data. After correction of data, return to 'dread()' which will
+*  continue read of track if more sectors to do.
+*  Return 0.
+*/
+register unsigned int pos , pat ;
+register unsigned short *wordp ;
+unsigned int ll ;
+struct { short wlo , whi ; } ;
+char tmp[50] ;
+pat = (*(dptr+RP_Epat)) & 0xffff ; /* ECC pattern reg */
+pos = (*(dptr+RP_Epos)) & 0xffff ; /* ECC position reg */
+putstr("pat : ") ;
+ul2x(pat,tmp) ;
+putlin(tmp) ;
+putstr("pos : ") ;
+ul2x(pos,tmp) ;
+putlin(tmp) ;
+wordp = bufptr ;   /* ptr to buffer */
+/*
+*  'BUFSIZ' bytes are read on each read into buffer pointed to
+*  by 'bufptr'. MBA byte count reg has neg. no. of bytes remaining
+*  in read if this read error was not in the last sector to be
+*  read.
+*/
+/* calculate buffer location of faulty data */
+wordp = (char *)wordp + (BUFSIZ + ((M0_bc->reg)>>16) - BLKSIZ) ; /* sector in buffer */
+wordp = wordp +  ((pos-1)>>4) ; /* word within sector */
+/* burst pattern may be across word boundary */
+ll = (*wordp) + ((*(wordp+1))<<16) ;
+putstr("bad data  : ") ;
+ul2x(ll,tmp) ;
+putlin(tmp) ;
+pat = pat<<((pos%16)-1) ;
+ll = ll^pat ; /* correction */
+putstr("good data : ") ;
+ul2x(ll,tmp) ;
+putlin(tmp) ;
+/* put good data back in buffer */
+*wordp = ll.wlo ;
+*(wordp+1) = ll.whi ;
+return(0) ;
+}
+/*             */
+ul2x(val,rptr)
+register unsigned int val ;
+register char *rptr ;
+{
+register unsigned int i , j ;
+register char *tp ;
+int knt ;
+char tmp[20] ;
+unsigned int udiv() , urem() ;
+knt =  0 ;
+tp = tmp ;
+loop :
+       knt++ ;
+       /* use unsigned integer divide & remainder routines */
+       i = udiv(val,16)  ;  /*  quotient & base 16 */
+       j = urem(val,16) ;
+       (*tp++) = j + (j<10?0x30:0x57) ;
+       val = i ;
+       if (val == 0) {
+               /*  done  dividing  */
+               for (i = knt ; i ; i--)
+                       (*rptr++) = tmp[i-1] ;
+               (*rptr++) = '\0' ;
+               return(knt) ;
+               }
+       else goto loop ;
+}
diff --git a/usr/src/standalone/stmes.c b/usr/src/standalone/stmes.c
new file mode 100644 (file)
index 0000000..a114353
--- /dev/null
@@ -0,0 +1,9 @@
+stmes(code)
+int code ;
+{
+register char *mesp ;
+mesp = " : err reg         " ;
+l2x(code,&mesp[11]) ;
+putlin(mesp) ;
+}
diff --git a/usr/src/standalone/tdcopy.c b/usr/src/standalone/tdcopy.c
new file mode 100644 (file)
index 0000000..b221eca
--- /dev/null
@@ -0,0 +1,265 @@
+#include "MBA.h"
+#include "RP.h"
+#include "TM.h"
+# include "CON.h"
+# define BLKMAX  32768
+# define MIN(a,b) (a<b?a:b)
+#define MAXTER 10  /*  max. no. consec. tape errors */
+/*             */
+int blksiz , tfoff , tboff , dboff , tunit , dens ;
+int count , *tmMBA , *rpMBA , dblks , wsize ;
+unsigned int ins , outs ;
+unsigned int nread  , bytoff , error ;
+int *RPptr , *TMptr ;
+int rpcyl,rptrk,rpsec;
+char input[150] , *bufptr , retry ;
+/*             */
+main() {
+register int i ;
+/*
+*  Stand-alone program to copy TM[23]/TE16 mag tape to
+*  RP06/RM03 disk.
+*  User specifies tape and disk MBA no.'s, tape and disk unit no.'s,
+*  tape block size, tape file offset, tape block offset in file,
+*  and disk sector offset.
+*/
+
+putlin("tdcopy : TM03 tape-to-disk copy") ;
+putnl() ;
+tmbno :
+count = getval("tape MBA #") ;
+if ((count < 0) || (count > MAXMBA-1)) goto tmbno ;
+tmMBA = TMptr = (int *)(M_BASE + (count*NEXSPC)) ; /* TM02 MBA addr */
+tuni :
+tunit = getval("tape unit #") ;
+if ((tunit < 0) || (tunit > 7)) goto tuni ;
+TMptr = (int *)((int)TMptr + (tunit*EXTSIZ) + M_extern) ; /*  ptr. to MBA
+               ext. reg set for this TM02 unit */
+/*
+*  ignore density prompt for tape read - TM02 recognizes and adjusts
+*  for NRZ or PE input (800 or 1600 BPI)
+gden :
+dens = getval("tape density(8 or 16)") ;
+if (dens == 0) dens = TM_D800 ;
+else if ((dens != 8)&&(dens!=16)) goto gden ;
+*/
+dens = (dens==16?TM_D1600:TM_D800) ;
+toff :
+tfoff = getval("tape file offset") ;
+if (tfoff < 0) goto toff ;
+gtbo :
+tboff = getval("tape block offset") ;
+if (tboff < 0) goto gtbo ;
+putnl() ;
+gdm :
+count = getval("disk MBA #") ;
+if ((count < 0) || (count > MAXMBA-1)) goto gdm ;
+rpMBA = RPptr = (int *)(M_BASE + (count*NEXSPC)) ; /* RP06 MBA addr */
+dun :
+count = getval("disk unit") ;
+if ((count > 7) || (count < 0)) goto dun ;
+RPptr = (int *)((int)RPptr +  (count*EXTSIZ) + M_extern) ; /* ptr to MBA ext reg set for
+                       this RP06 unit */
+doff :
+dboff = getval("disk block offset") ;
+putnl() ;
+gknt :
+count = getval("no. of input blocks") ;
+if (count < 0) goto gknt ;
+if (init()) {
+       putlin("init() error") ;
+       return(-1) ;
+       }
+if ((dboff < 0) || (dboff > MAXSEC-1)) goto doff ;
+if (tapfil(TMptr,tfoff)) {
+       tioerr :
+       putlin("tape positioning error") ;
+       return(-1) ;
+       }
+if (tapfsp(TMptr,tboff)) goto tioerr ;
+/* read in 1st block of tape file to determine block size */
+nread = 1 ;
+blksiz = 65536 ;
+for (retry=0,i=10,error=0;i;i--) {
+       if ((tread()&TM_FCE) != TM_FCE) {
+               if (++error > MAXTER)
+                       goto tioerr;
+               }
+       else break ;
+       }
+retry++;
+blksiz = (*(TMptr+TM_fc)) & 0xffff ;
+pdstr(" = tape block size",blksiz) ;
+nread = M_BCMAX/blksiz ; /* no. of tape reads to fill input buffer */
+wsize = nread * blksiz ; /* no. bytes each write to disc */
+dblks = wsize/512 ; /* no. of disc blocks on each write */
+*(TMptr+TM_cs1) = TM_DCLR | TM_GO ;
+twait(TMptr) ;
+if (tapbsp(TMptr,1)) goto tioerr ;
+putnl() ;
+for (error = 0 ; (error == 0) && (count > 0) ; count -= nread ) {
+       if (i=tread(TMptr)) {
+               putlin("tape i/o error") ;
+               TME_print(i) ;
+               goto ioerr ;
+               }
+       ins += nread ;  /*  count of tape blocks input */
+       if (i=dwrite(RPptr)) {
+               putlin("disk i/o error") ;
+               RPE_print(i) ;
+               ioerr :
+                       error++ ;
+                       continue ;
+               }
+       outs += dblks ;  /*  count of disk blocks output */
+}
+fini :
+/*  no rewind on normal termination */
+if (error == 0) putlin("normal termination") ;
+else taprew(TMptr) ;
+pdstr(" input blocks read",ins) ;
+pdstr(" output blocks written",outs) ;
+return(0) ;
+}
+/*             */
+init() {
+/*
+*  Initialization.
+*  Initialize MBA's and tape/disk units.
+*  Initialize TM2/TE16 for drive 0 , 800 BPI, PDP11, etc.
+*  Set up MBA  map registers to map a max.
+*    transfer of 'M_BCMAX' bytes.
+*/
+register int *mp0 , *mp1 , i , page ;
+extern char *end ;
+*(rpMBA+M_cr) = MBAinit ; /* init. RP06 MBA */
+if (rpMBA != tmMBA)
+       *(tmMBA+M_cr) = MBAinit ;
+if ((*(RPptr+RP_sr) & RP_MOL) == 0) {
+       putlin("disk unit not online") ;
+       return(-1) ;
+       }
+*(RPptr+RP_cr) = RP_RIP | RP_GO ; /* preset */
+dwait(RPptr) ;
+if (i=derror(RPptr)) {
+       putlin("disk init error") ;
+       RPE_print(i) ;
+       return(-1) ;
+       }
+*(RPptr+RP_off) = RP_FMT ; /* set format bit */
+i = *(RPptr+RP_dt)&0777 ;  /* get disk type */
+if (i==RP6typ) { /* RP06 */
+       rpsec=RP6SEC; rpcyl=RP6CYL; rptrk=RP6TRK;
+       }
+else {
+       if (i==RM3typ) {
+               rpsec=RM3SEC; rpcyl=RM3CYL; rptrk=RM3TRK;
+               }
+       else return(-1);
+       }
+/* set TM03 unit no., density, PDP11 normal mode, odd parity
+       abort on error */
+*(TMptr+TM_tc) = tunit | dens | TM_PNOR | TM_EABO ;
+*(TMptr+TM_cs1) = TM_DCLR | TM_GO ;
+twait(TMptr) ;
+if (i=terror(TMptr)) {
+       tierr :
+       putlin("tape init error") ;
+       TME_print(i) ;
+       return(-1) ;
+       }
+if ((*(TMptr+TM_ds) & TM_MOL) == 0) {
+       putlin("tape unit not online") ;
+       return(-1) ;
+       }
+*(TMptr+TM_cs1) = TM_RWND | TM_GO ;
+twait(TMptr) ;
+if (i=terror(TMptr)) goto tierr ;
+bufptr = (char *)((((int)&end)+511)&017777777000) ;
+page = ((int)((int)bufptr>>9)&017777777) | 0x80000000 ; /* SBI page no. */
+mp0 = (int *)((int)tmMBA + (int)(M_map*4)) ;
+mp1 = (int *)((int)rpMBA + (int)(M_map*4)) ;
+for (i = ((M_BCMAX+511)/512)+1 ; i ; i--,page++) {
+       (*mp0++) = page ;
+       (*mp1++) = page ;
+       }
+return(0) ;
+}
+/*             */
+tread()
+{
+/*
+*  Function to read TM2/TE16 tape drive, 'blksiz' bytes each
+*  read, and 'nread' reads.
+*/
+register int i, j , k , *t , *m , teknt ;
+m = tmMBA ;
+t = TMptr ;
+for (i=MIN(nread,count),j=0,teknt=0 ; i ; i--,j++) {
+       trloop :
+       *(m+M_var) = j * blksiz ;
+       *(m+M_bc) = (-blksiz) ; /* MBA byte count reg */
+       *(t+TM_cs1) = TM_REDF | TM_GO ; /* read forward */
+       twait(t) ; /* wait for ready */
+       if (k=terror(t)) {
+               if ((++teknt > MAXTER) || (retry == 0)) return(k);
+               *(t+TM_cs1) = TM_DCLR | TM_GO ;
+               twait(t);
+               if (k=tapbsp(t,1)) return(k);
+               goto trloop;
+               }
+       }
+return(0) ; /* normal return */
+}
+/*             */
+dwrite()
+{
+/*
+*  Function to write 'wsize' bytes to disc
+*  from buffer '*bufptr'.
+*/
+register int i , j , *m , *d ;
+m = rpMBA ;
+d = RPptr ;
+*(d+RP_cr) = RP_DC | RP_GO ; /* drive clear */
+dwait(d) ;
+*(d+RP_cyl) = dboff/RP6ST ; /* cylinder no. */
+i = dboff%RP6ST ;
+j = (i/rpsec)<<8 ; /* track */
+*(d+RP_stk) = j | (i%rpsec) ; /* sector : track */
+*(m+M_bc) = (count<nread?-(count*512):(-wsize)) ; /* byte count */
+*(m+M_var) = 0 ; /* virt addr reg = map no. + byte off */
+*(d+RP_cr) = RP_WR | RP_GO ;
+dwait(d) ;
+if (i=derror(d)) return(i) ; /* error */
+dboff += dblks ;  /*  point to next disc sector */
+return(0) ; /* normal return */
+}
diff --git a/usr/src/standalone/tpboot.s b/usr/src/standalone/tpboot.s
new file mode 100644 (file)
index 0000000..3298307
--- /dev/null
@@ -0,0 +1,264 @@
+#
+# Tape boot program to load and transfer
+#   to a program on a 9-tr mag tape in 
+#    UNIX 'tp' format on the VAX machine.
+#  This program is the boot block on the mag tape.
+#
+#  Entry is made to the desired file via 'calls $0,entrypt'
+#    so return can be 'ret'.
+#
+       .set    core,50  #  assume 50 K words avail.
+       .set    BOOBLK,1 #  no. tape blocks for boot
+       .set    RELOC,0x50000
+       .set    HDRSIZ,040  #  size of file header for VAX
+       .set    MAGIC,0410  #  file type id in header
+       .set    ENTSIZ,64  #  size of 1 TP dir entry, bytes
+       .set    PTHSIZ,32  #  size of TP path name, bytes
+       .set    BLKSIZ,512  #  tape block size, bytes
+       .set    NUMDIR,24  #  no. of dir blocks on tape
+       .set    ENTBLK,8  #  no. of dir entries per tape block
+       .set    NL,012  #  new-line char
+       .set    CR,015  # carriage-return char
+       .set    MAXC,65535  #  max. count for 'movc' op
+       .set    TSIZ,4          # text size
+       .set    DSIZ,8          # data size
+       .set    BSIZ,12         # bss size
+       .set    TENT,024  #  task header entry loc
+#
+       .set    RXCS,32
+       .set    RXDB,33
+       .set    TXCS,34
+       .set    TXDB,35
+       .set    RXCS_DONE,0x80
+       .set    TXCS_RDY,0x80
+       .set    TXCS_pr,7  #  bit position of TXCS ready bit
+       .set    RXCS_pd,7  #  bit position of RXCS done bit
+#
+       .set    FILSIZ,38  #  dir offset for file size
+       .set    BNUM,44  #  dir offset for start block no.
+#
+#  MBA registers
+       .set    MBA1,0x20012000  #  MBA 1 device reg's
+       .set    M_cfg,0  # MBA config reg
+       .set    M_cr,4  #  MBA control reg
+       .set    M_stat,8  #  MBA status reg
+       .set    M_var,12  #  MBA virt addr reg
+       .set    M_bc,16  #  MBA byte count reg
+       .set    M_map,0x800  #  start of MBA map reg's
+       .set    MBAinit,1  #  MBA init bit in MBA control reg
+#
+#  TM02  registers
+       .set    TM02,MBA1+0x400   #  start of TM02 reg's
+       .set    TM_cs1,0  #  TM02 control 1 reg
+       .set    TM_ds,4  #  status reg
+       .set    TM_er,8  #  error reg
+       .set    TM_as,16  #  attention summary
+       .set    TM_fc,20  #  frame count
+       .set    TM_tc,36  #  TM02 tape control
+#  Function codes for TM02 control reg 1
+       .set    GO,1  #  GO bit
+       .set    RWND,6  # rewind, on-line
+       .set    DCLR,010  #  drive clear
+       .set    SFWD,030  #  space forward
+       .set    SREV,032  # space reverse
+       .set    WRIF,060  # write forward
+       .set    REDF,070  #  read forward
+#  misc bits
+       .set    ERR,040000  #  composite error bit in status reg
+       .set    TCHAR,011700  #  drive 0, odd parity, PDP11,
+#                              800 BPI NRZ, abort on error - for
+#                              tape control reg
+       .set    DRDY,0200  #  TM02/drive ready in status reg
+       .set    TM_pd,7  #  bit position of TM DRDY bit
+       .set    TM_pe,14  #  bit position of TM ERROR bit
+#
+       .set    tapa,-4         # desired tape addr
+       .set    mtapa,-8        # current tape addr
+       .set    name,-8-PTHSIZ  # operator-typed file name
+#
+       .set    rMBA,r10
+       .set    rTM,r11
+#  system initialization
+init:
+       movl    $RELOC,fp       # core loc to which to move this program
+       addl3   $name,fp,sp     # set stack pointer, leaving room for locals
+       clrl    r0
+       cmpl    (r0),$MAGIC
+       bneq    rel
+       movl    $HDRSIZ,r0      #  skip header
+rel :
+       movc3   $end,(r0),(fp)  #  move boot up to relocated position
+       jmp     start+RELOC  #  jump to relocated code
+#
+start :
+       movab   *$MBA1,%rMBA
+       movl    $MBAinit,M_cr(%rMBA)  #  MBA initialize
+       movab   *$TM02,%rTM
+       movl    $TCHAR,TM_tc(%rTM)  #  drive no., etc.
+       movl    $DCLR+GO,TM_cs1(%rTM)  #  drive clear
+       bsbw    rew     # rewind input tape
+       movab   name(fp),r4  #  start of filename storage
+       movzbl  $'=,r0  #  prompt character
+       bsbw    putc    # output char to main console
+#
+gfil :
+       movl    r4,r1   # loc at which to store user-specified file name
+nxtc :
+       bsbw    getc    # get input char's in file name
+       cmpb    r0,$NL  #  terminator ?
+       beql    nullc
+       cmpb    r0,$'@  # r0 = return character
+       beql    gfil
+       movb    r0,(r1)+
+       cmpb    r0,$'#
+       bneq    nxtc
+       tstw    -(r1)   # subl2 $2,r1
+       cmpl    r1,r4
+       blss    gfil
+       brb     nxtc
+nullc:
+       subl3   r4,r1,r9        # size of path name
+       beql    start           # dumb operator
+#
+#  user-specified TP filename has been stored at name(fp)
+#
+#  read in entire tp directory contents into low core
+#  'cmpc[35]' instruction uses reg's 0-3
+#
+dirred :
+       movl    $BOOBLK,tapa(fp)        # desired tape block no.
+       movl    $(NUMDIR*BLKSIZ),r6     # no. bytes in total dir
+       bsbw    taper   # read no. bytes indicated
+#
+#  search entire directory for user-specified file name
+       clrl    r5      # dir buff loc = 0
+nxtdir :
+       cmpc3   r9,(r5),(r4)  #  see if dir entry matches filename
+       beql    fndfil  # found match
+       acbl    $NUMDIR*BLKSIZ-1,$ENTSIZ,r5,nxtdir  #  see if done with tp dir
+#
+       brb             start   # entry not in directory - start all over
+#
+#  found desired tp dir entry
+fndfil :
+       movzwl  BNUM(r5),tapa(fp)       #  start block no., 2 bytes
+       movzwl  FILSIZ(r5),r6  #  low 2 bytes file size
+       insv    FILSIZ-1(r5),$16,$8,r6  #  file size, high byte
+       cmpl    r6,$RELOC-512  #  check if file fits below stack
+       blss    filok  #  file o.k.
+       brw             start  #  file too large
+#
+#  time to read in desired file from tape
+filok :
+       movl    r6,r7  #  save r6
+       bsbb    taper
+       bsbw    rew
+#
+#  if load module header exists, move down rest of load
+#    module to 0
+       clrl    r5  #  entry loc 
+       cmpl    (r5),$MAGIC             # unix a.out?
+       bneq    clrcor
+#  move start of exec image down to 0
+       clrl    r0
+       movq    TSIZ(r0),r1  #  text size and data size
+       movq    BSIZ(r0),r3  #  bss size, symbol table size
+       movl    TENT(r0),r5  #  entry loc
+       movl    r7,r6  # restore file size
+movtxt:
+       movb    HDRSIZ(r0),(r0)+
+       sobgtr  r6,movtxt
+#  move data up to page boundary
+       extzv   $0,$9,r1,r0             # byte-in-page of last text byte
+       beql    clrcor
+       subl3   r0,$512,r0              # room needed
+       addl2   r2,r1                   # current end+1 of data
+       addl2   r1,r0                   # new end+1 of data
+       movl    r0,r7                   # start here on bssz clearing
+movdat:
+       movb    -(r1),-(r0)
+       sobgtr  r2,movdat
+#
+#  clear core up to stack
+clrcor :
+       subl3   r7,$RELOC-4,r0  #  no. bytes to clear
+clrit :
+       clrb    (r7)+
+       sobgtr  r0,clrit
+#
+#  time to jump to start of file & execute
+       calls   $0,(r5)
+       brw     start   # returned from execution - start all over
+#
+#
+#  taper: movcTAPE (r6),tapa(fp),0
+#
+rew2 :
+       bsbb    rew             # beginning of tape
+taper0:
+       bsbb    rrec    # advance 1 block; (we never want block 0)
+taper :
+       clrl    r0  #  SBI page no.
+       cmpl    mtapa(fp),tapa(fp)      # current position .vs. desired
+       bgtr    rew2
+       blss    taper0
+rloop :
+       bsbb    rrec
+       acbl    $1,$-BLKSIZ,r6,rloop
+       rsb
+#
+#  subr to read 1 block from mag tape into page (r0)
+#
+rrec :
+       movl    TM_ds(%rTM),r2
+       bbc     $TM_pd,r2,rrec  #  TM02 & drive ready ?
+       movl    $-BLKSIZ,M_bc(%rMBA)  #  byte count
+       bisl3   $0x80000000,r0,M_map(%rMBA)  #  MBA map entry = valid bit + phys page no.
+       clrl    M_var(%rMBA)  #  MBA virt addr reg = map reg no. + byte offset
+       movl    $REDF+GO,TM_cs1(%rTM)  #  read forward
+tmrdy :
+       movl    TM_ds(%rTM),r2
+       bbc     $TM_pd,r2,tmrdy  #  TM02 & device ready ?
+       movl    TM_er(%rTM),r2
+       bbc     $TM_pe,r2,donred  #  any read errors ?
+       clrl    TM_ds(%rTM)  # clear status - try to recover
+       mnegl   $1,TM_fc(%rTM)  # frame count for backspace
+       movl    $SREV+GO,TM_cs1(%rTM)  #  space reverse
+       brb     rrec
+donred :
+       incl    r0  #  next SBI page no.
+       incl    mtapa(fp)       # mag tape block position
+       rsb
+#
+#  subr to rewind mag tape
+#
+rew :
+       movl    $RWND+GO,TM_cs1(%rTM)  # rewind
+       clrl    mtapa(fp)  #  current position
+       rsb
+#
+#  subroutines to do char i-o with main tty console
+#
+getc :
+       mfpr    $RXCS,r0
+       bbc     $RXCS_pd,r0,getc  #  receiver ready ?
+       mfpr    $RXDB,r0
+       cmpb    r0,$CR
+       bneq    putc
+       movb    $NL,r0
+#
+putc:
+       mfpr    $TXCS,r2
+       bbc     $TXCS_pr,r2,putc  #  transmitter ready ?
+       cmpb    r0,$NL
+       bneq    wbyt
+       movb    $CR,r0
+       bsbb    putc
+       clrb    r0
+       bsbb    putc
+       movb    $NL,r0
+wbyt :
+       extzv   $0,$7,r0,r0
+       mtpr    r0,$TXDB
+       rsb
+end :
diff --git a/usr/src/standalone/vrmhead.c b/usr/src/standalone/vrmhead.c
new file mode 100644 (file)
index 0000000..50e34e7
--- /dev/null
@@ -0,0 +1,71 @@
+# define VAX 1
+struct {short hiword; short loword;}; /* stupid fp-11 */
+fixl(p) register long *p;{
+       register short t;
+       t=p->hiword; p->hiword=p->loword; p->loword=t;
+}
+
+main(argc,args)
+int argc ;
+char **args ;
+{
+int ifd , ofd , nbyt , ttt;
+register char *infile , *oufile , *ap ;
+char * fbuf, zero;
+struct {
+       long magic;
+       long tlen,dlen;
+       long blen,slen,eadr,trl,drl;
+} head;
+
+char buf[512] ;
+zero = '\0';
+if (argc != 3) {
+       usage :
+               printf("usage : rmhead input output\n") ;
+               exit(1) ;
+       }
+infile = args[1] ;
+oufile = args[2] ;
+if ((ifd = open(infile,0)) < 0) {
+       ap = infile ;
+       oerr :
+               printf("%s : cannot open\n",ap) ;
+               exit(1) ;
+       }
+if ((ofd = creat(oufile,0777)) < 0) {
+       ap = oufile ;
+       goto oerr ;
+       }
+read(ifd,&head,sizeof head);
+#ifndef VAX
+fixl(&head.tlen); fixl(&head.dlen);
+#endif
+if (seek(ifd,sizeof head,0) < 0) {
+       printf("input seek error\n") ;
+       unlnk :
+               unlink(oufile) ;
+                       exit(1) ;
+       }
+fbuf=sbrk(4096);
+while (head.tlen>0) {
+       if (head.tlen>4096) nbyt=4096; else nbyt=head.tlen;
+       read(ifd,fbuf,nbyt);
+       write(ofd,fbuf,nbyt);
+       head.tlen -= nbyt;
+}
+while (nbyt&0777) {write(ofd,&zero,1); ++nbyt;}
+while (head.dlen>0) {
+       if (head.dlen>4096) nbyt=4096; else nbyt=head.dlen;
+       read(ifd,fbuf,nbyt);
+       write(ofd,fbuf,nbyt);
+       head.dlen -= nbyt;
+}
+return(0);
+}
diff --git a/usr/src/sys/dev/cat.c b/usr/src/sys/dev/cat.c
new file mode 100644 (file)
index 0000000..194cabd
--- /dev/null
@@ -0,0 +1,75 @@
+#
+/*
+ */
+
+/*
+ * GP DR11C driver used for C/A/T
+ */
+
+#include "../h/param.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/tty.h"
+#include "../h/uba.h"
+
+#define        CATADDR ((struct catdev *)(UBA0_DEV+0167770))
+#define        PCAT    (PZERO+9)
+#define        CATHIWAT        100
+#define        CATLOWAT        30
+
+struct {
+       int     catlock;
+       struct  clist   oq;
+} cat;
+
+struct catdev {
+       short   catcsr;
+       short   catbuf;
+};
+
+ctopen(dev)
+{
+       if (cat.catlock==0) {
+               cat.catlock++;
+               CATADDR->catcsr |= IENABLE;
+       } else
+               u.u_error = ENXIO;
+}
+
+ctclose()
+{
+       cat.catlock = 0;
+       catintr();
+}
+
+ctwrite(dev)
+{
+       register c;
+       extern lbolt;
+
+       while ((c=cpass()) >= 0) {
+               spl5();
+               while (cat.oq.c_cc > CATHIWAT)
+                       sleep((caddr_t)&cat.oq, PCAT);
+               while (putc(c, &cat.oq) < 0)
+                       sleep((caddr_t)&lbolt, PCAT);
+               catintr();
+               spl0();
+       }
+}
+
+catintr()
+{
+       register int c;
+
+       if (CATADDR->catcsr&DONE) {
+               if ((c = getc(&cat.oq)) >= 0) {
+                       CATADDR->catbuf = c;
+                       if (cat.oq.c_cc==0 || cat.oq.c_cc==CATLOWAT)
+                               wakeup(&cat.oq);
+               } else {
+                       if (cat.catlock==0)
+                               CATADDR->catcsr = 0;
+               }
+       }
+}
diff --git a/usr/src/sys/dev/dc.c b/usr/src/sys/dev/dc.c
new file mode 100644 (file)
index 0000000..513292b
--- /dev/null
@@ -0,0 +1,241 @@
+#include "../h/param.h"
+#include "../h/conf.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/tty.h"
+#include "../h/systm.h"
+#include "../h/uba.h"
+
+/*
+ * Base address of DC-11's. Minor device  i  is at
+ * DCADDR + 10*i.
+ */
+#define        DCADDR  (struct device *)(UBA0_DEV+0174000)
+
+/*
+ * Number of DC's for which table space is allocated.
+ */
+#define        NDC11   4
+
+/*
+ * Control bits in device registers
+ */
+#define        CDLEAD  01
+#define        CARRIER 04
+#define        SPEED1  010
+#define        STOP1   0400
+#define        RQSEND  01
+#define        PARITY  040
+#define        ERROR   0100000
+#define        CTRANS  040000
+#define        RINGIND 020000
+
+
+struct tty dc11[NDC11];
+
+struct device {
+       short dcrcsr;
+       short dcrbuf;
+       short dctcsr;
+       short dctbuf;
+};
+
+/*
+ * Input-side speed and control bit table.
+ * Each DC11 has 4 speeds which correspond to the 4 non-zero entries.
+ * The table index is the same as the speed-selector
+ * number for the DH11.
+ * Attempts to set the speed to a zero entry are ignored.
+ */
+int dcrstab[] = {
+       0,              /* 0 baud */
+       0,              /* 50 baud */
+       0,              /* 75 baud */
+       0,              /* 110 baud */
+       01101,          /* 134.5 baud: 7b/ch, speed 0 */
+       0111,           /* 150 baud: 8b/ch, speed 1 */
+       0,              /* 200 baud */
+       0121,           /* 300 baud: 8b/ch, speed 2 */
+       0,              /* 600 baud */
+       0131,           /* 1200 baud */
+       0,              /* 1800 baud */
+       0,              /* 2400 baud */
+       0,              /* 4800 baud */
+       0,              /* 9600 baud */
+       0,              /* X0 */
+       0,              /* X1 */
+};
+
+/*
+ * Transmitter speed table
+ */
+int dctstab[] = {
+       0,              /* 0 baud */
+       0,              /* 50 baud */
+       0,              /* 75 baud */
+       0,              /* 110 baud */
+       0501,           /* 134.5 baud: stop 1 */
+       0511,           /* 150 baud */
+       0,              /* 200 baud */
+       0521,           /* 300 baud */
+       0,              /* 600 baud */
+       0531,           /* 1200 baud */
+       0,              /* 1800 baud */
+       0,              /* 2400 baud */
+       0,              /* 4800 baud */
+       0,              /* 9600 baud */
+       0,              /* X0 */
+       0,              /* X1 */
+};
+
+/*
+ * Open a DC11, waiting until carrier is established.
+ * Default initial conditions are set up on the first open.
+ * t_state's CARR_ON bit is a pure copy of the hardware
+ * CARRIER bit, and is only used to regularize
+ * carrier tests in general tty routines.
+ */
+dcopen(dev, flag)
+dev_t dev;
+{
+       register struct tty *tp;
+       register struct device *addr;
+       extern int klstart();
+       int s;
+
+       if (minor(dev) >= NDC11) {
+               u.u_error = ENXIO;
+               return;
+       }
+       tp = &dc11[minor(dev)];
+       addr = DCADDR + minor(dev);
+       tp->t_addr = (caddr_t)addr;
+       tp->t_state |= WOPEN;
+       s = spl5();
+       addr->dcrcsr |= IENABLE|CDLEAD;
+       if ((tp->t_state&ISOPEN) == 0) {
+               tp->t_erase = CERASE;
+               tp->t_kill = CKILL;
+               addr->dcrcsr = IENABLE|CDLEAD|SPEED1;
+               addr->dctcsr = IENABLE|SPEED1|STOP1|RQSEND;
+               tp->t_state = ISOPEN | WOPEN;
+               tp->t_flags = ODDP|EVENP|ECHO;
+               tp->t_oproc = klstart;
+       }
+       if (addr->dcrcsr & CARRIER)
+               tp->t_state |= CARR_ON;
+       splx(s);
+       while ((tp->t_state & CARR_ON) == 0)
+               sleep(&tp->t_rawq, TTIPRI);
+       ttyopen(dev, tp);
+}
+
+/*
+ * Close a dc11
+ */
+dcclose(dev)
+dev_t dev;
+{
+       register struct tty *tp;
+
+       tp = &dc11[minor(dev)];
+       if (tp->t_state&HUPCLS)
+               ((struct device *)(tp->t_addr))->dcrcsr &= ~CDLEAD;
+       ttyclose(tp);
+}
+
+/*
+ * Read a DC11
+ */
+dcread(dev)
+dev_t dev;
+{
+       ttread(&dc11[minor(dev)]);
+}
+
+/*
+ * Write a DC11
+ */
+dcwrite(dev)
+dev_t dev;
+{
+       ttwrite(&dc11[minor(dev)]);
+}
+
+/*
+ * DC11 transmitter interrupt.
+ */
+dcxint(dev)
+dev_t dev;
+{
+       register struct tty *tp;
+
+       tp = &dc11[minor(dev)];
+       ttstart(tp);
+       if (tp->t_outq.c_cc == 0 || tp->t_outq.c_cc == TTLOWAT)
+               wakeup(&tp->t_outq);
+}
+
+/*
+ * DC11 receiver interrupt.
+ */
+dcrint(dev)
+dev_t dev;
+{
+       register struct tty *tp;
+       register int c, csr;
+
+       tp = &dc11[minor(dev)];
+       c = ((struct device *)(tp->t_addr))->dcrbuf;
+       /*
+        * If carrier is off, and an open is not in progress,
+        * knock down the CD lead to hang up the local dataset
+        * and signal a hangup.
+        */
+       if (((csr = ((struct device *)(tp->t_addr))->dcrcsr) & CARRIER) == 0) {
+               if ((tp->t_state&WOPEN) == 0) {
+                       ((struct device *)(tp->t_addr))->dcrcsr &= ~CDLEAD;
+                       if (tp->t_state & CARR_ON)
+                               signal(tp->t_pgrp, SIGHUP);
+                       flushtty(tp);
+               }
+               tp->t_state &= ~CARR_ON;
+               return;
+       }
+       if (csr&ERROR || (tp->t_state&ISOPEN)==0) {
+               if (tp->t_state&WOPEN && csr&CARRIER)
+                       tp->t_state |= CARR_ON;
+               wakeup(tp);
+               return;
+       }
+       csr &= PARITY;
+       if (csr&&(tp->t_flags&ODDP) || !csr&&(tp->t_flags&EVENP))
+               ttyinput(c, tp);
+}
+
+/*
+ * DC11 stty/gtty.
+ * Perform general functions and set speeds.
+ */
+dcioctl(dev, cmd, addr, flag)
+dev_t dev;
+caddr_t addr;
+{
+       register struct tty *tp;
+       register r;
+
+       tp = &dc11[minor(dev)];
+       if (ttioccom(cmd, &dc11[minor(dev)], addr, dev) == 0) {
+               u.u_error = ENOTTY;
+               return;
+       }
+       if (cmd == TIOCSETP) {
+               r = dcrstab[tp->t_ispeed];
+               if (r)
+                       ((struct device *)(tp->t_addr))->dcrcsr = r;
+               else
+                       ((struct device *)(tp->t_addr))->dcrcsr &= ~CDLEAD;
+               r = dctstab[tp->t_ospeed];
+               ((struct device *)(tp->t_addr))->dctcsr = r;
+       }
+}
diff --git a/usr/src/sys/dev/dh.c b/usr/src/sys/dev/dh.c
new file mode 100644 (file)
index 0000000..83e5ac2
--- /dev/null
@@ -0,0 +1,398 @@
+/*
+ *     DH-11 driver
+ *     This driver calls on the DHDM driver.
+ *     If the DH has no DM11-BB, then the latter will
+ *     be fake. To insure loading of the correct DM code,
+ *     lib2 should have dhdm.o, dh.o and dhfdm.o in that order.
+ */
+
+#include "../h/param.h"
+#include "../h/conf.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/tty.h"
+#include "../h/uba.h"
+
+#define        DHADDR  ((struct device *)(UBA0_DEV+0160020))
+#define        NDH11   48      /* number of lines */
+#define        DHNCH   8       /* max number of DMA chars */
+
+struct tty dh11[NDH11];
+char   dh_clist[NDH11][DHNCH];
+int    dhchars[(NDH11+15)/16];
+int    ndh11   = NDH11;
+int    dhstart();
+int    ttrstrt();
+
+/*
+ * Hardware control bits
+ */
+#define        BITS6   01
+#define        BITS7   02
+#define        BITS8   03
+#define        TWOSB   04
+#define        PENABLE 020
+/* DEC manuals incorrectly say this bit causes generation of even parity. */
+#define        OPAR    040
+#define        HDUPLX  040000
+
+#define        IENAB   030100
+#define        PERROR  010000
+#define        FRERROR 020000
+#define        XINT    0100000
+#define        SSPEED  7       /* standard speed: 300 baud */
+#define        NSILO   16
+#define        DHTIME  6
+extern int dhtimer();
+
+/*
+ * DM control bits
+ */
+#define        TURNON  03      /* CD lead + line enable */
+#define        TURNOFF 01      /* line enable */
+#define        RQS     04      /* request to send */
+
+/*
+ * Software copy of last dhbar
+ */
+int    dhsar[(NDH11+15)/16];
+
+struct device
+{
+       union {
+               short   dhcsr;
+               char    dhcsrl;
+       } un;
+       short   dhnxch;
+       short   dhlpr;
+       unsigned short  *dhcar;
+       short   dhbcr;
+       short   dhbar;
+       short   dhbreak;
+       short   dhsilo;
+};
+
+/*
+ * Open a DH11 line.
+ */
+dhopen(dev, flag)
+{
+       register struct tty *tp;
+       register d;
+       register struct device *addr;
+       static  timer_on;
+       int s;
+
+       d = minor(dev);
+       if (d >= NDH11) {
+               u.u_error = ENXIO;
+               return;
+       }
+       tp = &dh11[d];
+       addr = DHADDR;
+       addr += d>>4;
+       tp->t_addr = (caddr_t)addr;
+       tp->t_oproc = dhstart;
+       tp->t_iproc = NULL;
+       tp->t_state |= WOPEN;
+       s = spl6();
+       if (!timer_on) {
+               timer_on++;
+               timeout(dhtimer,0,DHTIME);
+       }
+       splx(s);
+       addr->un.dhcsr |= IENAB;
+       if ((tp->t_state&ISOPEN) == 0) {
+               tp->t_erase = CERASE;
+               tp->t_kill = CKILL;
+               tp->t_ispeed = SSPEED;
+               tp->t_ospeed = SSPEED;
+               tp->t_flags = ODDP|EVENP|ECHO;
+               dhparam(d);
+       }
+       if (tp->t_state&XCLUDE && u.u_uid!=0) {
+               u.u_error = EBUSY;
+               return;
+       }
+       dmopen(d);
+       (*linesw[tp->t_line].l_open)(dev,tp);
+}
+
+/*
+ * Close a DH11 line.
+ */
+dhclose(dev)
+{
+       register struct tty *tp;
+       register d;
+
+       d = minor(dev);
+       tp = &dh11[d];
+       (*linesw[tp->t_line].l_close)(tp);
+       if (tp->t_state&HUPCLS)
+               dmctl(d, TURNOFF);
+       ttyclose(tp);
+}
+
+/*
+ * Read from a DH11 line.
+ */
+dhread(dev)
+{
+register struct tty *tp;
+
+       tp = &dh11[minor(dev)];
+       (*linesw[tp->t_line].l_read)(tp);
+}
+
+/*
+ * write on a DH11 line
+ */
+dhwrite(dev)
+{
+register struct tty *tp;
+
+       tp = &dh11[minor(dev)];
+       (*linesw[tp->t_line].l_write)(tp);
+}
+
+/*
+ * DH11 receiver interrupt.
+ */
+dhrint(dev)
+{
+       register struct tty *tp;
+       register int c;
+       register struct device *addr;
+
+       addr = DHADDR;
+       addr += minor(dev);
+       while ((c = addr->dhnxch) < 0) {        /* char. present */
+               tp = &dh11[(minor(dev)<<4) + ((c>>8)&017)];
+               dhchars[minor(dev)]++;
+               if (tp >= &dh11[NDH11])
+                       continue;
+               if((tp->t_state&ISOPEN)==0) {
+                       wakeup((caddr_t)tp);
+                       continue;
+               }
+               if (c&PERROR)
+                       if ((tp->t_flags&(EVENP|ODDP))==EVENP
+                        || (tp->t_flags&(EVENP|ODDP))==ODDP )
+                               continue;
+               if (c&FRERROR)          /* break */
+                       if (tp->t_flags&RAW)
+                               c = 0;  /* null (for getty) */
+                       else
+                               c = 0177;       /* DEL (intr) */
+               (*linesw[tp->t_line].l_rint)(c,tp);
+       }
+}
+
+/*
+ * stty/gtty for DH11
+ */
+dhioctl(dev, cmd, addr, flag)
+caddr_t addr;
+{
+       register struct tty *tp;
+
+       tp = &dh11[minor(dev)];
+       if (ttioccomm(cmd, tp, addr, dev)) {
+               if (cmd==TIOCSETP||cmd==TIOCSETN)
+                       dhparam(dev);
+       } else
+               u.u_error = ENOTTY;
+}
+
+/*
+ * Set parameters from open or stty into the DH hardware
+ * registers.
+ */
+dhparam(dev)
+{
+       register struct tty *tp;
+       register struct device *addr;
+       register d;
+
+       d = minor(dev);
+       tp = &dh11[d];
+       addr = (struct device *)tp->t_addr;
+       spl5();
+       addr->un.dhcsrl = (d&017) | IENAB;
+       /*
+        * Hang up line?
+        */
+       if ((tp->t_ispeed)==0) {
+               tp->t_state |= HUPCLS;
+               dmctl(d, TURNOFF);
+               return;
+       }
+       d = ((tp->t_ospeed)<<10) | ((tp->t_ispeed)<<6);
+       if ((tp->t_ispeed) == 4)                /* 134.5 baud */
+               d |= BITS6|PENABLE|HDUPLX;
+       else if (tp->t_flags&RAW)
+               d |= BITS8;
+       else
+               d |= BITS7|PENABLE;
+       if ((tp->t_flags&EVENP) == 0)
+               d |= OPAR;
+       if ((tp->t_ospeed) == 3)        /* 110 baud */
+               d |= TWOSB;
+       addr->dhlpr = d;
+       spl0();
+}
+
+/*
+ * DH11 transmitter interrupt.
+ * Restart each line which used to be active but has
+ * terminated transmission since the last interrupt.
+ */
+dhxint(dev)
+{
+       register struct tty *tp;
+       register struct device *addr;
+       register d;
+       int ttybit, bar;
+
+       d = minor(dev);
+       addr = DHADDR;
+       addr += d;
+       bar = dhsar[d] & ~addr->dhbar;
+       addr->un.dhcsr &= ~XINT;
+       ttybit = 1;
+       for (tp = &dh11[d<<4]; bar; tp++) {
+               if(bar&ttybit) {
+                       dhsar[d] &= ~ttybit;
+                       bar &= ~ttybit;
+                       tp->t_state &= ~BUSY;
+                       if (tp->t_line)
+                               (*linesw[tp->t_line].l_start)(tp);
+                       else
+                               dhstart(tp);
+               }
+               ttybit <<= 1;
+       }
+}
+
+/*
+ * Start (restart) transmission on the given DH11 line.
+ */
+dhstart(tp)
+register struct tty *tp;
+{
+       register struct device *addr;
+       register c;
+       int s, d, nch;
+       char *cp;
+
+       s = spl5();
+       d = tp-dh11;
+       addr = (struct device *)tp->t_addr;
+       /*
+        * If it's currently active, or delaying,
+        * no need to do anything.
+        */
+       if (tp->t_state&(TIMEOUT|BUSY|TTSTOP))
+               goto out;
+       /*
+        * t_char is a delay indicator which may have been
+        * left over from the last start.
+        * Arrange for the delay.
+        */
+       if (c = tp->t_char) {
+               tp->t_char = 0;
+               timeout(ttrstrt, (caddr_t)tp, (c&0177)+6);
+               tp->t_state |= TIMEOUT;
+               goto out;
+       }
+       /*
+        * if outq.c_cc is negative, then c_cf is
+        * taken as the address of a contiguous 
+        * output buffer
+        */
+       if ((nch=tp->t_outq.c_cc)<0) {
+               if ((cp=tp->t_outq.c_cf)==NULL)
+                       goto out;
+               addr->un.dhcsrl = (d&017) | IENAB;
+               addr->dhcar = cp;
+               addr->dhbcr = nch;
+               c = 1<<(d&017);
+               addr->dhbar |= c;
+               dhsar[d>>4] |= c;
+               tp->t_state |= BUSY;
+               tp->t_outq.c_cc = 0;
+               tp->t_outq.c_cf = NULL;
+               goto out;
+       }
+
+       cp = dh_clist[d];
+       nch = 0;
+       /*
+        * Copy DHNCH characters, or up to a delay indicator,
+        * to the DMA area.
+        */
+       while (nch > -DHNCH && (c = getc(&tp->t_outq))>=0) {
+               if (c >= 0200 && (tp->t_flags&RAW)==0) {
+                       tp->t_char = c;
+                       break;
+               }
+               *cp++ = c;
+               nch--;
+       }
+       /*
+        * If the writer was sleeping on output overflow,
+        * wake him when low tide is reached.
+        */
+       if (tp->t_outq.c_cc<=TTLOWAT && tp->t_state&ASLEEP) {
+               tp->t_state &= ~ASLEEP;
+               wakeup((caddr_t)&tp->t_outq);
+       }
+       /*
+        * enable transmission when hooked to a channel
+        */
+       if (tp->t_outq.c_cc<=TTLOWAT && tp->t_chan!=NULL) {
+               mcttstart(tp);
+       }
+       /*
+        * If any characters were set up, start transmission;
+        * otherwise, check for possible delay.
+        */
+       if (nch) {
+               addr->un.dhcsrl = (d&017) | IENAB;
+               addr->dhcar = cp+nch;
+               addr->dhbcr = nch;
+               c = 1<<(d&017);
+               addr->dhbar |= c;
+               dhsar[d>>4] |= c;
+               tp->t_state |= BUSY;
+       } else
+       if (c = tp->t_char) {
+               tp->t_char = 0;
+               timeout(ttrstrt, (caddr_t)tp, (c&0177)+6);
+               tp->t_state |= TIMEOUT;
+       }
+    out:
+       splx(s);
+}
+
+dhtimer(dev)
+{
+register d,cc;
+register struct device *addr;
+
+       addr = DHADDR; d = 0;
+       do {
+               cc = dhchars[d];
+               dhchars[d] = 0;
+               if (cc > 50)
+                       cc = 32; else
+                       if (cc > 16)
+                               cc = 16; else
+                               cc = 0;
+               addr->dhsilo = cc;
+               addr += 1;
+               dhrint(d++);
+       } while (d < (NDH11+15)/16);
+       timeout(dhtimer,0,DHTIME);
+}
diff --git a/usr/src/sys/dev/dhdm.c b/usr/src/sys/dev/dhdm.c
new file mode 100644 (file)
index 0000000..d88166f
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ *     DM-BB driver
+ */
+#include "../h/param.h"
+#include "../h/tty.h"
+#include "../h/conf.h"
+#include "../h/uba.h"
+
+#define        DMADDR  ((struct device *)(UBA0_DEV+0170500))
+
+struct tty dh11[];
+int    ndh11;          /* Set by dh.c to number of lines */
+
+#define        DONE    0200
+#define        SCENABL 040
+#define        CLSCAN  01000
+#define        TURNON  03      /* CD lead, line enable */
+#define        RQS     04      /* request to send */
+#define        TURNOFF 1       /* line enable only */
+#define        CARRIER 0100
+
+struct device
+{
+       short   dmcsr;
+       short   dmlstat;
+       short   junk[2];
+};
+
+/*
+ * Turn on the line associated with the (DH) device dev.
+ */
+dmopen(dev)
+{
+       register struct tty *tp;
+       register struct device *addr;
+       register d;
+
+       d = minor(dev);
+       tp = &dh11[d];
+       addr = DMADDR;
+       addr += d>>4;
+       spl5();
+       addr->dmcsr = d&017;
+       addr->dmlstat = TURNON;
+       if (addr->dmlstat&CARRIER)
+               tp->t_state |= CARR_ON;
+       addr->dmcsr = IENABLE|SCENABL;
+       while ((tp->t_state&CARR_ON)==0)
+               sleep((caddr_t)&tp->t_rawq, TTIPRI);
+       spl0();
+}
+
+/*
+ * Dump control bits into the DM registers.
+ */
+dmctl(dev, bits)
+{
+       register struct device *addr;
+       register d, s;
+
+       d = minor(dev);
+       addr = DMADDR;
+       addr += d>>4;
+       s = spl5();
+       addr->dmcsr = d&017;
+       addr->dmlstat = bits;
+       addr->dmcsr = IENABLE|SCENABL;
+       splx(s);
+}
+
+/*
+ * DM11 interrupt.
+ * Mainly, deal with carrier transitions.
+ */
+dmint(dev)
+{
+       register struct tty *tp;
+       register struct device *addr;
+       register d;
+
+       d = minor(dev);
+       addr = DMADDR;
+       addr += d;
+       if (addr->dmcsr&DONE) {
+               tp = &dh11[(d<<4)+(addr->dmcsr&017)];
+               if (tp < &dh11[ndh11]) {
+                       wakeup((caddr_t)&tp->t_rawq);
+                       if ((addr->dmlstat&CARRIER)==0) {
+                               if ((tp->t_state&WOPEN)==0) {
+                                       signal(tp->t_pgrp, SIGHUP);
+                                       addr->dmlstat = 0;
+                                       flushtty(tp);
+                               }
+                               tp->t_state &= ~CARR_ON;
+                       } else
+                               tp->t_state |= CARR_ON;
+               }
+               addr->dmcsr = IENABLE|SCENABL;
+       }
+}
diff --git a/usr/src/sys/dev/dhfdm.c b/usr/src/sys/dev/dhfdm.c
new file mode 100644 (file)
index 0000000..f7fe33b
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ *     DM-BB fake driver
+ */
+#include "../h/param.h"
+#include "../h/tty.h"
+#include "../h/conf.h"
+
+struct tty     dh11[];
+
+dmopen(dev)
+{
+       register struct tty *tp;
+
+       tp = &dh11[minor(dev)];
+       tp->t_state |= CARR_ON;
+}
+
+dmctl(dev, bits)
+{
+}
diff --git a/usr/src/sys/dev/dn.c b/usr/src/sys/dev/dn.c
new file mode 100644 (file)
index 0000000..919e484
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * DN-11 ACU interface
+ */
+
+#include "../h/param.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/uba.h"
+
+struct device {
+       short   dn_reg[4];
+};
+
+struct device *dn_addr[] = { (struct device *)(UBA0_DEV+0175200) };
+#define        NDN     4
+
+#define        PWI     0100000
+#define        ACR     040000
+#define        DLO     010000
+#define        DONE    0200
+#define        IENABLE 0100
+#define        DSS     040
+#define        PND     020
+#define        MENABLE 04
+#define        DPR     02
+#define        CRQ     01
+
+#define        DNPRI   (PZERO+5)
+
+dnopen(dev)
+register dev;
+{
+       register struct device *dp;
+
+       dev = minor(dev);
+       if (dev >= NDN ||
+          (dp = dn_addr[dev>>2])->dn_reg[dev&03]&(PWI|DLO|CRQ))
+               u.u_error = ENXIO;
+       else {
+               dp->dn_reg[0] |= MENABLE;
+               dp->dn_reg[dev&03] = IENABLE|MENABLE|CRQ;
+       }
+}
+
+dnclose(dev)
+{
+       dev = minor(dev);
+       dn_addr[dev>>2]->dn_reg[dev&03] = MENABLE;
+}
+
+dnwrite(dev)
+{
+       register c;
+       register short *dp;
+       extern lbolt;
+
+       dev = minor(dev);
+       dp = &(dn_addr[dev>>2]->dn_reg[dev&03]);
+       while ((*dp & (PWI|ACR|DSS)) == 0) {
+               spl4();
+               if ((*dp&PND) == 0 || u.u_count == 0 || (c=cpass()) < 0)
+                       sleep(dp, DNPRI);
+               else if (c == '-') {
+                       sleep(&lbolt, DNPRI);
+                       sleep(&lbolt, DNPRI);
+               } else {
+                       *dp = (c<<8)|IENABLE|MENABLE|DPR|CRQ;
+                       sleep(dp, DNPRI);
+               }
+               spl0();
+       }
+       if (*dp&(PWI|ACR))
+               u.u_error = EIO;
+}
+
+/*
+ * interrupt-- "dev" applies to
+ * system unit number, not minor device
+ */
+dnint(dev)
+{
+       register short *dp,*ep;
+
+       dp = &(dn_addr[dev]->dn_reg[0]);
+       *dp &= ~MENABLE;
+       for (ep=dp; ep<dp+4; ep++)
+               if (*ep&DONE) {
+                       *ep &= ~DONE;
+                       wakeup(ep);
+               }
+       *dp |= MENABLE;
+}
diff --git a/usr/src/sys/dev/du.c b/usr/src/sys/dev/du.c
new file mode 100644 (file)
index 0000000..9c79443
--- /dev/null
@@ -0,0 +1,259 @@
+/*
+ * DU-11 Synchronous interface driver
+ */
+
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/buf.h"
+#include "../h/uba.h"
+
+/* device registers */
+struct dureg {
+       short   rxcsr, rxdbuf;
+#define        parcsr  rxdbuf
+       short   txcsr, txdbuf;
+};
+
+struct du {
+       struct dureg    *du_addr;
+       int             du_state;
+       struct proc     *du_proc;
+       struct buf      *du_buf;
+       caddr_t         du_bufb;
+       caddr_t         du_bufp;
+       int             du_nxmit;
+       int             du_timer;
+} du[] = {
+       { (struct dureg *) (UBA0_DEV+0160110) },
+};
+
+#define        NDU     (sizeof(du)/sizeof(du[0]))
+
+#define        DONE    0200
+#define        IE      0100
+#define        SIE     040
+#define CTS    020000
+#define        CARRIER 010000
+#define        RCVACT  04000
+#define        DSR     01000
+#define STRIP  0400
+#define SCH    020
+#define RTS    04
+#define        DTR     02
+#define MR     0400
+#define SEND   020
+#define        HALF    010
+
+#define        READ    0
+#define        WRITE   1
+#define PWRIT  2
+
+#define        DUPRI   (PZERO+1)
+
+duopen(dev)
+register dev;
+{
+       int dutimeout();
+       register struct du *dp;
+       register struct dureg *lp;
+
+       dev = minor(dev);
+       if (dev >= NDU ||
+          ((dp = &du[dev])->du_proc!=NULL && dp->du_proc!=u.u_procp)) {
+               u.u_error = ENXIO;
+               return;
+       }
+       dp->du_proc = u.u_procp;
+       lp = dp->du_addr;
+       if (dp->du_buf==NULL) {
+               dp->du_buf = geteblk();
+               dp->du_bufb = dp->du_buf->b_un.b_addr;
+               dp->du_state = WRITE;
+               lp->txcsr = MR;
+               lp->parcsr = 035026;            /* Sync Int, 7 bits, even parity, sync=026 */
+               timeout(dutimeout, (caddr_t)dp, HZ);
+               duturn(dp);
+       }
+}
+
+duclose(dev)
+{
+       register struct du *dp;
+       register struct dureg *lp;
+
+       dp = &du[minor(dev)];
+       lp = dp->du_addr;
+       lp->rxcsr = 0;
+       lp->txcsr = 0;
+       dp->du_timer = 0;
+       dp->du_proc = 0;
+       if (dp->du_buf != NULL) {
+               brelse(dp->du_buf);
+               dp->du_buf = NULL;
+       }
+}
+
+duread(dev)
+{
+       register char *bp;
+       register struct du *dp;
+
+       dp = &du[minor(dev)];
+       bp = dp->du_bufb;
+       for(;;) {
+               if(duwait(dev))
+                       return;
+               if (dp->du_bufp > bp)
+                       break;
+               spl5();
+               if (dp->du_timer <= 1) {
+                       spl0();
+                       return;
+               }
+               sleep((caddr_t)dp, DUPRI);
+               spl0();
+       }
+       u.u_offset = 0;
+       iomove(dp->du_bufb, (int)min(u.u_count, (unsigned)(dp->du_bufp-bp)), B_READ);
+}
+
+duwrite(dev)
+{
+       register struct du *dp;
+       register struct dureg *lp;
+
+       dev = minor(dev);
+       dp = &du[dev];
+       if (u.u_count==0 || duwait(dev))
+               return;
+       dp->du_bufp = dp->du_bufb;
+       dp->du_state = PWRIT;
+       dp->du_addr->rxcsr &= ~SCH;
+       dp->du_addr->rxcsr = SIE|RTS|DTR;
+       if (u.u_count > BSIZE)
+               u.u_count = BSIZE;
+       dp->du_nxmit = u.u_count;
+       u.u_offset = 0;
+       iomove(dp->du_bufb, u.u_count, B_WRITE);
+       lp = dp->du_addr;
+       dp->du_timer = 10;
+       spl5();
+       while((lp->rxcsr&CTS)==0)
+               sleep((caddr_t)dp, DUPRI);
+       if (dp->du_state != WRITE) {
+               dp->du_state = WRITE;
+               lp->txcsr = IE|SIE|SEND|HALF;
+               dustart(dev);
+       }
+       spl0();
+}
+
+duwait(dev)
+{
+       register struct du *dp;
+       register struct dureg *lp;
+
+       dp = &du[minor(dev)];
+       lp = dp->du_addr;
+       for(;;) {
+               if ((lp->rxcsr&DSR)==0 || dp->du_buf==0) {
+                       u.u_error = EIO;
+                       return(1);
+               }
+               spl5();
+               if (dp->du_state==READ &&
+                       ((lp->rxcsr&RCVACT)==0)) {
+                       spl0();
+                       return(0);
+               }
+               sleep((caddr_t)dp, DUPRI);
+               spl0();
+       }
+}
+
+dustart(dev)
+{
+       register struct du *dp;
+       register struct dureg *lp;
+
+       dp = &du[minor(dev)];
+       lp = dp->du_addr;
+       dp->du_timer = 10;
+       if (dp->du_nxmit > 0) {
+               dp->du_nxmit--;
+               lp->txdbuf = *dp->du_bufp++;
+       } else {
+               duturn(dp);
+       }
+}
+
+durint(dev)
+{
+       register struct du *dp;
+       register c, s;
+       int dustat;
+
+       dp = &du[minor(dev)];
+       dustat = dp->du_addr->rxcsr;
+       if(dustat<0) {
+               if((dustat&CARRIER)==0 && dp->du_state==READ)
+                       duturn(dp);
+               else
+                       wakeup((caddr_t)dp);
+       } else
+       if(dustat&DONE) {
+               dp->du_addr->rxcsr = IE|SIE|SCH|DTR;
+               c = s = dp->du_addr->rxdbuf;
+               c &= 0177;
+               if(s<0)
+                       c |= 0200;
+               if (dp->du_bufp < dp->du_bufb+BSIZE)
+                       *dp->du_bufp++ = c;
+       }
+}
+
+duxint(dev)
+{
+       register struct du *dp;
+       register struct dureg *lp;
+       register int dustat;
+
+       dp = &du[minor(dev)];
+       lp = dp->du_addr;
+       dustat = lp->txcsr;
+       if(dustat<0)
+               duturn(dp);
+       else if(dustat&DONE)
+               dustart(dev);
+}
+
+duturn(dp)
+register struct du *dp;
+{
+       register struct dureg *lp;
+
+       lp = dp->du_addr;
+       if (dp->du_state!=READ) {
+               dp->du_state = READ;
+               dp->du_timer = 10;
+               dp->du_bufp = dp->du_bufb;
+       }
+       lp->txcsr = HALF;
+       lp->rxcsr &= ~SCH;
+       lp->rxcsr = STRIP|IE|SIE|SCH|DTR;
+       wakeup((caddr_t)dp);
+}
+
+dutimeout(dp)
+register struct du *dp;
+{
+       if (dp->du_timer == 0)
+               return;
+       if (--dp->du_timer == 0) {
+               duturn(dp);
+               dp->du_timer = 1;
+       }
+       timeout(dutimeout, (caddr_t)dp, HZ);
+}
diff --git a/usr/src/sys/dev/kl.c b/usr/src/sys/dev/kl.c
new file mode 100644 (file)
index 0000000..57bddd3
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ *   KL/DL-11 driver
+ */
+#include "../h/param.h"
+#include "../h/conf.h"
+#include       "../h/dir.h"
+#include "../h/user.h"
+#include "../h/tty.h"
+#include "../h/systm.h"
+#include "../h/uba.h"
+
+/* base address */
+#define        KLBASE  ((struct device *)(UBA0_DEV+0176500))   /* kl and dl11-a */
+#define        DLBASE  ((struct device *)(UBA0_DEV+0175610))   /* dl-e */
+#define        NKL11   1
+#define        NDL11   0
+#define DSRDY  02
+#define        RDRENB  01
+#define        DLDELAY 4       /* Extra delay for DL's (double buff) */
+
+#define        NL1     000400
+#define        NL2     001000
+#define        CR2     020000
+#define        FF1     040000
+#define        TAB1    002000
+
+struct tty kl11[NKL11+NDL11];
+int    klstart();
+int    ttrstrt();
+char   partab[];
+
+struct device {
+       short   rcsr;
+       short   rbuf;
+       short   tcsr;
+       short   tbuf;
+};
+
+klopen(dev, flag)
+dev_t dev;
+{
+       register struct device *addr;
+       register struct tty *tp;
+       register d;
+
+       d = minor(dev);
+       if(d >= NKL11+NDL11) {
+               u.u_error = ENXIO;
+               return;
+       }
+       tp = &kl11[d];
+       /*
+        * set up minor 0 to address KLADDR
+        * set up minor 0 thru NKL11-1 to address from KLBASE
+        * set up minor NKL11 on to address from DLBASE
+        */
+       if(d<NKL11)
+               addr = KLBASE + d;
+       else
+               addr = DLBASE + (d-NKL11);
+       tp->t_addr = (caddr_t)addr;
+       tp->t_oproc = klstart;
+       if ((tp->t_state&ISOPEN) == 0) {
+               tp->t_state = ISOPEN|CARR_ON;
+               tp->t_flags = EVENP|LCASE|ECHO|XTABS|CRMOD|CR2;
+               tp->t_erase = CERASE;
+               tp->t_kill = CKILL;
+       }
+       addr->rcsr |= IENABLE|DSRDY|RDRENB;
+       addr->tcsr |= IENABLE;
+       ttyopen(dev, tp);
+}
+
+klclose(dev)
+dev_t dev;
+{
+       register struct tty *tp;
+
+       tp = &kl11[minor(dev)];
+       ttyclose(tp);
+}
+
+klread(dev)
+dev_t dev;
+{
+       ttread(&kl11[minor(dev)]);
+}
+
+klwrite(dev)
+dev_t dev;
+{
+       ttwrite(&kl11[minor(dev)]);
+}
+
+klxint(dev)
+dev_t dev;
+{
+       register struct tty *tp;
+
+       tp = &kl11[minor(dev)];
+       ttstart(tp);
+       if (tp->t_outq.c_cc == 0 || tp->t_outq.c_cc == TTLOWAT)
+               wakeup((caddr_t)&tp->t_outq);
+}
+
+klrint(dev)
+dev_t dev;
+{
+       register int c;
+       register struct device *addr;
+       register struct tty *tp;
+
+       tp = &kl11[minor(dev)];
+       addr = (struct device *)tp->t_addr;
+       c = addr->rbuf;
+       addr->rcsr |= RDRENB;
+       ttyinput(c, tp);
+}
+
+klioctl(dev, cmd, addr, flag)
+caddr_t addr;
+dev_t dev;
+{
+       if (ttioccom(cmd, &kl11[minor(dev)], addr, dev)==0)
+               u.u_error = ENOTTY;
+}
+
+klstart(tp)
+register struct tty *tp;
+{
+       register c;
+       register struct device *addr;
+
+       addr = (struct device *)tp->t_addr;
+       if((addr->tcsr&DONE) == 0)
+               return;
+       if ((c=getc(&tp->t_outq)) >= 0) {
+               if (tp->t_flags&RAW)
+                       addr->tbuf = c;
+               else if (c<=0177)
+                       addr->tbuf = c | (partab[c]&0200);
+               else {
+                       timeout(ttrstrt, (caddr_t)tp, (c&0177) + DLDELAY);
+                       tp->t_state |= TIMEOUT;
+               }
+       }
+}
diff --git a/usr/src/sys/dev/lp.c b/usr/src/sys/dev/lp.c
new file mode 100644 (file)
index 0000000..08bc3bb
--- /dev/null
@@ -0,0 +1,214 @@
+/*
+ *  Line printer driver
+ */
+
+#include "../h/param.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/tty.h"
+#include "../h/uba.h"
+
+struct device *lp_addr[] = { (struct device *)(UBA0_DEV+0177514) };
+
+#define        LPPRI   PZERO+10
+#define        LPLOWAT 50
+#define        LPHIWAT 100
+#define LPMAX 2
+
+struct device {
+       short   lpcsr, lpbuf;
+};
+int lp_cnt = 1;
+
+struct lp {
+       struct  clist l_outq;
+       char    flag, ind;
+       short   ccc, mcc, mlc;
+       short   line, col;
+} lp_dt[LPMAX];
+
+#define        OPEN    010
+#define        CAP     020
+#define        NOCR    040
+#define        ASLP    0100
+
+#define        FORM    014
+
+lpopen(dev, flag)
+{
+       register unit;
+       register struct lp *lp;
+
+       unit = dev&07;
+       if (unit >= lp_cnt || unit >= LPMAX ||
+        (lp = &lp_dt[unit])->flag || lp_addr[unit]->lpcsr <0 ) {
+               u.u_error = EIO;
+               return;
+       }
+       lp->flag = (dev&077)|OPEN;
+       lp->ind = 4;
+       lp->col = 80;
+       lp->line = 66;
+       lp_addr[unit]->lpcsr |= IENABLE;
+       lpoutput(unit, FORM);
+}
+
+lpclose(dev)
+{
+       register unit;
+
+       unit = dev&07;
+       lpoutput(unit, FORM);
+       lp_dt[unit].flag = 0;
+}
+
+lpwrite(dev)
+{
+       register c;
+
+       while ((c=cpass())>=0)
+               lpoutput(dev&07, c);
+}
+
+lpoutput(dev, c)
+register dev, c;
+{
+       register struct lp *lp;
+
+       lp = &lp_dt[dev];
+       if(lp->flag&CAP) {
+               if(c>='a' && c<='z')
+                       c += 'A'-'a'; else
+               switch(c) {
+               case '{':
+                       c = '(';
+                       goto esc;
+               case '}':
+                       c = ')';
+                       goto esc;
+               case '`':
+                       c = '\'';
+                       goto esc;
+               case '|':
+                       c = '!';
+                       goto esc;
+               case '~':
+                       c = '^';
+               esc:
+                       lpoutput(dev, c);
+                       lp->ccc--;
+                       c = '-';
+               }
+       }
+       switch(c) {
+       case '\t':
+               lp->ccc = ((lp->ccc+8-lp->ind) & ~7) + lp->ind;
+               return;
+       case '\n':
+               lp->mlc++;
+               if(lp->mlc >= lp->line )
+                       c = FORM;
+       case FORM:
+               lp->mcc = 0;
+               if (lp->mlc) {
+                       lpputc(dev, c);
+                       if(c == FORM)
+                               lp->mlc = 0;
+               }
+       case '\r':
+               lp->ccc = lp->ind;
+               return;
+       case 010:
+               if(lp->ccc > lp->ind)
+                       lp->ccc--;
+               return;
+       case ' ':
+               lp->ccc++;
+               return;
+       default:
+               if(lp->ccc < lp->mcc) {
+                       if (lp->flag&NOCR) {
+                               lp->ccc++;
+                               return;
+                       }
+                       lpputc(dev, '\r');
+                       lp->mcc = 0;
+               }
+               if(lp->ccc < lp->col) {
+                       while(lp->ccc > lp->mcc) {
+                               lpputc(dev, ' ');
+                               lp->mcc++;
+                       }
+                       lpputc(dev, c);
+                       lp->mcc++;
+               }
+               lp->ccc++;
+       }
+}
+
+lpputc(dev, c)
+register dev, c;
+{
+       register struct lp *lp;
+
+       lp = &lp_dt[dev];
+       spl4();
+       while (lp->l_outq.c_cc > LPHIWAT) {
+               lp->flag |= ASLP;
+               sleep(lp, LPPRI);
+       }
+       putc(c, &lp->l_outq);
+       lpintr(dev);
+       spl0();
+}
+
+lpintr(dev)
+register dev;
+{
+       register struct lp *lp;
+       register c;
+
+       lp = &lp_dt[dev];
+       while (lp_addr[dev]->lpcsr&DONE && (c = getc(&lp->l_outq)) >= 0)
+               lp_addr[dev]->lpbuf = c;
+       if (lp->l_outq.c_cc <= LPLOWAT && lp->flag&ASLP) {
+               lp->flag &= ~ASLP;
+               wakeup(lp);
+       }
+}
+
+lpioctl(dev, cmd, addr, flag)
+register caddr_t addr;
+{
+register int m;
+struct lp *lp;
+struct {char lsg_flag, lsg_ind; short lsg_line, lsg_col;} lpios;
+
+       lp = &lp_dt[dev];
+       switch (cmd) {
+
+       case ('v'<<8)+0:
+               lpios.lsg_flag = lp->flag;
+               lpios.lsg_ind = lp->ind;
+               lpios.lsg_line = lp->line;
+               lpios.lsg_col = lp->col;
+               copyout(&lpios, addr, sizeof lpios);
+               return;
+
+       case ('v'<<8)+1:
+               m = copyin(addr, &lpios, sizeof lpios);
+               if (m == -1) {
+                       u.u_error = EFAULT;
+                       return;
+               }
+               lp->flag = lpios.lsg_flag;
+               lp->ind = lpios.lsg_ind;
+               lp->line = lpios.lsg_line;
+               lp->col = lpios.lsg_col;
+               return;
+
+       default:
+               u.u_error = ENOTTY;
+               return;
+       }
+}
diff --git a/usr/src/sys/dev/vp.c b/usr/src/sys/dev/vp.c
new file mode 100644 (file)
index 0000000..f4d1c01
--- /dev/null
@@ -0,0 +1,230 @@
+/*
+ * Versatec matrix printer/plotter
+ * dma interface driver
+ */
+
+#include "../h/param.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/userx.h"
+#include "../h/buf.h"
+#include "../h/systm.h"
+#include "../h/uba.h"
+#include "../h/tty.h"
+
+#define VPPRI   (PZERO+8)
+
+struct  vpregs {
+        short   plbcr;
+        short   fill;
+        short   prbcr;
+        unsigned short pbaddr;
+        short   plcsr;
+        short   plbuf;
+        short   prcsr;
+        unsigned short prbuf;
+};
+
+#define VPADDR  ((struct vpregs *)(UBA0_DEV + 0177500))
+
+#define ERROR   0100000
+#define DTCINTR 040000
+#define DMAACT  020000
+#define READY   0200
+#define IENABLE 0100
+#define TERMCOM 040
+#define FFCOM   020
+#define EOTCOM  010
+#define CLRCOM  04
+#define RESET   02
+#define SPP     01
+
+struct {
+        int     vp_state;
+        int     vp_count;
+        struct  buf *vp_buf;
+        int     vp_bufp;
+} vp11;
+
+#define VISOPEN 01
+#define CMNDS   076
+#define MODE    0700
+#define PRINT   0100
+#define PLOT    0200
+#define PPLOT   0400
+#define VBUSY   01000
+
+vpopen()
+{
+
+        if (vp11.vp_state & VISOPEN) {
+                u.u_error = ENXIO;
+                return;
+        }
+        vp11.vp_state = VISOPEN | PRINT | CLRCOM | FFCOM | RESET;
+        vp11.vp_count = 0;
+        vp11.vp_buf = geteblk();
+        VPADDR->prcsr = IENABLE | DTCINTR;
+        vptimo();
+        while (vp11.vp_state & CMNDS) {
+                spl4();
+                if (vperror(READY)) {
+                        vpclose();
+                        u.u_error = EIO;
+                        return;
+                }
+                vpstart();
+                spl0();
+        }
+}
+
+vpwrite()
+{
+        register int i, e;
+        register int ubainfo;
+
+        if (u.u_count == 0)
+                return;
+        spl4();
+        while (vp11.vp_state & VBUSY)
+                sleep((caddr_t) &vp11, VPPRI);
+        vp11.vp_state |= VBUSY;
+        spl0();
+        ubainfo = uballoc(vp11.vp_buf->b_un.b_addr, 512, 0);
+        vp11.vp_bufp = ubainfo & 0x3ffff;
+        while (i = vp11.vp_count = min(512, u.u_count)) {
+            iomove(vp11.vp_buf->b_addr, i, B_WRITE);
+                spl4();
+                if (e = vperror(READY))
+                        break;
+                vpstart();
+                while ((vp11.vp_state&PLOT ? VPADDR->plcsr : VPADDR->prcsr) & DMAACT)
+                        sleep((caddr_t) &vp11, VPPRI);
+                if ((vp11.vp_state&MODE) == PPLOT)
+                        vp11.vp_state = (vp11.vp_state &~ MODE) | PLOT;
+                spl0();
+        }
+        ubafree(ubainfo);
+        vp11.vp_state &= ~VBUSY;
+        if (e)
+                u.u_error = EIO;
+        wakeup ((caddr_t) &vp11);
+}
+
+vperror(bit)
+{
+        register int state, e;
+
+        state = vp11.vp_state & PLOT;
+        while ((e = (state ? VPADDR->plcsr : VPADDR->prcsr) & (bit|ERROR)) == 0)
+                sleep ((caddr_t) &vp11, VPPRI);
+        return (e & ERROR);
+}
+
+vpstart()
+{
+        register short bit;
+
+        if (vp11.vp_count) {
+                VPADDR->pbaddr = vp11.vp_bufp;
+                if (vp11.vp_state & (PRINT|PPLOT))
+                        VPADDR->prbcr = vp11.vp_count;
+                else
+                        VPADDR->plbcr = vp11.vp_count;
+                return;
+        }
+        for (bit = 1; bit != 0; bit <<= 1)
+                if (vp11.vp_state&bit&CMNDS) {
+                        VPADDR->plcsr |= bit;
+                        vp11.vp_state &= ~bit;
+                        return;
+                }
+}
+
+vpsgtty(dev, sgbp)
+        register struct sgttyb *sgbp;
+{
+        register int m;
+
+        if (sgbp != NULL) {
+                sgbp->sg_flags = vp11.vp_state;
+                return;
+        }
+        m = sgbp->sg_flags;
+        vp11.vp_state = (vp11.vp_state & ~MODE) | (m&(MODE|CMNDS));
+        spl4();
+        vperror(READY);
+        if (vp11.vp_state&PPLOT)
+                VPADDR->plcsr |= SPP;
+        else
+                VPADDR->plcsr &= ~SPP;
+        vp11.vp_count = 0;
+        while (CMNDS & vp11.vp_state) {
+                vperror(READY);
+                vpstart();
+        }
+        spl0();
+}
+
+vpioctl(dev, cmd, addr, flag)
+register caddr_t addr;
+{
+register int m;
+
+       switch (cmd) {
+
+       case ('v'<<8)+0:
+               suword(addr, vp11.vp_state);
+               return;
+
+       case ('v'<<8)+1:
+               m = fuword(addr);
+               if (m == -1) {
+                       u.u_error = EFAULT;
+                       return;
+               }
+               vp11.vp_state = (vp11.vp_state & ~MODE) | (m&(MODE|CMNDS));
+               break;
+
+       default:
+               u.u_error = ENOTTY;
+               return;
+       }
+       spl4();
+       vperr(READY);
+       if (vp11.vp_state&PPLOT)
+               VPADDR->plcsr |= SPP;
+       else
+               VPADDR->plcsr &= ~SPP;
+       vp11.vp_count = 0;
+       while (CMNDS & vp11.vp_state) {
+               vperror(READY);
+               vpstart();
+       }
+       spl0();
+}
+
+vptimo()
+{
+
+        if (vp11.vp_state&VISOPEN)
+                timeout(vptimo, 0, HZ/10);
+        vpintr(0);
+}
+
+vpintr(dev)
+{
+
+        wakeup((caddr_t) &vp11);
+}
+
+vpclose()
+{
+
+        brelse(vp11.vp_buf);
+        vp11.vp_state = 0;
+        vp11.vp_count = 0;
+        vp11.vp_buf = 0;
+        vp11.vp_bufp = 0;
+        VPADDR->plcsr = 0;
+}
diff --git a/usr/src/sys/dev/vs.c b/usr/src/sys/dev/vs.c
new file mode 100644 (file)
index 0000000..0fd3897
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ * Screw Works interface via DC-11
+ */
+
+#include "../h/types.h"
+#include "../h/tty.h"
+#include "../h/uba.h"
+
+#define        VSADDR  ((struct device *)(UBA0_DEV+0174140))
+#define        CDLEAD  01
+#define        B1200   030
+#define        STOP1   0400
+#define        CLSEND  02
+#define        RQSEND  01
+
+#define        GO      026
+#define        COUNT   120
+
+struct device {
+       short   vsrcsr;
+       short   vsrbuf;
+       short   vsxcsr;
+       short   vsxbuf;
+};
+
+struct {
+       struct  clist   iq;
+       int     vtime;
+       struct  clist   oq;
+} vs;
+
+
+vsopen(dev)
+{
+       register c;
+
+       c = VSADDR->vsrcsr;             /* touch register */
+       VSADDR->vsrcsr = IENABLE|B1200|CDLEAD;
+       VSADDR->vsxcsr = STOP1|IENABLE|B1200;
+       vschar(GO);
+}
+
+vsclose(dev)
+{
+       vschar(GO);
+       VSADDR->vsrcsr &= ~IENABLE;
+       while (getc(&vs.iq) >= 0);
+}
+
+vswrite(dev)
+{
+       register int count, c;
+
+       count = 0;
+       while ((c=cpass()) >= 0) {
+               if (--count <= 0) {
+                       count = COUNT;
+                       vschar(GO);
+               }
+               vschar(c);
+       }
+       vschar(GO);
+}
+
+vschar(c)
+{
+
+       spl5();
+       while (vs.oq.c_cc > 120) {
+               vsxintr();
+               sleep(&vs.oq, TTIPRI);
+       }
+       putc(c, &vs.oq);
+       vsxintr();
+       spl0();
+}
+
+vstimo()
+{
+       vs.vtime = 0;
+       vsxintr();
+}
+
+vsxintr()
+{
+       static lchar;
+       register c;
+       register short *xcsr;
+
+       xcsr = &VSADDR->vsxcsr;
+       if (*xcsr&DONE) {
+               if (lchar==GO) {
+                       *xcsr &= ~RQSEND;
+                       lchar = -1;
+                       if (vs.oq.c_cc==0) {
+                               wakeup(&vs.oq);
+                               return;
+                       }
+               }
+               if ((*xcsr&CLSEND) == 0) {
+                       *xcsr |= RQSEND;
+                       if ((*xcsr&CLSEND) == 0) {
+                               if (vs.vtime==0) {
+                                       vs.vtime++;
+                                       timeout(vstimo, 0, 60);
+                               }
+                               return;
+                       }
+               }
+               if ((c = getc(&vs.oq)) >= 0)
+                       VSADDR->vsxbuf = lchar = c;
+               else
+                       *xcsr &= ~RQSEND;
+               if (vs.oq.c_cc <= 15)
+                       wakeup(&vs.oq);
+       }
+}
+
+vsread(dev)
+{
+       register int c;
+
+       spl5();
+       while ((c = getc(&vs.iq)) < 0)
+               sleep(&vs.iq, TTIPRI);
+       spl0();
+       passc("?0*#?546?213?879?"[c&017]);
+}
+
+vsrintr()
+{
+       register int c;
+
+       c = VSADDR->vsrbuf;     /* Register must be read (?) */
+       c = VSADDR->vsrbuf;
+       if (vs.iq.c_cc<=10)
+               putc(c, &vs.iq);
+       wakeup(&vs.iq);
+}
diff --git a/usr/src/sys/h/acct.h b/usr/src/sys/h/acct.h
new file mode 100644 (file)
index 0000000..8a7d7c6
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Accounting structures
+ */
+
+typedef        unsigned short comp_t;  /* "floating pt": 3 bits base 8 exp, 13 bits fraction */
+struct acct
+{
+       char    ac_comm[10];            /* Accounting command name */
+       comp_t  ac_utime;               /* Accounting user time */
+       comp_t  ac_stime;               /* Accounting system time */
+       comp_t  ac_etime;               /* Accounting elapsed time */
+       time_t  ac_btime;               /* Beginning time */
+       short   ac_uid;                 /* Accounting user ID */
+       short   ac_gid;                 /* Accounting group ID */
+       short   ac_mem;                 /* average memory usage */
+       comp_t  ac_io;                  /* number of disk IO blocks */
+       dev_t   ac_tty;                 /* control typewriter */
+       char    ac_flag;                /* Accounting flag */
+};
+
+extern struct  acct    acctbuf;
+extern struct  inode   *acctp;         /* inode of accounting file */
+
+#define        AFORK   01              /* has executed fork, but no exec */
+#define        ASU     02              /* used super-user privileges */
diff --git a/usr/src/sys/h/buf.h b/usr/src/sys/h/buf.h
new file mode 100644 (file)
index 0000000..84f180e
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Each buffer in the pool is usually doubly linked into 2 lists:
+ * the device with which it is currently associated (always)
+ * and also on a list of blocks available for allocation
+ * for other use (usually).
+ * The latter list is kept in last-used order, and the two
+ * lists are doubly linked to make it easy to remove
+ * a buffer from one list when it was found by
+ * looking through the other.
+ * A buffer is on the available list, and is liable
+ * to be reassigned to another disk block, if and only
+ * if it is not marked BUSY.  When a buffer is busy, the
+ * available-list pointers can be used for other purposes.
+ * Most drivers use the forward ptr as a link in their I/O
+ * active queue.
+ * A buffer header contains all the information required
+ * to perform I/O.
+ * Most of the routines which manipulate these things
+ * are in bio.c.
+ */
+struct buf
+{
+       int     b_flags;                /* see defines below */
+       struct  buf *b_forw;            /* headed by d_tab of conf.c */
+       struct  buf *b_back;            /*  "  */
+       struct  buf *av_forw;           /* position on free list, */
+       struct  buf *av_back;           /*     if not BUSY*/
+       dev_t   b_dev;                  /* major+minor device name */
+       unsigned b_bcount;              /* transfer count */
+       union {
+           caddr_t b_addr;             /* low order core address */
+           int *b_words;               /* words for clearing */
+           struct filsys *b_filsys;    /* superblocks */
+           struct dinode *b_dino;      /* ilist */
+           daddr_t *b_daddr;           /* indirect block */
+       } b_un;
+       daddr_t b_blkno;                /* block # on device */
+       char    b_xmem;                 /* high order core address */
+       char    b_error;                /* returned after I/O */
+       unsigned int b_resid;           /* words not transferred after error */
+       struct  proc  *b_proc;  /* process doing physical or swap I/O */
+};
+
+extern struct buf buf[];               /* The buffer pool itself */
+extern struct buf bfreelist;           /* head of available list */
+
+/*
+ * These flags are kept in b_flags.
+ */
+#define        B_WRITE 0       /* non-read pseudo-flag */
+#define        B_READ  01      /* read when I/O occurs */
+#define        B_DONE  02      /* transaction finished */
+#define        B_ERROR 04      /* transaction aborted */
+#define        B_BUSY  010     /* not on av_forw/back list */
+#define        B_PHYS  020     /* Physical IO potentially using UNIBUS map */
+#define        B_MAP   040     /* This block has the UNIBUS map allocated */
+#define        B_WANTED 0100   /* issue wakeup when BUSY goes off */
+#define        B_AGE   0200    /* delayed write for correct aging */
+#define        B_ASYNC 0400    /* don't wait for I/O completion */
+#define        B_DELWRI 01000  /* don't write till block leaves available list */
+#define        B_UAREA  04000  /* add u-area to a swap operation */
+#define        B_TAPE 02000    /* this is a magtape (no bdwrite) */
+
+/*
+ * special redeclarations for
+ * the head of the queue per
+ * device driver.
+ */
+#define        b_actf  av_forw
+#define        b_actl  av_back
+#define        b_active b_bcount
+#define        b_errcnt b_resid
diff --git a/usr/src/sys/h/callo.h b/usr/src/sys/h/callo.h
new file mode 100755 (executable)
index 0000000..f66e5bb
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * The callout structure is for
+ * a routine arranging
+ * to be called by the clock interrupt
+ * (clock.c) with a specified argument,
+ * in a specified amount of time.
+ * Used, for example, to time tab
+ * delays on typewriters.
+ */
+
+struct callo
+{
+       int     c_time;         /* incremental time */
+       caddr_t c_arg;          /* argument to routine */
+       int     (*c_func)();    /* routine */
+};
+struct callo   callout[NCALL];
diff --git a/usr/src/sys/h/clock.h b/usr/src/sys/h/clock.h
new file mode 100755 (executable)
index 0000000..96c9505
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+  VAX clock registers
+ */
+
+#define ICCS_RUN 0x1
+#define ICCS_TRANS 0x10
+#define ICCS_SS 0x20
+#define ICCS_IE 0x40
+#define ICCS_INT 0x80
+#define ICCS_ERR 0x80000000
+# define YRCURR  1979  /*  current year */
+# define YRREF   1970  /*  reference year for time */
+# define SECHR  (60*60)  /* seconds/hr */
+# define SECDAY  (24*SECHR)  /* seconds/day */
+# define SECYR  (365*SECDAY) /* seconds/common year */
diff --git a/usr/src/sys/h/clock.m b/usr/src/sys/h/clock.m
new file mode 100755 (executable)
index 0000000..375598e
--- /dev/null
@@ -0,0 +1,10 @@
+#
+# VAX clock registers
+#
+
+       .set    ICCS_RUN,0x1
+       .set    ICCS_TRANS,0x10
+       .set    ICCS_SS,0x20
+       .set    ICCS_IE,0x40
+       .set    ICCS_INT,0x80
+       .set    ICCS_ERR,0x80000000
diff --git a/usr/src/sys/h/conf.h b/usr/src/sys/h/conf.h
new file mode 100644 (file)
index 0000000..25a0ed9
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Declaration of block device
+ * switch. Each entry (row) is
+ * the only link between the
+ * main unix code and the driver.
+ * The initialization of the
+ * device switches is in the
+ * file conf.c.
+ */
+extern struct bdevsw
+{
+       int     (*d_open)();
+       int     (*d_close)();
+       int     (*d_strategy)();
+       struct buf *d_tab;
+} bdevsw[];
+
+/*
+ * Character device switch.
+ */
+extern struct cdevsw
+{
+       int     (*d_open)();
+       int     (*d_close)();
+       int     (*d_read)();
+       int     (*d_write)();
+       int     (*d_ioctl)();
+       struct tty *d_ttys;
+} cdevsw[];
+
+/*
+ * tty line control switch.
+ */
+extern struct linesw
+{
+       int     (*l_open)();
+       int     (*l_close)();
+       int     (*l_read)();
+       int     (*l_write)();
+       int     (*l_ioctl)();
+       int     (*l_rint)();
+       int     (*l_start)();
+} linesw[];
diff --git a/usr/src/sys/h/cons.h b/usr/src/sys/h/cons.h
new file mode 100755 (executable)
index 0000000..b0a22dc
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+  VAX console interface registers
+ */
+
+#define RXCS_IE 0x40   /* receiver interrupt enable */
+#define RXCS_DONE 0x80 /* receiver done */
+#define RXDB_DATA 0xff /* received character */
+#define RXDB_ID 0xf00  /* channel id */
+#define RXDB_ERR 0x80000000    /* receiver error */
+
+#define TXCS_IE 0x40   /* transmitter interrupt enable */
+#define TXCS_RDY 0x80  /* transmitter ready for next char */
+#define TXDB_DATA 0xff /* transmitter byte */
+#define TXDB_ID 0xf00  /* channel id */
diff --git a/usr/src/sys/h/cons.m b/usr/src/sys/h/cons.m
new file mode 100644 (file)
index 0000000..9fedd92
--- /dev/null
@@ -0,0 +1,15 @@
+#
+# VAX console interface registers
+#
+
+       .set    RXCS_IE,0x40    # receiver interrupt enable
+       .set    RXCS_DONE,0x80  # receiver done
+       .set    RXDB_DATA,0xff  # received character
+       .set    RXDB_ID,0xf00   # channel id
+       .set    RXDB_ERR,0x80000000     # receiver error
+
+       .set    TXCS_IE,0x40    # transmitter interrupt i"enable
+       .set    TXCS_RDY,0x80   # transmitter ready for next char
+       .set    TXCS_BRDY,7             # bit number of TXCS_RDY
+       .set    TXDB_DATA,0xff  # transmitter byte
+       .set    TXDB_ID,0xf00   # channel id
diff --git a/usr/src/sys/h/dir.h b/usr/src/sys/h/dir.h
new file mode 100755 (executable)
index 0000000..737a3a6
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef        DIRSIZ
+#define        DIRSIZ  14
+#endif
+struct direct
+{
+       ino_t   d_ino;
+       char    d_name[DIRSIZ];
+};
diff --git a/usr/src/sys/h/fblk.h b/usr/src/sys/h/fblk.h
new file mode 100755 (executable)
index 0000000..9a1ba29
--- /dev/null
@@ -0,0 +1,5 @@
+struct fblk
+{
+       int     df_nfree;
+       daddr_t df_free[NICFREE];
+};
diff --git a/usr/src/sys/h/file.h b/usr/src/sys/h/file.h
new file mode 100644 (file)
index 0000000..99b3124
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * One file structure is allocated
+ * for each open/creat/pipe call.
+ * Main use is to hold the read/write
+ * pointer associated with each open
+ * file.
+ */
+struct file
+{
+       char    f_flag;
+       char    f_count;        /* reference count */
+       struct inode *f_inode;  /* pointer to inode structure */
+       union {
+               off_t   f_offset;       /* read/write character pointer */
+               struct chan *f_chan;    /* mpx channel pointer */
+       } f_un;
+};
+
+extern struct file file[];     /* The file table itself */
+
+/* flags */
+#define        FREAD   01
+#define        FWRITE  02
+#define        FPIPE   04
+#define FMPX   010
+#define        FMPY    020
+#define        FMP     030
diff --git a/usr/src/sys/h/filsys.h b/usr/src/sys/h/filsys.h
new file mode 100644 (file)
index 0000000..19ebcee
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Structure of the super-block
+ */
+struct filsys {
+       unsigned short s_isize; /* size in blocks of i-list */
+       daddr_t s_fsize;        /* size in blocks of entire volume */
+       short   s_nfree;        /* number of addresses in s_free */
+       daddr_t s_free[NICFREE];/* free block list */
+       short   s_ninode;       /* number of i-nodes in s_inode */
+       ino_t   s_inode[NICINOD];/* free i-node list */
+       char    s_flock;        /* lock during free list manipulation */
+       char    s_ilock;        /* lock during i-list manipulation */
+       char    s_fmod;         /* super block modified flag */
+       char    s_ronly;        /* mounted read-only flag */
+       time_t  s_time;         /* last super block update */
+       /* remainder not maintained by this version of the system */
+       daddr_t s_tfree;        /* total free blocks*/
+       ino_t   s_tinode;       /* total free inodes */
+       short   s_m;            /* interleave factor */
+       short   s_n;            /* " " */
+       char    s_fname[6];     /* file system name */
+       char    s_fpack[6];     /* file system pack name */
+};
diff --git a/usr/src/sys/h/ino.h b/usr/src/sys/h/ino.h
new file mode 100644 (file)
index 0000000..90579cb
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Inode structure as it appears on
+ * a disk block.
+ */
+struct dinode
+{
+       unsigned short  di_mode;        /* mode and type of file */
+       short   di_nlink;       /* number of links to file */
+       short   di_uid;         /* owner's user id */
+       short   di_gid;         /* owner's group id */
+       off_t   di_size;        /* number of bytes in file */
+       char    di_addr[40];    /* disk block addresses */
+       time_t  di_atime;       /* time last accessed */
+       time_t  di_mtime;       /* time last modified */
+       time_t  di_ctime;       /* time created */
+};
+#define        INOPB   8       /* 8 inodes per block */
+/*
+ * the 40 address bytes:
+ *     39 used; 13 addresses
+ *     of 3 bytes each.
+ */
diff --git a/usr/src/sys/h/inode.h b/usr/src/sys/h/inode.h
new file mode 100644 (file)
index 0000000..fc4310c
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * The I node is the focus of all
+ * file activity in unix. There is a unique
+ * inode allocated for each active file,
+ * each current directory, each mounted-on
+ * file, text file, and the root. An inode is 'named'
+ * by its dev/inumber pair. (iget/iget.c)
+ * Data, from mode on, is read in
+ * from permanent inode on volume.
+ */
+
+#define        NADDR   13
+
+#define        NINDEX          15
+struct group {
+       short   g_state;
+       char    g_index;
+       char    g_rot;
+       struct  group   *g_group;
+       struct  inode   *g_inode;
+       struct  file    *g_file;
+       short   g_rotmask;
+       short   g_datq;
+       struct  chan *g_chans[NINDEX];
+};
+struct inode
+{
+       char    i_flag;
+       char    i_count;        /* reference count */
+       dev_t   i_dev;          /* device where inode resides */
+       ino_t   i_number;       /* i number, 1-to-1 with device address */
+       unsigned short  i_mode;
+       short   i_nlink;        /* directory entries */
+       short   i_uid;          /* owner */
+       short   i_gid;          /* group of owner */
+       off_t   i_size;         /* size of file */
+       union {
+               struct {
+                       daddr_t i_addr[NADDR];  /* if normal file/directory */
+                       daddr_t i_lastr;        /* last logical block read (for read-ahead) */
+               };
+               struct  {
+                       daddr_t i_rdev;                 /* i_addr[0] */
+                       struct  group   i_group;        /*  multiplexor group file */
+               };
+       } i_un;
+};
+
+
+extern struct inode inode[];   /* The inode table itself */
+struct inode *mpxip;           /* mpx virtual inode */
+
+/* flags */
+#define        ILOCK   01              /* inode is locked */
+#define        IUPD    02              /* file has been modified */
+#define        IACC    04              /* inode access time to be updated */
+#define        IMOUNT  010             /* inode is mounted on */
+#define        IWANT   020             /* some process waiting on lock */
+#define        ITEXT   040             /* inode is pure text prototype */
+#define        ICHG    0100            /* inode has been changed */
+
+/* modes */
+#define        IFMT    0170000         /* type of file */
+#define                IFDIR   0040000 /* directory */
+#define                IFCHR   0020000 /* character special */
+#define                IFBLK   0060000 /* block special */
+#define                IFREG   0100000 /* regular */
+#define                IFMPC   0030000 /* multiplexed char special */
+#define                IFMPB   0070000 /* multiplexed block special */
+#define        ISUID   04000           /* set user id on execution */
+#define        ISGID   02000           /* set group id on execution */
+#define ISVTX  01000           /* save swapped text even after use */
+#define        IREAD   0400            /* read, write, execute permissions */
+#define        IWRITE  0200
+#define        IEXEC   0100
diff --git a/usr/src/sys/h/map.h b/usr/src/sys/h/map.h
new file mode 100644 (file)
index 0000000..32dc456
--- /dev/null
@@ -0,0 +1,14 @@
+struct map
+{
+       short   m_size;
+       unsigned short m_addr;
+};
+
+int memmap[CMAPSIZ];           /* space for core allocation */
+struct map swapmap[SMAPSIZ];   /* space for swap allocation */
+/*
+       uba
+*/
+char bdpwant , umrwant ;
+struct map ubamap[UAMSIZ];
+struct map bdpmap[15];
diff --git a/usr/src/sys/h/mba.h b/usr/src/sys/h/mba.h
new file mode 100644 (file)
index 0000000..4eef220
--- /dev/null
@@ -0,0 +1,31 @@
+/* VAX Massbus adapter registers
+ */
+
+struct mba_regs {
+       int mba_csr,
+           mba_cr,
+           mba_sr,
+           mba_var,
+           mba_bcr;
+};
+
+/* NOTE:
+       mba_erb at displacement 0x400
+       mba_as at displacement 0x410
+       mba_map at displacement 0x800
+ */
+
+#define MBA0 0x80028000
+#define MBA1 0x8002a000
+
+#define MBA_ERB 0x400
+#define MBA_MAP 0x800
+
+#define MBA0_MAP MBA0 + 0x800
+#define MBA1_MAP MBA1 + 0x800
+
+#define MBAEBITS 0xe0770
+
+
+#define MBAIE 0x4
+
diff --git a/usr/src/sys/h/mba.m b/usr/src/sys/h/mba.m
new file mode 100644 (file)
index 0000000..1afda57
--- /dev/null
@@ -0,0 +1,15 @@
+#
+#      VAX massbus adapter registers
+#
+
+       .set    MBA0_CSR,0x80028000             # virtual address of mba0
+       .set    MBA1_CSR,0x8002a000             # ditto mba1
+
+       .set    MBA_CSR,0       # configuration and status register
+       .set    MBA_CR,4        # control register
+       .set    MBA_SR,8        # status register
+       .set    MBA_VAR,12      # virtual address register
+       .set    MBA_BCR,16      # byte count register
+       .set    MBA_ERB,0x400   # ???
+       .set    MBA_AS,0x410    # attention summary
+
diff --git a/usr/src/sys/h/mem.h b/usr/src/sys/h/mem.h
new file mode 100644 (file)
index 0000000..4b5b503
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * "incore" memory free list
+ */
+
+struct {
+       int m_free;
+       short m_pnum[NICMEM];
+       } mem;
+
+int firstfree, maxfree, lastpos;
+int masktab[] = {
+       0x1,
+       0x2,
+       0x4,
+       0x8,
+       0x10,
+       0x20,
+       0x40,
+       0x80,
+       0x100,
+       0x200,
+       0x400,
+       0x800,
+       0x1000,
+       0x2000,
+       0x4000,
+       0x8000,
+       0x10000,
+       0x20000,
+       0x40000,
+       0x80000,
+       0x100000,
+       0x200000,
+       0x400000,
+       0x800000,
+       0x1000000,
+       0x2000000,
+       0x4000000,
+       0x8000000,
+       0x10000000,
+       0x20000000,
+       0x40000000,
+       0x80000000,
+       };
diff --git a/usr/src/sys/h/mount.h b/usr/src/sys/h/mount.h
new file mode 100755 (executable)
index 0000000..dfdbc90
--- /dev/null
@@ -0,0 +1,11 @@
+/*
+ * Mount structure.
+ * One allocated on every mount.
+ * Used to find the super block.
+ */
+struct mount
+{
+       dev_t   m_dev;          /* device mounted */
+       struct buf *m_bufp;     /* pointer to superblock */
+       struct inode *m_inodp;  /* pointer to mounted on inode */
+} mount[NMOUNT];
diff --git a/usr/src/sys/h/mtpr.h b/usr/src/sys/h/mtpr.h
new file mode 100755 (executable)
index 0000000..c27dd35
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+       VAX processor register numbers
+ */
+
+#define KSP 0          /* kernal stack pointer */
+#define ESP 1          /* exec stack pointer */
+#define SSP 2          /* supervisor stack pointer */
+#define USP 3          /* user stack pointer */
+#define ISP 4          /* interrupt stack pointer */
+#define P0BR 8         /* p0 base register */
+#define P0LR 9         /* p0 length register */
+#define P1BR 10                /* p1 base register */
+#define P1LR 11                /* p1 length register */
+#define SBR 12         /* system segment base register */
+#define SLR 13         /* system segment length register */
+#define PCBB 16                /* process control block base */
+#define SCBB 17                /* system control block base */
+#define IPL 18         /* interrupt priority level */
+#define ASTLVL 19      /* async. system trap level */
+#define SIRR 20                /* software interrupt request */
+#define SISR 21                /* software interrupt summary */
+#define ICCS 24                /* interval clock control */
+#define NICR 25                /* next interval count */
+#define ICR 26         /* interval count */
+#define TODR 27                /* time of year (day) */
+#define RXCS 32                /* console receiver control and status */
+#define RXDB 33                /* console receiver data buffer */
+#define TXCS 34                /* console transmitter control and status */
+#define TXDB 35                /* console transmitter data buffer */
+#define MAPEN 56       /* memory management enable */
+#define TBIA 57                /* translation buffer invalidate all */
+#define TBIS 58                /* translation buffer invalidate single */
+#define PMR 61         /* performance monitor enable */
+#define SID 62         /* system identification */
+/*
+       VAX-11/780 specific registers
+ */
+#define ACCS 40                /* accelerator control and status */
+#define ACCR 41                /* accelerator maintenance */
+#define WCSA 44                /* WCS address */
+#define WCSD 45                /* WCS data */
+#define SBIFS 48       /* SBI fault and status */
+#define SBIS 49                /* SBI silo */
+#define SBISC 50       /* SBI silo comparator */
+#define SBIMT 51       /* SBI maintenance */
+#define SBIER 52       /* SBI error register */
+#define SBITA 53       /* SBI timeout address */
+#define SBIQC 54       /* SBI quadword clear */
+#define MBRK 60                /* micro-program breakpoint */
diff --git a/usr/src/sys/h/mtpr.m b/usr/src/sys/h/mtpr.m
new file mode 100755 (executable)
index 0000000..e8211ee
--- /dev/null
@@ -0,0 +1,48 @@
+#
+#      VAX processor register numbers
+#
+       .set    KSP,0           # kernal stack pointer
+       .set    ESP,1           # exec stack pointer
+       .set    SSP,2           # supervisor stack pointer
+       .set    USP,3           # user stack pointer
+       .set    ISP,4           # interrupt stack pointer
+       .set    P0BR,8          # p0 base register
+       .set    P0LR,9          # p0 length register
+       .set    P1BR,10         # p1 base register
+       .set    P1LR,11         # p1 length register
+       .set    SBR,12          # system segment base register
+       .set    SLR,13          # system segment length register
+       .set    PCBB,16         # process control block base
+       .set    SCBB,17         # system control block base
+       .set    IPL,18          # interrupt priority level
+       .set    ASTLVL,19       # async. system trap level
+       .set    SIRR,20         # software interrupt request
+       .set    SISR,21         # software interrupt summary
+       .set    ICCS,24         # interval clock control
+       .set    NICR,25         # next interval count
+       .set    ICR,26          # interval count
+       .set    TODR,27         # time of year (day)
+       .set    RXCS,32         # console receiver control and status
+       .set    RXDB,33         # console receiver data buffer
+       .set    TXCS,34         # console transmitter control and status
+       .set    TXDB,35         # console transmitter data buffer
+       .set    MAPEN,56        # memory management enable
+       .set    TBIA,57         # translation buffer invalidate all
+       .set    TBIS,58         # translation buffer invalidate single
+       .set    PMR,61          # performance monitor enable
+       .set    SID,62          # system identification
+#
+#      VAX-11/780 specific registers
+#
+       .set    ACCS,40         # accelerator control and status
+       .set    ACCR,41         # accelerator maintenance
+       .set    WCSA,44         # WCS address
+       .set    WCSD,45         # WCS data
+       .set    SBIFS,48        # SBI fault and status
+       .set    SBIS,49         # SBI silo
+       .set    SBISC,50        # SBI silo comparator
+       .set    SBIMT,51        # SBI maintenance
+       .set    SBIER,52        # SBI error register
+       .set    SBITA,53        # SBI timeout address
+       .set    SBIQC,54        # SBI quadword clear
+       .set    MBRK,60         # micro-program breakpoint
diff --git a/usr/src/sys/h/mx.h b/usr/src/sys/h/mx.h
new file mode 100644 (file)
index 0000000..f9e8e14
--- /dev/null
@@ -0,0 +1,143 @@
+#define        NGROUPS         10      /* number of mpx files permitted at one time */
+#define        NCHANS          20      /* number of channel structures */
+#define        NPORTS          30      /* number of channels to i/o ports */
+#define        CNTLSIZ         10
+#define        NLEVELS         4
+#define        NMSIZE          50      /* max size of mxlstn file name */
+
+/*
+ * header returned on read of mpx
+ */
+struct rh {
+       short   index;
+       short   count;
+       short   ccount;
+};
+
+/*
+ * head expected on write of mpx
+ */
+struct wh {
+       short   index;
+       short   count;
+       short   ccount;
+       char    *data;
+};
+
+struct mx_args {
+       char    *m_name;
+       int     m_cmd;
+       int     m_arg[3];
+};
+
+
+#ifdef KERNEL
+/*
+ * internal structure for channel
+ */
+
+struct chan {
+       short   c_flags;
+       char    c_index;
+       char    c_line;
+       struct  group   *c_group;
+       struct  file    *c_fy;
+       struct  tty     *c_ttyp;
+       struct  clist   c_ctlx;
+       int     c_pgrp;
+       struct  tty     *c_ottyp;
+       char    c_oline;
+       union {
+               struct  clist   datq;
+       } cx;
+       union {
+               struct  clist   datq;
+               struct  chan    *c_chan;
+       } cy;
+       struct  clist   c_ctly;
+};
+
+struct schan {
+       short   c_flags;
+       char    c_index;
+       char    c_line;
+       struct  group   *c_group;
+       struct  file    *c_fy;
+       struct  tty     *c_ttyp;
+       struct  clist   c_ctlx;
+       int     c_pgrp;
+};
+
+
+/*
+ * flags
+ */
+#define        INUSE   01
+#define COPEN  02
+#define        XGRP    04
+#define        YGRP    010
+#define        WCLOSE  020
+#define        ISGRP   0100
+#define        BLOCK   0200
+#define        EOTMARK 0400
+#define        SIGBLK  01000
+#define        BLKMSG  01000
+#define        ENAMSG  02000
+#define        WFLUSH  04000
+#define        NMBUF   010000
+#define        PORT    020000
+
+#endif
+
+
+
+
+
+
+
+
+
+/*
+ * mpxchan command codes
+ */
+#define        MPX     5
+#define        MPXN    6
+#define        CHAN    1
+#define JOIN   2
+#define EXTR   3
+#define        ATTACH  4
+#define        CONNECT 7
+#define        DETACH  8
+#define        DISCON  9
+#define DEBUG  10
+#define        NPGRP   11
+#define        CSIG    12
+#define PACK   13
+
+#define NDEBUGS        30
+/*
+ * control channel message codes
+ */
+#define M_WATCH 1
+#define M_CLOSE 2
+#define        M_EOT   3
+#define        M_OPEN  4
+#define        M_BLK   5
+#define        M_UBLK  6
+#define        DO_BLK  7
+#define        DO_UBLK 8
+#define        M_IOCTL 12
+
+
+/*
+ * debug codes other than mpxchan cmds
+ */
+#define MCCLOSE 29
+#define MCOPEN 28
+#define        ALL     27
+#define SCON   26
+#define        MSREAD  25
+#define        SDATA   24
+#define        MCREAD  23
+#define MCWRITE        22
+
diff --git a/usr/src/sys/h/nuser.h b/usr/src/sys/h/nuser.h
new file mode 100644 (file)
index 0000000..6365455
--- /dev/null
@@ -0,0 +1,129 @@
+#include "../h/pcb.h"
+/*
+ * The user structure.
+ * One allocated per process.
+ * Contains all per process data
+ * that doesn't need to be referenced
+ * while the process is swapped.
+ * The user block is USIZE*512 bytes
+ * long; resides at virtual kernel
+ * loc 80020000; contains the system
+ * stack per user; is cross referenced
+ * with the proc structure for the
+ * same process.
+ */
+#define        EXCLOSE 01
+struct user
+{
+       struct pcb u_pcb;               /* pcb, save area when exchanging stacks */
+       int u_ptable[(MAXUMEM+127)/128];        /* click nums of user page table */
+       label_t u_rsav;
+       char    u_segflg;               /* IO flag: 0:user D; 1:system; 2:user I */
+       char    u_error;                /* return error code */
+       short   u_uid;                  /* effective user id */
+       short   u_gid;                  /* effective group id */
+       short   u_ruid;                 /* real user id */
+       short   u_rgid;                 /* real group id */
+       struct proc *u_procp;           /* pointer to proc structure */
+       int     *u_ap;                  /* pointer to arglist */
+       union {                         /* syscall return values */
+               struct  {
+                       int     r_val1;
+                       int     r_val2;
+               };
+               off_t   r_off;
+               time_t  r_time;
+       } u_r;
+       caddr_t u_base;                 /* base address for IO */
+       unsigned int u_count;           /* bytes remaining for IO */
+       off_t   u_offset;               /* offset in file for IO */
+       struct inode *u_cdir;           /* pointer to inode of current directory */
+       struct inode *u_rdir;           /* root directory of current process */
+       char    u_dbuf[DIRSIZ];         /* current pathname component */
+       caddr_t u_dirp;                 /* pathname pointer */
+       struct direct u_dent;           /* current directory entry */
+       struct inode *u_pdir;           /* inode of parent directory of dirp */
+       struct file *u_ofile[NOFILE];   /* pointers to file structures of open files */
+       char    u_pofile[NOFILE];       /* per-process flags of open files */
+       int     u_arg[5];               /* arguments to current system call */
+       unsigned u_tsize;               /* text size (clicks) */
+       unsigned u_dsize;               /* data size (clicks) */
+       unsigned u_ssize;               /* stack size (clicks) */
+       label_t u_qsav;                 /* label variable for quits and interrupts */
+       label_t u_ssav;                 /* label variable for swapping */
+       int     u_signal[NSIG];         /* disposition of signals */
+       time_t  u_utime;                /* this process user time */
+       time_t  u_stime;                /* this process system time */
+       time_t  u_cutime;               /* sum of childs' utimes */
+       time_t  u_cstime;               /* sum of childs' stimes */
+       int     *u_ar0;                 /* address of users saved R0 */
+       struct {                        /* profile arguments */
+               short   *pr_base;       /* buffer base */
+               unsigned pr_size;       /* buffer size */
+               unsigned pr_off;        /* pc offset */
+               unsigned pr_scale;      /* pc scaling */
+       } u_prof;
+       char    u_intflg;               /* catch intr from sys */
+       char    u_sep;                  /* flag for I and D separation */
+       struct tty *u_ttyp;             /* controlling tty pointer */
+       dev_t   u_ttyd;                 /* controlling tty dev */
+       struct {                        /* header of executable file */
+               int     ux_mag;         /* magic number */
+               unsigned ux_tsize;      /* text size */
+               unsigned ux_dsize;      /* data size */
+               unsigned ux_bsize;      /* bss size */
+               unsigned ux_ssize;      /* symbol table size */
+               unsigned ux_entloc;     /* entry location */
+               unsigned ux_unused;
+               unsigned ux_relflg;
+       } u_exdata;
+       char    u_comm[DIRSIZ];
+       time_t  u_start;
+       char    u_acflag;
+       short   u_fpflag;               /* unused now, will be later */
+       short   u_cmask;                /* mask for file creation */
+       int     u_stack[1];
+                                       /* kernel stack per user
+                                        * extends from u + USIZE*64
+                                        * backward not to reah here
+                                        */
+};
+
+/* u_error codes */
+#define        EPERM   1
+#define        ENOENT  2
+#define        ESRCH   3
+#define        EINTR   4
+#define        EIO     5
+#define        ENXIO   6
+#define        E2BIG   7
+#define        ENOEXEC 8
+#define        EBADF   9
+#define        ECHILD  10
+#define        EAGAIN  11
+#define        ENOMEM  12
+#define        EACCES  13
+#define        EFAULT  14
+#define        ENOTBLK 15
+#define        EBUSY   16
+#define        EEXIST  17
+#define        EXDEV   18
+#define        ENODEV  19
+#define        ENOTDIR 20
+#define        EISDIR  21
+#define        EINVAL  22
+#define        ENFILE  23
+#define        EMFILE  24
+#define        ENOTTY  25
+#define        ETXTBSY 26
+#define        EFBIG   27
+#define        ENOSPC  28
+#define        ESPIPE  29
+#define        EROFS   30
+#define        EMLINK  31
+#define        EPIPE   32
+#define EDOM   33
+#define        ERANGE  34
diff --git a/usr/src/sys/h/page.h b/usr/src/sys/h/page.h
new file mode 100755 (executable)
index 0000000..c2a719e
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+  VAX page table entry
+ */
+
+struct pt_entry {
+       int pg_pfnum:21,
+               :2,
+               pg_type:2,
+               :1,
+           pg_m:1,
+           pg_prot:4,
+           pg_v:1;
+};
+
+#define PG_PFNUM 0x1fffff
+#define PG_M 0x4000000
+#define PG_PROT 0x78000000
+#define PG_V 0x80000000
+
+#define PG_NOACC 0
+#define PG_KR 0x18000000
+#define PG_KW 0x10000000
+#define PG_UW 0x20000000
+#define PGURKW 0x60000000
+#define PG_URKR 0x78000000
+
+#define PG_TXT 0x01800000
diff --git a/usr/src/sys/h/page.m b/usr/src/sys/h/page.m
new file mode 100644 (file)
index 0000000..8a0be04
--- /dev/null
@@ -0,0 +1,15 @@
+#
+# VAX page table entry
+#
+
+       .set    PG_PFNUM,0x1fffff
+       .set    PG_M,0x4000000
+       .set    PG_PROT,0x78000000
+       .set    PG_V,0x80000000
+
+       .set    PG_NOACC,0
+       .set    PG_KR,0x18000000
+       .set    PG_KW,0x10000000
+       .set    PG_UW,0x20000000
+       .set    PGURKW,0x60000000
+       .set    PG_URKR,0x78000000
diff --git a/usr/src/sys/h/param.h b/usr/src/sys/h/param.h
new file mode 100644 (file)
index 0000000..53d0c02
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * tunable variables
+ */
+
+#define        NBUF    32              /* size of buffer cache */
+#define        NINODE  150             /* number of in core inodes */
+#define        NFILE   175             /* number of in core file structures */
+#define        NMOUNT  8               /* number of mountable file systems */
+#define        MAXMEM  1024            /* max core in 512-byte clicks */
+  /*
+   ***********************************************************
+   * NOTE: For the moment, MAXUMEM must be less than 12*128  *
+   ***********************************************************
+   */
+#define        MAXUMEM (MAXMEM - 128)  /* max no. clicks per process */
+#define        SWAPSIZE        16              /* granularity of partial swaps (in clicks) */
+#define        MAXUPRC 25              /* max processes per user */
+#define        SSIZE   4               /* initial stack size (*512 bytes) */
+#define        SINCR   2               /* increment of stack (*512 bytes) */
+#define        NOFILE  20              /* max open files per process */
+#define        CANBSIZ 256             /* max size of typewriter line */
+#define        CMAPSIZ (PHYSPAGES/32)  /* size of core allocation area */
+#define        SMAPSIZ 70              /* size of swap allocation area */
+#define        NCALL   20              /* max simultaneous time callouts */
+#define        NPROC   125             /* max number of processes */
+#define        NTEXT   80              /* max number of pure texts */
+#define        NCLIST  200             /* max total clist size */
+#define        HZ      60              /* Ticks/second of the clock */
+#define        TIMEZONE        (5*60)          /* Minutes westward from Greenwich */
+#define        DSTFLAG 1               /* Daylight Saving Time applies in this locality */
+#define        MSGBUFS 128             /* Characters saved from error messages */
+#define        NCARGS  5120            /* # characters in exec arglist */
+#define        USRSTACK 0x80000000     /* Start of user stack */
+#define PHYSPAGES 2048         /* max number of real memory pages */
+
+/*
+ * priorities
+ * probably should not be
+ * altered too much
+ */
+
+#define        PSWP    0
+#define        PINOD   10
+#define        PRIBIO  20
+#define        PZERO   25
+#define NZERO  20
+#define        PPIPE   26
+#define        PWAIT   30
+#define        PSLEP   40
+#define        PUSER   50
+
+/*
+ * signals
+ * dont change
+ */
+
+#define        NSIG    17
+/*
+ * No more than 16 signals (1-16) because they are
+ * stored in bits in a word.
+ */
+#define        SIGHUP  1       /* hangup */
+#define        SIGINT  2       /* interrupt (rubout) */
+#define        SIGQUIT 3       /* quit (FS) */
+#define        SIGINS  4       /* illegal instruction */
+#define        SIGTRC  5       /* trace or breakpoint */
+#define        SIGIOT  6       /* iot */
+#define        SIGEMT  7       /* emt */
+#define        SIGFPT  8       /* floating exception */
+#define        SIGKIL  9       /* kill, uncatchable termination */
+#define        SIGBUS  10      /* bus error */
+#define        SIGSEG  11      /* segmentation violation */
+#define        SIGSYS  12      /* bad system call */
+#define        SIGPIPE 13      /* end of pipe */
+#define        SIGCLK  14      /* alarm clock */
+#define        SIGTRM  15      /* Catchable termination */
+
+/*
+ * fundamental constants of the implementation--
+ * cannot be changed easily
+ */
+
+#define        NBPW    sizeof(int)     /* number of bytes in an integer */
+#define        BSIZE   512             /* size of secondary block (bytes) */
+/* BSLOP can be 0 unless you have a TIU/Spider */
+# define BSLOP 0       /* In case some device needs bigger buffers */
+#define        NINDIR  (BSIZE/sizeof(daddr_t))
+#define        BMASK   0777            /* BSIZE-1 */
+#define        BSHIFT  9               /* LOG2(BSIZE) */
+#define        NMASK   0177            /* NINDIR-1 */
+#define        NSHIFT  7               /* LOG2(NINDIR) */
+#define        UPAGES  4               /* pages of u-area (not including page tables ) */
+#define USIZE  (UPAGES + u.u_pcb.pcb_szpt)     /* size of user block (*512) */
+#define        NULL    0
+#define CMASK  0       /* default mask for file creation */
+#define        NODEV   (dev_t)(-1)
+#define        ROOTINO ((ino_t)2)      /* i number of all roots */
+#define        SUPERB  ((daddr_t)1)    /* block number of the super block */
+#define        DIRSIZ  14              /* max characters per directory */
+#define        NICINOD 100             /* number of superblock inodes */
+#define        NICFREE 50              /* number of superblock free blocks */
+#define NICMEM 100             /* number of "cheap" free page frames */
+#define        CBSIZE  12              /* number of chars in a clist block */
+#define        CROUND  0xF             /* clist rounding; sizeof(int *) + CBSIZE -1*/
+#define CLKTICK        (1000000/HZ)    /* microseconds in a  clock tick */
+
+/*
+ * Some macros for units conversion
+ */
+/* Core clicks (512 bytes) to segments and vice versa */
+#define        ctos(x) (x)
+#define        stoc(x) (x)
+
+/* Core clicks (512 bytes) to disk blocks */
+#define        ctod(x) (x)
+
+/* inumber to disk address */
+#define        itod(x) (daddr_t)((((unsigned)x+15)>>3))
+
+/* inumber to disk offset */
+#define        itoo(x) (int)((x+15)&07)
+
+/* clicks to bytes */
+#define        ctob(x) (x<<9)
+
+/* bytes to clicks */
+#define        btoc(x) ((((unsigned)x+511)>>9))
+
+/* major part of a device */
+#define        major(x)        (int)(((unsigned)x>>8)&0377)
+
+/* minor part of a device */
+#define        minor(x)        (int)(x&0377)
+
+/* make a device number */
+#define        makedev(x,y)    (dev_t)(((x)<<8) | (y))
+
+typedef        struct { int r[1]; } *  physadr;
+typedef        int             daddr_t;
+typedef char *         caddr_t;
+typedef        unsigned short          ino_t;
+typedef        int             time_t;
+typedef        int             label_t[10];
+typedef        short           dev_t;
+typedef        int             off_t;
+
+/*
+ * Machine-dependent bits and macros
+ */
+#define        UMODE   PSL_CURMOD              /* usermode bits */
+#define        USERMODE(ps)    ((ps & UMODE) == UMODE)
+
+#define        BASEPRI(ps)     ((ps & PSL_IPL) != 0)
diff --git a/usr/src/sys/h/pcb.h b/usr/src/sys/h/pcb.h
new file mode 100755 (executable)
index 0000000..a28f6a6
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+   VAX process control block
+ */
+
+struct pcb {
+       int
+       pcb_ksp,        /* kernal stack pointer */
+       pcb_esp,        /* exec stack pointer */
+       pcb_ssp,        /* supervisor stack pointer */
+       pcb_usp,        /* user stack pointer */
+       pcb_r0, 
+       pcb_r1, 
+       pcb_r2, 
+       pcb_r3, 
+       pcb_r4, 
+       pcb_r5, 
+       pcb_r6, 
+       pcb_r7, 
+       pcb_r8, 
+       pcb_r9, 
+       pcb_r10, 
+       pcb_r11, 
+       pcb_r12, 
+       pcb_r13, 
+       pcb_pc,         /* program counter */
+       pcb_psl,        /* program status longword */
+       pcb_p0br,       /* seg 0 base register */
+       pcb_p0lr,       /* seg 0 length register and astlevel */
+       pcb_p1br,       /* seg 1 base register */
+       pcb_p1lr,       /* seg 1 length register and pme */
+
+/*
+   Software pcb (extension)
+ */
+
+       pcb_szpt;       /* number of pages of user page table */
+
+};
diff --git a/usr/src/sys/h/pcb.m b/usr/src/sys/h/pcb.m
new file mode 100755 (executable)
index 0000000..cf6b4eb
--- /dev/null
@@ -0,0 +1,35 @@
+#
+#      VAX process control block
+#
+
+       .set    PCB_KSP,0       # kernal stack pointer
+       .set    PCB_ESP,4       # exec stack pointer
+       .set    PCB_SSP,8       # supervisor stack pointer
+       .set    PCB_USP,12      # user stack pointer
+       .set    PCB_R0,16
+       .set    PCB_R1,20
+       .set    PCB_R2,24
+       .set    PCB_R3,28
+       .set    PCB_R4,32
+       .set    PCB_R5,36
+       .set    PCB_R6,40
+       .set    PCB_R7,44
+       .set    PCB_R8,48
+       .set    PCB_R9,52
+       .set    PCB_R10,56
+       .set    PCB_R11,60
+       .set    PCB_R12,64
+       .set    PCB_R13,68
+       .set    PCB_PC,72       # program counter
+       .set    PCB_PSL,76      # program status longword
+       .set    PCB_P0BR,80     # seg 0 base register
+       .set    PCB_P0LR,84     # seg 0 length register and astlevel
+       .set    PCB_P1BR,88     # seg 1 base register
+       .set    PCB_P1LR,92     # seg 1 length register and pme
+
+#
+#      software pcb (extension)
+#
+
+       .set    PCB_SZPT,96     # number of pages of user page table
+
diff --git a/usr/src/sys/h/proc.h b/usr/src/sys/h/proc.h
new file mode 100644 (file)
index 0000000..8dfa6c8
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * One structure allocated per active
+ * process. It contains all data needed
+ * about the process while the
+ * process may be swapped out.
+ * Other per process data (user.h)
+ * is swapped with the process.
+ */
+struct proc {
+       char    p_stat;
+       char    p_flag;
+       char    p_pri;          /* priority, negative is high */
+       char    p_time;         /* resident time for scheduling */
+       char    p_cpu;          /* cpu usage for scheduling */
+       char    p_nice;         /* nice for cpu usage */
+       short   p_sig;          /* signals pending to this process */
+       short   p_uid;          /* user id, used to direct tty signals */
+       short   p_pgrp;         /* name of process group leader */
+       short   p_pid;          /* unique process id */
+       short   p_ppid;         /* process id of parent */
+       short   p_addr[UPAGES]; /* page table entries of u-area */
+       short   p_size;         /* size of swappable image (clicks) */
+       short   p_swaddr;       /* disk address when swapped */
+       short   p_swsize;       /* number of clicks already swapped */
+       short   p_tsize;        /* size of text (used by exec/swapin) */
+       caddr_t p_wchan;        /* event process is awaiting */
+       struct text *p_textp;   /* pointer to text structure */
+       struct proc *p_link;    /* linked list of running processes */
+       int     p_clktim;       /* time to alarm clock signal */
+};
+
+extern struct proc proc[];     /* the proc table itself */
+
+/* stat codes */
+#define        SSLEEP  1               /* awaiting an event */
+#define        SWAIT   2               /* (abandoned state) */
+#define        SRUN    3               /* running */
+#define        SIDL    4               /* intermediate state in process creation */
+#define        SZOMB   5               /* intermediate state in process termination */
+#define        SSTOP   6               /* process being traced */
+
+/* flag codes */
+#define        SLOAD   01              /* in core */
+#define        SSYS    02              /* scheduling process */
+#define        SLOCK   04              /* process cannot be swapped */
+#define        SSWAP   010             /* process is being swapped out */
+#define        STRC    020             /* process is being traced */
+#define        SWTED   040             /* another tracing flag */
+#define        SULOCK  0100            /* user settable lock in core */
+#define        SSPART  0200    /* process is partially swapped out */
+
+/*
+ * parallel proc structure
+ * to replace part with times
+ * to be passed to parent process
+ * in ZOMBIE state.
+ */
+struct xproc {
+       char    xp_stat;
+       char    xp_flag;
+       char    xp_pri;         /* priority, negative is high */
+       char    xp_time;        /* resident time for scheduling */
+       char    xp_cpu;         /* cpu usage for scheduling */
+       char    xp_nice;        /* nice for cpu usage */
+       short   xp_sig;         /* signals pending to this process */
+       short   xp_uid;         /* user id, used to direct tty signals */
+       short   xp_pgrp;        /* name of process group leader */
+       short   xp_pid;         /* unique process id */
+       short   xp_ppid;        /* process id of parent */
+       short   xp_xstat;       /* Exit status for wait */
+       time_t  xp_utime;       /* user time, this proc */
+       time_t  xp_stime;       /* system time, this proc */
+};
diff --git a/usr/src/sys/h/psl.h b/usr/src/sys/h/psl.h
new file mode 100755 (executable)
index 0000000..3f0e26b
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+       VAX program status longword
+ */
+
+#define PSL_C 0x1              /* carry bit */
+#define PSL_V 0x2              /* overflow bit */
+#define PSL_Z 0x4              /* zero bit */
+#define PSL_N 0x8              /* negative bit */
+#define PSL_T 0x10             /* trace enable bit */
+#define PSL_IV 0x20            /* integer overflow enable bit */
+#define PSL_FU 0x40            /* floating point underflow enable bit */
+#define PSL_DV 0x80            /* decimal overflow enable bit */
+#define PSL_IPL 0x1f0000       /* interrupt priority level */
+#define PSL_PRVMOD 0xc00000    /* previous mode */
+#define PSL_CURMOD 0x3000000   /* current mode */
+#define PSL_IS 0x4000000       /* interrupt stack */
+#define PSL_FPD 0x8000000      /* first part done */
+#define PSL_TP 0x40000000      /* trace pending */
+#define PSL_CM 0x80000000      /* compatibility mode */
+
diff --git a/usr/src/sys/h/psl.m b/usr/src/sys/h/psl.m
new file mode 100644 (file)
index 0000000..75f9c6e
--- /dev/null
@@ -0,0 +1,20 @@
+#
+#      VAX program status longword
+#
+
+       .set    PSL_C,0x1               # carry bit
+       .set    PSL_V,0x2               # overflow bit
+       .set    PSL_Z,0x4               # zero bit
+       .set    PSL_N,0x8               # negative bit
+       .set    PSL_T,0x10              # trace enable bit
+       .set    PSL_IV,0x20             # integer overflow enable bit
+       .set    PSL_FU,0x40             # floating point underflow enable bit
+       .set    PSL_DV,0x80             # decimal overflow enable bit
+       .set    PSL_IPL,0x1f0000        # interrupt priority level
+       .set    PSL_PRVMOD,0xc00000     # previous mode
+       .set    PSL_CURMOD,0x3000000    # current mode
+       .set    PSL_IS,0x4000000        # interrupt stack
+       .set    PSL_FPD,0x8000000       # first part done
+       .set    PSL_TP,0x40000000       # trace pending
+       .set    PSL_CM,0x80000000       # compatibility mode
+
diff --git a/usr/src/sys/h/reg.h b/usr/src/sys/h/reg.h
new file mode 100755 (executable)
index 0000000..f967548
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Location of the users' stored
+ * registers relative to R0.
+ * Usage is u.u_ar0[XX].
+ */
+#define        R0      0
+#define        R1      1
+#define        R2      2
+#define        R3      3
+#define        R4      4
+#define        R5      5
+#define        R6      6
+#define        R7      7
+#define        R8      8
+#define        R9      9
+#define        R10     10
+#define        R11     11
+#define        R12     12
+#define        R13     13
+
+#define AP     12
+#define        FP      13
+#define        SP      14
+#define        PS      18
+#define        PC      17
diff --git a/usr/src/sys/h/seg.h b/usr/src/sys/h/seg.h
new file mode 100755 (executable)
index 0000000..ab0437d
--- /dev/null
@@ -0,0 +1,6 @@
+/*
+ * Mapper addresses and bits
+ */
+
+#define        RO      PG_URKR         /* access abilities */
+#define        RW      PG_UW
diff --git a/usr/src/sys/h/stat.h b/usr/src/sys/h/stat.h
new file mode 100644 (file)
index 0000000..8101f5e
--- /dev/null
@@ -0,0 +1,28 @@
+struct stat
+{
+       dev_t   st_dev;
+       ino_t   st_ino;
+       unsigned short st_mode;
+       short           st_nlink;
+       short           st_uid;
+       short           st_gid;
+       dev_t   st_rdev;
+       off_t   st_size;
+       time_t  st_atime;
+       time_t  st_mtime;
+       time_t  st_ctime;
+};
+
+#define        S_IFMT  0170000         /* type of file */
+#define                S_IFDIR 0040000 /* directory */
+#define                S_IFCHR 0020000 /* character special */
+#define                S_IFBLK 0060000 /* block special */
+#define                S_IFREG 0100000 /* regular */
+#define                S_IFMPC 0030000 /* multiplexed char special */
+#define                S_IFMPB 0070000 /* multiplexed block special */
+#define        S_ISUID 0004000         /* set user id on execution */
+#define        S_ISGID 0002000         /* set group id on execution */
+#define        S_ISVTX 0001000         /* save swapped text even after use */
+#define        S_IREAD 0000400         /* read permission, owner */
+#define        S_IWRITE        0000200         /* write permission, owner */
+#define        S_IEXEC 0000100         /* execute/search permission, owner */
diff --git a/usr/src/sys/h/systm.h b/usr/src/sys/h/systm.h
new file mode 100644 (file)
index 0000000..d68e8ce
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Random set of variables
+ * used by more than one
+ * routine.
+ */
+char   canonb[CANBSIZ];        /* buffer for erase and kill (#@) */
+struct inode *rootdir;         /* pointer to inode of root directory */
+struct proc *runq;             /* head of linked list of running processes */
+int    cputype;                /* type of cpu =40, 45, or 70 */
+int    lbolt;                  /* time of day in 60th not in time */
+time_t time;                   /* time in sec from 1970 */
+
+/*
+ * Nblkdev is the number of entries
+ * (rows) in the block switch. It is
+ * set in binit/bio.c by making
+ * a pass over the switch.
+ * Used in bounds checking on major
+ * device numbers.
+ */
+int    nblkdev;
+
+/*
+ * Number of character switch entries.
+ * Set by cinit/tty.c
+ */
+int    nchrdev;
+
+int    mpid;                   /* generic for unique process id's */
+char   runin;                  /* scheduling flag */
+char   runout;                 /* scheduling flag */
+char   runrun;                 /* scheduling flag */
+char   curpri;                 /* more scheduling */
+int    maxmem;                 /* actual max memory per process */
+int    physmem;                        /* physical memory on this CPU */
+int    freemem;                        /* remaining blocks of free memory */
+daddr_t        swplo;                  /* block number of swap space */
+int    nswap;                  /* size of swap space */
+int    updlock;                /* lock for sync */
+daddr_t        rablock;                /* block to be read ahead */
+char   msgbuf[MSGBUFS];        /* saved "printf" characters */
+int    intstack[512];          /* stack for interrupts */
+dev_t  rootdev;                /* device of the root */
+dev_t  swapdev;                /* swapping device */
+dev_t  pipedev;                /* pipe device */
+extern int     icode[];        /* user init code */
+extern int     szicode;        /* its size */
+
+dev_t getmdev();
+daddr_t        bmap();
+struct inode *ialloc();
+struct inode *iget();
+struct inode *owner();
+struct inode *maknode();
+struct inode *namei();
+struct buf *alloc();
+struct buf *getblk();
+struct buf *geteblk();
+struct buf *bread();
+struct buf *breada();
+struct filsys *getfs();
+struct file *getf();
+struct file *falloc();
+int    uchar();
+caddr_t        realaddr();
+caddr_t        checkio();
+/*
+ * Instrumentation
+ */
+int    dk_busy;
+long   dk_time[32];
+long   dk_numb[3];
+long   dk_wds[3];
+long   tk_nin;
+long   tk_nout;
+
+/*
+ * Structure of the system-entry table
+ */
+extern struct sysent {
+       char    sy_narg;                /* total number of arguments */
+       char    sy_nrarg;               /* number of args in registers */
+       int     (*sy_call)();           /* handler */
+} sysent[];
diff --git a/usr/src/sys/h/text.h b/usr/src/sys/h/text.h
new file mode 100644 (file)
index 0000000..625fa85
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Text structure.
+ * One allocated per pure
+ * procedure on swap device.
+ * Manipulated by text.c
+ */
+struct text
+{
+       short   x_daddr;        /* disk address of segment (relative to swplo) */
+       short   x_size;         /* size (clicks) */
+       struct proc *x_caddr;   /* ptr to linked proc, if loaded */
+       struct inode *x_iptr;   /* inode of prototype */
+       char    x_count;        /* reference count */
+       char    x_ccount;       /* number of loaded references */
+       char    x_flag;         /* traced, written flags */
+};
+
+extern struct text text[];
+
+#define        XTRC    01              /* Text may be written, exclusive use */
+#define        XWRIT   02              /* Text written into, must swap out */
+#define        XLOAD   04              /* Currently being read from file */
+#define        XLOCK   010             /* Being swapped in or out */
+#define        XWANT   020             /* Wanted for swapping */
diff --git a/usr/src/sys/h/timeb.h b/usr/src/sys/h/timeb.h
new file mode 100644 (file)
index 0000000..23c850c
--- /dev/null
@@ -0,0 +1,9 @@
+/*
+ * Structure returned by ftime system call
+ */
+struct timeb {
+       time_t  time;
+       unsigned short millitm;
+       short   timezone;
+       short   dstflag;
+};
diff --git a/usr/src/sys/h/trap.h b/usr/src/sys/h/trap.h
new file mode 100755 (executable)
index 0000000..5751444
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+       Trap type values
+ */
+
+#define RESADFLT 0             /* reserved addressing fault */
+#define PRIVINFLT 1            /* privileged instruction fault */
+#define BPTFLT 2               /* bpt instruction fault */
+#define XFCFLT 3               /* xfc instruction fault */
+#define RESOPFLT 4             /* reserved operand fault */
+#define SYSCALL 5              /* chmk instruction (syscall trap) */
+#define ARITHTRAP 6            /* arithmetic trap */
+#define RESCHED 7              /* software level 1 trap (reschedule trap) */
+#define SEGFLT 8               /* segmentation fault */
+#define PROTFLT 9              /* protection fault */
+#define TRCTRAP 10             /* trace trap */
+#define COMPATFLT 11   /* compatibility mode fault */
+
diff --git a/usr/src/sys/h/trap.m b/usr/src/sys/h/trap.m
new file mode 100644 (file)
index 0000000..1afb58c
--- /dev/null
@@ -0,0 +1,17 @@
+#
+#      Trap,type values
+#
+
+       .set    RESADFLT,0              # reserved addressing fault
+       .set    PRIVINFLT,1             # privileged instruction fault
+       .set    BPTFLT,2                # bpt instruction fault
+       .set    XFCFLT,3                # xfc instruction fault
+       .set    RESOPFLT,4              # reserved operand fault
+       .set    SYSCALL,5               # chmk instruction (syscall trap)
+       .set    ARITHTRAP,6             # arithmetic trap
+       .set    RESCHED,7               # software level 1 trap (reschedule trap)
+       .set    SEGFLT,8                # segmentation fault
+       .set    PROTFLT,9               # protection fault
+
+       .set    TRCTRAP,10              # trace trap
+       .set    COMPATFLT,11    # compatibility mode fault
diff --git a/usr/src/sys/h/tty.h b/usr/src/sys/h/tty.h
new file mode 100644 (file)
index 0000000..3ae06b9
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * A clist structure is the head
+ * of a linked list queue of characters.
+ * The characters are stored in 4-word
+ * blocks containing a link and several characters.
+ * The routines getc and putc
+ * manipulate these structures.
+ */
+struct clist
+{
+       int     c_cc;           /* character count */
+       char    *c_cf;          /* pointer to first char */
+       char    *c_cl;          /* pointer to last char */
+};
+
+/*
+ * A tty structure is needed for
+ * each UNIX character device that
+ * is used for normal terminal IO.
+ * The routines in tty.c handle the
+ * common code associated with
+ * these structures.
+ * The definition and device dependent
+ * code is in each driver. (kl.c dc.c dh.c)
+ */
+struct tty
+{
+       struct  clist t_rawq;   /* input chars right off device */
+       struct  clist t_canq;   /* input chars after erase and kill */
+       struct  clist t_outq;   /* output list to device */
+       int     (* t_oproc)();  /* routine to start output */
+       int     (* t_iproc)();  /* routine to start input */
+       struct chan *t_chan;    /* destination channel */
+       caddr_t t_linep;        /* aux line discipline pointer */
+       caddr_t t_addr;         /* device address */
+       short   t_flags;        /* mode, settable by ioctl call */
+       short   t_state;        /* internal state, not visible externally */
+       short   t_pgrp;         /* process group name */
+       char    t_delct;        /* number of delimiters in raw q */
+       char    t_line;         /* line discipline */
+       char    t_col;          /* printing column of device */
+       char    t_erase;        /* erase character */
+       char    t_kill;         /* kill character */
+       char    t_char;         /* character temporary */
+       char    t_ispeed;       /* input speed */
+       char    t_ospeed;       /* output speed */
+};
+
+/*
+ * structure of arg for ioctl
+ */
+struct ttiocb {
+       char    ioc_ispeed;
+       char    ioc_ospeed;
+       char    ioc_erase;
+       char    ioc_kill;
+       int     ioc_flags;
+};
+
+#define        TTIPRI  28
+#define        TTOPRI  29
+
+#define        CERASE  '#'             /* default special characters */
+#define        CEOT    004
+#define        CKILL   '@'
+#define        CQUIT   034             /* FS, cntl shift L */
+#define        CINTR   0177            /* DEL */
+#define        CSTOP   023             /* Stop output: ctl-s */
+#define        CSTART  021             /* Start output: ctl-q */
+
+/* limits */
+#define        TTHIWAT 100
+#define        TTLOWAT 50
+#define        TTYHOG  256
+
+/* modes */
+#define        TANDEM  01
+#define        CBREAK  02
+#define        LCASE   04
+#define        ECHO    010
+#define        CRMOD   020
+#define        RAW     040
+#define        ODDP    0100
+#define        EVENP   0200
+#define        NLDELAY 001400
+#define        TBDELAY 006000
+#define        XTABS   006000
+#define        CRDELAY 030000
+#define        VTDELAY 040000
+
+/* Hardware bits */
+#define        DONE    0200
+#define        IENABLE 0100
+
+/* Internal state bits */
+#define        TIMEOUT 01              /* Delay timeout in progress */
+#define        WOPEN   02              /* Waiting for open to complete */
+#define        ISOPEN  04              /* Device is open */
+#define        CARR_ON 020             /* Software copy of carrier-present */
+#define        BUSY    040             /* Output in progress */
+#define        ASLEEP  0100            /* Wakeup when output done */
+#define        XCLUDE  0200            /* exclusive-use flag against open */
+#define        TTSTOP  0400            /* Output stopped by ctl-s */
+#define        HUPCLS  01000           /* Hang up upon last close */
+#define        TBLOCK  02000           /* tandem queue blocked */
+
+/*
+ * tty ioctl commands
+ */
+#define        TIOCGETD        (('t'<<8)|0)
+#define        TIOCSETD        (('t'<<8)|1)
+#define        TIOCHPCL        (('t'<<8)|2)
+#define        TIOCMODG        (('t'<<8)|3)
+#define        TIOCMODS        (('t'<<8)|4)
+#define        TIOCGETP        (('t'<<8)|8)
+#define        TIOCSETP        (('t'<<8)|9)
+#define        TIOCSETN        (('t'<<8)|10)
+#define        TIOCEXCL        (('t'<<8)|13)
+#define        TIOCNXCL        (('t'<<8)|14)
+#define        TIOCTSTP        (('t'<<8)|16)
+#define        DIOCLSTN        (('d'<<8)|1)
+#define        DIOCGETP        (('d'<<8)|8)
+#define        DIOCSETP        (('d'<<8)|9)
+#define        FIOCLEX         (('f'<<8)|1)
+#define        FIONCLEX        (('f'<<8)|2)
+#define        MXLSTN          (('x'<<8)|1)
+#define        MXNBLK          (('x'<<8)|2)
diff --git a/usr/src/sys/h/uba.h b/usr/src/sys/h/uba.h
new file mode 100644 (file)
index 0000000..9bb6cd0
--- /dev/null
@@ -0,0 +1,94 @@
+# define UBA0 0x80024000 /* sys virt i/o for UBA 0 */
+# define UBA0_DEV UBA0 + 0x2000 - 0160000      /* sys virt of device regs */
+# define UNIBASE 0760000 /* UNIBUS phys base of i/o reg's */
+/* UBA Configuration Register, CNFGR */
+# define PARFLT 0x80000000 /* SBI Parity Fault */
+# define WSQFLT 0x40000000 /* SBI Write Sequence Fault */
+# define URDFLT 0x20000000 /* SBI Unexpected Read Fault */
+# define ISQFLT 0x10000000 /* SBI Interlock Sequence Fault */
+# define MXTFLT 0x8000000 /* SBI Multiple Transmitter Fault */
+# define XMTFLT 0x4000000 /* UBA is transmit faulter */
+# define ADPDN 0x800000 /* Adapter Power Down */
+# define ADPUP 0x400000 /* Adapter Power Up */
+# define UBINIT 0x40000 /* UNIBUS INIT is asserted */
+# define UBPDN 0x20000 /* UNIBUS Power Down */
+# define UBIC 0x10000 /* UNIBUS Initialization */
+                       /* UNIBUS Ready */
+# define UBACOD 0xff  /*  UBA Code bits */
+/* UBA Control Register, UBACR  */
+# define MRD16 0x40000000  /* Map Reg Disable Bit 4  */
+# define MRD8 0x20000000  /* Map Reg Disable Bit 3  */
+# define MRD4 0x10000000  /* Map Rg Disable Bit 2  */
+# define MRD2 0x8000000  /* Map Reg Disable Bit 1 */
+# define MRD1 0x4000000  /* Map Reg Disable Bit 0 */
+# define IFS 0x40  /*  Interrupt Field Switch */
+# define BRIE 0x20  /* BR Interrupt Enable  */
+# define USEFIE 0x10  /* UNIBUS to SBI Error Field IE */
+# define SUEFIE 0x8  /* SBI to UNIBUS Error Field IE */
+# define CNFIE 0x4  /* Configuration IE  */
+# define UPF 0x2  /* UNIBUS Power Fail  */
+# define ADINIT 0x1  /* Adapter Init */
+/*  UBA Status Register, UASR  */
+# define BR7FULL 0x8000000  /* BR7 Receive Vector Rg Full  */
+# define BR6FULL 0x4000000  /* BR6 Receive Vector Reg Full */
+# define BR5FULL 0x2000000  /* BR5 Receive Vector Reg Full */
+# define BR4FULL 0x1000000  /* BR4 Receive Vector Reg Full */
+# define RDTO 0x400  /* UNIBUS to SBI Read Data Timeout */
+# define RDS 0x200  /* Read Data Substitute  */
+# define CRD 0x100  /* Corrected Read Data */
+# define CXTER 0x80  /* Command Transmit Error */
+# define CXTMO 0x40  /* Command Transmit Timeout */
+# define DPPE 0x20  /* Data Path Parity Error */
+# define IVMR 0x10  /* Invalid Map Register */
+# define MRPF 0x8  /* Map Register Parity Failure */
+# define LEB 0x4  /*  Lost Error  */
+# define UBSTO 0x2  /* UNIBUS Select Timeout */
+# define UBSSTO 0x1  /* UNIBUS Slave Sync Timeout */
+/* Failed Map Entry Register, FMER  */
+# define FMRN 0x1ff  /* Failed Map Reg. No. Field */
+/*  Failed UNIBUS Address Register, FUBAR  */
+# define FUA 0xffff  /* Failed UNIBUS Address Field */
+/*  BR Receive Vector register, BRRVR  */
+# define AIRI 0x80000000  /* Adapter Interrupt Request */
+# define DIV 0xffff  /* Device Interrupt Vector Field */
+/*  Data Path Register, DPR  */
+# define BNE 0x80000000  /*  Buffer Not Empty - Purge */
+# define BTE 0x40000000  /*  Buffer Transfer Error  */
+# define DPF 0x20000000  /* DP Function (RO)  */
+# define BS 0x7f0000  /*  Buffer State Field */
+# define BUBA 0xffff  /*  Buffered UNIBUS Address  */
+/*  Map Register, MR  */
+# define MRV 0x80000000  /*  Map Register Valid  */
+# define BO 0x2000000  /*  Byte Offset Bit  */
+# define DPDB 0x1e00000  /* Data Path Designator Field  */
+# define SBIPFN 0xfffff  /* SBI Page Address Field  */
+# define UAMSIZ 50
+/*
+*  UBA registers
+*/
+
+struct uba_regs {
+       int uba_cnfgr,
+           uba_cr,
+           uba_sr,
+           uba_dcr,
+           uba_fmer,
+           uba_fubar,
+           pad1[2],
+           uba_brsvr[4],
+           uba_brrvr[4],
+           uba_dpr[16],
+           pad2[480],
+           uba_map[496];
+       };
+
diff --git a/usr/src/sys/h/uba.m b/usr/src/sys/h/uba.m
new file mode 100644 (file)
index 0000000..37efdce
--- /dev/null
@@ -0,0 +1,14 @@
+#
+#      VAX unibus adapter registers
+#
+
+       .set    UBA,0x80024000          # virtual address of unibus registers
+       .set    UBA0,0x80024000
+       .set    UBR_OFF,0x30  #  UBA  offset to BRRVR regs
+       .set    CFGFLT,0xfc000000  #  SBI fault bits in UBA config reg
+       .set    UCN_OFF,0  #  UBA offset to config reg
+       .set    UST_OFF,8  #  UBA  offset to status reg
+
+       .set    UBA_SR,UBA + 0x8
+       .set    UBA_BR4,UBA + 0x30      # virtual address of interrupt vector registers
+
diff --git a/usr/src/sys/h/user.h b/usr/src/sys/h/user.h
new file mode 100644 (file)
index 0000000..11943a9
--- /dev/null
@@ -0,0 +1,130 @@
+#include "../h/pcb.h"
+/*
+ * The user structure.
+ * One allocated per process.
+ * Contains all per process data
+ * that doesn't need to be referenced
+ * while the process is swapped.
+ * The user block is USIZE*512 bytes
+ * long; resides at virtual kernel
+ * loc 80020000; contains the system
+ * stack per user; is cross referenced
+ * with the proc structure for the
+ * same process.
+ */
+#define        EXCLOSE 01
+struct user
+{
+       struct pcb u_pcb;               /* pcb, save area when exchanging stacks */
+       int u_ptable[(MAXUMEM+127)/128];        /* click nums of user page table */
+       label_t u_rsav;
+       char    u_segflg;               /* IO flag: 0:user D; 1:system; 2:user I */
+       char    u_error;                /* return error code */
+       short   u_uid;                  /* effective user id */
+       short   u_gid;                  /* effective group id */
+       short   u_ruid;                 /* real user id */
+       short   u_rgid;                 /* real group id */
+       struct proc *u_procp;           /* pointer to proc structure */
+       int     *u_ap;                  /* pointer to arglist */
+       union {                         /* syscall return values */
+               struct  {
+                       int     r_val1;
+                       int     r_val2;
+               };
+               off_t   r_off;
+               time_t  r_time;
+       } u_r;
+       caddr_t u_base;                 /* base address for IO */
+       unsigned int u_count;           /* bytes remaining for IO */
+       off_t   u_offset;               /* offset in file for IO */
+       struct inode *u_cdir;           /* pointer to inode of current directory */
+       struct inode *u_rdir;           /* root directory of current process */
+       char    u_dbuf[DIRSIZ];         /* current pathname component */
+       caddr_t u_dirp;                 /* pathname pointer */
+       struct direct u_dent;           /* current directory entry */
+       struct inode *u_pdir;           /* inode of parent directory of dirp */
+       struct file *u_ofile[NOFILE];   /* pointers to file structures of open files */
+       char    u_pofile[NOFILE];       /* per-process flags of open files */
+       int     u_arg[5];               /* arguments to current system call */
+       unsigned u_tsize;               /* text size (clicks) */
+       unsigned u_dsize;               /* data size (clicks) */
+       unsigned u_ssize;               /* stack size (clicks) */
+       label_t u_qsav;                 /* label variable for quits and interrupts */
+       label_t u_ssav;                 /* label variable for swapping */
+       int     u_signal[NSIG];         /* disposition of signals */
+       time_t  u_utime;                /* this process user time */
+       time_t  u_stime;                /* this process system time */
+       time_t  u_cutime;               /* sum of childs' utimes */
+       time_t  u_cstime;               /* sum of childs' stimes */
+       int     *u_ar0;                 /* address of users saved R0 */
+       struct {                        /* profile arguments */
+               short   *pr_base;       /* buffer base */
+               unsigned pr_size;       /* buffer size */
+               unsigned pr_off;        /* pc offset */
+               unsigned pr_scale;      /* pc scaling */
+       } u_prof;
+       char    u_intflg;               /* catch intr from sys */
+       char    u_sep;                  /* flag for I and D separation */
+       struct tty *u_ttyp;             /* controlling tty pointer */
+       dev_t   u_ttyd;                 /* controlling tty dev */
+       struct {                        /* header of executable file */
+               int     ux_mag;         /* magic number */
+               unsigned ux_tsize;      /* text size */
+               unsigned ux_dsize;      /* data size */
+               unsigned ux_bsize;      /* bss size */
+               unsigned ux_ssize;      /* symbol table size */
+               unsigned ux_entloc;     /* entry location */
+               unsigned ux_unused;
+               unsigned ux_relflg;
+       } u_exdata;
+       char    u_comm[DIRSIZ];
+       time_t  u_start;
+       char    u_acflag;
+       short   u_fpflag;               /* unused now, will be later */
+       short   u_cmask;                /* mask for file creation */
+       int     u_stack[1];
+                                       /* kernel stack per user
+                                        * extends from u + USIZE*64
+                                        * backward not to reah here
+                                        */
+};
+
+extern struct user u;
+/* u_error codes */
+#define        EPERM   1
+#define        ENOENT  2
+#define        ESRCH   3
+#define        EINTR   4
+#define        EIO     5
+#define        ENXIO   6
+#define        E2BIG   7
+#define        ENOEXEC 8
+#define        EBADF   9
+#define        ECHILD  10
+#define        EAGAIN  11
+#define        ENOMEM  12
+#define        EACCES  13
+#define        EFAULT  14
+#define        ENOTBLK 15
+#define        EBUSY   16
+#define        EEXIST  17
+#define        EXDEV   18
+#define        ENODEV  19
+#define        ENOTDIR 20
+#define        EISDIR  21
+#define        EINVAL  22
+#define        ENFILE  23
+#define        EMFILE  24
+#define        ENOTTY  25
+#define        ETXTBSY 26
+#define        EFBIG   27
+#define        ENOSPC  28
+#define        ESPIPE  29
+#define        EROFS   30
+#define        EMLINK  31
+#define        EPIPE   32
+#define EDOM   33
+#define        ERANGE  34
diff --git a/usr/src/sys/sys/acct.c b/usr/src/sys/sys/acct.c
new file mode 100644 (file)
index 0000000..ec3f04f
--- /dev/null
@@ -0,0 +1,127 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/acct.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/inode.h"
+#include "../h/proc.h"
+#include "../h/seg.h"
+
+/*
+ * Perform process accounting functions.
+ */
+
+sysacct()
+{
+       register struct inode *ip;
+       register struct a {
+               char    *fname;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       if (suser()) {
+               if (uap->fname==NULL) {
+                       if (acctp) {
+                               plock(acctp);
+                               iput(acctp);
+                               acctp = NULL;
+                       }
+                       return;
+               }
+               if (acctp) {
+                       u.u_error = EBUSY;
+                       return;
+               }
+               ip = namei(uchar, 0);
+               if(ip == NULL)
+                       return;
+               if((ip->i_mode & IFMT) != IFREG) {
+                       u.u_error = EACCES;
+                       iput(ip);
+                       return;
+               }
+               acctp = ip;
+               prele(ip);
+       }
+}
+
+/*
+ * On exit, write a record on the accounting file.
+ */
+acct()
+{
+       register i;
+       register struct inode *ip;
+       off_t siz;
+
+       if ((ip=acctp)==NULL)
+               return;
+       plock(ip);
+       for (i=0; i<sizeof(acctbuf.ac_comm); i++)
+               acctbuf.ac_comm[i] = u.u_comm[i];
+       acctbuf.ac_utime = compress(u.u_utime);
+       acctbuf.ac_stime = compress(u.u_stime);
+       acctbuf.ac_etime = compress(time - u.u_start);
+       acctbuf.ac_btime = u.u_start;
+       acctbuf.ac_uid = u.u_ruid;
+       acctbuf.ac_gid = u.u_rgid;
+       acctbuf.ac_mem = 0;
+       acctbuf.ac_io = 0;
+       acctbuf.ac_tty = u.u_ttyd;
+       acctbuf.ac_flag = u.u_acflag;
+       siz = ip->i_size;
+       u.u_offset = siz;
+       u.u_base = (caddr_t)&acctbuf;
+       u.u_count = sizeof(acctbuf);
+       u.u_segflg = 1;
+       u.u_error = 0;
+       writei(ip);
+       if(u.u_error)
+               ip->i_size = siz;
+       prele(ip);
+}
+
+/*
+ * Produce a pseudo-floating point representation
+ * with 3 bits base-8 exponent, 13 bits fraction.
+ */
+compress(t)
+register time_t t;
+{
+       register exp = 0, round = 0;
+
+       while (t >= 8192) {
+               exp++;
+               round = t&04;
+               t >>= 3;
+       }
+       if (round) {
+               t++;
+               if (t >= 8192) {
+                       t >>= 3;
+                       exp++;
+               }
+       }
+       return((exp<<13) + t);
+}
+
+/*
+ * lock user into core as much
+ * as possible. swapping may still
+ * occur if core grows.
+ */
+syslock()
+{
+       register struct proc *p;
+       register struct a {
+               int     flag;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       if(suser()) {
+               p = u.u_procp;
+               p->p_flag &= ~SULOCK;
+               if(uap->flag)
+                       p->p_flag |= SULOCK;
+       }
+}
diff --git a/usr/src/sys/sys/alloc.c b/usr/src/sys/sys/alloc.c
new file mode 100644 (file)
index 0000000..e3b1818
--- /dev/null
@@ -0,0 +1,317 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/mount.h"
+#include "../h/filsys.h"
+#include "../h/fblk.h"
+#include "../h/conf.h"
+#include "../h/buf.h"
+#include "../h/inode.h"
+#include "../h/ino.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+typedef        struct fblk *FBLKP;
+
+/*
+ * alloc will obtain the next available
+ * free disk block from the free list of
+ * the specified device.
+ * The super block has up to NICFREE remembered
+ * free blocks; the last of these is read to
+ * obtain NICFREE more . . .
+ *
+ * no space on dev x/y -- when
+ * the free list is exhausted.
+ */
+struct buf *
+alloc(dev)
+dev_t dev;
+{
+       daddr_t bno;
+       register struct filsys *fp;
+       register struct buf *bp;
+
+       fp = getfs(dev);
+       while(fp->s_flock)
+               sleep((caddr_t)&fp->s_flock, PINOD);
+       do {
+               if(fp->s_nfree <= 0)
+                       goto nospace;
+               if (fp->s_nfree > NICFREE) {
+                       prdev("Bad free count", dev);
+                       goto nospace;
+               }
+               bno = fp->s_free[--fp->s_nfree];
+               if(bno == 0)
+                       goto nospace;
+       } while (badblock(fp, bno, dev));
+       if(fp->s_nfree <= 0) {
+               fp->s_flock++;
+               bp = bread(dev, bno);
+               if ((bp->b_flags&B_ERROR) == 0) {
+                       fp->s_nfree = ((FBLKP)(bp->b_un.b_addr))->df_nfree;
+                       bcopy((caddr_t)((FBLKP)(bp->b_un.b_addr))->df_free,
+                           (caddr_t)fp->s_free, sizeof(fp->s_free));
+               }
+               brelse(bp);
+               fp->s_flock = 0;
+               wakeup((caddr_t)&fp->s_flock);
+               if (fp->s_nfree <=0)
+                       goto nospace;
+       }
+       bp = getblk(dev, bno);
+       clrbuf(bp);
+       fp->s_fmod = 1;
+       return(bp);
+
+nospace:
+       fp->s_nfree = 0;
+       prdev("no space", dev);
+       u.u_error = ENOSPC;
+       return(NULL);
+}
+
+/*
+ * place the specified disk block
+ * back on the free list of the
+ * specified device.
+ */
+free(dev, bno)
+dev_t dev;
+daddr_t bno;
+{
+       register struct filsys *fp;
+       register struct buf *bp;
+
+       fp = getfs(dev);
+       fp->s_fmod = 1;
+       while(fp->s_flock)
+               sleep((caddr_t)&fp->s_flock, PINOD);
+       if (badblock(fp, bno, dev))
+               return;
+       if(fp->s_nfree <= 0) {
+               fp->s_nfree = 1;
+               fp->s_free[0] = 0;
+       }
+       if(fp->s_nfree >= NICFREE) {
+               fp->s_flock++;
+               bp = getblk(dev, bno);
+               ((FBLKP)(bp->b_un.b_addr))->df_nfree = fp->s_nfree;
+               bcopy((caddr_t)fp->s_free,
+                       (caddr_t)((FBLKP)(bp->b_un.b_addr))->df_free,
+                       sizeof(fp->s_free));
+               fp->s_nfree = 0;
+               bwrite(bp);
+               fp->s_flock = 0;
+               wakeup((caddr_t)&fp->s_flock);
+       }
+       fp->s_free[fp->s_nfree++] = bno;
+       fp->s_fmod = 1;
+}
+
+/*
+ * Check that a block number is in the
+ * range between the I list and the size
+ * of the device.
+ * This is used mainly to check that a
+ * garbage file system has not been mounted.
+ *
+ * bad block on dev x/y -- not in range
+ */
+badblock(fp, bn, dev)
+register struct filsys *fp;
+daddr_t bn;
+dev_t dev;
+{
+
+       if (bn < fp->s_isize || bn >= fp->s_fsize) {
+               prdev("bad block", dev);
+               return(1);
+       }
+       return(0);
+}
+
+/*
+ * Allocate an unused I node
+ * on the specified device.
+ * Used with file creation.
+ * The algorithm keeps up to
+ * NICINOD spare I nodes in the
+ * super block. When this runs out,
+ * a linear search through the
+ * I list is instituted to pick
+ * up NICINOD more.
+ */
+struct inode *
+ialloc(dev)
+dev_t dev;
+{
+       register struct filsys *fp;
+       register struct buf *bp;
+       register struct inode *ip;
+       int i;
+       struct dinode *dp;
+       ino_t ino;
+       daddr_t adr;
+
+       fp = getfs(dev);
+       while(fp->s_ilock)
+               sleep((caddr_t)&fp->s_ilock, PINOD);
+loop:
+       if(fp->s_ninode > 0) {
+               ino = fp->s_inode[--fp->s_ninode];
+               ip = iget(dev, ino);
+               if(ip == NULL)
+                       return(NULL);
+               if(ip->i_mode == 0) {
+                       for (i=0; i<NADDR; i++)
+                               ip->i_un.i_addr[i] = 0;
+                       fp->s_fmod = 1;
+                       return(ip);
+               }
+               /*
+                * Inode was allocated after all.
+                * Look some more.
+                */
+               iput(ip);
+               goto loop;
+       }
+       fp->s_ilock++;
+       ino = 1;
+       for(adr = SUPERB+1; adr < fp->s_isize; adr++) {
+               bp = bread(dev, adr);
+               if (bp->b_flags & B_ERROR) {
+                       brelse(bp);
+                       ino += INOPB;
+                       continue;
+               }
+               dp = bp->b_un.b_dino;
+               for(i=0; i<INOPB; i++) {
+                       if(dp->di_mode != 0)
+                               goto cont;
+                       for(ip = &inode[0]; ip < &inode[NINODE]; ip++)
+                       if(dev==ip->i_dev && ino==ip->i_number)
+                               goto cont;
+                       fp->s_inode[fp->s_ninode++] = ino;
+                       if(fp->s_ninode >= NICINOD)
+                               break;
+               cont:
+                       ino++;
+                       dp++;
+               }
+               brelse(bp);
+               if(fp->s_ninode >= NICINOD)
+                       break;
+       }
+       fp->s_ilock = 0;
+       wakeup((caddr_t)&fp->s_ilock);
+       if(fp->s_ninode > 0)
+               goto loop;
+       prdev("Out of inodes", dev);
+       u.u_error = ENOSPC;
+       return(NULL);
+}
+
+/*
+ * Free the specified I node
+ * on the specified device.
+ * The algorithm stores up
+ * to NICINOD I nodes in the super
+ * block and throws away any more.
+ */
+ifree(dev, ino)
+dev_t dev;
+ino_t ino;
+{
+       register struct filsys *fp;
+
+       fp = getfs(dev);
+       if(fp->s_ilock)
+               return;
+       if(fp->s_ninode >= NICINOD)
+               return;
+       fp->s_inode[fp->s_ninode++] = ino;
+       fp->s_fmod = 1;
+}
+
+/*
+ * getfs maps a device number into
+ * a pointer to the incore super
+ * block.
+ * The algorithm is a linear
+ * search through the mount table.
+ * A consistency check of the
+ * in core free-block and i-node
+ * counts.
+ *
+ * bad count on dev x/y -- the count
+ *     check failed. At this point, all
+ *     the counts are zeroed which will
+ *     almost certainly lead to "no space"
+ *     diagnostic
+ * panic: no fs -- the device is not mounted.
+ *     this "cannot happen"
+ */
+struct filsys *
+getfs(dev)
+dev_t dev;
+{
+       register struct mount *mp;
+       register struct filsys *fp;
+
+       for(mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
+       if(mp->m_bufp != NULL && mp->m_dev == dev) {
+               fp = mp->m_bufp->b_un.b_filsys;
+               if(fp->s_nfree > NICFREE || fp->s_ninode > NICINOD) {
+                       prdev("bad count", dev);
+                       fp->s_nfree = 0;
+                       fp->s_ninode = 0;
+               }
+               return(fp);
+       }
+       panic("no fs");
+       return(NULL);
+}
+
+/*
+ * update is the internal name of
+ * 'sync'. It goes through the disk
+ * queues to initiate sandbagged IO;
+ * goes through the I nodes to write
+ * modified nodes; and it goes through
+ * the mount table to initiate modified
+ * super blocks.
+ */
+update()
+{
+       register struct inode *ip;
+       register struct mount *mp;
+       register struct buf *bp;
+       struct filsys *fp;
+
+       if(updlock)
+               return;
+       updlock++;
+       for(mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
+               if(mp->m_bufp != NULL) {
+                       fp = mp->m_bufp->b_un.b_filsys;
+                       if(fp->s_fmod==0 || fp->s_ilock!=0 ||
+                          fp->s_flock!=0 || fp->s_ronly!=0)
+                               continue;
+                       bp = getblk(mp->m_dev, SUPERB);
+                       if (bp->b_flags & B_ERROR)
+                               continue;
+                       fp->s_fmod = 0;
+                       fp->s_time = time;
+                       bcopy((caddr_t)fp, bp->b_un.b_addr, BSIZE);
+                       bwrite(bp);
+               }
+       for(ip = &inode[0]; ip < &inode[NINODE]; ip++)
+               if((ip->i_flag&ILOCK)==0 && ip->i_count) {
+                       ip->i_flag |= ILOCK;
+                       ip->i_count++;
+                       iupdat(ip, &time, &time);
+                       iput(ip);
+               }
+       updlock = 0;
+       bflush(NODEV);
+}
diff --git a/usr/src/sys/sys/bio.c b/usr/src/sys/sys/bio.c
new file mode 100644 (file)
index 0000000..db3a44c
--- /dev/null
@@ -0,0 +1,558 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/buf.h"
+#include "../h/conf.h"
+#include "../h/proc.h"
+#include "../h/seg.h"
+#include "../h/page.h"
+
+#define        DISKMON 1
+
+#ifdef DISKMON
+struct {
+       int     nbuf;
+       long    nread;
+       long    nreada;
+       long    ncache;
+       long    nwrite;
+       long    bufcount[NBUF];
+} io_info;
+#endif
+
+/*
+ * swap IO headers.
+ * they are filled in to point
+ * at the desired IO operation.
+ */
+struct buf     swbuf1;
+struct buf     swbuf2;
+
+/*
+ * The following several routines allocate and free
+ * buffers with various side effects.  In general the
+ * arguments to an allocate routine are a device and
+ * a block number, and the value is a pointer to
+ * to the buffer header; the buffer is marked "busy"
+ * so that no one else can touch it.  If the block was
+ * already in core, no I/O need be done; if it is
+ * already busy, the process waits until it becomes free.
+ * The following routines allocate a buffer:
+ *     getblk
+ *     bread
+ *     breada
+ * Eventually the buffer must be released, possibly with the
+ * side effect of writing it out, by using one of
+ *     bwrite
+ *     bdwrite
+ *     bawrite
+ *     brelse
+ */
+
+/*
+ * Read in (if necessary) the block and return a buffer pointer.
+ */
+struct buf *
+bread(dev, blkno)
+dev_t dev;
+daddr_t blkno;
+{
+       register struct buf *bp;
+
+       bp = getblk(dev, blkno);
+       if (bp->b_flags&B_DONE) {
+#ifdef DISKMON
+               io_info.ncache++;
+#endif
+               return(bp);
+       }
+       bp->b_flags |= B_READ;
+       bp->b_bcount = BSIZE;
+       (*bdevsw[major(dev)].d_strategy)(bp);
+#ifdef DISKMON
+       io_info.nread++;
+#endif
+       iowait(bp);
+       return(bp);
+}
+
+/*
+ * Read in the block, like bread, but also start I/O on the
+ * read-ahead block (which is not allocated to the caller)
+ */
+struct buf *
+breada(dev, blkno, rablkno)
+dev_t dev;
+daddr_t blkno, rablkno;
+{
+       register struct buf *bp, *rabp;
+
+       bp = NULL;
+       if (!incore(dev, blkno)) {
+               bp = getblk(dev, blkno);
+               if ((bp->b_flags&B_DONE) == 0) {
+                       bp->b_flags |= B_READ;
+                       bp->b_bcount = BSIZE;
+                       (*bdevsw[major(dev)].d_strategy)(bp);
+#ifdef DISKMON
+                       io_info.nread++;
+#endif
+               }
+       }
+       if (rablkno && !incore(dev, rablkno)) {
+               rabp = getblk(dev, rablkno);
+               if (rabp->b_flags & B_DONE)
+                       brelse(rabp);
+               else {
+                       rabp->b_flags |= B_READ|B_ASYNC;
+                       rabp->b_bcount = BSIZE;
+                       (*bdevsw[major(dev)].d_strategy)(rabp);
+#ifdef DISKMON
+                       io_info.nreada++;
+#endif
+               }
+       }
+       if(bp == NULL)
+               return(bread(dev, blkno));
+       iowait(bp);
+       return(bp);
+}
+
+/*
+ * Write the buffer, waiting for completion.
+ * Then release the buffer.
+ */
+bwrite(bp)
+register struct buf *bp;
+{
+       register flag;
+
+       flag = bp->b_flags;
+       bp->b_flags &= ~(B_READ | B_DONE | B_ERROR | B_DELWRI | B_AGE);
+       bp->b_bcount = BSIZE;
+#ifdef DISKMON
+       io_info.nwrite++;
+#endif
+       (*bdevsw[major(bp->b_dev)].d_strategy)(bp);
+       if ((flag&B_ASYNC) == 0) {
+               iowait(bp);
+               brelse(bp);
+       } else if (flag & B_DELWRI)
+               bp->b_flags |= B_AGE;
+       else
+               geterror(bp);
+}
+
+/*
+ * Release the buffer, marking it so that if it is grabbed
+ * for another purpose it will be written out before being
+ * given up (e.g. when writing a partial block where it is
+ * assumed that another write for the same block will soon follow).
+ * This can't be done for magtape, since writes must be done
+ * in the same order as requested.
+ */
+bdwrite(bp)
+register struct buf *bp;
+{
+       register struct buf *dp;
+
+       dp = bdevsw[major(bp->b_dev)].d_tab;
+       if(dp->b_flags & B_TAPE)
+               bawrite(bp);
+       else {
+               bp->b_flags |= B_DELWRI | B_DONE;
+               brelse(bp);
+       }
+}
+
+/*
+ * Release the buffer, start I/O on it, but don't wait for completion.
+ */
+bawrite(bp)
+register struct buf *bp;
+{
+
+       bp->b_flags |= B_ASYNC;
+       bwrite(bp);
+}
+
+/*
+ * release the buffer, with no I/O implied.
+ */
+brelse(bp)
+register struct buf *bp;
+{
+       register struct buf **backp;
+       register s;
+
+       if (bp->b_flags&B_WANTED)
+               wakeup((caddr_t)bp);
+       if (bfreelist.b_flags&B_WANTED) {
+               bfreelist.b_flags &= ~B_WANTED;
+               wakeup((caddr_t)&bfreelist);
+       }
+       if (bp->b_flags&B_ERROR)
+               bp->b_dev = NODEV;  /* no assoc. on error */
+       s = spl6();
+       if(bp->b_flags & B_AGE) {
+               backp = &bfreelist.av_forw;
+               (*backp)->av_back = bp;
+               bp->av_forw = *backp;
+               *backp = bp;
+               bp->av_back = &bfreelist;
+       } else {
+               backp = &bfreelist.av_back;
+               (*backp)->av_forw = bp;
+               bp->av_back = *backp;
+               *backp = bp;
+               bp->av_forw = &bfreelist;
+       }
+       bp->b_flags &= ~(B_WANTED|B_BUSY|B_ASYNC|B_AGE);
+       splx(s);
+}
+
+/*
+ * See if the block is associated with some buffer
+ * (mainly to avoid getting hung up on a wait in breada)
+ */
+incore(dev, blkno)
+dev_t dev;
+daddr_t blkno;
+{
+       register struct buf *bp;
+       register struct buf *dp;
+
+       dp = bdevsw[major(dev)].d_tab;
+       for (bp=dp->b_forw; bp != dp; bp = bp->b_forw)
+               if (bp->b_blkno==blkno && bp->b_dev==dev)
+                       return(1);
+       return(0);
+}
+
+/*
+ * Assign a buffer for the given block.  If the appropriate
+ * block is already associated, return it; otherwise search
+ * for the oldest non-busy buffer and reassign it.
+ */
+struct buf *
+getblk(dev, blkno)
+dev_t dev;
+daddr_t blkno;
+{
+       register struct buf *bp;
+       register struct buf *dp;
+#ifdef DISKMON
+       register i;
+#endif
+
+       if(major(dev) >= nblkdev)
+               panic("blkdev");
+
+    loop:
+       spl0();
+       dp = bdevsw[major(dev)].d_tab;
+       if(dp == NULL)
+               panic("devtab");
+       for (bp=dp->b_forw; bp != dp; bp = bp->b_forw) {
+               if (bp->b_blkno!=blkno || bp->b_dev!=dev)
+                       continue;
+               spl6();
+               if (bp->b_flags&B_BUSY) {
+                       bp->b_flags |= B_WANTED;
+                       sleep((caddr_t)bp, PRIBIO+1);
+                       goto loop;
+               }
+               spl0();
+#ifdef DISKMON
+               i = 0;
+               dp = bp->av_forw;
+               while (dp != &bfreelist) {
+                       i++;
+                       dp = dp->av_forw;
+               }
+               if (i<NBUF)
+                       io_info.bufcount[i]++;
+#endif
+               notavail(bp);
+               return(bp);
+       }
+       spl6();
+       if (bfreelist.av_forw == &bfreelist) {
+               bfreelist.b_flags |= B_WANTED;
+               sleep((caddr_t)&bfreelist, PRIBIO+1);
+               goto loop;
+       }
+       spl0();
+       notavail(bp = bfreelist.av_forw);
+       if (bp->b_flags & B_DELWRI) {
+               bp->b_flags |= B_ASYNC;
+               bwrite(bp);
+               goto loop;
+       }
+       bp->b_flags = B_BUSY;
+       bp->b_back->b_forw = bp->b_forw;
+       bp->b_forw->b_back = bp->b_back;
+       bp->b_forw = dp->b_forw;
+       bp->b_back = dp;
+       dp->b_forw->b_back = bp;
+       dp->b_forw = bp;
+       bp->b_dev = dev;
+       bp->b_blkno = blkno;
+       return(bp);
+}
+
+/*
+ * get an empty block,
+ * not assigned to any particular device
+ */
+struct buf *
+geteblk()
+{
+       register struct buf *bp;
+       register struct buf *dp;
+
+loop:
+       spl6();
+       while (bfreelist.av_forw == &bfreelist) {
+               bfreelist.b_flags |= B_WANTED;
+               sleep((caddr_t)&bfreelist, PRIBIO+1);
+       }
+       spl0();
+       dp = &bfreelist;
+       notavail(bp = bfreelist.av_forw);
+       if (bp->b_flags & B_DELWRI) {
+               bp->b_flags |= B_ASYNC;
+               bwrite(bp);
+               goto loop;
+       }
+       bp->b_flags = B_BUSY;
+       bp->b_back->b_forw = bp->b_forw;
+       bp->b_forw->b_back = bp->b_back;
+       bp->b_forw = dp->b_forw;
+       bp->b_back = dp;
+       dp->b_forw->b_back = bp;
+       dp->b_forw = bp;
+       bp->b_dev = (dev_t)NODEV;
+       return(bp);
+}
+
+/*
+ * Wait for I/O completion on the buffer; return errors
+ * to the user.
+ */
+iowait(bp)
+register struct buf *bp;
+{
+
+       spl6();
+       while ((bp->b_flags&B_DONE)==0)
+               sleep((caddr_t)bp, PRIBIO);
+       spl0();
+       geterror(bp);
+}
+
+/*
+ * Unlink a buffer from the available list and mark it busy.
+ * (internal interface)
+ */
+notavail(bp)
+register struct buf *bp;
+{
+       register s;
+
+       s = spl6();
+       bp->av_back->av_forw = bp->av_forw;
+       bp->av_forw->av_back = bp->av_back;
+       bp->b_flags |= B_BUSY;
+       splx(s);
+}
+
+/*
+ * Mark I/O complete on a buffer, release it if I/O is asynchronous,
+ * and wake up anyone waiting for it.
+ */
+iodone(bp)
+register struct buf *bp;
+{
+
+       bp->b_flags |= B_DONE;
+       if (bp->b_flags&B_ASYNC)
+               brelse(bp);
+       else {
+               bp->b_flags &= ~B_WANTED;
+               wakeup((caddr_t)bp);
+       }
+}
+
+/*
+ * Zero the core associated with a buffer.
+ */
+clrbuf(bp)
+struct buf *bp;
+{
+       register *p;
+       register c;
+
+       p = bp->b_un.b_words;
+       c = BSIZE/sizeof(int);
+       do
+               *p++ = 0;
+       while (--c);
+       bp->b_resid = 0;
+}
+
+/*
+ * swap I/O
+ */
+swap(p,blkno, coreaddr, count, rdflg,uflag)
+       struct  proc  *p;
+{
+       register struct buf *bp;
+       register int c, pt, i;
+       int ptab[(MAXUMEM+127)/128];
+       extern  int     Swap2map[], swap2utl[];
+
+       bp = &swbuf1;
+       if(bp->b_flags & B_BUSY)
+               if((swbuf2.b_flags&B_WANTED) == 0)
+                       bp = &swbuf2;
+       spl6();
+       while (bp->b_flags&B_BUSY) {
+               bp->b_flags |= B_WANTED;
+               sleep((caddr_t)bp, PSWP+1);
+       }
+       if (uflag) {    /* get current page table size */
+               ptaccess(p, Swap2map, swap2utl);
+               pt = ((struct user *)swap2utl)->u_pcb.pcb_szpt;
+               for(i=pt; --i>=0; )
+                       ptab[i] = (Swap2map+UPAGES)[i]&PG_PFNUM;
+       }
+       bp->b_proc = p;
+       bp->b_un.b_addr = (caddr_t)ctob(coreaddr);
+       bp->b_flags = B_BUSY | B_PHYS | rdflg | (uflag ? B_UAREA : 0);
+       while (count > 0) {
+               bp->b_dev = swapdev;
+               bp->b_bcount = ctob( (c = count>120 ? 120 : count));
+               bp->b_blkno = swplo+blkno;
+               (*bdevsw[major(swapdev)].d_strategy)(bp);
+               spl6();
+               while((bp->b_flags&B_DONE)==0)
+                       sleep((caddr_t)bp, PSWP);
+               if (bp->b_flags&B_WANTED)
+                       wakeup((caddr_t)bp);
+               spl0();
+               bp->b_un.b_addr += ctob(c);
+               if (bp->b_flags & B_UAREA) {
+                       bp->b_un.b_addr -= ctob(UPAGES);
+                       if (rdflg == B_READ) {  /* don't let page table size change */
+                               spl6();
+                               ptaccess(p, Swap2map, swap2utl);
+                               ((struct user *)swap2utl)->u_pcb.pcb_szpt = pt;
+                               for(i=pt; --i>=0; )
+                                  ((struct user *)swap2utl)->u_ptable[i]
+                                       = ptab[i];
+                               spl0();
+                       }
+               }
+               bp->b_flags &= ~(B_WANTED | B_UAREA | B_DONE);
+               if (bp->b_flags & B_ERROR)
+                       panic("IO err in swap");
+               count -= c;
+               blkno += c;
+       }
+       bp->b_flags &= ~(B_BUSY|B_WANTED|B_PHYS);
+}
+
+/*
+ * make sure all write-behind blocks
+ * on dev (or NODEV for all)
+ * are flushed out.
+ * (from umount and update)
+ */
+bflush(dev)
+dev_t dev;
+{
+       register struct buf *bp;
+
+loop:
+       spl6();
+       for (bp = bfreelist.av_forw; bp != &bfreelist; bp = bp->av_forw) {
+               if (bp->b_flags&B_DELWRI && (dev == NODEV||dev==bp->b_dev)) {
+                       bp->b_flags |= B_ASYNC;
+                       notavail(bp);
+                       bwrite(bp);
+                       goto loop;
+               }
+       }
+       spl0();
+}
+
+/*
+ * Raw I/O. The arguments are
+ *     The strategy routine for the device
+ *     A buffer, which will always be a special buffer
+ *       header owned exclusively by the device for this purpose
+ *     The device number
+ *     Read/write flag
+ * Essentially all the work is computing physical addresses and
+ * validating them.
+ */
+physio(strat, bp, dev, rw)
+register struct buf *bp;
+int (*strat)();
+{
+       register int c;
+       int flag = 0;
+
+       if (useracc(u.u_base,u.u_count,rw) == NULL) {
+               u.u_error =EFAULT;
+               return; }
+       spl6();
+       while (bp->b_flags&B_BUSY) {
+               bp->b_flags |= B_WANTED;
+               sleep((caddr_t)bp, PRIBIO+1);
+       }
+       bp->b_error = 0;
+       bp->b_proc = u.u_procp;
+       bp->b_un.b_addr = u.u_base;
+       while (u.u_count > 0 && bp->b_error==0) {
+               bp->b_flags = B_BUSY | B_PHYS | rw;
+               bp->b_dev = dev;
+               bp->b_blkno = u.u_offset >> BSHIFT;
+               bp->b_bcount = c = u.u_count>60*1024 ? 60*1024 : u.u_count;
+               flag = u.u_procp->p_flag & SULOCK;
+               u.u_procp->p_flag |= SULOCK;
+               (*strat)(bp);
+               spl6();
+               while ((bp->b_flags&B_DONE) == 0)
+                       sleep((caddr_t)bp, PRIBIO);
+               u.u_procp->p_flag &= ~SULOCK;
+               u.u_procp->p_flag |= flag;
+               if (bp->b_flags&B_WANTED)
+                       wakeup((caddr_t)bp);
+               spl0();
+               bp->b_un.b_addr += c;
+               u.u_count -= c;
+               u.u_offset += c;
+       }
+       bp->b_flags &= ~(B_BUSY|B_WANTED|B_PHYS);
+       u.u_count = bp->b_resid;
+       geterror(bp);
+       return;
+}
+
+/*
+ * Pick up the device's error number and pass it to the user;
+ * if there is an error but the number is 0 set a generalized
+ * code.  Actually the latter is always true because devices
+ * don't yet return specific errors.
+ */
+geterror(bp)
+register struct buf *bp;
+{
+
+       if (bp->b_flags&B_ERROR)
+               if ((u.u_error = bp->b_error)==0)
+                       u.u_error = EIO;
+}
diff --git a/usr/src/sys/sys/clock.c b/usr/src/sys/sys/clock.c
new file mode 100644 (file)
index 0000000..014870d
--- /dev/null
@@ -0,0 +1,180 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/callo.h"
+#include "../h/seg.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/proc.h"
+#include "../h/reg.h"
+#include "../h/psl.h"
+
+#define        SCHMAG  8/10
+
+
+/*
+ * clock is called straight from
+ * the real time clock interrupt.
+ *
+ * Functions:
+ *     copy *switches to display
+ *     implement callouts
+ *     maintain user/system times
+ *     maintain date
+ *     profile
+ *     lightning bolt wakeup (every second)
+ *     alarm clock signals
+ *     jab the scheduler
+ */
+
+clock(pc, ps)
+caddr_t pc;
+{
+       register struct callo *p1, *p2;
+       register struct proc *pp;
+       int a;
+       extern caddr_t waitloc, ewaitloc;
+
+       /*
+        * reprime clock
+        */
+       clkreld();
+
+
+
+
+       /*
+        * callouts
+        * if none, just continue
+        * else update first non-zero time
+        */
+
+       if(callout[0].c_func == NULL)
+               goto out;
+       p2 = &callout[0];
+       while(p2->c_time<=0 && p2->c_func!=NULL)
+               p2++;
+       p2->c_time--;
+
+       /*
+        * if ps is high, just return
+        */
+       if (BASEPRI(ps))
+               goto out;
+
+       /*
+        * callout
+        */
+
+       if(callout[0].c_time <= 0) {
+               p1 = &callout[0];
+               while(p1->c_func != 0 && p1->c_time <= 0) {
+                       (*p1->c_func)(p1->c_arg);
+                       p1++;
+               }
+               p2 = &callout[0];
+               while(p2->c_func = p1->c_func) {
+                       p2->c_time = p1->c_time;
+                       p2->c_arg = p1->c_arg;
+                       p1++;
+                       p2++;
+               }
+       }
+
+       /*
+        * lightning bolt time-out
+        * and time of day
+        */
+out:
+       a = dk_busy&07;
+       if (USERMODE(ps)) {
+               u.u_utime++;
+               if(u.u_prof.pr_scale)
+                       addupc(pc, &u.u_prof, 1);
+               if(u.u_procp->p_nice > NZERO)
+                       a += 8;
+       } else {
+               a += 16;
+               if (pc == waitloc || pc == ewaitloc )
+                       a += 8;
+               u.u_stime++;
+       }
+       dk_time[a] += 1;
+       pp = u.u_procp;
+       if(++pp->p_cpu == 0)
+               pp->p_cpu--;
+       if(++lbolt >= HZ) {
+               if (BASEPRI(ps))
+                       return;
+               lbolt -= HZ;
+               ++time;
+               runrun++;
+               wakeup((caddr_t)&lbolt);
+               for(pp = &proc[0]; pp < &proc[NPROC]; pp++)
+               if (pp->p_stat && pp->p_stat<SZOMB) {
+                       if(pp->p_time != 127)
+                               pp->p_time++;
+                       if(pp->p_clktim)
+                               if(--pp->p_clktim == 0)
+                                       psignal(pp, SIGCLK);
+                       a = (pp->p_cpu & 0377)*SCHMAG + pp->p_nice - NZERO;
+                       if(a < 0)
+                               a = 0;
+                       if(a > 255)
+                               a = 255;
+                       pp->p_cpu = a;
+                       if(pp->p_pri >= PUSER)
+                               setpri(pp);
+               }
+               if(runin!=0) {
+                       runin = 0;
+                       wakeup((caddr_t)&runin);
+               }
+       }
+}
+
+/*
+ * timeout is called to arrange that
+ * fun(arg) is called in tim/HZ seconds.
+ * An entry is sorted into the callout
+ * structure. The time in each structure
+ * entry is the number of HZ's more
+ * than the previous entry.
+ * In this way, decrementing the
+ * first entry has the effect of
+ * updating all entries.
+ *
+ * The panic is there because there is nothing
+ * intelligent to be done if an entry won't fit.
+ */
+timeout(fun, arg, tim)
+int (*fun)();
+caddr_t arg;
+{
+       register struct callo *p1, *p2;
+       register int t;
+       int s;
+
+       t = tim;
+       p1 = &callout[0];
+       s = spl7();
+       while(p1->c_func != 0 && p1->c_time <= t) {
+               t -= p1->c_time;
+               p1++;
+       }
+       if (p1 >= &callout[NCALL-1])
+               panic("Timeout table overflow");
+       p1->c_time -= t;
+       p2 = p1;
+       while(p2->c_func != 0)
+               p2++;
+       while(p2 >= p1) {
+               (p2+1)->c_time = p2->c_time;
+               (p2+1)->c_func = p2->c_func;
+               (p2+1)->c_arg = p2->c_arg;
+               p2--;
+       }
+       p1->c_time = t;
+       p1->c_func = fun;
+       p1->c_arg = arg;
+       splx(s);
+}
diff --git a/usr/src/sys/sys/conf.c b/usr/src/sys/sys/conf.c
new file mode 100644 (file)
index 0000000..d4b2cdc
--- /dev/null
@@ -0,0 +1,98 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/buf.h"
+#include "../h/tty.h"
+#include "../h/conf.h"
+#include "../h/proc.h"
+#include "../h/text.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/file.h"
+#include "../h/inode.h"
+#include "../h/mx.h"
+#include "../h/acct.h"
+#include "../h/mba.h"
+
+int    nulldev();
+int    nodev();
+int    random();
+
+int    hpstrategy(),hpread(),hpwrite(),hpintr();
+struct buf     hptab;
+int    htopen(),htclose(),htstrategy(),htread(),htwrite();
+struct buf     httab;
+
+struct bdevsw  bdevsw[] =
+{
+/* 0 */        nulldev,        nulldev,        hpstrategy,     &hptab,
+/* 1 */        htopen,         htclose,        htstrategy,     &httab,
+       0,
+};
+
+int    consopen(),consclose(),consread(),conswrite(),consioctl();
+int    dzopen(),dzclose(),dzread(),dzwrite(),dzioctl();
+struct tty     dz_tty[];
+int    syopen(),syread(),sywrite(),sysioctl();
+int    mmread(),mmwrite();
+int    mxopen(),mxclose(),mxread(),mxwrite(),mxioctl();
+int    mcread(),mcwrite();
+struct cdevsw  cdevsw[] =
+{
+/* 0 */ consopen, consclose, consread, conswrite, consioctl, 0,
+/* 1 */ dzopen, dzclose, dzread, dzwrite, dzioctl, dz_tty,
+/* 2 */ syopen,                nulldev,        syread, sywrite,        sysioctl, 0,
+/* 3 */        nulldev,        nulldev,        mmread, mmwrite,        nodev, 0,
+/* 4 */        nulldev,        nulldev,        hpread, hpwrite,        nodev, 0,
+/* 5 */ htopen,                htclose,        htread, htwrite,        nodev, 0,
+/* 6 */        mxopen, mxclose, mxread, mxwrite, mxioctl, 0,
+       0,
+};
+
+int ttyopen(),ttyclose(),ttread(),ttwrite();
+int ttyinput(),ttstart() ;
+struct linesw linesw[] =
+{
+/* 0 */ ttyopen, nulldev, ttread, ttwrite, nodev, ttyinput,    ttstart,
+/* 1 */        mxopen, mxclose, mcread, mcwrite, mxioctl, nulldev, nulldev,
+       0
+};
+int nldisp = 1;
+dev_t  rootdev = makedev(0, 0);
+dev_t  swapdev = makedev(0, 1);
+dev_t  pipedev = makedev(0, 0);
+daddr_t swplo = 0;
+int nswap = 8778;
+struct buf     buf[NBUF];
+struct file    file[NFILE];
+struct inode   inode[NINODE];
+struct text    text[NTEXT];
+struct proc    proc[NPROC];
+struct buf     bfreelist;
+struct acct    acctbuf;
+struct inode   *acctp;
+int *usrstack = (int *)USRSTACK;
+/*tbl*/ int mem_no = 3;        /* major device number of memory special file */
+
+
+extern int Sysmap[];
+extern struct user u;
+
+int mbanum[] = {       /* mba number of major device */
+       0,              /* disk */
+       1,              /* tape */
+       9999999,        /* unused */
+       9999999,        /* unused */
+       0,              /* disk, raw */
+       1,              /* tape, raw */
+       };
+
+int *mbaloc[] = { /* virtual location of mba */
+       (int *)MBA0,
+       (int *)MBA1,
+       };
diff --git a/usr/src/sys/sys/cons.c b/usr/src/sys/sys/cons.c
new file mode 100644 (file)
index 0000000..bb3075a
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ *   KL/DL-11 driver
+ */
+#include "../h/param.h"
+#include "../h/conf.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/tty.h"
+#include "../h/systm.h"
+#include "../h/cons.h"
+#include "../h/mtpr.h"
+
+#define        NL1     000400
+#define        NL2     001000
+#define        CR2     020000
+#define        FF1     040000
+#define        TAB1    002000
+
+struct tty cons;
+int    consstart();
+int    ttrstrt();
+char   partab[];
+
+consopen(dev, flag)
+dev_t dev;
+{
+       register struct device *addr;
+       register struct tty *tp;
+       register d;
+
+       tp = &cons;
+       tp->t_oproc = consstart;
+       tp->t_iproc = NULL;
+       if ((tp->t_state&ISOPEN) == 0) {
+               tp->t_state = ISOPEN|CARR_ON;
+               tp->t_flags = EVENP|ECHO|XTABS|CRMOD;
+               tp->t_erase = CERASE;
+               tp->t_kill = CKILL;
+       }
+       mtpr(RXCS, mfpr(RXCS)|RXCS_IE);
+       mtpr(TXCS, mfpr(TXCS)|TXCS_IE);
+       ttyopen(dev, tp);
+}
+
+consclose(dev)
+dev_t dev;
+{
+       register struct tty *tp;
+
+       tp = &cons;
+       wflushtty(tp);
+       tp->t_state = 0;
+}
+
+consread(dev)
+dev_t dev;
+{
+       ttread(&cons);
+}
+
+conswrite(dev)
+dev_t dev;
+{
+       ttwrite(&cons);
+}
+
+consxint(dev)
+dev_t dev;
+{
+       register struct tty *tp;
+
+       tp = &cons;
+       ttstart(tp);
+       if (tp->t_outq.c_cc == 0 || tp->t_outq.c_cc == TTLOWAT)
+               wakeup((caddr_t)&tp->t_outq);
+}
+
+consrint(dev)
+dev_t dev;
+{
+       register int c;
+       register struct device *addr;
+       register struct tty *tp;
+
+       c = mfpr(RXDB);
+       ttyinput(c, &cons);
+}
+
+consioctl(dev,cmd,addr,flag)
+dev_t dev;
+caddr_t addr;
+{
+       register struct tty *tp;
+       tp = &cons;
+       if (ttioccom(cmd,tp,addr,dev) ==0)
+               u.u_error = ENOTTY;
+}
+
+consstart(tp)
+register struct tty *tp;
+{
+       register c;
+       register struct device *addr;
+
+       if( (mfpr(TXCS)&TXCS_RDY) == 0)
+               return;
+       if ((c=getc(&tp->t_outq)) >= 0) {
+               if (tp->t_flags&RAW)
+                       mtpr(TXDB, c&0xff);
+               else if (c<=0177)
+                       mtpr(TXDB, (c | (partab[c]&0200))&0xff);
+               else {
+                       timeout(ttrstrt, (caddr_t)tp, (c&0177));
+                       tp->t_state |= TIMEOUT;
+               }
+       }
+}
+
+char   *msgbufp = msgbuf;      /* Next saved printf character */
+/*
+ * Print a character on console.
+ * Attempts to save and restore device
+ * status.
+ * If the switches are 0, all
+ * printing is inhibited.
+ *
+ * Whether or not printing is inhibited,
+ * the last MSGBUFS characters
+ * are saved in msgbuf for inspection later.
+ */
+putchar(c)
+register c;
+{
+       register s, timo;
+
+       if (c != '\0' && c != '\r' && c != 0177) {
+               *msgbufp++ = c;
+               if(msgbufp >= &msgbuf[MSGBUFS])
+                       msgbufp = msgbuf;
+       }
+       timo = 30000;
+       /*
+        * Try waiting for the console tty to come ready,
+        * otherwise give up after a reasonable time.
+        */
+       while((mfpr(TXCS)&TXCS_RDY) == 0)
+               if(--timo == 0)
+                       break;
+       if(c == 0)
+               return;
+       s = mfpr(TXCS);
+       mtpr(TXCS,0);
+       mtpr(TXDB, c&0xff);
+       if(c == '\n') {
+               putchar('\r');
+       }
+       putchar(0);
+       mtpr(TXCS, s);
+}
diff --git a/usr/src/sys/sys/dkleave.c b/usr/src/sys/sys/dkleave.c
new file mode 100644 (file)
index 0000000..7cd7a7d
--- /dev/null
@@ -0,0 +1,29 @@
+#include "../h/param.h"
+#include "../h/buf.h"
+
+daddr_t
+dkblock(bp)
+register struct buf *bp;
+{
+       register int dminor;
+
+       if (((dminor=minor(bp->b_dev))&0100) == 0)
+               return(bp->b_blkno);
+       dminor >>= 3;
+       dminor &= 07;
+       dminor++;
+       return(bp->b_blkno/dminor);
+}
+
+dkunit(bp)
+register struct buf *bp;
+{
+       register int dminor;
+
+       dminor = minor(bp->b_dev) >> 3;
+       if ((dminor&010) == 0)
+               return(dminor);
+       dminor &= 07;
+       dminor++;
+       return(bp->b_blkno%dminor);
+}
diff --git a/usr/src/sys/sys/dsort.c b/usr/src/sys/sys/dsort.c
new file mode 100644 (file)
index 0000000..5a90c1e
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * generalized seek sort for disk
+ */
+
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/buf.h"
+
+#define        b_cylin b_resid
+
+disksort(dp, bp)
+register struct buf *dp, *bp;
+{
+       register struct buf *ap;
+       struct buf *tp;
+
+       ap = dp->b_actf;
+       if(ap == NULL) {
+               dp->b_actf = bp;
+               dp->b_actl = bp;
+               bp->av_forw = NULL;
+               return;
+       }
+       tp = NULL;
+       for(; ap != NULL; ap = ap->av_forw) {
+               if ((bp->b_flags&B_READ) && (ap->b_flags&B_READ) == 0) {
+                       if (tp == NULL)
+                               tp = ap;
+                       break;
+               }
+               if ((bp->b_flags&B_READ) == 0 && (ap->b_flags&B_READ))
+                       continue;
+               if(ap->b_cylin <= bp->b_cylin)
+                       if(tp == NULL || ap->b_cylin >= tp->b_cylin)
+                               tp = ap;
+       }
+       if(tp == NULL)
+               tp = dp->b_actl;
+       bp->av_forw = tp->av_forw;
+       tp->av_forw = bp;
+       if(tp == dp->b_actl)
+               dp->b_actl = bp;
+}
diff --git a/usr/src/sys/sys/dz.c b/usr/src/sys/sys/dz.c
new file mode 100644 (file)
index 0000000..edc0174
--- /dev/null
@@ -0,0 +1,321 @@
+/*
+*  DZ-11 Driver
+*/
+# include "../h/param.h"
+# include "../h/tty.h"
+# include "../h/uba.h"
+# include "../h/proc.h"
+# include "../h/dir.h"
+# include "../h/file.h"
+# include "../h/inode.h"
+# include "../h/user.h"
+# include "../h/conf.h"
+# define DZADDR  (UBA0_DEV + 0160100)
+# define NDZ (1*8)
+# define  BITS7  020
+# define  BITS8  030
+# define  TWOSB  040
+# define  PENABLE  0100
+# define  OPAR  0200
+# define  MSE  040  /* Master Scan Enable */
+# define  RIE  0100  /* Receiver Interrupt Enable */
+# define  TIE  040000  /*  Transmit interrupt enable */
+# define  DZ_IEN  (MSE+RIE+TIE)
+# define  PERROR  010000
+# define  FRERROR  020000
+# define SSPEED  7  /* std speed = 300 baud */
+
+# define dzlpr  dzrbuf
+# define dzmsr  dzbrk
+# define  ON  1
+# define  OFF  0
+struct tty dz_tty[NDZ] ;
+int dz_cnt = { NDZ }  ;
+struct dzregs {
+       short dzcsr ;
+       short dzrbuf ;
+       char  dztcr ;
+       char  dzdtr ;
+       char  dztbuf ;
+       char  dzbrk ;
+       } ;
+struct dzregs *dz_addr[] = {
+       (struct dzregs *)(DZADDR),
+       (struct dzregs *)(DZADDR+010),
+       (struct dzregs *)(DZADDR+020),
+       (struct dzregs *)(DZADDR+030)
+       } ;
+char dz_timer ;
+char dz_speeds[] = {
+       0, 020 , 021 , 022 , 023 , 024 , 0, 025,
+       026 , 027 , 030 , 032 , 034 , 036 , 0 , 0,
+       } ;
+dzopen(d,flag)
+{
+       register struct tty *tp ;
+       register dev ;
+       extern dzstart() , dzscan() ;
+       dev = minor(d);
+       if (dev >= dz_cnt) {
+               u.u_error = ENXIO ;
+               return ;
+               }
+       if (dz_timer == 0) {
+               dz_timer++ ;
+               timeout(dzscan,0,60) ;
+               }
+       tp = &dz_tty[dev] ;
+       tp->t_addr = ((struct dzregs *)DZADDR) + (dev>>3);
+       tp->t_oproc = dzstart ;
+       tp->t_iproc = NULL;
+       tp->t_state |= WOPEN ;
+       if ((tp->t_state & ISOPEN) == 0) {
+               tp->t_erase = CERASE ;
+               tp->t_kill = CKILL ;
+               tp->t_ospeed = tp->t_ispeed = SSPEED ;
+               tp->t_flags = ODDP|EVENP|ECHO|HUPCLS ;
+               dzparam(dev) ;
+               }
+       else
+               if (tp->t_state&XCLUDE && u.u_uid != 0) {
+                       u.u_error = EBUSY ;
+                       return ;
+                       }
+       dzmodem(dev,ON) ;
+       spl5() ;
+       while ((tp->t_state & CARR_ON) == 0) {
+               tp->t_state |= WOPEN ;
+               sleep(&tp->t_rawq,TTIPRI) ;
+               }
+       spl0() ;
+       (*linesw[tp->t_line].l_open)(d,tp);
+}
+/*             */
+dzclose(d)
+{
+       register struct tty *tp ;
+       register dev ;
+       dev = minor(d);
+       tp = &dz_tty[dev] ;
+       (*linesw[tp->t_line].l_close)(tp);
+       if (tp->t_flags & HUPCLS)
+               dzmodem(dev,OFF) ;
+       ttyclose(tp);
+}
+/*             */
+dzread(d)
+{
+       register struct tty *tp;
+       tp = &dz_tty[minor(d)];
+       (*linesw[tp->t_line].l_read)(tp);
+}
+/*             */
+dzwrite(d)
+{
+       register struct tty *tp;
+       tp = &dz_tty[minor(d)];
+       (*linesw[tp->t_line].l_write)(tp);
+}
+/*             */
+dzrint(dev)
+{
+       register struct tty *tp ;
+       register int c ;
+       register struct dzregs *dzaddr ;
+       dzaddr = dz_addr[dev] ;
+       while ((c = dzaddr->dzrbuf) < 0) { /* char present */
+               tp = &dz_tty[((c>>8)&07)|(dev<<3)] ;
+               if (tp >= &dz_tty[dz_cnt]) continue ;
+               if ((tp->t_state & ISOPEN) == 0) {
+                       wakeup(&tp->t_rawq) ;
+                       continue ;
+                       }
+               if (c & FRERROR) /* framing error = break */
+                       if (tp->t_flags & RAW) c = 0 ; /* null for getty */
+                       else c = 0177 ; /* DEL = interrupt */
+               if (c & PERROR) /* parity error */
+                       if (((tp->t_flags & (EVENP|ODDP)) == EVENP)
+                         || ((tp->t_flags & (EVENP|ODDP)) == ODDP))
+                               continue ;
+               (*linesw[tp->t_line].l_rint)(c,tp);
+               }
+}
+/*             */
+dzioctl(dev,cmd,addr,flag)
+caddr_t addr;
+dev_t dev;
+{
+       register struct tty *tp;
+       tp = &dz_tty[minor(dev)];
+       if (ttioccomm(cmd,tp,addr,dev)) {
+               if (cmd==TIOCSETP || cmd==TIOCSETN)
+                       dzparam(minor(dev));
+       } else
+               u.u_error = ENOTTY;
+}
+/*             */
+dzparam(dev)
+{
+       register struct tty *tp ;
+       register struct dzregs *dzaddr ;
+       register short lpr ;
+       tp = &dz_tty[dev] ;
+       dzaddr = dz_addr[dev>>3] ;
+       dzaddr->dzcsr = DZ_IEN ;
+       if (tp->t_ispeed == 0) { /* hang up line */
+               dzmodem(dev,OFF) ;
+               return ;
+               }
+       lpr = (dz_speeds[tp->t_ispeed]<<8) | (dev & 07) ;
+       if (tp->t_flags & RAW) lpr |= BITS8 ;
+       else lpr |= (BITS7|PENABLE) ;
+       if ((tp->t_flags & EVENP) == 0) lpr |= OPAR ;
+       if (tp->t_ispeed == 3)  /*  110 baud */
+               lpr |= TWOSB ; /* 2 stop bits */
+       dzaddr->dzlpr = lpr ;
+}
+/*             */
+dzxint(dev)
+dev_t dev;
+{
+       register struct tty *tp ;
+       register struct dzregs *dzaddr ;
+       register unit ;
+       dzaddr = dz_addr[dev] ;
+       while (dzaddr->dzcsr < 0) { /* Transmit Ready is on */
+               unit = (dzaddr->dzcsr >> 8) & 07 ;
+               tp = &dz_tty[(dev<<3) | unit] ;
+               /* the following is an attempt to fix what appears
+                  to be a DZ hardware bug which causes the system
+                  to loop here.  Transmitting the NUL should not
+                  cause too many problems.... */
+               if ((dzaddr->dztcr & (1<<unit)) == 0 ) {
+                       printf("dzxint,line=%d\n", unit);
+                       dzaddr->dztbuf = 0;
+                       continue;
+               }
+               if (tp->t_state & BUSY) {
+                       dzaddr->dztbuf = tp->t_char ; /* output the char */
+                       tp->t_state &= ~BUSY ;
+                       if (tp->t_line)
+                               (*linesw[tp->t_line].l_start)(tp);
+                       else
+                               dzstart(tp);
+                       continue ;
+                       }
+               unit = (1<<unit) ;
+               dzaddr->dztcr &= (~unit) ; /* Transmit enable off */
+               }
+}
+/*             */
+dzstart(tp)
+register struct tty *tp ;
+{
+       register unit , c ;
+       register struct dzregs *dzaddr ;
+       extern ttrstrt() ;
+       int sps ;
+       unit = tp - dz_tty ;
+       dzaddr = dz_addr[unit>>3] ;
+       unit = 1<<(unit&07) ;
+       sps = spl5() ;
+       if (tp->t_state & (TIMEOUT|BUSY|TTSTOP)) {
+               splx(sps) ;
+               return ;
+               }
+       if ((c = getc(&tp->t_outq)) >= 0) {
+               if (c >= 0200 && (tp->t_flags&RAW) == 0) {
+                       dzaddr->dztcr &= ~unit ;
+                       tp->t_state |= TIMEOUT ;
+                       timeout(ttrstrt,tp,(c&0177)+6) ;
+                       }
+               else {
+                       tp->t_char = c ;
+                       tp->t_state |= BUSY ;
+                       dzaddr->dztcr |= unit ;
+                       }
+               if (tp->t_outq.c_cc <= TTLOWAT && tp->t_state&ASLEEP) {
+                       tp->t_state &= ~ASLEEP ;
+                       if (tp->t_chan)
+                               mcstart(tp->t_chan, (caddr_t)&tp->t_outq);
+                       else wakeup(&tp->t_outq) ;
+                       }
+               }
+               splx(sps) ;
+}
+/*             */
+dzmodem(dev,flag)
+register int dev;
+{
+       register struct dzregs *dzaddr ;
+       register char bit ;
+       dzaddr = dz_addr[dev>>3] ;
+       bit = 1<<(dev&07) ;
+       if (flag == OFF) dzaddr->dzdtr &= ~bit ;
+       else dzaddr->dzdtr |= bit ;
+}
+/*             */
+dzscan()
+{
+       register i ;
+       register struct dzregs *dzaddr ;
+       register bit ;
+       register struct tty *tp ;
+       extern dzscan() ;
+       for (i = 0 ; i < dz_cnt ; i++) {
+               dzaddr = dz_addr[i>>3] ;
+               tp = &dz_tty[i] ;
+               bit = 1<<(i&07) ;
+               if (dzaddr->dzmsr & bit) { /* carrier present */
+                       if ((tp->t_state & CARR_ON) == 0) {
+                               wakeup(&tp->t_rawq) ;
+                               tp->t_state |= CARR_ON ;
+                               }
+                       }
+               else {
+                       if ((tp->t_state & CARR_ON)) { /* carrier lost */
+                               signal(tp->t_pgrp,SIGHUP) ;
+                               dzaddr->dzdtr &= ~bit ;
+                               flushtty(tp) ;
+                               }
+                       tp->t_state &= ~CARR_ON ;
+                       }
+               }
+               timeout(dzscan,0,2*60) ;
+}
diff --git a/usr/src/sys/sys/fio.c b/usr/src/sys/sys/fio.c
new file mode 100644 (file)
index 0000000..b61d8da
--- /dev/null
@@ -0,0 +1,264 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/filsys.h"
+#include "../h/file.h"
+#include "../h/conf.h"
+#include "../h/inode.h"
+#include "../h/reg.h"
+#include "../h/acct.h"
+
+/*
+ * Convert a user supplied
+ * file descriptor into a pointer
+ * to a file structure.
+ * Only task is to check range
+ * of the descriptor.
+ */
+struct file *
+getf(f)
+register int f;
+{
+       register struct file *fp;
+
+       if(0 <= f && f < NOFILE) {
+               fp = u.u_ofile[f];
+               if(fp != NULL)
+                       return(fp);
+       }
+       u.u_error = EBADF;
+       return(NULL);
+}
+
+/*
+ * Internal form of close.
+ * Decrement reference count on
+ * file structure.
+ * Also make sure the pipe protocol
+ * does not constipate.
+ *
+ * Decrement reference count on the inode following
+ * removal to the referencing file structure.
+ * Call device handler on last close.
+ */
+closef(fp)
+register struct file *fp;
+{
+       register struct inode *ip;
+       int flag, mode;
+       dev_t dev;
+       register int (*cfunc)();
+       struct chan *cp;
+
+       if(fp == NULL)
+               return;
+       if (fp->f_count > 1) {
+               fp->f_count--;
+               return;
+       }
+       ip = fp->f_inode;
+       flag = fp->f_flag;
+       cp = fp->f_un.f_chan;
+       dev = (dev_t)ip->i_un.i_rdev;
+       mode = ip->i_mode;
+
+       plock(ip);
+       fp->f_count = 0;
+       if(flag & FPIPE) {
+               ip->i_mode &= ~(IREAD|IWRITE);
+               wakeup((caddr_t)ip+1);
+               wakeup((caddr_t)ip+2);
+       }
+       iput(ip);
+
+       switch(mode&IFMT) {
+
+       case IFCHR:
+       case IFMPC:
+               cfunc = cdevsw[major(dev)].d_close;
+               break;
+
+       case IFBLK:
+       case IFMPB:
+               cfunc = bdevsw[major(dev)].d_close;
+               break;
+       default:
+               return;
+       }
+
+       if (flag & FMP)
+               goto call;
+
+       for(fp=file; fp < &file[NFILE]; fp++)
+               if (fp->f_count && fp->f_inode==ip)
+                       return;
+
+call:
+       (*cfunc)(dev, flag, cp);
+}
+
+/*
+ * openi called to allow handler
+ * of special files to initialize and
+ * validate before actual IO.
+ */
+openi(ip, rw)
+register struct inode *ip;
+{
+       dev_t dev;
+       register unsigned int maj;
+
+       dev = (dev_t)ip->i_un.i_rdev;
+       maj = major(dev);
+       switch(ip->i_mode&IFMT) {
+
+       case IFCHR:
+       case IFMPC:
+               if(maj >= nchrdev)
+                       goto bad;
+               (*cdevsw[maj].d_open)(dev, rw);
+               break;
+
+       case IFBLK:
+       case IFMPB:
+               if(maj >= nblkdev)
+                       goto bad;
+               (*bdevsw[maj].d_open)(dev, rw);
+       }
+       return;
+
+bad:
+       u.u_error = ENXIO;
+}
+
+/*
+ * Check mode permission on inode pointer.
+ * Mode is READ, WRITE or EXEC.
+ * In the case of WRITE, the
+ * read-only status of the file
+ * system is checked.
+ * Also in WRITE, prototype text
+ * segments cannot be written.
+ * The mode is shifted to select
+ * the owner/group/other fields.
+ * The super user is granted all
+ * permissions.
+ */
+access(ip, mode)
+register struct inode *ip;
+{
+       register m;
+
+       m = mode;
+       if(m == IWRITE) {
+               if(getfs(ip->i_dev)->s_ronly != 0) {
+                       u.u_error = EROFS;
+                       return(1);
+               }
+               if (ip->i_flag&ITEXT)           /* try to free text */
+                       xrele(ip);
+               if(ip->i_flag & ITEXT) {
+                       u.u_error = ETXTBSY;
+                       return(1);
+               }
+       }
+       if(u.u_uid == 0)
+               return(0);
+       if(u.u_uid != ip->i_uid) {
+               m >>= 3;
+               if(u.u_gid != ip->i_gid)
+                       m >>= 3;
+       }
+       if((ip->i_mode&m) != 0)
+               return(0);
+
+       u.u_error = EACCES;
+       return(1);
+}
+
+/*
+ * Look up a pathname and test if
+ * the resultant inode is owned by the
+ * current user.
+ * If not, try for super-user.
+ * If permission is granted,
+ * return inode pointer.
+ */
+struct inode *
+owner()
+{
+       register struct inode *ip;
+
+       ip = namei(uchar, 0);
+       if(ip == NULL)
+               return(NULL);
+       if(u.u_uid == ip->i_uid)
+               return(ip);
+       if(suser())
+               return(ip);
+       iput(ip);
+       return(NULL);
+}
+
+/*
+ * Test if the current user is the
+ * super user.
+ */
+suser()
+{
+
+       if(u.u_uid == 0) {
+               u.u_acflag |= ASU;
+               return(1);
+       }
+       u.u_error = EPERM;
+       return(0);
+}
+
+/*
+ * Allocate a user file descriptor.
+ */
+ufalloc()
+{
+       register i;
+
+       for(i=0; i<NOFILE; i++)
+               if(u.u_ofile[i] == NULL) {
+                       u.u_r.r_val1 = i;
+                       u.u_pofile[i] = 0;
+                       return(i);
+               }
+       u.u_error = EMFILE;
+       return(-1);
+}
+
+/*
+ * Allocate a user file descriptor
+ * and a file structure.
+ * Initialize the descriptor
+ * to point at the file structure.
+ *
+ * no file -- if there are no available
+ *     file structures.
+ */
+struct file *
+falloc()
+{
+       register struct file *fp;
+       register i;
+
+       i = ufalloc();
+       if(i < 0)
+               return(NULL);
+       for(fp = &file[0]; fp < &file[NFILE]; fp++)
+               if(fp->f_count == 0) {
+                       u.u_ofile[i] = fp;
+                       fp->f_count++;
+                       fp->f_un.f_offset = 0;
+                       return(fp);
+               }
+       printf("no file\n");
+       u.u_error = ENFILE;
+       return(NULL);
+}
diff --git a/usr/src/sys/sys/hp.c b/usr/src/sys/sys/hp.c
new file mode 100644 (file)
index 0000000..9d3ac30
--- /dev/null
@@ -0,0 +1,370 @@
+/*
+ * RP04/RP06/RM03 disk driver
+ */
+
+#include "../h/param.h"
+#include "../h/uba.h"
+#include "../h/systm.h"
+#include "../h/buf.h"
+#include "../h/conf.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/map.h"
+#include "../h/mba.h"
+
+#define        DK_N    0
+
+struct device
+{
+       int     hpcs1;          /* control and Status register 1 */
+       int     hpds;           /* Drive Status */
+       int     hper1;          /* Error register 1 */
+       int     hpmr;           /* Maintenance */ 
+       int     hpas;           /* Attention Summary */
+       int     hpda;           /* Desired address register */
+       int     hpdt;           /* Drive type */
+       int     hpla;           /* Look ahead */
+       int     hpsn;           /* serial number */
+       int     hpof;           /* Offset register */
+       int     hpdc;           /* Desired Cylinder address register */
+       int     hpcc;           /* Current Cylinder */
+       int     hper2;          /* Error register 2 */
+       int     hper3;          /* Error register 3 */
+       int     hpec1;          /* Burst error bit position */
+       int     hpec2;          /* Burst error bit pattern */
+};
+
+#define        HPADDR  ((struct device *)(MBA0 + MBA_ERB))
+#define        NHP     2
+#define        RP      022
+#define        RM      024
+#define        NSECT   22
+#define        NTRAC   19
+#define        NRMSECT 32
+#define        NRMTRAC 5
+#define        SDIST   2
+#define        RDIST   6
+
+struct size
+{
+       daddr_t nblocks;
+       int     cyloff;
+} hp_sizes[8] =
+{
+       9614,   0,              /* cyl 0 thru 22 */
+       8778,   23,             /* cyl 23 thru 43 */
+       35948,  44,             /* cyl 44 thru 129 */
+       286330, 130,            /* cyl 130 thru 814 */
+       0,      0,
+       0,      0,
+       330220, 25,             /* cyl 25 thru 814 */
+       322278, 44,             /* cyl 44 thru 814 */
+}, rm_sizes[8] = {
+       9600,   0,      /* cyl 0 thru 59 */
+       8800,   60,     /* cyl 60 thru 114 */
+       0,      0,
+       0,      0,
+       0,      0,
+       0,      0,
+       122080, 60,     /* cyl 60 thru 822 */
+       113280, 115,    /* cyl 115 thru 822 */
+};
+
+#define        P400    020
+#define        M400    0220
+#define        P800    040
+#define        M800    0240
+#define        P1200   060
+#define        M1200   0260
+int    hp_offset[16] =
+{
+       P400, M400, P400, M400,
+       P800, M800, P800, M800,
+       P1200, M1200, P1200, M1200,
+       0, 0, 0, 0,
+};
+
+struct buf     hptab;
+struct buf     rhpbuf;
+struct buf     hputab[NHP];
+char   hp_type[NHP];   /* drive type */
+
+#define        GO      01
+#define        PRESET  020
+#define        RTC     016
+#define        OFFSET  014
+#define        SEARCH  030
+#define        RECAL   06
+#define DCLR   010
+#define        WCOM    060
+#define        RCOM    070
+
+#define        IE      0100
+#define        PIP     020000
+#define        DRY     0200
+#define        ERR     040000
+#define        TRE     040000
+#define        DCK     0100000
+#define        WLE     04000
+#define        ECH     0100
+#define VV     0100
+#define DPR 0400
+#define MOL 010000
+#define FMT22  010000
+
+#define b_cylin b_resid
+daddr_t dkblock();
+hpstrategy(bp)
+register struct buf *bp;
+{
+       register struct buf *dp;
+       register unit, xunit, nspc;
+       long sz, bn;
+       struct size *sizes;
+
+       xunit = minor(bp->b_dev) & 077;
+       sz = bp->b_bcount;
+       sz = (sz+511) >> 9;
+       unit = dkunit(bp);
+       if (hp_type[unit] == 0) {
+               struct device *hpaddr;
+
+               /* determine device type */
+               hpaddr = (struct device *)((int*)HPADDR + 32*unit);
+               hp_type[unit] = hpaddr->hpdt;
+       }
+       if (hp_type[unit] == RM) {
+               sizes = rm_sizes;
+               nspc = NRMSECT*NRMTRAC;
+       } else {
+               sizes = hp_sizes;
+               nspc = NSECT*NTRAC;
+       }
+       if (unit >= NHP ||
+           bp->b_blkno < 0 ||
+           (bn = dkblock(bp))+sz > sizes[xunit&07].nblocks) {
+               bp->b_flags |= B_ERROR;
+               iodone(bp);
+               return;
+       }
+       bp->b_cylin = bn/nspc + sizes[xunit&07].cyloff;
+       dp = &hputab[unit];
+       spl5();
+       disksort(dp, bp);
+       if (dp->b_active == 0) {
+               hpustart(unit);
+               if(hptab.b_active == 0)
+                       hpstart();
+       }
+       spl0();
+}
+
+hpustart(unit)
+register unit;
+{
+       register struct buf *bp, *dp;
+       register struct device *hpaddr;
+       daddr_t bn;
+       int sn, cn, csn;
+
+       ((struct mba_regs *)MBA0)->mba_cr |= MBAIE;
+       HPADDR->hpas = 1<<unit;
+
+       if(unit >= NHP)
+               return;
+       dk_busy &= ~(1<<(unit+DK_N));
+       dp = &hputab[unit];
+       if((bp=dp->b_actf) == NULL)
+               return;
+       hpaddr = (struct device *)((int *)HPADDR + 32*unit);
+       if((hpaddr->hpds & VV) == 0) {
+               hpaddr->hpcs1 = PRESET|GO;
+               hpaddr->hpof = FMT22;
+       }
+       if(dp->b_active)
+               goto done;
+       dp->b_active++;
+       if ((hpaddr->hpds & (DPR|MOL)) != (DPR|MOL))
+               goto done;
+
+       bn = dkblock(bp);
+       cn = bp->b_cylin;
+       if(hp_type[unit] == RM) {
+               sn = bn%(NRMSECT*NRMTRAC);
+               sn = (sn+NRMSECT-SDIST)%NRMSECT;
+       } else {
+               sn = bn%(NSECT*NTRAC);
+               sn = (sn+NSECT-SDIST)%NSECT;
+       }
+
+       if(cn - (hpaddr->hpdc & 0xffff))
+               goto search;
+       csn = ((hpaddr->hpla & 0xffff)>>6) - sn + SDIST - 1;
+       if(csn < 0)
+               csn += NSECT;
+       if(csn > NSECT-RDIST)
+               goto done;
+
+search:
+       hpaddr->hpdc = cn;
+       hpaddr->hpda = sn;
+       hpaddr->hpcs1 = SEARCH|GO;
+       unit += DK_N;
+       dk_busy |= 1<<unit;
+       dk_numb[unit] += 1;
+       return;
+
+done:
+       dp->b_forw = NULL;
+       if(hptab.b_actf == NULL)
+               hptab.b_actf = dp; else
+               hptab.b_actl->b_forw = dp;
+       hptab.b_actl = dp;
+}
+
+hpstart()
+{
+       register struct buf *bp, *dp;
+       register unit;
+       register struct device *hpaddr;
+       daddr_t bn;
+       int dn, sn, tn, cn, nspc, ns;
+
+loop:
+       if ((dp = hptab.b_actf) == NULL)
+               return;
+       if ((bp = dp->b_actf) == NULL) {
+               hptab.b_actf = dp->b_forw;
+               goto loop;
+       }
+       hptab.b_active++;
+       unit = minor(bp->b_dev) & 077;
+       dn = dkunit(bp);
+       bn = dkblock(bp);
+       if (hp_type[dn] == RM) {
+               nspc = NRMSECT*NRMTRAC;
+               ns = NRMSECT;
+               cn = rm_sizes[unit&07].cyloff;
+       } else {
+               nspc = NSECT*NTRAC;
+               ns = NSECT;
+               cn = hp_sizes[unit&07].cyloff;
+       }
+       cn += bn/nspc;
+       sn = bn%nspc;
+       tn = sn/ns;
+       sn = sn%ns;
+
+       hpaddr =  (struct device *)((int *)HPADDR + 32*dn);
+       if ((hpaddr->hpds & (DPR|MOL)) != (DPR|MOL)) {
+               hptab.b_active = 0;
+               hptab.b_errcnt = 0;
+               dp->b_actf = bp->av_forw;
+               bp->b_flags |= B_ERROR;
+               iodone(bp);
+               goto loop;
+       }
+       if(hptab.b_errcnt >= 16) {
+               hpaddr->hpof = hp_offset[hptab.b_errcnt & 017] | FMT22;
+               ((struct mba_regs *)MBA0)->mba_cr &= ~MBAIE;
+               hpaddr->hpcs1 = OFFSET|GO;
+               while(hpaddr->hpds & PIP)
+                       ;
+               ((struct mba_regs *)MBA0)->mba_cr |= MBAIE;
+       }
+       hpaddr->hpdc = cn;
+       hpaddr->hpda = (tn << 8) + sn;
+       mbastart(bp, hpaddr);
+
+       dk_busy |= 1<<(DK_N+NHP);
+       dk_numb[DK_N+NHP] += 1;
+       unit = bp->b_bcount>>6;
+       dk_wds[DK_N+NHP] += unit;
+}
+
+hpintr(mbastat, as)
+{
+       register struct buf *bp, *dp;
+       register unit;
+       register struct device *hpaddr;
+       int i, j;
+
+       if(hptab.b_active) {
+               dk_busy &= ~(1<<(DK_N+NHP));
+               dp = hptab.b_actf;
+               bp = dp->b_actf;
+               unit = dkunit(bp);
+               hpaddr = (struct device *)((int *)HPADDR + 32*unit);
+               if (hpaddr->hpds & ERR || mbastat & MBAEBITS) {         /* error bit */
+                       while((hpaddr->hpds & DRY) == 0)
+                               ;
+                       if(++hptab.b_errcnt > 28 || hpaddr->hper1&WLE)
+                               bp->b_flags |= B_ERROR; else
+                               hptab.b_active = 0;
+                       if(hptab.b_errcnt > 27)
+                               deverror(bp, mbastat, hpaddr->hper1);
+                       if((bp->b_flags&B_PHYS) == 0 &&
+                          (hpaddr->hper1 & (DCK|ECH)) == DCK) {
+                               i = (hpaddr->hpec1 & 0xffff) - 1;
+                               j = i&037;
+                               i >>= 5;
+                               if(i >= 0 && i <128) {
+                                       bp->b_un.b_words[i] ^= (hpaddr->hpec2 & 0xffff) << j;
+                                       bp->b_un.b_words[i+1] ^= (hpaddr->hpec2 & 0xffff) >> (32-j);
+                               }
+                               hptab.b_active++;
+                               printf("%D ", bp->b_blkno);
+                               prdev("ECC", bp->b_dev);
+                       }
+                       hpaddr->hpcs1 = DCLR|GO;
+                       if((hptab.b_errcnt&07) == 4) {
+                               ((struct mba_regs *)MBA0)->mba_cr &= ~MBAIE;
+                               hpaddr->hpcs1 = RECAL|GO;
+                               while(hpaddr->hpds & PIP)
+                                       ;
+                               ((struct mba_regs *)MBA0)->mba_cr |= MBAIE;
+                       }
+               }
+               if(hptab.b_active) {
+                       if(hptab.b_errcnt) {
+                               ((struct mba_regs *)MBA0)->mba_cr &= ~MBAIE;
+                               hpaddr->hpcs1 = RTC|GO;
+                               while(hpaddr->hpds & PIP)
+                                       ;
+                               ((struct mba_regs *)MBA0)->mba_cr |= MBAIE;
+                       }
+                       hptab.b_active = 0;
+                       hptab.b_errcnt = 0;
+                       hptab.b_actf = dp->b_forw;
+                       dp->b_active = 0;
+                       dp->b_errcnt = 0;
+                       dp->b_actf = bp->av_forw;
+                       bp->b_resid = -(((struct mba_regs *)MBA0)->mba_bcr) & 0xffff;
+                       iodone(bp);
+                       if(dp->b_actf)
+                               hpustart(unit);
+               }
+               as &= ~(1<<unit);
+       } else {
+               if(as == 0)
+                       ((struct mba_regs *)MBA0)->mba_cr |= MBAIE;
+       }
+       for(unit=0; unit<NHP; unit++)
+               if(as & (1<<unit))
+                       hpustart(unit);
+       hpstart();
+}
+
+hpread(dev)
+{
+
+       physio(hpstrategy, &rhpbuf, dev, B_READ);
+}
+
+hpwrite(dev)
+{
+
+       physio(hpstrategy, &rhpbuf, dev, B_WRITE);
+}
diff --git a/usr/src/sys/sys/ht.c b/usr/src/sys/sys/ht.c
new file mode 100644 (file)
index 0000000..3c1f745
--- /dev/null
@@ -0,0 +1,349 @@
+/*
+ * TJU16 tape driver
+ */
+
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/buf.h"
+#include "../h/conf.h"
+#include "../h/dir.h"
+#include "../h/file.h"
+#include "../h/user.h"
+#include "../h/uba.h"
+#include "../h/map.h"
+#include "../h/mba.h"
+
+struct device
+{
+       int     htcs1;
+       int     htds;
+       int     hter;
+       int     htmr;
+       int     htas;
+       int     htfc;
+       int     htdt;
+       int     htck;
+       int     htsn;
+       int     httc;
+};
+
+struct buf     httab;
+struct buf     rhtbuf;
+struct buf     chtbuf;
+
+#define        NUNIT   1
+#define        BUNIT   2
+#define        INF     1000000
+
+char   h_openf[NUNIT];
+daddr_t        h_blkno[NUNIT];
+char   h_flags[NUNIT];
+daddr_t        h_nxrec[NUNIT];
+
+#define        HTADDR  ((struct device *)(MBA1 + MBA_ERB))
+
+#define        GO      01
+#define        WCOM    060
+#define        RCOM    070
+#define        NOP     0
+#define        WEOF    026
+#define        SFORW   030
+#define        SREV    032
+#define        ERASE   024
+#define        REW     06
+#define        DCLR    010
+#define P800   01700           /* 800 + pdp11 mode */
+#define        P1600   02300           /* 1600 + pdp11 mode */
+#define        IENABLE 0100
+#define        RDY     0200
+#define        TM      04
+#define        DRY     0200
+#define EOT    02000
+#define CS     02000
+#define COR    0100000
+#define PES    040
+#define WRL    04000
+#define MOL    010000
+#define ERR    040000
+#define FCE    01000
+#define        TRE     040000
+#define HARD   064023  /* UNS|OPI|NEF|FMT|RMR|ILR|ILF */
+
+#define        SIO     1
+#define        SSFOR   2
+#define        SSREV   3
+#define SRETRY 4
+#define SCOM   5
+#define SOK    6
+
+#define H_WRITTEN 1
+
+htopen(dev, flag)
+{
+       register unit, ds;
+
+       httab.b_flags |= B_TAPE;
+       unit = minor(dev) & 03;
+       if (unit >= NUNIT || h_openf[unit]) {
+               u.u_error = ENXIO;
+               return;
+       }
+       h_blkno[unit] = 0;
+       h_nxrec[unit] = INF;
+       h_flags[unit] = 0;
+       ds = hcommand(dev, NOP);
+       if ((ds&MOL)==0 || (flag && (ds&WRL)))
+               u.u_error = ENXIO;
+       if (u.u_error==0)
+               h_openf[unit]++;
+}
+
+htclose(dev, flag)
+{
+       register int unit;
+
+       unit = minor(dev) & 03;
+       if (flag == FWRITE || ((flag&FWRITE) && (h_flags[unit]&H_WRITTEN))) {
+               hcommand(dev, WEOF);
+               hcommand(dev, WEOF);
+               hcommand(dev, SREV);
+       }
+/*     hcommand(dev, REW);     */
+/* for 'mtm' file positioning */
+       if((minor(dev)&4) == 0) /* no 4 -> rewind */
+               hcommand(dev,REW) ;
+       h_openf[unit] = 0;
+}
+
+hcommand(dev, com)
+{
+       register struct buf *bp;
+
+       bp = &chtbuf;
+       spl5();
+       while(bp->b_flags&B_BUSY) {
+               bp->b_flags |= B_WANTED;
+               sleep(bp, PRIBIO);
+       }
+       spl0();
+       bp->b_dev = dev;
+       bp->b_resid = com;
+       bp->b_blkno = 0;
+       bp->b_flags = B_BUSY|B_READ;
+       htstrategy(bp);
+       iowait(bp);
+       if(bp->b_flags&B_WANTED)
+               wakeup(bp);
+       bp->b_flags = 0;
+       return(bp->b_resid);
+}
+
+htstrategy(bp)
+register struct buf *bp;
+{
+       register daddr_t *p;
+
+       if(bp != &chtbuf) {
+               p = &h_nxrec[minor(bp->b_dev)&03];
+               if(bp->b_blkno > *p) {
+                       bp->b_flags |= B_ERROR;
+                       bp->b_error = ENXIO;
+                       iodone(bp);
+                       return;
+               }
+               if(bp->b_blkno == *p && bp->b_flags&B_READ) {
+                       bp->b_resid = bp->b_bcount;
+                       clrbuf(bp);
+                       iodone(bp);
+                       return;
+               }
+               if ((bp->b_flags&B_READ)==0) {
+                       *p = bp->b_blkno + 1;
+                       h_flags[minor(bp->b_dev)&03] |=  H_WRITTEN;
+               }
+       }
+       bp->av_forw = NULL;
+       spl5();
+       if (httab.b_actf == NULL)
+               httab.b_actf = bp;
+       else
+               httab.b_actl->av_forw = bp;
+       httab.b_actl = bp;
+       if (httab.b_active==0)
+               htstart();
+       spl0();
+}
+
+htstart()
+{
+       register struct buf *bp;
+       register unit, den;
+       daddr_t blkno;
+
+    loop:
+       if ((bp = httab.b_actf) == NULL)
+               return;
+       unit = minor(bp->b_dev);
+       den = P800 | (unit&03);
+       if(unit >= 8)
+               den = P1600 | (unit&03);
+       if((HTADDR->httc&03777) != den)
+               HTADDR->httc = den;
+       unit &= 03;
+       blkno = h_blkno[unit];
+       if (bp == &chtbuf) {
+               if (bp->b_resid==NOP) {
+                       bp->b_resid = HTADDR->htds & 0xffff;
+                       goto next;
+               }
+               httab.b_active = SCOM;
+               HTADDR->htfc = 0;
+               HTADDR->htcs1 = bp->b_resid|GO;
+               return;
+       }
+       if (h_openf[unit] < 0 || bp->b_blkno > h_nxrec[unit])
+               goto abort;
+       if (blkno == bp->b_blkno) {
+               httab.b_active = SIO;
+               HTADDR->htfc = -bp->b_bcount;
+               mbastart(bp, HTADDR);
+       } else {
+               if (blkno < bp->b_blkno) {
+                       httab.b_active = SSFOR;
+                       HTADDR->htfc = blkno - bp->b_blkno;
+                       HTADDR->htcs1 = SFORW|GO;
+               } else {
+                       httab.b_active = SSREV;
+                       HTADDR->htfc = bp->b_blkno - blkno;
+                       HTADDR->htcs1 = SREV|GO;
+               }
+       }
+       return;
+
+    abort:
+       bp->b_flags |= B_ERROR;
+
+    next:
+       httab.b_actf = bp->av_forw;
+       iodone(bp);
+       goto loop;
+}
+
+htintr(mbastat, as)
+{
+       register struct buf *bp;
+       register int unit, state;
+       int     err;
+
+       if ((bp = httab.b_actf)==NULL)
+               return;
+       unit = minor(bp->b_dev) & 03;
+       state = httab.b_active;
+       httab.b_active = 0;
+       if (HTADDR->htds&(ERR|EOT|TM) || mbastat & MBAEBITS) {
+               err = HTADDR->hter & 0xffff;
+               if ((mbastat & MBAEBITS) || (err&HARD))
+                       state = 0;
+               if (bp == &rhtbuf)
+                       err &= ~FCE;
+               if ((bp->b_flags&B_READ) && (HTADDR->htds&PES))
+                       err &= ~(CS|COR);
+               if(HTADDR->htds&EOT || (HTADDR->htds&MOL)==0) {
+                       if(h_openf[unit])
+                               h_openf[unit] = -1;
+               }
+               else if(HTADDR->htds&TM) {
+                       HTADDR->htfc = 0;
+                       h_nxrec[unit] = bp->b_blkno;
+                       state = SOK;
+               }
+               else if(state && err == 0)
+                       state = SOK;
+               if(httab.b_errcnt > 4)
+                       deverror(bp, HTADDR->hter, mbastat);
+               ((struct mba_regs *)MBA1)->mba_cr &= ~MBAIE;
+               HTADDR->htcs1 = DCLR|GO;
+               ((struct mba_regs *)MBA1)->mba_cr |= MBAIE;
+               if (state==SIO && ++httab.b_errcnt < 10) {
+                       httab.b_active = SRETRY;
+                       h_blkno[unit]++;
+                       HTADDR->htfc = -1;
+                       HTADDR->htcs1 = SREV|GO;
+                       return;
+               }
+               if (state!=SOK) {
+                       bp->b_flags |= B_ERROR;
+                       state = SIO;
+               }
+       } else if (HTADDR->htcs1 < 0) { /* SC */
+               if(HTADDR->htds & ERR) {
+                       ((struct mba_regs *)MBA1)->mba_cr &= ~MBAIE;
+                       HTADDR->htcs1 = DCLR|GO;
+                       ((struct mba_regs *)MBA1)->mba_cr |= MBAIE;
+               }
+       }
+       switch(state) {
+       case SIO:
+       case SOK:
+               h_blkno[unit]++;
+
+       case SCOM:
+               httab.b_errcnt = 0;
+               httab.b_actf = bp->av_forw;
+               bp->b_resid = - (HTADDR->htfc & 0xffff);
+               if (bp->b_flags & B_READ)
+                       bp->b_resid += bp->b_bcount;
+               iodone(bp);
+               break;
+
+       case SRETRY:
+               if((bp->b_flags&B_READ)==0) {
+                       httab.b_active = SSFOR;
+                       HTADDR->htcs1 = ERASE|GO;
+                       return;
+               }
+
+       case SSFOR:
+       case SSREV:
+               if(HTADDR->htds & TM) {
+                       if(state == SSREV) {
+                               h_nxrec[unit] = bp->b_blkno - (HTADDR->htfc&0xffff);
+                               h_blkno[unit] = h_nxrec[unit];
+                       } else {
+                               h_nxrec[unit] = bp->b_blkno + (HTADDR->htfc & 0xffff) - 1;
+                               h_blkno[unit] = bp->b_blkno + (HTADDR->htfc & 0xffff);
+                       }
+               } else
+                       h_blkno[unit] = bp->b_blkno;
+               break;
+
+       default:
+               return;
+       }
+       htstart();
+}
+
+htread(dev)
+{
+       htphys(dev);
+       physio(htstrategy, &rhtbuf, dev, B_READ);
+}
+
+htwrite(dev)
+{
+       htphys(dev);
+       physio(htstrategy, &rhtbuf, dev, B_WRITE);
+}
+
+htphys(dev)
+{
+       register unit;
+       daddr_t a;
+
+       unit = minor(dev) & 03;
+       if(unit < NUNIT) {
+               a = u.u_offset >> 9;
+               h_blkno[unit] = a;
+               h_nxrec[unit] = a+1;
+       }
+}
diff --git a/usr/src/sys/sys/iget.c b/usr/src/sys/sys/iget.c
new file mode 100644 (file)
index 0000000..09ae774
--- /dev/null
@@ -0,0 +1,316 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/mount.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/inode.h"
+#include "../h/ino.h"
+#include "../h/filsys.h"
+#include "../h/conf.h"
+#include "../h/buf.h"
+
+/*
+ * Look up an inode by device,inumber.
+ * If it is in core (in the inode structure),
+ * honor the locking protocol.
+ * If it is not in core, read it in from the
+ * specified device.
+ * If the inode is mounted on, perform
+ * the indicated indirection.
+ * In all cases, a pointer to a locked
+ * inode structure is returned.
+ *
+ * printf warning: no inodes -- if the inode
+ *     structure is full
+ * panic: no imt -- if the mounted file
+ *     system is not in the mount table.
+ *     "cannot happen"
+ */
+struct inode *
+iget(dev, ino)
+dev_t dev;
+ino_t ino;
+{
+       register struct inode *ip;
+       register struct mount *mp;
+       register struct inode *oip;
+       register struct buf *bp;
+       register struct dinode *dp;
+
+loop:
+       oip = NULL;
+       for(ip = &inode[0]; ip < &inode[NINODE]; ip++) {
+               if(ino == ip->i_number && dev == ip->i_dev) {
+                       if((ip->i_flag&ILOCK) != 0) {
+                               ip->i_flag |= IWANT;
+                               sleep((caddr_t)ip, PINOD);
+                               goto loop;
+                       }
+                       if((ip->i_flag&IMOUNT) != 0) {
+                               for(mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
+                               if(mp->m_inodp == ip) {
+                                       dev = mp->m_dev;
+                                       ino = ROOTINO;
+                                       goto loop;
+                               }
+                               panic("no imt");
+                       }
+                       ip->i_count++;
+                       ip->i_flag |= ILOCK;
+                       return(ip);
+               }
+               if(oip==NULL && ip->i_count==0)
+                       oip = ip;
+       }
+       ip = oip;
+       if(ip == NULL) {
+               printf("Inode table overflow\n");
+               u.u_error = ENFILE;
+               return(NULL);
+       }
+       ip->i_dev = dev;
+       ip->i_number = ino;
+       ip->i_flag = ILOCK;
+       ip->i_count++;
+       ip->i_un.i_lastr = 0;
+       bp = bread(dev, itod(ino));
+       /*
+        * Check I/O errors
+        */
+       if((bp->b_flags&B_ERROR) != 0) {
+               brelse(bp);
+               iput(ip);
+               return(NULL);
+       }
+       dp = bp->b_un.b_dino;
+       dp += itoo(ino);
+       iexpand(ip, dp);
+       brelse(bp);
+       return(ip);
+}
+
+iexpand(ip, dp)
+register struct inode *ip;
+register struct dinode *dp;
+{
+       register char *p1;
+       char *p2;
+       int i;
+
+       ip->i_mode = dp->di_mode;
+       ip->i_nlink = dp->di_nlink;
+       ip->i_uid = dp->di_uid;
+       ip->i_gid = dp->di_gid;
+       ip->i_size = dp->di_size;
+       p1 = (char *)ip->i_un.i_addr;
+       p2 = (char *)dp->di_addr;
+       for(i=0; i<NADDR; i++) {
+               *p1++ = *p2++;
+               *p1++ = *p2++;
+               *p1++ = *p2++;
+               *p1++ = 0;
+       }
+}
+
+/*
+ * Decrement reference count of
+ * an inode structure.
+ * On the last reference,
+ * write the inode out and if necessary,
+ * truncate and deallocate the file.
+ */
+iput(ip)
+register struct inode *ip;
+{
+
+       if(ip->i_count == 1) {
+               ip->i_flag |= ILOCK;
+               if(ip->i_nlink <= 0) {
+                       itrunc(ip);
+                       ip->i_mode = 0;
+                       ip->i_flag |= IUPD|ICHG;
+                       ifree(ip->i_dev, ip->i_number);
+               }
+               iupdat(ip, &time, &time);
+               prele(ip);
+               ip->i_flag = 0;
+               ip->i_number = 0;
+       }
+       ip->i_count--;
+       prele(ip);
+}
+
+/*
+ * Check accessed and update flags on
+ * an inode structure.
+ * If any is on, update the inode
+ * with the current time.
+ */
+iupdat(ip, ta, tm)
+register struct inode *ip;
+time_t *ta, *tm;
+{
+       register struct buf *bp;
+       struct dinode *dp;
+       register char *p1;
+       char *p2;
+       int i;
+
+       if((ip->i_flag&(IUPD|IACC|ICHG)) != 0) {
+               if(getfs(ip->i_dev)->s_ronly)
+                       return;
+               bp = bread(ip->i_dev, itod(ip->i_number));
+               if (bp->b_flags & B_ERROR) {
+                       brelse(bp);
+                       return;
+               }
+               dp = bp->b_un.b_dino;
+               dp += itoo(ip->i_number);
+               dp->di_mode = ip->i_mode;
+               dp->di_nlink = ip->i_nlink;
+               dp->di_uid = ip->i_uid;
+               dp->di_gid = ip->i_gid;
+               dp->di_size = ip->i_size;
+               p1 = (char *)dp->di_addr;
+               p2 = (char *)ip->i_un.i_addr;
+               for(i=0; i<NADDR; i++) {
+                       *p1++ = *p2++;
+                       *p1++ = *p2++;
+                       *p1++ = *p2++;
+                       if(*p2++ != 0 && (ip->i_mode&IFMT)!=IFMPC
+                          && (ip->i_mode&IFMT)!=IFMPB)
+                               printf("iaddress > 2^24\n");
+               }
+               if(ip->i_flag&IACC)
+                       dp->di_atime = *ta;
+               if(ip->i_flag&IUPD)
+                       dp->di_mtime = *tm;
+               if(ip->i_flag&ICHG)
+                       dp->di_ctime = time;
+               ip->i_flag &= ~(IUPD|IACC|ICHG);
+               bdwrite(bp);
+       }
+}
+
+/*
+ * Free all the disk blocks associated
+ * with the specified inode structure.
+ * The blocks of the file are removed
+ * in reverse order. This FILO
+ * algorithm will tend to maintain
+ * a contiguous free list much longer
+ * than FIFO.
+ */
+itrunc(ip)
+register struct inode *ip;
+{
+       register i;
+       dev_t dev;
+       daddr_t bn;
+
+       i = ip->i_mode & IFMT;
+       if (i!=IFREG && i!=IFDIR)
+               return;
+       dev = ip->i_dev;
+       for(i=NADDR-1; i>=0; i--) {
+               bn = ip->i_un.i_addr[i];
+               if(bn == (daddr_t)0)
+                       continue;
+               ip->i_un.i_addr[i] = (daddr_t)0;
+               switch(i) {
+
+               default:
+                       free(dev, bn);
+                       break;
+
+               case NADDR-3:
+                       tloop(dev, bn, 0, 0);
+                       break;
+
+               case NADDR-2:
+                       tloop(dev, bn, 1, 0);
+                       break;
+
+               case NADDR-1:
+                       tloop(dev, bn, 1, 1);
+               }
+       }
+       ip->i_size = 0;
+       ip->i_flag |= ICHG|IUPD;
+}
+
+tloop(dev, bn, f1, f2)
+dev_t dev;
+daddr_t bn;
+{
+       register i;
+       register struct buf *bp;
+       register daddr_t *bap;
+       daddr_t nb;
+
+       bp = NULL;
+       for(i=NINDIR-1; i>=0; i--) {
+               if(bp == NULL) {
+                       bp = bread(dev, bn);
+                       if (bp->b_flags & B_ERROR) {
+                               brelse(bp);
+                               return;
+                       }
+                       bap = bp->b_un.b_daddr;
+               }
+               nb = bap[i];
+               if(nb == (daddr_t)0)
+                       continue;
+               if(f1) {
+                       brelse(bp);
+                       bp = NULL;
+                       tloop(dev, nb, f2, 0);
+               } else
+                       free(dev, nb);
+       }
+       if(bp != NULL)
+               brelse(bp);
+       free(dev, bn);
+}
+
+/*
+ * Make a new file.
+ */
+struct inode *
+maknode(mode)
+{
+       register struct inode *ip;
+
+       ip = ialloc(u.u_pdir->i_dev);
+       if(ip == NULL) {
+               iput(u.u_pdir);
+               return(NULL);
+       }
+       ip->i_flag |= IACC|IUPD|ICHG;
+       if((mode&IFMT) == 0)
+               mode |= IFREG;
+       ip->i_mode = mode & ~u.u_cmask;
+       ip->i_nlink = 1;
+       ip->i_uid = u.u_uid;
+       ip->i_gid = u.u_gid;
+       wdir(ip);
+       return(ip);
+}
+
+/*
+ * Write a directory entry with
+ * parameters left as side effects
+ * to a call to namei.
+ */
+wdir(ip)
+struct inode *ip;
+{
+
+       u.u_dent.d_ino = ip->i_number;
+       bcopy((caddr_t)u.u_dbuf, (caddr_t)u.u_dent.d_name, DIRSIZ);
+       u.u_count = sizeof(struct direct);
+       u.u_segflg = 1;
+       u.u_base = (caddr_t)&u.u_dent;
+       writei(u.u_pdir);
+       iput(u.u_pdir);
+}
diff --git a/usr/src/sys/sys/loadall b/usr/src/sys/sys/loadall
new file mode 100755 (executable)
index 0000000..fd989a9
--- /dev/null
@@ -0,0 +1,2 @@
+ld -o unix -e start -x -T 80000000 locore.o acct.o alloc.o bio.o clock.o conf.o cons.o dkleave.o dsort.o dz.o fio.o hp.o ht.o iget.o machdep.o main.o malloc.o mba.o mem.o mx1.o mx2.o  nami.o partab.o pipe.o prf.o prim.o rdwri.o sig.o slp.o subr.o sys.o sys1.o sys2.o sys3.o sys4.o sysent.o tdump.o text.o trap.o tty.o uba.o univec.o
+ls -l unix
diff --git a/usr/src/sys/sys/locore.s b/usr/src/sys/sys/locore.s
new file mode 100644 (file)
index 0000000..be7dfc5
--- /dev/null
@@ -0,0 +1,1224 @@
+       .set    HIGH,31         # mask for total disable
+       .set    MCKVEC,4        # offset into Scbbase of machine check vector
+
+# Trap vectors and C interface for Vax
+
+#
+#
+#
+# System control block
+#
+
+       .set    INTSTK,1        # handle this interrupt on the interrupt stack
+       .set    HALT,3          # halt if this interrupt occurs
+       .align  9
+       .globl  Scbbase
+Scbbase:
+       .long   Xrandom + HALT  # unused
+       .long   Xmachcheck + HALT       # machine check interrupt
+       .long   Xkspnotval + HALT       # kernal stack not valid
+       .long   Xpowfail + HALT # power fail
+       .long   Xprivinflt      # privileged instruction 
+       .long   Xxfcflt         # xfc instruction 
+       .long   Xresopflt       # reserved operand 
+       .long   Xresadflt       # reserved addressing 
+       .long   Xprotflt        # protection 
+       .long   Xsegflt         # segmentation 
+       .long   Xtracep         # trace pending
+       .long   Xbptflt         # bpt instruction
+       .long   Xcompatflt      # compatibility mode fault
+       .long   Xarithtrap      # arithmetic trap
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xsyscall        # chmk
+       .long   Xchme+HALT              # chme
+       .long   Xchms+HALT              # chms
+       .long   Xchmu+HALT              # chmu
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # software level 1
+       .long   Xrandom + HALT  # software level 2 (asts)
+       .long   Xresched        # reschedule nudge
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+ubabase:
+       .long   Xclockint + INTSTK      # clock
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xconsrint + INTSTK      # console receiver 
+       .long   Xconsxint + INTSTK      # console transmitter
+
+#      I/O vectors
+
+# IPL 14
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xua0int + INTSTK        # UBA 0 br4
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+
+# IPL 15
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xua0int + INTSTK        # UBA 0 br5
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xmba0int + INTSTK       # mass bus adapter 0
+       .long   Xmba1int + INTSTK       # mass bus adapter 1
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+
+# IPL 16
+       .long   Xrandom + HALT          # unused
+       .long   Xrandom + HALT          # unused
+       .long   Xrandom + HALT          # unused
+       .long   Xua0int + INTSTK        # UBA 0 br6
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+
+# IPL 17
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+       .long   Xrandom + HALT  # unused
+
+
+#  0x200
+# Produce a core image dump on mag tape
+       .globl  doadump
+doadump:
+       movl    sp,dumpstack    # save stack pointer
+       movab   dumpstack,sp    # reinit stack
+       mfpr    $PCBB,-(sp)     # save u-area pointer
+       mfpr    $MAPEN,-(sp)    # save value
+       mfpr    $IPL,-(sp)      # ...
+       mtpr    $0,$MAPEN               # turn off memory mapping
+       mtpr    $HIGH,$IPL              # disable interrupts
+       pushr   $0x3fff                 # save regs 0 - 13
+       calls   $0,_dump        # produce dump
+       halt
+
+       .data
+       .align  2
+       .globl  dumpstack
+       .space  58*4            # seperate stack for tape dumps
+dumpstack: 
+       .space  4
+       .text
+
+
+# I/O interrupt vector routines
+#
+
+# Catch random or unexpected interrupts
+
+       .align  2
+Xrandom:
+Xmachcheck:
+Xkspnotval:
+Xpowfail:
+Xchme:
+Xchms:
+Xchmu:
+       halt
+
+# Massbus 0 adapter interrupts
+
+       .align  2
+Xmba0int:
+       pushr   $0x3f           # save r0 - r5
+       movab   MBA0_CSR,r0     # point at mba regs
+       movl    MBA_AS(r0),r1           # get attn summary bits
+       cvtwl   r1,-(sp)                # push attn summary as arg
+       pushl   MBA_SR(r0)      # pass sr as argument
+       mnegl   $1,MBA_SR(r0)   # clear attention bit
+       calls   $2,_hpintr      # call rp06 interrupt dispatcher
+       brw     int_ret         # merge with common interrupt code
+
+
+# Massbus 1 adapter interrupts
+
+       .align  2
+Xmba1int:
+       pushr   $0x3f
+       movab   MBA1_CSR,r0
+       pushl   MBA_AS(r0)
+       mnegl   $1,MBA_AS(r0)
+       pushl   MBA_SR(r0)              # pass cr as argument_
+       mnegl   $1,MBA_SR(r0)   # clear attention bit
+       calls   $2,_htintr      # call te16 interrupt dispatcher
+       brw     int_ret         # return from interrupt
+
+
+# Unibus adapter interrupts
+
+       .align  2
+Xua0int:       #  UBA 0 interrupts
+       pushr   $0x3f  #  save regs 0-5
+       pushab  UBA0  # save UBA base addr
+       brb     Xuacom  #  jump to common code
+Xua1int :      #  UBA 1 interrupts
+Xuacom :       #  common code for UBA interrupts
+       popr    $1              # UBA base addr
+       mfpr    $IPL,r2         # get br level
+       movl    UBR_OFF-20*4(r0)[r2],r3 # get unibus device vector
+       bleq    ubasrv  # branch if zero vector or UBA service required
+#  normal UBA interrupt point - device on a UBA has generated an
+#    interrupt - r3 holds interrupt vector
+ubanorm :
+       movl    _UNIvec(r3),r1  #  get interrupt service routine address
+#                      and controller code from UNIBUS vector area
+       extzv   $27,$4,r1,-(sp)  #  controller code is in 4 most
+#                              significant bits-1 of ISR addr
+       bicl2   $0x78000000,r1  #  clear code
+       calls   $1,(r1)  #  call ISR
+       brw     int_ret  #  go to common interrupt return
+#  here for zero or negative UBA interrupt vector.
+#  negative vector -> UBA requires service
+ubasrv :
+       beql    ubapass
+#
+#  UBA service required
+#  The following 'printf' calls should probably be replaced
+#    with calls to an error logger and/or some corrective action.
+       bitl    $CFGFLT,UCN_OFF(r0)  #  any SBI faults ?
+       beql    UBAflt
+       pushr   $0xf  #  save regs 0-3
+       pushab  SBImsg
+       calls   $1,_printf
+       popr    $0xf
+       halt
+#
+#  no SBI fault bits set in UBA config reg - must be
+#    some error bits set in UBA status reg
+UBAflt :
+       movl    UST_OFF(r0),r2  #  UBA status reg
+       pushr   $0xf  #  save regs 0-3
+       pushr   r2
+       pushab  UBAmsg
+       calls   $2,_printf
+       popr    $0xf
+       movl    r2,UST_OFF(r0)  #  clear error bits
+       bicl2   $0x80000000,r1  #  clear neg bit in vector
+       bneq    ubanorm  #  branch if normal UBA interrupt to process
+       brb     int_ret         # restore regs and return
+#
+#  zero interrupt vector - print message & continue
+ubapass :
+       pushr   $0xf
+       pushab  ZERmsg
+       calls   $1,_printf
+       popr    $0xf
+       brb     int_ret
+
+
+# Console receiver interrupt
+
+       .align  2
+Xconsrint:
+       pushr   $0x3f           # save registers 0 - 5
+       calls   $0,_consrint
+       brb     int_ret         # merge
+
+
+# Console transmit interrupt
+       .align  2
+Xconsxint:
+       pushr   $0x3f           # save registers 0 - 5
+       calls   $0,_consxint
+       brb     int_ret
+
+
+# Clock interrupt
+       .align  2
+Xclockint:
+       pushr   $0x3f           # save regs 0 - 5
+       pushl   4+6*4(sp)       # push psl
+       pushl   4+6*4(sp)       # push pc
+       calls   $2,_clock
+       brb     int_ret
+
+
+#
+# Common code for interrupts
+# At this point, the interrupt stack looks like:
+#
+#               ___________
+#              |    r0     | :isp
+#              |-----------|
+#              |    ...    |
+#              |-----------|
+#              |    r5     |
+#              |-----------|
+#              |    pc     |
+#              |-----------|
+#              |    psl    |
+#              |___________|
+
+
+int_ret:
+       bbssi   $0,idleflag,int_r0              # set idle escape flag (no wait instr)
+int_r0:
+       popr    $0x3f           # restore regs 0 - 5
+       bitl    $PSL_CURMOD,4(sp)       # interrupt from user mode?
+       beql    int_r1          # no, from kernal, just rei
+       tstb    _runrun         # should we reschedule?
+       beql    int_r1          # no, just rei
+#
+# If here, interrupt from user mode, and time to reschedule.
+#      to do this, we set a software level 3 interrupt to
+#      change to kernal mode, switch stacks,
+#      and format kernal stack for a `qswitch' trap to force
+#      a reschedule.
+#
+       mtpr    $0x18,$IPL      # make sure int won't happen now
+       mtpr    $3,$SIRR        # request level 3 software interrupt
+int_r1:
+       rei                     # return to interrupted process
+
+#
+# Trap and fault vector routines
+#
+
+#      Reschedule trap (Software level 3 interrupt)
+       .align  2
+Xresched:
+       movpsl  -(sp)   # get ps
+       bicl2   $PSL_IPL,(sp)   # lower ipl
+       pushab  resc1           # push pc
+       rei                     # lower ipl, jump to resc1
+
+resc1:
+       pushl   $0                      # dummy code
+       pushl   $RESCHED        # type
+       brb     alltraps        # merge
+
+
+#      privileged instruction fault
+       .align  2
+Xprivinflt:
+       pushl   $0              # push dummy code
+       pushl   $PRIVINFLT      # push type
+       brb     alltraps        # merge
+
+
+
+#      xfc instruction fault
+       .align  2
+Xxfcflt:
+       pushl   $0              # push dummy code value
+       pushl   $XFCFLT         # push type value
+       brb     alltraps        # merge
+
+
+#      reserved operand fault
+       .align  2
+Xresopflt:
+       pushl   $0              # push dummy code value
+       pushl   $RESOPFLT       # push type value
+       brb     alltraps        # merge
+
+
+#      reserved addressing mode fault
+       .align  2
+Xresadflt:
+       pushl   $0              # push dummy code value
+       pushl   $RESADFLT       # push type value
+       brb     alltraps        # merge with common code
+
+
+#      bpt instruction fault
+       .align  2
+Xbptflt:
+       pushl   $0              # push dummy code value
+       pushl   $BPTFLT         # push type value
+       brb     alltraps        # merge with common code
+
+#      Compatibility mode fault
+       .align  2
+Xcompatflt:
+       pushl   $COMPATFLT      # push type value
+       brb     alltraps        #merge with common code
+
+
+#      Trace trap
+
+       .align  2
+Xtracep:
+       pushl   $0              # push dummy code value
+       pushl   $TRCTRAP        # push type value
+       brb     alltraps        # go do it
+
+#      Arithmitic trap
+       .align  2
+Xarithtrap:
+       pushl   $ARITHTRAP      # push type value
+       brb     alltraps        # merge with common code
+
+
+#      Protection  fault
+
+       .align  2
+Xprotflt:
+       blbs    (sp),Xsegflt            # check for pt length violation
+       addl2   $4,sp           # pop fault param word 
+       pushl   $PROTFLT
+       brb     alltraps
+
+#      Segmentation fault
+
+       .align  2
+Xsegflt:
+       addl2   $4,sp
+       pushl   $SEGFLT
+       brb     alltraps
+
+
+
+
+#
+# CHMK trap (syscall trap)
+#      on entry, kernal stack:
+#
+#               ___________ 
+#              |    code   | :ksp
+#              |-----------|
+#              |    pc     |
+#              |-----------|
+#              |    psl    |
+#              |___________|
+#
+#
+#
+#      stack (parameters) at calls to _trap:
+#
+#               ___________ 
+#              |    ap     | :ksp
+#              |-----------|
+#              |    r0     |
+#              |-----------|
+#              |    ...    |
+#              |-----------|
+#              |    r13    |
+#              |-----------|
+#              |    usp    |
+#              |-----------|
+#              |    type   |
+#              |-----------|
+#              |    code   |
+#              |-----------|
+#              |    pc     |
+#              |-----------|
+#              |    psl    |
+#              |___________|
+#
+
+       .align  2
+Xsyscall:
+       pushl   $SYSCALL        # push type value
+alltraps:
+       movq    8(sp),_u+PCB_PC # save pc
+       bitl    $PSL_CURMOD,12(sp)      # from user mode?
+       beql    sysc1           # no
+# Prepare arguments to _trap, note that type has already been pushed
+       mfpr    $USP,-(sp)      # get usp
+       pushr   $0x3fff         # registers 0 - 13
+       pushl   ap              # ptr to syscall parameters
+#
+# Call _trap with wrong number of arguments
+#   so args not popped by ret
+#
+       calls   $1,_trap
+# Restore
+       popr    $0x3fff         # restore regs 0 - 13
+       mtpr    (sp)+,$USP      # restore usp
+       addl2   $8,sp           # pop type, code
+#
+       bitl    $PSL_CURMOD,4(sp)               # are we returning to user mode?
+       beql    sysc2           # no
+# Return
+       rei
+
+sysc1:
+       movab   emsg1,eptr      # set message pointer
+       brb     err_print       # print message and halt
+
+sysc2:
+       movab   emsg2,eptr      # pointer to error message
+       brb     err_print       # print msg and halt
+
+#
+# err_print
+#      print message on console and die
+#      message pointed to by eptr, terminated by zero byte.
+#
+
+err_print:
+       mtpr    $HIGH,$IPL      # disable all interrupts
+       mtpr    $0,$TXCS        # disable interrupts on console transmitter
+eloop1:
+       mfpr    $TXCS,ewk1      # get transmitter status
+       bbc     $TXCS_BRDY,ewk1,eloop1  # loop if not ready to transmit
+       tstb    *eptr           # end of message?
+       beql    eout            # yes, out of loop
+       movzbl  *eptr,ewk1      # get byte of message
+       incl    eptr            # bump pointer
+       mtpr    ewk1,$TXDB      # give byte to transmitter
+       brb     eloop1          # loop
+
+eout:
+       halt
+
+       .data
+eptr:  .long   0
+ewk1:  .long   0
+       .text
+
+
+
+#
+# Initialization
+
+#
+#      IPL == 1F
+#      MAPEN == off
+#      SCBB, PCBB not set
+#      SBR, SLR not set
+#      ISP, KSP not set
+#
+       .globl  start
+start:
+       .word   0x0000
+       mtpr    $HIGH,$IPL              # no interrupts yet
+       mtpr    $Scbbase,$SCBB  # set SCBB
+       mtpr    $_Sysmap,$SBR   # set SBR
+       mtpr    $Syssize,$SLR   # set SLR
+       mtpr    $_Sysmap,$P0BR  # set temp P0BR
+       mtpr    $Syssize,$P0LR  # set temp P0LR
+       movl    $_intstack+2048,sp      # set ISP
+# initialize i/o adatpers
+       movl    $1,PHYSMBA0+4   # init & interrupt enable
+       movl    $4,PHYSMBA0+4   # init & interrupt enable
+       movl    $1,PHYSMBA1+4   # init  interrupt enable
+       movl    $4,PHYSMBA1+4   # init  interrupt enable
+       movl    $1,PHYSUBA+4    # init  interrupt enable
+       movl    $0x78,PHYSUBA+4 # init  interrupt enable
+
+       movl    Scbbase+MCKVEC,r5       # save machine check entry
+       movab   startint+INTSTK,Scbbase+MCKVEC  # set new vector address
+#
+# will now see how much memory there really is
+#      in 64kb chunks, save number of bytes in r7
+#
+       mtpr    $HIGH-1,$IPL    # allow machine check interrupts
+       clrl    r7
+startlp:
+       tstl    (r7)            # this chunk really there?
+       acbl    $8096*1024-1,$64*1024,r7,startlp        # loop till machine check
+       brb     startint        # full load of memory, avoid .align
+       .align  2
+startint:
+       mtpr    $0,$SBIFS               # clear sbi fault status
+       movl    r5,Scbbase+MCKVEC       # restore machine check vector
+       movl    $_intstack+2048,sp      # reset interrupt stack pointer
+
+#      clear memory starting with unitialized data (kernal)
+       movab   _edata,r6
+       movab   _end+8096,r5    # clear uninitialized data and some slop
+strtclr:
+       clrq    (r6)
+       acbl    r5,$8,r6,strtclr
+
+#
+#      initialize system page table
+#
+       movab   _etext+511,r1   # end of kernal text segment
+       bbcc    $31,r1,strt1    # turn off high order bit
+strt1:
+       ashl    $-9,r1,r1       # last page of kernal text
+       clrl    r2              # point at first kernal text page
+strtlp1:
+       bisl3   $PG_V|PG_KR,r2,_Sysmap[r2]      # initialize page table entry
+       aoblss  r1,r2,strtlp1   # fill text entries
+       movab   _end+511,r1     # end of kernal data segment
+       bbcc    $31,r1,strt2    # turn off high order bit
+strt2:
+       ashl    $-9,r1,r1       # last page of kernal data
+strtlp2:
+       bisl3   $PG_V|PG_KW,r2,_Sysmap[r2]      # fill data entries
+       aoblss  r1,r2,strtlp2
+
+#      init i/o space page table entries
+       movl    $PHYSUBA/512,r1         # page frame number for uba
+       movab   _Sysmap+uba_offset,r2   # page table address
+       movab   15(r1),r3       # last pt entry
+strtlp3:
+       bisl3   $PG_V|PG_KW,r1,(r2)+    # init pt entry
+       aobleq  r3,r1,strtlp3
+       movl    $PHYSUMEM/512,r1
+       movab   _Sysmap+umem_offset,r2  # page table address
+       movab   15(r1),r3               # limit
+strtlp4:
+       bisl3   $PG_V|PG_KW,r1,(r2)+
+       aobleq  r3,r1,strtlp4
+       movl    $PHYSMBA0/512,r1
+       movab   _Sysmap+mba0_offset,r2
+       movab   15(r1),r3
+strtlp5:
+       bisl3   $PG_V|PG_KW,r1,(r2)+
+       aobleq  r3,r1,strtlp5
+       movl    $PHYSMBA1/512,r1
+       movab   _Sysmap+mba1_offset,r2
+       movab   15(r1),r3
+strtlp6:
+       bisl3   $PG_V|PG_KW,r1,(r2)+
+       aobleq  r3,r1,strtlp6
+
+       mtpr    $1,$TBIA        # invalidate all trans buffer entries
+       mtpr    $1,$MAPEN       # turn on memory mapping
+       jmp     *$startmap      # put system virtual address in pc
+
+startmap:
+# set maxmem = btoc(r7)
+       ashl    $-9,r7,_maxmem
+       movl    _maxmem,_physmem
+       movl    _maxmem,_freemem
+
+#
+# Setup context for proc[0] == Scheduler
+#
+# address first page past _end
+#      this will be u area for proc[0].
+#      initialize u area page table entries.
+#      initialize (slightly) the pcb.
+
+       movab   _end+511,r6
+       bicl2   $0x1ff,r6       # make page boundary
+
+# set up u area page table
+       bbcc    $31,r6,strt3
+strt3:
+       ashl    $-9,r6,r3               # r3 = btoc(r6)
+       bisl3   $PG_V|PG_KW,r3,_Sysmap+u_ptoffset       # init first u pt entry
+       movab   _u,r1           # point at _u area
+       mtpr    r1,$TBIS
+       movab   usize*512(r1),PCB_KSP(r1)       # init ksp
+       mnegl   $1,PCB_ESP(r1)          # invalidate esp
+       mnegl   $1,PCB_SSP(r1)          # invalidate ssp
+       movl    $0x80000000,PCB_USP(r1)         # set user sp
+       movab   _u+usize*512,PCB_P0BR(r1)       # p0 page table pointer
+       clrl    PCB_P0LR(r1)            # size zero page table
+       movb    $4,PCB_P0LR+3(r1)       # disable ast
+       movab   _u+(usize+1)*512-0x800000,PCB_P1BR(r1)          # p1 page table pointer
+       movl    $0x200000,PCB_P1LR(r1)          # invalid p1 p t length
+       movl    $1,PCB_SZPT(r1)         # init number pages usr page table
+       addl3   $usize,r3,PCB_SZPT+4(r1)        # store into u.u_ptable[0]
+       movl    $1,r2
+strt5:
+       incl    r3
+       bisl3   $PG_V|PG_KW,r3,_Sysmap+u_ptoffset[r2]
+       addl2   $512,r1
+       mtpr    r1,$TBIS
+       aoblss  $usize,r2,strt5
+
+       mtpr    r6,$PCBB                # first pcb
+
+       ldpctx                  # set regs, p0br, p0lr, p1br, p1lr, 
+#                              astlvl, ksp, and change to kernal mode
+       addl2   $8,sp           # pop dummy pc, psl
+       mtpr    $0,$IPL         # enable interrupts
+       movab   _end+511,r0     # calculate firstaddr
+       bbcc    $31,r0,strt4
+strt4:
+       ashl    $-9,r0,-(sp)    # convert to clicks and stack
+       calls   $1,_main        # startup, fork off /etc/init
+#
+# proc[1] == /etc/init now running here.
+# execute code at location 0, in user mode.
+#
+       pushl   $PSL_CURMOD|PSL_PRVMOD  # psl, user mode, ipl= 0
+       pushl   $0              # pc, $location 0
+       rei                     # do /etc/init
+
+
+#
+# Primitives
+#
+
+_display:      .globl  _display
+_savfp:        .globl  _savfp
+_restfp:       .globl  _restfp
+       .word   0x0000
+       ret
+
+_addupc:       .globl  _addupc
+       .word   0x0000
+       movl    8(ap),r2        # &u.u_prof
+       subl3   8(r2),4(ap),r0  # corrected pc
+       blss    addret
+       extzv   $1,$31,r0,r0    # logical right shift
+       extzv   $1,$31,12(r2),r1        # ditto for scale
+       mull2   r1,r0
+       ashl    $-14,r0,r0
+       incl    r0
+       bicb2   $1,r0
+       cmpl    r0,4(r2)        # length
+       bgequ   addret
+       addl2   (r2),r0         # base
+       probew  $3,$2,(r0)
+       beql    adderr
+       addw2   12(ap),(r0)
+addret:
+       ret
+adderr:
+       clrl    12(r2)
+       ret
+
+
+_fubyte:       .globl  _fubyte
+_fuibyte:.globl        _fuibyte
+       .word   0x0000
+       prober  $3,$1,*4(ap)    # byte accessible ?
+       beql    eret                    # no
+       movzbl  *4(ap),r0
+       ret
+
+_subyte:       .globl  _subyte
+_suibyte:.globl        _suibyte
+       .word   0x0000
+       probew  $3,$1,*4(ap)    # byte accessible ?
+       beql    eret                    # no
+       movb    8(ap),*4(ap)
+       clrl    r0
+       ret
+
+_fuword:       .globl  _fuword
+_fuiword:.globl        _fuiword
+       .word   0x0000
+       prober  $3,$4,*4(ap)
+       beql    eret
+       movl    *4(ap),r0
+       ret
+
+_suword:       .globl  _suword
+_suiword:.globl        _suiword
+       .word   0x0000
+       probew  $3,$4,*4(ap)
+       beql    eret
+       movl    8(ap),*4(ap)
+       clrl    r0
+       ret
+eret:
+       mnegl   $1,r0                   # error return
+       ret
+
+_copyin:       .globl  _copyin
+_copyiin:.globl        _copyiin
+       .word   0x0000
+       movl    12(ap),r0       # copy length
+       movl    4(ap),r1        # copy user address
+       cmpl    $512,r0         # probing one page or less ?
+       bgeq    cishort         # yes
+ciloop:
+       prober  $3,$512,(r1)    # bytes accessible ?
+       beql    eret            # no
+       addl2   $512,r1         # incr user address ptr
+       acbl    $513,$-512,r0,ciloop    # reduce count and loop
+cishort:
+       prober  $3,r0,(r1)      # bytes accessible ?
+       beql    eret            # no
+       movc3   12(ap),*4(ap),*8(ap)
+       clrl    r0
+       ret
+
+_copyout: .globl       _copyout
+_copyiout:.globl       _copyiout
+       .word   0x0000
+       movl    12(ap),r0       # get count
+       movl    8(ap),r1        # get user address
+       cmpl    $512,r0         # can do in one probew?
+       bgeq    coshort         # yes
+coloop:
+       probew  $3,$512,(r1)    # bytes accessible?
+       beql    eret            # no 
+       addl2   $512,r1         # increment user address
+       acbl    $513,$-512,r0,coloop    # reduce count and loop
+coshort:
+       probew  $3,r0,(r1)      # bytes accessible?
+       beql    eret            # no
+       movc3   12(ap),*4(ap),*8(ap)
+       clrl    r0
+       ret
+
+_idle: .globl  _idle
+       .word   0x0000
+       mtpr    $0,$IPL         # enable interrupts
+waitloc:       blbc    idleflag,waitloc        # loop until interrupt
+ewaitloc:      bbcci   $0,idleflag,idle1       # clear idle escape flag
+idle1:
+       ret
+       .data
+       .globl  _waitloc
+       .globl  _ewaitloc
+       .align  2
+_waitloc:      .long   waitloc
+_ewaitloc:     .long   ewaitloc
+idleflag:      .long   0
+       .text
+
+
+
+# save reg's and ret loc into save area - return 0
+       .globl  _save
+_save :                # save(save_area)
+       .word   0x0
+       mtpr    $HIGH,$IPL
+       movl    4(ap),r0  #  save area addr
+       movab   2*4(ap),sp  #  restore stack to val before 'save' call
+       movl    8(fp),ap  #  restore ap "       "       "
+       movl    16(fp),r1  #  restore pc        "       "       "
+       movl    12(fp),fp  #  restore fp        "       "       "
+       movq    r6,(r0)+
+       movq    r8,(r0)+
+       movq    r10,(r0)+
+       movq    ap,(r0)+  #  ap & fp
+       movl    sp,(r0)+
+       movl    r1,(r0)+  #  ret loc of call to 'save'
+       movpsl  -(sp)
+       pushl   r1
+       svpctx  # save reg's -> PCB
+       movpsl  -(sp)  # set up for return
+       bicl2   $PSL_IS|PSL_IPL,(sp)  #  undo SVPCTX
+       pushl   r1  #  ret loc
+       clrl    r0  #  return val
+       rei
+#
+#
+#  switch to another process's '_u' area - return val 1
+       .globl  _resume
+_resume :              #  resume(proc_addr,save_addr)
+       .word   0x0
+       mtpr    $HIGH,$IPL  # inhibit interrupts
+       movl    8(ap),retloc
+#  map u-area
+       clrl    r0
+       movab   _u,r1
+       movl    4(ap),r2
+res1:  cvtwl   (r2)[r0],r3     # get u click number from proc
+       bisl3   $PG_V|PG_KW,r3,_Umap[r0]
+       mtpr    r1,$TBIS
+       addl2   $512,r1
+       aoblss  $usize,r0,res1
+#  map user page tables
+       clrl    r0
+       movl    _u+PCB_SZPT,r3
+       jeql    res3            # no user page tables
+res2:  bisl3   $PG_V|PG_KW,_u+PCB_SZPT+4[r0],_Umap+4*usize[r0]
+       mtpr    r1,$TBIS
+       addl2   $512,r1
+       aoblss  r3,r0,res2
+res3:
+       movl    _u,sp           # KSP from u-area
+       ashl    $9,_Umap,r5     # pcb address
+       mtpr    r5,$PCBB
+       ldpctx
+       addl2   $8,sp           # clear ps,pc from stack
+       movl    retloc,r1  #  'ssav' or 'qsav' addr
+       movq    (r1)+,r6
+       movq    (r1)+,r8
+       movq    (r1)+,r10
+       movq    (r1)+,ap
+       movl    (r1)+,sp
+       movl    $1,r0  # return val
+       mtpr    $0,$IPL
+       jmp     *(r1)+  #  return to caller at 'save' address
+#
+       .data
+       .align  2
+retloc:        .space  1*4
+       .text
+
+
+
+
+# disable interrupts
+_spl1: .globl  _spl1
+       .word   0x0000
+       mfpr    $IPL,r0         # get IPL value
+       mtpr    $2,$IPL         # disable RESCHED & AST interrupts
+       ret
+
+_spl4: .globl  _spl4
+       .word   0x0000
+       mfpr    $IPL,r0
+       mtpr    $0x14,$IPL              # disable bus level 4 interrupts
+       ret
+
+_spl5: .globl  _spl5
+       .word   0x0000
+       mfpr    $IPL,r0
+       mtpr    $0x15,$IPL              # disable bus level 5 interrupts
+       ret
+
+_spl6: .globl  _spl6
+_spl7: .globl  _spl7
+       .word   0x0000
+       mfpr    $IPL,r0
+       mtpr    $0x18,$IPL              # disable bus level 7 and clock interrupts
+       ret
+
+# enable interrupts
+_spl0: .globl  _spl0
+       .word   0x0000
+       mfpr    $IPL,r0
+       mtpr    $0,$IPL
+       ret
+
+# restore interrupt state
+_splx: .globl  _splx
+       .word   0x0000
+       mfpr    $IPL,r0
+       mtpr    4(ap),$IPL
+       ret
+
+#
+# Copy 1 relocation unit (512 bytes)
+# from one physical address to another
+_copyseg: .globl       _copyseg
+       .word   0x0000
+       mfpr    $IPL,r0         # get current pri level
+       mtpr    $HIGH,$IPL      # turn off interrupts
+       bisl3   $PG_V|PG_KR,4(ap),_Sysmap+CMAP1
+       bisl3   $PG_V|PG_KW,8(ap),_Sysmap+CMAP2
+       mtpr    $CADDR1,$TBIS   # invalidate entry for copy 
+       mtpr    $CADDR2,$TBIS
+       movc3   $512,CADDR1,CADDR2
+       mtpr    r0,$IPL # restore pri level
+       ret
+
+# zero out physical memory
+# specified in relocation units (512 bytes)
+_clearseg: .globl      _clearseg
+       .word   0x0000
+       mfpr    $IPL,r0         # get current pri level
+       mtpr    $HIGH,$IPL      # extreme pri level
+       bisl3   $PG_V|PG_KW,4(ap),_Sysmap+CMAP1
+       mtpr    $CADDR1,$TBIS
+       movc5   $0,(r0),$0,$512,CADDR1
+       mtpr    r0,$IPL         # restore pri level
+       ret
+
+# Check address
+# given virtual address, byte count, and rw flag
+#  returns 0 on no access
+_useracc:      .globl  _useracc
+       .word   0x0000
+       movl    4(ap),r0                # get va
+       movl    8(ap),r1                # count
+       tstl    12(ap)          # test for read access ?
+       bneq    userar  # yes
+       cmpl    $512,r1 # can we do it in one probe ?
+       bgeq    uaw2            # yes
+uaw1:
+       probew  $3,$512,(r0)
+       beql    uaerr           # no access
+       addl2   $512,r0
+       acbl    $513,$-512,r1,uaw1
+uaw2:
+       probew  $3,r1,(r0)
+       beql    uaerr
+       movl    $1,r0
+       ret
+
+userar:
+       cmpl    $512,r1
+       bgeq    uar2
+uar1:
+       prober  $3,$512,(r0)
+       beql    uaerr
+       addl2   $512,r0
+       acbl    $513,$-512,r1,uar1
+uar2:
+       prober  $3,r1,(r0)
+       beql    uaerr
+       movl    $1,r0
+       ret
+
+uaerr:
+       clrl    r0
+       ret
+
+#      kernacc
+#              check for kernal access privileges
+#      Quiz: Why doesn't probe[rw] work?
+#
+
+       .globl  _kernacc
+_kernacc:
+       .word   0x0000
+
+       movl    4(ap),r0        # virtual address
+       bbcc    $31,r0,kacc1
+       mfpr    $SBR,r2 # address and length of page table (system)
+       mfpr    $SLR,r3
+       brb     kacc2
+kacc1:
+       bbsc    $30,r0,kacc3
+       mfpr    $P0BR,r2        # user P0
+       mfpr    $P0LR,r3
+       brb     kacc2
+kacc3:
+       mfpr    $P1BR,r2        # user P1 (stack)
+       mfpr    $P1LR,r3
+kacc2:
+       addl3   8(ap),r0,r1     # ending virtual address
+       ashl    $-9,r0,r0       # page number
+       ashl    $-9,r1,r1
+       bbc     $30,4(ap),kacc6
+       cmpl    r0,r3           # user stack
+       blss    kacerr          # address too low
+       brb     kacc4
+kacc6: cmpl    r1,r3           # compare last page to P0LR or SLR
+       bgeq    kacerr          # address too high
+kacc4: 
+       movl    (r2)[r0],r1
+       bbc     $31,r1,kacerr   # valid bit is off
+       cmpzv   $27,$4,r1,$1    # check protection code
+       bleq    kacerr          # no access allowed
+       tstb    12(ap)
+       bneq    kacc5           # only check read access
+       cmpzv   $27,$2,r1,$3    # check low 2 bits of prot code
+       beql    kacerr          # no write access
+kacc5:
+       aobleq  r1,r0,kacc4     # next page
+       movl    $1,r0           # no errors
+       ret
+kacerr:
+       clrl    r0              # error
+       ret
+
+#
+#  unsigned int divide :
+#              (int) i = udiv( (int)dvdnd , (int) divis)
+#
+#  unsigned int remainder :
+#              (int) j = urem( (int)dvdnd , (int) divis)
+#
+       .text
+       .align  1
+       .globl  _udiv
+       .globl  _urem
+#
+_udiv :
+       .word   0  #  no reg save
+       movl    4(ap),r0  #  dividend
+       clrl    r1
+       ediv    8(ap),r0,r0,r1  #  quotient in r0
+       ret
+#
+       .align  1
+_urem :
+       .word   0
+       movl    4(ap),r0
+       clrl    r1
+       ediv    8(ap),r0,r1,r0  #  remainder in r0
+       ret
+
+# define user area virtual address
+       .set    physpages,1024
+       .set    kernsize,256     # number of page table entries allocated to kernal
+       .globl  _u
+       .set    usize,4         # size of user area, in pages
+       .set    _u,0x80000000 + kernsize*512
+       .globl  _mbautl
+       .set    _mbautl,_u+128*512
+       .globl  _swaputl
+       .set    _swaputl,_mbautl+16*512
+       .globl  _swap2utl
+       .set    _swap2utl,_swaputl+16*512
+       .globl  _forkutl
+       .set    _forkutl,_swap2utl+16*512
+       .globl  _xswaputl
+       .set    _xswaputl,_forkutl+16*512
+       .globl  _xallutl
+       .set    _xallutl,_xswaputl+16*512
+       .globl  _xccdutl
+       .set    _xccdutl,_xallutl+16*512
+       .globl  _xswap2utl
+       .set    _xswap2utl,_xccdutl+16*512
+       .set    u_ptoffset,256*4        # offset into _Sysmap of ptentries of _u
+       .set    CMAP1,u_ptoffset+16*4   # offset into _sysmap of 1st seg copy entry
+       .set    CMAP2,CMAP1+4   # ditto 2ed entry
+       .set    CADDR1,_u+16*512        # virtual address of 1st copy segment
+       .set    CADDR2,CADDR1+512       # ditto second segment
+       .set    PHYSUBA,0x20006000      # real address of uba
+       .set    PHYSMBA0,0x20010000     # real addr of mba 0
+       .set    PHYSMBA1,0x20012000     # real addre of mba1
+       .set    PHYSUMEM,0x2013e000             # real address of unibus memory
+       .set    uba_offset,u_ptoffset+32*4      # offset in Sysmap of uba entries
+       .set    umem_offset,uba_offset+16*4     # ... unibus device registers
+       .set    mba0_offset,umem_offset+16*4    # ... massbus 0
+       .set    mba1_offset,mba0_offset+16*4    # ... massbus 1
+       .set    mba2_offset,mba1_offset+16*4    # ... massbus 2
+       .set    mba3_offset,mba2_offset+16*4    # ... massbus 3
+
+
+
+#
+# Error messages
+#
+       .data
+
+emsg1:
+       .byte   0xa,0xa,0xa,0xd,0x54,0x52,0x41,0x50,0x20
+       .byte   0x46,0x52,0x4f,0x4d,0x20
+       .byte   0x4b,0x45,0x52,0x4e,0x41,0x4c,0x20
+       .byte   0x4d,0x4f,0x44,0x45,0xa,0xa,0xd,0x0
+
+emsg2:
+       .byte   0xa,0xa,0xa,0xd,0x54,0x52,0x41,0x50,0x20
+       .byte   0x52,0x45,0x54,0x55,0x52,0x4e,0x20
+       .byte   0x44,0x4f,0x20
+       .byte   0x4b,0x45,0x52,0x4e,0x41,0x4c,0x20
+       .byte   0x4d,0x4f,0x44,0x45,0xa,0xa,0xd,0x0
+
+SBImsg :
+       .byte   'S,'B,'I,' ,'f,'a,'u,'l,'t,' ,012,0
+UBAmsg :
+       .byte   'U,'B,'A,' ,'e,'r,'r,'o,'r,' ,'%,'x,012,0
+ZERmsg :
+       .byte   'Z,'e,'r,'o,' ,'V,'e,'c,'t,'o,'r,012,0
+#
+#      _Sysmap:
+#              system page table
+#
+#      structure:
+#              2 pages of page table entries
+#                      reserved for kernal text and data.
+#              additional page table entries
+#                      used in mapping the u area (16 entries),
+#                      utility entries (16 entries),
+#                      unibus adapter (16 entries),
+#                      unibus device memory (16 entries),
+#                      massbus adapter 0 (16 entries),
+#                      massbus adapter 1 (16 entries),
+#                      massbus adapter 2 (16 entries),
+#                      massbus adapter 3 (16 entries).
+#                      used for phys & swap I/O
+#
+#
+
+       .align  2
+       .globl  _Sysmap
+       .globl  _Umap
+       .globl  _Tempmap
+       .globl  _Mbamap
+       .globl  _Swapmap
+       .globl  _Swap2map
+       .globl  _Forkmap
+       .globl  _Xswapmap
+       .globl  _Xallmap
+       .globl  _Xccdmap
+       .globl  _Xswap2map
+_Sysmap:
+       .space  2*128*4         # 2 pages of page table entries for kernal
+_Umap:
+       .space  16*4            # u-area
+_Tempmap:
+       .space  16*4*7          # utility area & others
+_Mbamap:
+       .space  16*4            # map for phys & swap I/O
+_Swapmap:
+       .space  16*4            # swap utility area
+_Swap2map:
+       .space  16*4            # second swap area
+_Forkmap:
+       .space  16*4            # fork area
+_Xswapmap:
+       .space  16*4            # xswap area
+_Xallmap:
+       .space  16*4            # xalloc area
+_Xccdmap:
+       .space  16*4            # xccdec area
+_Xswap2map:
+       .space  16*4            # xswap2 area
+       .set    Syssize,4*128           # number pt entries in sys page table
+       .globl  _mmap
+       .set    _mmap,_Sysmap+CMAP2+4
+       .globl  _vmmap
+       .set    _vmmap,CADDR2+512
diff --git a/usr/src/sys/sys/m.1 b/usr/src/sys/sys/m.1
new file mode 100644 (file)
index 0000000..9c9e2dc
--- /dev/null
@@ -0,0 +1,62 @@
+cat ../h/mtpr.m ../h/trap.m ../h/psl.m ../h/pcb.m ../h/clock.m  ../h/cons.m ../h/page.m ../h/mba.m ../h/uba.m locore.s | as -o locore.o
+cc -O -c acct.c
+cc -O -c alloc.c
+cc -O -c bio.c
+cc -O -c clock.c
+cc -O -c conf.c
+cc -O -c cons.c
+cc -O -c dkleave.c
+cc -O -c dsort.c
+cc -c -S dz.c
+/lib/c2 -i dz.s dz.os
+as -o dz.o dz.os
+rm dz.s dz.os
+cc -O -c fio.c
+cc -c -S hp.c
+/lib/c2 -i hp.s hp.os
+as -o hp.o hp.os
+rm hp.s hp.os
+cc -c -S ht.c
+/lib/c2 -i ht.s ht.os
+as -o ht.o ht.os
+rm ht.s ht.os
+cc -O -c iget.c
+cc -O -c machdep.c
+cc -O -c main.c
+cc -O -c malloc.c
+cc -c -S mba.c
+/lib/c2 -i mba.s mba.os
+as -o mba.o mba.os
+rm mba.s mba.os
+cc -O -c mem.c
+cc -O -c mx1.c
+cc -O -c mx2.c
+cc -O -c nami.c
+cc -O -c partab.c
+cc -O -c pipe.c
+cc -O -c prf.c
+cc -O -c prim.c
+cc -O -c rdwri.c
+cc -O -c sig.c
+cc -O -c slp.c
+cc -O -c subr.c
+cc -O -c sys.c
+cc -O -c sys1.c
+cc -O -c sys2.c
+cc -O -c sys3.c
+cc -O -c sys4.c
+cc -O -c sysent.c
+cc -c -S tdump.c
+/lib/c2 -i tdump.s tdump.os
+as -o tdump.o tdump.os
+rm tdump.s tdump.os
+cc -O -c text.c
+cc -O -c trap.c
+cc -O -c tty.c
+cc -c -S uba.c
+/lib/c2 -i uba.s uba.os
+as -o uba.o uba.os
+rm uba.s uba.os
+cc -O -c univec.c
+sh loadall
+-rwxrwxrwx 1 tbl     57376 Mar  7 10:22 unix
diff --git a/usr/src/sys/sys/m.2 b/usr/src/sys/sys/m.2
new file mode 100644 (file)
index 0000000..e4b713f
--- /dev/null
@@ -0,0 +1 @@
+"dz.c", line 74: warning: illegal pointer combination
diff --git a/usr/src/sys/sys/machdep.c b/usr/src/sys/sys/machdep.c
new file mode 100644 (file)
index 0000000..033dbc9
--- /dev/null
@@ -0,0 +1,338 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/acct.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/inode.h"
+#include "../h/proc.h"
+#include "../h/seg.h"
+#include "../h/uba.h"
+#include "../h/map.h"
+#include "../h/reg.h"
+#include "../h/mtpr.h"
+#include "../h/clock.h"
+#include "../h/page.h"
+
+long   icode[] =
+{
+       0x9f19af9f,     /* pushab [&"init",0]; pushab */
+       0x02dd09af,     /* "/etc/init"; pushl $2 */
+       0xbc5c5ed0,     /* movl sp,ap; chmk */
+       0x2ffe110b,     /* $exec; brb .; "/ */
+       0x2f637465,     /* etc/ */
+       0x74696e69,     /* init */
+       0x00000000,     /* ";  0 */
+       0x00000014,     /* [&"init", */
+       0x00000000,     /* 0] */
+};
+int    szicode = sizeof(icode);
+/*
+ * Machine-dependent startup code
+ */
+startup(firstaddr)
+{
+       int unixsize;
+
+       /*
+        * Initialize maps
+        */
+
+       printf("RESTRICTED RIGHTS\n");
+       printf("USE, DUPLICATION OR DISCLOSURE IS\n");
+       printf("SUBJECT TO RESTRICTION STATED IN YOUR\n");
+       printf("CONTRACT WITH WESTERN ELECTRIC COMPANY INC.\n\n");
+       printf("real mem  = %d\n", maxmem*ctob(1) );
+       if (maxmem > PHYSPAGES) {       /* more pages than allocated in bit map */
+               printf("Warning: more page-frames than allocated in bit map\n");
+               printf("   Only %d of %d used. (Increase PHYSPAGES)\n",
+                               PHYSPAGES,maxmem);
+               maxmem = PHYSPAGES;
+       }
+       unixsize = (firstaddr+USIZE);
+       meminit(unixsize, maxmem);
+       maxmem -= unixsize + 1;
+       printf("avail mem = %d\n", maxmem*ctob(1));
+       if(MAXMEM < maxmem)
+               maxmem = MAXMEM;
+       mfree(swapmap, nswap, 1);
+       swplo--;
+       mbainit();              /* setup mba mapping regs map */
+       ubainit();              /* setup uba mapping regs map */
+}
+
+/*
+ * set up a physical address
+ * into users virtual address space.
+ */
+sysphys()
+{
+       register i, s, d;
+
+       if(!suser())
+               return;
+       u.u_error = EINVAL;
+}
+
+/*
+ * Start clock
+ */
+clkstart()
+{
+       mtpr(NICR, -16667);     /* 16.667 milli-seconds */
+       mtpr(ICCS,ICCS_RUN+ICCS_IE+ICCS_TRANS+ICCS_INT+ICCS_ERR);
+}
+
+clkreld()
+{
+       mtpr(ICCS, ICCS_RUN + ICCS_IE + ICCS_INT + ICCS_ERR);
+}
+
+
+/*
+ * Send an interrupt to process
+ */
+sendsig(p, n)
+{
+       register int *usp, *regs;
+       register int mask, r, spa, t;
+       int *s;
+
+       regs = u.u_ar0;
+       usp = (int *)regs[SP];
+       grow((unsigned)(usp-20));
+       mask = (fuword(p) & 0xfff) | 0x3f; /* get register save mask (save r0-r5) */
+       suword( (caddr_t) --usp, n);    /* sig # as param */
+       suword( (caddr_t) --usp, 1);    /* one parameters */
+       s = usp;
+       spa = ((int) usp) & 0x3;
+       if (spa) usp = (int *)((int) (usp - 1) & ~ 0x3);
+       t = 11;
+       for (r=0x800; r; r>>=1)
+               {
+               if (mask & r) suword((caddr_t) --usp, regs[t]);
+               t--;
+               }
+       suword( (caddr_t) --usp, regs[PC]);
+       suword( (caddr_t) --usp, regs[FP]);
+       suword( (caddr_t) --usp, regs[AP]);
+       suword( (caddr_t) --usp, (spa << 30) | (0x2 << 28)
+                               | (mask << 16) | (regs[PS] & 0xfff1));
+       suword( (caddr_t) --usp, 0);
+
+       regs[SP] = (int)usp;
+       regs[FP] = (int)usp;
+       regs[AP] = (int)s;
+       regs[PC] = p + 2;
+       regs[PS] &= ~ 0x1f;
+}
+
+mtpr(regno, value)
+{
+       asm("   mtpr    8(ap),4(ap)");
+}
+
+mfpr(regno)
+{
+       asm("   mfpr    4(ap),r0");
+}
+
+/*
+ * Copy bytes within kernel
+ */
+bcopy(from,to,count)
+{
+       asm("   movc3   12(ap),*4(ap),*8(ap)");
+}
+
+/*
+ * create a duplicate copy of a process
+ */
+procdup(p)
+register struct proc *p;
+{
+       extern int forkutl[], Forkmap[];
+       register int i, *ip, *jp, *kp;
+
+       if (memall(Forkmap,USIZE) == 0)
+               return(NULL);   /* no memory available */
+
+       /* make u-area and page tables addressible */
+       for( i=USIZE; --i>=0; ) {
+               Forkmap[i] |= PG_V + PG_KW;
+               mtpr(TBIS, forkutl + 128*i);
+       }
+
+       if (u.u_dsize)
+               if (memall(&forkutl[UPAGES*128+u.u_tsize],u.u_dsize) == 0) {
+                       memfree(Forkmap,USIZE);
+                       return(NULL);
+               }
+       if (u.u_ssize)
+               if (memall(&forkutl[USIZE*128-u.u_ssize],u.u_ssize) == 0)  {
+                       memfree(&forkutl[UPAGES*128+u.u_tsize],u.u_dsize);
+                       memfree(Forkmap,USIZE);
+                       return(NULL);
+               }
+
+       /* copy the u-area */
+       bcopy(&u, forkutl, ctob(UPAGES));
+
+       /* copy the data segment */
+       ip = ((int *)&u) + UPAGES*128 + u.u_tsize;
+       jp = ip + u.u_dsize;
+       kp = forkutl + UPAGES*128 + u.u_tsize;
+       while(ip < jp) {
+               copyseg(*ip++&PG_PFNUM, *kp);
+               *kp++ |= PG_V + PG_UW;
+       }
+
+       /* copy stack segment */
+       jp = ((int *)&u) + USIZE*128;
+       ip = jp - u.u_ssize;
+       kp = forkutl + USIZE*128 - u.u_ssize;
+       while(ip < jp) {
+               copyseg(*ip++&PG_PFNUM, *kp);
+               *kp++ |= PG_V + PG_UW;
+       }
+
+       /* copy text page table entries */
+       bcopy( ((int *)&u) + UPAGES*128, forkutl + UPAGES*128, 
+               sizeof(struct pt_entry)*u.u_tsize);
+
+       /* clear unused page taple entries */
+       ip = forkutl + UPAGES*128 + u.u_tsize + u.u_dsize;
+       jp = forkutl + USIZE*128 - u.u_ssize;
+       while(ip < jp) 
+               *ip++ = 0;
+
+       /* store page numbers of new page table in new u-area */
+       for(i=u.u_pcb.pcb_szpt; --i>=0; )
+               ((struct user *)forkutl)->u_ptable[i] = (Forkmap+UPAGES)[i]
+                               & PG_PFNUM;
+
+       /* store page numbers of new u-area in proc */
+       for(i=UPAGES; --i>=0; )
+               p->p_addr[i] = Forkmap[i];
+       return(1);
+}
+
+
+/*
+ * change protection codes of a cegment
+ */
+chgprot(text,data,stack)
+{
+       register  int   *ptaddr,i;
+
+       if (text || data) {
+               ptaddr = (int *)mfpr(P0BR);
+               if (text)
+                       for(i=0; i<u.u_tsize; i++) {
+                               ptaddr[i] &= ~PG_PROT;  /* clear prot bits */
+                               ptaddr[i] |= text + PG_V;
+                       }
+               if (data)
+                       for(i=u.u_tsize; i<u.u_tsize+u.u_dsize; i++) {
+                               ptaddr[i] &= ~PG_PROT;  /* clear prot bits */
+                               ptaddr[i] |= data + PG_V;
+                       }
+               }
+       if (stack) {
+               ptaddr = (int *)(mfpr(P1BR) + 4 * mfpr(P1LR));
+               for(i=0; i<u.u_ssize; i++) {
+                       ptaddr[i] &= ~PG_PROT;  /* clear prot bits */
+                       ptaddr[i] |= stack + PG_V;
+               }
+       }
+}
+
+/*
+ * check that a process will not be too large 
+ */
+chksize(text,data,stack)
+{
+       if ( (text + data + stack) > MAXUMEM
+               || text + data + stack + UPAGES + MAXUMEM/128 > maxmem) {
+               u.u_error = ENOMEM;
+               return(-1);
+       }
+       return(0);
+}
+
+
+/*
+ * expand a page table
+ */
+ptexpand(change)
+register int change;
+{
+       register int  *p1, *p2, i, movept;
+       int  newpt[MAXUMEM/128];
+       extern  int  Umap[];
+
+       if (change <= 0)
+               return(change);
+       if (change > MAXUMEM/128 || memall(newpt,change) == 0)
+               return(-1);
+
+       /* calculate where stack entries start */
+       movept = (0x200000 - mfpr(P1LR))/128;
+
+       /* copy the stack page table pages down */
+       for(i=0; i<movept; i++) {
+               Umap[USIZE+change-1-i] = Umap[USIZE-1-i];
+               mtpr(TBIS, ((int)&u) + 512*(USIZE+change-1-i));
+       }
+
+       /* insert and clear new pages */
+       for(i=0; i<change; i++) {
+               Umap[USIZE-movept+i] = newpt[i] | (PG_V+PG_KW);
+               mtpr(TBIS,((int)&u) + 512*(USIZE-movept+i));
+               clearseg(newpt[i]);
+       }
+
+       /* copy any stack entries to new page, then clear entry */
+       p1 = (int *)mfpr(P1BR);
+       p1 += mfpr(P1LR);
+       p2 = p1 + 128*change;
+       while ((int)p1 & 0x1ff) {
+               *p2++ = *p1;
+               *p1++ = 0;
+       }
+
+       /* fixup page table numbers in u-area */
+       for(i=u.u_pcb.pcb_szpt+change; --i>=0; )
+               u.u_ptable[i] = (Umap+UPAGES)[i] & PG_PFNUM;
+       u.u_pcb.pcb_szpt += change;     /* new number of page tables */
+       u.u_pcb.pcb_p1br = mfpr(P1BR) + 512*change;
+       mtpr(P1BR, u.u_pcb.pcb_p1br);
+       mtpr(TBIA,1);
+       return(change);
+}
+
+/*
+ * make some u-area and allied page tables
+ * addressible;
+ */
+
+ptaccess(p, map, addr)
+register struct proc *p;
+register int map[], addr[];
+{
+       register int i;
+
+       /* make u-area addressible */
+       for(i=UPAGES; --i>=0; ) {
+               map[i] = p->p_addr[i] | (PG_V+PG_KW);
+               mtpr(TBIS, addr + 128*i);
+       }
+
+       /* make page tables addressible */
+       for(i=((struct user *)addr)->u_pcb.pcb_szpt; --i>=0; ) {
+               (map+UPAGES)[i] = ((struct user *)addr)->u_ptable[i]
+                               | (PG_V+PG_KW);
+               mtpr(TBIS, addr + 128*(i+UPAGES));
+       }
+}
diff --git a/usr/src/sys/sys/main.c b/usr/src/sys/sys/main.c
new file mode 100644 (file)
index 0000000..27a9ee8
--- /dev/null
@@ -0,0 +1,169 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/filsys.h"
+#include "../h/mount.h"
+#include "../h/uba.h"
+#include "../h/map.h"
+#include "../h/proc.h"
+#include "../h/inode.h"
+#include "../h/seg.h"
+#include "../h/conf.h"
+#include "../h/buf.h"
+#include "../h/mtpr.h"
+#include "../h/page.h"
+# include "../h/clock.h"
+
+
+/*
+ * Initialization code.
+ * Called from cold start routine as
+ * soon as a stack and segmentation
+ * have been established.
+ * Functions:
+ *     clear and free user core
+ *     turn on clock
+ *     hand craft 0th process
+ *     call all initialization routines
+ *     fork - process 0 to schedule
+ *          - process 1 execute bootstrap
+ *
+ * loop at loc 13 (0xd) in user mode -- /etc/init
+ *     cannot be executed.
+ */
+main(firstaddr)
+{
+       int i;
+
+       startup(firstaddr);
+
+       /*
+        * set up system process
+        */
+
+       for(i=0; i<UPAGES; i++) {
+               proc[0].p_addr[i] = firstaddr + i;
+       }
+       proc[0].p_size = UPAGES;
+       proc[0].p_stat = SRUN;
+       proc[0].p_flag |= SLOAD|SSYS;
+       proc[0].p_nice = NZERO;
+       u.u_procp = &proc[0];
+       u.u_cmask = CMASK;
+       clkstart();
+
+       /*
+        * Initialize devices and
+        * set up 'known' i-nodes
+        */
+
+       cinit();
+       binit();
+       iinit();
+       rootdir = iget(rootdev, (ino_t)ROOTINO);
+       rootdir->i_flag &= ~ILOCK;
+       u.u_cdir = iget(rootdev, (ino_t)ROOTINO);
+       u.u_cdir->i_flag &= ~ILOCK;
+       u.u_rdir = NULL;
+
+       /*
+        * make init process
+        * enter scheduling loop
+        * with system process
+        */
+
+       if(newproc()) {
+               expand(btoc(szicode), P0BR);
+               u.u_dsize = btoc(szicode);
+               copyout((caddr_t)icode, (caddr_t)0, szicode);
+               /*
+                * Return goes to loc. 0 of user init
+                * code just copied out.
+                */
+               return;
+       }
+       sched();
+}
+
+/*
+ * iinit is called once (from main)
+ * very early in initialization.
+ * It reads the root's super block
+ * and initializes the current date
+ * from the last modified date.
+ *
+ * panic: iinit -- cannot read the super
+ * block. Usually because of an IO error.
+ */
+iinit()
+{
+       register struct buf *cp, *bp;
+       register struct filsys *fp;
+       register unsigned i , j ;
+
+       (*bdevsw[major(rootdev)].d_open)(rootdev, 1);
+       bp = bread(rootdev, SUPERB);
+       cp = geteblk();
+       if(u.u_error)
+               panic("iinit");
+       bcopy(bp->b_un.b_addr, cp->b_un.b_addr, sizeof(struct filsys));
+       brelse(bp);
+       mount[0].m_bufp = cp;
+       mount[0].m_dev = rootdev;
+       fp = cp->b_un.b_filsys;
+       fp->s_flock = 0;
+       fp->s_ilock = 0;
+       fp->s_ronly = 0;
+       /* on boot, read VAX TODR register (GMT 10 ms.
+       *       clicks into current year) and set software time
+       *       in 'int time' (GMT seconds since year YRREF)
+       */
+       for (i = 0 , j = YRREF ; j < YRCURR ; j++)
+               i += (SECYR + (j%4?0:SECDAY)) ;
+       time = udiv(mfpr(TODR),100) + i ;
+}
+
+/*
+ * This is the set of buffers proper, whose heads
+ * were declared in buf.h.  There can exist buffer
+ * headers not pointing here that are used purely
+ * as arguments to the I/O routines to describe
+ * I/O to be done-- e.g. swbuf for
+ * swapping.
+ */
+char   buffers[NBUF][BSIZE+BSLOP];
+
+/*
+ * Initialize the buffer I/O system by freeing
+ * all buffers and setting all device buffer lists to empty.
+ */
+binit()
+{
+       register struct buf *bp;
+       register struct buf *dp;
+       register int i;
+       struct bdevsw *bdp;
+
+       bfreelist.b_forw = bfreelist.b_back =
+           bfreelist.av_forw = bfreelist.av_back = &bfreelist;
+       for (i=0; i<NBUF; i++) {
+               bp = &buf[i];
+               bp->b_dev = NODEV;
+               bp->b_un.b_addr = buffers[i];
+               bp->b_back = &bfreelist;
+               bp->b_forw = bfreelist.b_forw;
+               bfreelist.b_forw->b_back = bp;
+               bfreelist.b_forw = bp;
+               bp->b_flags = B_BUSY;
+               brelse(bp);
+       }
+       for (bdp = bdevsw; bdp->d_open; bdp++) {
+               dp = bdp->d_tab;
+               if(dp) {
+                       dp->b_forw = dp;
+                       dp->b_back = dp;
+               }
+               nblkdev++;
+       }
+}
diff --git a/usr/src/sys/sys/makefile b/usr/src/sys/sys/makefile
new file mode 100644 (file)
index 0000000..dcb27e2
--- /dev/null
@@ -0,0 +1,402 @@
+CFLAGS=-O
+AHEADS = ../h/mtpr.m ../h/trap.m ../h/psl.m ../h/pcb.m ../h/clock.m \
+               ../h/cons.m ../h/page.m ../h/mba.m ../h/uba.m
+FILES=\
+locore.o \
+acct.o \
+alloc.o \
+bio.o \
+clock.o \
+conf.o \
+cons.o \
+dkleave.o \
+dsort.o \
+dz.o \
+fio.o \
+hp.o \
+ht.o \
+iget.o \
+machdep.o \
+main.o \
+malloc.o \
+mba.o \
+mem.o \
+mx1.o \
+mx2.o \
+nami.o \
+partab.o \
+pipe.o \
+prf.o \
+prim.o \
+rdwri.o \
+sig.o \
+slp.o \
+subr.o \
+sys.o \
+sys1.o \
+sys2.o \
+sys3.o \
+sys4.o \
+sysent.o \
+tdump.o \
+text.o \
+trap.o \
+tty.o \
+uba.o \
+univec.o 
+
+
+unix: $(FILES)
+       sh loadall
+
+
+dz.o hp.o ht.o mba.o tdump.o uba.o :
+       cc -c -S $*.c
+       /lib/c2 -i $*.s $*.os
+       as -o $*.o $*.os
+       rm $*.s $*.os
+
+locore.o: $(AHEADS)
+       cat $(AHEADS) locore.s | as -o locore.o
+
+
+acct.o: ../h/param.h
+acct.o: ../h/systm.h
+acct.o: ../h/acct.h
+acct.o: ../h/dir.h
+acct.o: ../h/user.h
+acct.o: ../h/inode.h
+acct.o: ../h/proc.h
+acct.o: ../h/seg.h
+alloc.o: ../h/param.h
+alloc.o: ../h/systm.h
+alloc.o: ../h/mount.h
+alloc.o: ../h/filsys.h
+alloc.o: ../h/fblk.h
+alloc.o: ../h/conf.h
+alloc.o: ../h/buf.h
+alloc.o: ../h/inode.h
+alloc.o: ../h/ino.h
+alloc.o: ../h/dir.h
+alloc.o: ../h/user.h
+bio.o: ../h/param.h
+bio.o: ../h/systm.h
+bio.o: ../h/dir.h
+bio.o: ../h/user.h
+bio.o: ../h/buf.h
+bio.o: ../h/conf.h
+bio.o: ../h/proc.h
+bio.o: ../h/seg.h
+clock.o: ../h/param.h
+clock.o: ../h/systm.h
+clock.o: ../h/callo.h
+clock.o: ../h/seg.h
+clock.o: ../h/dir.h
+clock.o: ../h/user.h
+clock.o: ../h/proc.h
+clock.o: ../h/reg.h
+clock.o: ../h/psl.h
+conf.o: ../h/param.h
+conf.o: ../h/systm.h
+conf.o: ../h/buf.h
+conf.o: ../h/tty.h
+conf.o: ../h/conf.h
+conf.o: ../h/proc.h
+conf.o: ../h/text.h
+conf.o: ../h/dir.h
+conf.o: ../h/user.h
+conf.o: ../h/file.h
+conf.o: ../h/inode.h
+conf.o: ../h/acct.h
+conf.o: ../h/mba.h
+cons.o: ../h/param.h
+cons.o: ../h/conf.h
+cons.o: ../h/dir.h
+cons.o: ../h/user.h
+cons.o: ../h/tty.h
+cons.o: ../h/systm.h
+cons.o: ../h/cons.h
+cons.o: ../h/mtpr.h
+dkleave.o: ../h/param.h
+dkleave.o: ../h/buf.h
+dsort.o: ../h/param.h
+dsort.o: ../h/systm.h
+dsort.o: ../h/buf.h
+dz.o: ../h/param.h
+dz.o: ../h/tty.h
+dz.o: ../h/uba.h
+dz.o: ../h/proc.h
+dz.o: ../h/dir.h
+dz.o: ../h/file.h
+dz.o: ../h/inode.h
+dz.o: ../h/user.h
+dz.o: ../h/conf.h
+fio.o: ../h/param.h
+fio.o: ../h/systm.h
+fio.o: ../h/dir.h
+fio.o: ../h/user.h
+fio.o: ../h/filsys.h
+fio.o: ../h/file.h
+fio.o: ../h/conf.h
+fio.o: ../h/inode.h
+fio.o: ../h/reg.h
+fio.o: ../h/acct.h
+hp.o: ../h/param.h
+hp.o: ../h/uba.h
+hp.o: ../h/systm.h
+hp.o: ../h/buf.h
+hp.o: ../h/conf.h
+hp.o: ../h/dir.h
+hp.o: ../h/user.h
+hp.o: ../h/map.h
+hp.o: ../h/mba.h
+ht.o: ../h/param.h
+ht.o: ../h/systm.h
+ht.o: ../h/buf.h
+ht.o: ../h/conf.h
+ht.o: ../h/dir.h
+ht.o: ../h/file.h
+ht.o: ../h/user.h
+ht.o: ../h/uba.h
+ht.o: ../h/map.h
+ht.o: ../h/mba.h
+iget.o: ../h/param.h
+iget.o: ../h/systm.h
+iget.o: ../h/mount.h
+iget.o: ../h/dir.h
+iget.o: ../h/user.h
+iget.o: ../h/inode.h
+iget.o: ../h/ino.h
+iget.o: ../h/filsys.h
+iget.o: ../h/conf.h
+iget.o: ../h/buf.h
+machdep.o: ../h/param.h
+machdep.o: ../h/systm.h
+machdep.o: ../h/acct.h
+machdep.o: ../h/dir.h
+machdep.o: ../h/user.h
+machdep.o: ../h/inode.h
+machdep.o: ../h/proc.h
+machdep.o: ../h/seg.h
+machdep.o: ../h/uba.h
+machdep.o: ../h/map.h
+machdep.o: ../h/reg.h
+machdep.o: ../h/mtpr.h
+machdep.o: ../h/clock.h
+machdep.o: ../h/page.h
+main.o: ../h/param.h
+main.o: ../h/systm.h
+main.o: ../h/dir.h
+main.o: ../h/user.h
+main.o: ../h/filsys.h
+main.o: ../h/mount.h
+main.o: ../h/uba.h
+main.o: ../h/map.h
+main.o: ../h/proc.h
+main.o: ../h/inode.h
+main.o: ../h/seg.h
+main.o: ../h/conf.h
+main.o: ../h/buf.h
+main.o: ../h/mtpr.h
+main.o: ../h/page.h
+main.o: ../h/clock.h
+malloc.o: ../h/param.h
+malloc.o: ../h/systm.h
+malloc.o: ../h/uba.h
+malloc.o: ../h/map.h
+malloc.o: ../h/page.h
+malloc.o: ../h/mem.h
+mba.o: ../h/param.h
+mba.o: ../h/buf.h
+mba.o: ../h/conf.h
+mba.o: ../h/systm.h
+mba.o: ../h/dir.h
+mba.o: ../h/user.h
+mba.o: ../h/proc.h
+mba.o: ../h/seg.h
+mba.o: ../h/page.h
+mba.o: ../h/uba.h
+mba.o: ../h/map.h
+mba.o: ../h/mba.h
+mba.o: ../h/mtpr.h
+mem.o: ../h/param.h
+mem.o: ../h/dir.h
+mem.o: ../h/user.h
+mem.o: ../h/conf.h
+mem.o: ../h/buf.h
+mem.o: ../h/systm.h
+mem.o: ../h/page.h
+mem.o: ../h/mtpr.h
+mx1.o: ../h/param.h
+mx1.o: ../h/systm.h
+mx1.o: ../h/dir.h
+mx1.o: ../h/user.h
+mx1.o: ../h/reg.h
+mx1.o: ../h/proc.h
+mx1.o: ../h/tty.h
+mx1.o: ../h/inode.h
+mx1.o: ../h/mx.h
+mx1.o: ../h/file.h
+mx1.o: ../h/conf.h
+mx2.o: ../h/param.h
+mx2.o: ../h/systm.h
+mx2.o: ../h/dir.h
+mx2.o: ../h/user.h
+mx2.o: ../h/proc.h
+mx2.o: ../h/tty.h
+mx2.o: ../h/inode.h
+mx2.o: ../h/mx.h
+mx2.o: ../h/file.h
+mx2.o: ../h/conf.h
+mx2.o: ../h/buf.h
+nami.o: ../h/param.h
+nami.o: ../h/systm.h
+nami.o: ../h/inode.h
+nami.o: ../h/mount.h
+nami.o: ../h/dir.h
+nami.o: ../h/user.h
+nami.o: ../h/buf.h
+pipe.o: ../h/param.h
+pipe.o: ../h/systm.h
+pipe.o: ../h/dir.h
+pipe.o: ../h/user.h
+pipe.o: ../h/inode.h
+pipe.o: ../h/file.h
+pipe.o: ../h/reg.h
+prf.o: ../h/param.h
+prf.o: ../h/systm.h
+prf.o: ../h/seg.h
+prf.o: ../h/buf.h
+prf.o: ../h/conf.h
+prim.o: ../h/param.h
+prim.o: ../h/tty.h
+prim.o: ../h/systm.h
+prim.o: ../h/conf.h
+prim.o: ../h/buf.h
+rdwri.o: ../h/param.h
+rdwri.o: ../h/systm.h
+rdwri.o: ../h/inode.h
+rdwri.o: ../h/dir.h
+rdwri.o: ../h/user.h
+rdwri.o: ../h/buf.h
+rdwri.o: ../h/conf.h
+sig.o: ../h/param.h
+sig.o: ../h/systm.h
+sig.o: ../h/dir.h
+sig.o: ../h/user.h
+sig.o: ../h/proc.h
+sig.o: ../h/inode.h
+sig.o: ../h/reg.h
+sig.o: ../h/text.h
+sig.o: ../h/seg.h
+sig.o: ../h/mtpr.h
+sig.o: ../h/page.h
+sig.o: ../h/psl.h
+slp.o: ../h/param.h
+slp.o: ../h/systm.h
+slp.o: ../h/dir.h
+slp.o: ../h/user.h
+slp.o: ../h/proc.h
+slp.o: ../h/text.h
+slp.o: ../h/uba.h
+slp.o: ../h/map.h
+slp.o: ../h/file.h
+slp.o: ../h/inode.h
+slp.o: ../h/buf.h
+slp.o: ../h/page.h
+slp.o: ../h/mtpr.h
+subr.o: ../h/param.h
+subr.o: ../h/systm.h
+subr.o: ../h/conf.h
+subr.o: ../h/inode.h
+subr.o: ../h/dir.h
+subr.o: ../h/user.h
+subr.o: ../h/buf.h
+sys.o: ../h/param.h
+sys.o: ../h/conf.h
+sys.o: ../h/dir.h
+sys.o: ../h/user.h
+sys.o: ../h/tty.h
+sys.o: ../h/proc.h
+sys1.o: ../h/param.h
+sys1.o: ../h/systm.h
+sys1.o: ../h/uba.h
+sys1.o: ../h/map.h
+sys1.o: ../h/mtpr.h
+sys1.o: ../h/dir.h
+sys1.o: ../h/user.h
+sys1.o: ../h/proc.h
+sys1.o: ../h/buf.h
+sys1.o: ../h/reg.h
+sys1.o: ../h/inode.h
+sys1.o: ../h/seg.h
+sys1.o: ../h/acct.h
+sys1.o: ../h/page.h
+sys2.o: ../h/param.h
+sys2.o: ../h/systm.h
+sys2.o: ../h/dir.h
+sys2.o: ../h/user.h
+sys2.o: ../h/reg.h
+sys2.o: ../h/file.h
+sys2.o: ../h/inode.h
+sys3.o: ../h/param.h
+sys3.o: ../h/systm.h
+sys3.o: ../h/mount.h
+sys3.o: ../h/ino.h
+sys3.o: ../h/reg.h
+sys3.o: ../h/buf.h
+sys3.o: ../h/filsys.h
+sys3.o: ../h/dir.h
+sys3.o: ../h/user.h
+sys3.o: ../h/inode.h
+sys3.o: ../h/file.h
+sys3.o: ../h/conf.h
+sys3.o: ../h/stat.h
+sys4.o: ../h/param.h
+sys4.o: ../h/systm.h
+sys4.o: ../h/dir.h
+sys4.o: ../h/user.h
+sys4.o: ../h/reg.h
+sys4.o: ../h/inode.h
+sys4.o: ../h/proc.h
+sys4.o: ../h/clock.h
+sys4.o: ../h/mtpr.h
+sys4.o: ../h/timeb.h
+sysent.o: ../h/param.h
+sysent.o: ../h/systm.h
+text.o: ../h/param.h
+text.o: ../h/systm.h
+text.o: ../h/uba.h
+text.o: ../h/map.h
+text.o: ../h/dir.h
+text.o: ../h/user.h
+text.o: ../h/proc.h
+text.o: ../h/text.h
+text.o: ../h/inode.h
+text.o: ../h/buf.h
+text.o: ../h/seg.h
+text.o: ../h/page.h
+trap.o: ../h/param.h
+trap.o: ../h/systm.h
+trap.o: ../h/dir.h
+trap.o: ../h/user.h
+trap.o: ../h/proc.h
+trap.o: ../h/reg.h
+trap.o: ../h/seg.h
+trap.o: ../h/trap.h
+trap.o: ../h/psl.h
+tty.o: ../h/param.h
+tty.o: ../h/systm.h
+tty.o: ../h/dir.h
+tty.o: ../h/user.h
+tty.o: ../h/tty.h
+tty.o: ../h/proc.h
+tty.o: ../h/mx.h
+tty.o: ../h/inode.h
+tty.o: ../h/file.h
+tty.o: ../h/reg.h
+tty.o: ../h/conf.h
+uba.o: ../h/param.h
+uba.o: ../h/uba.h
+uba.o: ../h/map.h
+univec.o: ../h/param.h
diff --git a/usr/src/sys/sys/malloc.c b/usr/src/sys/sys/malloc.c
new file mode 100644 (file)
index 0000000..80bae66
--- /dev/null
@@ -0,0 +1,164 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/uba.h"
+#include "../h/map.h"
+#include "../h/page.h"
+#include "../h/mem.h"
+
+/*
+ * Allocate 'size' units from the given
+ * map. Return the base of the allocated
+ * space.
+ * In a map, the addresses are increasing and the
+ * list is terminated by a 0 size.
+ * The swap map unit is 512 bytes.
+ * Algorithm is first-fit.
+ */
+malloc(mp, size)
+struct map *mp;
+{
+       register unsigned int a;
+       register struct map *bp;
+
+       for (bp=mp; bp->m_size; bp++) {
+               if (bp->m_size >= size) {
+                       a = bp->m_addr;
+                       bp->m_addr += size;
+                       if ((bp->m_size -= size) == 0) {
+                               do {
+                                       bp++;
+                                       (bp-1)->m_addr = bp->m_addr;
+                               } while ((bp-1)->m_size = bp->m_size);
+                       }
+                       return(a);
+               }
+       }
+       return(0);
+}
+
+/*
+ * Free the previously allocated space aa
+ * of size units into the specified map.
+ * Sort aa into map and combine on
+ * one or both ends if possible.
+ */
+mfree(mp, size, a)
+struct map *mp;
+register unsigned int a;
+{
+       register struct map *bp;
+       register unsigned int t;
+
+       bp = mp;
+       for (; bp->m_addr<=a && bp->m_size!=0; bp++);
+       if (bp>mp && (bp-1)->m_addr+(bp-1)->m_size == a) {
+               (bp-1)->m_size += size;
+               if (a+size == bp->m_addr) {
+                       (bp-1)->m_size += bp->m_size;
+                       while (bp->m_size) {
+                               bp++;
+                               (bp-1)->m_addr = bp->m_addr;
+                               (bp-1)->m_size = bp->m_size;
+                       }
+               }
+       } else {
+               if (a+size == bp->m_addr && bp->m_size) {
+                       bp->m_addr -= size;
+                       bp->m_size += size;
+               } else if (size) {
+                       do {
+                               t = bp->m_addr;
+                               bp->m_addr = a;
+                               a = t;
+                               t = bp->m_size;
+                               bp->m_size = size;
+                               bp++;
+                       } while (size = t);
+               }
+       }
+}
+
+
+
+
+/* 
+ * allocate memory
+ * Note: the memory map is stored in the array
+ * `memmap', one bit per page frame.  If the
+ * i'th bit of memmap is 0, then page frame i
+ * is free (available), if 1, then it is allocated.
+ * Up to NICMEM free page frame numbers are
+ * stored in the array mem.m_pnum.
+ */
+memall(base, size)
+register int *base;
+{
+       register int i, pos, ndx, mask;
+
+       if (size <= 0 || size > freemem)
+               return(0);
+       if (mem.m_free < 0)
+               panic("bad mem free-list");
+       for(i=size; --i>=0; ) {
+               if (mem.m_free == 0) {
+                       pos = lastpos + 1;
+                       if (pos >= maxfree)
+                               pos = firstfree;
+                       while(mem.m_free<NICMEM) {
+                               if ((memmap[pos>>5]&masktab[pos&0x1f])==0)
+                                       mem.m_pnum[mem.m_free++] = pos;
+                               if (pos == lastpos)
+                                       break;
+                               if (++pos >= maxfree)
+                                       pos = firstfree;
+                       }
+                       if (mem.m_free <= 0)
+                               panic("lost mem");
+                       lastpos = pos;
+               }
+               pos = mem.m_pnum[--mem.m_free];
+               mask = masktab[pos&0x1f];
+               ndx = pos >> 5;
+               if (memmap[ndx]&mask)
+                       panic("dup alloc");
+               memmap[ndx] |= mask;
+               *base++ = pos;
+               freemem--;
+       }
+       return(size);
+}
+
+
+/*
+ * Free memory
+ */
+memfree(base, size)
+register int *base, size;
+{
+       register int ndx, mask;
+
+       while(--size>=0) {
+               *base &= PG_PFNUM;
+               if (*base<firstfree || *base>=maxfree) 
+                       panic("bad mem free");
+               if (mem.m_free < NICMEM && mem.m_free >= 0)
+                       mem.m_pnum[mem.m_free++] = *base;
+               ndx = *base >> 5;
+               mask = masktab[*base++ & 0x1f];
+               if ((memmap[ndx]&mask)==0)
+                       panic("dup free");
+               memmap[ndx] &= ~mask;
+               freemem++;
+       }
+}
+
+/*
+ * Initialize memory map
+ */
+meminit(first, last)
+{
+       firstfree = first;
+       maxfree = lastpos = last;
+       freemem = last - first;
+       mem.m_free = 0;
+}
diff --git a/usr/src/sys/sys/mba.c b/usr/src/sys/sys/mba.c
new file mode 100644 (file)
index 0000000..f3c973c
--- /dev/null
@@ -0,0 +1,96 @@
+#
+/*
+ */
+
+#include "../h/param.h"
+#include "../h/buf.h"
+#include "../h/conf.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/proc.h"
+#include "../h/seg.h"
+#include "../h/page.h"
+#include "../h/uba.h"
+#include "../h/map.h"
+#include "../h/mba.h"
+#include "../h/mtpr.h"
+
+/*
+ * startup routine for MBA controllers.
+ */
+#define        MBAWCOM 0x30
+#define        MBARCOM 0x38
+#define        GO      01
+
+int mbaboff;
+
+mbastart(bp, adcr)
+register struct buf *bp;
+int *adcr;
+{
+       int vaddr, com;
+       register int *io, num;
+       register struct mba_regs *mbap;
+       register int *pt, i;
+       int pf;
+       extern int mbanum[], *mbaloc[], mbautl[], Mbamap[];
+       extern char buffers[][];
+
+       mbap = (struct mba_regs *)mbaloc[mbanum[major(bp->b_dev)]];
+       if ( (bp->b_flags & B_PHYS) == 0 ) {
+               vaddr = (bp->b_un.b_addr - (char *)buffers) + mbaboff;
+       } else {
+               ptaccess(bp->b_proc, Mbamap, mbautl);   /* get to u-area & page tables */
+               io = (int *)mbap;
+               io += (MBA_MAP + 128*4)/4;
+               vaddr = (128 << 9) | ((int)bp->b_un.b_addr & 0x1ff);
+               pf = (int)bp->b_un.b_addr >> 9;
+               num = (((int)bp->b_un.b_addr + bp->b_bcount - 1) >> 9) - pf +1;
+               if ((bp -> b_flags & B_UAREA) != 0)  {  /* u-area should be part of the I/O */
+                       for(i=0; i<UPAGES; i++) {
+                           if ((*io++ = PG_V | bp->b_proc->p_addr[i])==PG_V)
+                               panic("mba, zero u-page");
+                       }
+                       num -= UPAGES;
+               }
+               if (pf & 0x200000) {    /* I/O to stack */
+                       i = ((struct user *)mbautl)->u_pcb.pcb_szpt;
+                       pf = i*128 + pf - 0x400000;
+               }
+               pt = mbautl + UPAGES*128 + pf;
+               while ( num-->0) {
+                       if ((*io++ = *pt++ | PG_V)==PG_V)
+                               panic("mba, zero entry");
+               }
+       }
+       mbap->mba_sr = -1;      /* clear status (error) bits */
+       mbap->mba_bcr = -bp->b_bcount;
+       mbap->mba_var = vaddr;
+       if (bp->b_flags & B_READ)
+               com = MBARCOM | GO;
+       else
+               com = MBAWCOM | GO;
+
+       *adcr = com;            /* set cmd in device control and status register */
+}
+
+mbainit()
+{
+       register int *io0, *io1, *b, t, j;
+       extern int Sysmap[], *mbaloc[];
+       extern char buffers[][];
+
+       io0 = mbaloc[0] + (MBA_MAP/4);
+       io1 = mbaloc[1] + (MBA_MAP/4);
+       b = Sysmap + ((((int) buffers)>>9)&PG_PFNUM);
+       j = NBUF + ((int)buffers & 0x1ff ? 1 : 0);
+       do {
+               t = PG_V | (*b++ & PG_PFNUM);
+               *io0++ = t;
+               *io1++ = t;
+       } while (--j>0);
+       *io0 = 0;               /* invalidate next entry */
+       *io1 = 0;
+       mbaboff = (int)buffers & 0x1ff;
+}
diff --git a/usr/src/sys/sys/mem.c b/usr/src/sys/sys/mem.c
new file mode 100644 (file)
index 0000000..bbac87b
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ *     Memory special file
+ *     minor device 0 is physical memory
+ *     minor device 1 is kernel memory 
+ *     minor device 2 is EOF/RATHOLE
+ */
+
+#include "../h/param.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/conf.h"
+#include "../h/buf.h"
+#include "../h/systm.h"
+#include "../h/page.h"
+#include "../h/mtpr.h"
+
+mmread(dev)
+{
+       register char *p;
+       register c;
+       extern int mmap[];
+       extern char vmmap[];
+
+       if(minor(dev) == 2)
+               return;
+       if( minor(dev) == 1 ) {
+               if( kernacc(u.u_offset, u.u_count, B_READ)
+           && !copyout(u.u_offset, u.u_base, u.u_count) ) {
+               c = u.u_count;
+               u.u_count = 0;
+               u.u_base += c;
+               u.u_offset += c;
+       } else 
+               u.u_error = EFAULT;
+       return;
+       }
+
+       if( minor(dev) == 0) {
+               while (u.u_count > 0 && u.u_error == 0) {
+                       c = (int) u.u_offset >> 9;
+                       if( c < 0 || c >= MAXMEM ) {
+                               u.u_error = EFAULT;
+                               break;
+                       }
+                       *mmap = c | (PG_V | PG_KR);
+                       mtpr(TBIS, vmmap);
+                       copyout(vmmap+((int)u.u_offset & 0x1ff), u.u_base, c=min(512-((int)u.u_offset & 0x1ff), u.u_count));
+                       u.u_count -= c;
+                       u.u_base += c;
+                       u.u_offset += c;
+               }
+       return;
+       }
+       if (minor(dev) == 3) { /* UNIBUS access */
+               if ((!kernacc(u.u_offset,u.u_count,B_READ)) ||
+               (!useracc(u.u_base,u.u_count,B_READ)) ||
+               UNIcpy(u.u_offset,u.u_base,u.u_count,B_READ))
+                 u.u_error = EFAULT;
+               else {
+                       u.u_offset += u.u_count;
+                       u.u_base += u.u_count;
+                       u.u_count = 0;
+               }
+               return;
+       }
+}
+
+mmwrite(dev)
+{
+       register char *p;
+       register c;
+
+       if(minor(dev) == 2) {
+               c = u.u_count;
+               u.u_count = 0;
+               u.u_offset += c;
+               return;
+       }
+       /*  kernel virt mem */
+       if (minor(dev) == 1) {
+               if ((!kernacc(u.u_offset,u.u_count,B_WRITE)) || copyin(u.u_base,u.u_offset,u.u_count))
+                       u.u_error = EFAULT;
+               else {
+                       u.u_offset += u.u_count;
+                       u.u_base += u.u_count;
+                       u.u_count = 0 ;
+               }
+               return;
+       }
+       if (minor(dev) == 3) { /* UNIBUS access */
+               if ((!kernacc(u.u_offset,u.u_count,B_WRITE)) ||
+               (!useracc(u.u_base,u.u_count,B_WRITE)) ||
+               UNIcpy(u.u_offset,u.u_base,u.u_count,B_WRITE))
+                       u.u_error = EFAULT;
+               else {
+                       u.u_offset += u.u_count;
+                       u.u_base += u.u_count;
+                       u.u_count = 0;
+               }
+               return;
+       }
+}
+
+/*
+ *  UNIBUS Address Space <-->  User Space transfer
+ */
+UNIcpy(uniadd,usradd,bknt,direct)
+short *uniadd , *usradd;
+{
+       register short *from , *to;
+       register int i;
+       if (direct == B_READ) {
+               from = uniadd;
+               to = usradd ;
+       } else {
+               if (direct == B_WRITE) {
+                       from = usradd;
+                       to = uniadd ;
+               }
+       }
+       for (i = (bknt>>1) ; i>0 ; i--)
+               (*to++) = (*from++);
+       return(0);
+}
diff --git a/usr/src/sys/sys/mx1.c b/usr/src/sys/sys/mx1.c
new file mode 100644 (file)
index 0000000..40bc15b
--- /dev/null
@@ -0,0 +1,479 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/reg.h"
+#include "../h/proc.h"
+#include "../h/tty.h"
+#include "../h/inode.h"
+#define        KERNEL  1
+#include "../h/mx.h"
+#include "../h/file.h"
+#include "../h/conf.h"
+
+/*
+ * Multiplexor:   clist version
+ *
+ * installation:
+ *     requires a line in cdevsw -
+ *             mxopen, mxclose, mxread, mxwrite, mxioctl, 0,
+ *
+ *     also requires a line in linesw -
+ *             mxopen, mxclose, mcread, mcwrite, mxioctl, nulldev, nulldev,
+ *
+ *     The linesw entry for mpx should be the last one in the table.
+ *     'nldisp' (number of line disciplines) should not include the
+ *     mpx line.  This is to prevent mpx from being enabled by an ioctl.
+
+ *     mxtty.c must be loaded instead of tty.c so that certain
+ *     sleeps will not be done if a typewriter is connected to
+ *     a channel and so that sdata will be called from ttyinput.
+ *     
+ */
+struct chan    chans[NCHANS];
+struct schan   schans[NPORTS];
+struct group   *groups[NGROUPS];
+int    mpxline;
+struct chan *xcp();
+dev_t  mpxdev  = -1;
+
+
+char   mcdebugs[NDEBUGS];
+
+
+/*
+ * Allocate a channel, set c_index to index.
+ */
+struct chan *
+challoc(index, isport)
+{
+register s;
+register struct chan *cp, *lastcp;
+
+       s = spl6();
+       if (isport) {
+               cp = (struct chan *)schans;
+               lastcp = (struct chan *)&schans[NPORTS];
+       } else {
+               cp = chans;
+               lastcp = &chans[NCHANS];
+       }
+
+       for(; cp < lastcp; cp++) 
+               if(cp->c_group==NULL) {
+                       cp->c_index = index;
+                       cp->c_pgrp = 0;
+                       cp->c_flags = 0;
+                       splx(s);
+                       return(cp);
+               }
+       splx(s);
+       return(NULL);
+}
+
+
+
+/*
+ * Allocate a group table cell.
+ */
+gpalloc()
+{
+register i,s;
+
+       s = spl6();
+       for(i = NGROUPS-1; i>=0; i--)
+               if (groups[i]==NULL) {
+                       groups[i]++;
+                       break;
+               }
+       splx(s);
+       return(i);
+}
+
+
+/*
+ * Add a channel to the group in
+ * inode ip.
+ */
+struct chan *
+addch(ip, isport)
+struct inode *ip;
+{
+register struct chan *cp;
+register struct group *gp;
+register i;
+
+       plock(ip);
+       gp = &ip->i_un.i_group;
+       for(i=0;i<NINDEX;i++) {
+               cp = (struct chan *)gp->g_chans[i];
+               if (cp == NULL) {
+                       if ((cp=challoc(i, isport)) != NULL) {
+                               gp->g_chans[i] = cp;
+                               cp->c_group = gp;
+                       }
+                       break;
+               }
+               cp = NULL;
+       }
+       prele(ip);
+       return(cp);
+}
+
+
+
+
+/*
+ * mpxchan system call
+ */
+mpxchan()
+{
+struct inode *ip, *gip;
+register int i;
+extern mxopen(), mcread();
+extern sdata(), scontrol();
+dev_t  dev;
+struct tty *tp;
+struct file *fp, *chfp, *gfp;
+struct chan *cp;
+struct group *gp, *ngp;
+struct a {
+       int     cmd;
+       int     *argvec;
+} *uap;
+struct mx_args vec;
+
+
+       /*
+        * common setup code.
+        */
+       uap = (struct a *)u.u_ap;
+       copyin(uap->argvec, &vec, sizeof vec);
+       gp = NULL;
+       switch(uap->cmd) {
+       case NPGRP:
+               if (vec.m_arg[1] < 0)
+                       goto sw;
+       case CHAN:
+       case JOIN:
+       case EXTR:
+       case ATTACH:
+       case DETACH:
+       case CSIG:
+               gfp = getf(vec.m_arg[1]);
+               if (gfp==NULL)
+                       goto bad;
+               gip = gfp->f_inode;
+               gp = &gip->i_un.i_group;
+               if (gp->g_inode != gip)
+                       goto bad;
+       }
+
+sw:
+       switch(uap->cmd) {
+       /*
+        * creat an mpx file.
+        */
+       case MPX:
+       case MPXN:
+               if (mpxdev < 0) {
+                       for(i=0; linesw[i].l_open; i++) 
+                               if (linesw[i].l_read == mcread) {
+                                       mpxline = i;
+                                       goto found1;
+                               }
+                       goto bad;
+
+               found1:
+                       for(i=0; cdevsw[i].d_open; i++) {
+                               if (cdevsw[i].d_open == mxopen)
+                                       goto found2;
+                       }
+               bad:
+                       u.u_error = ENXIO;
+                       return;
+               found2:
+                       mpxdev = (dev_t)(i<<8);
+               }
+               if (uap->cmd==MPXN) {
+                       if ((ip=ialloc(rootdev))==NULL)
+                               goto bad;
+                       ip->i_mode = (vec.m_arg[1]&0777)+IFCHR;
+                       ip->i_flag = IACC|IUPD|ICHG;
+                       goto merge;
+               }
+               u.u_dirp = vec.m_name;
+               ip = namei(uchar,1);
+               if (ip != NULL) {
+                       u.u_error = EEXIST;
+                       iput(ip);
+                       return;
+               }
+               if (u.u_error)
+                       return;
+               ip = maknode((vec.m_arg[1]&0777)+IFCHR);
+               if (ip == NULL)
+                       return;
+       merge:
+               if ((i = gpalloc()) < 0) {
+                       iput(ip);
+                       goto bad;
+               }
+               ip->i_un.i_rdev = (daddr_t)(mpxdev+i);
+               gp = &ip->i_un.i_group;
+               groups[i] = gp;
+               gp->g_inode = ip;
+               gp->g_state = COPEN;
+               gp->g_group = NULL;
+               gp->g_index = 0;
+               gp->g_rotmask = 1;
+               gp->g_rot = 0;
+               gp->g_datq = 0;
+               open1(ip,FREAD+FWRITE,2);
+               if (u.u_error) {
+                       groups[i] = NULL;
+                       iput(ip);
+                       goto bad;
+               }
+               ip->i_mode = (ip->i_mode & ~IFMT) | IFMPC;
+               ip->i_count++;
+               fp = u.u_ofile[u.u_r.r_val1];
+               fp->f_flag |= FMP;
+               fp->f_un.f_chan = NULL;
+               gp->g_file = fp;
+               for(i=0;i<NINDEX;)
+                       gp->g_chans[i++] = NULL;
+               return;
+       /*
+        * join file descriptor (arg 0) to group (arg 1)
+        * return channel number
+        */
+       case JOIN:
+               if ((fp=getf(vec.m_arg[0]))==NULL)
+                       goto bad;
+               ip = fp->f_inode;
+               i = ip->i_mode & IFMT;
+               if (i == IFMPC) {
+                       if ((fp->f_flag&FMP) != FMP) {
+                               goto bad;
+                       }
+                       ngp = &ip->i_un.i_group;
+                       mlink (ngp, gp);
+                       fp->f_count++;
+                       return;
+               }
+               if (i != IFCHR) 
+                       goto bad;
+               dev = (dev_t)ip->i_un.i_rdev;
+               tp = cdevsw[major(dev)].d_ttys;
+               if (tp==NULL)
+                       goto bad;
+               tp = &tp[minor(dev)];
+               if (tp->t_chan)
+                       goto bad;
+               if ((cp=addch(gip, 1))==NULL)
+                       goto bad;
+               tp->t_chan = cp;
+               cp->c_fy = fp;
+               fp->f_count++;
+               cp->c_ttyp = tp;
+               cp->c_line = tp->t_line;
+               cp->c_flags = XGRP+PORT;
+               u.u_r.r_val1 = cpx(cp);
+               return;
+       /*
+        * attach channel (arg 0) to group (arg 1)
+        */
+       case ATTACH:
+               cp = xcp(gp, vec.m_arg[0]);
+               if (cp==NULL)
+                       goto bad;
+               u.u_r.r_val1 = cpx(cp);
+               wakeup((caddr_t)cp);
+               return;
+       case DETACH:
+               cp = xcp(gp, vec.m_arg[0]);
+               if (cp==NULL)
+                       goto bad;
+               detach(cp);
+               return;
+       /*
+        * extract channel (arg 0) from group (arg 1).
+        */
+       case EXTR:
+               cp = xcp(gp, vec.m_arg[0]);
+               if (cp==NULL) {
+                       goto bad;
+               }
+               if (cp->c_flags & ISGRP) {
+                       mxfalloc(((struct group *)cp)->g_file);
+                       return;
+               }
+               if ((fp = cp->c_fy) != NULL) {
+                       mxfalloc(fp);
+                       return;
+               }
+               if ((fp = falloc()) == NULL) {
+                       return;
+               }
+               fp->f_inode = gip;
+               gip->i_count++;
+               fp->f_un.f_chan = cp;
+               fp->f_flag = (vec.m_arg[2]) ?
+                               (FREAD|FWRITE|FMPY) : (FREAD|FWRITE|FMPX);
+               cp->c_fy = fp;
+               return;
+       /*
+        * make new chan on group (arg 1)
+        */
+       case CHAN:
+               if ((cp=addch(gip, 0))==NULL)
+                       goto bad;
+               cp->c_flags = XGRP;
+               cp->c_fy = NULL;
+               cp->c_ttyp = cp->c_ottyp = (struct tty *)cp;
+               cp->c_line = cp->c_oline = mpxline;
+               u.u_r.r_val1 = cpx(cp);
+               return;
+       /*
+        * connect fd (arg 0) to channel fd (arg 1)
+        * (arg 2 <  0) => fd to chan only
+        * (arg 2 >  0) => chan to fd only
+        * (arg 2 == 0) => both directions
+        */
+       case CONNECT:
+               if ((fp=getf(vec.m_arg[0]))==NULL)
+                       goto bad;
+               if ((chfp=getf(vec.m_arg[1]))==NULL)
+                       goto bad;
+               ip = fp->f_inode;
+               i = ip->i_mode&IFMT;
+               if (i!=IFCHR)
+                       goto bad;
+               dev = (dev_t)ip->i_un.i_rdev;
+               tp = cdevsw[major(dev)].d_ttys;
+               if (tp==NULL)
+                       goto bad;
+               tp = &tp[minor(dev)];
+               if (!(chfp->f_flag&FMPY)) {
+                       goto bad;
+               }
+               cp = chfp->f_un.f_chan;
+               if (cp==NULL || cp->c_flags&PORT) {
+                       goto bad;
+               }
+               i = vec.m_arg[2];
+               if (i>=0) {
+                       cp->c_ottyp = tp;
+                       cp->c_oline = tp->t_line;
+               }
+               if (i<=0)  {
+                       tp->t_chan = cp;
+                       cp->c_ttyp = tp;
+                       cp->c_line = tp->t_line;
+               }
+               return;
+       case NPGRP: {
+               register struct proc *pp;
+
+               if (gp != NULL) {
+                       cp = xcp(gp, vec.m_arg[0]);
+                       if (cp==NULL)
+                               goto bad;
+               }
+               pp = u.u_procp;
+               pp->p_pgrp = pp->p_pid;
+               if (vec.m_arg[2])
+                       pp->p_pgrp = vec.m_arg[2];
+               if (gp != NULL)
+                       cp->c_pgrp = pp->p_pgrp;
+               return;
+       }
+       case CSIG:
+               cp = xcp(gp, vec.m_arg[0]);
+               if (cp==NULL)
+                       goto bad;
+               signal(cp->c_pgrp, vec.m_arg[2]);
+               return;
+       case DEBUG:
+               i = vec.m_arg[0];
+               if (i<0 || i>NDEBUGS)
+                       return;
+               mcdebugs[i] = vec.m_arg[1];
+               if (i==ALL)
+                       for(i=0;i<NDEBUGS;i++)
+                               mcdebugs[i] = vec.m_arg[1];
+               return;
+       default:
+               goto bad;
+       }
+}
+
+detach(cp)
+register struct chan *cp;
+{
+       register struct group *gp;
+       register int i;
+
+       if (cp->c_flags&ISGRP) {
+               gp = (struct group *)cp;
+               closef(gp->g_file);
+               i = ((struct group *)cp)->g_index;
+               gp->g_chans[i] = NULL;
+               return;
+       } else if (cp->c_flags&PORT && cp->c_ttyp != NULL) {
+               closef(cp->c_fy);
+               chdrain(cp);
+               chfree(cp);
+               return;
+       }
+       if (cp->c_fy && (cp->c_flags&WCLOSE)==0) {
+               cp->c_flags |= WCLOSE;
+               chwake(cp);
+       } else {
+               chdrain(cp);
+               chfree(cp);
+       }
+}
+
+
+mxfalloc(fp)
+register struct file *fp;
+{
+register i;
+
+       if (fp==NULL) {
+               u.u_error = ENXIO;
+               return(-1);
+       }
+
+       i = ufalloc();
+       if (i < 0)
+               return(i);
+       u.u_ofile[i] = fp;
+       fp->f_count++;
+       u.u_r.r_val1 = i;
+       return(i);
+}
+
+
+
+
+mlink(sub,master)
+struct group *sub, *master;
+{
+register i;
+
+
+       for(i=0;i<NINDEX;i++) {
+               if (master->g_chans[i] != NULL)
+                       continue;
+               master->g_chans[i] = (struct chan *)sub;
+               sub->g_group = master;
+               sub->g_index = i;
+               u.u_r.r_val1 = i;
+               return;
+       }
+       u.u_error = ENXIO;
+       return;
+}
diff --git a/usr/src/sys/sys/mx2.c b/usr/src/sys/sys/mx2.c
new file mode 100644 (file)
index 0000000..49029ca
--- /dev/null
@@ -0,0 +1,892 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/proc.h"
+#include "../h/tty.h"
+#include "../h/inode.h"
+#define        KERNEL  1
+#include "../h/mx.h"
+#include "../h/file.h"
+#include "../h/conf.h"
+#include "../h/buf.h"
+
+/*
+ * multiplexor driver
+ */
+struct chan    chans[NCHANS];
+struct group   *groups[NGROUPS];
+int    mpxline;
+struct chan *xcp();
+struct chan *addch();
+struct chan *nextcp();
+
+#define        MIN(a,b)        ((a<b)?a:b)
+short  cmask[16]       ={
+       01,     02,     04,
+       010,    020,    040,
+       0100,   0200,   0400,
+       01000,  02000,  04000,
+       010000, 020000, 040000, 0100000
+};
+
+
+char mcdebugs[NDEBUGS];
+
+/*
+ * Timing cell
+ */
+int    mxdummy;
+int    *MP     = &mxdummy;
+
+
+
+struct group *
+getmpx(dev)
+dev_t dev;
+{
+register d;
+
+       d = minor(dev);
+       if (d >= NGROUPS) 
+               return(NULL);
+       return(groups[d]);
+}
+
+
+
+
+mxopen(dev, flag)
+{
+register struct group *gp;
+register struct file *fp;
+register struct chan *cp;
+int    msg;
+       gp = getmpx(dev);
+       if (gp == NULL) {
+       bad:
+               u.u_error = ENXIO;
+               return;
+       }
+
+       if (gp->g_state == COPEN) {
+               gp->g_state = INUSE+ISGRP;
+               return;
+       }
+       if (!(gp->g_state&INUSE)) 
+               goto bad;
+       fp = u.u_ofile[u.u_r.r_val1];
+       if (fp->f_inode != gp->g_inode) 
+               goto bad;
+       if ((cp=addch(gp->g_inode, 0))==NULL)
+               goto bad;
+       cp->c_flags = XGRP;
+       cp->c_ottyp = cp->c_ttyp = (struct tty *)cp;
+       cp->c_line = cp->c_oline = mpxline;
+       fp->f_flag |= FMPY;
+       fp->f_flag |= FREAD+FWRITE;
+       fp->f_un.f_chan = cp;
+       if (gp->g_inode == mpxip) {
+               plock(mpxip);
+               mpxname(cp);
+               msg = M_OPEN;
+       } else
+               msg = M_WATCH;
+       scontrol(cp, msg+(cp->c_index<<8), u.u_uid);
+       sleep((caddr_t)cp,TTIPRI);
+       if (cp->c_flags&NMBUF)
+               prele(mpxip);
+       if (cp->c_flags & WCLOSE) {
+               chdrain(cp);
+               chfree(cp);
+               goto bad;
+       }
+       cp->c_fy = fp;
+       cp->c_pgrp = u.u_procp->p_pgrp;
+}
+
+
+char   mxnmbuf[NMSIZE];
+int    nmsize;
+struct chan *mxnmcp;
+mpxname(cp)
+register struct chan *cp;
+{
+register char *np;
+register c;
+       np = mxnmbuf;
+       u.u_dirp = (caddr_t)u.u_arg[0];
+       
+       while (np < &mxnmbuf[NMSIZE]) {
+               c = uchar();
+               if (c <= 0)
+                       break;
+               *np++ = c;
+       }
+       *np++ = '\0';
+       nmsize = np - mxnmbuf;
+
+       cp->c_flags |= NMBUF;
+}
+
+
+mxclose(dev, flag, cp)
+dev_t  dev;
+register struct chan *cp;
+{
+register struct group *gp;
+register struct inode *ip;
+register struct file *fp;
+int    i, fmp;
+
+       fmp = flag&FMP;
+
+       /*
+        * close a channel
+        */
+       if (cp!=NULL && fmp && fmp!=FMP) {
+               for(fp=file; fp < &file[NFILE]; fp++) 
+                   if(fp->f_count && fp->f_flag&FMP && fp->f_un.f_chan==cp){
+                               return;
+                       }
+               chdrain(cp);
+               if ((cp->c_flags&WCLOSE)==0) {
+                       scontrol(cp, M_CLOSE, 0);
+                       cp->c_flags |= WCLOSE;
+               } else {
+                       chfree(cp);
+               }
+               return;
+       }
+
+       if ((gp = getmpx(dev)) == NULL)
+               return;
+       ip = gp->g_inode;
+       if (ip==NULL || (ip->i_mode&IFMT)!=IFMPC) {
+               return;
+       }
+
+       for(fp=file; fp < &file[NFILE]; fp++) {
+               if (fp->f_count && (fp->f_flag&FMP)==FMP && fp->f_inode==ip) {
+                       return;
+               }
+       }
+
+       if (ip == mpxip) {
+               mpxip = NULL;
+               prele(ip);
+       }
+
+       for(i=0;i<NINDEX;i++)
+               if ((cp=gp->g_chans[i])!=NULL)
+                       detach(cp);
+
+       groups[minor(dev)] = NULL;
+       plock(ip);
+       i = ip->i_mode;
+       i &= ~IFMT;
+       i |= IFCHR;
+       ip->i_mode = i;
+       zero(gp, sizeof (struct group));
+       ip->i_flag |= IUPD|ICHG;
+       iput(ip);
+}
+
+zero(s, cc)
+register char *s;
+register cc;
+{
+       while (cc--)
+               *s++ = 0;
+}
+
+char   m_eot[] ={ M_EOT, 0, 0, 0};
+
+/*
+ * Mxread + mxwrite are entered from cdevsw
+ * for all read/write calls.  Operations on
+ * an mpx file are handled here.
+ * Calls are made through linesw to handle actual
+ * data movement.
+ */
+mxread(dev)
+{
+register struct group *gp;
+struct clist *q;
+struct chan *cp;
+struct file *fp;
+struct rh h;
+caddr_t        base;
+unsigned count;
+int    s, xfr, more, fmp;
+int esc;
+
+       if ((int)u.u_base & 1)
+               goto bad;
+       if ((gp=getmpx(dev))==NULL) {
+bad:
+               u.u_error = ENXIO;
+               return;
+       }
+       fp = getf(u.u_arg[0]);
+       fmp = fp->f_flag & FMP;
+       if (fmp != FMP) {
+               msread(fmp, fp->f_un.f_chan);
+               return;
+       }
+
+       s = spl6();
+       while (gp->g_datq == 0) {
+
+               sleep((caddr_t)&gp->g_datq, TTIPRI);
+       }
+
+       while (gp->g_datq && u.u_count >= CNTLSIZ + 2) {
+               splx(s);
+               esc = 0;
+               cp = nextcp(gp);
+               if (cp==NULL) {
+                       continue;
+               }
+               h.index = cpx(cp);
+               if (count = cp->c_ctlx.c_cc) {
+                       count += CNTLSIZ;
+                       if (cp->c_flags&NMBUF)
+                               count += nmsize;
+                       if (count > u.u_count) {
+                               sdata(cp);
+                               return;
+                       }
+                       esc++;
+               }
+               base = u.u_base;
+               count = u.u_count;
+               u.u_base += sizeof h;
+               u.u_count -= sizeof h;
+               xfr = u.u_count;
+               if (esc && cp->c_flags&PORT) {
+                       more = mcread(cp);
+               } else {
+                       more = (*linesw[cp->c_line].l_read)(cp->c_ttyp);
+               }
+               if (more > 0)
+                       sdata(cp);
+               if (more < 0)
+                       scontrol(cp, M_CLOSE, 0);
+               if (xfr == u.u_count) {
+                       esc++;
+                       iomove(m_eot, sizeof m_eot, B_READ);
+               }
+               xfr -= u.u_count;
+               if (esc) {
+                       h.count = 0;
+                       h.ccount = xfr;
+               } else {
+                       h.count = xfr;
+                       h.ccount = 0;
+               }
+               if (u.u_count && (xfr&1)) {
+                       u.u_base++;
+                       u.u_count--;
+               }
+               copyout(&h, base, sizeof h);
+
+               q = &cp->cx.datq;
+               if (cp->c_flags&BLOCK && esc==0) {
+                       if (q->c_cc<25) {
+                               wakeup((caddr_t)q+1);
+                               cp->c_flags &= ~BLOCK;
+                       } else {
+                       }
+               }
+               if (cp->c_flags&WFLUSH)
+                       wakeup((caddr_t)q+2);
+               s = spl6();
+       }
+}
+
+
+
+
+
+mxwrite(dev)
+{
+register struct chan *cp;
+struct wh h;
+struct file *fp;
+struct group *gp;
+int    ucount, esc, fmp, burpcount;
+caddr_t        ubase, hbase;
+
+       if ((gp=getmpx(dev))==NULL) {
+               u.u_error = ENXIO;
+               return;
+       }
+       fp = getf(u.u_arg[0]);
+       fmp = fp->f_flag & FMP;
+       if (fmp != FMP) {
+               mswrite(fmp, fp->f_un.f_chan);
+               return;
+       }
+       burpcount = 0;
+       while (u.u_count >= sizeof h) {
+               hbase = u.u_base;
+               iomove(&h, sizeof h, B_WRITE);
+               if (u.u_error)
+                       return;
+               esc = 0;
+               if (h.count==0) {
+                       esc++;
+                       h.count = h.ccount;
+               }
+               cp = xcp(gp, h.index);
+               if (cp==NULL)  {
+                       continue;
+               }
+               ucount = u.u_count;
+               ubase = u.u_base;
+               u.u_count = h.count;
+               u.u_base = h.data;
+
+               if (esc==0) {
+                       struct tty *tp;
+                       caddr_t waddr;
+                       int line;
+
+                       if (cp->c_flags&PORT) {
+                               line = cp->c_line;
+                               tp = cp->c_ttyp;
+                       } else {
+                               line = cp->c_oline;
+                               tp = cp->c_ottyp;
+                       }
+               loop:
+                       waddr = (caddr_t)(*linesw[line].l_write)(tp);
+                       if (u.u_count) {
+                               if (gp->g_state&ENAMSG) {
+                                       burpcount++;
+                                       cp->c_flags |= BLKMSG;
+/*
+                                       scontrol(cp, M_BLK, u.u_count);
+*/
+                                       h.ccount = -1;
+                                       h.count = u.u_count;
+                                       h.data = u.u_base;
+                                       copyout(&h, hbase, sizeof h);
+                               } else {
+                                       sleep(waddr, TTOPRI);
+                                       goto loop;
+                               }
+                       }
+               } else
+                       mxwcontrol(cp); 
+               u.u_count = ucount;
+               u.u_base = ubase;
+       }
+       u.u_count = burpcount;
+}
+
+
+
+/*
+ * Mcread and mcwrite move data on an mpx file.
+ * Transfer addr and length is controlled by mxread/mxwrite.
+ * Kernel-to-Kernel and other special transfers are not
+ * yet in.
+ */
+mcread(cp)
+register struct chan *cp;
+{
+register struct clist *q;
+register char *np;
+char   buf[100];
+
+int cc;
+
+       if (cp->c_ctlx.c_cc)
+               q = &cp->c_ctlx; else
+               q = &cp->cx.datq;
+
+       cc = MIN(u.u_count, sizeof buf);
+       cc = q_to_b(q, buf, cc);
+       iomove(buf, cc, B_READ);
+
+       if (cp->c_flags&NMBUF && q == &cp->c_ctlx) {
+               np = mxnmbuf;
+               while (nmsize--)
+                       passc(*np++);
+               cp->c_flags &= ~NMBUF;
+               prele(mpxip);
+       }
+       if (cp->c_flags&PORT)
+               return(cp->c_ctlx.c_cc + cp->c_ttyp->t_rawq.c_cc); else
+               return(cp->c_ctlx.c_cc + cp->cx.datq.c_cc);
+
+}
+
+
+caddr_t
+mcwrite(cp)
+register struct chan *cp;
+{
+register struct clist *q;
+register cc;
+char   buf[100];
+int    s;
+
+       q = &cp->cy.datq;
+
+
+       while (u.u_count) {
+               s = spl6();
+               if (q->c_cc > 100 || (cp->c_flags&EOTMARK)) {
+                       cp->c_flags |= SIGBLK;
+                       splx(s);
+                       wakeup((caddr_t)q);
+                       return((caddr_t)q);
+
+               }
+               splx(s);
+               cc = MIN(u.u_count, sizeof buf);
+               iomove(buf, cc, B_WRITE);
+               b_to_q(buf, cc, q);
+       }
+       wakeup((caddr_t)q);
+       return(NULL);
+}
+
+
+/*
+ * Msread and mswrite move bytes
+ * between user and non-multiplexed channel.
+ */
+msread(fmp, cp)
+register struct chan *cp;
+{
+register struct clist *q;
+register cc;
+char buf[100];
+int s;
+
+       q = (fmp&FMPX) ? &cp->cx.datq : &cp->cy.datq;
+       s = spl6();
+       while (q->c_cc == 0) {
+               if (cp->c_flags & EOTMARK) {
+                       cp->c_flags &= ~EOTMARK;
+                       if (cp->c_flags&ENAMSG)
+                               scontrol(cp, M_UBLK, 0);
+                       else {
+                               wakeup((caddr_t)cp);
+                               wakeup((caddr_t)q);
+                       }
+                       goto out;
+               }
+               if (cp->c_flags&WCLOSE) {
+                       u.u_error = ENXIO;
+                       goto out;
+               }
+               sleep((caddr_t)q,TTIPRI);
+       }
+       splx(s);
+       while (u.u_count) {
+               cc = q_to_b(q, buf, MIN(u.u_count, sizeof buf));
+               if (cc == 0)
+                       break;
+               iomove(buf, cc, B_READ);
+       }
+       if (cp->c_flags&SIGBLK && q->c_cc < 20) {
+               cp->c_flags &= ~SIGBLK;
+               mcstart(cp, q);
+       }
+       s = spl6();
+       if (cp->c_flags&WFLUSH)
+               wakeup((caddr_t)q+2);
+out:
+       splx(s);
+}
+
+
+mswrite(fmp, cp)
+register struct chan *cp;
+{
+register struct clist *q;
+register unsigned int cc;
+char buf[32];
+
+       q = (fmp&FMPX) ? &cp->cy.datq : &cp->cx.datq;
+       while (u.u_count) {
+               cc = MIN(u.u_count, sizeof buf);
+               iomove(buf, cc, B_WRITE);
+
+               spl6();
+               if (cp->c_flags&WCLOSE) {
+               bad:
+                       signal(SIGPIPE, cp->c_pgrp);
+                       return;
+               }
+
+               while (q->c_cc>100) {
+                       if (cp->c_flags&WCLOSE)
+                               goto bad;
+                       sdata(cp);
+                       cp->c_flags |= BLOCK;
+                       sleep((caddr_t)q+1,TTOPRI);
+               }
+               spl0();
+
+               cc = b_to_q(buf, cc, q);
+       }
+       if (fmp&FMPX) {
+               if (cp->c_flags&YGRP) 
+                       sdata(cp); else
+                       wakeup((caddr_t)q);
+       } else {
+               if (cp->c_flags&XGRP) 
+                       sdata(cp); else
+                       wakeup((caddr_t)q);
+       }
+       return;
+}
+
+
+mxwcontrol(cp)
+register struct chan *cp;
+{
+short  cmd[2];
+int    s;
+
+       iomove(cmd, sizeof cmd, B_WRITE);
+       switch(cmd[0]) {
+       /*
+        * not ready to queue this up yet.
+        */
+       case M_EOT:
+               s = spl6();
+               while (cp->c_flags & EOTMARK)
+                       if (cp->c_flags&ENAMSG) {
+                               scontrol(cp, M_BLK, 0);
+                               goto out;
+                       } else
+                               sleep(cp, TTOPRI);
+               cp->c_flags |= EOTMARK;
+       out:
+               splx(s);
+               break;
+       case M_IOCTL:
+printf("M_IOCTL");
+               break;
+       default:
+               u.u_error = ENXIO;
+       }
+}
+
+
+
+mcstart(cp, q)
+register struct chan *cp;
+register caddr_t q;
+{
+
+       if (cp->c_flags&(BLKMSG)) {
+               cp->c_flags &= ~BLKMSG;
+               scontrol(cp, M_UBLK, 0);
+       } else
+               wakeup(q);
+}
+
+
+
+
+
+mxioctl(dev, cmd, addr, flag)
+caddr_t addr;
+{
+struct group *gp;
+int fmp;
+struct file *fp;
+
+       if ((gp = getmpx(dev)) == NULL) {
+bad:
+               u.u_error = ENXIO;
+               return;
+       }
+
+       fp = getf(u.u_arg[0]);
+       if (fp==NULL)
+               goto bad;
+
+       fmp = fp->f_flag & FMP;
+
+       if (fmp == FMP) {
+               switch(cmd) {
+               case MXLSTN:
+                       if (mpxip == NULL) {
+                               mpxip = gp->g_inode;
+                       } else
+                               goto bad;
+                       break;
+               case MXNBLK:
+                       gp->g_state |= ENAMSG;
+                       break;
+               default:
+                       goto bad;
+               }
+       }
+}
+
+
+
+
+chdrain(cp)
+register struct chan *cp;
+{
+register struct tty *tp;
+int wflag;
+
+       chwake(cp);
+
+       wflag = (cp->c_flags&WCLOSE)==0;
+       tp = cp->c_ttyp;
+       if (tp == NULL)         /* prob not required */
+               return;
+       if (cp->c_flags&PORT && tp->t_chan == cp) {
+               cp->c_ttyp = NULL;
+               tp->t_chan = NULL;
+               return;
+       }
+       if (wflag) 
+               wflush(cp,&cp->cx.datq); else
+               flush(&cp->cx.datq);
+       if (!(cp->c_flags&YGRP)) {
+               flush(&cp->cy.datq);
+       }
+}
+
+chwake(cp)
+register struct chan *cp;
+{
+register char *p;
+
+       wakeup(cp);
+       flush(&cp->c_ctlx);
+       p = (char *)&cp->cx.datq;
+       wakeup(p); wakeup(++p); wakeup(++p);
+       p = (char *)&cp->cy.datq;
+       wakeup(p); wakeup(++p); wakeup(++p);
+}
+
+
+chfree(cp)
+register struct chan *cp;
+{
+register struct group *gp;
+register i;
+
+       gp = cp->c_group;
+       if (gp==NULL)
+               return;
+       i = cp->c_index;
+       if (cp == gp->g_chans[i]) {
+               gp->g_chans[i] = NULL;
+       }
+       cp->c_group = NULL;
+}
+
+
+flush(q)
+register struct clist *q;
+{
+
+       while(q->c_cc)
+               getc(q);
+}
+
+
+wflush(cp,q)
+register struct chan *cp;
+register struct clist *q;
+{
+register s;
+
+       s = spl6();
+       while(q->c_cc) {
+               if (cp->c_flags & WCLOSE) {
+                       flush(q);
+                       goto out;
+               }
+               cp->c_flags |= WFLUSH;
+               sdata(cp);
+               sleep((caddr_t)q+2,TTOPRI);
+       }
+out:
+       cp->c_flags &= ~WFLUSH;
+       splx(s);
+}
+
+
+scontrol(cp,event,value)
+register struct chan *cp;
+short event,value;
+{
+register struct clist *q;
+int s;
+
+       q = &cp->c_ctlx;
+       s = spl6();
+       if (sdata(cp) == NULL)
+               return;
+       putw(event,q);
+       putw(value,q);
+       splx(s);
+}
+
+sdata(cp)
+register struct chan *cp;
+{
+register struct group *gp;
+register short x;
+register struct group *lgp;
+int s;
+
+       gp = cp->c_group;
+       if (gp==NULL) {
+               return(0);
+       }
+       x = cp->c_index;
+
+       s = spl6();
+       while (gp) {
+               if ((gp->g_state&ISGRP)==0) {
+                       return(0);
+               }
+               gp->g_datq |= cmask[x];
+               x = gp->g_index;
+               lgp = gp;
+               gp = gp->g_group;
+       }
+       gp =  lgp;
+       splx(s);
+       wakeup((caddr_t)&gp->g_datq);
+       return((int)gp);
+}
+
+
+
+struct chan *
+xcp(gp, x)
+register struct group *gp;
+register short x;
+{
+register i;
+
+       i = 0;
+       while (i<NLEVELS && gp->g_state&ISGRP) {
+               gp = (struct group *)gp->g_chans[x&017];
+               x >>= 4;
+               if ((x&017) >= NINDEX)
+                       break;
+               i++;
+       }
+       return((struct chan *)gp);
+}
+
+cpx(cp)
+register struct chan *cp;
+{
+register x;
+register struct group *gp;
+
+       if (cp==NULL)
+               return(-1);
+       x = (-1<<4) + cp->c_index;
+       gp = cp->c_group;
+       if (gp==NULL || (gp->g_state&ISGRP)==0)
+               return(-1);
+       gp = gp->g_group;
+       while (gp && gp->g_state&ISGRP) {
+               x <<= 4;
+               x |= gp->g_index;
+               gp = gp->g_group;
+       }
+       return(x);
+}
+
+
+
+struct chan *
+nextcp(gp)
+register struct group *gp;
+{
+
+       if (gp->g_datq == 0) {
+               gp = NULL;
+               goto out;
+       }
+
+       while (gp != NULL && gp->g_state&ISGRP) {
+               while ( (gp->g_datq & gp->g_rotmask) == 0) {
+                       gp->g_rot++;
+                       gp->g_rot &= 017;
+                       if (gp->g_rot)
+                               gp->g_rotmask <<= 1; else
+                               gp->g_rotmask = 1;
+               }
+               gp = (struct group *)gp->g_chans[gp->g_rot];
+       }
+       if (gp)
+               rmdata(gp);
+out:
+       return((struct chan *)gp);
+}
+
+rmdata(cp)
+register struct chan *cp;
+{
+register struct group *gp;
+register short x;
+
+       gp = cp->c_group;
+       x = cp->c_index;
+
+       while (gp) {
+               gp->g_datq &= ~cmask[x];
+               if (gp->g_datq)
+                       return;
+               x = gp->g_index;
+               gp = gp->g_group;
+       }
+}
+
+
+
+
+
+mcrint(c, tp)
+struct tty *tp;
+{
+}
+
+mcxint(tp)
+struct tty *tp;
+{
+}
+prstuff(s,cc)
+register char *s;
+register cc;
+{
+       while (cc--)
+               printf("%o ",*s++&0377);
+}
+
+prascii(s, cc)
+register char *s;
+register cc;
+{
+register c;
+       while (cc--) {
+               c = *s++;
+               if (c>=040 && c<=0176)
+                       putchar(c); else
+                       printf(" %o ", c&0377);
+       }
+}
diff --git a/usr/src/sys/sys/nami.c b/usr/src/sys/sys/nami.c
new file mode 100644 (file)
index 0000000..b310575
--- /dev/null
@@ -0,0 +1,224 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/inode.h"
+#include "../h/mount.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/buf.h"
+
+/*
+ * Convert a pathname into a pointer to
+ * an inode. Note that the inode is locked.
+ *
+ * func = function called to get next char of name
+ *     &uchar if name is in user space
+ *     &schar if name is in system space
+ * flag = 0 if name is sought
+ *     1 if name is to be created
+ *     2 if name is to be deleted
+ */
+struct inode *
+namei(func, flag)
+int (*func)();
+{
+       register struct inode *dp;
+       register c;
+       register char *cp;
+       struct buf *bp;
+       int i;
+       dev_t d;
+       off_t eo;
+
+       /*
+        * If name starts with '/' start from
+        * root; otherwise start from current dir.
+        */
+
+       dp = u.u_cdir;
+       if((c=(*func)()) == '/')
+               if ((dp = u.u_rdir) == NULL)
+                       dp = rootdir;
+       iget(dp->i_dev, dp->i_number);
+       while(c == '/')
+               c = (*func)();
+       if(c == '\0' && flag != 0)
+               u.u_error = ENOENT;
+
+cloop:
+       /*
+        * Here dp contains pointer
+        * to last component matched.
+        */
+
+       if(u.u_error)
+               goto out;
+       if(c == '\0')
+               return(dp);
+
+       /*
+        * If there is another component,
+        * Gather up name into
+        * users' dir buffer.
+        */
+
+       cp = &u.u_dbuf[0];
+       while (c != '/' && c != '\0' && u.u_error == 0 ) {
+               if (mpxip!=NULL && c=='!')
+                       break;
+               if(cp < &u.u_dbuf[DIRSIZ])
+                       *cp++ = c;
+               c = (*func)();
+       }
+       while(cp < &u.u_dbuf[DIRSIZ])
+               *cp++ = '\0';
+       while(c == '/')
+               c = (*func)();
+       if (c == '!' && mpxip != NULL) {
+               iput(dp);
+               plock(mpxip);
+               mpxip->i_count++;
+               return(mpxip);
+       }
+
+seloop:
+       /*
+        * dp must be a directory and
+        * must have X permission.
+        */
+
+       if((dp->i_mode&IFMT) != IFDIR)
+               u.u_error = ENOTDIR;
+       access(dp, IEXEC);
+       if(u.u_error)
+               goto out;
+
+       /*
+        * set up to search a directory
+        */
+       u.u_offset = 0;
+       u.u_segflg = 1;
+       eo = 0;
+       bp = NULL;
+
+eloop:
+
+       /*
+        * If at the end of the directory,
+        * the search failed. Report what
+        * is appropriate as per flag.
+        */
+
+       if(u.u_offset >= dp->i_size) {
+               if(bp != NULL)
+                       brelse(bp);
+               if(flag==1 && c=='\0') {
+                       if(access(dp, IWRITE))
+                               goto out;
+                       u.u_pdir = dp;
+                       if(eo)
+                               u.u_offset = eo-sizeof(struct direct);
+                       else
+                               dp->i_flag |= IUPD|ICHG;
+                       return(NULL);
+               }
+               u.u_error = ENOENT;
+               goto out;
+       }
+
+       /*
+        * If offset is on a block boundary,
+        * read the next directory block.
+        * Release previous if it exists.
+        */
+
+       if((u.u_offset&BMASK) == 0) {
+               if(bp != NULL)
+                       brelse(bp);
+               bp = bread(dp->i_dev,
+                       bmap(dp, (daddr_t)(u.u_offset>>BSHIFT), B_READ));
+               if (bp->b_flags & B_ERROR) {
+                       brelse(bp);
+                       goto out;
+               }
+       }
+
+       /*
+        * Note first empty directory slot
+        * in eo for possible creat.
+        * String compare the directory entry
+        * and the current component.
+        * If they do not match, go back to eloop.
+        */
+
+       bcopy(bp->b_un.b_addr+(u.u_offset&BMASK), (caddr_t)&u.u_dent,
+               sizeof(struct direct));
+       u.u_offset += sizeof(struct direct);
+       if(u.u_dent.d_ino == 0) {
+               if(eo == 0)
+                       eo = u.u_offset;
+               goto eloop;
+       }
+       for(i=0; i<DIRSIZ; i++)
+               if(u.u_dbuf[i] != u.u_dent.d_name[i])
+                       goto eloop;
+
+       /*
+        * Here a component matched in a directory.
+        * If there is more pathname, go back to
+        * cloop, otherwise return.
+        */
+
+       if(bp != NULL)
+               brelse(bp);
+       if(flag==2 && c=='\0') {
+               if(access(dp, IWRITE))
+                       goto out;
+               return(dp);
+       }
+       d = dp->i_dev;
+       if(u.u_dent.d_ino == ROOTINO)
+       if(dp->i_number == ROOTINO)
+       if(u.u_dent.d_name[1] == '.')
+               for(i=1; i<NMOUNT; i++)
+                       if(mount[i].m_bufp != NULL)
+                       if(mount[i].m_dev == d) {
+                               iput(dp);
+                               dp = mount[i].m_inodp;
+                               dp->i_count++;
+                               plock(dp);
+                               goto seloop;
+                       }
+       iput(dp);
+       dp = iget(d, u.u_dent.d_ino);
+       if(dp == NULL)
+               return(NULL);
+       goto cloop;
+
+out:
+       iput(dp);
+       return(NULL);
+}
+
+/*
+ * Return the next character from the
+ * kernel string pointed at by dirp.
+ */
+schar()
+{
+
+       return(*u.u_dirp++ & 0377);
+}
+
+/*
+ * Return the next character from the
+ * user string pointed at by dirp.
+ */
+uchar()
+{
+       register c;
+
+       c = fubyte(u.u_dirp++);
+       if(c == -1)
+               u.u_error = EFAULT;
+       return(c);
+}
diff --git a/usr/src/sys/sys/partab.c b/usr/src/sys/sys/partab.c
new file mode 100644 (file)
index 0000000..44628c4
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ */
+
+char partab[] = {
+       0001,0201,0201,0001,0201,0001,0001,0201,
+       0202,0004,0003,0201,0005,0206,0201,0001,
+       0201,0001,0001,0201,0001,0201,0201,0001,
+       0001,0201,0201,0001,0201,0001,0001,0201,
+       0200,0000,0000,0200,0000,0200,0200,0000,
+       0000,0200,0200,0000,0200,0000,0000,0200,
+       0000,0200,0200,0000,0200,0000,0000,0200,
+       0200,0000,0000,0200,0000,0200,0200,0000,
+       0200,0000,0000,0200,0000,0200,0200,0000,
+       0000,0200,0200,0000,0200,0000,0000,0200,
+       0000,0200,0200,0000,0200,0000,0000,0200,
+       0200,0000,0000,0200,0000,0200,0200,0000,
+       0000,0200,0200,0000,0200,0000,0000,0200,
+       0200,0000,0000,0200,0000,0200,0200,0000,
+       0200,0000,0000,0200,0000,0200,0200,0000,
+       0000,0200,0200,0000,0200,0000,0000,0201
+};
diff --git a/usr/src/sys/sys/pipe.c b/usr/src/sys/sys/pipe.c
new file mode 100644 (file)
index 0000000..1ca26ba
--- /dev/null
@@ -0,0 +1,216 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/inode.h"
+#include "../h/file.h"
+#include "../h/reg.h"
+
+/*
+ * Max allowable buffering per pipe.
+ * This is also the max size of the
+ * file created to implement the pipe.
+ * If this size is bigger than 5120,
+ * pipes will be implemented with large
+ * files, which is probably not good.
+ */
+#define        PIPSIZ  4096
+
+/*
+ * The sys-pipe entry.
+ * Allocate an inode on the root device.
+ * Allocate 2 file structures.
+ * Put it all together with flags.
+ */
+pipe()
+{
+       register struct inode *ip;
+       register struct file *rf, *wf;
+       int r;
+
+       ip = ialloc(pipedev);
+       if(ip == NULL)
+               return;
+       rf = falloc();
+       if(rf == NULL) {
+               iput(ip);
+               return;
+       }
+       r = u.u_r.r_val1;
+       wf = falloc();
+       if(wf == NULL) {
+               rf->f_count = 0;
+               u.u_ofile[r] = NULL;
+               iput(ip);
+               return;
+       }
+       u.u_r.r_val2 = u.u_r.r_val1;
+       u.u_r.r_val1 = r;
+       wf->f_flag = FWRITE|FPIPE;
+       wf->f_inode = ip;
+       rf->f_flag = FREAD|FPIPE;
+       rf->f_inode = ip;
+       ip->i_count = 2;
+       ip->i_mode = IFREG;
+       ip->i_flag = IACC|IUPD|ICHG;
+}
+
+/*
+ * Read call directed to a pipe.
+ */
+readp(fp)
+register struct file *fp;
+{
+       register struct inode *ip;
+
+       ip = fp->f_inode;
+
+loop:
+       /*
+        * Very conservative locking.
+        */
+
+       plock(ip);
+       /*
+        * If nothing in the pipe, wait.
+        */
+       if (ip->i_size == 0) {
+               /*
+                * If there are not both reader and
+                * writer active, return without
+                * satisfying read.
+                */
+               prele(ip);
+               if(ip->i_count < 2)
+                       return;
+               ip->i_mode |= IREAD;
+               sleep((caddr_t)ip+2, PPIPE);
+               goto loop;
+       }
+
+       /*
+        * Read and return
+        */
+
+       u.u_offset = fp->f_un.f_offset;
+       readi(ip);
+       fp->f_un.f_offset = u.u_offset;
+       /*
+        * If reader has caught up with writer, reset
+        * offset and size to 0.
+        */
+       if (fp->f_un.f_offset == ip->i_size) {
+               fp->f_un.f_offset = 0;
+               ip->i_size = 0;
+               if(ip->i_mode & IWRITE) {
+                       ip->i_mode &= ~IWRITE;
+                       wakeup((caddr_t)ip+1);
+               }
+       }
+       prele(ip);
+}
+
+/*
+ * Write call directed to a pipe.
+ */
+writep(fp)
+register struct file *fp;
+{
+       register c;
+       register struct inode *ip;
+
+       ip = fp->f_inode;
+       c = u.u_count;
+
+loop:
+
+       /*
+        * If all done, return.
+        */
+
+       plock(ip);
+       if(c == 0) {
+               prele(ip);
+               u.u_count = 0;
+               return;
+       }
+
+       /*
+        * If there are not both read and
+        * write sides of the pipe active,
+        * return error and signal too.
+        */
+
+       if(ip->i_count < 2) {
+               prele(ip);
+               u.u_error = EPIPE;
+               psignal(u.u_procp, SIGPIPE);
+               return;
+       }
+
+       /*
+        * If the pipe is full,
+        * wait for reads to deplete
+        * and truncate it.
+        */
+
+       if(ip->i_size >= PIPSIZ) {
+               ip->i_mode |= IWRITE;
+               prele(ip);
+               sleep((caddr_t)ip+1, PPIPE);
+               goto loop;
+       }
+
+       /*
+        * Write what is possible and
+        * loop back.
+        * If writing less than PIPSIZ, it always goes.
+        * One can therefore get a file > PIPSIZ if write
+        * sizes do not divide PIPSIZ.
+        */
+
+       u.u_offset = ip->i_size;
+       u.u_count = min((unsigned)c, (unsigned)PIPSIZ);
+       c -= u.u_count;
+       writei(ip);
+       prele(ip);
+       if(ip->i_mode&IREAD) {
+               ip->i_mode &= ~IREAD;
+               wakeup((caddr_t)ip+2);
+       }
+       goto loop;
+}
+
+/*
+ * Lock a pipe.
+ * If its already locked,
+ * set the WANT bit and sleep.
+ */
+plock(ip)
+register struct inode *ip;
+{
+
+       while(ip->i_flag&ILOCK) {
+               ip->i_flag |= IWANT;
+               sleep((caddr_t)ip, PINOD);
+       }
+       ip->i_flag |= ILOCK;
+}
+
+/*
+ * Unlock a pipe.
+ * If WANT bit is on,
+ * wakeup.
+ * This routine is also used
+ * to unlock inodes in general.
+ */
+prele(ip)
+register struct inode *ip;
+{
+
+       ip->i_flag &= ~ILOCK;
+       if(ip->i_flag&IWANT) {
+               ip->i_flag &= ~IWANT;
+               wakeup((caddr_t)ip);
+       }
+}
diff --git a/usr/src/sys/sys/prf.c b/usr/src/sys/sys/prf.c
new file mode 100644 (file)
index 0000000..842897d
--- /dev/null
@@ -0,0 +1,116 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/seg.h"
+#include "../h/buf.h"
+#include "../h/conf.h"
+
+/*
+ * In case console is off,
+ * panicstr contains argument to last
+ * call to panic.
+ */
+
+char   *panicstr;
+
+/*
+ * Scaled down version of C Library printf.
+ * Only %s %u %d (==%u) %o %x %D are recognized.
+ * Used to print diagnostic information
+ * directly on console tty.
+ * Since it is not interrupt driven,
+ * all system activities are pretty much
+ * suspended.
+ * Printf should not be used for chit-chat.
+ */
+/* VARARGS */
+printf(fmt, x1)
+register char *fmt;
+unsigned x1;
+{
+       register c;
+       register unsigned int *adx;
+       char *s;
+
+       adx = &x1;
+loop:
+       while((c = *fmt++) != '%') {
+               if(c == '\0')
+                       return;
+               putchar(c);
+       }
+       c = *fmt++;
+       if(c == 'd' || c == 'u' || c == 'o' || c == 'x')
+               printn((long)*adx, c=='o'? 8: (c=='x'? 16:10));
+       else if(c == 's') {
+               s = (char *)*adx;
+               while(c = *s++)
+                       putchar(c);
+       } else if (c == 'D') {
+               printn(*(long *)adx, 10);
+               adx += (sizeof(long) / sizeof(int)) - 1;
+       }
+       adx++;
+       goto loop;
+}
+
+/*
+ * Print an unsigned integer in base b.
+ */
+printn(n, b)
+long n;
+{
+       register long a;
+
+       if (n<0) {      /* shouldn't happen */
+               putchar('-');
+               n = -n;
+       }
+       if(a = n/b)
+               printn(a, b);
+       putchar("0123456789ABCDEF"[(int)(n%b)]);
+}
+
+/*
+ * Panic is called on unresolvable
+ * fatal errors.
+ * It syncs, prints "panic: mesg" and
+ * then loops.
+ */
+panic(s)
+char *s;
+{
+       panicstr = s;
+       update();
+       printf("panic: %s\n", s);
+       for(;;)
+               idle();
+}
+
+/*
+ * prdev prints a warning message of the
+ * form "mesg on dev x/y".
+ * x and y are the major and minor parts of
+ * the device argument.
+ */
+prdev(str, dev)
+char *str;
+dev_t dev;
+{
+
+       printf("%s on dev %u/%u\n", str, major(dev), minor(dev));
+}
+
+/*
+ * deverr prints a diagnostic from
+ * a device driver.
+ * It prints the device, block number,
+ * and an octal word (usually some error
+ * status register) passed as argument.
+ */
+deverror(bp, o1, o2)
+register struct buf *bp;
+{
+
+       prdev("err", bp->b_dev);
+       printf("bn=%d er=%x,%x\n", bp->b_blkno, o1,o2);
+}
diff --git a/usr/src/sys/sys/prim.c b/usr/src/sys/sys/prim.c
new file mode 100644 (file)
index 0000000..954f9e6
--- /dev/null
@@ -0,0 +1,230 @@
+#include "../h/param.h"
+#include "../h/tty.h"
+#include "../h/systm.h"
+#include "../h/conf.h"
+#include "../h/buf.h"
+
+struct cblock {
+       struct cblock *c_next;
+       char    c_info[CBSIZE];
+};
+
+struct cblock  cfree[NCLIST];
+struct cblock  *cfreelist;
+
+/*
+ * Character list get/put
+ */
+getc(p)
+register struct clist *p;
+{
+       register struct cblock *bp;
+       register int c, s;
+
+       s = spl6();
+       if (p->c_cc <= 0) {
+               c = -1;
+               p->c_cc = 0;
+               p->c_cf = p->c_cl = NULL;
+       } else {
+               c = *p->c_cf++ & 0377;
+               if (--p->c_cc<=0) {
+                       bp = (struct cblock *)(p->c_cf-1);
+                       bp = (struct cblock *) ((int)bp & ~CROUND);
+                       p->c_cf = NULL;
+                       p->c_cl = NULL;
+                       bp->c_next = cfreelist;
+                       cfreelist = bp;
+               } else if (((int)p->c_cf & CROUND) == 0){
+                       bp = (struct cblock *)(p->c_cf);
+                       bp--;
+                       p->c_cf = bp->c_next->c_info;
+                       bp->c_next = cfreelist;
+                       cfreelist = bp;
+               }
+       }
+       splx(s);
+       return(c);
+}
+
+/*
+ * copy clist to buffer.
+ * return number of bytes moved.
+ */
+q_to_b(q, cp, cc)
+register struct clist *q;
+register char *cp;
+{
+       register struct cblock *bp;
+       register int s;
+       char *acp;
+
+       if (cc <= 0)
+               return(0);
+       s = spl6();
+       if (q->c_cc <= 0) {
+               q->c_cc = 0;
+               q->c_cf = q->c_cl = NULL;
+               return(0);
+       }
+       acp = cp;
+       cc++;
+
+       while (--cc) {
+               *cp++ = *q->c_cf++;
+               if (--q->c_cc <= 0) {
+                       bp = (struct cblock *)(q->c_cf-1);
+                       bp = (struct cblock *)((int)bp & ~CROUND);
+                       q->c_cf = q->c_cl = NULL;
+                       bp->c_next = cfreelist;
+                       cfreelist = bp;
+                       break;
+               }
+               if (((int)q->c_cf & CROUND) == 0) {
+                       bp = (struct cblock *)(q->c_cf);
+                       bp--;
+                       q->c_cf = bp->c_next->c_info;
+                       bp->c_next = cfreelist;
+                       cfreelist = bp;
+               }
+       }
+       splx(s);
+       return(cp-acp);
+}
+
+putc(c, p)
+register struct clist *p;
+{
+       register struct cblock *bp;
+       register char *cp;
+       register s;
+
+       s = spl6();
+       if ((cp = p->c_cl) == NULL || p->c_cc < 0 ) {
+               if ((bp = cfreelist) == NULL) {
+                       splx(s);
+                       return(-1);
+               }
+               cfreelist = bp->c_next;
+               bp->c_next = NULL;
+               p->c_cf = cp = bp->c_info;
+       } else if (((int)cp & CROUND) == 0) {
+               bp = (struct cblock *)cp - 1;
+               if ((bp->c_next = cfreelist) == NULL) {
+                       splx(s);
+                       return(-1);
+               }
+               bp = bp->c_next;
+               cfreelist = bp->c_next;
+               bp->c_next = NULL;
+               cp = bp->c_info;
+       }
+       *cp++ = c;
+       p->c_cc++;
+       p->c_cl = cp;
+       splx(s);
+       return(0);
+}
+
+
+
+/*
+ * copy buffer to clist.
+ * return number of bytes not transfered.
+ */
+b_to_q(cp, cc, q)
+register char *cp;
+struct clist *q;
+register int cc;
+{
+       register char *cq;
+       register struct cblock *bp;
+       register s, acc;
+
+       if (cc <= 0)
+               return(0);
+       acc = cc;
+
+
+       s = spl6();
+       if ((cq = q->c_cl) == NULL || q->c_cc < 0) {
+               if ((bp = cfreelist) == NULL) 
+                       goto out;
+               cfreelist = bp->c_next;
+               bp->c_next = NULL;
+               q->c_cf = cq = bp->c_info;
+       }
+
+       while (cc) {
+               if (((int)cq & CROUND) == 0) {
+                       bp = (struct cblock *) cq - 1;
+                       if ((bp->c_next = cfreelist) == NULL) 
+                               goto out;
+                       bp = bp->c_next;
+                       cfreelist = bp->c_next;
+                       bp->c_next = NULL;
+                       cq = bp->c_info;
+               }
+               *cq++ = *cp++;
+               cc--;
+       }
+out:
+       q->c_cl = cq;
+       q->c_cc += acc-cc;
+       splx(s);
+       return(cc);
+}
+
+/*
+ * Initialize clist by freeing all character blocks, then count
+ * number of character devices. (Once-only routine)
+ */
+cinit()
+{
+       register int ccp;
+       register struct cblock *cp;
+       register struct cdevsw *cdp;
+
+       ccp = (int)cfree;
+       ccp = (ccp+CROUND) & ~CROUND;
+       for(cp=(struct cblock *)ccp; cp <= &cfree[NCLIST-1]; cp++) {
+               cp->c_next = cfreelist;
+               cfreelist = cp;
+       }
+       ccp = 0;
+       for(cdp = cdevsw; cdp->d_open; cdp++)
+               ccp++;
+       nchrdev = ccp;
+}
+
+
+/*
+ * integer (2-byte) get/put
+ * using clists
+ */
+getw(p)
+register struct clist *p;
+{
+       register int s;
+
+       if (p->c_cc <= 1)
+               return(-1);
+       s = getc(p);
+       return(s | (getc(p)<<8));
+}
+
+putw(c, p)
+register struct clist *p;
+{
+       register s;
+
+       s = spl6();
+       if (cfreelist==NULL) {
+               splx(s);
+               return(-1);
+       }
+       putc(c, p);
+       putc(c>>8, p);
+       splx(s);
+       return(0);
+}
diff --git a/usr/src/sys/sys/rdwri.c b/usr/src/sys/sys/rdwri.c
new file mode 100644 (file)
index 0000000..6c6deee
--- /dev/null
@@ -0,0 +1,194 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/inode.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/buf.h"
+#include "../h/conf.h"
+
+/*
+ * Read the file corresponding to
+ * the inode pointed at by the argument.
+ * The actual read arguments are found
+ * in the variables:
+ *     u_base          core address for destination
+ *     u_offset        byte offset in file
+ *     u_count         number of bytes to read
+ *     u_segflg        read to kernel/user/user I
+ */
+readi(ip)
+register struct inode *ip;
+{
+       struct buf *bp;
+       dev_t dev;
+       daddr_t lbn, bn;
+       off_t diff;
+       register on, n;
+       register type;
+       extern int mem_no;
+
+       if(u.u_count == 0)
+               return;
+       dev = (dev_t)ip->i_un.i_rdev;
+       if(u.u_offset < 0 && ((ip->i_mode&IFMT) != IFCHR || mem_no != major(dev)) ) {
+               u.u_error = EINVAL;
+               return;
+       }
+       ip->i_flag |= IACC;
+       type = ip->i_mode&IFMT;
+       if (type==IFCHR || type==IFMPC) {
+               return((*cdevsw[major(dev)].d_read)(dev));
+       }
+
+       do {
+               lbn = bn = u.u_offset >> BSHIFT;
+               on = u.u_offset & BMASK;
+               n = min((unsigned)(BSIZE-on), u.u_count);
+               if (type!=IFBLK && type!=IFMPB) {
+                       diff = ip->i_size - u.u_offset;
+                       if(diff <= 0)
+                               return;
+                       if(diff < n)
+                               n = diff;
+                       bn = bmap(ip, bn, B_READ);
+                       if(u.u_error)
+                               return;
+                       dev = ip->i_dev;
+               } else
+                       rablock = bn+1;
+               if ((long)bn<0) {
+                       bp = geteblk();
+                       clrbuf(bp);
+               } else if (ip->i_un.i_lastr+1==lbn)
+                       bp = breada(dev, bn, rablock);
+               else
+                       bp = bread(dev, bn);
+               ip->i_un.i_lastr = lbn;
+               n = min((unsigned)n, BSIZE-bp->b_resid);
+               if (n!=0)
+                       iomove(bp->b_un.b_addr+on, n, B_READ);
+               brelse(bp);
+       } while(u.u_error==0 && u.u_count!=0 && n>0);
+}
+
+/*
+ * Write the file corresponding to
+ * the inode pointed at by the argument.
+ * The actual write arguments are found
+ * in the variables:
+ *     u_base          core address for source
+ *     u_offset        byte offset in file
+ *     u_count         number of bytes to write
+ *     u_segflg        write to kernel/user/user I
+ */
+writei(ip)
+register struct inode *ip;
+{
+       struct buf *bp;
+       dev_t dev;
+       daddr_t bn;
+       register n, on;
+       register type;
+       extern int mem_no;
+
+       dev = (dev_t)ip->i_un.i_rdev;
+       if(u.u_offset < 0 && ((ip->i_mode&IFMT) != IFCHR || mem_no != major(dev)) ) {
+               u.u_error = EINVAL;
+               return;
+       }
+       type = ip->i_mode&IFMT;
+       if (type==IFCHR || type==IFMPC) {
+               ip->i_flag |= IUPD|ICHG;
+               (*cdevsw[major(dev)].d_write)(dev);
+               return;
+       }
+       if (u.u_count == 0)
+               return;
+
+       do {
+               bn = u.u_offset >> BSHIFT;
+               on = u.u_offset & BMASK;
+               n = min((unsigned)(BSIZE-on), u.u_count);
+               if (type!=IFBLK && type!=IFMPB) {
+                       bn = bmap(ip, bn, B_WRITE);
+                       if((long)bn<0)
+                               return;
+                       dev = ip->i_dev;
+               }
+               if(n == BSIZE) 
+                       bp = getblk(dev, bn);
+               else
+                       bp = bread(dev, bn);
+               iomove(bp->b_un.b_addr+on, n, B_WRITE);
+               if(u.u_error != 0)
+                       brelse(bp);
+               else
+                       bdwrite(bp);
+               if(u.u_offset > ip->i_size &&
+                  (type==IFDIR || type==IFREG))
+                       ip->i_size = u.u_offset;
+               ip->i_flag |= IUPD|ICHG;
+       } while(u.u_error==0 && u.u_count!=0);
+}
+
+/*
+ * Return the logical maximum
+ * of the 2 arguments.
+ */
+max(a, b)
+unsigned a, b;
+{
+
+       if(a > b)
+               return(a);
+       return(b);
+}
+
+/*
+ * Return the logical minimum
+ * of the 2 arguments.
+ */
+min(a, b)
+unsigned a, b;
+{
+
+       if(a < b)
+               return(a);
+       return(b);
+}
+
+/*
+ * Move n bytes at byte location
+ * &bp->b_un.b_addr[o] to/from (flag) the
+ * user/kernel (u.segflg) area starting at u.base.
+ * Update all the arguments by the number
+ * of bytes moved.
+ */
+iomove(cp, n, flag)
+register caddr_t cp;
+register n;
+{
+       register t;
+
+       if (n==0)
+               return;
+       if(u.u_segflg != 1)  {
+               if (flag==B_WRITE)
+                       t = copyin(u.u_base, (caddr_t)cp, n);
+               else
+                       t = copyout((caddr_t)cp, u.u_base, n);
+               if (t) {
+                       u.u_error = EFAULT;
+                       return;
+               }
+       }
+       else
+               if (flag == B_WRITE)
+                       bcopy(u.u_base,(caddr_t)cp,n);
+               else
+                       bcopy((caddr_t)cp,u.u_base,n);
+       u.u_base += n;
+       u.u_offset += n;
+       u.u_count -= n;
+       return;
+}
diff --git a/usr/src/sys/sys/sig.c b/usr/src/sys/sys/sig.c
new file mode 100644 (file)
index 0000000..97daee3
--- /dev/null
@@ -0,0 +1,412 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/proc.h"
+#include "../h/inode.h"
+#include "../h/reg.h"
+#include "../h/text.h"
+#include "../h/seg.h"
+#include "../h/mtpr.h"
+#include "../h/page.h"
+#include "../h/psl.h"
+
+/*
+ * Priority for tracing
+ */
+#define        IPCPRI  PZERO
+
+/*
+ * Tracing variables.
+ * Used to pass trace command from
+ * parent to child being traced.
+ * This data base cannot be
+ * shared and is locked
+ * per user.
+ */
+struct
+{
+       int     ip_lock;
+       int     ip_req;
+       int     *ip_addr;
+       int     ip_data;
+} ipc;
+
+/*
+ * Send the specified signal to
+ * all processes with 'pgrp' as
+ * process group.
+ * Called by tty.c for quits and
+ * interrupts.
+ */
+signal(pgrp, sig)
+register pgrp;
+{
+       register struct proc *p;
+
+       if(pgrp == 0)
+               return;
+       for(p = &proc[0]; p < &proc[NPROC]; p++)
+               if(p->p_pgrp == pgrp)
+                       psignal(p, sig);
+}
+
+/*
+ * Send the specified signal to
+ * the specified process.
+ */
+psignal(p, sig)
+register struct proc *p;
+register unsigned sig;
+{
+
+       if((unsigned)sig >= NSIG)
+               return;
+       if(sig)
+               p->p_sig |= 1<<(sig-1);
+       if(p->p_pri > PUSER)
+               p->p_pri = PUSER;
+       if(p->p_stat == SSLEEP && p->p_pri > PZERO)
+               setrun(p);
+}
+
+/*
+ * Returns true if the current
+ * process has a signal to process.
+ * This is asked at least once
+ * each time a process enters the
+ * system.
+ * A signal does not do anything
+ * directly to a process; it sets
+ * a flag that asks the process to
+ * do something to itself.
+ */
+issig()
+{
+       register n;
+       register struct proc *p;
+
+       p = u.u_procp;
+       while(p->p_sig) {
+               n = fsig(p);
+               if((u.u_signal[n]&1) == 0 || (p->p_flag&STRC))
+                       return(n);
+               p->p_sig &= ~(1<<(n-1));
+       }
+       return(0);
+}
+
+/*
+ * Enter the tracing STOP state.
+ * In this state, the parent is
+ * informed and the process is able to
+ * receive commands from the parent.
+ */
+stop()
+{
+       register struct proc *pp, *cp;
+
+loop:
+       cp = u.u_procp;
+       if(cp->p_ppid != 1)
+       for (pp = &proc[0]; pp < &proc[NPROC]; pp++)
+               if (pp->p_pid == cp->p_ppid) {
+                       wakeup((caddr_t)pp);
+                       cp->p_stat = SSTOP;
+                       swtch();
+                       if ((cp->p_flag&STRC)==0 || procxmt())
+                               return;
+                       goto loop;
+               }
+       exit(fsig(u.u_procp));
+}
+
+/*
+ * Perform the action specified by
+ * the current signal.
+ * The usual sequence is:
+ *     if(issig())
+ *             psig();
+ */
+psig()
+{
+       register n, p;
+       register struct proc *rp;
+
+       rp = u.u_procp;
+       if (rp->p_flag&STRC)
+               stop();
+       n = fsig(rp);
+       if (n==0)
+               return;
+       rp->p_sig &= ~(1<<(n-1));
+       if((p=u.u_signal[n]) != 0) {
+               u.u_error = 0;
+               if(n != SIGINS && n != SIGTRC)
+                       u.u_signal[n] = 0;
+               sendsig(p, n);
+               return;
+       }
+       switch(n) {
+
+       case SIGQUIT:
+       case SIGINS:
+       case SIGTRC:
+       case SIGIOT:
+       case SIGEMT:
+       case SIGFPT:
+       case SIGBUS:
+       case SIGSEG:
+       case SIGSYS:
+               if(core())
+                       n += 0200;
+       }
+       exit(n);
+}
+
+/*
+ * find the signal in bit-position
+ * representation in p_sig.
+ */
+fsig(p)
+struct proc *p;
+{
+       register n, i;
+
+       n = p->p_sig;
+       for(i=1; i<NSIG; i++) {
+               if(n & 1)
+                       return(i);
+               n >>= 1;
+       }
+       return(0);
+}
+
+/*
+ * Create a core image on the file "core"
+ * If you are looking for protection glitches,
+ * there are probably a wealth of them here
+ * when this occurs to a suid command.
+ *
+ * It writes USIZE block of the
+ * user.h area followed by the entire
+ * data+stack segments.
+ */
+core()
+{
+       register struct inode *ip;
+       register s;
+       extern schar();
+
+       u.u_error = 0;
+       u.u_dirp = "core";
+       ip = namei(schar, 1);
+       if(ip == NULL) {
+               if(u.u_error)
+                       return(0);
+               ip = maknode(0666);
+               if (ip==NULL)
+                       return(0);
+       }
+       if(!access(ip, IWRITE) &&
+          (ip->i_mode&IFMT) == IFREG &&
+          u.u_uid == u.u_ruid) {
+               itrunc(ip);
+               u.u_offset = 0;
+               u.u_base = (caddr_t)&u;
+               u.u_count = ctob(USIZE);
+               u.u_segflg = 1;
+               writei(ip);
+               u.u_base = (char *)ctob(u.u_tsize);
+               u.u_count = ctob(u.u_dsize);
+               u.u_segflg = 0;
+               writei(ip);
+               u.u_base = (char *)(0x80000000 - ctob(u.u_ssize));
+               u.u_count = ctob(u.u_ssize);
+               writei(ip);
+       }
+       iput(ip);
+       return(u.u_error==0);
+}
+
+/*
+ * grow the stack to include the SP
+ * true return if successful.
+ */
+
+grow(sp)
+unsigned sp;
+{
+       register si, i;
+       register struct proc *p;
+
+       if(sp >= USRSTACK-ctob(u.u_ssize))
+               return(0);
+       mtpr(TBIS, sp);
+       mtpr(TBIS, ((int *)&u) + 128*USIZE - u.u_ssize - 1);
+       si = btoc((USRSTACK-sp)) - u.u_ssize + SINCR;
+       if(si <= 0)
+               return(0);
+       if(chksize(u.u_tsize, u.u_dsize, u.u_ssize+si))
+               return(0);
+       p = u.u_procp;
+       u.u_ssize += si;
+       expand(si, P1BR);
+       for(i=si; --i>=0;)
+               clearseg(((int *)&u)[128*USIZE - u.u_ssize + i] & PG_PFNUM);
+       return(1);
+}
+
+/*
+ * sys-trace system call.
+ */
+ptrace()
+{
+       register struct proc *p;
+       register struct a {
+               int     req;
+               int     pid;
+               int     *addr;
+               int     data;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       if (uap->req <= 0) {
+               u.u_procp->p_flag |= STRC;
+               return;
+       }
+       for (p=proc; p < &proc[NPROC]; p++) 
+               if (p->p_stat==SSTOP
+                && p->p_pid==uap->pid
+                && p->p_ppid==u.u_procp->p_pid)
+                       goto found;
+       u.u_error = ESRCH;
+       return;
+
+    found:
+       while (ipc.ip_lock)
+               sleep((caddr_t)&ipc, IPCPRI);
+       ipc.ip_lock = p->p_pid;
+       ipc.ip_data = uap->data;
+       ipc.ip_addr = uap->addr;
+       ipc.ip_req = uap->req;
+       p->p_flag &= ~SWTED;
+       setrun(p);
+       while (ipc.ip_req > 0)
+               sleep((caddr_t)&ipc, IPCPRI);
+       u.u_r.r_val1 = ipc.ip_data;
+       if (ipc.ip_req < 0)
+               u.u_error = EIO;
+       ipc.ip_lock = 0;
+       wakeup((caddr_t)&ipc);
+}
+
+int ipcreg[] = {R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, AP, FP, SP, PC};
+/*
+ * Code that the child process
+ * executes to implement the command
+ * of the parent process in tracing.
+ */
+procxmt()
+{
+       register int i;
+       register *p;
+       register struct text *xp;
+
+       if (ipc.ip_lock != u.u_procp->p_pid)
+               return(0);
+       i = ipc.ip_req;
+       ipc.ip_req = 0;
+       wakeup((caddr_t)&ipc);
+       switch (i) {
+
+       /* read user I */
+       case 1:
+               if ( !useracc((caddr_t)ipc.ip_addr, 4, 1))
+                       goto error;
+               ipc.ip_data = fuiword((caddr_t)ipc.ip_addr);
+               break;
+
+       /* read user D */
+       case 2:
+               if ( !useracc((caddr_t)ipc.ip_addr, 4, 1))
+                       goto error;
+               ipc.ip_data = fuword((caddr_t)ipc.ip_addr);
+               break;
+
+       /* read u */
+       case 3:
+               i = (int)ipc.ip_addr;
+               if (i<0 || i >= ctob(USIZE))
+                       goto error;
+               ipc.ip_data = ((physadr)&u)->r[i>>2];
+               break;
+
+       /* write user I */
+       /* Must set up to allow writing */
+       case 4:
+               /*
+                * If text, must assure exclusive use
+                */
+               if (xp = u.u_procp->p_textp) {
+                       if (xp->x_count!=1 || xp->x_iptr->i_mode&ISVTX)
+                               goto error;
+                       xp->x_iptr->i_flag &= ~ITEXT;
+               }
+               chgprot(RW, 0, 0);
+               i = suiword((caddr_t)ipc.ip_addr, 0);
+               suiword((caddr_t)ipc.ip_addr, ipc.ip_data);
+               chgprot(RO, 0, 0);
+               if (i<0)
+                       goto error;
+               if (xp)
+                       xp->x_flag |= XWRIT;
+               break;
+
+       /* write user D */
+       case 5:
+               if (suword((caddr_t)ipc.ip_addr, 0) < 0)
+                       goto error;
+               suword((caddr_t)ipc.ip_addr, ipc.ip_data);
+               break;
+
+       /* write u */
+       case 6:
+               i = (int)ipc.ip_addr;
+               p = (int *)&((physadr)&u)->r[i>>2];
+               for (i=0; i<16; i++)
+                       if (p == &u.u_ar0[ipcreg[i]])
+                               goto ok;
+               if (p == &u.u_ar0[PS]) {
+                       ipc.ip_data |= 0x3c00000; /* modes == user */
+                       ipc.ip_data &=  ~0x3c20ff00; /* IS, FPD,  ... */
+                       goto ok;
+               }
+               goto error;
+
+       ok:
+               *p = ipc.ip_data;
+               break;
+
+       /* set signal and continue */
+       /*  one version causes a trace-trap */
+       case 9:
+               u.u_ar0[PS] |= PSL_T;
+       case 7:
+               if ((int)ipc.ip_addr != 1)
+                       u.u_ar0[PC] = (int)ipc.ip_addr;
+               u.u_procp->p_sig = 0;
+               if (ipc.ip_data)
+                       psignal(u.u_procp, ipc.ip_data);
+               return(1);
+
+       /* force exit */
+       case 8:
+               exit(fsig(u.u_procp));
+
+       default:
+       error:
+               ipc.ip_req = -1;
+       }
+       return(0);
+}
diff --git a/usr/src/sys/sys/slp.c b/usr/src/sys/sys/slp.c
new file mode 100644 (file)
index 0000000..ea50d98
--- /dev/null
@@ -0,0 +1,663 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/proc.h"
+#include "../h/text.h"
+#include "../h/uba.h"
+#include "../h/map.h"
+#include "../h/file.h"
+#include "../h/inode.h"
+#include "../h/buf.h"
+#include "../h/page.h"
+#include "../h/mtpr.h"
+
+/*
+ * Give up the processor till a wakeup occurs
+ * on chan, at which time the process
+ * enters the scheduling queue at priority pri.
+ * The most important effect of pri is that when
+ * pri<=PZERO a signal cannot disturb the sleep;
+ * if pri>PZERO signals will be processed.
+ * Callers of this routine must be prepared for
+ * premature return, and check that the reason for
+ * sleeping has gone away.
+ */
+sleep(chan, pri)
+caddr_t chan;
+{
+       register struct proc *rp;
+       register s;
+
+       rp = u.u_procp;
+       s = spl6();
+       rp->p_stat = SSLEEP;
+       rp->p_wchan = chan;
+       rp->p_pri = pri;
+       if(pri > PZERO) {
+               if(issig()) {
+                       rp->p_wchan = 0;
+                       rp->p_stat = SRUN;
+                       spl0();
+                       goto psig;
+               }
+               spl0();
+               if(runin != 0) {
+                       runin = 0;
+                       wakeup((caddr_t)&runin);
+               }
+               swtch();
+               if(issig())
+                       goto psig;
+       } else {
+               spl0();
+               swtch();
+       }
+       splx(s);
+       return;
+
+       /*
+        * If priority was low (>PZERO) and
+        * there has been a signal,
+        * execute non-local goto to
+        * the qsav location.
+        * (see trap1/trap.c)
+        */
+psig:
+       resume(u.u_procp->p_addr, u.u_qsav);
+}
+
+/*
+ * Wake up all processes sleeping on chan.
+ */
+wakeup(chan)
+register caddr_t chan;
+{
+       register struct proc *p;
+       register i;
+       int s;
+
+       p = &proc[0];
+       i = NPROC;
+       do {
+               if(p->p_wchan==chan && p->p_stat!=SZOMB) {
+                       /*
+                        * this code looks dumb, but
+                        * there is a possible race due
+                        * to interrupts.
+                        */
+                       s = spl6();
+                       if(p->p_wchan == chan)
+                               setrun(p);
+                       splx(s);
+               }
+               p++;
+       } while(--i);
+}
+
+/*
+ * when you are sure that it
+ * is impossible to get the
+ * 'proc on q' diagnostic, the
+ * diagnostic loop can be removed.
+ */
+setrq(p)
+struct proc *p;
+{
+       register struct proc *q;
+       register s;
+
+       s = spl6();
+       for(q=runq; q!=NULL; q=q->p_link)
+               if(q == p) {
+                       printf("proc on q\n");
+                       goto out;
+               }
+       p->p_link = runq;
+       runq = p;
+out:
+       splx(s);
+}
+
+/*
+ * Set the process running;
+ * arrange for it to be swapped in if necessary.
+ */
+setrun(p)
+register struct proc *p;
+{
+
+       if (p->p_stat==0 || p->p_stat==SZOMB)
+               panic("Running a dead proc");
+       p->p_wchan = 0;
+       p->p_stat = SRUN;
+       setrq(p);
+       if(p->p_pri < curpri)
+               runrun++;
+       if(runout != 0 && (p->p_flag&SLOAD) == 0) {
+               runout = 0;
+               wakeup((caddr_t)&runout);
+       }
+}
+
+/*
+ * Set user priority.
+ * The rescheduling flag (runrun)
+ * is set if the priority is better
+ * than the currently running process.
+ */
+setpri(pp)
+register struct proc *pp;
+{
+       register p;
+
+       p = (pp->p_cpu & 0377)/16;
+       p += PUSER + pp->p_nice - NZERO;
+       if(p > 127)
+               p = 127;
+       if(p < curpri)
+               runrun++;
+       pp->p_pri = p;
+       return(p);
+}
+
+/*
+ * The main loop of the scheduling (swapping)
+ * process.
+ * The basic idea is:
+ *  see if anyone wants to be swapped in;
+ *  swap out processes until there is room;
+ *  swap him in;
+ *  repeat.
+ * The runout flag is set whenever someone is swapped out.
+ * Sched sleeps on it awaiting work.
+ *
+ * Sched sleeps on runin whenever it cannot find enough
+ * core (by swapping out or otherwise) to fit the
+ * selected swapped process.  It is awakened when the
+ * core situation changes and in any case once per second.
+ */
+sched()
+{
+       register struct proc *rp, *p, *inp;
+       register outage, inage,memneed,memleft;
+       int maxsize;
+       extern  int  freemem;
+
+       /*
+        * find user to swap in;
+        * of users ready, select one out longest
+        */
+
+loop:
+       spl6();
+       outage = -20000;
+       for (rp = &proc[0]; rp < &proc[NPROC]; rp++)
+       if (rp->p_stat==SRUN && (rp->p_flag&SLOAD)==0 &&
+           rp->p_time - (rp->p_nice-NZERO)*8 > outage) {
+               p = rp;
+               outage = rp->p_time - (rp->p_nice-NZERO)*8;
+       }
+       /*
+        * If there is no one there, wait.
+        */
+       if (outage == -20000) {
+               runout++;
+               sleep((caddr_t)&runout, PSWP);
+               goto loop;
+       }
+       spl0();
+
+       /*
+        * See if there is core for that process;
+        * if so, swap it in.
+        */
+
+       if (swapin(p))
+               goto loop;
+
+       /*
+        * none found.
+        * look around for core.
+        * Select the largest of those sleeping
+        * at bad priority; if none, select the oldest.
+        */
+
+       spl6();
+       inp = p;                /* we are trying to swap this guy in */
+       p = NULL;
+       maxsize = -1;
+       inage = -1;
+       for (rp = &proc[0]; rp < &proc[NPROC]; rp++) {
+               if (rp->p_stat==SZOMB)
+                       continue;
+               if (rp == inp)
+                       continue;
+               if (rp->p_flag&SSPART) {        /* we have found one partially swapped */
+                       p = rp;
+                       maxsize = 0;
+                       break;
+               }
+               if ((rp->p_flag&(SSYS|SLOCK|SULOCK|SLOAD))!=SLOAD)
+                       continue;
+               if (rp->p_textp && rp->p_textp->x_flag&XLOCK)
+                       continue;
+               if (rp->p_stat==SSLEEP&&rp->p_pri>=PZERO || rp->p_stat==SSTOP) {
+                       if (maxsize < rp->p_size) {
+                               p = rp;
+                               maxsize = rp->p_size;
+                       }
+               } else if (maxsize<0 && (rp->p_stat==SRUN||rp->p_stat==SSLEEP)) {
+                       if (rp->p_time+rp->p_nice-NZERO > inage) {
+                               p = rp;
+                               inage = rp->p_time+rp->p_nice-NZERO;
+                       }
+               }
+       }
+       spl0();
+       /*
+        * Swap found user out if sleeping at bad pri,
+        * or if he has spent at least 2 seconds in core and
+        * the swapped-out process has spent at least 3 seconds out.
+        * Otherwise wait a bit and try again.
+        */
+       if (maxsize>=0 || (outage>=3 && inage>=2)) {
+               p->p_flag &= ~SLOAD;
+               if (inp->p_flag & SSPART)
+                       memneed = inp->p_swsize - UPAGES;
+               else
+                       memneed = inp->p_size;
+               if (inp->p_textp)
+                       if (inp->p_textp->x_ccount == 0)
+                               memneed += inp->p_textp->x_size;
+               memneed -= freemem;             /* amount we must swap out */
+               memneed += 11 + SWAPSIZE - (memneed+11)%SWAPSIZE;
+               memleft = p->p_size;
+               if (p->p_flag & SSPART)
+                       memleft -= p->p_swsize; /* core left */
+               if ((memleft - memneed) < 2*SWAPSIZE)
+                       memneed = memleft;      /* take it all */
+               xswap(p,-memneed,0,-1);
+               goto loop;
+       }
+       spl6();
+       runin++;
+       sleep((caddr_t)&runin, PSWP);
+       goto loop;
+}
+
+/*
+ * Swap a process in.
+ */
+swapin(p)
+register struct proc *p;
+{
+       extern int Swapmap[], swaputl[], Swap2map[], swap2utl[];
+       register struct text *xp;
+       register int i, *ip;
+       int x, pt, tsize, tmem;
+       struct proc *prc;
+
+       if (xp = p->p_textp) {
+               xlock(xp);
+               tsize = xp->x_size;
+               tmem = xp->x_ccount == 0 ? tsize : 0;
+       } else {
+               tsize = p->p_tsize;
+               tmem = 0;
+       }       
+       if ((p->p_flag & SSPART) == 0) {
+               pt = (p->p_size - UPAGES + tsize + 127)/128;    /* number of pages of page table */
+               if (memall(Swapmap,UPAGES + pt) == 0)
+                       goto nomem;
+               for (i=UPAGES+pt; --i>=0; ) {   /* map u-area & page tables */
+                       Swapmap[i] |= PG_V + PG_KW;
+                       mtpr(TBIS, swaputl + (128 * i));
+               }
+               if(memall(&swaputl[(UPAGES*128)+tsize-tmem],p->p_size-UPAGES+tmem)==0){
+                               memfree(Swapmap, UPAGES + pt);  /* free u-area & page tables */
+                               goto nomem;
+               }
+               ip = &swaputl[UPAGES*128];
+               for (i=tmem; --i>=0;)
+                       *ip++ |= PG_V + PG_URKR;
+               ip = &swaputl[(UPAGES*128) + tsize];
+               for (i=p->p_size-UPAGES; --i>=0; )
+                       *ip++ |= PG_V + PG_UW;
+               ((struct user *)swaputl)->u_pcb.pcb_szpt = pt;  /* for swap I/O */
+               x = p->p_swaddr;                /* disk address */
+               for (i=0; i<UPAGES; i++)
+                       p->p_addr[i] = Swapmap[i];
+               for (i=0; i<pt; i++)
+                       ((struct user *)swaputl)->u_ptable[i] = (Swapmap+UPAGES)[i] & PG_PFNUM;
+       } else {
+               ptaccess(p, Swapmap, swaputl);
+               pt = ((struct user *)swaputl)->u_pcb.pcb_szpt;
+               if (memall(&swaputl[(UPAGES*128)+tsize-tmem], p->p_swsize-UPAGES
+                               + tmem) == 0)
+                       goto nomem;
+               ip = &swaputl[(UPAGES*128)];
+               for (i=tmem; --i>=0; )
+                       *ip++ |= PG_V + PG_URKR;
+               ip = &swaputl[(UPAGES*128)+tsize];
+               for (i=p->p_swsize-UPAGES; --i>=0; )
+                       *ip++ |= PG_V + PG_UW;
+               x = p->p_swaddr;
+       }
+       if (xp) {
+               if (xp->x_ccount==0) {
+                       xp->x_caddr = p;        /* make link to loaded proc */
+                       if ((xp->x_flag&XLOAD)==0)
+                               swap(p,xp->x_daddr,0,xp->x_size,B_READ,0);
+               } else {
+                       if (xp->x_caddr == 0)   /* must find the text */
+                               for (prc= &proc[0]; prc<&proc[NPROC]; prc++)
+                                       if ((prc->p_flag&SLOAD) && (prc->p_textp==xp)
+                                         && (prc->p_flag&SLOCK)==0 && (prc!=p)){
+                                               xp->x_caddr = prc;      /* found it */
+                                               break;
+                                       }
+                       if (xp->x_caddr == 0)
+                               panic("lost text");
+                       ptaccess(xp->x_caddr, Swap2map, swap2utl);
+                       bcopy(swap2utl + 128*UPAGES, swaputl + 128*UPAGES, 4*xp->x_size);
+               }
+               xp->x_ccount++;
+               xunlock(xp);
+       }
+       if ((p->p_flag & SSPART) == 0)
+               swap(p, x, tsize, p->p_size, B_READ, 1);
+       else {
+               swap(p, x+UPAGES, tsize, p->p_swsize-UPAGES, B_READ, 0);
+               p->p_flag &= ~SSPART;
+       }
+       ((struct user *)swaputl)->u_pcb.pcb_szpt = pt;   /* may have shrunk */
+       ((struct user *)swaputl)->u_pcb.pcb_p1br = (int)&u + UPAGES*512
+                                       + pt*512 - 0x800000;  /* if page table shrunk, its moved */
+       mfree(swapmap, ctod(p->p_size), x);
+       x = (UPAGES*128) + tsize +  p->p_size - UPAGES;
+       for (i=1; i<=((struct user *)swaputl)->u_ssize; i++) {
+               swaputl[((UPAGES+pt)*128) - i] = swaputl[x - i];
+               if ( x != (UPAGES+pt)*128 )
+                       swaputl[x - i] = 0;
+       }
+       p->p_flag |= SLOAD;
+       p->p_time = 0;
+       return(1);
+
+nomem:
+       if (xp)
+               xunlock(xp);
+       return(0);
+}
+
+/*
+ * put the current process on
+ * the Q of running processes and
+ * call the scheduler.
+ */
+qswtch()
+{
+
+       setrq(u.u_procp);
+       swtch();
+}
+
+/*
+ * This routine is called to reschedule the CPU.
+ * if the calling process is not in RUN state,
+ * arrangements for it to restart must have
+ * been made elsewhere, usually by calling via sleep.
+ * There is a race here. A process may become
+ * ready after it has been examined.
+ * In this case, idle() will be called and
+ * will return in at most 1HZ time.
+ * i.e. its not worth putting an spl() in.
+ */
+swtch()
+{
+       register n;
+       register struct proc *p, *q, *pp, *pq;
+
+       /*
+        * If not the idle process, resume the idle process.
+        */
+       if (u.u_procp != &proc[0]) {
+               if (save(u.u_rsav)) {
+                       return;
+               }
+               resume(proc[0].p_addr, u.u_qsav);
+       }
+       /*
+        * The first save returns nonzero when proc 0 is resumed
+        * by another process (above); then the second is not done
+        * and the process-search loop is entered.
+        *
+        * The first save returns 0 when swtch is called in proc 0
+        * from sched().  The second save returns 0 immediately, so
+        * in this case too the process-search loop is entered.
+        * Thus when proc 0 is awakened by being made runnable, it will
+        * find itself and resume itself at rsav, and return to sched().
+        */
+       if (save(u.u_qsav)==0 && save(u.u_rsav))
+               return;
+loop:
+       spl6();
+       runrun = 0;
+       pp = NULL;
+       q = NULL;
+       n = 128;
+       /*
+        * Search for highest-priority runnable process
+        */
+       for(p=runq; p!=NULL; p=p->p_link) {
+               if((p->p_stat==SRUN) && (p->p_flag&SLOAD)) {
+                       if(p->p_pri < n) {
+                               pp = p;
+                               pq = q;
+                               n = p->p_pri;
+                       }
+               }
+               q = p;
+       }
+       /*
+        * If no process is runnable, idle.
+        */
+       p = pp;
+       if(p == NULL) {
+               idle();
+               goto loop;
+       }
+       q = pq;
+       if(q == NULL)
+               runq = p->p_link;
+       else
+               q->p_link = p->p_link;
+       curpri = n;
+       spl0();
+       /*
+        * The rsav (ssav) contents are interpreted in the new address space
+        */
+       n = p->p_flag&SSWAP;
+       p->p_flag &= ~SSWAP;
+       resume(p->p_addr, n? u.u_ssav: u.u_rsav);
+}
+
+/*
+ * Create a new process-- the internal version of
+ * sys fork.
+ * It returns 1 in the new process, 0 in the old.
+ */
+newproc()
+{
+       register struct proc *p, *up;
+       register struct proc *rpp, *rip;
+       register n;
+
+       p = NULL;
+       /*
+        * First, just locate a slot for a process
+        * and copy the useful info from this process into it.
+        * The panic "cannot happen" because fork has already
+        * checked for the existence of a slot.
+        */
+retry:
+       mpid++;
+       if(mpid >= 30000) {
+               mpid = 0;
+               goto retry;
+       }
+       for(rpp = &proc[0]; rpp < &proc[NPROC]; rpp++) {
+               if(rpp->p_stat == NULL && p==NULL)
+                       p = rpp;
+               if (rpp->p_pid==mpid || rpp->p_pgrp==mpid)
+                       goto retry;
+       }
+       if ((rpp = p)==NULL)
+               panic("no procs");
+
+       /*
+        * make proc entry for new proc
+        */
+
+       rip = u.u_procp;
+       up = rip;
+       rpp->p_stat = SRUN;
+       rpp->p_clktim = 0;
+       rpp->p_flag = SLOAD;
+       rpp->p_uid = rip->p_uid;
+       rpp->p_pgrp = rip->p_pgrp;
+       rpp->p_nice = rip->p_nice;
+       rpp->p_textp = rip->p_textp;
+       rpp->p_pid = mpid;
+       rpp->p_ppid = rip->p_pid;
+       rpp->p_time = 0;
+       rpp->p_cpu = 0;
+       rpp->p_tsize = rip->p_tsize;
+
+       /*
+        * make duplicate entries
+        * where needed
+        */
+
+       for(n=0; n<NOFILE; n++)
+               if(u.u_ofile[n] != NULL)
+                       u.u_ofile[n]->f_count++;
+       if(up->p_textp != NULL) {
+               up->p_textp->x_count++;
+               up->p_textp->x_ccount++;
+       }
+       u.u_cdir->i_count++;
+       if (u.u_rdir)
+               u.u_rdir->i_count++;
+       /*
+        * Partially simulate the environment
+        * of the new process so that when it is actually
+        * created (by copying) it will look right.
+        */
+       rpp = p;
+       u.u_procp = rpp;
+       rip = up;
+       rpp->p_size = rip->p_size;
+       /*
+        * When the resume is executed for the new process,
+        * here's where it will resume.
+        */
+       if (save(u.u_ssav)) {
+               return(1);
+       }
+       /*
+        * If there is not enough core for the
+        * new process, swap out the current process to generate the
+        * copy.
+        */
+       if (procdup(rpp) == NULL) {
+               rip->p_stat = SIDL;
+               for(n=UPAGES; --n>=0; )
+                       rpp->p_addr[n] = rip->p_addr[n];
+               xswap(rpp, 0, 0, -1);
+               rip->p_stat = SRUN;
+       }
+       u.u_procp = rip;
+       setrq(rpp);
+       rpp->p_flag |= SSWAP;
+       return(0);
+}
+
+/*
+ * Change the size of the data+stack regions of the process.
+ * If the size is shrinking, it's easy-- just release the extra core.
+ * If it's growing, and there is core, just allocate it
+ * and copy the image, taking care to reset registers to account
+ * for the fact that the system's stack has moved.
+ * If there is no core, arrange for the process to be swapped
+ * out after adjusting the size requirement-- when it comes
+ * in, enough core will be allocated.
+ *
+ * After the expansion, the caller will take care of copying
+ * the user's stack towards or away from the data area.
+ */
+expand(change,region)
+{
+       int n,p0,p1,oldss;
+       register struct proc *p;
+       register  new;
+       register  struct  pt_entry  *base;
+
+       p = u.u_procp;
+       n = p->p_size;
+       oldss = 0x200000 - u.u_pcb.pcb_p1lr;
+       p->p_size += change;
+       if (change == 0)
+               return;
+       p0 = mfpr(P0BR) + 4 * mfpr(P0LR);
+       p1 = mfpr(P1BR) + 4 * mfpr(P1LR);
+
+       /* see if we must add another page to the user page table */
+       if ((new = (p0 - p1 + 4*change)/4) > 0) {
+               new = ptexpand((new + 127)/128);
+       }
+       if (region == P0BR) {
+               base = (struct pt_entry *)mfpr(P0BR);
+               base += (p0 = mfpr(P0LR)) + (change > 0 ? 0 : change);
+       } else {
+               base = (struct pt_entry *)mfpr(P1BR);
+               base += (p1 = mfpr(P1LR)) - (change > 0 ? change : 0);
+       }
+       if (change > 0) {
+               new = memall(base,change);
+       } else
+               memfree(base,-change);
+       if (region == P0BR)  {
+               mtpr(P0LR,p0 + change);
+               u.u_pcb.pcb_p0lr = p0 + change | 0x04000000;
+       } else {
+               mtpr(P1LR,p1 - change);
+               u.u_pcb.pcb_p1lr = p1 - change;
+       }
+       if (change < 0 || new > 0) {
+               new = 1;
+               if (change < 0) {
+                       change = -change;
+                       new = 0;
+               }
+               while (--change >= 0) {
+                       *(int *)base |= PG_UW;
+                       base->pg_v = new;  
+                       base++;
+               }
+               return;
+       }
+
+       /*
+        * When the resume is executed for the new process
+        * here's where it will resume.
+        */
+       if (save(u.u_ssav)) {
+               return;
+       }
+       xswap(p, 1, n, oldss);
+       p->p_flag |= SSWAP;
+       qswtch();
+       /* no return */
+}
diff --git a/usr/src/sys/sys/subr.c b/usr/src/sys/sys/subr.c
new file mode 100644 (file)
index 0000000..23958ba
--- /dev/null
@@ -0,0 +1,188 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/conf.h"
+#include "../h/inode.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/buf.h"
+
+/*
+ * Bmap defines the structure of file system storage
+ * by returning the physical block number on a device given the
+ * inode and the logical block number in a file.
+ * When convenient, it also leaves the physical
+ * block number of the next block of the file in rablock
+ * for use in read-ahead.
+ */
+daddr_t
+bmap(ip, bn, rwflg)
+register struct inode *ip;
+daddr_t bn;
+{
+       register i;
+       struct buf *bp, *nbp;
+       int j, sh;
+       daddr_t nb, *bap;
+       dev_t dev;
+
+       if(bn < 0) {
+               u.u_error = EFBIG;
+               return((daddr_t)0);
+       }
+       dev = ip->i_dev;
+       rablock = 0;
+
+       /*
+        * blocks 0..NADDR-4 are direct blocks
+        */
+       if(bn < NADDR-3) {
+               i = bn;
+               nb = ip->i_un.i_addr[i];
+               if(nb == 0) {
+                       if(rwflg==B_READ || (bp = alloc(dev))==NULL)
+                               return((daddr_t)-1);
+                       nb = bp->b_blkno;
+                       bdwrite(bp);
+                       ip->i_un.i_addr[i] = nb;
+                       ip->i_flag |= IUPD|ICHG;
+               }
+               if(i < NADDR-4)
+                       rablock = ip->i_un.i_addr[i+1];
+               return(nb);
+       }
+
+       /*
+        * addresses NADDR-3, NADDR-2, and NADDR-1
+        * have single, double, triple indirect blocks.
+        * the first step is to determine
+        * how many levels of indirection.
+        */
+       sh = 0;
+       nb = 1;
+       bn -= NADDR-3;
+       for(j=3; j>0; j--) {
+               sh += NSHIFT;
+               nb <<= NSHIFT;
+               if(bn < nb)
+                       break;
+               bn -= nb;
+       }
+       if(j == 0) {
+               u.u_error = EFBIG;
+               return((daddr_t)0);
+       }
+
+       /*
+        * fetch the address from the inode
+        */
+       nb = ip->i_un.i_addr[NADDR-j];
+       if(nb == 0) {
+               if(rwflg==B_READ || (bp = alloc(dev))==NULL)
+                       return((daddr_t)-1);
+               nb = bp->b_blkno;
+               bdwrite(bp);
+               ip->i_un.i_addr[NADDR-j] = nb;
+               ip->i_flag |= IUPD|ICHG;
+       }
+
+       /*
+        * fetch through the indirect blocks
+        */
+       for(; j<=3; j++) {
+               bp = bread(dev, nb);
+               if(bp->b_flags & B_ERROR) {
+                       brelse(bp);
+                       return((daddr_t)0);
+               }
+               bap = bp->b_un.b_daddr;
+               sh -= NSHIFT;
+               i = (bn>>sh) & NMASK;
+               nb = bap[i];
+               if(nb == 0) {
+                       if(rwflg==B_READ || (nbp = alloc(dev))==NULL) {
+                               brelse(bp);
+                               return((daddr_t)-1);
+                       }
+                       nb = nbp->b_blkno;
+                       bdwrite(nbp);
+                       bap[i] = nb;
+                       bdwrite(bp);
+               } else
+                       brelse(bp);
+       }
+
+       /*
+        * calculate read-ahead.
+        */
+       if(i < NINDIR-1)
+               rablock = bap[i+1];
+       return(nb);
+}
+
+/*
+ * Pass back  c  to the user at his location u_base;
+ * update u_base, u_count, and u_offset.  Return -1
+ * on the last character of the user's read.
+ * u_base is in the user address space unless u_segflg is set.
+ */
+passc(c)
+register c;
+{
+       register id;
+
+       if((id = u.u_segflg) == 1)
+               *u.u_base = c;
+       else
+               if(id?suibyte(u.u_base, c):subyte(u.u_base, c) < 0) {
+                       u.u_error = EFAULT;
+                       return(-1);
+               }
+       u.u_count--;
+       u.u_offset++;
+       u.u_base++;
+       return(u.u_count == 0? -1: 0);
+}
+
+/*
+ * Pick up and return the next character from the user's
+ * write call at location u_base;
+ * update u_base, u_count, and u_offset.  Return -1
+ * when u_count is exhausted.  u_base is in the user's
+ * address space unless u_segflg is set.
+ */
+cpass()
+{
+       register c, id;
+
+       if(u.u_count == 0)
+               return(-1);
+       if((id = u.u_segflg) == 1)
+               c = *u.u_base;
+       else
+               if((c = id==0?fubyte(u.u_base):fuibyte(u.u_base)) < 0) {
+                       u.u_error = EFAULT;
+                       return(-1);
+               }
+       u.u_count--;
+       u.u_offset++;
+       u.u_base++;
+       return(c&0377);
+}
+
+/*
+ * Routine which sets a user error; placed in
+ * illegal entries in the bdevsw and cdevsw tables.
+ */
+nodev()
+{
+
+       u.u_error = ENODEV;
+}
+
+/*
+ * Null routine; placed in insignificant entries
+ * in the bdevsw and cdevsw tables.
+ */
+nulldev()
+{
+}
diff --git a/usr/src/sys/sys/sys.c b/usr/src/sys/sys/sys.c
new file mode 100644 (file)
index 0000000..80c77f9
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ *     indirect driver for controlling tty.
+ */
+#include "../h/param.h"
+#include "../h/conf.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/tty.h"
+#include "../h/proc.h"
+
+syopen(dev, flag)
+{
+
+       if(u.u_ttyp == NULL) {
+               u.u_error = ENXIO;
+               return;
+       }
+       (*cdevsw[major(u.u_ttyd)].d_open)(u.u_ttyd, flag);
+}
+
+syread(dev)
+{
+
+       (*cdevsw[major(u.u_ttyd)].d_read)(u.u_ttyd);
+}
+
+sywrite(dev)
+{
+
+       (*cdevsw[major(u.u_ttyd)].d_write)(u.u_ttyd);
+}
+
+sysioctl(dev, cmd, addr, flag)
+caddr_t addr;
+{
+
+       (*cdevsw[major(u.u_ttyd)].d_ioctl)(u.u_ttyd, cmd, addr, flag);
+}
diff --git a/usr/src/sys/sys/sys1.c b/usr/src/sys/sys/sys1.c
new file mode 100644 (file)
index 0000000..e20c02e
--- /dev/null
@@ -0,0 +1,534 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/uba.h"
+#include "../h/map.h"
+#include "../h/mtpr.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/proc.h"
+#include "../h/buf.h"
+#include "../h/reg.h"
+#include "../h/inode.h"
+#include "../h/seg.h"
+#include "../h/acct.h"
+#include "../h/page.h"
+
+/*
+ * exec system call, with and without environments.
+ */
+struct execa {
+       char    *fname;
+       char    **argp;
+       char    **envp;
+};
+
+exec()
+{
+       ((struct execa *)u.u_ap)->envp = NULL;
+       exece();
+}
+
+exece()
+{
+       register nc;
+       register char *cp;
+       register struct buf *bp;
+       register struct execa *uap;
+       int na, ne, bno, ucp, ap, c;
+       struct inode *ip;
+
+       if ((ip = namei(uchar, 0)) == NULL)
+               return;
+       bno = 0;
+       bp = 0;
+       if(access(ip, IEXEC))
+               goto bad;
+       if((ip->i_mode & IFMT) != IFREG ||
+          (ip->i_mode & (IEXEC|(IEXEC>>3)|(IEXEC>>6))) == 0) {
+               u.u_error = EACCES;
+               goto bad;
+       }
+       /*
+        * Collect arguments on "file" in swap space.
+        */
+       na = 0;
+       ne = 0;
+       nc = 0;
+       uap = (struct execa *)u.u_ap;
+       if ((bno = malloc(swapmap,(NCARGS+BSIZE-1)/BSIZE)) == 0)
+               panic("Out of swap");
+       if (uap->argp) for (;;) {
+               ap = NULL;
+               if (uap->argp) {
+                       ap = fuword((caddr_t)uap->argp);
+                       uap->argp++;
+               }
+               if (ap==NULL && uap->envp) {
+                       uap->argp = NULL;
+                       if ((ap = fuword((caddr_t)uap->envp)) == NULL)
+                               break;
+                       uap->envp++;
+                       ne++;
+               }
+               if (ap==NULL)
+                       break;
+               na++;
+               if(ap == -1)
+                       u.u_error = EFAULT;
+               do {
+                       if (nc >= NCARGS-1)
+                               u.u_error = E2BIG;
+                       if ((c = fubyte((caddr_t)ap++)) < 0)
+                               u.u_error = EFAULT;
+                       if (u.u_error)
+                               goto bad;
+                       if ((nc&BMASK) == 0) {
+                               if (bp)
+                                       bawrite(bp);
+                               bp = getblk(swapdev, swplo+bno+(nc>>BSHIFT));
+                               cp = bp->b_un.b_addr;
+                       }
+                       nc++;
+                       *cp++ = c;
+               } while (c>0);
+       }
+       if (bp)
+               bawrite(bp);
+       bp = 0;
+       nc = (nc + NBPW-1) & ~(NBPW-1);
+       if (getxfile(ip, nc) || u.u_error)
+               goto bad;
+
+       /*
+        * copy back arglist
+        */
+
+       ucp = USRSTACK - nc - NBPW;
+       ap = ucp - na*NBPW - 3*NBPW;
+       u.u_ar0[SP] = ap;
+       suword((caddr_t)ap, na-ne);
+       nc = 0;
+       for (;;) {
+               ap += NBPW;
+               if (na==ne) {
+                       suword((caddr_t)ap, 0);
+                       ap += NBPW;
+               }
+               if (--na < 0)
+                       break;
+               suword((caddr_t)ap, ucp);
+               do {
+                       if ((nc&BMASK) == 0) {
+                               if (bp)
+                                       brelse(bp);
+                               bp = bread(swapdev, swplo+bno+(nc>>BSHIFT));
+                               cp = bp->b_un.b_addr;
+                       }
+                       subyte((caddr_t)ucp++, (c = *cp++));
+                       nc++;
+               } while(c&0377);
+       }
+       suword((caddr_t)ap, 0);
+       suword((caddr_t)ucp, 0);
+       setregs();
+bad:
+       if (bp)
+               brelse(bp);
+       if(bno)
+               mfree(swapmap, (NCARGS+BSIZE-1)/BSIZE, bno);
+       iput(ip);
+}
+
+/*
+ * Read in and set up memory for executed file.
+ * Zero return is normal;
+ * non-zero means only the text is being replaced
+ */
+getxfile(ip, nargc)
+register struct inode *ip;
+{
+       register unsigned ds;
+       register sep;
+       register struct pt_entry *ptaddr;
+       register unsigned ts, ss;
+       register i, overlay;
+
+       /*
+        * read in first few bytes
+        * of file for segment
+        * sizes:
+        * ux_mag = 407/410/411/405
+        *  407 is plain executable
+        *  410 is RO text
+        *  411 is separated ID
+        *  405 is overlaid text
+        */
+
+       u.u_base = (caddr_t)&u.u_exdata;
+       u.u_count = sizeof(u.u_exdata);
+       u.u_offset = 0;
+       u.u_segflg = 1;
+       readi(ip);
+       u.u_segflg = 0;
+       if(u.u_error)
+               goto bad;
+       if (u.u_count!=0) {
+               u.u_error = ENOEXEC;
+               goto bad;
+       }
+       sep = 0;
+       overlay = 0;
+       if(u.u_exdata.ux_mag == 0407) {
+               u.u_exdata.ux_dsize += u.u_exdata.ux_tsize;
+               u.u_exdata.ux_tsize = 0;
+       } else if (u.u_exdata.ux_mag == 0411)
+               sep++;
+       else if (u.u_exdata.ux_mag == 0405)
+               overlay++;
+       else if (u.u_exdata.ux_mag != 0410) {
+               u.u_error = ENOEXEC;
+               goto bad;
+       }
+       if(u.u_exdata.ux_tsize!=0 && (ip->i_flag&ITEXT)==0 && ip->i_count!=1) {
+               u.u_error = ETXTBSY;
+               goto bad;
+       }
+
+       /*
+        * find text and data sizes
+        * try them out for possible
+        * exceed of max sizes
+        */
+
+       ts = btoc(u.u_exdata.ux_tsize);
+       ds = btoc(u.u_exdata.ux_dsize + u.u_exdata.ux_bsize);
+       ss = SSIZE + btoc(nargc);
+       if (overlay) {
+               if (u.u_sep==0 && ctos(ts) != ctos(u.u_tsize) || nargc) {
+                       u.u_error = ENOMEM;
+                       goto bad;
+               }
+               ds = u.u_dsize;
+               ss = u.u_ssize;
+               sep = u.u_sep;
+               xfree();
+               xalloc(ip);
+               u.u_ar0[PC] = u.u_exdata.ux_entloc + 2; /* skip over entry mask */
+       } else {
+               if(chksize(ts, ds, ss))
+                       goto bad;
+       
+               /*
+                * allocate and clear core
+                * at this point, committed
+                * to the new image
+                */
+       
+               u.u_prof.pr_scale = 0;
+               xfree();
+               memfree(mfpr(P0BR) + 4*u.u_tsize,u.u_dsize);    /* free old data area */
+               memfree(mfpr(P1BR) + 4*mfpr(P1LR),u.u_ssize);   /* free stack */
+               u.u_procp->p_size -= u.u_dsize + u.u_ssize;
+               u.u_dsize = 0;
+               u.u_ssize = ss;
+               mtpr(P0LR,ts);
+               u.u_pcb.pcb_p0lr = ts | 0x04000000;     /* also set ast level */
+               mtpr(P1LR,0x200000);
+               u.u_pcb.pcb_p1lr = 0x200000;
+               u.u_procp->p_tsize = ts;        /* save prospective text size for swapin */
+               u.u_tsize = ts;
+               expand(ss,P1BR);
+               u.u_dsize = ds;
+               expand(ds,P0BR);
+/*             mtpr(TBIA,0); */
+               ptaddr = (struct pt_entry *)mfpr(P0BR);
+               ptaddr += ts + (u.u_exdata.ux_dsize)/512;
+               i = ds - (u.u_exdata.ux_dsize/512);
+               while (--i >= 0) {
+                       clearseg(ptaddr->pg_pfnum);     /* clear bss segment */
+                       ptaddr++;
+               }
+               ptaddr = (struct pt_entry *)(mfpr(P1BR) + 4*mfpr(P1LR));
+               for(i=ss; --i>=0; ) {
+                       clearseg(ptaddr->pg_pfnum);     /* clear stack */
+                       ptaddr++;
+               }
+               xalloc(ip);
+               mtpr(TBIA,1);
+       
+               /*
+                * read in data segment
+                */
+       
+               chgprot(0,0,RO);        /* protect the stack */
+               u.u_base = (char *)ctob(ts);
+               u.u_offset = sizeof(u.u_exdata)+u.u_exdata.ux_tsize;
+               u.u_count = u.u_exdata.ux_dsize;
+               readi(ip);
+               chgprot(0,0,RW);        /* unprotect the stack */
+               /*
+                * set SUID/SGID protections, if no tracing
+                */
+               if ((u.u_procp->p_flag&STRC)==0) {
+                       if(ip->i_mode&ISUID)
+                               if(u.u_uid != 0) {
+                                       u.u_uid = ip->i_uid;
+                                       u.u_procp->p_uid = ip->i_uid;
+                               }
+                       if(ip->i_mode&ISGID)
+                               u.u_gid = ip->i_gid;
+               } else
+                       psignal(u.u_procp, SIGTRC);
+       }
+       u.u_tsize = ts;
+       u.u_dsize = ds;
+       u.u_ssize = ss;
+       u.u_sep = sep;
+bad:
+       return(overlay);
+}
+
+/*
+ * Clear registers on exec
+ */
+setregs()
+{
+       register int *rp;
+       register char *cp;
+       register i;
+
+       for(rp = &u.u_signal[0]; rp < &u.u_signal[NSIG]; rp++)
+               if((*rp & 1) == 0)
+                       *rp = 0;
+/*
+       for(rp = &u.u_ar0[0]; rp < &u.u_ar0[16];)
+               *rp++ = 0;
+*/
+       u.u_ar0[PC] = u.u_exdata.ux_entloc + 2; /* skip over entry mask */
+       for(i=0; i<NOFILE; i++) {
+               if (u.u_pofile[i]&EXCLOSE) {
+                       closef(u.u_ofile[i]);
+                       u.u_ofile[i] = NULL;
+                       u.u_pofile[i] &= ~EXCLOSE;
+               }
+       }
+       /*
+        * Remember file name for accounting.
+        */
+       u.u_acflag &= ~AFORK;
+       bcopy((caddr_t)u.u_dbuf, (caddr_t)u.u_comm, DIRSIZ);
+}
+
+/*
+ * exit system call:
+ * pass back caller's arg
+ */
+rexit()
+{
+       register struct a {
+               int     rval;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       exit((uap->rval & 0377) << 8);
+}
+
+/*
+ * Release resources.
+ * Save u. area for parent to look at.
+ * Enter zombie state.
+ * Wake up parent and init processes,
+ * and dispose of children.
+ */
+exit(rv)
+{
+       register int i;
+       register struct proc *p, *q;
+       register struct file *f;
+       extern int Umap[];
+       int ftable[UPAGES + MAXUMEM/128];
+
+       p = u.u_procp;
+       p->p_flag &= ~(STRC|SULOCK);
+       p->p_clktim = 0;
+       for(i=0; i<NSIG; i++)
+               u.u_signal[i] = 1;
+       for(i=0; i<NOFILE; i++) {
+               f = u.u_ofile[i];
+               u.u_ofile[i] = NULL;
+               closef(f);
+       }
+       plock(u.u_cdir);
+       iput(u.u_cdir);
+       if (u.u_rdir) {
+               plock(u.u_rdir);
+               iput(u.u_rdir);
+       }
+       xfree();
+       acct();
+
+       /* free data, stack, u-area, and page-tables */
+       memfree((int *)&u + UPAGES*128 + u.u_tsize, u.u_dsize);
+       memfree(((int *)&u) + USIZE*128 - u.u_ssize, u.u_ssize);
+       for(i=USIZE; --i>=0; )
+               ftable[i] = Umap[i];
+       memfree(ftable, USIZE);
+
+       p->p_stat = SZOMB;
+       ((struct xproc *)p)->xp_xstat = rv;
+       ((struct xproc *)p)->xp_utime = u.u_cutime + u.u_utime;
+       ((struct xproc *)p)->xp_stime = u.u_cstime + u.u_stime;
+       for(q = &proc[0]; q < &proc[NPROC]; q++)
+               if(q->p_ppid == p->p_pid) {
+                       wakeup((caddr_t)&proc[1]);
+                       q->p_ppid = 1;
+                       if (q->p_stat==SSTOP)
+                               setrun(q);
+               }
+       for(q = &proc[0]; q < &proc[NPROC]; q++)
+               if(p->p_ppid == q->p_pid) {
+                       wakeup((caddr_t)q);
+                       swtch();
+                       /* no return */
+               }
+       swtch();
+}
+
+/*
+ * Wait system call.
+ * Search for a terminated (zombie) child,
+ * finally lay it to rest, and collect its status.
+ * Look also for stopped (traced) children,
+ * and pass back status from them.
+ */
+wait()
+{
+       register f;
+       register struct proc *p;
+
+       f = 0;
+
+loop:
+       for(p = &proc[0]; p < &proc[NPROC]; p++)
+       if(p->p_ppid == u.u_procp->p_pid) {
+               f++;
+               if(p->p_stat == SZOMB) {
+                       u.u_r.r_val1 = p->p_pid;
+                       u.u_r.r_val2 = ((struct xproc *)p)->xp_xstat;
+                       u.u_cutime += ((struct xproc *)p)->xp_utime;
+                       u.u_cstime += ((struct xproc *)p)->xp_stime;
+                       p->p_stat = NULL;
+                       p->p_pid = 0;
+                       p->p_ppid = 0;
+                       p->p_sig = 0;
+                       p->p_pgrp = 0;
+                       p->p_flag = 0;
+                       p->p_wchan = 0;
+                       return;
+               }
+               if(p->p_stat == SSTOP) {
+                       if((p->p_flag&SWTED) == 0) {
+                               p->p_flag |= SWTED;
+                               u.u_r.r_val1 = p->p_pid;
+                               u.u_r.r_val2 = (fsig(p)<<8) | 0177;
+                               return;
+                       }
+                       continue;
+               }
+       }
+       if(f) {
+               sleep((caddr_t)u.u_procp, PWAIT);
+               goto loop;
+       }
+       u.u_error = ECHILD;
+}
+
+/*
+ * fork system call.
+ */
+fork()
+{
+       register struct proc *p1, *p2;
+       register a;
+
+       /*
+        * Make sure there's enough swap space for max
+        * core image, thus reducing chances of running out
+        */
+       if ((a = malloc(swapmap, ctod(MAXMEM))) == 0) {
+               u.u_error = ENOMEM;
+               goto out;
+       }
+       mfree(swapmap, ctod(MAXMEM), a);
+       a = 0;
+       p2 = NULL;
+       for(p1 = &proc[0]; p1 < &proc[NPROC]; p1++) {
+               if (p1->p_stat==NULL && p2==NULL)
+                       p2 = p1;
+               else {
+                       if (p1->p_uid==u.u_uid && p1->p_stat!=NULL)
+                               a++;
+               }
+       }
+       /*
+        * Disallow if
+        *  No processes at all;
+        *  not su and too many procs owned; or
+        *  not su and would take last slot.
+        */
+       if (p2==NULL || (u.u_uid!=0 && (p2==&proc[NPROC-1] || a>MAXUPRC))) {
+               u.u_error = EAGAIN;
+               goto out;
+       }
+       p1 = u.u_procp;
+       if(newproc()) {
+               u.u_r.r_val1 = p1->p_pid;
+               u.u_r.r_val2 = 1;  /* child */
+               u.u_start = time;
+               u.u_cstime = 0;
+               u.u_stime = 0;
+               u.u_cutime = 0;
+               u.u_utime = 0;
+               u.u_acflag = AFORK;
+               return;
+       }
+       u.u_r.r_val1 = p2->p_pid;
+
+out:
+       u.u_r.r_val2 = 0;
+}
+
+/*
+ * break system call.
+ *  -- bad planning: "break" is a dirty word in C.
+ */
+sbreak()
+{
+       struct a {
+               char    *nsiz;
+       };
+       register  n, d;
+       register struct pt_entry *ptaddr;
+
+       /*
+        * set n to new data size
+        * set d to new-old
+        */
+
+       n = btoc(((struct a *)u.u_ap)->nsiz);
+       if(!u.u_sep)
+               n -= ctos(u.u_tsize) * stoc(1);
+       if(n < 0)
+               n = 0;
+       d = n - u.u_dsize;
+       if(chksize(u.u_tsize, u.u_dsize+d, u.u_ssize))
+               return;
+       u.u_dsize += d;
+       expand(d,P0BR);
+       if (d>0) {      /* bigger */
+               ptaddr = (struct pt_entry *)mfpr(P0BR);
+               ptaddr += u.u_tsize + u.u_dsize - d;    /* point at first new page */
+               while(d--)
+                       clearseg(ptaddr++->pg_pfnum);
+       }
+}
diff --git a/usr/src/sys/sys/sys2.c b/usr/src/sys/sys/sys2.c
new file mode 100644 (file)
index 0000000..01e14c1
--- /dev/null
@@ -0,0 +1,317 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/reg.h"
+#include "../h/file.h"
+#include "../h/inode.h"
+
+/*
+ * read system call
+ */
+read()
+{
+       rdwr(FREAD);
+}
+
+/*
+ * write system call
+ */
+write()
+{
+       rdwr(FWRITE);
+}
+
+/*
+ * common code for read and write calls:
+ * check permissions, set base, count, and offset,
+ * and switch out to readi, writei, or pipe code.
+ */
+rdwr(mode)
+register mode;
+{
+       register struct file *fp;
+       register struct inode *ip;
+       register struct a {
+               int     fdes;
+               char    *cbuf;
+               unsigned count;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       fp = getf(uap->fdes);
+       if(fp == NULL)
+               return;
+       if((fp->f_flag&mode) == 0) {
+               u.u_error = EBADF;
+               return;
+       }
+       u.u_base = (caddr_t)uap->cbuf;
+       u.u_count = uap->count;
+       u.u_segflg = 0;
+       if((fp->f_flag&FPIPE) != 0) {
+               if(mode == FREAD)
+                       readp(fp);
+               else
+                       writep(fp);
+       } else {
+               ip = fp->f_inode;
+               if (fp->f_flag&FMP)
+                       u.u_offset = 0;
+               else
+                       u.u_offset = fp->f_un.f_offset;
+               if((ip->i_mode&(IFCHR&IFBLK)) == 0)
+                       plock(ip);
+               if(mode == FREAD)
+                       readi(ip);
+               else
+                       writei(ip);
+               if((ip->i_mode&(IFCHR&IFBLK)) == 0)
+                       prele(ip);
+               if ((fp->f_flag&FMP) == 0)
+                       fp->f_un.f_offset += uap->count-u.u_count;
+       }
+       u.u_r.r_val1 = uap->count-u.u_count;
+}
+
+/*
+ * open system call
+ */
+open()
+{
+       register struct inode *ip;
+       register struct a {
+               char    *fname;
+               int     rwmode;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       ip = namei(uchar, 0);
+       if(ip == NULL)
+               return;
+       open1(ip, ++uap->rwmode, 0);
+}
+
+/*
+ * creat system call
+ */
+creat()
+{
+       register struct inode *ip;
+       register struct a {
+               char    *fname;
+               int     fmode;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       ip = namei(uchar, 1);
+       if(ip == NULL) {
+               if(u.u_error)
+                       return;
+               ip = maknode(uap->fmode&07777&(~ISVTX));
+               if (ip==NULL)
+                       return;
+               open1(ip, FWRITE, 2);
+       } else
+               open1(ip, FWRITE, 1);
+}
+
+/*
+ * common code for open and creat.
+ * Check permissions, allocate an open file structure,
+ * and call the device open routine if any.
+ */
+open1(ip, mode, trf)
+register struct inode *ip;
+register mode;
+{
+       register struct file *fp;
+       int i;
+
+       if(trf != 2) {
+               if(mode&FREAD)
+                       access(ip, IREAD);
+               if(mode&FWRITE) {
+                       access(ip, IWRITE);
+                       if((ip->i_mode&IFMT) == IFDIR)
+                               u.u_error = EISDIR;
+               }
+       }
+       if(u.u_error)
+               goto out;
+       if(trf == 1)
+               itrunc(ip);
+       prele(ip);
+       if ((fp = falloc()) == NULL)
+               goto out;
+       fp->f_flag = mode&(FREAD|FWRITE);
+       fp->f_inode = ip;
+       i = u.u_r.r_val1;
+       openi(ip, mode&FWRITE);
+       if(u.u_error == 0)
+               return;
+       u.u_ofile[i] = NULL;
+       fp->f_count--;
+
+out:
+       iput(ip);
+}
+
+/*
+ * close system call
+ */
+close()
+{
+       register struct file *fp;
+       register struct a {
+               int     fdes;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       fp = getf(uap->fdes);
+       if(fp == NULL)
+               return;
+       u.u_ofile[uap->fdes] = NULL;
+       closef(fp);
+}
+
+/*
+ * seek system call
+ */
+seek()
+{
+       register struct file *fp;
+       register struct a {
+               int     fdes;
+               off_t   off;
+               int     sbase;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       fp = getf(uap->fdes);
+       if(fp == NULL)
+               return;
+       if(fp->f_flag&(FPIPE|FMP)) {
+               u.u_error = ESPIPE;
+               return;
+       }
+       if(uap->sbase == 1)
+               uap->off += fp->f_un.f_offset;
+       else if(uap->sbase == 2)
+               uap->off += fp->f_inode->i_size;
+       fp->f_un.f_offset = uap->off;
+       u.u_r.r_off = uap->off;
+}
+
+
+/*
+ * link system call
+ */
+link()
+{
+       register struct inode *ip, *xp;
+       register struct a {
+               char    *target;
+               char    *linkname;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       ip = namei(uchar, 0);
+       if(ip == NULL)
+               return;
+       if((ip->i_mode&IFMT)==IFDIR && !suser())
+               goto out;
+       /*
+        * Unlock to avoid possibly hanging the namei.
+        * Sadly, this means races. (Suppose someone
+        * deletes the file in the meantime?)
+        * Nor can it be locked again later
+        * because then there will be deadly
+        * embraces.
+        */
+       prele(ip);
+       u.u_dirp = (caddr_t)uap->linkname;
+       xp = namei(uchar, 1);
+       if(xp != NULL) {
+               u.u_error = EEXIST;
+               iput(xp);
+               goto out;
+       }
+       if (u.u_error)
+               goto out;
+       if(u.u_pdir->i_dev != ip->i_dev) {
+               iput(u.u_pdir);
+               u.u_error = EXDEV;
+               goto out;
+       }
+       wdir(ip);
+       if (u.u_error==0) {
+               ip->i_nlink++;
+               ip->i_flag |= ICHG;
+       }
+
+out:
+       iput(ip);
+}
+
+/*
+ * mknod system call
+ */
+mknod()
+{
+       register struct inode *ip;
+       register struct a {
+               char    *fname;
+               int     fmode;
+               int     dev;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       if(suser()) {
+               ip = namei(uchar, 1);
+               if(ip != NULL) {
+                       u.u_error = EEXIST;
+                       goto out;
+               }
+       }
+       if(u.u_error)
+               return;
+       ip = maknode(uap->fmode);
+       if (ip == NULL)
+               return;
+       ip->i_un.i_rdev = (dev_t)uap->dev;
+
+out:
+       iput(ip);
+}
+
+/*
+ * access system call
+ */
+saccess()
+{
+       register svuid, svgid;
+       register struct inode *ip;
+       register struct a {
+               char    *fname;
+               int     fmode;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       svuid = u.u_uid;
+       svgid = u.u_gid;
+       u.u_uid = u.u_ruid;
+       u.u_gid = u.u_rgid;
+       ip = namei(uchar, 0);
+       if (ip != NULL) {
+               if (uap->fmode&(IREAD>>6))
+                       access(ip, IREAD);
+               if (uap->fmode&(IWRITE>>6))
+                       access(ip, IWRITE);
+               if (uap->fmode&(IEXEC>>6))
+                       access(ip, IEXEC);
+               iput(ip);
+       }
+       u.u_uid = svuid;
+       u.u_gid = svgid;
+}
diff --git a/usr/src/sys/sys/sys3.c b/usr/src/sys/sys/sys3.c
new file mode 100644 (file)
index 0000000..1523d25
--- /dev/null
@@ -0,0 +1,255 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/mount.h"
+#include "../h/ino.h"
+#include "../h/reg.h"
+#include "../h/buf.h"
+#include "../h/filsys.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/inode.h"
+#include "../h/file.h"
+#include "../h/conf.h"
+#include "../h/stat.h"
+
+/*
+ * the fstat system call.
+ */
+fstat()
+{
+       register struct file *fp;
+       register struct a {
+               int     fdes;
+               struct stat *sb;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       fp = getf(uap->fdes);
+       if(fp == NULL)
+               return;
+       stat1(fp->f_inode, uap->sb, fp->f_flag&FPIPE? fp->f_un.f_offset: 0);
+}
+
+/*
+ * the stat system call.
+ */
+stat()
+{
+       register struct inode *ip;
+       register struct a {
+               char    *fname;
+               struct stat *sb;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       ip = namei(uchar, 0);
+       if(ip == NULL)
+               return;
+       stat1(ip, uap->sb, (off_t)0);
+       iput(ip);
+}
+
+/*
+ * The basic routine for fstat and stat:
+ * get the inode and pass appropriate parts back.
+ */
+stat1(ip, ub, pipeadj)
+register struct inode *ip;
+struct stat *ub;
+off_t pipeadj;
+{
+       register struct dinode *dp;
+       register struct buf *bp;
+       struct stat ds;
+
+       iupdat(ip, &time, &time);
+       /*
+        * first copy from inode table
+        */
+       ds.st_dev = ip->i_dev;
+       ds.st_ino = ip->i_number;
+       ds.st_mode = ip->i_mode;
+       ds.st_nlink = ip->i_nlink;
+       ds.st_uid = ip->i_uid;
+       ds.st_gid = ip->i_gid;
+       ds.st_rdev = (dev_t)ip->i_un.i_rdev;
+       ds.st_size = ip->i_size - pipeadj;
+       /*
+        * next the dates in the disk
+        */
+       bp = bread(ip->i_dev, itod(ip->i_number));
+       dp = bp->b_un.b_dino;
+       dp += itoo(ip->i_number);
+       ds.st_atime = dp->di_atime;
+       ds.st_mtime = dp->di_mtime;
+       ds.st_ctime = dp->di_ctime;
+       brelse(bp);
+       if (copyout((caddr_t)&ds, (caddr_t)ub, sizeof(ds)) < 0)
+               u.u_error = EFAULT;
+}
+
+/*
+ * the dup system call.
+ */
+dup()
+{
+       register struct file *fp;
+       register struct a {
+               int     fdes;
+               int     fdes2;
+       } *uap;
+       register i, m;
+
+       uap = (struct a *)u.u_ap;
+       m = uap->fdes & ~077;
+       uap->fdes &= 077;
+       fp = getf(uap->fdes);
+       if(fp == NULL)
+               return;
+       if ((m&0100) == 0) {
+               if ((i = ufalloc()) < 0)
+                       return;
+       } else {
+               i = uap->fdes2;
+               if (i<0 || i>=NOFILE) {
+                       u.u_error = EBADF;
+                       return;
+               }
+               u.u_r.r_val1 = i;
+       }
+       if (i!=uap->fdes) {
+               if (u.u_ofile[i]!=NULL)
+                       closef(u.u_ofile[i]);
+               u.u_ofile[i] = fp;
+               fp->f_count++;
+       }
+}
+
+/*
+ * the mount system call.
+ */
+smount()
+{
+       dev_t dev;
+       register struct inode *ip;
+       register struct mount *mp;
+       struct mount *smp;
+       register struct filsys *fp;
+       struct buf *bp;
+       register struct a {
+               char    *fspec;
+               char    *freg;
+               int     ronly;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       dev = getmdev();
+       if(u.u_error)
+               return;
+       u.u_dirp = (caddr_t)uap->freg;
+       ip = namei(uchar, 0);
+       if(ip == NULL)
+               return;
+       if(ip->i_count!=1 || (ip->i_mode&(IFBLK&IFCHR))!=0)
+               goto out;
+       smp = NULL;
+       for(mp = &mount[0]; mp < &mount[NMOUNT]; mp++) {
+               if(mp->m_bufp != NULL) {
+                       if(dev == mp->m_dev)
+                               goto out;
+               } else
+               if(smp == NULL)
+                       smp = mp;
+       }
+       mp = smp;
+       if(mp == NULL)
+               goto out;
+       (*bdevsw[major(dev)].d_open)(dev, !uap->ronly);
+       if(u.u_error)
+               goto out;
+       bp = bread(dev, SUPERB);
+       if(u.u_error) {
+               brelse(bp);
+               goto out1;
+       }
+       mp->m_inodp = ip;
+       mp->m_dev = dev;
+       mp->m_bufp = geteblk();
+       bcopy((caddr_t)bp->b_un.b_addr, mp->m_bufp->b_un.b_addr, BSIZE);
+       fp = mp->m_bufp->b_un.b_filsys;
+       fp->s_ilock = 0;
+       fp->s_flock = 0;
+       fp->s_ronly = uap->ronly & 1;
+       brelse(bp);
+       ip->i_flag |= IMOUNT;
+       prele(ip);
+       return;
+
+out:
+       u.u_error = EBUSY;
+out1:
+       iput(ip);
+}
+
+/*
+ * the umount system call.
+ */
+sumount()
+{
+       dev_t dev;
+       register struct inode *ip;
+       register struct mount *mp;
+       struct buf *bp;
+       register struct a {
+               char    *fspec;
+       };
+
+       dev = getmdev();
+       if(u.u_error)
+               return;
+       xumount(dev);   /* remove unused sticky files from text table */
+       update();
+       for(mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
+               if(mp->m_bufp != NULL && dev == mp->m_dev)
+                       goto found;
+       u.u_error = EINVAL;
+       return;
+
+found:
+       for(ip = &inode[0]; ip < &inode[NINODE]; ip++)
+               if(ip->i_number != 0 && dev == ip->i_dev) {
+                       u.u_error = EBUSY;
+                       return;
+               }
+       (*bdevsw[major(dev)].d_close)(dev, 0);
+       ip = mp->m_inodp;
+       ip->i_flag &= ~IMOUNT;
+       plock(ip);
+       iput(ip);
+       bp = mp->m_bufp;
+       mp->m_bufp = NULL;
+       brelse(bp);
+}
+
+/*
+ * Common code for mount and umount.
+ * Check that the user's argument is a reasonable
+ * thing on which to mount, and return the device number if so.
+ */
+dev_t
+getmdev()
+{
+       dev_t dev;
+       register struct inode *ip;
+
+       ip = namei(uchar, 0);
+       if(ip == NULL)
+               return(NODEV);
+       if((ip->i_mode&IFMT) != IFBLK)
+               u.u_error = ENOTBLK;
+       dev = (dev_t)ip->i_un.i_rdev;
+       if(major(dev) >= nblkdev)
+               u.u_error = ENXIO;
+       iput(ip);
+       return(dev);
+}
diff --git a/usr/src/sys/sys/sys4.c b/usr/src/sys/sys/sys4.c
new file mode 100644 (file)
index 0000000..cc61a78
--- /dev/null
@@ -0,0 +1,432 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/reg.h"
+#include "../h/inode.h"
+#include "../h/proc.h"
+#include "../h/clock.h"
+#include "../h/mtpr.h"
+#include "../h/timeb.h"
+
+/*
+ * Everything in this file is a routine implementing a system call.
+ */
+
+/*
+ * return the current time (old-style entry)
+ */
+gtime()
+{
+       u.u_r.r_time = time;
+}
+
+/*
+ * New time entry-- return TOD with milliseconds, timezone,
+ * DST flag
+ */
+ftime()
+{
+       register struct a {
+               struct  timeb   *tp;
+       } *uap;
+       struct timeb t;
+       register unsigned ms;
+
+       uap = (struct a *)u.u_ap;
+       spl7();
+       t.time = time;
+       ms = lbolt;
+       spl0();
+       if (ms > HZ) {
+               ms -= HZ;
+               t.time++;
+       }
+       t.millitm = (1000*ms)/HZ;
+       t.timezone = TIMEZONE;
+       t.dstflag = DSTFLAG;
+       if (copyout((caddr_t)&t, (caddr_t)uap->tp, sizeof(t)) < 0)
+               u.u_error = EFAULT;
+}
+
+/*
+ * Set the time
+ */
+stime()
+{
+       register unsigned int i , j ;
+       register struct a {
+               time_t  time;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       if(suser()) {
+               time = uap->time;
+               /* In addition to setting software time (GMT seconds
+               *  since YRREF), also set VAX TODR reg (10 ms. clicks
+               *  into current year YRCURR
+               */
+               for (i = time , j = YRREF ; j < YRCURR ; j++)
+                       i -= (SECYR + (j%4?0:SECDAY)) ;
+               mtpr(TODR,i*100) ; /* 10 ms. clicks */
+       }
+}
+
+setuid()
+{
+       register uid;
+       register struct a {
+               int     uid;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       uid = uap->uid;
+       if(u.u_ruid == uid || suser()) {
+               u.u_uid = uid;
+               u.u_procp->p_uid = uid;
+               u.u_ruid = uid;
+       }
+}
+
+getuid()
+{
+
+       u.u_r.r_val1 = u.u_ruid;
+       u.u_r.r_val2 = u.u_uid;
+}
+
+setgid()
+{
+       register gid;
+       register struct a {
+               int     gid;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       gid = uap->gid;
+       if(u.u_rgid == gid || suser()) {
+               u.u_gid = gid;
+               u.u_rgid = gid;
+       }
+}
+
+getgid()
+{
+
+       u.u_r.r_val1 = u.u_rgid;
+       u.u_r.r_val2 = u.u_gid;
+}
+
+getpid()
+{
+       u.u_r.r_val1 = u.u_procp->p_pid;
+       u.u_r.r_val2 = u.u_procp->p_ppid;
+}
+
+sync()
+{
+
+       update();
+}
+
+nice()
+{
+       register n;
+       register struct a {
+               int     niceness;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       n = uap->niceness;
+       if(n < 0 && !suser())
+               n = 0;
+       n += u.u_procp->p_nice;
+       if(n >= 2*NZERO)
+               n = 2*NZERO -1;
+       if(n < 0)
+               n = 0;
+       u.u_procp->p_nice = n;
+}
+
+/*
+ * Unlink system call.
+ * Hard to avoid races here, especially
+ * in unlinking directories.
+ */
+unlink()
+{
+       register struct inode *ip, *pp;
+       struct a {
+               char    *fname;
+       };
+
+       pp = namei(uchar, 2);
+       if(pp == NULL)
+               return;
+       /*
+        * Check for unlink(".")
+        * to avoid hanging on the iget
+        */
+       if (pp->i_number == u.u_dent.d_ino) {
+               ip = pp;
+               ip->i_count++;
+       } else
+               ip = iget(pp->i_dev, u.u_dent.d_ino);
+       if(ip == NULL)
+               goto out1;
+       if((ip->i_mode&IFMT)==IFDIR && !suser())
+               goto out;
+       /*
+        * Don't unlink a mounted file.
+        */
+       if (ip->i_dev != pp->i_dev) {
+               u.u_error = EBUSY;
+               goto out;
+       }
+       if (ip->i_flag&ITEXT)
+               xrele(ip);      /* try once to free text */
+       if (ip->i_flag&ITEXT && ip->i_nlink==1) {
+               u.u_error = ETXTBSY;
+               goto out;
+       }
+       u.u_offset -= sizeof(struct direct);
+       u.u_base = (caddr_t)&u.u_dent;
+       u.u_count = sizeof(struct direct);
+       u.u_dent.d_ino = 0;
+       writei(pp);
+       ip->i_nlink--;
+       ip->i_flag |= ICHG;
+
+out:
+       iput(ip);
+out1:
+       iput(pp);
+}
+chdir()
+{
+       chdirec(&u.u_cdir);
+}
+
+chroot()
+{
+       chdirec(&u.u_rdir);
+}
+
+chdirec(ipp)
+register struct inode **ipp;
+{
+       register struct inode *ip;
+       struct a {
+               char    *fname;
+       };
+
+       ip = namei(uchar, 0);
+       if(ip == NULL)
+               return;
+       if((ip->i_mode&IFMT) != IFDIR) {
+               u.u_error = ENOTDIR;
+               goto bad;
+       }
+       if(access(ip, IEXEC))
+               goto bad;
+       prele(ip);
+       if (*ipp) {
+               plock(*ipp);
+               iput(*ipp);
+       }
+       *ipp = ip;
+       return;
+
+bad:
+       iput(ip);
+}
+
+chmod()
+{
+       register struct inode *ip;
+       register struct a {
+               char    *fname;
+               int     fmode;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       if ((ip = owner()) == NULL)
+               return;
+       ip->i_mode &= ~07777;
+       if (u.u_uid)
+               uap->fmode &= ~ISVTX;
+       ip->i_mode |= uap->fmode&07777;
+       ip->i_flag |= ICHG;
+       if (ip->i_flag&ITEXT && (ip->i_mode&ISVTX)==0)
+               xrele(ip);
+       iput(ip);
+}
+
+chown()
+{
+       register struct inode *ip;
+       register struct a {
+               char    *fname;
+               int     uid;
+               int     gid;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       if (!suser() || (ip = owner()) == NULL)
+               return;
+       ip->i_uid = uap->uid;
+       ip->i_gid = uap->gid;
+       ip->i_flag |= ICHG;
+       iput(ip);
+}
+
+ssig()
+{
+       register a;
+       struct a {
+               int     signo;
+               int     fun;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       a = uap->signo;
+       if(a<=0 || a>=NSIG || a==SIGKIL) {
+               u.u_error = EINVAL;
+               return;
+       }
+       u.u_r.r_val1 = u.u_signal[a];
+       u.u_signal[a] = uap->fun;
+       u.u_procp->p_sig &= ~(1<<(a-1));
+}
+
+kill()
+{
+       register struct proc *p, *q;
+       register a;
+       register struct a {
+               int     pid;
+               int     signo;
+       } *uap;
+       int f, priv;
+
+       uap = (struct a *)u.u_ap;
+       f = 0;
+       a = uap->pid;
+       priv = 0;
+       if (a==-1 && u.u_uid==0) {
+               priv++;
+               a = 0;
+       }
+       q = u.u_procp;
+       for(p = &proc[0]; p < &proc[NPROC]; p++) {
+               if(p->p_stat == NULL)
+                       continue;
+               if(a != 0 && p->p_pid != a)
+                       continue;
+               if(a==0 && ((p->p_pgrp!=q->p_pgrp&&priv==0) || p<=&proc[1]))
+                       continue;
+               if(u.u_uid != 0 && u.u_uid != p->p_uid)
+                       continue;
+               f++;
+               psignal(p, uap->signo);
+       }
+       if(f == 0)
+               u.u_error = ESRCH;
+}
+
+times()
+{
+       register struct a {
+               time_t  (*times)[4];
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       if (copyout((caddr_t)&u.u_utime, (caddr_t)uap->times, sizeof(*uap->times)) < 0)
+               u.u_error = EFAULT;
+}
+
+profil()
+{
+       register struct a {
+               short   *bufbase;
+               unsigned bufsize;
+               unsigned pcoffset;
+               unsigned pcscale;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       u.u_prof.pr_base = uap->bufbase;
+       u.u_prof.pr_size = uap->bufsize;
+       u.u_prof.pr_off = uap->pcoffset;
+       u.u_prof.pr_scale = uap->pcscale;
+}
+
+/*
+ * alarm clock signal
+ */
+alarm()
+{
+       register struct proc *p;
+       register c;
+       register struct a {
+               int     deltat;
+       } *uap;
+
+       uap = (struct a *)u.u_ap;
+       p = u.u_procp;
+       c = p->p_clktim;
+       p->p_clktim = uap->deltat;
+       u.u_r.r_val1 = c;
+}
+
+/*
+ * indefinite wait.
+ * no one should wakeup(&u)
+ */
+pause()
+{
+
+       for(;;)
+               sleep((caddr_t)&u, PSLEP);
+}
+
+/*
+ * mode mask for creation of files
+ */
+umask()
+{
+       register struct a {
+               int     mask;
+       } *uap;
+       register t;
+
+       uap = (struct a *)u.u_ap;
+       t = u.u_cmask;
+       u.u_cmask = uap->mask & 0777;
+       u.u_r.r_val1 = t;
+}
+
+/*
+ * Set IUPD and IACC times on file.
+ * Can't set ICHG.
+ */
+utime()
+{
+       register struct a {
+               char    *fname;
+               time_t  *tptr;
+       } *uap;
+       register struct inode *ip;
+       time_t tv[2];
+
+       uap = (struct a *)u.u_ap;
+       if ((ip = owner()) == NULL)
+               return;
+       if (copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof(tv))) {
+               u.u_error = EFAULT;
+               return;
+       }
+       ip->i_flag |= IACC|IUPD|ICHG;
+       iupdat(ip, &tv[0], &tv[1]);
+       iput(ip);
+}
diff --git a/usr/src/sys/sys/sysent.c b/usr/src/sys/sys/sysent.c
new file mode 100644 (file)
index 0000000..b62ca3f
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * This table is the switch used to transfer
+ * to the appropriate routine for processing a system call.
+ * Each row contains the number of arguments expected
+ * and a pointer to the routine.
+ */
+
+#include "../h/param.h"
+#include "../h/systm.h"
+
+int    alarm();
+int    chdir();
+int    chmod();
+int    chown();
+int    chroot();
+int    close();
+int    creat();
+int    dup();
+int    exec();
+int    exece();
+int    fork();
+int    fstat();
+int    getgid();
+int    getpid();
+int    getuid();
+int    gtime();
+int    gtty();
+int    ioctl();
+int    kill();
+int    link();
+int    mknod();
+int    mpxchan();
+int    nice();
+int    ftime();
+int    nosys();
+int    nullsys();
+int    open();
+int    pause();
+int    pipe();
+int    profil();
+int    ptrace();
+int    read();
+int    rexit();
+int    saccess();
+int    sbreak();
+int    seek();
+int    setgid();
+int    setuid();
+int    smount();
+int    ssig();
+int    stat();
+int    stime();
+int    stty();
+int    sumount();
+int    sync();
+int    sysacct();
+int    syslock();
+int    sysphys();
+int    times();
+int    umask();
+int    unlink();
+int    utime();
+int    wait();
+int    write();
+
+struct sysent sysent[64] =
+{
+       0, 0, nosys,                    /* 0 = indir */
+       1, 0, rexit,                    /*  1 = exit */
+       0, 0, fork,                     /*  2 = fork */
+       3, 0, read,                     /*  3 = read */
+       3, 0, write,                    /*  4 = write */
+       2, 0, open,                     /*  5 = open */
+       1, 0, close,                    /*  6 = close */
+       0, 0, wait,                     /*  7 = wait */
+       2, 0, creat,                    /*  8 = creat */
+       2, 0, link,                     /*  9 = link */
+       1, 0, unlink,                   /* 10 = unlink */
+       2, 0, exec,                     /* 11 = exec */
+       1, 0, chdir,                    /* 12 = chdir */
+       0, 0, gtime,                    /* 13 = time */
+       3, 0, mknod,                    /* 14 = mknod */
+       2, 0, chmod,                    /* 15 = chmod */
+       3, 0, chown,                    /* 16 = chown; now 3 args */
+       1, 0, sbreak,                   /* 17 = break */
+       2, 0, stat,                     /* 18 = stat */
+       3, 0, seek,                     /* 19 = seek */
+       0, 0, getpid,                   /* 20 = getpid */
+       3, 0, smount,                   /* 21 = mount */
+       1, 0, sumount,                  /* 22 = umount */
+       1, 0, setuid,                   /* 23 = setuid */
+       0, 0, getuid,                   /* 24 = getuid */
+       1, 0, stime,                    /* 25 = stime */
+       4, 0, ptrace,                   /* 26 = ptrace */
+       1, 0, alarm,                    /* 27 = alarm */
+       2, 0, fstat,                    /* 28 = fstat */
+       0, 0, pause,                    /* 29 = pause */
+       2, 0, utime,                    /* 30 = utime */
+       2, 0, stty,                     /* 31 = stty */
+       2, 0, gtty,                     /* 32 = gtty */
+       2, 0, saccess,                  /* 33 = access */
+       1, 0, nice,                     /* 34 = nice */
+       1, 0, ftime,                    /* 35 = ftime; formally sleep;  */
+       0, 0, sync,                     /* 36 = sync */
+       2, 0, kill,                     /* 37 = kill */
+       0, 0, nullsys,                  /* 38 = switch; inoperative */
+       0, 0, nullsys,                  /* 39 = setpgrp (not in yet) */
+       0, 0, nosys,                    /* 40 = tell - obsolete */
+       2, 0, dup,                              /* 41 = dup */
+       0, 0, pipe,                     /* 42 = pipe */
+       1, 0, times,                    /* 43 = times */
+       4, 0, profil,                   /* 44 = prof */
+       0, 0, nosys,                    /* 45 = tiu */
+       1, 0, setgid,                   /* 46 = setgid */
+       0, 0, getgid,                   /* 47 = getgid */
+       2, 0, ssig,                     /* 48 = sig */
+       0, 0, nosys,                    /* 49 = reserved for USG */
+       0, 0, nosys,                    /* 50 = reserved for USG */
+       1, 0, sysacct,                  /* 51 = turn acct off/on */
+       3, 0, sysphys,                  /* 52 = set user physical addresses */
+       1, 0, syslock,                  /* 53 = lock user in core */
+       3, 0, ioctl,                    /* 54 = ioctl */
+       0, 0, nosys,                    /* 55 = reboot */
+       4, 0, mpxchan,                  /* 56 = creat mpx comm channel */
+       0, 0, nosys,                    /* 57 = reserved for USG */
+       0, 0, nosys,                    /* 58 = reserved for USG */
+       3, 0, exece,                    /* 59 = exece */
+       1, 0, umask,                    /* 60 = umask */
+       1, 0, chroot,                   /* 61 = chroot */
+       1, 0, nosys,            /* 62 = unused */
+       0, 0, nosys                     /* 63 = used internally */
+};
diff --git a/usr/src/sys/sys/tdump.c b/usr/src/sys/sys/tdump.c
new file mode 100644 (file)
index 0000000..2bf0330
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Dump core to magtape
+ * Assumes memory mapping has been disabled
+ * and IPL has be set high ( > 0x15 )
+ */
+
+
+#define PHYSPAGES 1024
+#define UBA 0x20006000
+#define mba0 0x20010000
+#define mba1 0x20012000
+
+struct mba_regs {
+       int mba_csr,
+           mba_cr,
+           mba_sr,
+           mba_var,
+           mba_bcr;
+};
+
+struct device
+{
+       int     htcs1;
+       int     htds;
+       int     hter;
+       int     htmr;
+       int     htas;
+       int     htfc;
+       int     htdt;
+       int     htck;
+       int     htsn;
+       int     httc;
+};
+
+#define        HTADDR  ((struct device *)(mba1 + 0x400))
+#define HTMAP ((int *) (mba1 + 0x800))
+
+#define        GO      01
+#define        WCOM    060
+#define        RCOM    070
+#define        NOP     0
+#define        WEOF    026
+#define        SFORW   030
+#define        SREV    032
+#define        ERASE   024
+#define        REW     06
+#define        DCLR    010
+#define P800   01300           /* 800 + pdp11 mode */
+#define        P1600   02300           /* 1600 + pdp11 mode */
+#define        IENABLE 0100
+#define        RDY     0200
+#define        TM      04
+#define        DRY     0200
+#define EOT    02000
+#define CS     02000
+#define COR    0100000
+#define PES    040
+#define WRL    04000
+#define MOL    010000
+#define ERR    040000
+#define FCE    01000
+#define        TRE     040000
+#define HARD   064023  /* UNS|OPI|NEF|FMT|RMR|ILR|ILF */
+
+#define        SIO     1
+#define        SSFOR   2
+#define        SSREV   3
+#define SRETRY 4
+#define SCOM   5
+#define SOK    6
+
+dump()
+{
+
+       HTADDR->httc = P800;    /* set 800 bpi mode */
+
+       twall((char *)0, PHYSPAGES);    /* write out memory */
+
+       teof();
+       teof();
+       rewind();
+       twait();
+}
+
+twall(start, num)
+       char *start;
+       int num;
+{
+       HTADDR->htcs1 = DCLR | GO;
+       while (num--) {
+               twrite(start);
+               start += 512;
+               }
+}
+
+twrite(buf)
+char *buf;
+{
+
+       twait();
+       HTADDR->htfc = -512;
+       *HTMAP = (((int)buf)>>9) | 0x80000000;  /* map entry */
+       ((struct mba_regs *)mba1)->mba_sr = -1;
+       ((struct mba_regs *)mba1)->mba_bcr = -512;
+       ((struct mba_regs *)mba1)->mba_var = 0;
+       HTADDR->htcs1 = WCOM | GO;
+       return;
+}
+
+twait()
+{
+       register s;
+
+       do
+               s = HTADDR->htds;
+       while ((s & RDY) == 0);
+}
+
+rewind()
+{
+       twait();
+       HTADDR->htcs1 = REW | GO;
+}
+
+teof()
+{
+       twait();
+       HTADDR->htcs1 = WEOF | GO;
+}
diff --git a/usr/src/sys/sys/text.c b/usr/src/sys/sys/text.c
new file mode 100644 (file)
index 0000000..4b4b924
--- /dev/null
@@ -0,0 +1,365 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/uba.h"
+#include "../h/map.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/proc.h"
+#include "../h/text.h"
+#include "../h/inode.h"
+#include "../h/buf.h"
+#include "../h/seg.h"
+#include "../h/page.h"
+
+/*
+ * Swap out process p.
+ * The ff flag causes its core to be freed--
+ * it may be off when called to create an image for a
+ * child process in newproc.
+ * On a partial swap ff is the negative number of blocks to be swapped.
+ * Os is the old size  of the process,
+ * and is supplied during core expansion swaps.
+ * Ss is the old stack size for core expansion swaps.
+ *
+ * panic: out of swap space
+ */
+
+int xswapwant, xswaplock;
+
+xswap(p, ff, os, ss)
+register struct proc *p;
+{
+       extern int Xswapmap[], xswaputl[], Xswap2map[], xswap2utl[];
+       register int *map, *utl;
+       register a,i,stkpage,uflag;
+       int s, szpt;
+
+       uflag = 0;
+       s = 1;
+       map = Xswapmap;
+       utl = xswaputl;
+       if (xswaplock & s)
+               if ((xswaplock & 2) == 0) {
+                       s = 2;
+                       map = Xswap2map;
+                       utl = xswap2utl;
+               }
+       a = spl6();
+       while (xswaplock & s) {
+               xswapwant |= s;
+               sleep((caddr_t)map, PSWP);
+       }
+       xswaplock |= s;
+       splx(a);
+       if(os == 0)
+               os = p->p_size;
+       ptaccess(p, map, utl);
+       szpt = ((struct user *)utl)->u_pcb.pcb_szpt;
+       os -= UPAGES;   /* we don't worry about u-area (only sometimes) */
+       if (ss == -1)
+               ss = ((struct user *)utl)->u_ssize;
+       p->p_flag |= SLOCK;
+       if ((p->p_flag & SSPART) == 0)  {
+               a = malloc(swapmap, ctod(p->p_size));
+               if(a == NULL)
+                       panic("out of swap space");
+               if (p->p_textp)
+                       xccdec(p->p_textp, p);
+               p->p_swaddr = a;
+               p->p_swsize = 0;
+               for(i=0; i<ss; i++)
+                       utl[UPAGES*128+p->p_tsize+os-ss+i] =
+                           utl[UPAGES*128+szpt*128-ss+i];
+       }
+       if ( (os + UPAGES) == p->p_size) {
+               if (ff >= 0)    /* do a complete swap */
+                       swap(p, a, p->p_tsize, p->p_size, B_WRITE, 1);
+               else {
+                       p->p_flag |= SSPART;    /* partial  swap */
+                       i = p->p_tsize+(p->p_swsize ? p->p_swsize-UPAGES:0);
+                       swap(p, p->p_swaddr+p->p_swsize, i, -ff,
+                           B_WRITE, uflag=(p->p_swsize?0:1));
+                       p->p_swsize += -ff;             /* new swap total */
+                       if (p->p_swsize == p->p_size) {
+                               a = p->p_swaddr;
+                               p->p_flag &= ~SSPART;
+                       }
+               }
+       } else {
+               swap(p, a, p->p_tsize, os+UPAGES-ss, B_WRITE, 1);
+               swap(p, a+p->p_size-ss, p->p_tsize+os-ss, ss, B_WRITE, 0);
+       }
+       p->p_flag &= ~SLOAD;
+       if (ff)  {
+               if (ff > 0)
+                       memfree(utl+128*UPAGES+p->p_tsize, os);
+               else
+                       memfree(utl+UPAGES*128+p->p_tsize+p->p_swsize
+                           +ff-UPAGES*(1-uflag), -ff-uflag*UPAGES);
+               if ((p->p_flag & SSPART) == 0)
+                       memfree(map, UPAGES+szpt);
+       } else {
+               stkpage = UPAGES*128 + p->p_tsize + os - 1;
+               for(i=0; i<ss; i++) {
+                       utl[UPAGES*128+szpt*128-1-i] =
+                           utl[stkpage-i];
+                       if (stkpage!=(UPAGES*128+szpt*128-1))
+                               utl[stkpage-i] = 0;
+               }
+       }
+       p->p_flag &= ~SLOCK;
+       p->p_time = 0;
+       if(runout) {
+               runout = 0;
+               wakeup((caddr_t)&runout);
+       }
+       xswaplock &= ~s;
+       if (xswapwant & s) {
+               xswapwant &= ~s;
+               wakeup((caddr_t)map);
+       }
+}
+
+/*
+ * relinquish use of the shared text segment
+ * of a process.
+ */
+xfree()
+{
+       register struct text *xp;
+       register struct inode *ip;
+
+       if((xp=u.u_procp->p_textp) == NULL)
+               return;
+       xlock(xp);
+       xp->x_flag &= ~XLOCK;
+       u.u_procp->p_textp = NULL;
+       ip = xp->x_iptr;
+       if(--xp->x_count==0 && (ip->i_mode&ISVTX)==0) {
+               xp->x_iptr = NULL;
+               mfree(swapmap, ctod(xp->x_size), xp->x_daddr);
+               memfree(((int *)&u) + UPAGES*128, u.u_tsize);
+               ip->i_flag &= ~ITEXT;
+               if (ip->i_flag&ILOCK)
+                       ip->i_count--;
+               else
+                       iput(ip);
+       } else
+               xccdec(xp, u.u_procp);
+}
+
+/*
+ * Attach to a shared text segment.
+ * If there is no shared text, just return.
+ * If there is, hook up to it:
+ * if it is not currently being used, it has to be read
+ * in from the inode (ip); the written bit is set to force it
+ * to be written out as appropriate.
+ * If it is being used, but is not currently in core,
+ * a swap has to be done to get it back.
+ */
+xalloc(ip)
+register struct inode *ip;
+{
+       register struct text *xp;
+       register ts,i;
+       register struct text *xp1;
+       register  struct  proc *p;
+       extern int Xallmap[], xallutl[];
+
+       if(u.u_exdata.ux_tsize == 0)
+               return;
+       xp1 = NULL;
+       for (xp = &text[0]; xp < &text[NTEXT]; xp++) {
+               if(xp->x_iptr == NULL) {
+                       if(xp1 == NULL)
+                               xp1 = xp;
+                       continue;
+               }
+               if(xp->x_iptr == ip) {
+                       xlock(xp);
+                       xp->x_count++;
+                       u.u_procp->p_textp = xp;
+                       if (xp->x_ccount == 0)
+                               xexpand(xp);
+                       else {
+                               xp->x_ccount++;
+                               if (xp->x_caddr == 0)   /* must find the text */
+                                       for(p= &proc[0]; p<&proc[NPROC]; p++)
+                                               if ((p->p_flag&SLOAD) && p->p_textp==xp
+                                                    && (p->p_flag&SLOCK)==0 && p!=u.u_procp) {
+                                                       xp->x_caddr = p;
+                                                       break;
+                                               }
+                               if (xp->x_caddr == 0)
+                                       panic("lost text");
+                               ptaccess(xp->x_caddr, Xallmap, xallutl);
+                               for(i=UPAGES*128; i<UPAGES*128+xp->x_size; i++)
+                                       ((int *)&u)[i] = xallutl[i];
+                       }
+                       xunlock(xp);
+                       return;
+               }
+       }
+       if((xp=xp1) == NULL) {
+               printf("out of text");
+               psignal(u.u_procp, SIGKIL);
+               return;
+       }
+       xp->x_flag = XLOAD|XLOCK;
+       xp->x_count = 1;
+       xp->x_ccount = 0;
+       xp->x_iptr = ip;
+       ip->i_flag |= ITEXT;
+       ip->i_count++;
+       ts = btoc(u.u_exdata.ux_tsize);
+       xp->x_size = ts;
+       if((xp->x_daddr = malloc(swapmap, ctod(ts))) == NULL)
+               panic("out of swap space");
+       u.u_procp->p_textp = xp;
+       xexpand(xp);
+       chgprot(RW,0,0);
+       u.u_count = u.u_exdata.ux_tsize;
+       u.u_offset = sizeof(u.u_exdata);
+       u.u_base = 0;
+       u.u_segflg = 2;
+       u.u_procp->p_flag |= SLOCK;
+       readi(ip);
+       chgprot(RO,0,0);
+       u.u_procp->p_flag &= ~SLOCK;
+       u.u_segflg = 0;
+       xp->x_flag = XWRIT;
+}
+
+/*
+ * Assure core for text segment
+ * Text must be locked to keep someone else from
+ * freeing it in the meantime.
+ * x_ccount must be 0.
+ */
+xexpand(xp)
+register  struct text *xp;
+{
+
+       if (memall(((int *)&u) + UPAGES*128, btoc(u.u_exdata.ux_tsize)) != NULL) {
+               xp->x_caddr = u.u_procp;
+               if ((xp->x_flag&XLOAD)==0)
+                       swap(u.u_procp,xp->x_daddr,0, xp->x_size, B_READ,0);
+               xp->x_ccount++;
+               chgprot(RO,0,0);
+               xunlock(xp);
+               return;
+       }
+       if (save(u.u_ssav)) {
+               return;
+       }
+       xswap(u.u_procp, 1, 0,-1);
+       xunlock(xp);
+       u.u_procp->p_flag |= SSWAP;
+       qswtch();
+       /* no return */
+}
+
+/*
+ * Lock and unlock a text segment from swapping
+ */
+xlock(xp)
+register struct text *xp;
+{
+
+       while(xp->x_flag&XLOCK) {
+               xp->x_flag |= XWANT;
+               sleep((caddr_t)xp, PSWP);
+       }
+       xp->x_flag |= XLOCK;
+}
+
+xunlock(xp)
+register struct text *xp;
+{
+
+       if (xp->x_flag&XWANT)
+               wakeup((caddr_t)xp);
+       xp->x_flag &= ~(XLOCK|XWANT);
+}
+
+/*
+ * Decrement the in-core usage count of a shared text segment.
+ * When it drops to zero, free the core space.
+ */
+xccdec(xp, p)
+register struct text *xp;
+register struct proc *p;
+{
+       extern int Xccdmap[], xccdutl[];
+
+       if (xp==NULL || xp->x_ccount==0)
+               return;
+       xlock(xp);
+       if (--xp->x_ccount==0) {
+               if (xp->x_flag&XWRIT) {
+                       xp->x_flag &= ~XWRIT;
+                       swap(p,xp->x_daddr,0,xp->x_size,B_WRITE,0);
+               }
+               ptaccess(p, Xccdmap, xccdutl);
+               memfree(xccdutl + UPAGES*128, p->p_tsize);
+       }
+       if (xp->x_caddr == p)
+               xp->x_caddr = 0;        /* page table no longer valid */
+
+       xunlock(xp);
+}
+
+/*
+ * free the swap image of all unused saved-text text segments
+ * which are from device dev (used by umount system call).
+ */
+xumount(dev)
+register dev;
+{
+       register struct text *xp;
+
+       for (xp = &text[0]; xp < &text[NTEXT]; xp++) 
+               if (xp->x_iptr!=NULL && dev==xp->x_iptr->i_dev)
+                       xuntext(xp);
+}
+
+/*
+ * remove a shared text segment from the text table, if possible.
+ */
+xrele(ip)
+register struct inode *ip;
+{
+       register struct text *xp;
+
+       if (ip->i_flag&ITEXT==0)
+               return;
+       for (xp = &text[0]; xp < &text[NTEXT]; xp++)
+               if (ip==xp->x_iptr)
+                       xuntext(xp);
+}
+
+/*
+ * remove text image from the text table.
+ * the use count must be zero.
+ */
+xuntext(xp)
+register struct text *xp;
+{
+       register struct inode *ip;
+
+       xlock(xp);
+       if (xp->x_count) {
+               xunlock(xp);
+               return;
+       }
+       ip = xp->x_iptr;
+       xp->x_flag &= ~XLOCK;
+       xp->x_iptr = NULL;
+       mfree(swapmap, ctod(xp->x_size), xp->x_daddr);
+       ip->i_flag &= ~ITEXT;
+       if (ip->i_flag&ILOCK)
+               ip->i_count--;
+       else
+               iput(ip);
+}
diff --git a/usr/src/sys/sys/trap.c b/usr/src/sys/sys/trap.c
new file mode 100644 (file)
index 0000000..a29c56c
--- /dev/null
@@ -0,0 +1,158 @@
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/proc.h"
+#include "../h/reg.h"
+#include "../h/seg.h"
+#include "../h/trap.h"
+#include "../h/psl.h"
+
+#define        USER    040             /* user-mode flag added to type */
+
+struct sysent  sysent[64];
+
+/*
+ * Called from the trap handler when a processor trap occurs.
+ */
+trap(params, r0, r1, r2, r3, r4, r5 ,r6, r7, r8, r9, r10,
+       r11, r12, r13, sp, type, code, pc, psl)
+caddr_t params;
+{
+       register i, a;
+       register struct sysent *callp;
+       register caddr_t errorp;
+       register time_t syst;
+       register int *locr0;
+
+       locr0 = &r0;
+       syst = u.u_stime;
+       u.u_ar0 = locr0;
+       if (USERMODE(locr0[PS]))
+               type |= USER;
+       u.u_ar0 = locr0;
+       switch (type) {
+
+       /*
+        * Trap not expected.
+        * Usually a kernel mode bus error.
+        */
+       default:
+               printf("user = ");
+               for(i=0; i<UPAGES; i++)
+                       printf("%x ", u.u_procp->p_addr[i]);
+               printf("\n");
+               printf("ps = %x\n", locr0[PS]);
+               printf("pc = %x\n", locr0[PC]);
+               printf("trap type %x\n", type);
+               printf("code = %x\n", code);
+               panic("trap");
+
+       case PROTFLT + USER:    /* protection fault */
+               i = SIGBUS;
+               break;
+
+       case PRIVINFLT + USER:  /* privileged instruction fault */
+       case RESADFLT + USER:   /* reserved addressing fault */
+       case RESOPFLT + USER:   /* resereved operand fault */
+               i = SIGINS;
+               break;
+
+       case RESCHED + USER:    /* Allow process switch */
+               goto out;
+
+       case SYSCALL + USER: /* sys call */
+               params += NBPW;         /* skip word with param count */
+               u.u_error = 0;
+               callp = &sysent[code&077];
+               if (callp == sysent) { /* indirect */
+                       a = fuword(params);
+                       params += NBPW;
+                       callp = &sysent[a&077];
+               }
+               for(i=0; i<callp->sy_narg; i++) {
+                       u.u_arg[i] = fuword(params);
+                       params += NBPW;
+               }
+               u.u_ap = u.u_arg;
+               locr0[PS] &= ~PSL_C;
+               u.u_dirp = (caddr_t)u.u_arg[0];
+               u.u_r.r_val1 = 0;
+               u.u_r.r_val2 = locr0[R1];
+               if(save(u.u_qsav)){
+                       if(u.u_error==0)
+                               u.u_error = EINTR;
+               } else {
+                       (*(callp->sy_call))();
+               }
+               if(u.u_error) {
+                       locr0[R0] = u.u_error;
+                       locr0[PS] |= PSL_C;     /* carry bit */
+                } else {
+                       locr0[R0] = u.u_r.r_val1;
+                       locr0[R1] = u.u_r.r_val2;
+               }
+               goto out;
+
+       case ARITHTRAP + USER:
+               i = SIGFPT;
+               break;
+
+       /*
+        * If the user SP is above the stack segment,
+        * grow the stack automatically.
+        */
+       case SEGFLT + USER: /* segmentation exception */
+               if(grow(locr0[SP]) || grow(code))
+                       goto out;
+               i = SIGSEG;
+               break;
+
+       case BPTFLT + USER:     /* bpt instruction fault */
+       case TRCTRAP + USER:    /* trace trap */
+               locr0[PS] &= ~PSL_T;    /* turn off trace bit */
+               i = SIGTRC;
+               break;
+
+       case XFCFLT + USER:     /* xfc instruction fault */
+               i = SIGEMT;
+               break;
+
+       case COMPATFLT + USER: /* compatibility mode fault */
+                               /* so far, just send a SIGINS signal */
+               i = SIGINS;
+               break;
+
+       }
+       psignal(u.u_procp, i);
+
+out:
+       if(issig())
+               psig();
+       curpri = setpri(u.u_procp);
+       if (runrun)
+               qswtch();
+       if(u.u_prof.pr_scale)
+               addupc((caddr_t)locr0[PC], &u.u_prof, (int)(u.u_stime-syst));
+       return;
+}
+
+/*
+ * nonexistent system call-- set fatal error code.
+ */
+nosys()
+{
+       u.u_error = 100;
+}
+
+/*
+ * Ignored system call
+ */
+nullsys()
+{
+}
+
+random(dev, stat, ps, pc, ccb)
+{
+       printf("Random interrupt, device %x\n", dev);
+}
diff --git a/usr/src/sys/sys/tty.c b/usr/src/sys/sys/tty.c
new file mode 100644 (file)
index 0000000..7e98f44
--- /dev/null
@@ -0,0 +1,631 @@
+#
+/*
+ * general TTY subroutines
+ */
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/tty.h"
+#include "../h/proc.h"
+#include "../h/mx.h"
+#include "../h/inode.h"
+#include "../h/file.h"
+#include "../h/reg.h"
+#include "../h/conf.h"
+
+char   partab[];
+
+/*
+ * Input mapping table-- if an entry is non-zero, when the
+ * corresponding character is typed preceded by "\" the escape
+ * sequence is replaced by the table value.  Mostly used for
+ * upper-case only terminals.
+ */
+
+char   maptab[] ={
+       000,000,000,000,CEOT,00,000,000,
+       000,000,000,000,000,000,000,000,
+       000,000,000,000,000,000,000,000,
+       000,000,000,000,000,000,000,000,
+       000,'|',000,000,000,000,000,'`',
+       '{','}',000,000,000,000,000,000,
+       000,000,000,000,000,000,000,000,
+       000,000,000,000,000,000,000,000,
+       000,000,000,000,000,000,000,000,
+       000,000,000,000,000,000,000,000,
+       000,000,000,000,000,000,000,000,
+       000,000,000,000,000,000,'~',000,
+       000,'A','B','C','D','E','F','G',
+       'H','I','J','K','L','M','N','O',
+       'P','Q','R','S','T','U','V','W',
+       'X','Y','Z',000,000,000,000,000,
+};
+
+/*
+ * routine called on first teletype open.
+ * establishes a process group for distribution
+ * of quits and interrupts from the tty.
+ */
+ttyopen(dev, tp)
+dev_t dev;
+register struct tty *tp;
+{
+       register struct proc *pp;
+
+       pp = u.u_procp;
+       if(pp->p_pgrp == 0) {
+               u.u_ttyp = tp;
+               u.u_ttyd = dev;
+               if (tp->t_pgrp==0)
+                       tp->t_pgrp = pp->p_pid;
+               pp->p_pgrp = tp->t_pgrp;
+       }
+       tp->t_state &= ~WOPEN;
+       tp->t_state |= ISOPEN;
+}
+
+/*
+ * clean tp on last close
+ */
+ttyclose(tp)
+register struct tty *tp;
+{
+
+       tp->t_pgrp = 0;
+       wflushtty(tp);
+       tp->t_state = 0;
+}
+
+/*
+ * stty/gtty writearound
+ */
+stty()
+{
+       u.u_arg[2] = u.u_arg[1];
+       u.u_arg[1] = TIOCSETP;
+       ioctl();
+}
+
+gtty()
+{
+       u.u_arg[2] = u.u_arg[1];
+       u.u_arg[1] = TIOCGETP;
+       ioctl();
+}
+
+/*
+ * ioctl system call
+ * Check legality, execute common code, and switch out to individual
+ * device routine.
+ */
+ioctl()
+{
+       register struct file *fp;
+       register struct inode *ip;
+       register struct a {
+               int     fdes;
+               int     cmd;
+               caddr_t cmarg;
+       } *uap;
+       register dev_t dev;
+       register fmt;
+
+       uap = (struct a *)u.u_ap;
+       if ((fp = getf(uap->fdes)) == NULL)
+               return;
+       if (uap->cmd==FIOCLEX) {
+               u.u_pofile[uap->fdes] |= EXCLOSE;
+               return;
+       }
+       if (uap->cmd==FIONCLEX) {
+               u.u_pofile[uap->fdes] &= ~EXCLOSE;
+               return;
+       }
+       ip = fp->f_inode;
+       fmt = ip->i_mode & IFMT;
+       if (fmt != IFCHR && fmt != IFMPC) {
+               u.u_error = ENOTTY;
+               return;
+       }
+       dev = (dev_t)ip->i_un.i_rdev;
+       (*cdevsw[major(dev)].d_ioctl)(dev, uap->cmd, uap->cmarg, fp->f_flag&(FREAD|FWRITE));
+}
+
+/*
+ * Common code for several tty ioctl commands
+ */
+ttioccomm(com, tp, addr, dev)
+register struct tty *tp;
+caddr_t addr;
+{
+       unsigned t;
+       struct ttiocb iocb;
+       extern int nldisp;
+
+       switch(com) {
+
+       /*
+        * get discipline number
+        */
+       case TIOCGETD:
+               t = tp->t_line;
+               if (copyout((caddr_t)&t, addr, sizeof(t)))
+                       u.u_error = EFAULT;
+               break;
+
+       /*
+        * set line discipline
+        */
+       case TIOCSETD:
+               if (copyin(addr, (caddr_t)&t, sizeof(t))) {
+                       u.u_error = EFAULT;
+                       break;
+               }
+               if (t >= nldisp) {
+                       u.u_error = ENXIO;
+                       break;
+               }
+               if (tp->t_line)
+                       (*linesw[tp->t_line].l_close)(tp);
+               if (t)
+                       (*linesw[t].l_open)(dev, tp, addr);
+               if (u.u_error==0)
+                       tp->t_line = t;
+               break;
+
+       /*
+        * prevent more opens on channel
+        */
+       case TIOCEXCL:
+               tp->t_state |= XCLUDE;
+               break;
+       case TIOCNXCL:
+               tp->t_state &= ~XCLUDE;
+               break;
+
+       /*
+        * Set new parameters
+        */
+       case TIOCSETP:
+               wflushtty(tp);
+       case TIOCSETN:
+               if (copyin(addr, (caddr_t)&iocb, sizeof(iocb))) {
+                       u.u_error = EFAULT;
+                       return(1);
+               }
+               tp->t_ispeed = iocb.ioc_ispeed;
+               tp->t_ospeed = iocb.ioc_ospeed;
+               tp->t_erase = iocb.ioc_erase;
+               tp->t_kill = iocb.ioc_kill;
+               tp->t_flags = iocb.ioc_flags;
+               break;
+
+       /*
+        * send current parameters to user
+        */
+       case TIOCGETP:
+               iocb.ioc_ispeed = tp->t_ispeed;
+               iocb.ioc_ospeed = tp->t_ospeed;
+               iocb.ioc_erase = tp->t_erase;
+               iocb.ioc_kill = tp->t_kill;
+               iocb.ioc_flags = tp->t_flags;
+               if (copyout((caddr_t)&iocb, addr, sizeof(iocb)))
+                       u.u_error = EFAULT;
+               break;
+
+       /*
+        * Hang up line on last close
+        */
+
+       case TIOCHPCL:
+               tp->t_state |= HUPCLS;
+               break;
+
+       /*
+        * toggle TTSTOP from user program
+        */
+       case TIOCTSTP:
+               tp->t_state ^= TTSTOP;
+               ttstart(tp);
+               break;
+
+       /*
+        * ioctl entries to line discipline
+        */
+       case DIOCSETP:
+       case DIOCGETP:
+               (*linesw[tp->t_line].l_ioctl)(com, tp, addr);
+               break;
+       default:
+               return(0);
+       }
+       return(1);
+}
+
+/*
+ * Wait for output to drain, then flush input waiting.
+ */
+wflushtty(tp)
+register struct tty *tp;
+{
+
+       spl5();
+       while (tp->t_outq.c_cc && tp->t_state&CARR_ON) {
+               (*tp->t_oproc)(tp);
+               tp->t_state |= ASLEEP;
+               sleep((caddr_t)&tp->t_outq, TTOPRI);
+       }
+       flushtty(tp);
+       spl0();
+}
+
+/*
+ * flush all TTY queues
+ */
+flushtty(tp)
+register struct tty *tp;
+{
+       register s;
+
+       while (getc(&tp->t_canq) >= 0)
+               ;
+       while (getc(&tp->t_outq) >= 0)
+               ;
+       wakeup((caddr_t)&tp->t_rawq);
+       wakeup((caddr_t)&tp->t_outq);
+       s = spl5();
+       while (getc(&tp->t_rawq) >= 0)
+               ;
+       tp->t_delct = 0;
+       splx(s);
+}
+
+/*
+ * transfer raw input list to canonical list,
+ * doing erase-kill processing and handling escapes.
+ * It waits until a full line has been typed in cooked mode,
+ * or until any character has been typed in raw mode.
+ */
+canon(tp)
+register struct tty *tp;
+{
+       register char *bp;
+       char *bp1;
+       register int c;
+       int mc;
+
+       spl5();
+       while ((tp->t_flags&(RAW|CBREAK))==0 && tp->t_delct==0
+           || (tp->t_flags&(RAW|CBREAK))!=0 && tp->t_rawq.c_cc==0) {
+               if ((tp->t_state&CARR_ON)==0 || tp->t_chan!=NULL) {
+                       return(0);
+               }
+               sleep((caddr_t)&tp->t_rawq, TTIPRI);
+       }
+       spl0();
+loop:
+       bp = &canonb[2];
+       while ((c=getc(&tp->t_rawq)) >= 0) {
+               if ((tp->t_flags&(RAW|CBREAK))==0) {
+                       if (c==0377) {
+                               tp->t_delct--;
+                               break;
+                       }
+                       if (bp[-1]!='\\') {
+                               if (c==tp->t_erase) {
+                                       if (bp > &canonb[2])
+                                               bp--;
+                                       continue;
+                               }
+                               if (c==tp->t_kill)
+                                       goto loop;
+                               if (c==CEOT)
+                                       continue;
+                       } else {
+                               mc = maptab[c] & 0177;
+                               if (c==tp->t_erase || c==tp->t_kill)
+                                       mc = c;
+                               if (mc && (mc==c || (tp->t_flags&LCASE))) {
+                                       if (bp[-2] != '\\')
+                                               c = mc;
+                                       bp--;
+                               }
+                       }
+               }
+               *bp++ = c;
+               if (bp>=canonb+CANBSIZ)
+                       break;
+       }
+       bp1 = bp;
+       bp = &canonb[2];
+       while (bp<bp1)
+               putc(*bp++, &tp->t_canq);
+
+
+       if (tp->t_state&TBLOCK && tp->t_rawq.c_cc < TTYHOG/5) 
+               if (putc(CSTOP, &tp->t_outq)==0) {
+                       tp->t_state &= ~TBLOCK;
+                       ttstart(tp);
+               }
+
+
+       return(bp1 - &canonb[2]);
+}
+
+/*
+ * Place a character on raw TTY input queue, putting in delimiters
+ * and waking up top half as needed.
+ * Also echo if required.
+ * The arguments are the character and the appropriate
+ * tty structure.
+ */
+ttyinput(c, tp)
+register c;
+register struct tty *tp;
+{
+       register int t_flags;
+       register struct chan *cp;
+
+       tk_nin += 1;
+       c &= 0377;
+       t_flags = tp->t_flags;
+       if (t_flags&TANDEM) {
+               if (tp->t_rawq.c_cc >= TTYHOG/2 && (tp->t_state&TBLOCK)==0) {
+                       if (putc(CSTOP, &tp->t_outq)==0) {
+                               tp->t_state |= TBLOCK;
+                               ttstart(tp);
+                       }
+               }
+       }
+       if ((t_flags&RAW)==0) {
+               c &= 0177;
+               if (c==CSTOP) {
+                       tp->t_state ^= TTSTOP;
+                       ttstart(tp);
+                       return;
+               }
+               tp->t_state &= ~TTSTOP;
+               if (c==CQUIT || c==CINTR) {
+                       signal(tp->t_pgrp, c==CINTR? SIGINT:SIGQUIT);
+                       flushtty(tp);
+                       return;
+               }
+               if (c=='\r' && t_flags&CRMOD)
+                       c = '\n';
+       }
+       if (tp->t_rawq.c_cc>TTYHOG) {
+               flushtty(tp);
+               return;
+       }
+       if (t_flags&LCASE && c>='A' && c<='Z')
+               c += 'a'-'A';
+       putc(c, &tp->t_rawq);
+       if (t_flags&(RAW|CBREAK) || (c=='\n' || c==CEOT)) {
+               if ((t_flags&(RAW|CBREAK))==0 && putc(0377, &tp->t_rawq)==0)
+                       tp->t_delct++;
+                       if ((cp=tp->t_chan)!=NULL)
+                               sdata(cp); else
+                               wakeup((caddr_t)&tp->t_rawq);
+       }
+       if (t_flags&ECHO) {
+               ttyoutput(c, tp);
+               if (c==tp->t_kill && (t_flags&(RAW|CBREAK))==0)
+                       ttyoutput('\n', tp);
+               ttstart(tp);
+       }
+}
+
+/*
+ * put character on TTY output queue, adding delays,
+ * expanding tabs, and handling the CR/NL bit.
+ * It is called both from the top half for output, and from
+ * interrupt level for echoing.
+ * The arguments are the character and the tty structure.
+ */
+ttyoutput(c, tp)
+register c;
+register struct tty *tp;
+{
+       register char *colp;
+       register ctype;
+
+       tk_nout += 1;
+       /*
+        * Ignore EOT in normal mode to avoid hanging up
+        * certain terminals.
+        * In raw mode dump the char unchanged.
+        */
+
+       if ((tp->t_flags&RAW)==0) {
+               c &= 0177;
+               if (c==CEOT)
+                       return;
+       } else {
+               putc(c, &tp->t_outq);
+               return;
+       }
+
+
+       if (tp->t_flags&TANDEM && (c&0177)==CSTOP)
+               return;
+
+
+       /*
+        * Turn tabs to spaces as required
+        */
+       if (c=='\t' && (tp->t_flags&TBDELAY)==XTABS) {
+               c = 8;
+               do
+                       ttyoutput(' ', tp);
+               while (--c >= 0 && tp->t_col&07);
+               return;
+       }
+       /*
+        * for upper-case-only terminals,
+        * generate escapes.
+        */
+       if (tp->t_flags&LCASE) {
+               colp = "({)}!|^~'`";
+               while(*colp++)
+                       if(c == *colp++) {
+                               ttyoutput('\\', tp);
+                               c = colp[-2];
+                               break;
+                       }
+               if ('a'<=c && c<='z')
+                       c += 'A' - 'a';
+       }
+       /*
+        * turn <nl> to <cr><lf> if desired.
+        */
+       if (c=='\n' && tp->t_flags&CRMOD)
+               ttyoutput('\r', tp);
+       putc(c, &tp->t_outq);
+       /*
+        * Calculate delays.
+        * The numbers here represent clock ticks
+        * and are not necessarily optimal for all terminals.
+        * The delays are indicated by characters above 0200.
+        * In raw mode there are no delays and the
+        * transmission path is 8 bits wide.
+        */
+       colp = &tp->t_col;
+       ctype = partab[c];
+       c = 0;
+       switch (ctype&077) {
+
+       /* ordinary */
+       case 0:
+               (*colp)++;
+
+       /* non-printing */
+       case 1:
+               break;
+
+       /* backspace */
+       case 2:
+               if (*colp)
+                       (*colp)--;
+               break;
+
+       /* newline */
+       case 3:
+               ctype = (tp->t_flags >> 8) & 03;
+               if(ctype == 1) { /* tty 37 */
+                       if (*colp)
+                               c = max(((unsigned)*colp>>4) + 3, (unsigned)6);
+               } else
+               if(ctype == 2) { /* vt05 */
+                       c = 6;
+               }
+               *colp = 0;
+               break;
+
+       /* tab */
+       case 4:
+               ctype = (tp->t_flags >> 10) & 03;
+               if(ctype == 1) { /* tty 37 */
+                       c = 1 - (*colp | ~07);
+                       if(c < 5)
+                               c = 0;
+               }
+               *colp |= 07;
+               (*colp)++;
+               break;
+
+       /* vertical motion */
+       case 5:
+               if(tp->t_flags & VTDELAY) /* tty 37 */
+                       c = 0177;
+               break;
+
+       /* carriage return */
+       case 6:
+               ctype = (tp->t_flags >> 12) & 03;
+               if(ctype == 1) { /* tn 300 */
+                       c = 5;
+               } else if(ctype == 2) { /* ti 700 */
+                       c = 10;
+               }
+               *colp = 0;
+       }
+       if(c)
+               putc(c|0200, &tp->t_outq);
+}
+
+/*
+ * Restart typewriter output following a delay
+ * timeout.
+ * The name of the routine is passed to the timeout
+ * subroutine and it is called during a clock interrupt.
+ */
+ttrstrt(tp)
+register struct tty *tp;
+{
+
+       tp->t_state &= ~TIMEOUT;
+       ttstart(tp);
+}
+
+/*
+ * Start output on the typewriter. It is used from the top half
+ * after some characters have been put on the output queue,
+ * from the interrupt routine to transmit the next
+ * character, and after a timeout has finished.
+ */
+ttstart(tp)
+register struct tty *tp;
+{
+       register s;
+
+       s = spl5();
+       if((tp->t_state&(TIMEOUT|TTSTOP|BUSY)) == 0)
+               (*tp->t_oproc)(tp);
+       splx(s);
+}
+
+/*
+ * Called from device's read routine after it has
+ * calculated the tty-structure given as argument.
+ */
+ttread(tp)
+register struct tty *tp;
+{
+       struct chan *chan;
+
+       if ((tp->t_state&CARR_ON)==0)
+               return(0);
+       if (tp->t_canq.c_cc || canon(tp))
+               while (tp->t_canq.c_cc && passc(getc(&tp->t_canq))>=0)
+                       ;
+out:
+       return(tp->t_canq.c_cc);
+}
+
+/*
+ * Called from the device's write routine after it has
+ * calculated the tty-structure given as argument.
+ */
+int TTIME      =100;
+ttwrite(tp)
+register struct tty *tp;
+{
+       register c;
+
+       if ((tp->t_state&CARR_ON)==0)
+               return;
+       while (u.u_count) {
+               spl5();
+               while (tp->t_outq.c_cc > TTIME) {
+                       ttstart(tp);
+                       tp->t_state |= ASLEEP;
+                       if (tp->t_chan) 
+                               return((caddr_t)&tp->t_outq);
+                       sleep((caddr_t)&tp->t_outq, TTOPRI);
+               }
+               spl0();
+               ttyoutput(cpass(), tp);
+       }
+       ttstart(tp);
+}
diff --git a/usr/src/sys/sys/uba.c b/usr/src/sys/sys/uba.c
new file mode 100644 (file)
index 0000000..e93e39a
--- /dev/null
@@ -0,0 +1,107 @@
+# include "../h/param.h"
+#include "../h/uba.h"
+# include "../h/map.h"
+int uballoc(baddr,bcnt,bdpflg)
+char  bdpflg ;
+char * baddr ;
+unsigned short bcnt;
+{
+/*
+*  Allocate as many contiguous UBA mapping registers
+*  as are necessary to do transfer of 'bcnt' bytes
+*  to/from location 'baddr'.
+*  Wait for enough map registers.
+*  'bdpflg' is non-zero if a "buffered data path" (BDP) is
+*  to be used, else 0 -> use direct data path (DDP) .
+*  Return
+*
+*    |31 - - 28|27 - - 18|17 - - - 9|8 - - 0|
+*    |         |         |          |       |
+*    |  BDP    |   no.   |  start   | byte  |
+*    |   no.   | mapping |   map    | offset|
+*    |         |  reg's  | reg. no. |       |
+*    |         |         |          |       |
+*
+*/
+register regnum , nmreg , bdp , pfn , j ;
+/* calculate no. of mapping reg's required */
+nmreg = btoc(bcnt) + 2;
+pfn = ((int)baddr>>9) & 0xfff ; /* start page frame no. */
+spl6() ;
+while ((regnum = malloc(ubamap,nmreg) - 1) < 0) {
+       /* wait for no. of mapping reg's requested */
+       umrwant++ ;
+       sleep(ubamap,PSWP) ;
+       }
+if (bdpflg)  /* buffered data path BDP 1-15 */
+       while ( (bdp=malloc(bdpmap,1)) == NULL)
+               {
+               bdpwant++;
+               sleep(bdpmap, PSWP);
+               }
+else { /* BDP 0 = DDP */
+       bdp = 0 ;
+       }
+spl0() ;
+j = (bdp<<28) | (nmreg<<18) | (regnum<<9) | ((int)baddr & 0x01ff) ;
+pfn |= (MRV | (bdp<<21)) ; /* map reg entry */
+if (bdp && ((int)baddr & 01)) pfn |= BO ; /* byte offset */
+while (--nmreg)  /* fill the memory mapping reg's */
+       ((struct uba_regs *)UBA0)->uba_map[regnum++] = pfn++ ;
+((struct uba_regs *)UBA0)->uba_map[regnum] = 0 ; /* last entry is invalid */
+return(j) ;
+}
+/*                                                     */
+ubafree(mr)
+int mr ;
+{
+/*
+*  Free UBA memory mapping reg's and a BDP no..
+*    mr :
+*              bits 0 - 3 :  bdp no.
+*               4 - 15 : start map reg. no.
+*                      16 - 31 : no. of mapping reg's
+*
+*/
+register bdp , nmreg , regnum ;
+spl6();
+bdp = (mr>>28) & 0x0f ;  /* BDP no. */
+if (bdp)
+       {
+       ((struct uba_regs *)UBA0)->uba_dpr[bdp] |= BNE ; /* purge */
+       mfree(bdpmap, 1, bdp);
+       if (bdpwant) {
+               bdpwant = 0;
+               wakeup(bdpmap);
+       }
+}
+
+nmreg = (mr>>18) & 0x3ff ; /* no. of mapping reg's */
+regnum = (mr>>9) & 0x1ff ; /* 1st map reg. no. */
+/* free mapping reg's */
+mfree(ubamap,nmreg,regnum+1) ;
+if (umrwant) {
+       umrwant = 0;
+       wakeup(ubamap);
+}
+spl0() ;
+}
+
+ubainit()
+{
+       mfree(ubamap, 496, 1);
+       mfree(bdpmap, 15, 1);
+}
diff --git a/usr/src/sys/sys/univec.c b/usr/src/sys/sys/univec.c
new file mode 100644 (file)
index 0000000..cb4b757
--- /dev/null
@@ -0,0 +1,175 @@
+# include "../h/param.h"
+/* controller no.'s for bits 27-31 of ISR addr */
+# define DEV_1  0x08000000
+# define DEV_2  0x10000000
+/* Interrupt Service Routine (ISR) addresses */
+extern ubastray() ;
+extern  dzrint() , dzxint() ;
+int *UNIvec[BSIZE/NBPW] = {
+/* 0x0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x10 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x20 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x30 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x40 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x50 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x60 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x70 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x80 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x90 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0xa0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0xb0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0xc0 */
+       (int *)dzrint,  /* DZ-11 # 0 */
+       (int *)dzxint,
+       (int *)((int)dzrint+DEV_1),     /*  DZ-11  # 1 */
+       (int *)((int)dzxint+DEV_1),
+/* 0xd0 */
+       (int *)ubastray, /* DR-11B, VAX-11/45 link */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0xe0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0xf0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x100 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x110 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x120 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x130 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x140 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x150 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x160 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x170 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x180 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x190 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x1a0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x1b0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x1c0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x1d0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x1e0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+/* 0x1f0 */
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       (int *)ubastray,
+       } ;
+ubastray()
+{
+printf("stray UBA interrupt\n") ;
+}
diff --git a/usr/src/sys/sys/v45lnk.c b/usr/src/sys/sys/v45lnk.c
new file mode 100644 (file)
index 0000000..83bd407
--- /dev/null
@@ -0,0 +1,219 @@
+# include "../h/param.h"
+# include "../h/dir.h"
+# include "../h/user.h"
+# include "../h/proc.h"
+# include "../h/uba.h"
+# include "../h/buf.h"
+/*             */
+# define LNKADR (UBA0_DEV+0172410) /* DR11-B devive reg's */
+/*
+*  UBA0_DEV = 0x80018000
+*  LNKADR = 0x80027508
+*/
+/*  DA11-B  DR-11B Status & Command reg */
+# define ERR  0x8000  /*  error bit */
+# define NEX  0x4000  /*  non-existent memory */
+# define IIR  0x800  /*  Input Interrupt Request */
+# define ID  0x400  /*  Input direction */
+# define IM  0x200  /*  Input mode */
+# define CYCLE  0x100  /* Cycle */
+# define RDY  0x80  /* Ready */
+# define IE  0x40  /*  Interrupt Enable */
+# define OIR  8  /*  Output interrupt request */
+# define OD  4  /* Output direction */
+# define OM  2  /* output mode */
+# define GO  1  /* Go bit */
+/*     states  */
+# define CLOSED 0  /*  closed */
+# define  OPEN  1  /* open  */
+# define  S1  2  /* write state 1 */
+# define  S2  4  /* write state 2 */
+# define  R1  8  /* read state 1 */
+# define  R2  16  /* read state 2 */
+# define L_NOT 128  /*  send OIR to other end link */
+# define IPEND 256
+# define PREread  512  /*  'lnkmon' wait */
+# define L_MON 1024  /* 'lnkmon' decr V11opn */
+# define L_WAKE  2048
+# define BUSY (S1|S2|R1|R2)  /* i-o in progress for driver */
+# define S_ERR  0x8000
+/*             */
+# define  V11PRI  0
+# define BUFSIZ  512
+# define VSPEC  0100000
+/*             */
+struct lnkreg {
+       short drwc , drba , drst , drdb ;
+       } ;
+struct {
+       short state ;
+       struct buf *bp ;
+       } V11tab ;
+char V11opn ;
+/*             */
+V11open(dev,flag)
+{
+struct buf *geteblk() ;
+if (V11opn) {
+       u.u_error = EBUSY;
+       return;
+       }
+V11opn++;
+if (V11tab.bp == 0) /* grab system buffer */
+       V11tab.bp = geteblk() ;  /*  VAX call */
+((struct lnkreg *)LNKADR)->drst |= IE ;
+V11tab.state |= OPEN ;
+}
+/*             */
+V11close(dev,flag) /* called on last close only ! ! */
+{
+V11opn = 0;
+V11tab.state = CLOSED ;
+((struct lnkreg *)LNKADR)->drst = 0 ; /* IE off */
+if (V11tab.bp) brelse(V11tab.bp) ; /* release system buffer */
+V11tab.bp = 0 ;
+}
+/*             */
+V11write(dev)
+{
+register int i , j  , k ;
+/*  INIT clears OUTPUT DIR bit = transmitter */
+spl5() ;
+V11tab.state |= S1 ;
+/* setup for transmit */
+((struct lnkreg *)LNKADR)->drst &= ~(OD) ; /* 0 -> transmitter */
+spl0() ;
+i = uballoc(V11tab.bp->b_un.b_addr,BUFSIZ,1) ; /* get UBA map entry for
+       system buffer and set valid bit & BDP no. & BO bit & load map */
+j = i & 0x3ffff ; /* start map no. & byte offset */
+/* write loop, until done or error */
+while ((u.u_count > 0) && (u.u_error == 0)) {
+       iomove(V11tab.bp->b_un.b_addr,min(BUFSIZ,u.u_count),B_WRITE) ; /* move
+               data from user space to system buffer */
+       ((struct lnkreg *)LNKADR)->drwc = (-(BUFSIZ>>1)) ; /* word count */
+       ((struct lnkreg *)LNKADR)->drba = j ; /* map no. (SBI page) & byte offset */
+       spl5() ;
+       ((struct lnkreg *)LNKADR)->drst |= GO ; /* setup for transfer */
+       sleep(LNKADR,V11PRI) ; /* wait for transfer to finish(interrupt) */
+       spl0() ;
+       if (V11tab.state & S_ERR) {
+               u.u_error = ENXIO ;
+               V11tab.state &= (~S_ERR);
+               }
+       }
+ubafree(i) ;
+((struct lnkreg *)LNKADR)->drst &= (~OM);
+V11tab.state &= (~BUSY) ;
+}
+/*             */
+V11read(dev)
+{
+register i , j  ;
+spl5() ;
+V11tab.state |= R1 ;
+((struct lnkreg *)LNKADR)->drst |= OD ; /* receiver */
+spl0() ;
+i = uballoc(V11tab.bp->b_un.b_addr,BUFSIZ,1) ;
+j = i & 0x3ffff ; /* start map no. & byte offset */
+while ((u.u_count>0) && (u.u_error == 0)) {
+       ((struct lnkreg *)LNKADR)->drwc = (-(BUFSIZ>>1)) ;
+       ((struct lnkreg *)LNKADR)->drba = j ;
+       spl5() ;
+       ((struct lnkreg *)LNKADR)->drst |= GO ;
+       /* wait for i-o to finish */
+       sleep(LNKADR,V11PRI) ;
+       spl0() ;
+       if (V11tab.state & S_ERR) {
+               u.u_error = ENXIO ;
+               V11tab.state &= (~S_ERR);
+               continue ;
+               }
+       iomove(V11tab.bp->b_un.b_addr,min(BUFSIZ,u.u_count),B_READ) ;
+       }
+ubafree(i) ;
+V11tab.state &= (~BUSY) ;
+}
+/*             */
+V11int(dev)
+{
+register unsigned short state ;
+register int i ;
+extern int V11ioctl() ;
+state = V11tab.state ;
+if ((i = ((struct lnkreg *)LNKADR)->drst) & ERR)
+       if (state&BUSY) V11tab.state |= S_ERR ;
+if (state&BUSY) {
+       wakeup(LNKADR) ;
+       return ;
+       }
+if (i&IM) {
+       if (state&PREread) {
+               wakeup(V11ioctl);
+               return;
+               }
+       if (((state&BUSY) == 0) && (state&OPEN))
+               V11tab.state |= IPEND ;
+       return;
+       }
+}
+/*             */
+V11ioctl(dev,cmd,addr,flag)
+dev_t dev;
+caddr_t addr;
+{
+if (cmd & VSPEC) {
+       switch (cmd & 077777) {
+               case L_WAKE : { /* debug wakeup */
+                       wakeup(LNKADR);
+                       break;
+                       }
+               case L_NOT : { /* send OIR to other end of link */
+                       spl5();
+                       ((struct lnkreg *)LNKADR)->drst |= (OIR|OM) ;
+                       ((struct lnkreg *)LNKADR)->drst &= (~OIR);
+                       spl0();
+                       break;
+                       }
+               case L_MON : { /* 'lnkmon' decr 'V11opn' */
+                       V11opn--;
+                       break;
+                       }
+               case PREread : { /* 'lnkmon' wait */
+                       spl5();
+                       if (V11tab.state&IPEND) {
+                               V11tab.state &= (~IPEND);
+                               }
+                       else {
+                               V11tab.state |= PREread;
+                               sleep(V11ioctl,PZERO+1);
+                               V11tab.state &= (~PREread);
+                               }
+                       spl0();
+                       break;
+                       }
+               }
+       }
+else {
+       *((short *)addr) = V11tab.state;
+       }
+}
diff --git a/usr/sys/40/README b/usr/sys/40/README
deleted file mode 100644 (file)
index 30043ec..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-The m40.s here is purported to support 7th edition Unix
-on the 11/40, 11/60, and 11/23.  It has, in fact,
-worked on the latter machine.
-The param.h is included because various sizes have to
-be cut down considerably; this is a guide.
-(Things will be tight!  You might consider removing some system calls
-you don't care about, like accounting.)
-Also, it is necessary to remove the
-       .data
-from line 3 of the l.s file, because the interrupt
-vectors and such should go in I space.
-
-Support is included for FP11-style floating point
-but I can't vouch for it.
diff --git a/usr/sys/40/m40.s b/usr/sys/40/m40.s
deleted file mode 100644 (file)
index 311509a..0000000
+++ /dev/null
@@ -1,1011 +0,0 @@
-/ machine language assist
-/ for 11/40
-
-
-/ non-UNIX instructions
-mfpi   = 6500^tst
-mtpi   = 6600^tst
-halt   = 0
-wait   = 1
-reset  = 5
-rtt    = 6
-
-.globl start, _end, _edata, _main, dump
-dump:
-start:
-       mov     $trap,34
-
-/ Set location 0 and 2 to catch traps and jumps to 0
-
-       mov     $42,0           / illegal instruction if jump
-       mov     $777,2          / trace trap at high priority if trap
-
-/ initialize systems segments
-
-       mov     $KISA0,r0
-       mov     $KISD0,r1
-       mov     $200,r4
-       clr     r2
-       mov     $6,r3
-1:
-       mov     r2,(r0)+
-       mov     $77406,(r1)+            / 4k rw
-       add     r4,r2
-       sob     r3,1b
-
-/ initialize user segment
-
-       mov     $_end+63.,r2
-       ash     $-6,r2
-       bic     $!1777,r2
-       mov     r2,(r0)+                / ksr6 = sysu
-       mov     $usize-1\<8|6,(r1)+
-
-/ initialize io segment
-/ set up counts on supervisor segments
-
-       mov     $IO,(r0)+
-       mov     $77406,(r1)+            / rw 4k
-
-/ get a sp and start segmentation
-
-       mov     $_u+[usize*64.],sp
-
-       inc     SSR0
-/ test for floating point
-       mov     $1f,nofault
-       setd                            / jumps to 1f if no fpu
-       inc     fpp
-1:
-       clr     nofault
-
-/ clear bss
-
-       mov     $_edata,r0
-1:
-       clr     (r0)+
-       cmp     r0,$_end
-       blo     1b
-
-/ clear user block
-
-       mov     $_u,r0
-1:
-       clr     (r0)+
-       cmp     r0,$_u+[usize*64.]
-       blo     1b
-
-/ set up previous mode and call main
-/ on return, enter user mode at 0R
-
-       mov     $30000,PS
-       jsr     pc,_main
-       mov     $170000,-(sp)
-       clr     -(sp)
-       rtt
-
-.globl trap, call
-.globl _trap
-
-/ all traps and interrupts are
-/ vectored thru this routine.
-
-trap:
-       mov     PS,saveps
-       tst     nofault
-       bne     1f
-       mov     SSR0,ssr
-       mov     SSR2,ssr+4
-       mov     $1,SSR0
-       jsr     r0,call1; jmp _trap
-       / no return
-1:
-       mov     $1,SSR0
-       mov     nofault,(sp)
-       rtt
-.text
-
-.globl _runrun
-call1:
-       mov     saveps,-(sp)
-       bic     $HIPRI,PS
-       br      1f
-
-call:
-       mov     PS,-(sp)
-1:
-       mov     r1,-(sp)
-       mfpi    sp
-       mov     4(sp),-(sp)
-       bic     $!37,(sp)
-       bit     $30000,PS
-       beq     1f
-       jsr     pc,(r0)+
-       tstb    _runrun
-       beq     2f
-       mov     $12.,(sp)               / trap 12 is give up cpu
-       jsr     pc,_trap
-2:
-       tst     (sp)+
-       mtpi    sp
-       br      2f
-1:
-       bis     $30000,PS
-       jsr     pc,(r0)+
-       cmp     (sp)+,(sp)+
-2:
-       mov     (sp)+,r1
-       tst     (sp)+
-       mov     (sp)+,r0
-       rtt
-.globl _savfp
-_savfp:
-       tst     fpp
-       beq     8f
-       mov     2(sp),r1
-       stfps   (r1)+
-       setd
-       movf    fr0,(r1)+
-       movf    fr1,(r1)+
-       movf    fr2,(r1)+
-       movf    fr3,(r1)+
-       movf    fr4,fr0
-       movf    fr0,(r1)+
-       movf    fr5,fr0
-       movf    fr0,(r1)+
-8:
-       rts     pc
-
-.globl _restfp
-_restfp:
-       tst     fpp
-       beq     8f
-       mov     2(sp),r1
-       mov     r1,r0
-       setd
-       add     $8.+2.,r1
-       movf    (r1)+,fr1
-       movf    (r1)+,fr2
-       movf    (r1)+,fr3
-       movf    (r1)+,fr0
-       movf    fr0,fr4
-       movf    (r1)+,fr0
-       movf    fr0,fr5
-       movf    2(r0),fr0
-       ldfps   (r0)
-8:
-       rts     pc
-
-.globl _addupc
-_addupc:
-       mov     r2,-(sp)
-       mov     6(sp),r2                / base of prof with base,leng,off,scale
-       mov     4(sp),r0                / pc
-       sub     4(r2),r0                / offset
-       clc
-       ror     r0
-       mov     6(r2),r1
-       clc
-       ror     r1
-       mul     r1,r0           / scale
-       ashc    $-14.,r0
-       inc     r1
-       bic     $1,r1
-       cmp     r1,2(r2)                / length
-       bhis    1f
-       add     (r2),r1         / base
-       mov     nofault,-(sp)
-       mov     $2f,nofault
-       mfpi    (r1)
-       add     12.(sp),(sp)
-       mtpi    (r1)
-       br      3f
-2:
-       clr     6(r2)
-3:
-       mov     (sp)+,nofault
-1:
-       mov     (sp)+,r2
-       rts     pc
-
-.globl _display
-_display:
-       rts     pc
-
-/ Character list get/put
-
-/.globl        _getc, _putc
-/.globl        _cfreelist
-/
-/_getc:
-/      mov     2(sp),r1
-/      mov     PS,-(sp)
-/      mov     r2,-(sp)
-/      bis     $HIPRI,PS
-/      bic     $40,PS
-/      mov     2(r1),r2                / first ptr
-/      beq     9f              / empty
-/      movb    (r2)+,r0                / character
-/      bic     $!377,r0
-/      mov     r2,2(r1)
-/      dec     (r1)+           / count
-/      bne     1f
-/      clr     (r1)+
-/      clr     (r1)+           / last block
-/      br      2f
-/1:
-/      bit     $7,r2
-/      bne     3f
-/      mov     -10(r2),(r1)            / next block
-/      add     $2,(r1)
-/2:
-/      dec     r2
-/      bic     $7,r2
-/      mov     _cfreelist,(r2)
-/      mov     r2,_cfreelist
-/3:
-/      mov     (sp)+,r2
-/      mov     (sp)+,PS
-/      rts     pc
-/9:
-/      clr     4(r1)
-/      mov     $-1,r0
-/      mov     (sp)+,r2
-/      mov     (sp)+,PS
-/      rts     pc
-/
-/_putc:
-/      mov     2(sp),r0
-/      mov     4(sp),r1
-/      mov     PS,-(sp)
-/      mov     r2,-(sp)
-/      mov     r3,-(sp)
-/      bis     $HIPRI,PS
-/      bic     $40,PS
-/      mov     4(r1),r2                / last ptr
-/      bne     1f
-/      mov     _cfreelist,r2
-/      beq     9f
-/      mov     (r2),_cfreelist
-/      clr     (r2)+
-/      mov     r2,2(r1)                / first ptr
-/      br      2f
-/1:
-/      bit     $7,r2
-/      bne     2f
-/      mov     _cfreelist,r3
-/      beq     9f
-/      mov     (r3),_cfreelist
-/      mov     r3,-10(r2)
-/      mov     r3,r2
-/      clr     (r2)+
-/2:
-/      movb    r0,(r2)+
-/      mov     r2,4(r1)
-/      inc     (r1)            / count
-/      clr     r0
-/      mov     (sp)+,r3
-/      mov     (sp)+,r2
-/      mov     (sp)+,PS
-/      rts     pc
-/9:
-/      mov     pc,r0
-/      mov     (sp)+,r3
-/      mov     (sp)+,r2
-/      mov     (sp)+,PS
-/      rts     pc
-
-.globl _backup
-.globl _regloc
-_backup:
-       mov     2(sp),ssr+2
-       mov     r2,-(sp)
-       jsr     pc,backup
-       mov     r2,ssr+2
-       mov     (sp)+,r2
-       movb    jflg,r0
-       bne     2f
-       mov     2(sp),r0
-       movb    ssr+2,r1
-       jsr     pc,1f
-       movb    ssr+3,r1
-       jsr     pc,1f
-       movb    _regloc+7,r1
-       asl     r1
-       add     r0,r1
-       mov     ssr+4,(r1)
-       clr     r0
-2:
-       rts     pc
-1:
-       mov     r1,-(sp)
-       asr     (sp)
-       asr     (sp)
-       asr     (sp)
-       bic     $!7,r1
-       movb    _regloc(r1),r1
-       asl     r1
-       add     r0,r1
-       sub     (sp)+,(r1)
-       rts     pc
-
-/ hard part
-/ simulate the ssr2 register missing on 11/40
-
-backup:
-       clr     r2              / backup register ssr1
-       mov     $1,bflg         / clrs jflg
-       mov     ssr+4,r0
-       jsr     pc,fetch
-       mov     r0,r1
-       ash     $-11.,r0
-       bic     $!36,r0
-       jmp     *0f(r0)
-0:             t00; t01; t02; t03; t04; t05; t06; t07
-               t10; t11; t12; t13; t14; t15; t16; t17
-
-t00:
-       clrb    bflg
-
-t10:
-       mov     r1,r0
-       swab    r0
-       bic     $!16,r0
-       jmp     *0f(r0)
-0:             u0; u1; u2; u3; u4; u5; u6; u7
-
-u6:    / single op, m[tf]pi, sxt, illegal
-       bit     $400,r1
-       beq     u5              / all but m[tf], sxt
-       bit     $200,r1
-       beq     1f              / mfpi
-       bit     $100,r1
-       bne     u5              / sxt
-
-/ simulate mtpi with double (sp)+,dd
-       bic     $4000,r1        / turn instr into (sp)+
-       br      t01
-
-/ simulate mfpi with double ss,-(sp)
-1:
-       ash     $6,r1
-       bis     $46,r1          / -(sp)
-       br      t01
-
-u4:    / jsr
-       mov     r1,r0
-       jsr     pc,setreg       / assume no fault
-       bis     $173000,r2      / -2 from sp
-       rts     pc
-
-t07:   / EIS
-       clrb    bflg
-
-u0:    / jmp, swab
-u5:    / single op
-f5:    / movei, movfi
-ff1:   / ldfps
-ff2:   / stfps
-ff3:   / stst
-       mov     r1,r0
-       br      setreg
-
-t01:   / mov
-t02:   / cmp
-t03:   / bit
-t04:   / bic
-t05:   / bis
-t06:   / add
-t16:   / sub
-       clrb    bflg
-
-t11:   / movb
-t12:   / cmpb
-t13:   / bitb
-t14:   / bicb
-t15:   / bisb
-       mov     r1,r0
-       ash     $-6,r0
-       jsr     pc,setreg
-       swab    r2
-       mov     r1,r0
-       jsr     pc,setreg
-
-/ if delta(dest) is zero,
-/ no need to fetch source
-
-       bit     $370,r2
-       beq     1f
-
-/ if mode(source) is R,
-/ no fault is possible
-
-       bit     $7000,r1
-       beq     1f
-
-/ if reg(source) is reg(dest),
-/ too bad.
-
-       mov     r2,-(sp)
-       bic     $174370,(sp)
-       cmpb    1(sp),(sp)+
-       beq     u7
-
-/ start source cycle
-/ pick up value of reg
-
-       mov     r1,r0
-       ash     $-6,r0
-       bic     $!7,r0
-       movb    _regloc(r0),r0
-       asl     r0
-       add     ssr+2,r0
-       mov     (r0),r0
-
-/ if reg has been incremented,
-/ must decrement it before fetch
-
-       bit     $174000,r2
-       ble     2f
-       dec     r0
-       bit     $10000,r2
-       beq     2f
-       dec     r0
-2:
-
-/ if mode is 6,7 fetch and add X(R) to R
-
-       bit     $4000,r1
-       beq     2f
-       bit     $2000,r1
-       beq     2f
-       mov     r0,-(sp)
-       mov     ssr+4,r0
-       add     $2,r0
-       jsr     pc,fetch
-       add     (sp)+,r0
-2:
-
-/ fetch operand
-/ if mode is 3,5,7 fetch *
-
-       jsr     pc,fetch
-       bit     $1000,r1
-       beq     1f
-       bit     $6000,r1
-       bne     fetch
-1:
-       rts     pc
-
-t17:   / floating point instructions
-       clrb    bflg
-       mov     r1,r0
-       swab    r0
-       bic     $!16,r0
-       jmp     *0f(r0)
-0:             f0; f1; f2; f3; f4; f5; f6; f7
-
-f0:
-       mov     r1,r0
-       ash     $-5,r0
-       bic     $!16,r0
-       jmp     *0f(r0)
-0:             ff0; ff1; ff2; ff3; ff4; ff5; ff6; ff7
-
-f1:    / mulf, modf
-f2:    / addf, movf
-f3:    / subf, cmpf
-f4:    / movf, divf
-ff4:   / clrf
-ff5:   / tstf
-ff6:   / absf
-ff7:   / negf
-       inc     fflg
-       mov     r1,r0
-       br      setreg
-
-f6:
-       bit     $400,r1
-       beq     f1      / movfo
-       br      f5      / movie
-
-f7:
-       bit     $400,r1
-       beq     f5      / movif
-       br      f1      / movof
-
-ff0:   / cfcc, setf, setd, seti, setl
-u1:    / br
-u2:    / br
-u3:    / br
-u7:    / illegal
-       incb    jflg
-       rts     pc
-
-setreg:
-       mov     r0,-(sp)
-       bic     $!7,r0
-       bis     r0,r2
-       mov     (sp)+,r0
-       ash     $-3,r0
-       bic     $!7,r0
-       movb    0f(r0),r0
-       tstb    bflg
-       beq     1f
-       bit     $2,r2
-       beq     2f
-       bit     $4,r2
-       beq     2f
-1:
-       cmp     r0,$20
-       beq     2f
-       cmp     r0,$-20
-       beq     2f
-       asl     r0
-2:
-       tstb    fflg
-       beq     3f
-       asl     r0
-       stfps   r1
-       bit     $200,r1
-       beq     3f
-       asl     r0
-3:
-       bisb    r0,r2
-       rts     pc
-
-0:     .byte   0,0,10,20,-10,-20,0,0
-
-fetch:
-       bic     $1,r0
-       mov     nofault,-(sp)
-       mov     $1f,nofault
-       mfpi    (r0)
-       mov     (sp)+,r0
-       mov     (sp)+,nofault
-       rts     pc
-
-1:
-       mov     (sp)+,nofault
-       clrb    r2                      / clear out dest on fault
-       mov     $-1,r0
-       rts     pc
-
-.bss
-bflg:  .=.+1
-jflg:  .=.+1
-fflg:  .=.+1
-.text
-
-.text
-
-.globl _fubyte, _subyte
-.globl _fuibyte, _suibyte
-.globl _fuword, _suword
-.globl _fuiword, _suiword
-_fuibyte:
-_fubyte:
-       mov     2(sp),r1
-       bic     $1,r1
-       jsr     pc,gword
-       cmp     r1,2(sp)
-       beq     1f
-       swab    r0
-1:
-       bic     $!377,r0
-       rts     pc
-
-_suibyte:
-_subyte:
-       mov     2(sp),r1
-       bic     $1,r1
-       jsr     pc,gword
-       mov     r0,-(sp)
-       cmp     r1,4(sp)
-       beq     1f
-       movb    6(sp),1(sp)
-       br      2f
-1:
-       movb    6(sp),(sp)
-2:
-       mov     (sp)+,r0
-       jsr     pc,pword
-       clr     r0
-       rts     pc
-_fuiword:
-_fuword:
-       mov     2(sp),r1
-fuword:
-       jsr     pc,gword
-       rts     pc
-
-gword:
-       mov     PS,-(sp)
-       bis     $HIPRI,PS
-       mov     nofault,-(sp)
-       mov     $err,nofault
-       mfpi    (r1)
-       mov     (sp)+,r0
-       br      1f
-
-_suiword:
-_suword:
-       mov     2(sp),r1
-       mov     4(sp),r0
-suword:
-       jsr     pc,pword
-       rts     pc
-
-pword:
-       mov     PS,-(sp)
-       bis     $HIPRI,PS
-       mov     nofault,-(sp)
-       mov     $err,nofault
-       mov     r0,-(sp)
-       mtpi    (r1)
-1:
-       mov     (sp)+,nofault
-       mov     (sp)+,PS
-       rts     pc
-
-err:
-       mov     (sp)+,nofault
-       mov     (sp)+,PS
-       tst     (sp)+
-       mov     $-1,r0
-       rts     pc
-       rts     pc
-.globl _copyin, _copyout
-.globl _copyiin, _copyiout
-_copyiin:
-_copyin:
-       jsr     pc,copsu
-1:
-       mfpi    (r0)+
-       mov     (sp)+,(r1)+
-       sob     r2,1b
-       br      2f
-
-_copyiout:
-_copyout:
-       jsr     pc,copsu
-1:
-       mov     (r0)+,-(sp)
-       mtpi    (r1)+
-       sob     r2,1b
-2:
-       mov     (sp)+,nofault
-       mov     (sp)+,r2
-       clr     r0
-       rts     pc
-
-copsu:
-       mov     (sp)+,r0
-       mov     r2,-(sp)
-       mov     nofault,-(sp)
-       mov     r0,-(sp)
-       mov     10(sp),r0
-       mov     12(sp),r1
-       mov     14(sp),r2
-       asr     r2
-       mov     $1f,nofault
-       rts     pc
-
-1:
-       mov     (sp)+,nofault
-       mov     (sp)+,r2
-       mov     $-1,r0
-       rts     pc
-
-.globl _idle, _waitloc
-_idle:
-       mov     PS,-(sp)
-       bic     $HIPRI,PS
-       wait
-waitloc:
-       mov     (sp)+,PS
-       rts     pc
-       .data
-_waitloc:
-       waitloc
-       .text
-
-.globl _save
-_save:
-       mov     (sp)+,r1
-       mov     (sp),r0
-       mov     r2,(r0)+
-       mov     r3,(r0)+
-       mov     r4,(r0)+
-       mov     r5,(r0)+
-       mov     sp,(r0)+
-       mov     r1,(r0)+
-       clr     r0
-       jmp     (r1)
-
-.globl _resume
-_resume:
-       mov     2(sp),r0                / new process
-       mov     4(sp),r1                / new stack
-       bis     $HIPRI,PS
-       mov     r0,KISA6                / In new process
-       mov     (r1)+,r2
-       mov     (r1)+,r3
-       mov     (r1)+,r4
-       mov     (r1)+,r5
-       mov     (r1)+,sp
-       mov     $1,r0
-       bic     $HIPRI,PS
-       jmp     *(r1)+
-
-.globl _spl0, _spl1, _spl4, _spl5, _spl6, _spl7, _splx
-_spl0:
-       mov     PS,r0
-       bic     $HIPRI,PS
-       rts     pc
-
-_spl1:
-       mov     PS,r0
-       bis     $HIPRI,PS
-       bic     $300,PS
-       rts     pc
-
-_spl4:
-       mov     PS,r0
-       bis     $HIPRI,PS
-       bic     $140,PS
-       rts     pc
-
-_spl5:
-       mov     PS,r0
-       bis     $HIPRI,PS
-       bic     $100,PS
-       rts     pc
-
-_spl6:
-       mov     PS,r0
-       bis     $HIPRI,PS
-       bic     $40,PS
-       rts     pc
-
-_spl7:
-       mov     PS,r0
-       bis     $HIPRI,PS
-       rts     pc
-
-_splx:
-       mov     2(sp),PS
-       rts     pc
-
-.globl _copyseg
-_copyseg:
-       mov     PS,-(sp)
-       mov     UISA0,-(sp)
-       mov     UISA1,-(sp)
-       mov     $30340,PS
-       mov     10(sp),UISA0
-       mov     12(sp),UISA1
-       mov     UISD0,-(sp)
-       mov     UISD1,-(sp)
-       mov     $6,UISD0
-       mov     $6,UISD1
-       mov     r2,-(sp)
-       clr     r0
-       mov     $8192.,r1
-       mov     $32.,r2
-1:
-       mfpi    (r0)+
-       mtpi    (r1)+
-       sob     r2,1b
-       mov     (sp)+,r2
-       mov     (sp)+,UISD1
-       mov     (sp)+,UISD0
-       mov     (sp)+,UISA1
-       mov     (sp)+,UISA0
-       mov     (sp)+,PS
-       rts     pc
-
-.globl _clearseg
-_clearseg:
-       mov     PS,-(sp)
-       mov     UISA0,-(sp)
-       mov     $30340,PS
-       mov     6(sp),UISA0
-       mov     UISD0,-(sp)
-       mov     $6,UISD0
-       clr     r0
-       mov     $32.,r1
-1:
-       clr     -(sp)
-       mtpi    (r0)+
-       sob     r1,1b
-       mov     (sp)+,UISD0
-       mov     (sp)+,UISA0
-       mov     (sp)+,PS
-       rts     pc
-
-.globl _piget, _piput
-_piget:
-       mov     PS,-(sp)
-       jsr     pc,2f
-       mfpi    (r0)
-       mov     (sp)+,r0
-1:
-       mov     (sp)+,PS
-       rts     pc
-
-_piput:
-       mov     PS,-(sp)
-       jsr     pc,2f
-       mov     10(sp),r1
-       mov     r1,-(sp)
-       mtpi    (r0)
-       br      1b
-2:
-       mov     6(sp),r0
-       mov     10(sp),r1
-       ashc    $-6,r0
-       mov     HIPRI,PS
-       mov     r1,KISA7
-       mov     10(sp),r0
-       bic     $!77,r0
-       bis     $160000,r0
-       rts     pc
-
-/ Long quotient
-
-       .globl  ldiv
-ldiv:
-       jsr     r5,csv
-       mov     10.(r5),r3
-       sxt     r4
-       bpl     1f
-       neg     r3
-1:
-       cmp     r4,8.(r5)
-       bne     hardldiv
-       mov     6.(r5),r2
-       mov     4.(r5),r1
-       bge     1f
-       neg     r1
-       neg     r2
-       sbc     r1
-       com     r4
-1:
-       mov     r4,-(sp)
-       clr     r0
-       div     r3,r0
-       mov     r0,r4           /high quotient
-       mov     r1,r0
-       mov     r2,r1
-       div     r3,r0
-       bvc     1f
-       sub     r3,r0           / this is the clever part
-       div     r3,r0
-       tst     r1
-       sxt     r1
-       add     r1,r0           / cannot overflow!
-1:
-       mov     r0,r1
-       mov     r4,r0
-       tst     (sp)+
-       bpl     9f
-       neg     r0
-       neg     r1
-       sbc     r0
-9:
-       jmp     cret
-
-hardldiv:
-       4
-
-/ Long remainder
-
-       .globl  lrem
-lrem:
-       jsr     r5,csv
-       mov     10.(r5),r3
-       sxt     r4
-       bpl     1f
-       neg     r3
-1:
-       cmp     r4,8.(r5)
-       bne     hardlrem
-       mov     6.(r5),r2
-       mov     4.(r5),r1
-       mov     r1,r4
-       bge     1f
-       neg     r1
-       neg     r2
-       sbc     r1
-1:
-       clr     r0
-       div     r3,r0
-       mov     r1,r0
-       mov     r2,r1
-       div     r3,r0
-       bvc     1f
-       sub     r3,r0
-       div     r3,r0
-       tst     r1
-       beq     9f
-       add     r3,r1
-1:
-       tst     r4
-       bpl     9f
-       neg     r1
-9:
-       sxt     r0
-       jmp     cret
-
-/ The divisor is known to be >= 2^15.  Only 16 cycles are
-/ needed to get a remainder.
-hardlrem:
-       4
-
-.globl csv
-csv:
-       mov     r5,r0
-       mov     sp,r5
-       mov     r4,-(sp)
-       mov     r3,-(sp)
-       mov     r2,-(sp)
-       jsr     pc,(r0)
-
-.globl cret
-cret:
-       mov     r5,r2
-       mov     -(r2),r4
-       mov     -(r2),r3
-       mov     -(r2),r2
-       mov     r5,sp
-       mov     (sp)+,r5
-       rts     pc
-
-.globl _u
-_u     = 140000
-usize  = 16.
-
-HIPRI  = 340
-
-PS     = 177776
-SSR0   = 177572
-SSR2   = 177576
-KISA0  = 172340
-KISA6  = 172354
-KISA7  = 172356
-KISD0  = 172300
-MTC    = 172522
-TUC    = 172440
-UISA0  = 177640
-UISA1  = 177642
-UISD0  = 177600
-UISD1  = 177602
-IO     = 7600
-
-.data
-.globl _ka6
-.globl _cputype
-
-_ka6:  KISA6
-_cputype:40.
-stk:   0
-
-.bss
-nofault:.=.+2
-ssr:   .=.+6
-saveps: .=.+2
-power: .=.+2
-fpp:   .=.+2
-
-.globl _stst
-.text
-.globl _stst
-stst   = 170300^tst
-_stst:
-       tst     fpp
-       beq     9f
-       stst    r0
-       mov     r0,*2(sp)
-9:
-       rts     pc
diff --git a/usr/sys/40/param.h b/usr/sys/40/param.h
deleted file mode 100644 (file)
index 33ed643..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * tunable variables
- */
-
-#define        NBUF    15              /* size of buffer cache */
-#define        NINODE  20              /* number of in core inodes */
-#define        NFILE   20              /* number of in core file structures */
-#define        NMOUNT  2               /* number of mountable file systems */
-#define        MAXMEM  (64*32)         /* max core per process - first # is Kw */
-#define        MAXUPRC 15              /* max processes per user */
-#define        SSIZE   20              /* initial stack size (*64 bytes) */
-#define        SINCR   20              /* increment of stack (*64 bytes) */
-#define        NOFILE  20              /* max open files per process */
-#define        CANBSIZ 256             /* max size of typewriter line */
-#define        CMAPSIZ 20              /* size of core allocation area */
-#define        SMAPSIZ 20              /* size of swap allocation area */
-#define        NCALL   10              /* max simultaneous time callouts */
-#define        NPROC   20              /* max number of processes */
-#define        NTEXT   10              /* max number of pure texts */
-#define        NCLIST  40              /* max total clist size */
-#define        HZ      60              /* Ticks/second of the clock */
-#define        TIMEZONE (5*60)         /* Minutes westward from Greenwich */
-#define        DSTFLAG 1               /* Daylight Saving Time applies in this locality */
-#define        MSGBUFS 128             /* Characters saved from error messages */
-#define        NCARGS  5120            /* # characters in exec arglist */
-
-/*
- * priorities
- * probably should not be
- * altered too much
- */
-
-#define        PSWP    0
-#define        PINOD   10
-#define        PRIBIO  20
-#define        PZERO   25
-#define        NZERO   20
-#define        PPIPE   26
-#define        PWAIT   30
-#define        PSLEP   40
-#define        PUSER   50
-
-/*
- * signals
- * dont change
- */
-
-#define        NSIG    17
-/*
- * No more than 16 signals (1-16) because they are
- * stored in bits in a word.
- */
-#define        SIGHUP  1       /* hangup */
-#define        SIGINT  2       /* interrupt (rubout) */
-#define        SIGQUIT 3       /* quit (FS) */
-#define        SIGINS  4       /* illegal instruction */
-#define        SIGTRC  5       /* trace or breakpoint */
-#define        SIGIOT  6       /* iot */
-#define        SIGEMT  7       /* emt */
-#define        SIGFPT  8       /* floating exception */
-#define        SIGKIL  9       /* kill, uncatchable termination */
-#define        SIGBUS  10      /* bus error */
-#define        SIGSEG  11      /* segmentation violation */
-#define        SIGSYS  12      /* bad system call */
-#define        SIGPIPE 13      /* end of pipe */
-#define        SIGCLK  14      /* alarm clock */
-#define        SIGTRM  15      /* Catchable termination */
-
-/*
- * fundamental constants of the implementation--
- * cannot be changed easily
- */
-
-#define        NBPW    sizeof(int)     /* number of bytes in an integer */
-#define        BSIZE   512             /* size of secondary block (bytes) */
-/* BSLOP can be 0 unless you have a TIU/Spider */
-#define        BSLOP   2               /* In case some device needs bigger buffers */
-#define        NINDIR  (BSIZE/sizeof(daddr_t))
-#define        BMASK   0777            /* BSIZE-1 */
-#define        BSHIFT  9               /* LOG2(BSIZE) */
-#define        NMASK   0177            /* NINDIR-1 */
-#define        NSHIFT  7               /* LOG2(NINDIR) */
-#define        USIZE   16              /* size of user block (*64) */
-#define        UBASE   0140000         /* abs. addr of user block */
-#define        NULL    0
-#define        CMASK   0               /* default mask for file creation */
-#define        NODEV   (dev_t)(-1)
-#define        ROOTINO ((ino_t)2)      /* i number of all roots */
-#define        SUPERB  ((daddr_t)1)    /* block number of the super block */
-#define        DIRSIZ  14              /* max characters per directory */
-#define        NICINOD 100             /* number of superblock inodes */
-#define        NICFREE 50              /* number of superblock free blocks */
-#define        INFSIZE 138             /* size of per-proc info for users */
-#define        CBSIZE  6               /* number of chars in a clist block */
-#define        CROUND  07              /* clist rounding: sizeof(int *) + CBSIZE - 1*/
-
-/*
- * Some macros for units conversion
- */
-/* Core clicks (64 bytes) to segments and vice versa */
-#define        ctos(x) ((x+127)/128)
-#define stoc(x) ((x)*128)
-
-/* Core clicks (64 bytes) to disk blocks */
-#define        ctod(x) ((x+7)>>3)
-
-/* inumber to disk address */
-#define        itod(x) (daddr_t)((((unsigned)x+15)>>3))
-
-/* inumber to disk offset */
-#define        itoo(x) (int)((x+15)&07)
-
-/* clicks to bytes */
-#define        ctob(x) (x<<6)
-
-/* bytes to clicks */
-#define        btoc(x) ((((unsigned)x+63)>>6))
-
-/* major part of a device */
-#define        major(x)        (int)(((unsigned)x>>8))
-
-/* minor part of a device */
-#define        minor(x)        (int)(x&0377)
-
-/* make a device number */
-#define        makedev(x,y)    (dev_t)((x)<<8 | (y))
-
-typedef        struct { int r[1]; } *  physadr;
-typedef        long            daddr_t;
-typedef char *         caddr_t;
-typedef        unsigned int    ino_t;
-typedef        long            time_t;
-typedef        int             label_t[6];     /* regs 2-7 */
-typedef        int             dev_t;
-typedef        long            off_t;
-
-/*
- * Machine-dependent bits and macros
- */
-#define        UMODE   0170000         /* usermode bits */
-#define        USERMODE(ps)    ((ps & UMODE)==UMODE)
-
-#define        INTPRI  0340            /* Priority bits */
-#define        BASEPRI(ps)     ((ps & INTPRI) != 0)
diff --git a/usr/sys/conf/c.c b/usr/sys/conf/c.c
deleted file mode 100644 (file)
index 8b82f1f..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/buf.h"
-#include "../h/tty.h"
-#include "../h/conf.h"
-#include "../h/proc.h"
-#include "../h/text.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/file.h"
-#include "../h/inode.h"
-#include "../h/acct.h"
-
-int    nulldev();
-int    nodev();
-int    rkstrategy();
-struct buf     rktab;
-int    htopen(), htclose(), htstrategy();
-struct buf     httab;
-struct bdevsw  bdevsw[] =
-{
-       nulldev, nulldev, rkstrategy, &rktab,   /* rk = 0 */
-       nodev, nodev, nodev, 0, /* rp = 1 */
-       nodev, nodev, nodev, 0, /* rf = 2 */
-       nodev, nodev, nodev, 0, /* tm = 3 */
-       nodev, nodev, nodev, 0, /* tc = 4 */
-       nodev, nodev, nodev, 0, /* hs = 5 */
-       nodev, nodev, nodev, 0, /* hp = 6 */
-       htopen, htclose, htstrategy, &httab,    /* ht = 7 */
-       nodev, nodev, nodev, 0, /* rl = 8 */
-       0
-};
-
-int    klopen(), klclose(), klread(), klwrite(), klioctl();
-int    mmread(), mmwrite();
-int    rkread(), rkwrite();
-int    htread(), htwrite();
-int    syopen(), syread(), sywrite(), sysioctl();
-
-struct cdevsw  cdevsw[] =
-{
-       klopen, klclose, klread, klwrite, klioctl, nulldev, 0,  /* console = 0 */
-       nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* pc = 1 */
-       nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* lp = 2 */
-       nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* dc = 3 */
-       nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* dh = 4 */
-       nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* dp = 5 */
-       nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* dj = 6 */
-       nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* dn = 7 */
-       nulldev, nulldev, mmread, mmwrite, nodev, nulldev, 0,   /* mem = 8 */
-       nulldev, nulldev, rkread, rkwrite, nodev, nulldev, 0,   /* rk = 9 */
-       nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* rf = 10 */
-       nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* rp = 11 */
-       nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* tm = 12 */
-       nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* hs = 13 */
-       nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* hp = 14 */
-       htopen, htclose, htread, htwrite, nodev, nulldev, 0,    /* ht = 15 */
-       nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* du = 16 */
-       syopen, nulldev, syread, sywrite, sysioctl, nulldev, 0, /* tty = 17 */
-       nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* rl = 18 */
-       0
-};
-
-int    ttyopen(), ttyclose(), ttread(), ttwrite(), ttyinput(), ttstart();
-struct linesw  linesw[] =
-{
-       ttyopen, nulldev, ttread, ttwrite, nodev, ttyinput, ttstart, /* 0 */
-       0
-};
-int    rootdev = makedev(0, 0);
-int    swapdev = makedev(0, 0);
-int    pipedev = makedev(0, 0);
-int    nldisp = 1;
-daddr_t        swplo   = 4000;
-int    nswap   = 872;
-       
-struct buf     buf[NBUF];
-struct file    file[NFILE];
-struct inode   inode[NINODE];
-int    mpxchan();
-int    (*ldmpx)() = mpxchan;
-struct proc    proc[NPROC];
-struct text    text[NTEXT];
-struct buf     bfreelist;
-struct acct    acctbuf;
-struct inode   *acctp;
diff --git a/usr/sys/conf/hphtconf b/usr/sys/conf/hphtconf
deleted file mode 100644 (file)
index da718e4..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-hp
-root hp 0
-swap hp 1
-swplo 0
-nswap 8778
-ht
diff --git a/usr/sys/conf/hptmconf b/usr/sys/conf/hptmconf
deleted file mode 100644 (file)
index 2ba13d7..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-hp
-root hp 0
-swap hp 1
-swplo 0
-nswap 8778
-tm
diff --git a/usr/sys/conf/l.s b/usr/sys/conf/l.s
deleted file mode 100644 (file)
index c555d95..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/ low core
-
-.data
-ZERO:
-
-br4 = 200
-br5 = 240
-br6 = 300
-br7 = 340
-
-. = ZERO+0
-       br      1f
-       4
-
-/ trap vectors
-       trap; br7+0.            / bus error
-       trap; br7+1.            / illegal instruction
-       trap; br7+2.            / bpt-trace trap
-       trap; br7+3.            / iot trap
-       trap; br7+4.            / power fail
-       trap; br7+5.            / emulator trap
-       start;br7+6.            / system  (overlaid by 'trap')
-
-. = ZERO+40
-.globl start, dump
-1:     jmp     start
-       jmp     dump
-
-
-. = ZERO+60
-       klin; br4
-       klou; br4
-
-. = ZERO+100
-       kwlp; br6
-       kwlp; br6
-
-. = ZERO+114
-       trap; br7+7.            / 11/70 parity
-
-. = ZERO+220
-       rkio; br5
-
-. = ZERO+224
-       htio; br5
-
-. = ZERO+240
-       trap; br7+7.            / programmed interrupt
-       trap; br7+8.            / floating point
-       trap; br7+9.            / segmentation violation
-
-//////////////////////////////////////////////////////
-/              interface code to C
-//////////////////////////////////////////////////////
-
-.text
-.globl call, trap
-
-.globl _klrint
-klin:  jsr     r0,call; jmp _klrint
-.globl _klxint
-klou:  jsr     r0,call; jmp _klxint
-
-.globl _clock
-kwlp:  jsr     r0,call; jmp _clock
-
-
-.globl _rkintr
-rkio:  jsr     r0,call; jmp _rkintr
-
-.globl _htintr
-htio:  jsr     r0,call; jmp _htintr
diff --git a/usr/sys/conf/makefile b/usr/sys/conf/makefile
deleted file mode 100644 (file)
index 9ea19a0..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-unix:  l.o mch.o c.o ../sys/LIB1 ../dev/LIB2
-       ld -o unix -X -i l.o mch.o c.o ../sys/LIB1 ../dev/LIB2
-
-all:
-       cd ../sys; cc -c -O *.c; mklib; rm *.o
-       cd ../dev; cc -c -O *.c; mklib; rm *.o
-
-mch.o: mch0.s mch.s
-       as -o mch.o mch0.s mch.s
-
-allsystems:
-       mkconf <hphtconf
-       make unix
-       mv unix hphtunix
-       mkconf <hptmconf
-       make unix
-       mv unix hptmunix
-       mkconf <rptmconf
-       make unix
-       mv unix rptmunix
-       mkconf <rphtconf
-       make unix
-       mv unix rphtunix
-       mkconf <rktmconf
-       make unix
-       mv unix rktmunix
-       mkconf <rkhtconf
-       make unix
-       mv unix rkhtunix
diff --git a/usr/sys/conf/mch.s b/usr/sys/conf/mch.s
deleted file mode 100644 (file)
index 28718b4..0000000
+++ /dev/null
@@ -1,1058 +0,0 @@
-/ machine language assist
-/ for 11/45 or 11/70 CPUs
-
-
-/ non-UNIX instructions
-mfpi   = 6500^tst
-stst   = 170300^tst
-mtpi   = 6600^tst
-mfpd   = 106500^tst
-mtpd   = 106600^tst
-spl    = 230
-ldfps  = 170100^tst
-stfps  = 170200^tst
-wait   = 1
-rtt    = 6
-reset  = 5
-
-.PROFIL        = 0
-HIPRI  = 340
-HIGH   = 7
-       .if     .PROFIL
-HIGH   = 6
-HIPRI  = 300
-       .endif
-
-/ Mag tape dump
-/ save registers in low core and
-/ write all core onto mag tape.
-/ entry is thru 44 abs
-
-.data
-.globl dump
-dump:
-
-/ save regs r0,r1,r2,r3,r4,r5,r6,KIA6
-/ starting at abs location 4
-
-       mov     r0,4
-       mov     $6,r0
-       mov     r1,(r0)+
-       mov     r2,(r0)+
-       mov     r3,(r0)+
-       mov     r4,(r0)+
-       mov     r5,(r0)+
-       mov     sp,(r0)+
-       mov     KDSA6,(r0)+
-
-/ dump all of core (ie to first mt error)
-/ onto mag tape. (9 track or 7 track 'binary')
-
-.if HTDUMP
-       mov     $HTCS1,r0
-       mov     $40,*$HTCS2
-       mov     $2300,*$HTTC
-       clr     *$HTBA
-       mov     $1,(r0)
-1:
-       mov     $-512.,*$HTFC
-       mov     $-256.,*$HTWC
-       movb    $61,(r0)
-2:
-       tstb    (r0)
-       bge     2b
-       bit     $1,(r0)
-       bne     2b
-       bit     $40000,(r0)
-       beq     1b
-       mov     $27,(r0)
-.endif
-HT     = 0172440
-HTCS1  = HT+0
-HTWC   = HT+2
-HTBA   = HT+4
-HTFC   = HT+6
-HTCS2  = HT+10
-HTTC   = HT+32
-
-MTC = 172522
-.if TUDUMP
-       mov     $MTC,r0
-       mov     $60004,(r0)+
-       clr     2(r0)
-1:
-       mov     $-512.,(r0)
-       inc     -(r0)
-2:
-       tstb    (r0)
-       bge     2b
-       tst     (r0)+
-       bge     1b
-       reset
-
-/ end of file and loop
-
-       mov     $60007,-(r0)
-.endif
-       br      .
-
-.text
-.globl start, _end, _edata, _etext, _main
-
-/ 11/45 and 11/70 startup.
-/ entry is thru 0 abs.
-/ since core is shuffled,
-/ this code can be executed but once
-
-start:
-       bit     $1,SSR0
-       beq     1f
-       mov     $trap,34
-       mov     $trap,0
-       mov     $340+15.,2
-       bit     $20,SSR3
-       beq     9f
-       mov     $70.,_cputype
-       mov     $3,*$MSCR
-9:
-       clr     PS
-       br      9f
-1:
-       inc     $-1
-       bne     .
-       reset
-/ Set loc. 0 to trap to system, in case of
-/ hardware glitch
-       mov     $trap,0         / in case of bad trap through 0
-       mov     $340+15.,2      / high pri, trap type 15
-       clr     PS
-
-/ set KI0 to physical 0
-
-       mov     $77406,r3
-       mov     $KISA0,r0
-       mov     $KISD0,r1
-       clr     (r0)+
-       mov     r3,(r1)+
-
-/ set KI1-6 to eventual text resting place
-
-       mov     $_end+63.,r2
-       ash     $-6,r2
-       bic     $!1777,r2
-1:
-       mov     r2,(r0)+
-       mov     r3,(r1)+
-       add     $200,r2
-       cmp     r0,$KISA7
-       blos    1b
-
-/ set KI7 to IO seg for escape
-
-       mov     $IO,-(r0)
-
-/ set KD0-7 to physical
-
-       mov     $KDSA0,r0
-       mov     $KDSD0,r1
-       clr     r2
-1:
-       mov     r2,(r0)+
-       mov     r3,(r1)+
-       add     $200,r2
-       cmp     r0,$KDSA7
-       blos    1b
-
-/ initialization
-/ get a temp (1-word) stack
-/ turn on segmentation
-/ copy text to I space
-/ clear bss in D space
-
-       mov     $stk+2,sp
-       mov     $65,SSR3                / 22-bit, map, K+U sep
-       bit     $20,SSR3
-       beq     1f
-       mov     $70.,_cputype
-       mov     $3,*$MSCR               / Disable UNIBUS traps, non-fatal traps
-1:
-       inc     SSR0
-       mov     $_etext+100,r2
-       mov     $_edata+100,r1
-       add     $_etext-8192.,r1
-1:
-       mov     -(r1),-(sp)
-       mtpi    -(r2)
-       cmp     r1,$_edata
-       bhi     1b
-1:
-       clr     (r1)+
-       cmp     r1,$_end
-       blo     1b
-
-/ use KI escape to set KD7 to IO seg
-/ set KD6 to first available core
-/ If profiling, snag supervisor registers.
-
-       mov     $IO,-(sp)
-       mtpi    *$KDSA7
-9:
-       mov     $_etext-8192.+63.,r2
-       ash     $-6,r2
-       bic     $!1777,r2
-       add     KISA1,r2
-       .if     .PROFIL
-       mov     r2,SISA2
-       mov     r2,_proloc
-       mov     $77406,SISD2
-       add     $200,r2
-       mov     r2,SISA2+2
-       mov     $77406,SISD2+2
-       add     $200,r2
-       .endif
-       mov     r2,KDSA6
-
-/ Turn off write permission on kernel text
-/ Take stuff above data out of address space
-
-       mov     $KISD0,r0
-1:
-       mov     $77402,(r0)+
-       cmp     r0,$KISD7
-       blos    1b
-
-       mov     $_end+63.,r0
-       ash     $-6,r0
-       bic     $!1777,r0
-       mov     $KDSD0,r1
-1:
-       cmp     r0,$200
-       bge     2f
-       dec     r0
-       bge     4f
-       clr     (r1)
-       br      3f
-4:
-       movb    r0,1(r1)
-       br      3f
-2:
-       movb    $177,1(r1)
-3:
-       tst     (r1)+
-       sub     $200,r0
-       cmp     r1,$KDSD5
-       blos    1b
-
-/ set up supervisor D registers
-
-9:
-       mov     $6,SISD0
-       mov     $6,SISD1
-
-/ set up real sp
-/ clear user block
-/ test for floating point hardware
-
-       mov     $_u+[usize*64.],sp
-       mov     $1f,nofault
-       setd                    / jump to 1f if this traps
-       inc     fpp
-1:
-       clr     nofault
-       mov     $_u,r0
-1:
-       clr     (r0)+
-       cmp     r0,sp
-       blo     1b
-       .if     .PROFIL
-       mov     $40000,r0
-       mov     $10000,PS       / prev = super
-1:
-       clr     -(sp)
-       mtpi    (r0)+
-       cmp     r0,$100000
-       blo     1b
-       jsr     pc,_isprof
-       .endif
-
-/ set up previous mode and call main
-/ on return, enter user mode at 0R
-
-       mov     $30000,PS
-       jsr     pc,_main
-       mov     $170000,-(sp)
-       clr     -(sp)
-       rtt
-
-.globl _rkboot, _rpboot
-_rkboot:
-       jmp     *$173000
-
-_rpboot:
-       jmp     *$173006
-
-
-.globl trap, call
-.globl _trap
-
-/ all traps and interrupts are
-/ vectored thru this routine.
-
-trap:
-       mov     PS,saveps
-       tst     nofault
-       bne     1f
-       mov     SSR0,ssr
-       mov     SSR1,ssr+2
-       mov     SSR2,ssr+4
-       mov     $1,SSR0
-       jsr     r0,call1; jmp _trap
-       / no return
-1:
-       mov     $1,SSR0
-       mov     nofault,(sp)
-       rtt
-.text
-
-.globl _runrun
-call1:
-       mov     saveps,-(sp)
-       spl     0
-       br      1f
-
-call:
-       mov     PS,-(sp)
-1:
-       mov     r1,-(sp)
-       mfpd    sp
-       mov     4(sp),-(sp)
-       bic     $!37,(sp)
-       bit     $30000,PS
-       beq     1f
-       jsr     pc,(r0)+
-       tstb    _runrun
-       beq     2f
-       mov     $12.,(sp)               / trap 12 is give up cpu
-       jsr     pc,_trap
-2:
-       tst     (sp)+
-       mtpd    sp
-       br      2f
-1:
-       bis     $30000,PS
-       jsr     pc,(r0)+
-       cmp     (sp)+,(sp)+
-2:
-       mov     (sp)+,r1
-       tst     (sp)+
-       mov     (sp)+,r0
-       rtt
-
-.globl _savfp
-_savfp:
-       tst     fpp
-       beq     9f              / No FP hardware
-       mov     2(sp),r1
-       stfps   (r1)+
-       setd
-       movf    fr0,(r1)+
-       movf    fr1,(r1)+
-       movf    fr2,(r1)+
-       movf    fr3,(r1)+
-       movf    fr4,fr0
-       movf    fr0,(r1)+
-       movf    fr5,fr0
-       movf    fr0,(r1)+
-9:
-       rts     pc
-
-.globl _restfp
-_restfp:
-       tst     fpp
-       beq     9f
-       mov     2(sp),r1
-       mov     r1,r0
-       setd
-       add     $8.+2.,r1
-       movf    (r1)+,fr1
-       movf    (r1)+,fr2
-       movf    (r1)+,fr3
-       movf    (r1)+,fr0
-       movf    fr0,fr4
-       movf    (r1)+,fr0
-       movf    fr0,fr5
-       movf    2(r0),fr0
-       ldfps   (r0)
-9:
-       rts     pc
-
-.globl _stst
-_stst:
-       tst     fpp
-       beq     9f
-       stst    r0
-       mov     r0,*2(sp)
-9:
-       rts     pc
-
-.globl _addupc
-_addupc:
-       mov     r2,-(sp)
-       mov     6(sp),r2        / base of prof with base,leng,off,scale
-       mov     4(sp),r0        / pc
-       sub     4(r2),r0        / offset
-       clc
-       ror     r0
-       mov     6(r2),r1
-       clc
-       ror     r1
-       mul     r1,r0           / scale
-       ashc    $-14.,r0
-       inc     r1
-       bic     $1,r1
-       cmp     r1,2(r2)        / length
-       bhis    1f
-       add     (r2),r1         / base
-       mov     nofault,-(sp)
-       mov     $2f,nofault
-       mfpd    (r1)
-       add     12.(sp),(sp)
-       mtpd    (r1)
-       br      3f
-2:
-       clr     6(r2)
-3:
-       mov     (sp)+,nofault
-1:
-       mov     (sp)+,r2
-       rts     pc
-
-.globl _display
-_display:
-       dec     dispdly
-       bge     2f
-       clr     dispdly
-       mov     PS,-(sp)
-       mov     $HIPRI,PS
-       mov     CSW,r1
-       bit     $1,r1
-       beq     1f
-       bis     $30000,PS
-       dec     r1
-1:
-       jsr     pc,fuword
-       mov     r0,CSW
-       mov     (sp)+,PS
-       cmp     r0,$-1
-       bne     2f
-       mov     $120.,dispdly           / 2 sec delay after CSW fault
-2:
-       rts     pc
-
-.globl _backup
-.globl _regloc
-_backup:
-       mov     2(sp),r0
-       movb    ssr+2,r1
-       jsr     pc,1f
-       movb    ssr+3,r1
-       jsr     pc,1f
-       movb    _regloc+7,r1
-       asl     r1
-       add     r0,r1
-       mov     ssr+4,(r1)
-       clr     r0
-2:
-       rts     pc
-1:
-       mov     r1,-(sp)
-       asr     (sp)
-       asr     (sp)
-       asr     (sp)
-       bic     $!7,r1
-       movb    _regloc(r1),r1
-       asl     r1
-       add     r0,r1
-       sub     (sp)+,(r1)
-       rts     pc
-
-
-.globl _fubyte, _subyte
-.globl _fuword, _suword
-.globl _fuibyte, _suibyte
-.globl _fuiword, _suiword
-_fuibyte:
-       mov     2(sp),r1
-       bic     $1,r1
-       jsr     pc,giword
-       br      2f
-
-_fubyte:
-       mov     2(sp),r1
-       bic     $1,r1
-       jsr     pc,gword
-
-2:
-       cmp     r1,2(sp)
-       beq     1f
-       swab    r0
-1:
-       bic     $!377,r0
-       rts     pc
-
-_suibyte:
-       mov     2(sp),r1
-       bic     $1,r1
-       jsr     pc,giword
-       mov     r0,-(sp)
-       cmp     r1,4(sp)
-       beq     1f
-       movb    6(sp),1(sp)
-       br      2f
-1:
-       movb    6(sp),(sp)
-2:
-       mov     (sp)+,r0
-       jsr     pc,piword
-       clr     r0
-       rts     pc
-
-_subyte:
-       mov     2(sp),r1
-       bic     $1,r1
-       jsr     pc,gword
-       mov     r0,-(sp)
-       cmp     r1,4(sp)
-       beq     1f
-       movb    6(sp),1(sp)
-       br      2f
-1:
-       movb    6(sp),(sp)
-2:
-       mov     (sp)+,r0
-       jsr     pc,pword
-       clr     r0
-       rts     pc
-
-_fuiword:
-       mov     2(sp),r1
-fuiword:
-       jsr     pc,giword
-       rts     pc
-
-_fuword:
-       mov     2(sp),r1
-fuword:
-       jsr     pc,gword
-       rts     pc
-
-giword:
-       mov     PS,-(sp)
-       spl     HIGH
-       mov     nofault,-(sp)
-       mov     $err,nofault
-       mfpi    (r1)
-       mov     (sp)+,r0
-       br      1f
-
-gword:
-       mov     PS,-(sp)
-       spl     HIGH
-       mov     nofault,-(sp)
-       mov     $err,nofault
-       mfpd    (r1)
-       mov     (sp)+,r0
-       br      1f
-
-_suiword:
-       mov     2(sp),r1
-       mov     4(sp),r0
-suiword:
-       jsr     pc,piword
-       rts     pc
-
-_suword:
-       mov     2(sp),r1
-       mov     4(sp),r0
-suword:
-       jsr     pc,pword
-       rts     pc
-
-piword:
-       mov     PS,-(sp)
-       spl     HIGH
-       mov     nofault,-(sp)
-       mov     $err,nofault
-       mov     r0,-(sp)
-       mtpi    (r1)
-       br      1f
-
-pword:
-       mov     PS,-(sp)
-       spl     HIGH
-       mov     nofault,-(sp)
-       mov     $err,nofault
-       mov     r0,-(sp)
-       mtpd    (r1)
-1:
-       mov     (sp)+,nofault
-       mov     (sp)+,PS
-       rts     pc
-
-err:
-       mov     (sp)+,nofault
-       mov     (sp)+,PS
-       tst     (sp)+
-       mov     $-1,r0
-       rts     pc
-
-.globl _copyin, _copyout
-.globl _copyiin, _copyiout
-_copyiin:
-       jsr     pc,copsu
-1:
-       mfpi    (r0)+
-       mov     (sp)+,(r1)+
-       sob     r2,1b
-       br      2f
-
-_copyin:
-       jsr     pc,copsu
-1:
-       mfpd    (r0)+
-       mov     (sp)+,(r1)+
-       sob     r2,1b
-       br      2f
-
-_copyiout:
-       jsr     pc,copsu
-1:
-       mov     (r0)+,-(sp)
-       mtpi    (r1)+
-       sob     r2,1b
-       br      2f
-
-_copyout:
-       jsr     pc,copsu
-1:
-       mov     (r0)+,-(sp)
-       mtpd    (r1)+
-       sob     r2,1b
-2:
-       mov     (sp)+,nofault
-       mov     (sp)+,r2
-       clr     r0
-       rts     pc
-
-copsu:
-       mov     (sp)+,r0
-       mov     r2,-(sp)
-       mov     nofault,-(sp)
-       mov     r0,-(sp)
-       mov     10(sp),r0
-       mov     12(sp),r1
-       mov     14(sp),r2
-       asr     r2
-       mov     $1f,nofault
-       rts     pc
-
-1:
-       mov     (sp)+,nofault
-       mov     (sp)+,r2
-       mov     $-1,r0
-       rts     pc
-
-.globl _idle, _waitloc
-_idle:
-       mov     PS,-(sp)
-       spl     0
-       wait
-waitloc:
-       mov     (sp)+,PS
-       rts     pc
-
-       .data
-_waitloc:
-       waitloc
-       .text
-
-.globl _save
-_save:
-       mov     (sp)+,r1
-       mov     (sp),r0
-       mov     r2,(r0)+
-       mov     r3,(r0)+
-       mov     r4,(r0)+
-       mov     r5,(r0)+
-       mov     sp,(r0)+
-       mov     r1,(r0)+
-       clr     r0
-       jmp     (r1)
-
-       .globl  _resume
-_resume:
-       mov     2(sp),r0                / new process
-       mov     4(sp),r1                / new stack
-       spl     7
-       mov     r0,KDSA6                / In new process
-       mov     (r1)+,r2
-       mov     (r1)+,r3
-       mov     (r1)+,r4
-       mov     (r1)+,r5
-       mov     (r1)+,sp
-       mov     $1,r0
-       spl     0
-       jmp     *(r1)+
-
-.globl _spl0, _spl1, _spl4, _spl5, _spl6, _spl7, _splx
-_spl0:
-       mov     PS,r0
-       spl     0
-       rts     pc
-
-_spl1:
-       mov     PS,r0
-       spl     1
-       rts     pc
-
-_spl4:
-       mov     PS,r0
-       spl     4
-       rts     pc
-
-_spl5:
-       mov     PS,r0
-       spl     5
-       rts     pc
-
-_spl6:
-       mov     PS,r0
-       spl     6
-       rts     pc
-
-_spl7:
-       mov     PS,r0
-       spl     HIGH
-       rts     pc
-
-_splx:
-       mov     2(sp),PS
-       rts     pc
-
-.globl _copyseg
-_copyseg:
-       mov     PS,-(sp)
-       mov     4(sp),SISA0
-       mov     6(sp),SISA1
-       mov     $10000+HIPRI,PS
-       mov     r2,-(sp)
-       clr     r0
-       mov     $8192.,r1
-       mov     $32.,r2
-1:
-       mfpd    (r0)+
-       mtpd    (r1)+
-       sob     r2,1b
-       mov     (sp)+,r2
-       mov     (sp)+,PS
-       rts     pc
-
-.globl _clearseg
-_clearseg:
-       mov     PS,-(sp)
-       mov     4(sp),SISA0
-       mov     $10000+HIPRI,PS
-       clr     r0
-       mov     $32.,r1
-1:
-       clr     -(sp)
-       mtpd    (r0)+
-       sob     r1,1b
-       mov     (sp)+,PS
-       rts     pc
-
-/ Long quotient
-
-       .globl  ldiv
-ldiv:
-       jsr     r5,csv
-       mov     10.(r5),r3
-       sxt     r4
-       bpl     1f
-       neg     r3
-1:
-       cmp     r4,8.(r5)
-       bne     hardldiv
-       mov     6.(r5),r2
-       mov     4.(r5),r1
-       bge     1f
-       neg     r1
-       neg     r2
-       sbc     r1
-       com     r4
-1:
-       mov     r4,-(sp)
-       clr     r0
-       div     r3,r0
-       mov     r0,r4           /high quotient
-       mov     r1,r0
-       mov     r2,r1
-       div     r3,r0
-       bvc     1f
-       sub     r3,r0           / this is the clever part
-       div     r3,r0
-       tst     r1
-       sxt     r1
-       add     r1,r0           / cannot overflow!
-1:
-       mov     r0,r1
-       mov     r4,r0
-       tst     (sp)+
-       bpl     9f
-       neg     r0
-       neg     r1
-       sbc     r0
-9:
-       jmp     cret
-
-hardldiv:
-       4
-
-/ Long remainder
-
-       .globl  lrem
-lrem:
-       jsr     r5,csv
-       mov     10.(r5),r3
-       sxt     r4
-       bpl     1f
-       neg     r3
-1:
-       cmp     r4,8.(r5)
-       bne     hardlrem
-       mov     6.(r5),r2
-       mov     4.(r5),r1
-       mov     r1,r4
-       bge     1f
-       neg     r1
-       neg     r2
-       sbc     r1
-1:
-       clr     r0
-       div     r3,r0
-       mov     r1,r0
-       mov     r2,r1
-       div     r3,r0
-       bvc     1f
-       sub     r3,r0
-       div     r3,r0
-       tst     r1
-       beq     9f
-       add     r3,r1
-1:
-       tst     r4
-       bpl     9f
-       neg     r1
-9:
-       sxt     r0
-       jmp     cret
-
-/ The divisor is known to be >= 2^15.  Only 16 cycles are
-/ needed to get a remainder.
-hardlrem:
-       4
-
-/.globl        lmul
-/lmul:
-/      mov     r2,-(sp)
-/      mov     r3,-(sp)
-/      mov     8(sp),r2
-/      sxt     r1
-/      sub     6(sp),r1
-/      mov     12.(sp),r0
-/      sxt     r3
-/      sub     10.(sp),r3
-/      mul     r0,r1
-/      mul     r2,r3
-/      add     r1,r3
-/      mul     r2,r0
-/      sub     r3,r0
-/      mov     (sp)+,r3
-/      mov     (sp)+,r2
-/      rts     pc
-
-.globl csv
-csv:
-       mov     r5,r0
-       mov     sp,r5
-       mov     r4,-(sp)
-       mov     r3,-(sp)
-       mov     r2,-(sp)
-       jsr     pc,(r0)
-
-.globl cret
-cret:
-       mov     r5,r2
-       mov     -(r2),r4
-       mov     -(r2),r3
-       mov     -(r2),r2
-       mov     r5,sp
-       mov     (sp)+,r5
-       rts     pc
-
-.globl _u
-_u     = 140000
-usize  = 16.
-
-CSW    = 177570
-PS     = 177776
-SSR0   = 177572
-SSR1   = 177574
-SSR2   = 177576
-SSR3   = 172516
-KISA0  = 172340
-KISA1  = 172342
-KISA7  = 172356
-KISD0  = 172300
-KISD7  = 172316
-KDSA0  = 172360
-KDSA6  = 172374
-KDSA7  = 172376
-KDSD0  = 172320
-KDSD5  = 172332
-SISA0  = 172240
-SISA1  = 172242
-SISA2  = 172244
-SISD0  = 172200
-SISD1  = 172202
-SISD2  = 172204
-MSCR   = 017777746     / 11/70 memory control register
-IO     = 177600
-
-SWR    = 177570
-.data
-.globl _ka6
-.globl _cputype
-
-_ka6:  KDSA6
-_cputype:45.
-stk:   0
-
-.bss
-nofault:.=.+2
-fpp:   .=.+2
-ssr:   .=.+6
-dispdly:.=.+2
-saveps:        .=.+2
-
-.text
-/ system profiler
-/  Expects to have a KW11-P in addition to the line-frequency
-/  clock, and it should be set to BR7.
-/  Uses supervisor I space register 2&3 (40000-100000)
-/  to maintain the profile.
-
-       .if     .PROFIL
-CCSB   = 172542
-CCSR   = 172540
-
-.globl _sprof, _xprobuf, _probsiz, _mode
-_probsiz = 37777
-
-_isprof:
-       mov     $1f,nofault
-       mov     $_sprof,104     / interrupt
-       mov     $340,106        / pri
-       mov     $100.,CCSB      / count set = 100
-       mov     $113,CCSR       / count down, 10kHz, repeat
-1:
-       clr     nofault
-       rts     pc
-
-_sprof:
-       mov     r0,-(sp)
-       mov     PS,r0
-       ash     $-10.,r0
-       bic     $!14,r0
-       add     $1,_mode+2(r0)
-       adc     _mode(r0)
-       cmp     r0,$14          / user
-       beq     done
-       mov     2(sp),r0        / pc
-       asr     r0
-       asr     r0
-       bic     $140001,r0
-       cmp     r0,$_probsiz
-       blo     1f
-       inc     _outside
-       br      done
-1:
-       mov     $10340,PS               / prev = super
-       mfpi    40000(r0)
-       inc     (sp)
-       mtpi    40000(r0)
-       bne     done
-       mov     r1,-(sp)
-       mov     $_xprobuf,r1
-2:
-       cmp     (r1)+,r0
-       bne     3f
-       inc     (r1)
-       br      4f
-3:
-       tst     (r1)+
-       bne     2b
-       sub     $4,r1
-       mov     r0,(r1)+
-       mov     $1,(r1)+
-4:
-       mov     (sp)+,r1
-done:
-       mov     (sp)+,r0
-       mov     $113,CCSR
-       rtt
-
-/ count subroutine calls during profiling
-/  of the system.
-
-.globl mcount, _profcnts, _profsize
-
-.bss
-_profcnts:
-       .=.+[6*340.]
-
-.globl countbase
-.data
-countbase:
-       _profcnts
-_profsize:
-       340.
-.text
-
-mcount:
-       mov     (r0),r1
-       bne     1f
-       mov     countbase,r1
-       beq     2f
-       add     $6,countbase
-       cmp     countbase,$_profcnts+[6*340.]
-       blo     3f
-       clr     countbase
-       rts     pc
-3:
-       mov     (sp),(r1)+
-       mov     r1,(r0)
-1:
-       inc     2(r1)
-       bne     2f
-       inc     (r1)
-2:
-       rts     pc
-
-.bss
-_xprobuf:.=.+512.
-_proloc:.=.+2
-_mode: .=.+16.
-_outside: .=.+2
-
-       .endif
diff --git a/usr/sys/conf/mch0.s b/usr/sys/conf/mch0.s
deleted file mode 100644 (file)
index 6734653..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-HTDUMP = 1
-TUDUMP = 0
diff --git a/usr/sys/conf/mkconf.c b/usr/sys/conf/mkconf.c
deleted file mode 100644 (file)
index 5888b0c..0000000
+++ /dev/null
@@ -1,821 +0,0 @@
-#include <stdio.h>
-
-#define CHAR   01
-#define BLOCK  02
-#define INTR   04
-#define EVEN   010
-#define KL     020
-#define ROOT   040
-#define        SWAP    0100
-#define        PIPE    0200
-
-char   *btab[] =
-{
-       "rk",
-       "rp",
-       "rf",
-       "tm",
-       "tc",
-       "hs",
-       "hp",
-       "ht",
-       "rl",
-       0
-};
-char   *ctab[] =
-{
-       "console",
-       "pc",
-       "lp",
-       "dc",
-       "dh",
-       "dp",
-       "dj",
-       "dn",
-       "mem",
-       "rk",
-       "rf",
-       "rp",
-       "tm",
-       "hs",
-       "hp",
-       "ht",
-       "du",
-       "tty",
-       "rl",
-       0
-};
-struct tab
-{
-       char    *name;
-       int     count;
-       int     address;
-       int     key;
-       char    *codea;
-       char    *codeb;
-       char    *codec;
-       char    *coded;
-       char    *codee;
-       char    *codef;
-       char    *codeg;
-} table[] =
-{
-       "console",
-       -1, 60, CHAR+INTR+KL,
-       "       klin; br4\n     klou; br4\n",
-       ".globl _klrint\nklin:  jsr     r0,call; jmp _klrint\n",
-       ".globl _klxint\nklou:  jsr     r0,call; jmp _klxint\n",
-       "",
-       "       klopen, klclose, klread, klwrite, klioctl, nulldev, 0,",
-       "",
-       "int    klopen(), klclose(), klread(), klwrite(), klioctl();",
-
-       "mem",
-       -1, 300, CHAR,
-       "",
-       "",
-       "",
-       "",
-       "       nulldev, nulldev, mmread, mmwrite, nodev, nulldev, 0, ",
-       "",
-       "int    mmread(), mmwrite();",
-
-       "pc",
-       0, 70, CHAR+INTR,
-       "       pcin; br4\n     pcou; br4\n",
-       ".globl _pcrint\npcin:  jsr     r0,call; jmp _pcrint\n",
-       ".globl _pcpint\npcou:  jsr     r0,call; jmp _pcpint\n",
-       "",
-       "       pcopen, pcclose, pcread, pcwrite, nodev, nulldev, 0, ",
-       "",
-       "int    pcopen(), pcclose(), pcread(), pcwrite();",
-
-       "clock",
-       -2, 100, INTR,
-       "       kwlp; br6\n",
-       ".globl _clock\n",
-       "kwlp:  jsr     r0,call; jmp _clock\n",
-       "",
-       "",
-       "",
-       "",
-
-       "parity",
-       -1, 114, INTR,
-       "       trap; br7+7.            / 11/70 parity\n",
-       "",
-       "",
-       "",
-       "",
-       "",
-       "",
-
-/*
- * 110 unused
- * 114 memory parity
- * 120 XY plotter
- * 124 DR11-B
- * 130 AD01 & RL01
-*/
-
-       "rl",
-       0, 130, BLOCK+CHAR+INTR,
-       "       rlio; br5\n",
-       ".globl _rlintr\n",
-       "rlio:  jsr     r0,call; jmp _rlintr\n",
-       "       nulldev, nulldev, rlstrategy, &rltab,",
-       "       rlopen, rlclose, rlread, rlwrite, nodev, nulldev, 0,",
-       "int    rlstrategy();\nstruct   buf     rltab;",
-       "int    rlopen(), rlclose(), rlread(), rlwrite();",
-
-/*
- * 134 AFC11
- * 140 AA11
- * 144 AA11
- * 150-174 unused
- */
-
-       "lp",
-       0, 200, CHAR+INTR,
-       "       lpou; br4\n",
-       "",
-       ".globl _lpint\nlpou:   jsr     r0,call; jmp _lpint\n",
-       "",
-       "       lpopen, lpclose, nodev, lpwrite, nodev, nulldev, 0,",
-       "",
-       "int    lpopen(), lpclose(), lpwrite();",
-
-       "rf",
-       0, 204, BLOCK+CHAR+INTR,
-       "       rfio; br5\n",
-       ".globl _rfintr\n",
-       "rfio:  jsr     r0,call; jmp _rfintr\n",
-       "       nulldev, nulldev, rfstrategy, &rftab, ",
-       "       nulldev, nulldev, rfread, rfwrite, nodev, nulldev, 0,",
-       "int    rfstrategy();\nstruct   buf     rftab;",
-       "int    rfread(), rfwrite();",
-
-       "hs",
-       0, 204, BLOCK+CHAR+INTR,
-       "       hsio; br5\n",
-       ".globl _hsintr\n",
-       "hsio:  jsr     r0,call; jmp _hsintr\n",
-       "       nulldev, nulldev, hsstrategy, &hstab, ",
-       "       nulldev, nulldev, hsread, hswrite, nodev, nulldev, 0,",
-       "int    hsstrategy();\nstruct   buf     hstab;",
-       "int    hsread(), hswrite();",
-
-/*
- * 210 RC
- */
-
-       "tc",
-       0, 214, BLOCK+INTR,
-       "       tcio; br6\n",
-       ".globl _tcintr\n",
-       "tcio:  jsr     r0,call; jmp _tcintr\n",
-       "       nulldev, tcclose, tcstrategy, &tctab,",
-       "",
-       "int    tcstrategy(), tcclose();\nstruct        buf     tctab;",
-       "",
-
-       "rk",
-       0, 220, BLOCK+CHAR+INTR,
-       "       rkio; br5\n",
-       ".globl _rkintr\n",
-       "rkio:  jsr     r0,call; jmp _rkintr\n",
-       "       nulldev, nulldev, rkstrategy, &rktab,",
-       "       nulldev, nulldev, rkread, rkwrite, nodev, nulldev, 0,",
-       "int    rkstrategy();\nstruct   buf     rktab;",
-       "int    rkread(), rkwrite();",
-
-       "tm",
-       0, 224, BLOCK+CHAR+INTR,
-       "       tmio; br5\n",
-       ".globl _tmintr\n",
-       "tmio:  jsr     r0,call; jmp _tmintr\n",
-       "       tmopen, tmclose, tmstrategy, &tmtab, ",
-       "       tmopen, tmclose, tmread, tmwrite, nodev, nulldev, 0,",
-       "int    tmopen(), tmclose(), tmstrategy();\nstruct      buf     tmtab;",
-       "int    tmread(), tmwrite();",
-
-       "ht",
-       0, 224, BLOCK+CHAR+INTR,
-       "       htio; br5\n",
-       ".globl _htintr\n",
-       "htio:  jsr     r0,call; jmp _htintr\n",
-       "       htopen, htclose, htstrategy, &httab,",
-       "       htopen, htclose, htread, htwrite, nodev, nulldev, 0,",
-       "int    htopen(), htclose(), htstrategy();\nstruct      buf     httab;",
-       "int    htread(), htwrite();",
-
-       "cr",
-       0, 230, CHAR+INTR,
-       "       crin; br6\n",
-       "",
-       ".globl _crint\ncrin:   jsr     r0,call; jmp _crint\n",
-       "",
-       "       cropen, crclose, crread, nodev, nodev, nulldev, 0,",
-       "",
-       "int    cropen(), crclose(), crread();",
-
-/*
- * 234 UDC11
- */
-
-       "rp",
-       0, 254, BLOCK+CHAR+INTR,
-       "       rpio; br5\n",
-       ".globl _rpintr\n",
-       "rpio:  jsr     r0,call; jmp _rpintr\n",
-       "       nulldev, nulldev, rpstrategy, &rptab,",
-       "       nulldev, nulldev, rpread, rpwrite, nodev, nulldev, 0,",
-       "int    rpstrategy();\nstruct   buf     rptab;",
-       "int    rpread(), rpwrite();",
-
-       "hp",
-       0, 254, BLOCK+CHAR+INTR,
-       "       hpio; br5\n",
-       ".globl _hpintr\n",
-       "hpio:  jsr     r0,call; jmp _hpintr\n",
-       "       nulldev, nulldev, hpstrategy, &hptab,",
-       "       nulldev, nulldev, hpread, hpwrite, nodev, nulldev, 0,",
-       "int    hpstrategy();\nstruct   buf     hptab;",
-       "int    hpread(), hpwrite();",
-
-/*
- * 260 TA11
- * 264-274 unused
- */
-
-       "dc",
-       0, 308, CHAR+INTR,
-       "       dcin; br5+%d.\n dcou; br5+%d.\n",
-       ".globl _dcrint\ndcin:  jsr     r0,call; jmp _dcrint\n",
-       ".globl _dcxint\ndcou:  jsr     r0,call; jmp _dcxint\n",
-       "",
-       "       dcopen, dcclose, dcread, dcwrite, dcioctl, nulldev, dc11,",
-       "",
-       "int    dcopen(), dcclose(), dcread(), dcwrite(), dcioctl();\nstruct    tty     dc11[];",
-
-       "kl",
-       0, 308, INTR+KL,
-       "       klin; br4+%d.\n klou; br4+%d.\n",
-       "",
-       "",
-       "",
-       "",
-       "",
-       "",
-
-       "dp",
-       0, 308, CHAR+INTR,
-       "       dpin; br6+%d.\n dpou; br6+%d.\n",
-       ".globl _dprint\ndpin:  jsr     r0,call; jmp _dprint\n",
-       ".globl _dpxint\ndpou:  jsr     r0,call; jmp _dpxint\n",
-       "",
-       "       dpopen, dpclose, dpread, dpwrite, nodev, nulldev, 0,",
-       "",
-       "int    dpopen(), dpclose(), dpread(), dpwrite();",
-
-/*
- * DM11-A
- */
-
-       "dn",
-       0, 304, CHAR+INTR,
-       "       dnou; br5+%d.\n",
-       "",
-       ".globl _dnint\ndnou:   jsr     r0,call; jmp _dnint\n",
-       "",
-       "       dnopen, dnclose, nodev, dnwrite, nodev, nulldev, 0,",
-       "",
-       "int    dnopen(), dnclose(), dnwrite();",
-
-       "dhdm",
-       0, 304, INTR,
-       "       dmin; br4+%d.\n",
-       "",
-       ".globl _dmint\ndmin:   jsr     r0,call; jmp _dmint\n",
-       "",
-       "",
-       "",
-       "",
-
-/*
- * DR11-A+
- * DR11-C+
- * PA611+
- * PA611+
- * DT11+
- * DX11+
- */
-
-       "dl",
-       0, 308, INTR+KL,
-       "       klin; br4+%d.\n klou; br4+%d.\n",
-       "",
-       "",
-       "",
-       "",
-       "",
-       "",
-
-/*
- * DJ11
- */
-
-       "dh",
-       0, 308, CHAR+INTR+EVEN,
-       "       dhin; br5+%d.\n dhou; br5+%d.\n",
-       ".globl _dhrint\ndhin:  jsr     r0,call; jmp _dhrint\n",
-       ".globl _dhxint\ndhou:  jsr     r0,call; jmp _dhxint\n",
-       "",
-       "       dhopen, dhclose, dhread, dhwrite, dhioctl, dhstop, dh11,",
-       "",
-       "int    dhopen(), dhclose(), dhread(), dhwrite(), dhioctl(), dhstop();\nstruct  tty     dh11[];",
-
-/*
- * GT40
- * LPS+
- * DQ11
- * KW11-W
- */
-
-       "du",
-       0, 308, CHAR+INTR,
-       "       duin; br6+%d.\n duou; br6+%d.\n",
-       ".globl _durint\nduin:  jsr     r0,call; jmp _durint\n",
-       ".globl _duxint\nduou:  jsr     r0,call; jmp _duxint\n",
-       "",
-       "       duopen, duclose, duread, duwrite, nodev, nulldev, 0,",
-       "",
-       "int    duopen(), duclose(), duread(), duwrite();",
-
-       "tty",
-       1, 0, CHAR,
-       "",
-       "",
-       "",
-       "",
-       "       syopen, nulldev, syread, sywrite, sysioctl, nulldev, 0,",
-       "",
-       "int    syopen(), syread(), sywrite(), sysioctl();",
-
-       0
-};
-
-char   *stra[] =
-{
-       "/ low core",
-       "",
-       ".data",
-       "ZERO:",
-       "",
-       "br4 = 200",
-       "br5 = 240",
-       "br6 = 300",
-       "br7 = 340",
-       "",
-       ". = ZERO+0",
-       "       br      1f",
-       "       4",
-       "",
-       "/ trap vectors",
-       "       trap; br7+0.            / bus error",
-       "       trap; br7+1.            / illegal instruction",
-       "       trap; br7+2.            / bpt-trace trap",
-       "       trap; br7+3.            / iot trap",
-       "       trap; br7+4.            / power fail",
-       "       trap; br7+5.            / emulator trap",
-       "       start;br7+6.            / system  (overlaid by 'trap')",
-       "",
-       ". = ZERO+40",
-       ".globl start, dump",
-       "1:     jmp     start",
-       "       jmp     dump",
-       "",
-       0,
-};
-
-char   *strb[] =
-{
-       "",
-       ". = ZERO+240",
-       "       trap; br7+7.            / programmed interrupt",
-       "       trap; br7+8.            / floating point",
-       "       trap; br7+9.            / segmentation violation",
-       0
-};
-
-char   *strc[] =
-{
-       "",
-       "/ floating vectors",
-       ". = ZERO+300",
-       0,
-};
-
-char   *strd[] =
-{
-       "",
-       "//////////////////////////////////////////////////////",
-       "/              interface code to C",
-       "//////////////////////////////////////////////////////",
-       "",
-       ".text",
-       ".globl call, trap",
-       0
-};
-
-char   *stre[] =
-{
-       "#include \"../h/param.h\"",
-       "#include \"../h/systm.h\"",
-       "#include \"../h/buf.h\"",
-       "#include \"../h/tty.h\"",
-       "#include \"../h/conf.h\"",
-       "#include \"../h/proc.h\"",
-       "#include \"../h/text.h\"",
-       "#include \"../h/dir.h\"",
-       "#include \"../h/user.h\"",
-       "#include \"../h/file.h\"",
-       "#include \"../h/inode.h\"",
-       "#include \"../h/acct.h\"",
-       "",
-       "int    nulldev();",
-       "int    nodev();",
-       0
-};
-
-char   *stre1[] =
-{
-       "struct bdevsw  bdevsw[] =",
-       "{",
-       0,
-};
-
-char   *strf[] =
-{
-       "       0",
-       "};",
-       "",
-       0,
-};
-
-char   *strf1[] =
-{
-       "",
-       "struct cdevsw  cdevsw[] =",
-       "{",
-       0,
-};
-
-char   strg[] =
-{
-"      0\n\
-};\n\
-int    rootdev = makedev(%d, %d);\n\
-int    swapdev = makedev(%d, %d);\n\
-int    pipedev = makedev(%d, %d);\n\
-int    nldisp = %d;\n\
-daddr_t        swplo   = %ld;\n\
-int    nswap   = %l;\n\
-"};
-
-char   strg1[] =
-{
-"      \n\
-struct buf     buf[NBUF];\n\
-struct file    file[NFILE];\n\
-struct inode   inode[NINODE];\n"
-};
-
-char   *strg1a[] =
-{
-       "int    mpxchan();",
-       "int    (*ldmpx)() = mpxchan;",
-       0
-};
-
-char   strg2[] =
-{
-"struct        proc    proc[NPROC];\n\
-struct text    text[NTEXT];\n\
-struct buf     bfreelist;\n\
-struct acct    acctbuf;\n\
-struct inode   *acctp;\n"
-};
-
-char   *strh[] =
-{
-       "       0",
-       "};",
-       "",
-       "int    ttyopen(), ttyclose(), ttread(), ttwrite(), ttyinput(), ttstart();",
-       0
-};
-
-char   *stri[] =
-{
-       "int    pkopen(), pkclose(), pkread(), pkwrite(), pkioctl(), pkrint(), pkxint();",
-       0
-};
-
-char   *strj[] =
-{
-       "struct linesw  linesw[] =",
-       "{",
-       "       ttyopen, nulldev, ttread, ttwrite, nodev, ttyinput, ttstart, /* 0 */",
-       0
-};
-
-char   *strk[] =
-{
-       "       pkopen, pkclose, pkread, pkwrite, pkioctl, pkrint, pkxint, /* 1 */",
-       0
-};
-
-int    pack;
-int    mpx;
-int    rootmaj = -1;
-int    rootmin;
-int    swapmaj = -1;
-int    swapmin;
-int    pipemaj = -1;
-int    pipemin;
-long   swplo   = 4000;
-int    nswap = 872;
-int    pack;
-int    nldisp = 1;
-
-main()
-{
-       register struct tab *p;
-       register char *q;
-       int i, n, ev, nkl;
-       int flagf, flagb, dumpht;
-
-       while(input());
-
-/*
- * pass1 -- create interrupt vectors
- */
-       nkl = 0;
-       flagf = flagb = 1;
-       freopen("l.s", "w", stdout);
-       puke(stra);
-       ev = 0;
-       for(p=table; p->name; p++)
-       if(p->count != 0 && p->key & INTR) {
-               if(p->address>240 && flagb) {
-                       flagb = 0;
-                       puke(strb);
-               }
-               if(p->address >= 300) {
-                       if(flagf) {
-                               ev = 0;
-                               flagf = 0;
-                               puke(strc);
-                       }
-                       if(p->key & EVEN && ev & 07) {
-                               printf("        .=.+4\n");
-                               ev += 4;
-                       }
-                       printf("/%s %o\n", p->name, 0300+ev);
-               } else
-                       printf("\n. = ZERO+%d\n", p->address);
-               n = p->count;
-               if(n < 0)
-                       n = -n;
-               for(i=0; i<n; i++) {
-                       if(p->key & KL) {
-                               printf(p->codea, nkl, nkl);
-                               nkl++;
-                       } else
-                               printf(p->codea, i, i);
-                       if (p->address<300)
-                               fprintf(stderr, "%s at %d\n", p->name, p->address+4*i);
-                       else
-                               fprintf(stderr, "%s at %o\n", p->name, 0300+ev);
-                       ev += p->address - 300;
-               }
-       }
-       if(flagb)
-               puke(strb);
-       puke(strd);
-       for(p=table; p->name; p++)
-       if(p->count != 0 && p->key & INTR)
-               printf("\n%s%s", p->codeb, p->codec);
-
-/*
- * pass 2 -- create configuration table
- */
-
-       freopen("c.c", "w", stdout);
-       /*
-        * declarations
-        */
-       puke(stre);
-       for (i=0; q=btab[i]; i++) {
-               for (p=table; p->name; p++)
-               if (equal(q, p->name) &&
-                  (p->key&BLOCK) && p->count && *p->codef)
-                       printf("%s\n", p->codef);
-       }
-       puke(stre1);
-       for(i=0; q=btab[i]; i++) {
-               for(p=table; p->name; p++)
-               if(equal(q, p->name) &&
-                  (p->key&BLOCK) && p->count) {
-                       printf("%s      /* %s = %d */\n", p->coded, q, i);
-                       if(p->key & ROOT)
-                               rootmaj = i;
-                       if (p->key & SWAP)
-                               swapmaj = i;
-                       if (p->key & PIPE)
-                               pipemaj = i;
-                       goto newb;
-               }
-               printf("        nodev, nodev, nodev, 0, /* %s = %d */\n", q, i);
-       newb:;
-       }
-       if (swapmaj == -1) {
-               swapmaj = rootmaj;
-               swapmin = rootmin;
-       }
-       if (pipemaj == -1) {
-               pipemaj = rootmaj;
-               pipemin = rootmin;
-       }
-       puke(strf);
-       for (i=0; q=ctab[i]; i++) {
-               for (p=table; p->name; p++)
-               if (equal(q, p->name) &&
-                  (p->key&CHAR) && p->count && *p->codeg)
-                       printf("%s\n", p->codeg);
-       }
-       puke(strf1);
-       for(i=0; q=ctab[i]; i++) {
-               for(p=table; p->name; p++)
-               if(equal(q, p->name) &&
-                  (p->key&CHAR) && p->count) {
-                       printf("%s      /* %s = %d */\n", p->codee, q, i);
-                       goto newc;
-               }
-               printf("        nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* %s = %d */\n", q, i);
-       newc:;
-       }
-       puke(strh);
-       if (pack) {
-               nldisp++;
-               puke(stri);
-       }
-       puke(strj);
-       if (pack)
-               puke(strk);
-       printf(strg, rootmaj, rootmin,
-               swapmaj, swapmin,
-               pipemaj, pipemin,
-               nldisp,
-               swplo, nswap);
-       printf(strg1);
-       if (!mpx)
-               puke(strg1a);
-       printf(strg2);
-       if(rootmaj < 0)
-               fprintf(stderr, "No root device given\n");
-       freopen("mch0.s", "w", stdout);
-       dumpht = 0;
-       for (i=0; table[i].name; i++) {
-               if (equal(table[i].name, "ht") && table[i].count)
-                       dumpht = 1;
-       }
-       if (dumpht) {
-               printf("HTDUMP = 1\n");
-               printf("TUDUMP = 0\n");
-       } else {
-               printf("HTDUMP = 0\n");
-               printf("TUDUMP = 1\n");
-       }
-}
-
-puke(s, a)
-char **s;
-{
-       char *c;
-
-       while(c = *s++) {
-               printf(c, a);
-               printf("\n");
-       }
-}
-
-input()
-{
-       char line[100];
-       register struct tab *q;
-       int count, n;
-       long num;
-       char keyw[32], dev[32];
-
-       if (fgets(line, 100, stdin) == NULL)
-               return(0);
-       count = -1;
-       n = sscanf(line, "%d%s%s%ld", &count, keyw, dev, &num);
-       if (count == -1 && n>0) {
-               count = 1;
-               n++;
-       }
-       if (n<2)
-               goto badl;
-       for(q=table; q->name; q++)
-       if(equal(q->name, keyw)) {
-               if(q->count < 0) {
-                       fprintf(stderr, "%s: no more, no less\n", keyw);
-                       return(1);
-               }
-               q->count += count;
-               if(q->address < 300 && q->count > 1) {
-                       q->count = 1;
-                       fprintf(stderr, "%s: only one\n", keyw);
-               }
-               return(1);
-       }
-       if (equal(keyw, "nswap")) {
-               if (n<3)
-                       goto badl;
-               if (sscanf(dev, "%ld", &num) <= 0)
-                       goto badl;
-               nswap = num;
-               return(1);
-       }
-       if (equal(keyw, "swplo")) {
-               if (n<3)
-                       goto badl;
-               if (sscanf(dev, "%ld", &num) <= 0)
-                       goto badl;
-               swplo = num;
-               return(1);
-       }
-       if (equal(keyw, "pack")) {
-               pack++;
-               return(1);
-       }
-       if (equal(keyw, "mpx")) {
-               mpx++;
-               return(1);
-       }
-       if(equal(keyw, "done"))
-               return(0);
-       if (equal(keyw, "root")) {
-               if (n<4)
-                       goto badl;
-               for (q=table; q->name; q++) {
-                       if (equal(q->name, dev)) {
-                               q->key |= ROOT;
-                               rootmin = num;
-                               return(1);
-                       }
-               }
-               fprintf(stderr, "Can't find root\n");
-               return(1);
-       }
-       if (equal(keyw, "swap")) {
-               if (n<4)
-                       goto badl;
-               for (q=table; q->name; q++) {
-                       if (equal(q->name, dev)) {
-                               q->key |= SWAP;
-                               swapmin = num;
-                               return(1);
-                       }
-               }
-               fprintf(stderr, "Can't find swap\n");
-               return(1);
-       }
-       if (equal(keyw, "pipe")) {
-               if (n<4)
-                       goto badl;
-               for (q=table; q->name; q++) {
-                       if (equal(q->name, dev)) {
-                               q->key |= PIPE;
-                               pipemin = num;
-                               return(1);
-                       }
-               }
-               fprintf(stderr, "Can't find pipe\n");
-               return(1);
-       }
-       fprintf(stderr, "%s: cannot find\n", keyw);
-       return(1);
-badl:
-       fprintf(stderr, "Bad line: %s", line);
-       return(1);
-}
-
-equal(a, b)
-char *a, *b;
-{
-       return(!strcmp(a, b));
-}
diff --git a/usr/sys/conf/rkhtconf b/usr/sys/conf/rkhtconf
deleted file mode 100644 (file)
index 4c6baec..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-rk
-root rk 0
-swap rk 0
-swplo 4000
-nswap 872
-ht
diff --git a/usr/sys/conf/rktmconf b/usr/sys/conf/rktmconf
deleted file mode 100644 (file)
index 726ae15..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-rk
-root rk 0
-swap rk 0
-swplo 4000
-nswap 872
-tm
diff --git a/usr/sys/conf/rp1conf b/usr/sys/conf/rp1conf
deleted file mode 100644 (file)
index fd99caf..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-rp
-dh
-root rp 9
-swap rp 10
-swplo 0
-nswap 2000
-tm
diff --git a/usr/sys/conf/rphtconf b/usr/sys/conf/rphtconf
deleted file mode 100644 (file)
index da33dd2..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-rp
-root rp 1
-swap rp 2
-swplo 0
-nswap 2000
-ht
diff --git a/usr/sys/conf/rptmconf b/usr/sys/conf/rptmconf
deleted file mode 100644 (file)
index 06a8d65..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-rp
-root rp 1
-swap rp 2
-swplo 0
-nswap 2000
-tm
diff --git a/usr/sys/conf/tconf b/usr/sys/conf/tconf
deleted file mode 100644 (file)
index 11da3ad..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-hp
-root hp 0
-swap hp 1
-swplo 0
-nswap 8778
-ht
-2dh
-dhdm
-3kl
diff --git a/usr/sys/dev/bio.c b/usr/sys/dev/bio.c
deleted file mode 100644 (file)
index 9c9b807..0000000
+++ /dev/null
@@ -1,564 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/buf.h"
-#include "../h/conf.h"
-#include "../h/proc.h"
-#include "../h/seg.h"
-
-#define        DISKMON 1
-
-#ifdef DISKMON
-struct {
-       int     nbuf;
-       long    nread;
-       long    nreada;
-       long    ncache;
-       long    nwrite;
-       long    bufcount[NBUF];
-} io_info;
-#endif
-
-/*
- * swap IO headers.
- * they are filled in to point
- * at the desired IO operation.
- */
-struct buf     swbuf1;
-struct buf     swbuf2;
-
-/*
- * The following several routines allocate and free
- * buffers with various side effects.  In general the
- * arguments to an allocate routine are a device and
- * a block number, and the value is a pointer to
- * to the buffer header; the buffer is marked "busy"
- * so that no one else can touch it.  If the block was
- * already in core, no I/O need be done; if it is
- * already busy, the process waits until it becomes free.
- * The following routines allocate a buffer:
- *     getblk
- *     bread
- *     breada
- * Eventually the buffer must be released, possibly with the
- * side effect of writing it out, by using one of
- *     bwrite
- *     bdwrite
- *     bawrite
- *     brelse
- */
-
-/*
- * Read in (if necessary) the block and return a buffer pointer.
- */
-struct buf *
-bread(dev, blkno)
-dev_t dev;
-daddr_t blkno;
-{
-       register struct buf *bp;
-
-       bp = getblk(dev, blkno);
-       if (bp->b_flags&B_DONE) {
-#ifdef DISKMON
-               io_info.ncache++;
-#endif
-               return(bp);
-       }
-       bp->b_flags |= B_READ;
-       bp->b_bcount = BSIZE;
-       (*bdevsw[major(dev)].d_strategy)(bp);
-#ifdef DISKMON
-       io_info.nread++;
-#endif
-       iowait(bp);
-       return(bp);
-}
-
-/*
- * Read in the block, like bread, but also start I/O on the
- * read-ahead block (which is not allocated to the caller)
- */
-struct buf *
-breada(dev, blkno, rablkno)
-dev_t dev;
-daddr_t blkno, rablkno;
-{
-       register struct buf *bp, *rabp;
-
-       bp = NULL;
-       if (!incore(dev, blkno)) {
-               bp = getblk(dev, blkno);
-               if ((bp->b_flags&B_DONE) == 0) {
-                       bp->b_flags |= B_READ;
-                       bp->b_bcount = BSIZE;
-                       (*bdevsw[major(dev)].d_strategy)(bp);
-#ifdef DISKMON
-                       io_info.nread++;
-#endif
-               }
-       }
-       if (rablkno && !incore(dev, rablkno)) {
-               rabp = getblk(dev, rablkno);
-               if (rabp->b_flags & B_DONE)
-                       brelse(rabp);
-               else {
-                       rabp->b_flags |= B_READ|B_ASYNC;
-                       rabp->b_bcount = BSIZE;
-                       (*bdevsw[major(dev)].d_strategy)(rabp);
-#ifdef DISKMON
-                       io_info.nreada++;
-#endif
-               }
-       }
-       if(bp == NULL)
-               return(bread(dev, blkno));
-       iowait(bp);
-       return(bp);
-}
-
-/*
- * Write the buffer, waiting for completion.
- * Then release the buffer.
- */
-bwrite(bp)
-register struct buf *bp;
-{
-       register flag;
-
-       flag = bp->b_flags;
-       bp->b_flags &= ~(B_READ | B_DONE | B_ERROR | B_DELWRI | B_AGE);
-       bp->b_bcount = BSIZE;
-#ifdef DISKMON
-       io_info.nwrite++;
-#endif
-       (*bdevsw[major(bp->b_dev)].d_strategy)(bp);
-       if ((flag&B_ASYNC) == 0) {
-               iowait(bp);
-               brelse(bp);
-       } else if (flag & B_DELWRI)
-               bp->b_flags |= B_AGE;
-       else
-               geterror(bp);
-}
-
-/*
- * Release the buffer, marking it so that if it is grabbed
- * for another purpose it will be written out before being
- * given up (e.g. when writing a partial block where it is
- * assumed that another write for the same block will soon follow).
- * This can't be done for magtape, since writes must be done
- * in the same order as requested.
- */
-bdwrite(bp)
-register struct buf *bp;
-{
-       register struct buf *dp;
-
-       dp = bdevsw[major(bp->b_dev)].d_tab;
-       if(dp->b_flags & B_TAPE)
-               bawrite(bp);
-       else {
-               bp->b_flags |= B_DELWRI | B_DONE;
-               brelse(bp);
-       }
-}
-
-/*
- * Release the buffer, start I/O on it, but don't wait for completion.
- */
-bawrite(bp)
-register struct buf *bp;
-{
-
-       bp->b_flags |= B_ASYNC;
-       bwrite(bp);
-}
-
-/*
- * release the buffer, with no I/O implied.
- */
-brelse(bp)
-register struct buf *bp;
-{
-       register struct buf **backp;
-       register s;
-
-       if (bp->b_flags&B_WANTED)
-               wakeup((caddr_t)bp);
-       if (bfreelist.b_flags&B_WANTED) {
-               bfreelist.b_flags &= ~B_WANTED;
-               wakeup((caddr_t)&bfreelist);
-       }
-       if (bp->b_flags&B_ERROR)
-               bp->b_dev = NODEV;  /* no assoc. on error */
-       s = spl6();
-       if(bp->b_flags & B_AGE) {
-               backp = &bfreelist.av_forw;
-               (*backp)->av_back = bp;
-               bp->av_forw = *backp;
-               *backp = bp;
-               bp->av_back = &bfreelist;
-       } else {
-               backp = &bfreelist.av_back;
-               (*backp)->av_forw = bp;
-               bp->av_back = *backp;
-               *backp = bp;
-               bp->av_forw = &bfreelist;
-       }
-       bp->b_flags &= ~(B_WANTED|B_BUSY|B_ASYNC|B_AGE);
-       splx(s);
-}
-
-/*
- * See if the block is associated with some buffer
- * (mainly to avoid getting hung up on a wait in breada)
- */
-incore(dev, blkno)
-dev_t dev;
-daddr_t blkno;
-{
-       register struct buf *bp;
-       register struct buf *dp;
-
-       dp = bdevsw[major(dev)].d_tab;
-       for (bp=dp->b_forw; bp != dp; bp = bp->b_forw)
-               if (bp->b_blkno==blkno && bp->b_dev==dev)
-                       return(1);
-       return(0);
-}
-
-/*
- * Assign a buffer for the given block.  If the appropriate
- * block is already associated, return it; otherwise search
- * for the oldest non-busy buffer and reassign it.
- */
-struct buf *
-getblk(dev, blkno)
-dev_t dev;
-daddr_t blkno;
-{
-       register struct buf *bp;
-       register struct buf *dp;
-#ifdef DISKMON
-       register i;
-#endif
-
-       if(major(dev) >= nblkdev)
-               panic("blkdev");
-
-    loop:
-       spl0();
-       dp = bdevsw[major(dev)].d_tab;
-       if(dp == NULL)
-               panic("devtab");
-       for (bp=dp->b_forw; bp != dp; bp = bp->b_forw) {
-               if (bp->b_blkno!=blkno || bp->b_dev!=dev)
-                       continue;
-               spl6();
-               if (bp->b_flags&B_BUSY) {
-                       bp->b_flags |= B_WANTED;
-                       sleep((caddr_t)bp, PRIBIO+1);
-                       goto loop;
-               }
-               spl0();
-#ifdef DISKMON
-               i = 0;
-               dp = bp->av_forw;
-               while (dp != &bfreelist) {
-                       i++;
-                       dp = dp->av_forw;
-               }
-               if (i<NBUF)
-                       io_info.bufcount[i]++;
-#endif
-               notavail(bp);
-               return(bp);
-       }
-       spl6();
-       if (bfreelist.av_forw == &bfreelist) {
-               bfreelist.b_flags |= B_WANTED;
-               sleep((caddr_t)&bfreelist, PRIBIO+1);
-               goto loop;
-       }
-       spl0();
-       notavail(bp = bfreelist.av_forw);
-       if (bp->b_flags & B_DELWRI) {
-               bp->b_flags |= B_ASYNC;
-               bwrite(bp);
-               goto loop;
-       }
-       bp->b_flags = B_BUSY;
-       bp->b_back->b_forw = bp->b_forw;
-       bp->b_forw->b_back = bp->b_back;
-       bp->b_forw = dp->b_forw;
-       bp->b_back = dp;
-       dp->b_forw->b_back = bp;
-       dp->b_forw = bp;
-       bp->b_dev = dev;
-       bp->b_blkno = blkno;
-       return(bp);
-}
-
-/*
- * get an empty block,
- * not assigned to any particular device
- */
-struct buf *
-geteblk()
-{
-       register struct buf *bp;
-       register struct buf *dp;
-
-loop:
-       spl6();
-       while (bfreelist.av_forw == &bfreelist) {
-               bfreelist.b_flags |= B_WANTED;
-               sleep((caddr_t)&bfreelist, PRIBIO+1);
-       }
-       spl0();
-       dp = &bfreelist;
-       notavail(bp = bfreelist.av_forw);
-       if (bp->b_flags & B_DELWRI) {
-               bp->b_flags |= B_ASYNC;
-               bwrite(bp);
-               goto loop;
-       }
-       bp->b_flags = B_BUSY;
-       bp->b_back->b_forw = bp->b_forw;
-       bp->b_forw->b_back = bp->b_back;
-       bp->b_forw = dp->b_forw;
-       bp->b_back = dp;
-       dp->b_forw->b_back = bp;
-       dp->b_forw = bp;
-       bp->b_dev = (dev_t)NODEV;
-       return(bp);
-}
-
-/*
- * Wait for I/O completion on the buffer; return errors
- * to the user.
- */
-iowait(bp)
-register struct buf *bp;
-{
-
-       spl6();
-       while ((bp->b_flags&B_DONE)==0)
-               sleep((caddr_t)bp, PRIBIO);
-       spl0();
-       geterror(bp);
-}
-
-/*
- * Unlink a buffer from the available list and mark it busy.
- * (internal interface)
- */
-notavail(bp)
-register struct buf *bp;
-{
-       register s;
-
-       s = spl6();
-       bp->av_back->av_forw = bp->av_forw;
-       bp->av_forw->av_back = bp->av_back;
-       bp->b_flags |= B_BUSY;
-       splx(s);
-}
-
-/*
- * Mark I/O complete on a buffer, release it if I/O is asynchronous,
- * and wake up anyone waiting for it.
- */
-iodone(bp)
-register struct buf *bp;
-{
-
-       if(bp->b_flags&B_MAP)
-               mapfree(bp);
-       bp->b_flags |= B_DONE;
-       if (bp->b_flags&B_ASYNC)
-               brelse(bp);
-       else {
-               bp->b_flags &= ~B_WANTED;
-               wakeup((caddr_t)bp);
-       }
-}
-
-/*
- * Zero the core associated with a buffer.
- */
-clrbuf(bp)
-struct buf *bp;
-{
-       register *p;
-       register c;
-
-       p = bp->b_un.b_words;
-       c = BSIZE/sizeof(int);
-       do
-               *p++ = 0;
-       while (--c);
-       bp->b_resid = 0;
-}
-
-/*
- * swap I/O
- */
-swap(blkno, coreaddr, count, rdflg)
-register count;
-{
-       register struct buf *bp;
-       register tcount;
-
-       bp = &swbuf1;
-       if(bp->b_flags & B_BUSY)
-               if((swbuf2.b_flags&B_WANTED) == 0)
-                       bp = &swbuf2;
-       spl6();
-       while (bp->b_flags&B_BUSY) {
-               bp->b_flags |= B_WANTED;
-               sleep((caddr_t)bp, PSWP+1);
-       }
-       while (count) {
-               bp->b_flags = B_BUSY | B_PHYS | rdflg;
-               bp->b_dev = swapdev;
-               tcount = count;
-               if (tcount >= 01700)    /* prevent byte-count wrap */
-                       tcount = 01700;
-               bp->b_bcount = ctob(tcount);
-               bp->b_blkno = swplo+blkno;
-               bp->b_un.b_addr = (caddr_t)(coreaddr<<6);
-               bp->b_xmem = (coreaddr>>10) & 077;
-               (*bdevsw[major(swapdev)].d_strategy)(bp);
-               spl6();
-               while((bp->b_flags&B_DONE)==0)
-                       sleep((caddr_t)bp, PSWP);
-               count -= tcount;
-               coreaddr += tcount;
-               blkno += ctod(tcount);
-       }
-       if (bp->b_flags&B_WANTED)
-               wakeup((caddr_t)bp);
-       spl0();
-       bp->b_flags &= ~(B_BUSY|B_WANTED);
-       if (bp->b_flags & B_ERROR)
-               panic("IO err in swap");
-}
-
-/*
- * make sure all write-behind blocks
- * on dev (or NODEV for all)
- * are flushed out.
- * (from umount and update)
- */
-bflush(dev)
-dev_t dev;
-{
-       register struct buf *bp;
-
-loop:
-       spl6();
-       for (bp = bfreelist.av_forw; bp != &bfreelist; bp = bp->av_forw) {
-               if (bp->b_flags&B_DELWRI && (dev == NODEV||dev==bp->b_dev)) {
-                       bp->b_flags |= B_ASYNC;
-                       notavail(bp);
-                       bwrite(bp);
-                       goto loop;
-               }
-       }
-       spl0();
-}
-
-/*
- * Raw I/O. The arguments are
- *     The strategy routine for the device
- *     A buffer, which will always be a special buffer
- *       header owned exclusively by the device for this purpose
- *     The device number
- *     Read/write flag
- * Essentially all the work is computing physical addresses and
- * validating them.
- */
-physio(strat, bp, dev, rw)
-register struct buf *bp;
-int (*strat)();
-{
-       register unsigned base;
-       register int nb;
-       int ts;
-
-       base = (unsigned)u.u_base;
-       /*
-        * Check odd base, odd count, and address wraparound
-        */
-       if (base&01 || u.u_count&01 || base>=base+u.u_count)
-               goto bad;
-       ts = (u.u_tsize+127) & ~0177;
-       if (u.u_sep)
-               ts = 0;
-       nb = (base>>6) & 01777;
-       /*
-        * Check overlap with text. (ts and nb now
-        * in 64-byte clicks)
-        */
-       if (nb < ts)
-               goto bad;
-       /*
-        * Check that transfer is either entirely in the
-        * data or in the stack: that is, either
-        * the end is in the data or the start is in the stack
-        * (remember wraparound was already checked).
-        */
-       if ((((base+u.u_count)>>6)&01777) >= ts+u.u_dsize
-           && nb < 1024-u.u_ssize)
-               goto bad;
-       spl6();
-       while (bp->b_flags&B_BUSY) {
-               bp->b_flags |= B_WANTED;
-               sleep((caddr_t)bp, PRIBIO+1);
-       }
-       bp->b_flags = B_BUSY | B_PHYS | rw;
-       bp->b_dev = dev;
-       /*
-        * Compute physical address by simulating
-        * the segmentation hardware.
-        */
-       ts = (u.u_sep? UDSA: UISA)->r[nb>>7] + (nb&0177);
-       bp->b_un.b_addr = (caddr_t)((ts<<6) + (base&077));
-       bp->b_xmem = (ts>>10) & 077;
-       bp->b_blkno = u.u_offset >> BSHIFT;
-       bp->b_bcount = u.u_count;
-       bp->b_error = 0;
-       u.u_procp->p_flag |= SLOCK;
-       (*strat)(bp);
-       spl6();
-       while ((bp->b_flags&B_DONE) == 0)
-               sleep((caddr_t)bp, PRIBIO);
-       u.u_procp->p_flag &= ~SLOCK;
-       if (bp->b_flags&B_WANTED)
-               wakeup((caddr_t)bp);
-       spl0();
-       bp->b_flags &= ~(B_BUSY|B_WANTED);
-       u.u_count = bp->b_resid;
-       geterror(bp);
-       return;
-    bad:
-       u.u_error = EFAULT;
-}
-
-/*
- * Pick up the device's error number and pass it to the user;
- * if there is an error but the number is 0 set a generalized
- * code.  Actually the latter is always true because devices
- * don't yet return specific errors.
- */
-geterror(bp)
-register struct buf *bp;
-{
-
-       if (bp->b_flags&B_ERROR)
-               if ((u.u_error = bp->b_error)==0)
-                       u.u_error = EIO;
-}
diff --git a/usr/sys/dev/cat.c b/usr/sys/dev/cat.c
deleted file mode 100644 (file)
index 46bd3c1..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-#
-/*
- */
-
-/*
- * GP DR11C driver used for C/A/T
- */
-
-#include "../h/param.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/tty.h"
-
-#define        CATADDR ((struct catdev *)0167770)
-#define        PCAT    (PZERO+9)
-#define        CATHIWAT        100
-#define        CATLOWAT        30
-
-struct {
-       int     catlock;
-       struct  clist   oq;
-} cat;
-
-struct catdev {
-       int     catcsr;
-       int     catbuf;
-};
-
-ctopen(dev)
-{
-       if (cat.catlock==0) {
-               cat.catlock++;
-               CATADDR->catcsr |= IENABLE;
-       } else
-               u.u_error = ENXIO;
-}
-
-ctclose()
-{
-       cat.catlock = 0;
-       catintr();
-}
-
-ctwrite(dev)
-{
-       register c;
-       extern lbolt;
-
-       while ((c=cpass()) >= 0) {
-               spl5();
-               while (cat.oq.c_cc > CATHIWAT)
-                       sleep((caddr_t)&cat.oq, PCAT);
-               while (putc(c, &cat.oq) < 0)
-                       sleep((caddr_t)&lbolt, PCAT);
-               catintr();
-               spl0();
-       }
-}
-
-catintr()
-{
-       register int c;
-
-       if (CATADDR->catcsr&DONE) {
-               if ((c = getc(&cat.oq)) >= 0) {
-                       CATADDR->catbuf = c;
-                       if (cat.oq.c_cc==0 || cat.oq.c_cc==CATLOWAT)
-                               wakeup((caddr_t)&cat.oq);
-               } else {
-                       if (cat.catlock==0)
-                               CATADDR->catcsr = 0;
-               }
-       }
-}
diff --git a/usr/sys/dev/dc.c b/usr/sys/dev/dc.c
deleted file mode 100644 (file)
index cc43b4a..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-#include "../h/param.h"
-#include "../h/conf.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/tty.h"
-#include "../h/systm.h"
-
-/*
- * Base address of DC-11's. Minor device  i  is at
- * DCADDR + 10*i.
- */
-#define        DCADDR  (struct device *)0174000
-
-/*
- * Number of DC's for which table space is allocated.
- */
-#define        NDC11   4
-
-/*
- * Control bits in device registers
- */
-#define        CDLEAD  01
-#define        CARRIER 04
-#define        SPEED1  010
-#define        STOP1   0400
-#define        RQSEND  01
-#define        PARITY  040
-#define        ERROR   0100000
-#define        CTRANS  040000
-#define        RINGIND 020000
-
-
-struct tty dc11[NDC11];
-
-struct device {
-       int dcrcsr;
-       int dcrbuf;
-       int dctcsr;
-       int dctbuf;
-};
-
-/*
- * Input-side speed and control bit table.
- * Each DC11 has 4 speeds which correspond to the 4 non-zero entries.
- * The table index is the same as the speed-selector
- * number for the DH11.
- * Attempts to set the speed to a zero entry are ignored.
- */
-int dcrstab[] = {
-       0,              /* 0 baud */
-       0,              /* 50 baud */
-       0,              /* 75 baud */
-       0,              /* 110 baud */
-       01101,          /* 134.5 baud: 7b/ch, speed 0 */
-       0111,           /* 150 baud: 8b/ch, speed 1 */
-       0,              /* 200 baud */
-       0121,           /* 300 baud: 8b/ch, speed 2 */
-       0,              /* 600 baud */
-       0131,           /* 1200 baud */
-       0,              /* 1800 baud */
-       0,              /* 2400 baud */
-       0,              /* 4800 baud */
-       0,              /* 9600 baud */
-       0,              /* X0 */
-       0,              /* X1 */
-};
-
-/*
- * Transmitter speed table
- */
-int dctstab[] = {
-       0,              /* 0 baud */
-       0,              /* 50 baud */
-       0,              /* 75 baud */
-       0,              /* 110 baud */
-       0501,           /* 134.5 baud: stop 1 */
-       0511,           /* 150 baud */
-       0,              /* 200 baud */
-       0521,           /* 300 baud */
-       0,              /* 600 baud */
-       0531,           /* 1200 baud */
-       0,              /* 1800 baud */
-       0,              /* 2400 baud */
-       0,              /* 4800 baud */
-       0,              /* 9600 baud */
-       0,              /* X0 */
-       0,              /* X1 */
-};
-
-/*
- * Open a DC11, waiting until carrier is established.
- * Default initial conditions are set up on the first open.
- * t_state's CARR_ON bit is a pure copy of the hardware
- * CARRIER bit, and is only used to regularize
- * carrier tests in general tty routines.
- */
-dcopen(dev, flag)
-dev_t dev;
-{
-       register struct tty *tp;
-       register struct device *addr;
-       extern int klstart();
-       int s;
-
-       if (minor(dev) >= NDC11) {
-               u.u_error = ENXIO;
-               return;
-       }
-       tp = &dc11[minor(dev)];
-       addr = DCADDR + minor(dev);
-       tp->t_addr = (caddr_t)addr;
-       tp->t_state |= WOPEN;
-       s = spl5();
-       addr->dcrcsr |= IENABLE|CDLEAD;
-       if ((tp->t_state&ISOPEN) == 0) {
-               tp->t_erase = CERASE;
-               tp->t_kill = CKILL;
-               addr->dcrcsr = IENABLE|CDLEAD|SPEED1;
-               addr->dctcsr = IENABLE|SPEED1|STOP1|RQSEND;
-               tp->t_state = ISOPEN | WOPEN;
-               tp->t_flags = ODDP|EVENP|ECHO;
-               tp->t_oproc = klstart;
-       }
-       if (addr->dcrcsr & CARRIER)
-               tp->t_state |= CARR_ON;
-       splx(s);
-       while ((tp->t_state & CARR_ON) == 0)
-               sleep((caddr_t)&tp->t_rawq, TTIPRI);
-       ttyopen(dev, tp);
-}
-
-/*
- * Close a dc11
- */
-dcclose(dev)
-dev_t dev;
-{
-       register struct tty *tp;
-
-       tp = &dc11[minor(dev)];
-       if (tp->t_state&HUPCLS)
-               ((struct device *)(tp->t_addr))->dcrcsr &= ~CDLEAD;
-       ttyclose(tp);
-}
-
-/*
- * Read a DC11
- */
-dcread(dev)
-dev_t dev;
-{
-       ttread(&dc11[minor(dev)]);
-}
-
-/*
- * Write a DC11
- */
-dcwrite(dev)
-dev_t dev;
-{
-       ttwrite(&dc11[minor(dev)]);
-}
-
-/*
- * DC11 transmitter interrupt.
- */
-dcxint(dev)
-dev_t dev;
-{
-       register struct tty *tp;
-
-       tp = &dc11[minor(dev)];
-       ttstart(tp);
-       if (tp->t_outq.c_cc == 0 || tp->t_outq.c_cc == TTLOWAT)
-               wakeup((caddr_t)&tp->t_outq);
-}
-
-/*
- * DC11 receiver interrupt.
- */
-dcrint(dev)
-dev_t dev;
-{
-       register struct tty *tp;
-       register int c, csr;
-
-       tp = &dc11[minor(dev)];
-       c = ((struct device *)(tp->t_addr))->dcrbuf;
-       /*
-        * If carrier is off, and an open is not in progress,
-        * knock down the CD lead to hang up the local dataset
-        * and signal a hangup.
-        */
-       if (((csr = ((struct device *)(tp->t_addr))->dcrcsr) & CARRIER) == 0) {
-               if ((tp->t_state&WOPEN) == 0) {
-                       ((struct device *)(tp->t_addr))->dcrcsr &= ~CDLEAD;
-                       if (tp->t_state & CARR_ON)
-                               signal(tp->t_pgrp, SIGHUP);
-                       flushtty(tp);
-               }
-               tp->t_state &= ~CARR_ON;
-               return;
-       }
-       if (csr&ERROR || (tp->t_state&ISOPEN)==0) {
-               if (tp->t_state&WOPEN && csr&CARRIER)
-                       tp->t_state |= CARR_ON;
-               wakeup((caddr_t)tp);
-               return;
-       }
-       csr &= PARITY;
-       if (csr&&(tp->t_flags&ODDP) || !csr&&(tp->t_flags&EVENP))
-               ttyinput(c, tp);
-}
-
-/*
- * DC11 stty/gtty.
- * Perform general functions and set speeds.
- */
-dcioctl(dev, cmd, addr, flag)
-dev_t dev;
-caddr_t addr;
-{
-       register struct tty *tp;
-       register r;
-
-       tp = &dc11[minor(dev)];
-       if (ttioccom(cmd, &dc11[minor(dev)], addr, dev) == 0) {
-               u.u_error = ENOTTY;
-               return;
-       }
-       if (cmd == TIOCSETP) {
-               r = dcrstab[tp->t_ispeed];
-               if (r)
-                       ((struct device *)(tp->t_addr))->dcrcsr = r;
-               else
-                       ((struct device *)(tp->t_addr))->dcrcsr &= ~CDLEAD;
-               r = dctstab[tp->t_ospeed];
-               ((struct device *)(tp->t_addr))->dctcsr = r;
-       }
-}
diff --git a/usr/sys/dev/dh.c b/usr/sys/dev/dh.c
deleted file mode 100644 (file)
index 4988dc7..0000000
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- *     DH-11 driver
- *     This driver calls on the DHDM driver.
- *     If the DH has no DM11-BB, then the latter will
- *     be fake. To insure loading of the correct DM code,
- *     lib2 should have dhdm.o, dh.o and dhfdm.o in that order.
- */
-
-#include "../h/param.h"
-#include "../h/conf.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/tty.h"
-
-#define        q3      tp->t_outq
-#define        DHADDR  ((struct device *)0160020)
-#define        NDH11   16      /* number of lines */
-
-struct tty dh11[NDH11];
-char   dhcc[NDH11];
-int    dhchars[(NDH11+15)/16];
-int    ndh11   = NDH11;
-int    dhstart();
-int    ttrstrt();
-
-/*
- * Hardware control bits
- */
-#define        BITS6   01
-#define        BITS7   02
-#define        BITS8   03
-#define        TWOSB   04
-#define        PENABLE 020
-/* DEC manuals incorrectly say this bit causes generation of even parity. */
-#define        OPAR    040
-#define        HDUPLX  040000
-
-#define        IENAB   030100
-#define        PERROR  010000
-#define        FRERROR 020000
-#define        OVERRUN 040000
-#define        XINT    0100000
-#define        SSPEED  7       /* standard speed: 300 baud */
-#define        NSILO   16
-#define        DHTIME  6
-extern int dhtimer();
-
-/*
- * DM control bits
- */
-#define        TURNON  03      /* CD lead + line enable */
-#define        TURNOFF 01      /* line enable */
-#define        RQS     04      /* request to send */
-
-/*
- * Software copy of last dhbar
- */
-int    dhsar[(NDH11+15)/16];
-
-struct device
-{
-       union {
-               int     dhcsr;
-               char    dhcsrl;
-       } un;
-       int     dhnxch;
-       int     dhlpr;
-       char    *dhcar;
-       int     dhbcr;
-       int     dhbar;
-       int     dhbreak;
-       int     dhsilo;
-};
-
-/*
- * Open a DH11 line.
- */
-dhopen(dev, flag)
-{
-       register struct tty *tp;
-       register d;
-       register struct device *addr;
-       static  timer_on;
-       int s;
-
-       d = minor(dev);
-       if (d >= NDH11) {
-               u.u_error = ENXIO;
-               return;
-       }
-       tp = &dh11[d];
-       addr = DHADDR;
-       addr += d>>4;
-       tp->t_addr = (caddr_t)addr;
-       tp->t_oproc = dhstart;
-       tp->t_iproc = NULL;
-       tp->t_state |= WOPEN;
-       s = spl6();
-       if (!timer_on) {
-               timer_on++;
-               timeout(dhtimer, (caddr_t)0, DHTIME);
-       }
-       splx(s);
-       addr->un.dhcsr |= IENAB;
-       if ((tp->t_state&ISOPEN) == 0) {
-               ttychars(tp);
-               tp->t_ispeed = SSPEED;
-               tp->t_ospeed = SSPEED;
-               tp->t_flags = ODDP|EVENP|ECHO;
-               dhparam(d);
-       }
-       if (tp->t_state&XCLUDE && u.u_uid!=0) {
-               u.u_error = EBUSY;
-               return;
-       }
-       dmopen(d);
-       (*linesw[tp->t_line].l_open)(dev,tp);
-}
-
-/*
- * Close a DH11 line.
- */
-dhclose(dev, flag)
-dev_t dev;
-int  flag;
-{
-       register struct tty *tp;
-       register d;
-
-       d = minor(dev);
-       tp = &dh11[d];
-       (*linesw[tp->t_line].l_close)(tp);
-       if (tp->t_state&HUPCLS)
-               dmctl(d, TURNOFF);
-       ttyclose(tp);
-}
-
-/*
- * Read from a DH11 line.
- */
-dhread(dev)
-{
-register struct tty *tp;
-
-       tp = &dh11[minor(dev)];
-       (*linesw[tp->t_line].l_read)(tp);
-}
-
-/*
- * write on a DH11 line
- */
-dhwrite(dev)
-{
-register struct tty *tp;
-
-       tp = &dh11[minor(dev)];
-       (*linesw[tp->t_line].l_write)(tp);
-}
-
-/*
- * DH11 receiver interrupt.
- */
-dhrint(dev)
-{
-       register struct tty *tp;
-       register int c;
-       register struct device *addr;
-
-       addr = DHADDR;
-       addr += minor(dev);
-       while ((c = addr->dhnxch) < 0) {        /* char. present */
-               tp = &dh11[(minor(dev)<<4) + ((c>>8)&017)];
-               dhchars[minor(dev)]++;
-               if (tp >= &dh11[NDH11])
-                       continue;
-               if((tp->t_state&ISOPEN)==0) {
-                       wakeup((caddr_t)tp);
-                       continue;
-               }
-               if (c&PERROR)
-                       if ((tp->t_flags&(EVENP|ODDP))==EVENP
-                        || (tp->t_flags&(EVENP|ODDP))==ODDP )
-                               continue;
-               if (c&FRERROR)          /* break */
-                       if (tp->t_flags&RAW)
-                               c = 0;  /* null (for getty) */
-                       else
-                               c = 0177;       /* DEL (intr) */
-               (*linesw[tp->t_line].l_rint)(c,tp);
-       }
-}
-
-/*
- * stty/gtty for DH11
- */
-dhioctl(dev, cmd, addr, flag)
-caddr_t addr;
-{
-       register struct tty *tp;
-
-       tp = &dh11[minor(dev)];
-       if (ttioccomm(cmd, tp, addr, dev)) {
-               if (cmd==TIOCSETP||cmd==TIOCSETN)
-                       dhparam(dev);
-       } else
-               u.u_error = ENOTTY;
-}
-
-/*
- * Set parameters from open or stty into the DH hardware
- * registers.
- */
-dhparam(dev)
-{
-       register struct tty *tp;
-       register struct device *addr;
-       register d;
-
-       d = minor(dev);
-       tp = &dh11[d];
-       addr = (struct device *)tp->t_addr;
-       spl5();
-       addr->un.dhcsrl = (d&017) | IENAB;
-       /*
-        * Hang up line?
-        */
-       if ((tp->t_ispeed)==0) {
-               tp->t_state |= HUPCLS;
-               dmctl(d, TURNOFF);
-               return;
-       }
-       d = ((tp->t_ospeed)<<10) | ((tp->t_ispeed)<<6);
-       if ((tp->t_ispeed) == 4)                /* 134.5 baud */
-               d |= BITS6|PENABLE|HDUPLX;
-       else if (tp->t_flags&RAW)
-               d |= BITS8;
-       else
-               d |= BITS7|PENABLE;
-       if ((tp->t_flags&EVENP) == 0)
-               d |= OPAR;
-       if ((tp->t_ospeed) == 3)        /* 110 baud */
-               d |= TWOSB;
-       addr->dhlpr = d;
-       spl0();
-}
-
-/*
- * DH11 transmitter interrupt.
- * Restart each line which used to be active but has
- * terminated transmission since the last interrupt.
- */
-dhxint(dev)
-{
-       register struct tty *tp;
-       register struct device *addr;
-       register d;
-       int ttybit, bar, *sbar;
-
-       d = minor(dev);
-       addr = DHADDR + d;
-       addr->un.dhcsr &= ~XINT;
-       sbar = &dhsar[d];
-       bar = *sbar & ~addr->dhbar;
-       d <<= 4; ttybit = 1;
-
-       for(; bar; d++, ttybit <<= 1) {
-               if(bar&ttybit) {
-                       *sbar &= ~ttybit;
-                       bar &= ~ttybit;
-                       tp = &dh11[d];
-                       if (tp->t_line) {
-                               (*linesw[tp->t_line].l_start)(tp);
-                       } else {
-                               addr->un.dhcsrl = (d&017)|IENAB;
-                               if (tp->t_state&FLUSH)
-                                       tp->t_state &= ~FLUSH;
-                               else {
-                                       ndflush(&q3, addr->dhcar-q3.c_cf);
-                               }
-                               tp->t_state &= ~BUSY;
-                               dhstart(tp);
-                       }
-               }
-       }
-}
-
-/*
- * Start (restart) transmission on the given DH11 line.
- */
-dhstart(tp)
-register struct tty *tp;
-{
-       register struct device *addr;
-       register nch;
-       int s, d;
-
-       /*
-        * If it's currently active, or delaying,
-        * no need to do anything.
-        */
-       s = spl5();
-       d = tp-dh11;
-       addr = (struct device *)tp->t_addr;
-       if (tp->t_state&(TIMEOUT|BUSY|TTSTOP))
-               goto out;
-
-
-       /*
-        * If the writer was sleeping on output overflow,
-        * wake him when low tide is reached.
-        */
-       if (tp->t_state&ASLEEP && tp->t_outq.c_cc<=TTLOWAT) {
-               tp->t_state &= ~ASLEEP;
-               if (tp->t_chan)
-                       mcstart(tp->t_chan, (caddr_t)&tp->t_outq); else
-                       wakeup((caddr_t)&tp->t_outq);
-       }
-
-       if (tp->t_outq.c_cc == 0)
-               goto out;
-
-
-
-       /*
-        * Find number of characters to transfer.
-        */
-       if (tp->t_flags & RAW) {
-               nch = ndqb(&tp->t_outq, 0);
-       } else {
-               nch = ndqb(&tp->t_outq, 0200);
-               if (nch == 0) {
-                       nch = getc(&tp->t_outq);
-                       timeout(ttrstrt, (caddr_t)tp, (nch&0177)+6);
-                       tp->t_state |= TIMEOUT;
-                       goto out;
-               }
-       }
-       /*
-        * If any characters were set up, start transmission;
-        */
-       if (nch) {
-               addr->un.dhcsrl = (d&017)|IENAB;
-               addr->dhcar = tp->t_outq.c_cf;
-               addr->dhbcr = -nch;
-               dhcc[d] = nch;
-               nch = 1<<(d&017);
-               addr->dhbar |= nch;
-               dhsar[d>>4] |= nch;
-               tp->t_state |= BUSY;
-       }
-    out:
-       splx(s);
-}
-
-
-/*
- * Stop output on a line.
- */
-dhstop(tp, flag)
-register struct tty *tp;
-{
-       register struct device *addr;
-       register d, s;
-
-       addr = (struct device *)tp->t_addr;
-       s = spl6();
-       if (tp->t_state & BUSY) {
-               d = minor(tp->t_dev);
-               addr->un.dhcsrl = (d&017) | IENAB;
-               if ((tp->t_state&TTSTOP)==0) {
-                       tp->t_state |= FLUSH;
-               }
-               addr->dhbcr = -1;
-       }
-       splx(s);
-}
-
-dhtimer(dev)
-{
-register d,cc;
-register struct device *addr;
-
-       addr = DHADDR; d = 0;
-       do {
-               cc = dhchars[d];
-               dhchars[d] = 0;
-               if (cc > 50)
-                       cc = 32; else
-                       if (cc > 16)
-                               cc = 16; else
-                               cc = 0;
-               addr->dhsilo = cc;
-               addr += 1;
-               dhrint(d++);
-       } while (d < (NDH11+15)/16);
-       timeout(dhtimer, (caddr_t)0, DHTIME);
-}
-
diff --git a/usr/sys/dev/dhdm.c b/usr/sys/dev/dhdm.c
deleted file mode 100644 (file)
index 42c84a5..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- *     DM-BB driver
- */
-#include "../h/param.h"
-#include "../h/tty.h"
-#include "../h/conf.h"
-
-#define        DMADDR  ((struct device *)0170500)
-
-struct tty dh11[];
-int    ndh11;          /* Set by dh.c to number of lines */
-
-#define        DONE    0200
-#define        SCENABL 040
-#define        CLSCAN  01000
-#define        TURNON  03      /* CD lead, line enable */
-#define        SECX    010     /* secondary xmit */
-#define        RQS     04      /* request to send */
-#define        TURNOFF 1       /* line enable only */
-#define        CARRIER 0100
-#define        CLS     040     /* clear to send */
-#define        SECR    020     /* secondary receive */
-
-struct device
-{
-       int     dmcsr;
-       int     dmlstat;
-       int     junk[2];
-};
-
-#define        B1200   9
-#define        B300    7
-
-/*
- * Turn on the line associated with the (DH) device dev.
- */
-dmopen(dev)
-{
-       register struct tty *tp;
-       register struct device *addr;
-       register d;
-
-       d = minor(dev);
-       tp = &dh11[d];
-       addr = DMADDR;
-       addr += d>>4;
-       spl5();
-       addr->dmcsr = d&017;
-       addr->dmlstat = TURNON;
-       if (addr->dmlstat&CARRIER) {
-               tp->t_state |= CARR_ON;
-       }
-       addr->dmcsr = IENABLE|SCENABL;
-       while ((tp->t_state&CARR_ON)==0)
-               sleep((caddr_t)&tp->t_rawq, TTIPRI);
-       addr->dmcsr = d&017;
-       if (addr->dmlstat&SECR) {
-               tp->t_ispeed = B1200;
-               tp->t_ospeed = B1200;
-               dhparam(dev);
-       }
-       addr->dmcsr = IENABLE|SCENABL;
-       spl0();
-}
-
-/*
- * Dump control bits into the DM registers.
- */
-dmctl(dev, bits)
-{
-       register struct device *addr;
-       register d, s;
-
-       d = minor(dev);
-       addr = DMADDR;
-       addr += d>>4;
-       s = spl5();
-       addr->dmcsr = d&017;
-       addr->dmlstat = bits;
-       addr->dmcsr = IENABLE|SCENABL;
-       splx(s);
-}
-
-/*
- * DM11 interrupt.
- * Mainly, deal with carrier transitions.
- */
-dmint(dev)
-{
-       register struct tty *tp;
-       register struct device *addr;
-       register d;
-
-       d = minor(dev);
-       addr = DMADDR;
-       addr += d;
-       if (addr->dmcsr&DONE) {
-               tp = &dh11[(d<<4)+(addr->dmcsr&017)];
-               if (tp < &dh11[ndh11]) {
-                       wakeup((caddr_t)&tp->t_rawq);
-                       if ((addr->dmlstat&CARRIER)==0) {
-                               if ((tp->t_state&WOPEN)==0) {
-                                       signal(tp->t_pgrp, SIGHUP);
-                                       addr->dmlstat = 0;
-                                       flushtty(tp);
-                               }
-                               tp->t_state &= ~CARR_ON;
-                       } else {
-                               tp->t_state |= CARR_ON;
-                       }
-               }
-               addr->dmcsr = IENABLE|SCENABL;
-       }
-}
diff --git a/usr/sys/dev/dhfdm.c b/usr/sys/dev/dhfdm.c
deleted file mode 100644 (file)
index f7fe33b..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- *     DM-BB fake driver
- */
-#include "../h/param.h"
-#include "../h/tty.h"
-#include "../h/conf.h"
-
-struct tty     dh11[];
-
-dmopen(dev)
-{
-       register struct tty *tp;
-
-       tp = &dh11[minor(dev)];
-       tp->t_state |= CARR_ON;
-}
-
-dmctl(dev, bits)
-{
-}
diff --git a/usr/sys/dev/dkleave.c b/usr/sys/dev/dkleave.c
deleted file mode 100644 (file)
index 7cd7a7d..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#include "../h/param.h"
-#include "../h/buf.h"
-
-daddr_t
-dkblock(bp)
-register struct buf *bp;
-{
-       register int dminor;
-
-       if (((dminor=minor(bp->b_dev))&0100) == 0)
-               return(bp->b_blkno);
-       dminor >>= 3;
-       dminor &= 07;
-       dminor++;
-       return(bp->b_blkno/dminor);
-}
-
-dkunit(bp)
-register struct buf *bp;
-{
-       register int dminor;
-
-       dminor = minor(bp->b_dev) >> 3;
-       if ((dminor&010) == 0)
-               return(dminor);
-       dminor &= 07;
-       dminor++;
-       return(bp->b_blkno%dminor);
-}
diff --git a/usr/sys/dev/dn.c b/usr/sys/dev/dn.c
deleted file mode 100644 (file)
index ab8d299..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * DN-11 ACU interface
- */
-
-#include "../h/param.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-
-struct device {
-       int     dn_reg[4];
-};
-
-struct device *dn_addr[] = { (struct device *)0175200 };
-#define        NDN     4
-
-#define        PWI     0100000
-#define        ACR     040000
-#define        DLO     010000
-#define        DONE    0200
-#define        IENABLE 0100
-#define        DSS     040
-#define        PND     020
-#define        MENABLE 04
-#define        DPR     02
-#define        CRQ     01
-
-#define        DNPRI   (PZERO+5)
-
-dnopen(dev)
-register dev;
-{
-       register struct device *dp;
-
-       dev = minor(dev);
-       if (dev >= NDN ||
-          (dp = dn_addr[dev>>2])->dn_reg[dev&03]&(PWI|DLO|CRQ))
-               u.u_error = ENXIO;
-       else {
-               dp->dn_reg[0] |= MENABLE;
-               dp->dn_reg[dev&03] = IENABLE|MENABLE|CRQ;
-       }
-}
-
-dnclose(dev)
-{
-       dev = minor(dev);
-       dn_addr[dev>>2]->dn_reg[dev&03] = MENABLE;
-}
-
-dnwrite(dev)
-{
-       register c;
-       register *dp;
-       extern lbolt;
-
-       dev = minor(dev);
-       dp = &(dn_addr[dev>>2]->dn_reg[dev&03]);
-       while ((*dp & (PWI|ACR|DSS)) == 0) {
-               spl4();
-               if ((*dp&PND) == 0 || u.u_count == 0 || (c=cpass()) < 0)
-                       sleep((caddr_t)dp, DNPRI);
-               else if (c == '-') {
-                       sleep((caddr_t)&lbolt, DNPRI);
-                       sleep((caddr_t)&lbolt, DNPRI);
-               } else {
-                       *dp = (c<<8)|IENABLE|MENABLE|DPR|CRQ;
-                       sleep((caddr_t)dp, DNPRI);
-               }
-               spl0();
-       }
-       if (*dp&(PWI|ACR))
-               u.u_error = EIO;
-}
-
-/*
- * interrupt-- "dev" applies to
- * system unit number, not minor device
- */
-dnint(dev)
-{
-       register *dp,*ep;
-
-       dp = &(dn_addr[dev]->dn_reg[0]);
-       *dp &= ~MENABLE;
-       for (ep=dp; ep<dp+4; ep++)
-               if (*ep&DONE) {
-                       *ep &= ~DONE;
-                       wakeup((caddr_t)ep);
-               }
-       *dp |= MENABLE;
-}
diff --git a/usr/sys/dev/dsort.c b/usr/sys/dev/dsort.c
deleted file mode 100644 (file)
index 5a90c1e..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * generalized seek sort for disk
- */
-
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/buf.h"
-
-#define        b_cylin b_resid
-
-disksort(dp, bp)
-register struct buf *dp, *bp;
-{
-       register struct buf *ap;
-       struct buf *tp;
-
-       ap = dp->b_actf;
-       if(ap == NULL) {
-               dp->b_actf = bp;
-               dp->b_actl = bp;
-               bp->av_forw = NULL;
-               return;
-       }
-       tp = NULL;
-       for(; ap != NULL; ap = ap->av_forw) {
-               if ((bp->b_flags&B_READ) && (ap->b_flags&B_READ) == 0) {
-                       if (tp == NULL)
-                               tp = ap;
-                       break;
-               }
-               if ((bp->b_flags&B_READ) == 0 && (ap->b_flags&B_READ))
-                       continue;
-               if(ap->b_cylin <= bp->b_cylin)
-                       if(tp == NULL || ap->b_cylin >= tp->b_cylin)
-                               tp = ap;
-       }
-       if(tp == NULL)
-               tp = dp->b_actl;
-       bp->av_forw = tp->av_forw;
-       tp->av_forw = bp;
-       if(tp == dp->b_actl)
-               dp->b_actl = bp;
-}
diff --git a/usr/sys/dev/du.c b/usr/sys/dev/du.c
deleted file mode 100644 (file)
index 577f3b6..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * DU-11 Synchronous interface driver
- */
-
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/buf.h"
-
-/* device registers */
-struct dureg {
-       int     rxcsr, rxdbuf;
-#define        parcsr  rxdbuf
-       int     txcsr, txdbuf;
-};
-
-struct du {
-       struct dureg    *du_addr;
-       int             du_state;
-       struct proc     *du_proc;
-       struct buf      *du_buf;
-       caddr_t         du_bufb;
-       caddr_t         du_bufp;
-       int             du_nxmit;
-       int             du_timer;
-} du[] = {
-       { (struct dureg *) 0160110 },
-};
-
-#define        NDU     (sizeof(du)/sizeof(du[0]))
-
-#define        DONE    0200
-#define        IE      0100
-#define        SIE     040
-#define CTS    020000
-#define        CARRIER 010000
-#define        RCVACT  04000
-#define        DSR     01000
-#define STRIP  0400
-#define SCH    020
-#define RTS    04
-#define        DTR     02
-#define MR     0400
-#define SEND   020
-#define        HALF    010
-
-#define        READ    0
-#define        WRITE   1
-#define PWRIT  2
-
-#define        DUPRI   (PZERO+1)
-
-duopen(dev)
-register dev;
-{
-       int dutimeout();
-       register struct du *dp;
-       register struct dureg *lp;
-
-       dev = minor(dev);
-       if (dev >= NDU ||
-          ((dp = &du[dev])->du_proc!=NULL && dp->du_proc!=u.u_procp)) {
-               u.u_error = ENXIO;
-               return;
-       }
-       dp->du_proc = u.u_procp;
-       lp = dp->du_addr;
-       if (dp->du_buf==NULL) {
-               dp->du_buf = geteblk();
-               dp->du_bufb = dp->du_buf->b_un.b_addr;
-               dp->du_state = WRITE;
-               lp->txcsr = MR;
-               lp->parcsr = 035026;            /* Sync Int, 7 bits, even parity, sync=026 */
-               timeout(dutimeout, (caddr_t)dp, HZ);
-               duturn(dp);
-       }
-}
-
-duclose(dev)
-{
-       register struct du *dp;
-       register struct dureg *lp;
-
-       dp = &du[minor(dev)];
-       lp = dp->du_addr;
-       lp->rxcsr = 0;
-       lp->txcsr = 0;
-       dp->du_timer = 0;
-       dp->du_proc = 0;
-       if (dp->du_buf != NULL) {
-               brelse(dp->du_buf);
-               dp->du_buf = NULL;
-       }
-}
-
-duread(dev)
-{
-       register char *bp;
-       register struct du *dp;
-
-       dp = &du[minor(dev)];
-       bp = dp->du_bufb;
-       for(;;) {
-               if(duwait(dev))
-                       return;
-               if (dp->du_bufp > bp)
-                       break;
-               spl6();
-               if (dp->du_timer <= 1) {
-                       spl0();
-                       return;
-               }
-               sleep((caddr_t)dp, DUPRI);
-               spl0();
-       }
-       u.u_offset = 0;
-       iomove(dp->du_bufb, (int)min(u.u_count, (unsigned)(dp->du_bufp-bp)), B_READ);
-}
-
-duwrite(dev)
-{
-       register struct du *dp;
-       register struct dureg *lp;
-
-       dev = minor(dev);
-       dp = &du[dev];
-       if (u.u_count==0 || duwait(dev))
-               return;
-       dp->du_bufp = dp->du_bufb;
-       dp->du_state = PWRIT;
-       dp->du_addr->rxcsr &= ~SCH;
-       dp->du_addr->rxcsr = SIE|RTS|DTR;
-       if (u.u_count > BSIZE)
-               u.u_count = BSIZE;
-       dp->du_nxmit = u.u_count;
-       u.u_offset = 0;
-       iomove(dp->du_bufb, (int)u.u_count, B_WRITE);
-       lp = dp->du_addr;
-       dp->du_timer = 10;
-       spl6();
-       while((lp->rxcsr&CTS)==0)
-               sleep((caddr_t)dp, DUPRI);
-       if (dp->du_state != WRITE) {
-               dp->du_state = WRITE;
-               lp->txcsr = IE|SIE|SEND|HALF;
-               dustart(dev);
-       }
-       spl0();
-}
-
-duwait(dev)
-{
-       register struct du *dp;
-       register struct dureg *lp;
-
-       dp = &du[minor(dev)];
-       lp = dp->du_addr;
-       for(;;) {
-               if ((lp->rxcsr&DSR)==0 || dp->du_buf==0) {
-                       u.u_error = EIO;
-                       return(1);
-               }
-               spl6();
-               if (dp->du_state==READ &&
-                       ((lp->rxcsr&RCVACT)==0)) {
-                       spl0();
-                       return(0);
-               }
-               sleep((caddr_t)dp, DUPRI);
-               spl0();
-       }
-}
-
-dustart(dev)
-{
-       register struct du *dp;
-       register struct dureg *lp;
-
-       dp = &du[minor(dev)];
-       lp = dp->du_addr;
-       dp->du_timer = 10;
-       if (dp->du_nxmit > 0) {
-               dp->du_nxmit--;
-               lp->txdbuf = *dp->du_bufp++;
-       } else {
-               duturn(dp);
-       }
-}
-
-durint(dev)
-{
-       register struct du *dp;
-       register c, s;
-       int dustat;
-
-       dp = &du[minor(dev)];
-       dustat = dp->du_addr->rxcsr;
-       if(dustat<0) {
-               if((dustat&CARRIER)==0 && dp->du_state==READ)
-                       duturn(dp);
-               else
-                       wakeup((caddr_t)dp);
-       } else
-       if(dustat&DONE) {
-               dp->du_addr->rxcsr = IE|SIE|SCH|DTR;
-               c = s = dp->du_addr->rxdbuf;
-               c &= 0177;
-               if(s<0)
-                       c |= 0200;
-               if (dp->du_bufp < dp->du_bufb+BSIZE)
-                       *dp->du_bufp++ = c;
-       }
-}
-
-duxint(dev)
-{
-       register struct du *dp;
-       register struct dureg *lp;
-       register int dustat;
-
-       dp = &du[minor(dev)];
-       lp = dp->du_addr;
-       dustat = lp->txcsr;
-       if(dustat<0)
-               duturn(dp);
-       else if(dustat&DONE)
-               dustart(dev);
-}
-
-duturn(dp)
-register struct du *dp;
-{
-       register struct dureg *lp;
-
-       lp = dp->du_addr;
-       if (dp->du_state!=READ) {
-               dp->du_state = READ;
-               dp->du_timer = 10;
-               dp->du_bufp = dp->du_bufb;
-       }
-       lp->txcsr = HALF;
-       lp->rxcsr &= ~SCH;
-       lp->rxcsr = STRIP|IE|SIE|SCH|DTR;
-       wakeup((caddr_t)dp);
-}
-
-dutimeout(dp)
-register struct du *dp;
-{
-       if (dp->du_timer == 0)
-               return;
-       if (--dp->du_timer == 0) {
-               duturn(dp);
-               dp->du_timer = 1;
-       }
-       timeout(dutimeout, (caddr_t)dp, HZ);
-}
diff --git a/usr/sys/dev/dz.c b/usr/sys/dev/dz.c
deleted file mode 100644 (file)
index f28b536..0000000
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- *     DZ11 driver
- * CAUTION -- MODIFIED FROM WORKING VERSION BUT NEVER PROPERLY TESTED
- */
-
-#include "../h/param.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/tty.h"
-
-struct device *dz_addr[] = { (struct device *)0160100, (struct device *)0160110};
-int    dz_cnt = 16;
-struct tty dz_tty[16];
-char   dz_stat;
-
-char   dz_speeds[] = {
-       0, 020, 021, 022, 023, 024, 0, 025,
-       026, 027, 030, 032, 034, 036, 0, 0,
-       };
-
-#define        BITS7   020
-#define        BITS8   030
-#define        TWOSB   040
-#define        PENABLE 0100
-#define        OPAR    0200
-#define        RCVENA  010000
-
-#define        IE      040140
-#define        PERROR  010000
-#define        FRERROR 020000
-#define        SSPEED  7       /* standard speed: 300 baud */
-
-struct device {
-       int     dzcsr, dzrbuf;
-       char    dztcr, dzdtr;
-       char    dztbuf, dzbrk;
-};
-#define        dzlpr   dzrbuf
-#define        dzmsr   dzbrk
-
-#define        ON      1
-#define        OFF     0
-
-
-dzopen(dev, flag)
-{
-       register struct tty *tp;
-       int x;
-       extern dzstart(), dzscan();
-
-       x = dev;
-       dev = minor(dev);
-       if (dev >= dz_cnt) {
-               u.u_error = ENXIO;
-               return;
-       }
-       tp = &dz_tty[dev];
-       if ((tp->t_state&(ISOPEN|WOPEN)) == 0) {
-               tp->t_oproc = dzstart;
-               tp->t_iproc = NULL;
-               ttychars(tp);
-               tp->t_ispeed = SSPEED;
-               tp->t_ospeed = SSPEED;
-               tp->t_flags = ODDP|EVENP|ECHO;
-               dzparam(dev);
-       }
-       dzmodem(dev, ON);
-       spl6();
-       while ((tp->t_state&CARR_ON)==0) {
-               tp->t_state |= WOPEN;
-               sleep((caddr_t)&tp->t_rawq, TTIPRI);
-       }
-       ttyopen(x,tp);
-       spl0();
-}
-
-dzclose(dev)
-{
-       register struct tty *tp;
-
-       dev = minor(dev);
-       tp = &dz_tty[dev];
-       wflushtty(tp);
-       if (tp->t_state&HUPCLS) {
-               dzmodem(dev, OFF);
-       }
-       tp->t_state &= CARR_ON;
-}
-
-dzread(dev)
-{
-       dev = minor(dev);
-       ttread(&dz_tty[dev]);
-}
-
-dzwrite(dev)
-{
-       dev = minor(dev);
-       ttwrite(&dz_tty[dev]);
-}
-
-dzioctl(dev, cmd, addr, flag)
-{
-       register struct tty *tp;
-
-       dev = minor(dev);
-       tp = &dz_tty[dev];
-       if (ttioccomm(cmd, tp, (caddr_t)addr, dev)) {
-               if (cmd==TIOCSETP||cmd==TIOCSETN)
-                       dzparam(dev);
-       } else {
-               u.u_error = ENOTTY;
-       }
-}
-
-dzparam(dev)
-{
-       register struct tty *tp;
-       register struct device *dzaddr;
-       register lpr;
-
-       tp = &dz_tty[dev];
-       dzaddr= dz_addr[dev>>3];
-       dzaddr->dzcsr = IE;
-       if (dz_stat==0) {
-               dzscan();
-               dz_stat++;
-       }
-       if (tp->t_ispeed==0) {  /* Hang up line */
-               dzmodem(dev, OFF);
-               return;
-       }
-       lpr = (dz_speeds[tp->t_ispeed]<<8)|(dev&07);
-       if (tp->t_flags&RAW)
-               lpr |= BITS8;
-       else
-               lpr |= BITS7|PENABLE;
-       if ((tp->t_flags&EVENP)==0)
-               lpr |= OPAR;
-       if (tp->t_ispeed == 3)  /* 110 baud */
-               lpr |= TWOSB;
-       dzaddr->dzlpr = lpr;
-}
-
-dzrint(dev)
-{
-       register struct tty *tp;
-       register c;
-       register struct device *dzaddr;
-
-       dzaddr = dz_addr[dev];
-       while ((c = dzaddr->dzrbuf) < 0) {      /* char. present */
-               tp = &dz_tty[((c>>8)&07)|(dev<<3)];
-               if (tp >= &dz_tty[dz_cnt])
-                       continue;
-               if((tp->t_state&ISOPEN)==0) {
-                       wakeup((caddr_t)&tp->t_rawq);
-                       continue;
-               }
-               if (c&FRERROR)          /* break */
-                       if (tp->t_flags&RAW)
-                               c = 0;          /* null (for getty) */
-                       else
-                               c = 0177;       /* DEL (intr) */
-               if (c&PERROR)
-                       if ((tp->t_flags&(EVENP|ODDP))==EVENP
-                        || (tp->t_flags&(EVENP|ODDP))==ODDP )
-                               continue;
-               ttyinput(c, tp);
-       }
-}
-
-dzxint(dev)
-{
-       register struct tty *tp;
-       register struct device *dzaddr;
-
-       dzaddr = dz_addr[dev];
-       while(dzaddr->dzcsr<0) {        /* TX rdy */
-               tp = &dz_tty[((dev<<3)|(dzaddr->dzcsr>>8)&07)];
-               dzaddr->dztbuf = tp->t_char;
-               tp->t_state &= ~BUSY;
-               dzstart(tp);
-       }
-}
-
-dzstart(tp)
-register struct tty *tp;
-{
-       register unit, c;
-       int s;
-       struct device *dzaddr;
-       extern ttrstrt();
-
-       unit = tp - dz_tty;
-       dzaddr = dz_addr[unit>>3];
-       unit = 1<<(unit&07);
-       s = spl5();
-       if (tp->t_state&(TIMEOUT|BUSY)) {
-               splx(s);
-               return;
-       }
-       if (tp->t_state&TTSTOP) {
-               dzaddr->dztcr &= ~unit;
-               splx(s);
-               return;
-       }
-       if ((c=getc(&tp->t_outq)) >= 0) {
-               if (c>=0200 && (tp->t_flags&RAW)==0) {
-                       dzaddr->dztcr &= ~unit;
-                       tp->t_state |= TIMEOUT;
-                       timeout(ttrstrt, (caddr_t)tp, (c&0177)+6);
-               } else {
-                       tp->t_char = c;
-                       tp->t_state |= BUSY;
-                       dzaddr->dztcr |= unit;
-               }
-               if (tp->t_outq.c_cc<=TTLOWAT && tp->t_state&ASLEEP) {
-                       tp->t_state &= ~ASLEEP;
-                       wakeup((caddr_t)&tp->t_outq);
-               }
-       } else
-               dzaddr->dztcr &= ~unit;
-       splx(s);
-}
-
-dzmodem(dev, flag)
-{
-       register struct device *dzaddr;
-       register bit;
-
-       dzaddr = dz_addr[dev>>3];
-       bit = 1<<(dev&07);
-       if (flag==OFF)
-               dzaddr->dzdtr &= ~bit;
-       else    dzaddr->dzdtr |= bit;
-}
-
-dzscan()
-{
-       register i;
-       register struct device *dzaddr;
-       register struct tty *tp;
-       char    bit;
-
-       for (i=0; i<dz_cnt; i++) {
-               dzaddr = dz_addr[i>>3];
-               tp = &dz_tty[i];
-               bit = 1<<(i&07);
-               if (dzaddr->dzmsr&bit) {
-                       if ((tp->t_state&CARR_ON)==0) {
-                               wakeup((caddr_t)&tp->t_rawq);
-                               tp->t_state |= CARR_ON;
-                       }
-               } else {
-                       if (tp->t_state&CARR_ON) {
-                               if (tp->t_state&ISOPEN) {
-                                       signal(tp->t_pgrp, SIGHUP);
-                                       dzaddr->dzdtr &= ~bit;
-                                       flushtty(tp);
-                               }
-                               tp->t_state &= ~CARR_ON;
-                       }
-               }
-       }
-       timeout(dzscan, (caddr_t)0, 120);
-}
diff --git a/usr/sys/dev/hp.c b/usr/sys/dev/hp.c
deleted file mode 100644 (file)
index 4b48d49..0000000
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * RP04/RP06 disk driver
- */
-
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/buf.h"
-#include "../h/conf.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-
-#define        DK_N    0
-
-struct device
-{
-       union {
-               int     w;
-               char    c[2];
-       } hpcs1;                /* Control and Status register 1 */
-       int     hpwc;           /* Word count register */
-       caddr_t hpba;           /* UNIBUS address register */
-       int     hpda;           /* Desired address register */
-       union {
-               int     w;
-               char    c[2];
-       } hpcs2;                /* Control and Status register 2*/
-       int     hpds;           /* Drive Status */
-       int     hper1;          /* Error register 1 */
-       int     hpas;           /* Attention Summary */
-       int     hpla;           /* Look ahead */
-       int     hpdb;           /* Data buffer */
-       int     hpmr;           /* Maintenance register */
-       int     hpdt;           /* Drive type */
-       int     hpsn;           /* Serial number */
-       int     hpof;           /* Offset register */
-       int     hpdc;           /* Desired Cylinder address register*/
-       int     hpcc;           /* Current Cylinder */
-       int     hper2;          /* Error register 2 */
-       int     hper3;          /* Error register 3 */
-       int     hpec1;          /* Burst error bit position */
-       int     hpec2;          /* Burst error bit pattern */
-       int     hpbae;          /* 11/70 bus extension */
-       int     hpcs3;
-};
-
-#define        HPADDR  ((struct device *)0176700)
-#define        NHP     2
-#define        NSECT   22
-#define        NTRAC   19
-#define        SDIST   2
-#define        RDIST   6
-
-struct size
-{
-       daddr_t nblocks;
-       int     cyloff;
-} hp_sizes[8] =
-{
-       9614,   0,              /* cyl 0 thru 22 */
-       8778,   23,             /* cyl 23 thru 43 */
-       0,      0,
-       0,      0,
-       161348, 44,             /* cyl 44 thru 429 */
-       160930, 430,            /* cyl 430 thru 814 */
-       153406, 44,             /* cyl 44 thru 410 (rp04, rp05) */
-       322278, 44,             /* cyl 44 thru 814 (rp06) */
-};
-
-#define        P400    020
-#define        M400    0220
-#define        P800    040
-#define        M800    0240
-#define        P1200   060
-#define        M1200   0260
-int    hp_offset[16] =
-{
-       P400, M400, P400, M400,
-       P800, M800, P800, M800,
-       P1200, M1200, P1200, M1200,
-       0, 0, 0, 0,
-};
-
-struct buf     hptab;
-struct buf     rhpbuf;
-struct buf     hputab[NHP];
-
-#define        GO      01
-#define        PRESET  020
-#define        RTC     016
-#define        OFFSET  014
-#define        SEARCH  030
-#define        RECAL   06
-#define DCLR   010
-#define        WCOM    060
-#define        RCOM    070
-
-#define        IE      0100
-#define        PIP     020000
-#define        DRY     0200
-#define        ERR     040000
-#define        TRE     040000
-#define        DCK     0100000
-#define        WLE     04000
-#define        ECH     0100
-#define VV     0100
-#define        DPR     0400
-#define        MOL     010000
-#define FMT22  010000
-
-#define        b_cylin b_resid
-
-daddr_t dkblock();
-
-hpstrategy(bp)
-register struct buf *bp;
-{
-       register struct buf *dp;
-       register unit;
-       long sz, bn;
-
-       unit = minor(bp->b_dev) & 077;
-       sz = bp->b_bcount;
-       sz = (sz+511) >> 9;
-       if (unit >= (NHP<<3) ||
-           bp->b_blkno < 0 ||
-           (bn = dkblock(bp))+sz > hp_sizes[unit&07].nblocks) {
-               bp->b_flags |= B_ERROR;
-               iodone(bp);
-               return;
-       }
-       bp->b_cylin = bn/(NSECT*NTRAC) + hp_sizes[unit&07].cyloff;
-       unit = dkunit(bp);
-       dp = &hputab[unit];
-       spl5();
-       disksort(dp, bp);
-       if (dp->b_active == 0) {
-               hpustart(unit);
-               if(hptab.b_active == 0)
-                       hpstart();
-       }
-       spl0();
-}
-
-hpustart(unit)
-register unit;
-{
-       register struct buf *bp, *dp;
-       daddr_t bn;
-       int sn, cn, csn;
-
-       HPADDR->hpcs2.w = unit;
-       HPADDR->hpcs1.c[0] = IE;
-       HPADDR->hpas = 1<<unit;
-
-       if(unit >= NHP)
-               return;
-       dk_busy &= ~(1<<(unit+DK_N));
-       dp = &hputab[unit];
-       if((bp=dp->b_actf) == NULL)
-               return;
-       if((HPADDR->hpds & VV) == 0) {
-               HPADDR->hpcs1.c[0] = IE|PRESET|GO;
-               HPADDR->hpof = FMT22;
-       }
-       if(dp->b_active)
-               goto done;
-       dp->b_active++;
-       if ((HPADDR->hpds & (DPR|MOL)) != (DPR|MOL))
-               goto done;
-
-       bn = dkblock(bp);
-       cn = bp->b_cylin;
-       sn = bn%(NSECT*NTRAC);
-       sn = (sn+NSECT-SDIST)%NSECT;
-
-       if(HPADDR->hpcc != cn)
-               goto search;
-       csn = (HPADDR->hpla>>6) - sn + SDIST - 1;
-       if(csn < 0)
-               csn += NSECT;
-       if(csn > NSECT-RDIST)
-               goto done;
-
-search:
-       HPADDR->hpdc = cn;
-       HPADDR->hpda = sn;
-       HPADDR->hpcs1.c[0] = IE|SEARCH|GO;
-       unit += DK_N;
-       dk_busy |= 1<<unit;
-       dk_numb[unit] += 1;
-       return;
-
-done:
-       dp->b_forw = NULL;
-       if(hptab.b_actf == NULL)
-               hptab.b_actf = dp; else
-               hptab.b_actl->b_forw = dp;
-       hptab.b_actl = dp;
-}
-
-hpstart()
-{
-       register struct buf *bp, *dp;
-       register unit;
-       daddr_t bn;
-       int dn, sn, tn, cn;
-
-loop:
-       if ((dp = hptab.b_actf) == NULL)
-               return;
-       if ((bp = dp->b_actf) == NULL) {
-               hptab.b_actf = dp->b_forw;
-               goto loop;
-       }
-       hptab.b_active++;
-       unit = minor(bp->b_dev) & 077;
-       dn = dkunit(bp);
-       bn = dkblock(bp);
-       cn = bn/(NSECT*NTRAC) + hp_sizes[unit&07].cyloff;
-       sn = bn%(NSECT*NTRAC);
-       tn = sn/NSECT;
-       sn = sn%NSECT;
-
-       HPADDR->hpcs2.w = dn;
-       if ((HPADDR->hpds & (DPR|MOL)) != (DPR|MOL)) {
-               hptab.b_active = 0;
-               hptab.b_errcnt = 0;
-               dp->b_actf = bp->av_forw;
-               bp->b_flags |= B_ERROR;
-               iodone(bp);
-               goto loop;
-       }
-       if(hptab.b_errcnt >= 16) {
-               HPADDR->hpof = hp_offset[hptab.b_errcnt & 017] | FMT22;
-               HPADDR->hpcs1.w = OFFSET|GO;
-               while(HPADDR->hpds & PIP)
-                       ;
-       }
-       HPADDR->hpdc = cn;
-       HPADDR->hpda = (tn << 8) + sn;
-       HPADDR->hpba = bp->b_un.b_addr;
-       if(cputype == 70)
-               HPADDR->hpbae = bp->b_xmem;
-       HPADDR->hpwc = -(bp->b_bcount>>1);
-       unit = ((bp->b_xmem&3) << 8) | IE | GO;
-       if(bp->b_flags & B_READ)
-               unit |= RCOM; else
-               unit |= WCOM;
-       HPADDR->hpcs1.w = unit;
-
-       dk_busy |= 1<<(DK_N+NHP);
-       dk_numb[DK_N+NHP] += 1;
-       unit = bp->b_bcount>>6;
-       dk_wds[DK_N+NHP] += unit;
-}
-
-hpintr()
-{
-       register struct buf *bp, *dp;
-       register unit;
-       int as, i, j;
-
-       as = HPADDR->hpas & 0377;
-       if(hptab.b_active) {
-               dk_busy &= ~(1<<(DK_N+NHP));
-               dp = hptab.b_actf;
-               bp = dp->b_actf;
-               unit = dkunit(bp);
-               HPADDR->hpcs2.c[0] = unit;
-               if (HPADDR->hpcs1.w & TRE) {            /* error bit */
-                       while((HPADDR->hpds & DRY) == 0)
-                               ;
-                       if(++hptab.b_errcnt > 28 || HPADDR->hper1&WLE)
-                               bp->b_flags |= B_ERROR; else
-                               hptab.b_active = 0;
-                       if(hptab.b_errcnt > 27)
-                               deverror(bp, HPADDR->hpcs2.w, HPADDR->hper1);
-                       if((bp->b_flags&B_PHYS) == 0 &&
-                          (HPADDR->hper1 & (DCK|ECH)) == DCK) {
-                               i = HPADDR->hpec1 - 1;
-                               j = i&017;
-                               i >>= 4;
-                               if(i >= 0 && i <256) {
-                                       bp->b_un.b_words[i] ^= HPADDR->hpec2 << j;
-                                       bp->b_un.b_words[i+1] ^= HPADDR->hpec2 >> (16-j);
-                               }
-                               hptab.b_active++;
-                               printf("%D ", bp->b_blkno);
-                               prdev("ECC", bp->b_dev);
-                       }
-                       HPADDR->hpcs1.w = TRE|IE|DCLR|GO;
-                       if((hptab.b_errcnt&07) == 4) {
-                               HPADDR->hpcs1.w = RECAL|IE|GO;
-                               while(HPADDR->hpds & PIP)
-                                       ;
-                       }
-               }
-               if(hptab.b_active) {
-                       if(hptab.b_errcnt) {
-                               HPADDR->hpcs1.w = RTC|GO;
-                               while(HPADDR->hpds & PIP)
-                                       ;
-                       }
-                       hptab.b_active = 0;
-                       hptab.b_errcnt = 0;
-                       hptab.b_actf = dp->b_forw;
-                       dp->b_active = 0;
-                       dp->b_errcnt = 0;
-                       dp->b_actf = bp->av_forw;
-                       bp->b_resid = -(HPADDR->hpwc<<1);
-                       iodone(bp);
-                       HPADDR->hpcs1.w = IE;
-                       if(dp->b_actf)
-                               hpustart(unit);
-               }
-               as &= ~(1<<unit);
-       } else {
-               if(as == 0)
-                       HPADDR->hpcs1.w = IE;
-               HPADDR->hpcs1.c[1] = TRE>>8;
-       }
-       for(unit=0; unit<NHP; unit++)
-               if(as & (1<<unit))
-                       hpustart(unit);
-       hpstart();
-}
-
-hpread(dev)
-{
-
-       physio(hpstrategy, &rhpbuf, dev, B_READ);
-}
-
-hpwrite(dev)
-{
-
-       physio(hpstrategy, &rhpbuf, dev, B_WRITE);
-}
diff --git a/usr/sys/dev/ht.c b/usr/sys/dev/ht.c
deleted file mode 100644 (file)
index 8ea0fb3..0000000
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * TJU16 tape driver
- */
-
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/buf.h"
-#include "../h/conf.h"
-#include "../h/dir.h"
-#include "../h/file.h"
-#include "../h/user.h"
-
-struct device
-{
-       int     htcs1;
-       int     htwc;
-       caddr_t htba;
-       int     htfc;
-       int     htcs2;
-       int     htds;
-       int     hter;
-       int     htas;
-       int     htck;
-       int     htdb;
-       int     htmr;
-       int     htdt;
-       int     htsn;
-       int     httc;
-       int     htbae;  /* 11/70 bus extension */
-       int     htcs3;
-};
-
-struct buf     httab;
-struct buf     rhtbuf;
-struct buf     chtbuf;
-
-#define        NUNIT   1
-#define        INF     1000000
-
-char   h_flags[NUNIT];
-char   h_openf[NUNIT];
-daddr_t        h_blkno[NUNIT];
-daddr_t        h_nxrec[NUNIT];
-
-#define        HTADDR  ((struct device *)0172440)
-
-#define        GO      01
-#define        WCOM    060
-#define        RCOM    070
-#define        NOP     0
-#define        WEOF    026
-#define        SFORW   030
-#define        SREV    032
-#define        ERASE   024
-#define        REW     06
-#define        DCLR    010
-#define P800   01300           /* 800 + pdp11 mode */
-#define        P1600   02300           /* 1600 + pdp11 mode */
-#define        IENABLE 0100
-#define        RDY     0200
-#define        TM      04
-#define        DRY     0200
-#define EOT    02000
-#define CS     02000
-#define COR    0100000
-#define PES    040
-#define WRL    04000
-#define MOL    010000
-#define ERR    040000
-#define FCE    01000
-#define        TRE     040000
-#define HARD   064023  /* UNS|OPI|NEF|FMT|RMR|ILR|ILF */
-
-#define        CLR     040     /* controller clear (in cs2) */
-
-#define        NED     010000
-
-#define        SIO     1
-#define        SSFOR   2
-#define        SSREV   3
-#define SRETRY 4
-#define SCOM   5
-#define SOK    6
-
-#define H_WRITTEN 1
-htopen(dev, flag)
-{
-       register unit, ds;
-
-       httab.b_flags |= B_TAPE;
-       unit = minor(dev) & 077;
-       if (unit >= NUNIT || h_openf[unit]) {
-               u.u_error = ENXIO;
-               return;
-       }
-       h_blkno[unit] = 0;
-       h_nxrec[unit] = INF;
-       h_flags[unit] = 0;
-       ds = hcommand(dev, NOP);
-       if ((ds&MOL)==0 || (flag && (ds&WRL)))
-               u.u_error = ENXIO;
-       if (u.u_error==0)
-               h_openf[unit]++;
-}
-
-htclose(dev, flag)
-{
-       register int unit;
-
-       unit = minor(dev) & 077;
-       if (flag == FWRITE || ((flag&FWRITE) && (h_flags[unit]&H_WRITTEN))) {
-               hcommand(dev, WEOF);
-               hcommand(dev, WEOF);
-               hcommand(dev, SREV);
-       }
-       if ((minor(dev)&0200) == 0)
-               hcommand(dev, REW);
-       h_openf[unit] = 0;
-}
-
-hcommand(dev, com)
-{
-       register struct buf *bp;
-
-       bp = &chtbuf;
-       spl5();
-       while(bp->b_flags&B_BUSY) {
-               bp->b_flags |= B_WANTED;
-               sleep((caddr_t)bp, PRIBIO);
-       }
-       spl0();
-       bp->b_dev = dev;
-       bp->b_resid = com;
-       bp->b_blkno = 0;
-       bp->b_flags = B_BUSY|B_READ;
-       htstrategy(bp);
-       iowait(bp);
-       if(bp->b_flags&B_WANTED)
-               wakeup((caddr_t)bp);
-       bp->b_flags = 0;
-       return(bp->b_resid);
-}
-
-htstrategy(bp)
-register struct buf *bp;
-{
-       register daddr_t *p;
-
-       if(bp != &chtbuf) {
-               p = &h_nxrec[minor(bp->b_dev)&077];
-               if(bp->b_blkno > *p) {
-                       bp->b_flags |= B_ERROR;
-                       bp->b_error = ENXIO;
-                       iodone(bp);
-                       return;
-               }
-               if(bp->b_blkno == *p && bp->b_flags&B_READ) {
-                       clrbuf(bp);
-                       bp->b_resid = bp->b_bcount;
-                       iodone(bp);
-                       return;
-               }
-               if ((bp->b_flags&B_READ)==0) {
-                       *p = bp->b_blkno + 1;
-                       h_flags[minor(bp->b_dev)&077] |= H_WRITTEN;
-               }
-       }
-       bp->av_forw = NULL;
-       spl5();
-       if (httab.b_actf == NULL)
-               httab.b_actf = bp;
-       else
-               httab.b_actl->av_forw = bp;
-       httab.b_actl = bp;
-       if (httab.b_active==0)
-               htstart();
-       spl0();
-}
-
-htstart()
-{
-       register struct buf *bp;
-       register unit, den;
-       daddr_t blkno;
-
-    loop:
-       if ((bp = httab.b_actf) == NULL)
-               return;
-       unit = minor(bp->b_dev) & 0177;
-       HTADDR->htcs2 = ((unit>>3)&07);
-       den = P1600 | (unit&07);
-       if(unit > 077)
-               den = P800 | (unit&07);
-       if((HTADDR->httc&03777) != den)
-               HTADDR->httc = den;
-       if (HTADDR->htcs2 & NED || (HTADDR->htds&MOL)==0)
-               goto abort;
-       unit &= 077;
-       blkno = h_blkno[unit];
-       if (bp == &chtbuf) {
-               if (bp->b_resid==NOP) {
-                       bp->b_resid = HTADDR->htds;
-                       goto next;
-               }
-               httab.b_active = SCOM;
-               HTADDR->htfc = 0;
-               HTADDR->htcs1 = bp->b_resid|IENABLE|GO;
-               return;
-       }
-       if (h_openf[unit] < 0 || bp->b_blkno > h_nxrec[unit])
-               goto abort;
-       if (blkno == bp->b_blkno) {
-               httab.b_active = SIO;
-               HTADDR->htba = bp->b_un.b_addr;
-               if(cputype == 70)
-                       HTADDR->htbae = bp->b_xmem;
-               HTADDR->htfc = -bp->b_bcount;
-               HTADDR->htwc = -(bp->b_bcount>>1);
-               den = ((bp->b_xmem&3) << 8) | IENABLE | GO;
-               if(bp->b_flags & B_READ)
-                       den |= RCOM;
-               else {
-                       if(HTADDR->htds & EOT) {
-                               bp->b_resid = bp->b_bcount;
-                               goto next;
-                       }
-                       den |= WCOM;
-               }
-               HTADDR->htcs1 = den;
-       } else {
-               if (blkno < bp->b_blkno) {
-                       httab.b_active = SSFOR;
-                       HTADDR->htfc = blkno - bp->b_blkno;
-                       HTADDR->htcs1 = SFORW|IENABLE|GO;
-               } else {
-                       httab.b_active = SSREV;
-                       HTADDR->htfc = bp->b_blkno - blkno;
-                       HTADDR->htcs1 = SREV|IENABLE|GO;
-               }
-       }
-       return;
-
-    abort:
-       bp->b_flags |= B_ERROR;
-
-    next:
-       httab.b_actf = bp->av_forw;
-       iodone(bp);
-       goto loop;
-}
-
-htintr()
-{
-       register struct buf *bp;
-       register int unit, state;
-       int     err;
-
-       if ((bp = httab.b_actf)==NULL)
-               return;
-       unit = minor(bp->b_dev) & 077;
-       state = httab.b_active;
-       httab.b_active = 0;
-       if (HTADDR->htcs1&TRE) {
-               err = HTADDR->hter;
-               if (HTADDR->htcs2&077400 || (err&HARD))
-                       state = 0;
-               if (bp == &rhtbuf)
-                       err &= ~FCE;
-               if ((bp->b_flags&B_READ) && (HTADDR->htds&PES))
-                       err &= ~(CS|COR);
-               if((HTADDR->htds&MOL) == 0) {
-                       if(h_openf[unit])
-                               h_openf[unit] = -1;
-               }
-               else if(HTADDR->htds&TM) {
-                       HTADDR->htwc = -(bp->b_bcount>>1);
-                       h_nxrec[unit] = bp->b_blkno;
-                       state = SOK;
-               }
-               else if(state && err == 0)
-                       state = SOK;
-               if(httab.b_errcnt > 4)
-                       deverror(bp, HTADDR->hter, HTADDR->htcs2);
-               htinit();
-               if (state==SIO && ++httab.b_errcnt < 10) {
-                       httab.b_active = SRETRY;
-                       h_blkno[unit]++;
-                       HTADDR->htfc = -1;
-                       HTADDR->htcs1 = SREV|IENABLE|GO;
-                       return;
-               }
-               if (state!=SOK) {
-                       bp->b_flags |= B_ERROR;
-                       state = SIO;
-               }
-       } else if (HTADDR->htcs1 < 0) { /* SC */
-               if(HTADDR->htds & ERR)
-                       htinit();
-       }
-       switch(state) {
-       case SIO:
-       case SOK:
-               h_blkno[unit]++;
-
-       case SCOM:
-               httab.b_errcnt = 0;
-               httab.b_actf = bp->av_forw;
-               iodone(bp);
-               bp->b_resid = (-HTADDR->htwc)<<1;
-               break;
-
-       case SRETRY:
-               if((bp->b_flags&B_READ)==0) {
-                       httab.b_active = SSFOR;
-                       HTADDR->htcs1 = ERASE|IENABLE|GO;
-                       return;
-               }
-
-       case SSFOR:
-       case SSREV:
-               if(HTADDR->htds & TM) {
-                       if(state == SSREV) {
-                               h_nxrec[unit] = bp->b_blkno - HTADDR->htfc;
-                               h_blkno[unit] = h_nxrec[unit];
-                       } else {
-                               h_nxrec[unit] = bp->b_blkno + HTADDR->htfc - 1;
-                               h_blkno[unit] = h_nxrec[unit]+1;
-                       }
-               } else
-                       h_blkno[unit] = bp->b_blkno;
-               break;
-
-       default:
-               return;
-       }
-       htstart();
-}
-
-htinit()
-{
-       register ocs2;
-       register omttc;
-       
-       omttc = HTADDR->httc & 03777;   /* preserve old slave select, dens, format */
-       ocs2 = HTADDR->htcs2 & 07;      /* preserve old unit */
-
-       HTADDR->htcs2 = CLR;
-       HTADDR->htcs2 = ocs2;
-       HTADDR->httc = omttc;
-       HTADDR->htcs1 = DCLR|GO;
-}
-
-htread(dev)
-{
-       htphys(dev);
-       physio(htstrategy, &rhtbuf, dev, B_READ);
-}
-
-htwrite(dev)
-{
-       htphys(dev);
-       physio(htstrategy, &rhtbuf, dev, B_WRITE);
-}
-
-htphys(dev)
-{
-       register unit;
-       daddr_t a;
-
-       unit = minor(dev) & 077;
-       if(unit < NUNIT) {
-               a = u.u_offset >> 9;
-               h_blkno[unit] = a;
-               h_nxrec[unit] = a+1;
-       }
-}
diff --git a/usr/sys/dev/kl.c b/usr/sys/dev/kl.c
deleted file mode 100644 (file)
index 07d83f8..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- *   KL/DL-11 driver
- */
-#include "../h/param.h"
-#include "../h/conf.h"
-#include       "../h/dir.h"
-#include "../h/user.h"
-#include "../h/tty.h"
-#include "../h/systm.h"
-
-/* base address */
-#define        KLADDR  ((struct device *)0177560)      /* console */
-#define        KLBASE  ((struct device *)0176500)      /* kl and dl11-a */
-#define        DLBASE  ((struct device *)0175610)      /* dl-e */
-#define        NKL11   1
-#define        NDL11   0
-#define DSRDY  02
-#define        RDRENB  01
-#define        DLDELAY 4       /* Extra delay for DL's (double buff) */
-
-#define        NL1     000400
-#define        NL2     001000
-#define        CR2     020000
-#define        FF1     040000
-#define        TAB1    002000
-
-struct tty kl11[NKL11+NDL11];
-int    klstart();
-int    ttrstrt();
-char   partab[];
-
-struct device {
-       int     rcsr;
-       int     rbuf;
-       int     tcsr;
-       int     tbuf;
-};
-
-klopen(dev, flag)
-dev_t dev;
-{
-       register struct device *addr;
-       register struct tty *tp;
-       register d;
-
-       d = minor(dev);
-       if(d >= NKL11+NDL11) {
-               u.u_error = ENXIO;
-               return;
-       }
-       tp = &kl11[d];
-       /*
-        * set up minor 0 to address KLADDR
-        * set up minor 1 thru NKL11-1 to address from KLBASE
-        * set up minor NKL11 on to address from DLBASE
-        */
-       if(d == 0)
-               addr = KLADDR;
-       else if(d < NKL11)
-               addr = KLBASE + (d-1);
-       else
-               addr = DLBASE + (d-NKL11);
-       tp->t_addr = (caddr_t)addr;
-       tp->t_oproc = klstart;
-       if ((tp->t_state&ISOPEN) == 0) {
-               tp->t_state = ISOPEN|CARR_ON;
-               tp->t_flags = EVENP|LCASE|ECHO|XTABS|CRMOD|CR2;
-               ttychars(tp);
-       }
-       addr->rcsr |= IENABLE|DSRDY|RDRENB;
-       addr->tcsr |= IENABLE;
-       ttyopen(dev, tp);
-}
-
-klclose(dev, flag)
-dev_t dev;
-int flag;
-{
-       register struct tty *tp;
-
-       tp = &kl11[minor(dev)];
-       ttyclose(tp);
-}
-
-klread(dev)
-dev_t dev;
-{
-       ttread(&kl11[minor(dev)]);
-}
-
-klwrite(dev)
-dev_t dev;
-{
-       ttwrite(&kl11[minor(dev)]);
-}
-
-klxint(dev)
-dev_t dev;
-{
-       register struct tty *tp;
-
-       tp = &kl11[minor(dev)];
-       ttstart(tp);
-       if (tp->t_state&ASLEEP && tp->t_outq.c_cc<=TTLOWAT)
-               if (tp->t_chan)
-                       mcstart(tp->t_chan, (caddr_t)&tp->t_outq);
-               else
-                       wakeup((caddr_t)&tp->t_outq);
-}
-
-klrint(dev)
-dev_t dev;
-{
-       register int c;
-       register struct device *addr;
-       register struct tty *tp;
-
-       tp = &kl11[minor(dev)];
-       addr = (struct device *)tp->t_addr;
-       c = addr->rbuf;
-       addr->rcsr |= RDRENB;
-       ttyinput(c, tp);
-}
-
-klioctl(dev, cmd, addr, flag)
-caddr_t addr;
-dev_t dev;
-{
-       if (ttioccom(cmd, &kl11[minor(dev)], addr, dev)==0)
-               u.u_error = ENOTTY;
-}
-
-klstart(tp)
-register struct tty *tp;
-{
-       register c;
-       register struct device *addr;
-
-       addr = (struct device *)tp->t_addr;
-       if((addr->tcsr&DONE) == 0)
-               return;
-       if ((c=getc(&tp->t_outq)) >= 0) {
-               if (tp->t_flags&RAW)
-                       addr->tbuf = c;
-               else if (c<=0177)
-                       addr->tbuf = c | (partab[c]&0200);
-               else {
-                       timeout(ttrstrt, (caddr_t)tp, (c&0177) + DLDELAY);
-                       tp->t_state |= TIMEOUT;
-               }
-       }
-}
-
-char   *msgbufp = msgbuf;      /* Next saved printf character */
-/*
- * Print a character on console.
- * Attempts to save and restore device
- * status.
- * If the switches are 0, all
- * printing is inhibited.
- *
- * Whether or not printing is inhibited,
- * the last MSGBUFS characters
- * are saved in msgbuf for inspection later.
- */
-putchar(c)
-register c;
-{
-       register s, timo;
-
-       if (c != '\0' && c != '\r' && c != 0177) {
-               *msgbufp++ = c;
-               if(msgbufp >= &msgbuf[MSGBUFS])
-                       msgbufp = msgbuf;
-       }
-       /*
-        *  If last char was a break or null, don't print
-       */
-       if ((KLADDR->rbuf&0177) == 0)
-               return;
-       timo = 30000;
-       /*
-        * Try waiting for the console tty to come ready,
-        * otherwise give up after a reasonable time.
-        */
-       while((KLADDR->tcsr&0200) == 0)
-               if(--timo == 0)
-                       break;
-       if(c == 0)
-               return;
-       s = KLADDR->tcsr;
-       KLADDR->tcsr = 0;
-       KLADDR->tbuf = c;
-       if(c == '\n') {
-               putchar('\r');
-               putchar(0177);
-               putchar(0177);
-       }
-       putchar(0);
-       KLADDR->tcsr = s;
-}
diff --git a/usr/sys/dev/lp.c b/usr/sys/dev/lp.c
deleted file mode 100644 (file)
index 5def52c..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- *  Line printer driver
- *
- *  Notice nonstandard indirection in struct device
- */
-
-#include "sys/param.h"
-#include "sys/dir.h"
-#include "sys/user.h"
-#include "sys/tty.h"
-
-struct device *lp_addr[];
-int    lp_cnt;
-
-#define        LPPRI   (PZERO+8)
-#define        LPLOWAT 40
-#define        LPHIWAT 100
-#define        LPMAX   2
-
-struct device {
-       int     lpcsr, lpbuf;
-};
-
-struct lp {
-       struct  clist l_outq;
-       char    flag, ind;
-       int     ccc, mcc, mlc;
-       int     line, col;
-} lp_dt[LPMAX];
-
-#define        OPEN    010
-#define        CAP     020
-#define        NOCR    040
-#define        ASLP    0100
-
-#define        FORM    014
-
-lpopen(dev, flag)
-{
-       register unit;
-       register struct lp *lp;
-
-       unit = dev&07;
-       if (unit >= lp_cnt || unit >= LPMAX ||
-        (lp = &lp_dt[unit])->flag || lp_addr[unit]->lpcsr <0 ) {
-               u.u_error = EIO;
-               return;
-       }
-       lp->flag = (dev&077)|OPEN;
-       lp->ind = 4;
-       lp->col = 80;
-       lp->line = 66;
-       lp_addr[unit]->lpcsr |= IENABLE;
-       lpoutput(unit, FORM);
-}
-
-lpclose(dev)
-{
-       register unit;
-
-       unit = dev&07;
-       lpoutput(unit, FORM);
-       lp_dt[unit].flag = 0;
-}
-
-lpwrite(dev)
-{
-       register unit;
-       register c;
-       register struct lp *lp;
-
-       unit = dev&07;
-       lp = &lp_dt[unit];
-       while (u.u_count) {
-               spl4();
-               while(lp->l_outq.c_cc > LPHIWAT) {
-                       lpintr(unit);
-                       lp->flag |= ASLP;
-                       sleep(lp, LPPRI);
-               }
-               spl0();
-               c = fubyte(u.u_base++);
-               if (c < 0) {
-                       u.u_error = EFAULT;
-                       break;
-               }
-               u.u_count--;
-               lpoutput(unit, c);
-       }
-       spl4();
-       lpintr(unit);
-       spl0();
-}
-
-lpoutput(dev, c)
-register dev, c;
-{
-       register struct lp *lp;
-
-       lp = &lp_dt[dev];
-       if(lp->flag&CAP) {
-               if(c>='a' && c<='z')
-                       c += 'A'-'a'; else
-               switch(c) {
-               case '{':
-                       c = '(';
-                       goto esc;
-               case '}':
-                       c = ')';
-                       goto esc;
-               case '`':
-                       c = '\'';
-                       goto esc;
-               case '|':
-                       c = '!';
-                       goto esc;
-               case '~':
-                       c = '^';
-               esc:
-                       lpoutput(dev, c);
-                       lp->ccc--;
-                       c = '-';
-               }
-       }
-       switch(c) {
-       case '\t':
-               lp->ccc = ((lp->ccc+8-lp->ind) & ~7) + lp->ind;
-               return;
-       case '\n':
-               lp->mlc++;
-               if(lp->mlc >= lp->line )
-                       c = FORM;
-       case FORM:
-               lp->mcc = 0;
-               if (lp->mlc) {
-                       putc(c, &lp->l_outq);
-                       if(c == FORM)
-                               lp->mlc = 0;
-               }
-       case '\r':
-               lp->ccc = lp->ind;
-               spl4();
-               lpintr(dev);
-               spl0();
-               return;
-       case 010:
-               if(lp->ccc > lp->ind)
-                       lp->ccc--;
-               return;
-       case ' ':
-               lp->ccc++;
-               return;
-       default:
-               if(lp->ccc < lp->mcc) {
-                       if (lp->flag&NOCR) {
-                               lp->ccc++;
-                               return;
-                       }
-                       putc('\r', &lp->l_outq);
-                       lp->mcc = 0;
-               }
-               if(lp->ccc < lp->col) {
-                       while(lp->ccc > lp->mcc) {
-                               putc(' ', &lp->l_outq);
-                               lp->mcc++;
-                       }
-                       putc(c, &lp->l_outq);
-                       lp->mcc++;
-               }
-               lp->ccc++;
-       }
-}
-
-lpintr(dev)
-register dev;
-{
-       register struct lp *lp;
-       register c;
-
-       lp = &lp_dt[dev];
-       while (lp_addr[dev]->lpcsr&DONE && (c = getc(&lp->l_outq)) >= 0)
-               lp_addr[dev]->lpbuf = c;
-       if (lp->l_outq.c_cc <= LPLOWAT && lp->flag&ASLP) {
-               lp->flag &= ~ASLP;
-               wakeup(lp);
-       }
-}
-
-struct { char lobyte, hibyte;};
-lpsgtty(dev, v)
-register *v;
-{
-       register struct lp *lp;
-
-       lp = &lp_dt[dev&07];
-       if (v) {
-               v->lobyte = lp->flag;
-               v->hibyte = lp->ind;
-               v[1] = lp->line;
-               v[2] = lp->col;
-       } else {
-               lp->flag = (u.u_arg[0].lobyte&077)|OPEN;
-               lp->ind = u.u_arg[0].hibyte&017;
-               lp->line = u.u_arg[1];
-               lp->col = u.u_arg[2];
-       }
-}
diff --git a/usr/sys/dev/mem.c b/usr/sys/dev/mem.c
deleted file mode 100644 (file)
index 68ac682..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#
-/*
- */
-
-/*
- *     Memory special file
- *     minor device 0 is physical memory
- *     minor device 1 is kernel memory
- *     minor device 2 is EOF/RATHOLE
- */
-
-#include "../h/param.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/conf.h"
-#include "../h/seg.h"
-
-mmread(dev)
-{
-       register c, bn, on;
-       int a, d;
-
-       if(minor(dev) == 2)
-               return;
-       do {
-               bn = u.u_offset >> 6;
-               on = u.u_offset & 077;
-               a = UISA->r[0];
-               d = UISD->r[0];
-               spl7();
-               UISA->r[0] = bn;
-               UISD->r[0] = 077406;
-               if(minor(dev) == 1)
-                       UISA->r[0] = (ka6-6)->r[(bn>>7)&07] + (bn & 0177);
-               if ((c = fuibyte((caddr_t)on)) < 0)
-                       u.u_error = ENXIO;
-               UISA->r[0] = a;
-               UISD->r[0] = d;
-               spl0();
-       } while(u.u_error==0 && passc(c)>=0);
-}
-
-mmwrite(dev)
-{
-       register c, bn, on;
-       int a, d;
-
-       if(minor(dev) == 2) {
-               u.u_count = 0;
-               return;
-       }
-       for(;;) {
-               bn = u.u_offset >> 6;
-               on = u.u_offset & 077;
-               if ((c=cpass())<0 || u.u_error!=0)
-                       break;
-               a = UISA->r[0];
-               d = UISD->r[0];
-               spl7();
-               UISA->r[0] = bn;
-               UISD->r[0] = 077406;
-               if(minor(dev) == 1)
-                       UISA->r[0] = (ka6-6)->r[(bn>>7)&07] + (bn & 0177);
-               if (suibyte((caddr_t)on, c) < 0)
-                       u.u_error = ENXIO;
-               UISA->r[0] = a;
-               UISD->r[0] = d;
-               spl0();
-       }
-}
diff --git a/usr/sys/dev/mklib b/usr/sys/dev/mklib
deleted file mode 100755 (executable)
index 53940ac..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-ar rc LIB2 \
-bio.o \
-cat.o \
-dhdm.o \
-dh.o \
-dhfdm.o \
-dn.o \
-du.o \
-hp.o \
-ht.o \
-kl.o \
-mem.o \
-mx1.o \
-mx2.o \
-partab.o \
-rf.o \
-rk.o \
-sys.o \
-tc.o \
-tm.o \
-tty.o \
-vp.o \
-vs.o \
-dsort.o \
-dkleave.o \
-pk0.o \
-pk1.o \
-pk2.o \
-pk3.o \
-dc.o \
-dz.o \
-rl.o \
-rp.o
diff --git a/usr/sys/dev/mx1.c b/usr/sys/dev/mx1.c
deleted file mode 100644 (file)
index 39a45d2..0000000
+++ /dev/null
@@ -1,489 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/reg.h"
-#include "../h/proc.h"
-#include "../h/tty.h"
-#include "../h/inode.h"
-#define        KERNEL  1
-#include "../h/mx.h"
-#include "../h/file.h"
-#include "../h/conf.h"
-
-/*
- * Multiplexor:   clist version
- *
- * installation:
- *     requires a line in cdevsw -
- *             mxopen, mxclose, mxread, mxwrite, mxioctl, 0,
- *
- *     also requires a line in linesw -
- *             mxopen, mxclose, mcread, mcwrite, mxioctl, nulldev, nulldev,
- *
- *     The linesw entry for mpx should be the last one in the table.
- *     'nldisp' (number of line disciplines) should not include the
- *     mpx line.  This is to prevent mpx from being enabled by an ioctl.
-
- *     mxtty.c must be loaded instead of tty.c so that certain
- *     sleeps will not be done if a typewriter is connected to
- *     a channel and so that sdata will be called from ttyinput.
- *     
- */
-struct chan    chans[NCHANS];
-struct schan   schans[NPORTS];
-struct group   *groups[NGROUPS];
-int    mpxline;
-struct chan *xcp();
-dev_t  mpxdev  = -1;
-
-
-char   mcdebugs[NDEBUGS];
-
-
-/*
- * Allocate a channel, set c_index to index.
- */
-struct chan *
-challoc(index, isport)
-{
-register s;
-
-       s = spl6();
-       if (isport) {
-               register struct schan *cp, *lastcp;
-               cp = schans;
-               lastcp = &schans[NPORTS];
-               for (; cp < lastcp; cp++)
-                       if (cp->c_group==NULL) {
-                               cp->c_index = index;
-                               cp->c_pgrp = 0;
-                               cp->c_flags = 0;
-                               splx(s);
-                               return((struct chan *)cp);
-                       }
-               goto out;
-       } else {
-               register struct chan *cp, *lastcp;
-               cp = chans;
-               lastcp = &chans[NCHANS];
-               for(; cp < lastcp; cp++) 
-                       if(cp->c_group==NULL) {
-                               cp->c_index = index;
-                               cp->c_pgrp = 0;
-                               cp->c_flags = 0;
-                               splx(s);
-                               return(cp);
-                       }
-       }
-out:
-       splx(s);
-       return(NULL);
-}
-
-
-
-/*
- * Allocate a group table cell.
- */
-gpalloc()
-{
-register i,s;
-
-       s = spl6();
-       for(i = NGROUPS-1; i>=0; i--)
-               if (groups[i]==NULL) {
-                       groups[i]++;
-                       break;
-               }
-       splx(s);
-       return(i);
-}
-
-
-/*
- * Add a channel to the group in
- * inode ip.
- */
-struct chan *
-addch(ip, isport)
-struct inode *ip;
-{
-register struct chan *cp;
-register struct group *gp;
-register i;
-
-       plock(ip);
-       gp = &ip->i_un.i_group;
-       for(i=0;i<NINDEX;i++) {
-               cp = (struct chan *)gp->g_chans[i];
-               if (cp == NULL) {
-                       if ((cp=challoc(i, isport)) != NULL) {
-                               gp->g_chans[i] = cp;
-                               cp->c_group = gp;
-                       }
-                       break;
-               }
-               cp = NULL;
-       }
-       prele(ip);
-       return(cp);
-}
-
-
-
-
-/*
- * mpxchan system call
- */
-mpxchan()
-{
-struct inode *ip, *gip;
-register int i;
-extern mxopen(), mcread();
-extern sdata(), scontrol();
-dev_t  dev;
-struct tty *tp;
-struct file *fp, *chfp, *gfp;
-struct chan *cp;
-struct group *gp, *ngp;
-struct a {
-       int     cmd;
-       int     *argvec;
-} *uap;
-struct mx_args vec;
-
-
-       /*
-        * common setup code.
-        */
-       uap = (struct a *)u.u_ap;
-       copyin((caddr_t)uap->argvec, (caddr_t)&vec, sizeof vec);
-       gp = NULL;
-       switch(uap->cmd) {
-       case NPGRP:
-               if (vec.m_arg[1] < 0)
-                       goto sw;
-       case CHAN:
-       case JOIN:
-       case EXTR:
-       case ATTACH:
-       case DETACH:
-       case CSIG:
-               gfp = getf(vec.m_arg[1]);
-               if (gfp==NULL)
-                       goto bad;
-               gip = gfp->f_inode;
-               gp = &gip->i_un.i_group;
-               if (gp->g_inode != gip)
-                       goto bad;
-       }
-
-sw:
-       switch(uap->cmd) {
-       /*
-        * creat an mpx file.
-        */
-       case MPX:
-       case MPXN:
-               if (mpxdev < 0) {
-                       for(i=0; linesw[i].l_open; i++) 
-                               if (linesw[i].l_read == mcread) {
-                                       mpxline = i;
-                                       goto found1;
-                               }
-                       goto bad;
-
-               found1:
-                       for(i=0; cdevsw[i].d_open; i++) {
-                               if (cdevsw[i].d_open == mxopen)
-                                       goto found2;
-                       }
-               bad:
-                       u.u_error = ENXIO;
-                       return;
-               found2:
-                       mpxdev = (dev_t)(i<<8);
-               }
-               if (uap->cmd==MPXN) {
-                       if ((ip=ialloc(rootdev))==NULL)
-                               goto bad;
-                       ip->i_mode = 0666+IFCHR;
-                       goto merge;
-               }
-               u.u_dirp = vec.m_name;
-               ip = namei(uchar,1);
-               if (ip != NULL) {
-                       u.u_error = EEXIST;
-                       iput(ip);
-                       return;
-               }
-               if (u.u_error)
-                       return;
-               ip = maknode((vec.m_arg[0]&0777)+IFCHR);
-               if (ip == NULL)
-                       return;
-       merge:
-               if ((i = gpalloc()) < 0) {
-                       iput(ip);
-                       goto bad;
-               }
-               ip->i_un.i_rdev = (daddr_t)(mpxdev+i);
-               gp = &ip->i_un.i_group;
-               groups[i] = gp;
-               gp->g_inode = ip;
-               gp->g_state = COPEN;
-               gp->g_group = NULL;
-               gp->g_index = 0;
-               gp->g_rotmask = 1;
-               gp->g_rot = 0;
-               gp->g_datq = 0;
-               open1(ip,FREAD+FWRITE,2);
-               if (u.u_error) {
-                       groups[i] = NULL;
-                       iput(ip);
-                       goto bad;
-               }
-               ip->i_mode = (ip->i_mode & ~IFMT) | IFMPC;
-               ip->i_count++;
-               ip->i_flag |= IACC|IUPD|ICHG;
-               fp = u.u_ofile[u.u_r.r_val1];
-               fp->f_flag |= FMP;
-               fp->f_un.f_chan = NULL;
-               gp->g_file = fp;
-               for(i=0;i<NINDEX;)
-                       gp->g_chans[i++] = NULL;
-               return;
-       /*
-        * join file descriptor (arg 0) to group (arg 1)
-        * return channel number
-        */
-       case JOIN:
-               if ((fp=getf(vec.m_arg[0]))==NULL)
-                       goto bad;
-               ip = fp->f_inode;
-               i = ip->i_mode & IFMT;
-               if (i == IFMPC) {
-                       if ((fp->f_flag&FMP) != FMP) {
-                               goto bad;
-                       }
-                       ngp = &ip->i_un.i_group;
-                       mlink (ngp, gp);
-                       fp->f_count++;
-                       return;
-               }
-               if (i != IFCHR) 
-                       goto bad;
-               dev = (dev_t)ip->i_un.i_rdev;
-               tp = cdevsw[major(dev)].d_ttys;
-               if (tp==NULL)
-                       goto bad;
-               tp = &tp[minor(dev)];
-               if (tp->t_chan)
-                       goto bad;
-               if ((cp=addch(gip, 1))==NULL)
-                       goto bad;
-               tp->t_chan = cp;
-               cp->c_fy = fp;
-               fp->f_count++;
-               cp->c_ttyp = tp;
-               cp->c_line = tp->t_line;
-               cp->c_flags = XGRP+PORT;
-               u.u_r.r_val1 = cpx(cp);
-               return;
-       /*
-        * attach channel (arg 0) to group (arg 1)
-        */
-       case ATTACH:
-               cp = xcp(gp, vec.m_arg[0]);
-               if (cp==NULL)
-                       goto bad;
-               u.u_r.r_val1 = cpx(cp);
-               wakeup((caddr_t)cp);
-               return;
-       case DETACH:
-               cp = xcp(gp, vec.m_arg[0]);
-               if (cp==NULL)
-                       goto bad;
-               detach(cp);
-               return;
-       /*
-        * extract channel (arg 0) from group (arg 1).
-        */
-       case EXTR:
-               cp = xcp(gp, vec.m_arg[0]);
-               if (cp==NULL) {
-                       goto bad;
-               }
-               if (cp->c_flags & ISGRP) {
-                       mxfalloc(((struct group *)cp)->g_file);
-                       return;
-               }
-               if ((fp = cp->c_fy) != NULL) {
-                       mxfalloc(fp);
-                       return;
-               }
-               if ((fp = falloc()) == NULL) {
-                       return;
-               }
-               fp->f_inode = gip;
-               gip->i_count++;
-               fp->f_un.f_chan = cp;
-               fp->f_flag = (vec.m_arg[2]) ?
-                               (FREAD|FWRITE|FMPY) : (FREAD|FWRITE|FMPX);
-               cp->c_fy = fp;
-               return;
-       /*
-        * make new chan on group (arg 1)
-        */
-       case CHAN:
-               if ((cp=addch(gip, 0))==NULL)
-                       goto bad;
-               cp->c_flags = XGRP;
-               cp->c_fy = NULL;
-               cp->c_ttyp = cp->c_ottyp = (struct tty *)cp;
-               cp->c_line = cp->c_oline = mpxline;
-               u.u_r.r_val1 = cpx(cp);
-               return;
-       /*
-        * connect fd (arg 0) to channel fd (arg 1)
-        * (arg 2 <  0) => fd to chan only
-        * (arg 2 >  0) => chan to fd only
-        * (arg 2 == 0) => both directions
-        */
-       case CONNECT:
-               if ((fp=getf(vec.m_arg[0]))==NULL)
-                       goto bad;
-               if ((chfp=getf(vec.m_arg[1]))==NULL)
-                       goto bad;
-               ip = fp->f_inode;
-               i = ip->i_mode&IFMT;
-               if (i!=IFCHR)
-                       goto bad;
-               dev = (dev_t)ip->i_un.i_rdev;
-               tp = cdevsw[major(dev)].d_ttys;
-               if (tp==NULL)
-                       goto bad;
-               tp = &tp[minor(dev)];
-               if (!(chfp->f_flag&FMPY)) {
-                       goto bad;
-               }
-               cp = chfp->f_un.f_chan;
-               if (cp==NULL || cp->c_flags&PORT) {
-                       goto bad;
-               }
-               i = vec.m_arg[2];
-               if (i>=0) {
-                       cp->c_ottyp = tp;
-                       cp->c_oline = tp->t_line;
-               }
-               if (i<=0)  {
-                       tp->t_chan = cp;
-                       cp->c_ttyp = tp;
-                       cp->c_line = tp->t_line;
-               }
-               return;
-       case NPGRP: {
-               register struct proc *pp;
-
-               if (gp != NULL) {
-                       cp = xcp(gp, vec.m_arg[0]);
-                       if (cp==NULL)
-                               goto bad;
-               }
-               pp = u.u_procp;
-               pp->p_pgrp = pp->p_pid;
-               if (vec.m_arg[2])
-                       pp->p_pgrp = vec.m_arg[2];
-               if (gp != NULL)
-                       cp->c_pgrp = pp->p_pgrp;
-               return;
-       }
-       case CSIG:
-               cp = xcp(gp, vec.m_arg[0]);
-               if (cp==NULL)
-                       goto bad;
-               signal(cp->c_pgrp, vec.m_arg[2]);
-               return;
-       case DEBUG:
-               i = vec.m_arg[0];
-               if (i<0 || i>NDEBUGS)
-                       return;
-               mcdebugs[i] = vec.m_arg[1];
-               if (i==ALL)
-                       for(i=0;i<NDEBUGS;i++)
-                               mcdebugs[i] = vec.m_arg[1];
-               return;
-       default:
-               goto bad;
-       }
-}
-
-detach(cp)
-register struct chan *cp;
-{
-       register struct group *gp;
-       register int i;
-
-       if (cp->c_flags&ISGRP) {
-               gp = (struct group *)cp;
-               closef(gp->g_file);
-               i = ((struct group *)cp)->g_index;
-               gp->g_chans[i] = NULL;
-               return;
-       } else if (cp->c_flags&PORT && cp->c_ttyp != NULL) {
-               closef(cp->c_fy);
-               chdrain(cp);
-               chfree(cp);
-               return;
-       }
-       if (cp->c_fy && (cp->c_flags&WCLOSE)==0) {
-               cp->c_flags |= WCLOSE;
-               chwake(cp);
-       } else {
-               chdrain(cp);
-               chfree(cp);
-       }
-}
-
-
-mxfalloc(fp)
-register struct file *fp;
-{
-register i;
-
-       if (fp==NULL) {
-               u.u_error = ENXIO;
-               return;
-       }
-
-       i = ufalloc();
-       if (i < 0)
-               return;
-       u.u_ofile[i] = fp;
-       fp->f_count++;
-       u.u_r.r_val1 = i;
-       return;
-}
-
-
-
-
-mlink(sub,master)
-struct group *sub, *master;
-{
-register i;
-
-
-       for(i=0;i<NINDEX;i++) {
-               if (master->g_chans[i] != NULL)
-                       continue;
-               master->g_chans[i] = (struct chan *)sub;
-               sub->g_group = master;
-               sub->g_index = i;
-               u.u_r.r_val1 = i;
-               return;
-       }
-       u.u_error = ENXIO;
-       return;
-}
diff --git a/usr/sys/dev/mx2.c b/usr/sys/dev/mx2.c
deleted file mode 100644 (file)
index cd93315..0000000
+++ /dev/null
@@ -1,915 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/proc.h"
-#include "../h/tty.h"
-#include "../h/inode.h"
-#define        KERNEL  1
-#include "../h/mx.h"
-#include "../h/file.h"
-#include "../h/conf.h"
-#include "../h/buf.h"
-
-/*
- * multiplexor driver
- */
-struct chan    chans[NCHANS];
-struct group   *groups[NGROUPS];
-int    mpxline;
-struct chan *xcp();
-struct chan *addch();
-struct chan *nextcp();
-
-#define        MIN(a,b)        ((a<b)?a:b)
-short  cmask[16]       ={
-       01,     02,     04,
-       010,    020,    040,
-       0100,   0200,   0400,
-       01000,  02000,  04000,
-       010000, 020000, 040000, 0100000
-};
-
-#define        HIQ     100
-#define        LOQ     20
-#define        FP      ((struct file *)cp)
-
-
-
-char mcdebugs[NDEBUGS];
-
-/*
- * Timing cell
- */
-int    mxdummy;
-int    *MP     = &mxdummy;
-
-
-
-struct group *
-getmpx(dev)
-dev_t dev;
-{
-register d;
-
-       d = minor(dev);
-       if (d >= NGROUPS) 
-               return(NULL);
-       return(groups[d]);
-}
-
-
-
-
-mxopen(dev, flag)
-{
-register struct group *gp;
-register struct file *fp;
-register struct chan *cp;
-int    msg;
-       gp = getmpx(dev);
-       if (gp == NULL) {
-       bad:
-               u.u_error = ENXIO;
-               return;
-       }
-
-       if (gp->g_state == COPEN) {
-               gp->g_state = INUSE+ISGRP;
-               return;
-       }
-       if (!(gp->g_state&INUSE)) 
-               goto bad;
-       fp = u.u_ofile[u.u_r.r_val1];
-       if (fp->f_inode != gp->g_inode) 
-               goto bad;
-       if ((cp=addch(gp->g_inode, 0))==NULL)
-               goto bad;
-       cp->c_flags = XGRP;
-       cp->c_ottyp = cp->c_ttyp = (struct tty *)cp;
-       cp->c_line = cp->c_oline = mpxline;
-       fp->f_flag |= FMPY;
-       fp->f_flag |= FREAD+FWRITE;
-       fp->f_un.f_chan = cp;
-       if (gp->g_inode == mpxip) {
-               plock(mpxip);
-               mpxname(cp);
-               msg = M_OPEN;
-       } else
-               msg = M_WATCH;
-       scontrol(cp, msg, u.u_uid);
-       sleep((caddr_t)cp,TTIPRI);
-       if (cp->c_flags&NMBUF)
-               prele(mpxip);
-       if (cp->c_flags & WCLOSE) {
-               chdrain(cp);
-               chfree(cp);
-               goto bad;
-       }
-       cp->c_fy = fp;
-       cp->c_pgrp = u.u_procp->p_pgrp;
-}
-
-
-char   mxnmbuf[NMSIZE];
-int    nmsize;
-struct chan *mxnmcp;
-mpxname(cp)
-register struct chan *cp;
-{
-register char *np;
-register c;
-       np = mxnmbuf;
-       u.u_dirp = (caddr_t)u.u_arg[0];
-       
-       while (np < &mxnmbuf[NMSIZE]) {
-               c = uchar();
-               if (c <= 0)
-                       break;
-               *np++ = c;
-       }
-       *np++ = '\0';
-       nmsize = np - mxnmbuf;
-
-       cp->c_flags |= NMBUF;
-}
-
-
-mxclose(dev, flag, cp)
-dev_t  dev;
-register struct chan *cp;
-{
-register struct group *gp;
-register struct inode *ip;
-register struct file *fp;
-int    i, fmp;
-
-       fmp = flag&FMP;
-
-       /*
-        * close a channel
-        */
-       if (cp!=NULL && fmp && fmp!=FMP) {
-               for(fp=file; fp < &file[NFILE]; fp++) 
-                   if(fp->f_count && fp->f_flag&FMP && fp->f_un.f_chan==cp){
-                               return;
-                       }
-               chdrain(cp);
-               if ((cp->c_flags&WCLOSE)==0) {
-                       scontrol(cp, M_CLOSE, 0);
-                       cp->c_flags |= WCLOSE;
-               } else {
-                       chfree(cp);
-               }
-               return;
-       }
-
-       if ((gp = getmpx(dev)) == NULL)
-               return;
-       ip = gp->g_inode;
-       if (ip==NULL || (ip->i_mode&IFMT)!=IFMPC) {
-               return;
-       }
-
-       for(fp=file; fp < &file[NFILE]; fp++) {
-               if (fp->f_count && (fp->f_flag&FMP)==FMP && fp->f_inode==ip) {
-                       return;
-               }
-       }
-
-       if (ip == mpxip) {
-               mpxip = NULL;
-               prele(ip);
-       }
-
-       for(i=0;i<NINDEX;i++)
-               if ((cp=gp->g_chans[i])!=NULL)
-                       detach(cp);
-
-       groups[minor(dev)] = NULL;
-       plock(ip);
-       i = ip->i_mode;
-       i &= ~IFMT;
-       i |= IFCHR;
-       ip->i_mode = i;
-       zero((caddr_t)gp, sizeof (struct group));
-       ip->i_flag |= IUPD|ICHG;
-       iput(ip);
-}
-
-zero(s, cc)
-register char *s;
-register cc;
-{
-       while (cc--)
-               *s++ = 0;
-}
-
-char   m_eot[] ={ M_EOT, 0, 0, 0};
-
-/*
- * Mxread + mxwrite are entered from cdevsw
- * for all read/write calls.  Operations on
- * an mpx file are handled here.
- * Calls are made through linesw to handle actual
- * data movement.
- */
-mxread(dev)
-{
-register struct group *gp;
-register struct chan *cp;
-register esc;
-struct rh h;
-caddr_t        base;
-unsigned count;
-int    s, xfr, more, fmp;
-
-       if ((gp=getmpx(dev))==NULL) {
-bad:
-               u.u_error = ENXIO;
-               return;
-       }
-       FP = getf(u.u_arg[0]);
-       fmp = FP->f_flag & FMP;
-       if (fmp != FMP) {
-               msread(fmp, FP->f_un.f_chan);
-               return;
-       }
-
-       if ((int)u.u_base & 1)
-               goto bad;
-       s = spl6();
-       while (gp->g_datq == 0) {
-
-               sleep((caddr_t)&gp->g_datq, TTIPRI);
-       }
-
-       while (gp->g_datq && u.u_count >= CNTLSIZ + 2) {
-               splx(s);
-               esc = 0;
-               cp = nextcp(gp);
-               if (cp==NULL) {
-                       continue;
-               }
-               h.index = cpx(cp);
-               if (count = cp->c_ctlx.c_cc) {
-                       count += CNTLSIZ;
-                       if (cp->c_flags&NMBUF)
-                               count += nmsize;
-                       if (count > u.u_count) {
-                               sdata(cp);
-                               return;
-                       }
-                       esc++;
-               }
-               base = u.u_base;
-               count = u.u_count;
-               u.u_base += sizeof h;
-               u.u_count -= sizeof h;
-               xfr = u.u_count;
-               if (esc && cp->c_flags&PORT) {
-                       more = mcread(cp);
-               } else {
-                       more = (*linesw[cp->c_line].l_read)(cp->c_ttyp);
-               }
-               if (more > 0)
-                       sdata(cp);
-               if (more < 0)
-                       scontrol(cp, M_CLOSE, 0);
-               if (xfr == u.u_count) {
-                       esc++;
-                       iomove((caddr_t)m_eot, sizeof m_eot, B_READ);
-               }
-               xfr -= u.u_count;
-               if (esc) {
-                       h.count = 0;
-                       h.ccount = xfr;
-               } else {
-                       h.count = xfr;
-                       h.ccount = 0;
-                       mxrstrt(cp, &cp->cx.datq, BLOCK|ALT);
-               }
-               if (u.u_count && (xfr&1)) {
-                       u.u_base++;
-                       u.u_count--;
-               }
-               copyout((caddr_t)&h, base, sizeof h);
-
-               s = spl6();
-       }
-}
-
-
-
-
-
-mxwrite(dev)
-{
-register struct chan *cp;
-struct wh h;
-struct group *gp;
-int    ucount, esc, fmp, burpcount;
-caddr_t        ubase, hbase;
-
-       if ((gp=getmpx(dev))==NULL) {
-               u.u_error = ENXIO;
-               return;
-       }
-       FP = getf(u.u_arg[0]);
-       fmp = FP->f_flag & FMP;
-       if (fmp != FMP) {
-               mswrite(fmp, FP->f_un.f_chan);
-               return;
-       }
-       burpcount = 0;
-       while (u.u_count >= sizeof h) {
-               hbase = u.u_base;
-               iomove((caddr_t)&h, sizeof h, B_WRITE);
-               if (u.u_error)
-                       return;
-               esc = 0;
-               if (h.count==0) {
-                       esc++;
-                       h.count = h.ccount;
-               }
-               cp = xcp(gp, h.index);
-               if (cp==NULL)  {
-                       continue;
-               }
-               ucount = u.u_count;
-               ubase = u.u_base;
-               u.u_count = h.count;
-               u.u_base = h.data;
-
-               if (esc==0) {
-                       struct tty *tp;
-                       caddr_t waddr;
-                       int line;
-
-                       if (cp->c_flags&PORT) {
-                               line = cp->c_line;
-                               tp = cp->c_ttyp;
-                       } else {
-                               line = cp->c_oline;
-                               tp = cp->c_ottyp;
-                       }
-               loop:
-                       waddr = (caddr_t)(*linesw[line].l_write)(tp);
-                       if (u.u_count) {
-                               if (gp->g_state&ENAMSG) {
-                                       burpcount++;
-                                       cp->c_flags |= BLKMSG;
-/*
-                                       scontrol(cp, M_BLK, u.u_count);
-*/
-                                       h.ccount = -1;
-                                       h.count = u.u_count;
-                                       h.data = u.u_base;
-                                       copyout((caddr_t)&h, hbase, sizeof h);
-                               } else {
-                                       if (waddr==0) {
-                                               u.u_error = ENXIO;
-                                               return;
-                                       }
-                                       sleep(waddr, TTOPRI);
-                                       goto loop;
-                               }
-                       }
-               } else
-                       mxwcontrol(cp); 
-               u.u_count = ucount;
-               u.u_base = ubase;
-       }
-       u.u_count = burpcount;
-}
-
-
-
-/*
- * Mcread and mcwrite move data on an mpx file.
- * Transfer addr and length is controlled by mxread/mxwrite.
- * Kernel-to-Kernel and other special transfers are not
- * yet in.
- */
-mcread(cp)
-register struct chan *cp;
-{
-register struct clist *q;
-register char *np;
-
-int cc;
-
-       q = (cp->c_ctlx.c_cc) ? &cp->c_ctlx : &cp->cx.datq;
-       cc = mxmove(q, B_READ);
-
-       if (cp->c_flags&NMBUF && q == &cp->c_ctlx) {
-               np = mxnmbuf;
-               while (nmsize--)
-                       passc(*np++);
-               cp->c_flags &= ~NMBUF;
-               prele(mpxip);
-       }
-       if (cp->c_flags&PORT)
-               return(cp->c_ctlx.c_cc + cp->c_ttyp->t_rawq.c_cc); else
-               return(cp->c_ctlx.c_cc + cp->cx.datq.c_cc);
-
-}
-
-
-char *
-mcwrite(cp)
-register struct chan *cp;
-{
-register struct clist *q;
-register cc;
-int    s;
-
-       q = &cp->cy.datq;
-       while (u.u_count) {
-               s = spl6();
-               if (q->c_cc > HIQ || (cp->c_flags&EOTMARK)) {
-                       cp->c_flags |= SIGBLK;
-                       splx(s);
-                       break;
-               }
-               splx(s);
-               cc = mxmove(q, B_WRITE);
-       }
-       wakeup((caddr_t)q);
-       return((caddr_t)q);
-}
-
-
-/*
- * Msread and mswrite move bytes
- * between user and non-multiplexed channel.
- */
-msread(fmp, cp)
-register struct chan *cp;
-{
-register struct clist *q;
-int s;
-
-       q = (fmp&FMPX) ? &cp->cx.datq : &cp->cy.datq;
-       s = spl6();
-       while (q->c_cc == 0) {
-               if (cp->c_flags & EOTMARK) {
-                       cp->c_flags &= ~EOTMARK;
-                       if (cp->c_flags&ENAMSG)
-                               scontrol(cp, M_UBLK, 0);
-                       else {
-                               wakeup((caddr_t)cp);
-                               wakeup((caddr_t)q);
-                       }
-                       goto out;
-               }
-               if (cp->c_flags&WCLOSE) {
-                       u.u_error = ENXIO;
-                       goto out;
-               }
-               sleep((caddr_t)q,TTIPRI);
-       }
-       splx(s);
-       while (mxmove(q, B_READ) > 0)
-               ;
-       mxrstrt(cp, q, SIGBLK);
-       return;
-out:
-       splx(s);
-}
-
-
-mswrite(fmp, cp)
-register struct chan *cp;
-{
-register struct clist *q;
-register int cc;
-
-       q = (fmp&FMPX) ? &cp->cy.datq : &cp->cx.datq;
-       while (u.u_count) {
-
-               spl6();
-               if (cp->c_flags&WCLOSE) {
-               bad:
-                       signal(SIGPIPE, cp->c_pgrp);
-                       return;
-               }
-
-               while (q->c_cc>100) {
-                       if (cp->c_flags&WCLOSE)
-                               goto bad;
-                       sdata(cp);
-                       cp->c_flags |= BLOCK;
-                       sleep((caddr_t)q+1,TTOPRI);
-               }
-               spl0();
-               cc = mxmove(q, B_WRITE);
-               if (cc < 0)
-                       break;
-       }
-       if (fmp&FMPX) {
-               if (cp->c_flags&YGRP) 
-                       sdata(cp); else
-                       wakeup((caddr_t)q);
-       } else {
-               if (cp->c_flags&XGRP) 
-                       sdata(cp); else
-                       wakeup((caddr_t)q);
-       }
-}
-
-
-
-/*
- * move chars between clist and user space.
- */
-mxmove(q, dir)
-register struct clist *q;
-register dir;
-{
-register cc;
-char buf[HIQ];
-
-       cc = MIN(u.u_count, sizeof buf);
-       if (dir == B_READ) 
-               cc = q_to_b(q, buf, cc);
-       if (cc <= 0)
-               return(cc);
-       iomove((caddr_t)buf, cc, dir);
-       if (dir == B_WRITE)
-               cc = b_to_q(buf, cc, q);
-       return(cc);
-}
-
-
-
-mxrstrt(cp, q, b)
-register struct chan *cp;
-register struct clist *q;
-register b;
-{
-int s;
-
-       s = spl6();
-       if (cp->c_flags&b && q->c_cc<LOQ) {
-               cp->c_flags &= ~b;
-               if (b&ALT)
-                       wakeup((caddr_t)q+1); else
-                       mcstart(cp, (caddr_t)q);
-       }
-       if (cp->c_flags&WFLUSH)
-               wakeup((caddr_t)q+2);
-       splx(s);
-}
-
-
-
-/*
- * called from driver start or xint routines
- * to wakeup output sleeper.
- */
-mcstart(cp, q)
-register struct chan *cp;
-register caddr_t q;
-{
-
-       if (cp->c_flags&(BLKMSG)) {
-               cp->c_flags &= ~BLKMSG;
-               scontrol(cp, M_UBLK, 0);
-       } else
-               wakeup((caddr_t)q);
-}
-
-
-mxwcontrol(cp)
-register struct chan *cp;
-{
-short  cmd[2];
-int    s;
-
-       iomove((caddr_t)cmd, sizeof cmd, B_WRITE);
-       switch(cmd[0]) {
-       /*
-        * not ready to queue this up yet.
-        */
-       case M_EOT:
-               s = spl6();
-               while (cp->c_flags & EOTMARK)
-                       if (cp->c_flags&ENAMSG) {
-                               scontrol(cp, M_BLK, 0);
-                               goto out;
-                       } else
-                               sleep((caddr_t)cp, TTOPRI);
-               cp->c_flags |= EOTMARK;
-       out:
-               splx(s);
-               break;
-       case M_IOCTL:
-printf("M_IOCTL");
-               break;
-       default:
-               u.u_error = ENXIO;
-       }
-}
-
-
-
-
-
-
-
-
-mxioctl(dev, cmd, addr, flag)
-caddr_t addr;
-{
-struct group *gp;
-int fmp;
-struct file *fp;
-
-       if ((gp = getmpx(dev)) == NULL) {
-bad:
-               u.u_error = ENXIO;
-               return;
-       }
-
-       fp = getf(u.u_arg[0]);
-       if (fp==NULL)
-               goto bad;
-
-       fmp = fp->f_flag & FMP;
-
-       if (fmp == FMP) {
-               switch(cmd) {
-               case MXLSTN:
-                       if (mpxip == NULL) {
-                               mpxip = gp->g_inode;
-                       } else
-                               goto bad;
-                       break;
-               case MXNBLK:
-                       gp->g_state |= ENAMSG;
-                       break;
-               default:
-                       goto bad;
-               }
-       }
-}
-
-
-
-
-chdrain(cp)
-register struct chan *cp;
-{
-register struct tty *tp;
-int wflag;
-
-       chwake(cp);
-
-       wflag = (cp->c_flags&WCLOSE)==0;
-       tp = cp->c_ttyp;
-       if (tp == NULL)         /* prob not required */
-               return;
-       if (cp->c_flags&PORT && tp->t_chan == cp) {
-               cp->c_ttyp = NULL;
-               tp->t_chan = NULL;
-               return;
-       }
-       if (wflag) 
-               wflush(cp,&cp->cx.datq); else
-               flush(&cp->cx.datq);
-       if (!(cp->c_flags&YGRP)) {
-               flush(&cp->cy.datq);
-       }
-}
-
-chwake(cp)
-register struct chan *cp;
-{
-register char *p;
-
-       wakeup((caddr_t)cp);
-       flush(&cp->c_ctlx);
-       p = (char *)&cp->cx.datq;
-       wakeup((caddr_t)p); wakeup((caddr_t)++p); wakeup((caddr_t)++p);
-       p = (char *)&cp->cy.datq;
-       wakeup((caddr_t)p); wakeup((caddr_t)++p); wakeup((caddr_t)++p);
-}
-
-
-chfree(cp)
-register struct chan *cp;
-{
-register struct group *gp;
-register i;
-
-       gp = cp->c_group;
-       if (gp==NULL)
-               return;
-       i = cp->c_index;
-       if (cp == gp->g_chans[i]) {
-               gp->g_chans[i] = NULL;
-       }
-       cp->c_group = NULL;
-}
-
-
-flush(q)
-register struct clist *q;
-{
-
-       while(q->c_cc)
-               getc(q);
-}
-
-
-wflush(cp,q)
-register struct chan *cp;
-register struct clist *q;
-{
-register s;
-
-       s = spl6();
-       while(q->c_cc) {
-               if (cp->c_flags & WCLOSE) {
-                       flush(q);
-                       goto out;
-               }
-               cp->c_flags |= WFLUSH;
-               sdata(cp);
-               sleep((caddr_t)q+2,TTOPRI);
-       }
-out:
-       cp->c_flags &= ~WFLUSH;
-       splx(s);
-}
-
-
-scontrol(cp,event,value)
-register struct chan *cp;
-short event,value;
-{
-register struct clist *q;
-int s;
-
-       q = &cp->c_ctlx;
-       s = spl6();
-       if (sdata(cp) == NULL)
-               return;
-       putw(event,q);
-       putw(value,q);
-       splx(s);
-}
-
-sdata(cp)
-register struct chan *cp;
-{
-register struct group *gp;
-register short x;
-register struct group *lgp;
-int s;
-
-       gp = cp->c_group;
-       if (gp==NULL) {
-               return(0);
-       }
-       x = cp->c_index;
-
-       s = spl6();
-       while (gp) {
-               if ((gp->g_state&ISGRP)==0) {
-                       return(0);
-               }
-               gp->g_datq |= cmask[x];
-               x = gp->g_index;
-               lgp = gp;
-               gp = gp->g_group;
-       }
-       gp =  lgp;
-       splx(s);
-       wakeup((caddr_t)&gp->g_datq);
-       return((int)gp);
-}
-
-
-
-struct chan *
-xcp(gp, x)
-register struct group *gp;
-register short x;
-{
-register i;
-
-       i = 0;
-       while (i<NLEVELS && gp->g_state&ISGRP) {
-               gp = (struct group *)gp->g_chans[x&017];
-               x >>= 4;
-               if ((x&017) >= NINDEX)
-                       break;
-               i++;
-       }
-       return((struct chan *)gp);
-}
-
-cpx(cp)
-register struct chan *cp;
-{
-register x;
-register struct group *gp;
-
-       if (cp==NULL)
-               return(-1);
-       x = (-1<<4) + cp->c_index;
-       gp = cp->c_group;
-       if (gp==NULL || (gp->g_state&ISGRP)==0)
-               return(-1);
-       gp = gp->g_group;
-       while (gp && gp->g_state&ISGRP) {
-               x <<= 4;
-               x |= gp->g_index;
-               gp = gp->g_group;
-       }
-       return(x);
-}
-
-
-
-struct chan *
-nextcp(gp)
-register struct group *gp;
-{
-
-       if (gp->g_datq == 0) {
-               gp = NULL;
-               goto out;
-       }
-
-       while (gp != NULL && gp->g_state&ISGRP) {
-               while ( (gp->g_datq & gp->g_rotmask) == 0) {
-                       gp->g_rot++;
-                       gp->g_rot &= 017;
-                       if (gp->g_rot)
-                               gp->g_rotmask <<= 1; else
-                               gp->g_rotmask = 1;
-               }
-               gp = (struct group *)gp->g_chans[gp->g_rot];
-       }
-       if (gp)
-               rmdata(gp);
-out:
-       return((struct chan *)gp);
-}
-
-rmdata(cp)
-register struct chan *cp;
-{
-register struct group *gp;
-register short x;
-
-       gp = cp->c_group;
-       x = cp->c_index;
-
-       while (gp) {
-               gp->g_datq &= ~cmask[x];
-               if (gp->g_datq)
-                       return;
-               x = gp->g_index;
-               gp = gp->g_group;
-       }
-}
-
-
-
-
-
-mcrint(c, tp)
-struct tty *tp;
-{
-}
-
-mcxint(tp)
-struct tty *tp;
-{
-}
-/*
-prstuff(s,cc)
-register char *s;
-register cc;
-{
-       while (cc--)
-               printf("%o ",*s++&0377);
-}
-
-prascii(s, cc)
-register char *s;
-register cc;
-{
-register c;
-       while (cc--) {
-               c = *s++;
-               if (c>=040 && c<=0176)
-                       putchar(c); else
-                       printf(" %o ", c&0377);
-       }
-}
-*/
diff --git a/usr/sys/dev/partab.c b/usr/sys/dev/partab.c
deleted file mode 100644 (file)
index 44628c4..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- */
-
-char partab[] = {
-       0001,0201,0201,0001,0201,0001,0001,0201,
-       0202,0004,0003,0201,0005,0206,0201,0001,
-       0201,0001,0001,0201,0001,0201,0201,0001,
-       0001,0201,0201,0001,0201,0001,0001,0201,
-       0200,0000,0000,0200,0000,0200,0200,0000,
-       0000,0200,0200,0000,0200,0000,0000,0200,
-       0000,0200,0200,0000,0200,0000,0000,0200,
-       0200,0000,0000,0200,0000,0200,0200,0000,
-       0200,0000,0000,0200,0000,0200,0200,0000,
-       0000,0200,0200,0000,0200,0000,0000,0200,
-       0000,0200,0200,0000,0200,0000,0000,0200,
-       0200,0000,0000,0200,0000,0200,0200,0000,
-       0000,0200,0200,0000,0200,0000,0000,0200,
-       0200,0000,0000,0200,0000,0200,0200,0000,
-       0200,0000,0000,0200,0000,0200,0200,0000,
-       0000,0200,0200,0000,0200,0000,0000,0201
-};
diff --git a/usr/sys/dev/pk0.c b/usr/sys/dev/pk0.c
deleted file mode 100644 (file)
index c9f7fb1..0000000
+++ /dev/null
@@ -1,683 +0,0 @@
-#define        KERNEL  1
-#include "../h/pk.p"
-
-/*
- * packet driver
- */
-
-char next[8]   ={ 1,2,3,4,5,6,7,0};    /* packet sequence numbers */
-char mask[8]   ={ 1,2,4,010,020,040,0100,0200 };
-
-struct pack *pklines[NPLINES];
-
-
-/*
- * receive control messages
- */
-
-pkcntl(cntl, pk)
-register cntl;
-register struct pack *pk;
-{
-register val;
-register m;
-
-       val = cntl & MOD8;
-
-       if ( NOTCNTL(cntl) ) {
-               pkbadframe(pk);
-               return;
-       }
-
-       cntl >>= 3;
-       pk->p_state &= ~BADFRAME;
-       m = pk->p_msg;
-
-       switch(cntl) {
-
-       case INITB:
-               val++;
-               pk->p_xsize = pksizes[val];
-               pk->p_lpsize = val;
-               pk->p_bits = DTOM(pk->p_xsize);
-               if (pk->p_state & LIVE) {
-                       pk->p_msg |= M_INITC;
-                       break;
-               }
-               pk->p_state |= INITb;
-               if ((pk->p_state & INITa)==0) {
-                       break;
-               }
-               pk->p_rmsg &= ~M_INITA;
-               pk->p_msg |= M_INITC;
-               break;
-
-       case INITC:
-               if ((pk->p_state&INITab)==INITab) {
-                       pk->p_state = LIVE;
-                       WAKEUP(&pk->p_state);
-                       pk->p_rmsg &= ~(M_INITA|M_INITB);
-               } else
-                       if ((pk->p_state&LIVE)==0)
-                               pk->p_msg |= M_INITB;
-               if (val)
-                       pk->p_swindow = val;
-               break;
-       case INITA:
-               if (val==0 && pk->p_state&LIVE) {
-                       printf("alloc change\n");
-                       break;
-               }
-               if (val) {
-                       pk->p_state |= INITa;
-                       pk->p_msg |= M_INITB;
-                       pk->p_rmsg |= M_INITB;
-                       pk->p_swindow = val;
-               }
-               break;
-       case RJ:
-               pk->p_state |= RXMIT;
-               pk->p_msg |= M_RR;
-       case RR:
-               pk->p_rpr = val;
-               if (pksack(pk)==0) {
-                       WAKEUP(&pk->p_ps);
-               }
-               break;
-       case CLOSE:
-               pk->p_state = DOWN+RCLOSE;
-               pk->p_rmsg = 0;
-               WAKEUP(&pk->p_pr);
-               WAKEUP(&pk->p_ps);
-               WAKEUP(&pk->p_state);
-               return;
-       }
-       if (pk->p_msg==0)
-               pk->p_msg |= pk->p_rmsg;
-
-
-       if (m==0 && pk->p_msg)
-               pkoutput(pk);
-}
-
-
-/*
- * Send RJ message on first framing error.
- * Cleared by receiving a good frame 
- * (pkcntl or pkdata).
- */
-pkbadframe(pk)
-register struct pack *pk;
-{
-       WAKEUP(&pk->p_pr);
-       if (pk->p_state & BADFRAME)
-               return;
-       pk->p_state |= BADFRAME;
-       pk->p_timer = 2;
-}
-
-
-
-
-/*
- * Look at sequence numbers (mostly).
- */
-pkaccept(pk)
-register struct pack *pk;
-{
-register x, seq;
-char m, cntl, *p, imask, **bp;
-int bad, accept, skip, s, t, cc;
-unsigned short sum;
-
-       bad = accept = skip = 0;
-       /*
-        * wait for input
-        */
-       LOCK;
-       x = next[pk->p_pr];
-       if((imask=pk->p_imap)==0 && pk->p_rcount==0) {
-               UNLOCK;
-               goto out;
-       }
-       pk->p_imap = 0;
-       UNLOCK;
-
-
-       /*
-        * determine input window in m.
-        */
-       t = (~(-1<<pk->p_rwindow)) <<x;
-       m = t;
-       m |= t>>8;
-
-
-       /*
-        * mark newly accepted input buffers
-        */
-       for(x=0; x<8; x++) {
-
-               if ((imask & mask[x]) == 0)
-                       continue;
-
-               if (((cntl=pk->p_is[x])&0200)==0) {
-                       bad++;
-free:
-                       bp = (char **)pk->p_ib[x];
-                       LOCK;
-                       *bp = (char *)pk->p_ipool;
-                       pk->p_ipool = bp;
-                       pk->p_is[x] = 0;
-                       UNLOCK;
-                       continue;
-               }
-
-               pk->p_is[x] = ~(B_COPY+B_MARK);
-               sum = (unsigned)chksum(pk->p_ib[x], pk->p_rsize) ^ (unsigned)cntl;
-               sum += pk->p_isum[x];
-               if (sum == CHECK) {
-                       seq = (cntl>>3) & MOD8;
-                       if (m & mask[seq]) {
-                               if (pk->p_is[seq] & (B_COPY | B_MARK)) {
-                               dup:
-                                       skip++;
-                                       goto free;
-                               }
-                               if (x != seq) {
-                                       LOCK;
-                                       p = pk->p_ib[x];
-                                       pk->p_ib[x] = pk->p_ib[seq];
-                                       pk->p_is[x] = pk->p_is[seq];
-                                       pk->p_ib[seq] = p;
-                                       UNLOCK;
-                               }
-                               pk->p_is[seq] = B_MARK;
-                               accept++;
-                               cc = 0;
-                               if (cntl&B_SHORT) {
-                                       pk->p_is[seq] = B_MARK+B_SHORT;
-                                       p = pk->p_ib[seq];
-                                       cc = (unsigned)*p++;
-                                       if (cc & 0200) {
-                                               cc &= 0177;
-                                               cc |= *p << 7;
-                                       }
-                               }
-                               pk->p_isum[seq] = pk->p_rsize - cc;
-                       } else {
-                               goto dup;
-                       }
-               } else {
-                       bad++;
-                       goto free;
-               }
-       }
-
-       /*
-        * scan window again turning marked buffers into
-        * COPY buffers and looking for missing sequence
-        * numbers.
-        */
-       accept = 0;
-       for(x=next[pk->p_pr],t= -1; m & mask[x]; x = next[x]) {
-               if (pk->p_is[x] & B_MARK)
-                       pk->p_is[x] |= B_COPY;
-               if (pk->p_is[x] & B_COPY) {
-                       if (t >= 0) {
-                               bp = (char **)pk->p_ib[x];
-                               LOCK;
-                               *bp = (char *)pk->p_ipool;
-                               pk->p_ipool = bp;
-                               pk->p_is[x] = 0;
-                               UNLOCK;
-                               skip++;
-                       } else 
-                               accept++;
-               } else {
-                       if (t<0)
-                               t = x;
-               }
-       }
-
-       if (bad) {
-               pk->p_msg |= M_RJ;
-       } else 
-
-       if (skip) {
-               pk->p_msg |= M_RR;
-       }
-
-       pk->p_rcount = accept;
-out:
-       if (pk->p_msg)
-               pkoutput(pk);
-       return(accept);
-}
-
-
-pkread(S)
-SDEF;
-{
-register struct pack *pk;
-register x,s;
-int is,cc,xfr,count;
-char *cp, **bp;
-
-       pk = PADDR;
-       xfr = 0;
-       count = -1;
-       while (pkaccept(pk) == 0) {
-               PKGETPKT(pk);
-               if (pk->p_state&DOWN) {
-                       SETERROR;
-                       goto out;
-               }
-               if (SLEEPNO) {
-                       count++;
-                       goto out;
-               }
-               SLEEP(&pk->p_pr, PKIPRI);
-       }
-       count = 0;
-
-
-       while (UCOUNT) {
-
-               x = next[pk->p_pr];
-               is = pk->p_is[x];
-
-               if (is & B_COPY) {
-                       cc = MIN(pk->p_isum[x], UCOUNT);
-                       if (cc==0 && xfr) {
-                               break;
-                       }
-                       if (is & B_RESID)
-                               cp = pk->p_rptr;
-                       else {
-                               cp = pk->p_ib[x];
-                               if (is & B_SHORT) {
-                                       if (*cp++ & 0200)
-                                               *cp++;
-                               }
-                       }
-                       IOMOVE(cp,cc,B_READ);
-                       count += cc;
-                       xfr++;
-                       pk->p_isum[x] -= cc;
-                       if (pk->p_isum[x] == 0) {
-                               LOCK;
-                               pk->p_pr = x;
-                               bp = (char **)pk->p_ib[x];
-                               *bp = (char *)pk->p_ipool;
-                               pk->p_ipool = bp;
-                               pk->p_is[x] = 0;
-                               pk->p_rcount--;
-                               UNLOCK;
-                               pk->p_msg |= M_RR;
-                       } else {
-                               pk->p_rptr = cp+cc;
-                               pk->p_is[x] |= B_RESID;
-                       }
-                       if (cc==0)
-                               break;
-               } else
-                       break;
-       }
-       pkoutput(pk);
-       if (SLEEPNO)
-               count = pk->p_rcount;
-out:
-       return(count);
-}
-
-
-
-
-pkwrite(S)
-SDEF;
-{
-register struct pack *pk;
-register x;
-int partial;
-caddr_t cp;
-int cc, s, fc, count;
-int pktimeout();
-
-       pk = PADDR;
-       if ((pk->p_state&LIVE)==0) {
-       down:
-               SIGNAL;
-               SETERROR;
-               return(-1);
-       }
-
-       count = UCOUNT;
-       do {
-               LOCK;
-               while (pk->p_xcount>=pk->p_swindow)  {
-                       pkoutput(pk);
-                       PKGETPKT(pk);
-                       SLEEP(&pk->p_ps,PKOPRI);
-                       if (pk->p_state&DOWN)
-                               goto down;
-               }
-               x = next[pk->p_pscopy];
-               while (pk->p_os[x]!=B_NULL)  {
-                       goto down;
-               }
-               pk->p_os[x] = B_MARK;
-               pk->p_pscopy = x;
-               pk->p_xcount++;
-               UNLOCK;
-
-               cp = pk->p_ob[x] = (char *)GETEPACK;
-               partial = 0;
-               if ((int)UCOUNT < pk->p_xsize) {
-                       cc = UCOUNT;
-                       fc = pk->p_xsize - cc;
-                       *cp = fc&0177;
-                       if (fc > 127) {
-                               *cp++ |= 0200;
-                               *cp++ = fc>>7;
-                       } else
-                               cp++;
-                       partial = B_SHORT;
-               } else
-                       cc = pk->p_xsize;
-               IOMOVE(cp,cc,B_WRITE);
-               pk->p_osum[x] = chksum(pk->p_ob[x], pk->p_xsize);
-               pk->p_os[x] = B_READY+partial;
-               pkoutput(pk);
-       } while (UCOUNT);
-
-       return(count-UCOUNT);
-}
-
-pksack(pk)
-register struct pack *pk;
-{
-register x, i;
-int s;
-
-       i = 0;
-       LOCK;
-       for(x=pk->p_ps; x!=pk->p_rpr; ) {
-               x = next[x];
-               if (pk->p_os[x]&B_SENT) {
-                       i++;
-                       FREEPACK(pk->p_ob[x], pk->p_bits);
-                       pk->p_os[x] = B_NULL;
-                       pk->p_state &= ~WAITO;
-                       pk->p_xcount--;
-                       pk->p_ps = x;
-                       WAKEUP(&pk->p_ps);
-               }
-       }
-       UNLOCK;
-       return(i);
-}
-
-
-
-pkoutput(pk)
-register struct pack *pk;
-{
-register x;
-int s;
-char bstate;
-int i;
-SDEF;
-extern pkzot;
-
-       ISYSTEM;
-       LOCK;
-       if (OBUSY) {
-               UNLOCK;
-               return;
-       }
-
-
-       /*
-        * find seq number and buffer state
-        * of next output packet
-        */
-       if (pk->p_state&RXMIT)  {
-               pk->p_nxtps = next[pk->p_rpr];
-               pk->p_state &= ~RXMIT;
-       }
-       x = pk->p_nxtps;
-       bstate = pk->p_os[x];
-
-
-       /*
-        * Send control packet if indicated
-        */
-       if (pk->p_msg) {
-               if (pk->p_msg & ~M_RR || !(bstate&B_READY) ) {
-                       x = pk->p_msg;
-                       for(i=0; i<8; i++) 
-                               if (x&1)
-                                       break; else
-                               x >>= 1;
-                       x = i;
-                       x <<= 3;
-                       switch(i) {
-                       case CLOSE:
-                               break;
-                       case RJ:
-                       case RR:
-                               x += pk->p_pr;
-                               break;
-                       case SRJ:
-                               break;
-                       case INITB:
-                               x += pksize(pk->p_rsize);
-                               break;
-                       case INITC:
-                               x += pk->p_rwindow;
-                               break;
-                       case INITA:
-                               x += pk->p_rwindow;
-                               break;
-                       }
-
-                       pk->p_msg &= ~mask[i];
-                       pkxstart(pk, x, -1);
-                       goto out;
-               }
-       }
-
-
-       /*
-        * Don't send data packets if line is marked dead.
-        */
-       if (pk->p_state&DOWN || (pk->p_state&LIVE)==0) {
-               WAKEUP(&pk->p_ps);
-               goto out;
-       }
-       /*
-        * Start transmission (or retransmission) of data packets.
-        */
-       if (bstate & (B_READY|B_SENT)) {
-               char seq;
-
-               bstate |= B_SENT;
-               seq = x;
-               pk->p_nxtps = next[x];
-
-               x = 0200+pk->p_pr+(seq<<3);
-               if (bstate & B_SHORT)
-                       x |= 0100;
-               pkxstart(pk, x, seq);
-               if (pk->p_os[seq])
-                       pk->p_os[seq] = bstate;
-               pk->p_nout++;
-               goto out;
-       }
-       /*
-        * enable timeout if there's nothing to send
-        * and transmission buffers are languishing
-        */
-       if (pk->p_xcount) {
-               pk->p_timer = 10+pkzot;
-               pk->p_state |= WAITO;
-       } else
-               pk->p_state &= ~WAITO;
-       WAKEUP(&pk->p_ps);
-out:
-       pk->p_obusy = 0;
-       UNLOCK;
-}
-
-
-/*
- * shut down line by
- *     ignoring new input
- *     letting output drain
- *     releasing space and turning off line discipline
- */
-pkclose(S)
-SDEF;
-{
-register struct pack *pk;
-register i,s,rbits;
-char **bp;
-
-#define        NTRIES  1
-
-       pk = PADDR;
-       pk->p_state |= DRAINO;
-
-
-       /*
-        * try to flush output
-        */
-       i = 0;
-       LOCK;
-       if (pklive(pk)==0) {
-               pk->p_state = DOWN;
-               UNLOCK;
-               goto final;
-       }
-       pk->p_timer = 2;
-       while (pk->p_xcount && pk->p_state&LIVE) {
-               if (pk->p_state&(RCLOSE+DOWN) || ++i > NTRIES)
-                       break;
-               pkoutput(pk);
-               SLEEP(&pk->p_ps,PKOPRI);
-       }
-       pk->p_timer = 0;
-       pk->p_state |= DOWN;
-       UNLOCK;
-
-
-       /*
-        * try to exchange CLOSE messages
-        */
-       i = 0;
-       while ((pk->p_state&RCLOSE)==0 && i<NTRIES) {
-               pk->p_msg = M_CLOSE;
-               pk->p_timer = 2;
-               pkoutput(pk);
-               SLEEP(&pk->p_ps, PKOPRI);
-               i++;
-       }
-
-
-final:
-       TURNOFF;
-
-
-       /*
-        * free space
-        */
-       rbits = DTOM(pk->p_rsize);
-       for (i=0;i<8;i++) {
-               if (pk->p_os[i]!=B_NULL) {
-                       FREEPACK(pk->p_ob[i],pk->p_bits);
-                       pk->p_xcount--;
-               }
-               if (pk->p_is[i]!=B_NULL)  {
-                       FREEPACK(pk->p_ib[i],rbits);
-               }
-       }
-       LOCK;
-       while (pk->p_ipool != NULL) {
-               bp = pk->p_ipool;
-               pk->p_ipool = (char **)*bp;
-               FREEPACK((caddr_t)bp, rbits);
-       }
-       UNLOCK;
-       for(i=0;i<NPLINES;i++)
-               if (pklines[i]==pk)  {
-                       pklines[i] = NULL;
-               }
-       FREEPACK((caddr_t)pk, npbits);
-}
-
-
-
-pkreset(pk)
-register struct pack *pk;
-{
-
-       pk->p_ps = pk->p_pr =  pk->p_rpr = 0;
-       pk->p_nxtps = 1;
-}
-
-chksum(s,n)
-register char *s;
-register n;
-{
-       register short sum;
-       register unsigned t;
-       register x;
-
-       sum = -1;
-       x = 0;
-
-       do {
-               if (sum<0) {
-                       sum <<= 1;
-                       sum++;
-               } else
-                       sum <<= 1;
-               t = sum;
-               sum += (unsigned)*s++;
-               x += sum^n;
-               if ((unsigned)sum <= t) {
-                       sum ^= x;
-               }
-       } while (--n > 0);
-
-       return(sum);
-}
-
-pkline(pk)
-register struct pack *pk;
-{
-register i;
-       for(i=0;i<NPLINES;i++) {
-               if (pklines[i]==pk)
-                       return(i);
-       }
-       return(-i);
-}
-
-pkzero(s,n)
-register char *s;
-register n;
-{
-       while (n--)
-               *s++ = 0;
-}
-
-pksize(n)
-register n;
-{
-register k;
-
-       n >>= 5;
-       for(k=0; n >>= 1; k++);
-       return(k);
-}
diff --git a/usr/sys/dev/pk1.c b/usr/sys/dev/pk1.c
deleted file mode 100644 (file)
index 331cbbe..0000000
+++ /dev/null
@@ -1,265 +0,0 @@
-#define        KERNEL  1
-#include "../h/pk.p"
-
-
-/*
- * kernel support routines.
- */
-
-struct pack *pklines[NPLINES];
-int    maxwindow =2;
-
-/*
- * start initial synchronization.
- * allocate space.
- */
-pkopen(dev, tp, addr)
-register struct tty *tp;
-caddr_t addr;
-{
-register struct pack *pk;
-register i;
-int pktimeout();
-char **bp;
-static timer_on;
-int s;
-struct piocb   piocb;
-
-
-       if (tp->t_line)
-               return;
-       /*
-        * copy user parameters
-        */
-       if (copyin(addr, (caddr_t)&piocb, sizeof (piocb))) {
-               u.u_error = EFAULT;
-               return;
-       }
-       npbits = dtom(sizeof(struct pack));
-       pk = (struct pack *)getepack(npbits);
-       if (pk==NULL)
-               goto notsobad;
-       pkzero((caddr_t)pk,sizeof (struct pack));
-       pk->p_rwindow = piocb.window;
-       if (pk->p_rwindow > maxwindow)
-               pk->p_rwindow = maxwindow;
-       pk->p_rsize = piocb.psize;
-       if (pk->p_rsize > 512 || pk->p_rsize & 037)
-               goto notsobad;
-       pk->p_mode = piocb.mode;
-       if (pk->p_mode & 01)
-               pkdebug++;
-       /*
-        * try to allocate input window
-        */
-       pk->p_bits = dtom(pk->p_rsize);
-       for(i=0; i<pk->p_rwindow; i++) {
-               bp = (char **)getepack(pk->p_bits);
-               if (bp==NULL)
-                       break;
-               *bp = (char *)pk->p_ipool;
-               pk->p_ipool = bp;
-       }
-
-       if (i==0 && bp==NULL)
-               goto notsobad;
-       pk->p_rwindow = i;
-
-
-       /*
-        * start timer process,
-        * wait for synchronization.
-        */
-       flushtty(tp);
-       s = spl6();
-       pkdisc = tp->t_line = piocb.t;
-       pk->p_ttyp = tp;
-       tp->t_linep = (caddr_t)pk;
-       q2.c_cf = q2.c_cl = NULL;
-       q1.c_cf = q1.c_cl = (caddr_t)&pk->p_ihbuf;
-       q1.c_cc = -HDRSIZ;
-       if (tp->t_iproc != NULL)
-               (*tp->t_iproc)(tp);
-
-       pk->p_rmsg = M_INITA;
-       for(i=0; i<NPLINES; i++) {
-               if (pklines[i]==NULL) {
-                       pklines[i] = pk;
-                       goto found;
-               }
-       }
-       goto notsobad;
-found:
-       pk->p_timer++;
-       if (timer_on==0) {
-               timer_on++;
-               pktimeout();
-       }
-       splx(s);
-       SLEEP(&pk->p_state, PKOPRI);
-       pkreset(pk);
-
-       if ((pk->p_state&LIVE)==0) {
-               pk->p_state = DOWN;
-               pk->p_rmsg = 0;
-notsobad:
-               u.u_error = ENXIO;
-               return;
-       }
-
-       pksetgrp(tp);
-       pkioctl(DIOCGETP, tp, addr);
-
-}
-
-
-
-
-/*
- * unix ioctl interface
- */
-pkioctl(com,tp,addr)
-register struct tty *tp;
-caddr_t addr;
-{
-struct piocb piocb;
-register struct pack *pk;
-
-       pk = (struct pack *)tp->t_linep;
-       if (com == DIOCGETP) {
-               piocb.window = pk->p_swindow;
-               piocb.psize  = pk->p_xsize;
-               piocb.state  = pk->p_state;
-               if (copyout((caddr_t)&piocb, addr, sizeof(piocb))) {
-                       u.u_error = EFAULT;
-               }
-               if (u.u_error==0)
-                       u.u_r.r_val1 = piocb.psize;
-       }
-}
-
-
-/*
- * Arrange for the device (i.e. tp)
- * to be able to generate signals if need be.
- */
-pksetgrp(tp)
-register struct tty *tp;
-{
-register struct proc *pp;
-
-       pp = u.u_procp;
-       if (pp->p_pgrp == 0)
-               pp->p_pgrp = pp->p_pid;
-       if (tp->t_pgrp == 0)
-               tp->t_pgrp = pp->p_pgrp;
-}
-
-
-
-/*
- * Shut down io.
- * The problem is mainly input since the
- * device driver may have a buffer.
- */
-pkturnoff(tp)
-register struct tty *tp;
-{
-register char **bp;
-register struct pack *pk;
-register s;
-
-       pk = PADDR;
-       LOCK;
-       bp = pk->p_io;
-       tp->t_line = 0;
-       q1.c_cf = NULL;
-       flushtty(tp);
-       if (bp!=NULL) {
-               *bp = (char *)pk->p_ipool;
-               pk->p_ipool = bp;
-       }
-       UNLOCK;
-}
-
-
-
-/*
- * link dead?
- */
-pklive(pk)
-register struct pack *pk;
-{
-register struct tty  *tp;
-
-       tp = pk->p_ttyp;
-       if (tp->t_line!=pkdisc || tp->t_linep!=(caddr_t)pk) {
-               return(0);
-       }
-       return(tp->t_state&CARR_ON);
-}
-
-
-
-/*
- * timeout process:
- * wakes up periodically to check status
- * of active lines.
- */
-pktimeout()
-{
-register struct pack *pk;
-extern time_t time;
-register i;
-
-       for(i=0;i<NPLINES;i++) {
-               if ((pk=pklines[i])==NULL)
-                       continue;
-               if (pk->p_nout == pk->p_tout) {
-                       if (pk->p_xcount && pk->p_timer==0) {
-                               pk->p_timer = 3;
-                               pk->p_state |= WAITO;
-                       }
-               } else
-                       pk->p_tout = pk->p_nout;
-               if (pk->p_timer==0) {
-                       if (pk->p_state & BADFRAME) {
-                               pk->p_msg |= M_RJ;
-                               pk->p_state &= ~BADFRAME;
-                               goto startup;
-                       }
-                       if (pk->p_rmsg)
-                               goto startup;
-                       WAKEUP(&pk->p_ps);
-                       continue;
-               }
-               if (--pk->p_timer == 0) {
-                       if ((pk->p_state&LIVE)==0) {
-                       startup:
-                               pk->p_timer = 1;
-                       } else
-                       if (pk->p_state & WAITO) {
-                               if (pk->p_state&DRAINO)  {
-                                       pk->p_state |= DOWN; 
-                               } else {
-                                       pk->p_state |= RXMIT;
-                               }
-                               pkoutput(pk);
-                               pk->p_timer = 5+2*pkzot;
-                       }
-                       WAKEUP(&pk->p_ps);
-                       pk->p_msg |= pk->p_rmsg;
-                       if (pk->p_msg)
-                               pkoutput(pk);
-               }
-       }
-       timeout(pktimeout, (caddr_t)pk, 60);
-
-
-       /*
-        * randomize timeouts.
-        */
-       pkzot = 2 + time&07;
-}
-
-
diff --git a/usr/sys/dev/pk2.c b/usr/sys/dev/pk2.c
deleted file mode 100644 (file)
index a8be80c..0000000
+++ /dev/null
@@ -1,265 +0,0 @@
-#define        KERNEL  1
-#include "../h/pk.p"
-
-/*
- * input framing and block checking.
- * frame layout for most devices is:
- *     
- *     S|K|X|Y|C|Z|  ... data ... |
- *
- *     where   S       == initial synch byte
- *             K       == encoded frame size (indexes pksizes[])
- *             X, Y    == block check bytes
- *             C       == control byte
- *             Z       == XOR of header (K^X^Y^C)
- *             data    == 0 or more data bytes
- *
- * device driver interfaces on input are:
- *     pkrint  - byte level
- *     pkrend  - dma or pseudo-dma transfer level
- *     pkdata - packet level
- */
-
-int pksizes[] ={
-       1, 32, 64, 128, 256, 512, 1024, 2048, 4096, 1
-};
-
-/*
- * Pseudo-dma byte collection.
- * This code can be put in the device driver
- * interrupt routine to eliminate the per byte
- * subroutine call.
- */
-pkrint(c, tp)
-register c;
-register struct tty *tp;
-{
-
-       if (q1.c_cc<0) {
-               if (q1.c_cf != NULL) {
-                       tp->t_erase = 0;
-                       *q1.c_cf++ = c;
-               }
-               if (++q1.c_cc)
-                       return;
-               pkrend(tp);
-               return;
-       }
-}
-
-
-
-/*
- * End of input transfer.
- */
-pkrend(tp)
-register struct tty *tp;
-{
-register char *p;
-struct pack *pk;
-struct header *h;
-register x;
-char   cntl, hdcheck;
-unsigned short sum;
-int i,j,k;
-char **bp;
-
-       p = q1.c_cl;
-       x = (int)q1.c_cf - (int)p;
-       pk = (struct pack *)tp->t_linep;
-       h = (struct header * )&pk->p_ihbuf;
-       if (x == HDRSIZ) {
-               if (*p++ == SYN ) {
-                       hdcheck = k = *p++;
-                       sum = (unsigned)*p;
-                       hdcheck ^= *p++;
-                       sum |= (unsigned)*p << 8;
-                       hdcheck ^= *p++;
-                       hdcheck ^= cntl = *p++;
-                       if (hdcheck != *p) {
-                               goto bad;
-                       }
-                       if (k == 9) {
-                               pkcntl(cntl, pk);
-                               q1.c_cf = q1.c_cl;
-                               q1.c_cc = -HDRSIZ;
-                               goto istart1;
-                       }
-                       if (k && pksizes[k]==pk->p_rsize) {
-                               pk->p_rpr = cntl&MOD8;
-                               pksack(pk);
-                               bp = pk->p_ipool;
-                               if (bp) {
-                                       pk->p_ipool = (char **)*bp;
-                                       pk->p_io = bp;
-                               } else {
-                               }
-                               q1.c_cf = (char *)bp;
-                               q1.c_cc = -pk->p_rsize;
-                               h->sum = sum;
-                               h->cntl = cntl;
-                               goto istart1;
-                       }
-bad:
-                       pkbadframe(pk);
-               }
-scan:
-               x = HDRSIZ;
-               j = 0;
-               p = (caddr_t)h;
-               for (i = 1; i < HDRSIZ; i++)
-                       if (p[i] == SYN)
-                               for(x=i; i<HDRSIZ; i++,j++)
-                                       p[j] = p[i];
-
-               q1.c_cc = -x;
-               q1.c_cf = (caddr_t)((int)p + j);
-               goto istart2;
-       }
-       if (x == pk->p_rsize) {
-               pkdata(h->cntl, h->sum, pk, q1.c_cl);
-               pk->p_io = NULL;
-               q1.c_cf = (char *)h;
-               q1.c_cc = -HDRSIZ;
-               goto istart1;
-       }
-       if (x == 0) {
-               q1.c_cf = (char *)h;
-               q1.c_cc = -HDRSIZ;
-               pkbadframe(pk);
-       } else {
-               pkbadframe(pk);
-               goto scan;
-       }
-istart1:
-       q1.c_cl = q1.c_cf;
-istart2:
-       if (tp->t_iproc != NULL)
-               (*tp->t_iproc)(tp);
-}
-
-
-
-/*
- * Put packet located at address bp
- * in an input slot for further processing.
- */
-pkdata(c, sum, pk, cp)
-char c;
-unsigned short sum;
-register struct pack *pk;
-char *cp;
-{
-register struct tty *tp;
-register x;
-char **bp;
-int t;
-
-       pk->p_state &= ~BADFRAME;
-       bp = (char **)cp;
-       tp = pk->p_ttyp;
-       if (pk->p_state&DRAINO || !(pk->p_state&LIVE)) {
-               pk->p_msg |= pk->p_rmsg;
-               pkoutput(pk);
-               goto drop;
-       }
-       t = next[pk->p_pr];
-       for(x=pk->p_pr; x!=t; x = (x-1)&7) {
-               if (pk->p_is[x] == 0)
-                       goto slot;
-       }
-       /*
-        * this can't happen
-        */
-       printf("no slot\n");
-drop:
-       *bp = (char *)pk->p_ipool;
-       pk->p_ipool = bp;
-       return;
-
-slot:
-       pk->p_imap |= mask[x];
-       pk->p_is[x] = c;
-       pk->p_isum[x] = sum;
-       pk->p_ib[x] = cp;
-       if (tp->t_chan)
-               sdata(tp->t_chan); else
-               wakeup(&pk->p_pr);
-}
-
-
-/*
- * Start transmission on output device associated with pk.
- * For asynch devices (t_line==1) framing is
- * imposed.  For devices with framing and crc
- * in the driver (t_line==2) the transfer is
- * passed on to the driver.
- */
-pkxstart(pk, cntl, x)
-struct pack *pk;
-char cntl;
-register x;
-{
-struct tty *tp;
-register char *p;
-short checkword;
-char hdcheck;
-
-       p = (caddr_t)&pk->p_ohbuf;
-       tp = pk->p_ttyp;
-
-       if (tp->t_line==1) {
-               *p++ = SYN;
-               if (x < 0) {
-                       *p = 9;
-                       checkword = cntl;
-                       q3.c_cl = NULL;
-               } else {
-                       *p = pk->p_lpsize;
-                       checkword = pk->p_osum[x] ^ (unsigned)cntl;
-                       q3.c_cl = pk->p_ob[x];
-               }
-               checkword = CHECK - checkword;
-               hdcheck = *p++;
-               hdcheck ^= *p++ = checkword;
-               hdcheck ^= *p++ = checkword>>8;
-               q3.c_cc = -HDRSIZ;
-       } else {
-               q3.c_cc = -1;
-       }
-
-       hdcheck ^= *p++ = cntl;
-       *p = hdcheck;
-       q3.c_cf = (caddr_t)&pk->p_ohbuf;
-/*
-       pk->p_srxmit++;
-*/
-       (*tp->t_oproc)(tp);
-}
-
-/*
- * transmitter interrupt.
- */
-int    pkdelay = 2;
-
-pkxint(tp)
-register struct tty *tp;
-{
-register struct pack *pk;
-register s;
-extern int pkoutput();
-
-       pk = (struct pack *)tp->t_linep;
-       s = spl6();
-       tp->t_state &= ~BUSY;
-       if (q3.c_cl == NULL) {
-                       pkoutput(pk);
-       } else {
-               q3.c_cf = q3.c_cl;
-               q3.c_cl = NULL;
-               q3.c_cc = -pk->p_xsize;
-               (*tp->t_oproc)(tp);
-       }
-       splx(s);
-}
-
diff --git a/usr/sys/dev/pk3.c b/usr/sys/dev/pk3.c
deleted file mode 100644 (file)
index ac42a35..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/conf.h"
-#include "../h/buf.h"
-
-#define        XPRI    30
-#define        NBLOCKS 10
-
-int    bwaiting, wcount;
-struct buf *bufps[NBLOCKS];
-char   *nbase[NBLOCKS];        /* normal allocations */
-short  nmap[NBLOCKS];          /* 1 bit == 32 bytes */
-
-char log[] ={0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4};
-#define        FULL    -1
-#define        LOCK    s = spl6()
-#define        UNLOCK  splx(s)
-
-/*
- * getepack: get empty packet
- * with size specified by bitmask.
- */
-char *
-getepack(bits)
-{
-register i;
-int    s, savbits;
-char   **base;
-short  *map;
-
-       base = nbase; map = nmap;
-       savbits = bits;
-
-       /*
-        * search for space
-        */
-       LOCK;
-       for(;;) {
-
-               if (bits == FULL)
-                       goto force;
-
-               for(i=0; i<NBLOCKS; i++) {
-                       register m;
-                       register unsigned n;
-                       register offset;
-
-                       m = map[i];
-                       if (m==FULL || base[i]==NULL)
-                               continue;
-                       if (bits == 1) {
-                               n = m;
-                               m |= m+1;
-                               n = m-n;
-                               for (offset=0; n > 16; n >>= 4) 
-                                       offset += 4;
-                               offset += log[n];
-                       } else {
-                               bits = savbits;
-                               for(n=17; --n; bits <<= 1)
-                                       if ((m&bits)==0)
-                                               goto found;
-                               continue;
-                       found:
-                               offset = 16-n;
-                               m |= bits;
-                       }
-                       map[i] = m;
-                       UNLOCK;
-                       return(base[i] + 32*offset);
-               }
-               /*
-                * grab another block from the system
-                */
-       force:
-               for(i=0;i<NBLOCKS;i++) {
-                       register struct buf *bp;
-
-                       if (bufps[i]!=NULL)
-                               continue;
-                       bufps[i] = bp = geteblk();
-                       bp->b_flags |= B_PACK;
-                       bp->b_flags |= B_PBUSY;
-                       map[i] = bits;
-                       base[i] = bp->b_un.b_addr;
-                       UNLOCK;
-                       return(bp->b_un.b_addr);
-               }
-               /*
-                * sleep until something is released
-                */
-               bwaiting++;
-               wcount++;
-               sleep((caddr_t)&bwaiting, XPRI);
-               bwaiting--;
-       }
-}
-
-/*
- * freepack: release space beginning
- * at address p with length specified
- * by bits.
- */
-freepack(p, bits)
-char *p;
-{
-register i, d, s;
-char   **base;
-short  *map;
-
-       if (p==NULL)
-               return;
-       LOCK;
-       base = nbase; map = nmap;
-
-       for(i=0;i<NBLOCKS;i++) {
-               d = p-base[i];
-               if (d>=0 && d<=512) 
-                       goto found;
-       }
-       goto out;
-found:
-       d >>= 5;
-       d = (bits<<d);
-       map[i] &= ~d;
-       if (map[i]==0) {
-               register struct buf *bp;
-
-               bp = bufps[i];
-               bp->b_flags &= ~B_PBUSY;
-               base[i] = NULL;
-               bufps[i] = NULL;
-               brelse(bp);
-       }
-       if (bwaiting)
-               wakeup((caddr_t)&bwaiting);
-out:
-       splx(s);
-}
-
-
-
-/*
- * integer to bitmap conversion
- */
-dtom(d)
-register d;
-{
-register m;
-
-       m = 1;
-       while (d>32) {
-               d -= 32;
-               m |= m+1;
-       }
-       return(m);
-}
-
-#define NRECS  160
-int reclist[NRECS];
-int recbits[NRECS];
-
diff --git a/usr/sys/dev/rf.c b/usr/sys/dev/rf.c
deleted file mode 100644 (file)
index ba06765..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-#
-/*
- * RF disk driver
- */
-
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/buf.h"
-#include "../h/conf.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-
-struct device {
-       int     rfcs;
-       int     rfwc;
-       char    *rfba;
-       int     rfda;
-       int     rfdae;
-};
-
-struct buf     rftab;
-struct buf     rrfbuf;
-
-#define        NRFBLK  1024
-#define RFADDR ((struct device *)0177460)
-
-#define        GO      01
-#define        RCOM    04
-#define        WCOM    02
-#define        CTLCLR  0400
-#define        IENABLE 0100
-
-/*
- * Monitoring device number
- */
-#define        DK_N    0
-
-rfstrategy(bp)
-register struct buf *bp;
-{
-       if(bp->b_flags&B_PHYS)
-               mapalloc(bp);
-       if (bp->b_blkno >= NRFBLK*(minor(bp->b_dev)+1)) {
-               bp->b_flags |= B_ERROR;
-               iodone(bp);
-               return;
-       }
-       bp->av_forw = 0;
-       spl5();
-       if (rftab.b_actf == NULL)
-               rftab.b_actf = bp;
-       else
-               rftab.b_actl->av_forw = bp;
-       rftab.b_actl = bp;
-       if (rftab.b_active == NULL)
-               rfstart();
-       spl0();
-}
-
-rfstart()
-{
-       register struct buf *bp;
-       register int com;
-
-       if ((bp = rftab.b_actf) == NULL)
-               return;
-       rftab.b_active++;
-       RFADDR->rfda = (int)(bp->b_blkno<<8)&0177777;
-       RFADDR->rfdae = (int)(bp->b_blkno>>8)&037;
-       RFADDR->rfba = bp->b_un.b_addr;
-       RFADDR->rfwc = -(bp->b_bcount>>1);
-       com = (bp->b_xmem&3) << 4;
-       com |= (bp->b_flags & B_READ) ? RCOM+GO+IENABLE : WCOM+GO+IENABLE;
-       RFADDR->rfcs = com;
-       dk_busy |= 1<<DK_N;
-       dk_numb[DK_N] += 1;
-       com = (-bp->b_bcount>>5) & 03777;
-       dk_wds[DK_N] += com;
-}
-
-rfintr()
-{
-       register struct buf *bp;
-
-       if (rftab.b_active == NULL)
-               return;
-       dk_busy &= ~(1<<DK_N);
-       bp = rftab.b_actf;
-       rftab.b_active = NULL;
-       if (RFADDR->rfcs < 0) {         /* error bit */
-               deverror(bp, RFADDR->rfcs, RFADDR->rfdae);
-               RFADDR->rfcs = CTLCLR;
-               if (++rftab.b_errcnt <= 10) {
-                       rfstart();
-                       return;
-               }
-               bp->b_flags |= B_ERROR;
-       }
-       rftab.b_errcnt = 0;
-       rftab.b_actf = bp->av_forw;
-       bp->b_resid = 0;
-       iodone(bp);
-       rfstart();
-}
-
-rfread(dev)
-{
-
-       physio(rfstrategy, &rrfbuf, dev, B_READ);
-}
-
-rfwrite(dev)
-{
-
-       physio(rfstrategy, &rrfbuf, dev, B_WRITE);
-}
diff --git a/usr/sys/dev/rk.c b/usr/sys/dev/rk.c
deleted file mode 100644 (file)
index 608eb6f..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * RK disk driver
- */
-
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/buf.h"
-#include "../h/conf.h"
-#include       "../h/dir.h"
-#include "../h/user.h"
-
-#define        RKADDR  ((struct device *)0177400)
-#define        NRK     4
-#define        NRKBLK  4872
-
-#define        RESET   0
-#define        WCOM    2
-#define        RCOM    4
-#define        GO      01
-#define        DRESET  014
-#define        IENABLE 0100
-#define        DRY     0200
-#define        ARDY    0100
-#define        WLO     020000
-#define        CTLRDY  0200
-
-/*
- * Monitoring device bit
- */
-#define        DK_N    1
-
-struct device
-{
-       int     rkds;
-       int     rker;
-       int     rkcs;
-       int     rkwc;
-       caddr_t rkba;
-       int     rkda;
-};
-
-struct buf     rktab;
-struct buf     rrkbuf;
-
-rkstrategy(bp)
-register struct buf *bp;
-{
-
-       if(bp->b_flags&B_PHYS)
-               mapalloc(bp);
-       if (bp->b_blkno >= NRKBLK) {
-               bp->b_flags |= B_ERROR;
-               iodone(bp);
-               return;
-       }
-       bp->av_forw = (struct buf *)NULL;
-       spl5();
-       if(rktab.b_actf == NULL)
-               rktab.b_actf = bp;
-       else
-               rktab.b_actl->av_forw = bp;
-       rktab.b_actl = bp;
-       if(rktab.b_active == NULL)
-               rkstart();
-       spl0();
-}
-
-rkstart()
-{
-       register struct buf *bp;
-       register com;
-       daddr_t bn;
-       int dn, cn, sn;
-
-       if ((bp = rktab.b_actf) == NULL)
-               return;
-       rktab.b_active++;
-       bn = bp->b_blkno;
-       dn = minor(bp->b_dev);
-       cn = bn/12;
-       sn = bn%12;
-       RKADDR->rkda = (dn<<13) | (cn<<4) | sn;
-       RKADDR->rkba = bp->b_un.b_addr;
-       RKADDR->rkwc = -(bp->b_bcount>>1);
-       com = ((bp->b_xmem&3) << 4) | IENABLE | GO;
-       if(bp->b_flags & B_READ)
-               com |= RCOM; else
-               com |= WCOM;
-       RKADDR->rkcs = com;
-       dk_busy |= 1<<DK_N;
-       dk_numb[DK_N] += 1;
-       com = bp->b_bcount>>6;
-       dk_wds[DK_N] += com;
-}
-
-rkintr()
-{
-       register struct buf *bp;
-
-       if (rktab.b_active == NULL)
-               return;
-       dk_busy &= ~(1<<DK_N);
-       bp = rktab.b_actf;
-       rktab.b_active = NULL;
-       if (RKADDR->rkcs < 0) {         /* error bit */
-               deverror(bp, RKADDR->rker, RKADDR->rkds);
-               RKADDR->rkcs = RESET|GO;
-               while((RKADDR->rkcs&CTLRDY) == 0)
-                       ;
-               if (++rktab.b_errcnt <= 10) {
-                       rkstart();
-                       return;
-               }
-               bp->b_flags |= B_ERROR;
-       }
-       rktab.b_errcnt = 0;
-       rktab.b_actf = bp->av_forw;
-       bp->b_resid = 0;
-       iodone(bp);
-       rkstart();
-}
-
-rkread(dev)
-dev_t dev;
-{
-
-       physio(rkstrategy, &rrkbuf, dev, B_READ);
-}
-
-rkwrite(dev)
-dev_t dev;
-{
-
-       physio(rkstrategy, &rrkbuf, dev, B_WRITE);
-}
diff --git a/usr/sys/dev/rl.c b/usr/sys/dev/rl.c
deleted file mode 100644 (file)
index 86fd81e..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- *  RL disk driver
- */
-
-#define DK_N   2
-#include "../h/param.h"
-#include "../h/buf.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/systm.h"
-
-#define NRLBLK 10240
-#define RLCYLSZ 10240
-#define RLSECSZ 256
-
-#define RESET 013
-#define STAT 03
-#define GETSTAT 04
-#define WCOM 012
-#define RCOM 014
-#define SEEK 06
-#define SEEKHI 5
-#define SEEKLO 1
-#define RDHDR 010
-#define IENABLE 0100
-#define CRDY 0200
-#define OPI 02000
-#define CRCERR 04000
-#define TIMOUT 010000
-#define NXM 020000
-#define DE  040000
-
-struct device
-{
-       int rlcs, rlba, rlda, rlmp;
-};
-
-#define RLADDR ((struct device *)0174400)
-#define RL_CNT 1
-struct buf     rrlbuf;
-struct buf     rltab;
-
-struct 
-{
-       int     cn[4];          /* location of heads for each drive */
-       int     dn;             /* drive number */
-       int     com;            /* read or write command word */
-       int     chn;            /* cylinder and head number */
-       unsigned int    bleft;  /* bytes left to be transferred */
-       unsigned int    bpart;  /* number of bytes transferred */
-       int     sn;             /* sector number */
-       union {
-               int     w[2];
-               long    l;
-       } addr;                 /* address of memory for transfer */
-
-}      rl = {-1,-1,-1,-1};
-
-rlstrategy(bp)
-register struct buf *bp;
-{
-       if(bp->b_blkno >= NRLBLK) {
-               if(bp->b_blkno == NRLBLK && bp->b_flags&B_READ)
-                       bp->b_resid = bp->b_bcount;
-               else {
-                       bp->b_flags |= B_ERROR;
-                       bp->b_error = ENXIO;
-               }
-               iodone(bp);
-               return;
-       }
-       bp->av_forw = NULL;
-       spl5();
-       if(rltab.b_actf == NULL)
-               rltab.b_actf = bp;
-       else
-               rltab.b_actl->av_forw = bp;
-       rltab.b_actl = bp;
-       if(rltab.b_active == NULL)
-               rlstart();
-       spl0();
-}
-
-rlstart()
-{
-
-       register struct buf *bp;
-
-       if ((bp = rltab.b_actf) == NULL)
-               return;
-       rltab.b_active++;
-       rl.dn = minor(bp->b_dev);
-       rl.chn = bp->b_blkno/20;
-       rl.sn = (bp->b_blkno%20) << 1;
-       rl.bleft = bp->b_bcount;
-       rl.addr.w[0] = bp->b_xmem & 3;
-       rl.addr.w[1] = (int)bp->b_un.b_addr;
-       rl.com = (rl.dn << 8) | IENABLE;
-       if (bp->b_flags & B_READ)
-               rl.com |= RCOM;
-       else
-               rl.com |= WCOM;
-       rlio();
-}
-
-rlintr()
-{
-       register struct buf *bp;
-       register struct device *rp;
-       register int status;
-
-       rp = RLADDR;
-       if (rltab.b_active == NULL) {
-/*
-               logstray(rp);
-*/
-               return;
-       }
-       bp = rltab.b_actf;
-       dk_busy &= ~(1<<DK_N);
-       if (rp->rlcs < 0) {             /* error bit */
-               if (rp->rlcs & 036000) {
-                       if(rltab.b_errcnt > 2)
-                               deverror(bp, rp->rlcs, rp->rlda);
-               }
-               if (rp->rlcs & 040000) {
-                       rp->rlda = STAT;
-                       rp->rlcs = (rl.dn << 8) | GETSTAT;
-                       while ((rp->rlcs & CRDY) == 0)
-                               ;
-                       status = rp->rlmp;
-                       if(rltab.b_errcnt > 2)
-                               deverror(bp, status, rp->rlda);
-                       rp->rlda = RESET;
-                       rp->rlcs = (rl.dn << 8) | GETSTAT;
-                       while ((rp->rlcs & CRDY) == 0)
-                               ;
-                       if(status & 01000) {
-                               rlstart();
-                               return;
-                       }
-               }
-               if (++rltab.b_errcnt <= 10) {
-                       rl.cn[rl.dn] = -1;
-                       rlstart();
-                       return;
-               }
-               else {
-                       bp->b_flags |= B_ERROR;
-                       rl.bpart = rl.bleft;
-               }
-       }
-
-       if ((rl.bleft -= rl.bpart) > 0) {
-               rl.addr.l += rl.bpart;
-               rl.sn=0;
-               rl.chn++;
-               rlio();
-               return;
-       }
-       rltab.b_active = NULL;
-       rltab.b_errcnt = 0;
-       rltab.b_actf = bp->av_forw;
-       bp->b_resid = 0;
-       iodone(bp);
-       rlstart();
-}
-
-rlio()
-{
-
-       register struct device *rp;
-       register dif;
-       register int head;
-
-       rp = RLADDR;
-       dk_busy |= 1<<DK_N;
-       dk_numb[DK_N] += 1;
-       head = rl.bpart>>6;
-       dk_wds[DK_N] += head;
-       if (rl.cn[rl.dn] < 0) {
-               rp->rlcs = (rl.dn << 8) | RDHDR;
-               while ((rp->rlcs&CRDY) == 0)
-                       ;
-               rl.cn[rl.dn] = (rp->rlmp&077700) >> 6;
-       }
-       dif =(rl.cn[rl.dn] >> 1) - (rl.chn >>1);
-       head = (rl.chn & 1) << 4;
-       if (dif < 0)
-               rp->rlda = (-dif <<7) | SEEKHI | head;
-       else
-               rp->rlda = (dif << 7) | SEEKLO | head;
-       rp->rlcs = (rl.dn << 8) | SEEK;
-       rl.cn[rl.dn] = rl.chn;
-       if (rl.bleft < (rl.bpart = RLCYLSZ - (rl.sn * RLSECSZ)))
-               rl.bpart = rl.bleft;
-       while ((rp->rlcs&CRDY) == 0)
-               ;
-       rp->rlda = (rl.chn << 6) | rl.sn;
-       rp->rlba = rl.addr.w[1];
-       rp->rlmp = -(rl.bpart >> 1);
-       rp->rlcs = rl.com | rl.addr.w[0] << 4;
-}
-
-rlread(dev)
-{
-
-       physio(rlstrategy, &rrlbuf, dev, B_READ);
-}
-
-rlwrite(dev)
-{
-
-       physio(rlstrategy, &rrlbuf, dev, B_WRITE);
-}
diff --git a/usr/sys/dev/rp.c b/usr/sys/dev/rp.c
deleted file mode 100644 (file)
index 0890f9f..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-#
-/*
- * RP disk driver
- */
-
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/buf.h"
-#include "../h/dir.h"
-#include "../h/conf.h"
-#include "../h/user.h"
-
-struct device {
-       int     rpds;
-       int     rper;
-       union {
-               int     w;
-               char    c;
-       } rpcs;
-       int     rpwc;
-       char    *rpba;
-       int     rpca;
-       int     rpda;
-};
-
-#define RPADDR ((struct device *) 0176710)
-#define        NRP     8
-
-struct {
-       daddr_t nblocks;
-       int     cyloff;
-} rp_sizes[] = {
-       81000,  0,              /* cyl 0 thru 405 */
-       5000,   0,              /* cyl 0 thru 24 */
-       2000,   25,             /* cyl 25 thru 34 */
-       74000,  35,             /* cyl 35 thru 405 */
-       0,      0,
-       0,      0,
-       0,      0,
-       0,      0,
-};
-
-struct buf     rptab;
-struct buf     rrpbuf;
-
-#define        GO      01
-#define        RESET   0
-#define        HSEEK   014
-
-#define        IENABLE 0100
-#define        READY   0200
-#define        RCOM    4
-#define        WCOM    2
-
-#define        SUFU    01000
-#define        SUSU    02000
-#define        SUSI    04000
-#define        HNF     010000
-
-/*
- * Use av_back to save track+sector,
- * b_resid for cylinder.
- */
-
-#define        trksec  av_back
-#define        cylin   b_resid
-
-/*
- * Monitoring device number
- */
-#define        DK_N    2
-
-rpstrategy(bp)
-register struct buf *bp;
-{
-       register struct buf *dp;
-       register int unit;
-       long sz;
-
-       unit = minor(bp->b_dev);
-       sz = bp->b_bcount;
-       sz = (sz+511)>>9;
-       if (unit >= (NRP<<3) ||
-          bp->b_blkno+sz >= rp_sizes[unit&07].nblocks) {
-               bp->b_flags |= B_ERROR;
-               iodone(bp);
-               return;
-       }
-       bp->av_forw = NULL;
-       unit >>= 3;
-       spl5();
-       dp = & rptab;
-       if (dp->b_actf == NULL)
-               dp->b_actf = bp;
-       else
-               dp->b_actl->av_forw = bp;
-       dp->b_actl = bp;
-       if (dp->b_active == NULL)
-               rpstart();
-       spl0();
-}
-
-rpstart()
-{
-       register struct buf *bp;
-       register int unit;
-       int com,cn,tn,sn,dn;
-       daddr_t bn;
-
-
-       if ((bp = rptab.b_actf) == NULL)
-               return;
-       rptab.b_active++;
-       unit = minor(bp->b_dev);
-       dn = unit>>3;
-       bn = bp->b_blkno;
-       cn = bn/(20*10) + rp_sizes[unit&07].cyloff;
-       sn = bn%(20*10);
-       tn = sn/10;
-       sn = sn%10;
-       RPADDR->rpcs.w = (dn<<8);
-       RPADDR->rpda = (tn<<8) | sn;
-       RPADDR->rpca = cn;
-       RPADDR->rpba = bp->b_un.b_addr;
-       RPADDR->rpwc = -(bp->b_bcount>>1);
-       com = ((bp->b_xmem&3)<<4) | IENABLE | GO;
-       if (bp->b_flags & B_READ)
-               com |= RCOM; else
-               com |= WCOM;
-       
-       RPADDR->rpcs.w |= com;
-       dk_busy |= 1<<DK_N;
-       dk_numb[DK_N] += 1;
-       unit = bp->b_bcount>>6;
-       dk_wds[DK_N] += unit;
-}
-
-rpintr()
-{
-       register struct buf *bp;
-       register int ctr;
-
-       if (rptab.b_active == NULL)
-               return;
-       dk_busy &= ~(1<<DK_N);
-       bp = rptab.b_actf;
-       rptab.b_active = NULL;
-       if (RPADDR->rpcs.w < 0) {               /* error bit */
-               deverror(bp, RPADDR->rper, RPADDR->rpds);
-               if(RPADDR->rpds & (SUFU|SUSI|HNF)) {
-                       RPADDR->rpcs.c = HSEEK|GO;
-                       ctr = 0;
-                       while ((RPADDR->rpds&SUSU) && --ctr)
-                               ;
-               }
-               RPADDR->rpcs.w = RESET|GO;
-               ctr = 0;
-               while ((RPADDR->rpcs.w&READY) == 0 && --ctr)
-                       ;
-               if (++rptab.b_errcnt <= 10) {
-                       rpstart();
-                       return;
-               }
-               bp->b_flags |= B_ERROR;
-       }
-       rptab.b_errcnt = 0;
-       rptab.b_actf = bp->av_forw;
-       bp->b_resid = 0;
-       iodone(bp);
-       rpstart();
-}
-
-rpread(dev)
-{
-
-       physio(rpstrategy, &rrpbuf, dev, B_READ);
-}
-
-rpwrite(dev)
-{
-
-       physio(rpstrategy, &rrpbuf, dev, B_WRITE);
-}
diff --git a/usr/sys/dev/sys.c b/usr/sys/dev/sys.c
deleted file mode 100644 (file)
index 80c77f9..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- *     indirect driver for controlling tty.
- */
-#include "../h/param.h"
-#include "../h/conf.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/tty.h"
-#include "../h/proc.h"
-
-syopen(dev, flag)
-{
-
-       if(u.u_ttyp == NULL) {
-               u.u_error = ENXIO;
-               return;
-       }
-       (*cdevsw[major(u.u_ttyd)].d_open)(u.u_ttyd, flag);
-}
-
-syread(dev)
-{
-
-       (*cdevsw[major(u.u_ttyd)].d_read)(u.u_ttyd);
-}
-
-sywrite(dev)
-{
-
-       (*cdevsw[major(u.u_ttyd)].d_write)(u.u_ttyd);
-}
-
-sysioctl(dev, cmd, addr, flag)
-caddr_t addr;
-{
-
-       (*cdevsw[major(u.u_ttyd)].d_ioctl)(u.u_ttyd, cmd, addr, flag);
-}
diff --git a/usr/sys/dev/tc.c b/usr/sys/dev/tc.c
deleted file mode 100644 (file)
index a234666..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-#
-
-/*
- * TC-11 DECtape driver
- */
-
-#include "../h/param.h"
-#include "../h/conf.h"
-#include "../h/buf.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-
-struct device {
-       int     tccsr;
-       union wb {
-               int     w;
-               char    b[2];
-       } tccm;
-       int     tcwc;
-       int     tcba;
-       int     tcdt;
-};
-
-struct buf     tctab;
-char   tcper[8];
-
-#define        TCADDR  ((struct device *) 0177340)
-#define        NTCBLK  578
-
-#define        TAPERR  0100000
-#define        TREV    04000
-#define        READY   0200
-#define        IENABLE 0100
-#define        UPS     0200
-#define        ENDZ    0100000
-#define        BLKM    02000
-#define        ILGOP   010000
-#define        SELERR  04000
-
-#define        SAT     0
-#define        RNUM    02
-#define        RDATA   04
-#define        SST     010
-#define        WDATA   014
-#define        GO      01
-
-#define        SFORW   1
-#define        SREV    2
-#define        SIO     3
-
-tcclose(dev)
-{
-       bflush(dev);
-       tcper[dev&07] = 0;
-}
-
-tcstrategy(bp)
-register struct buf *bp;
-{
-
-       if(bp->b_flags&B_PHYS)
-               mapalloc(bp);
-       bp->b_resid = 0;
-       if(bp->b_blkno >= NTCBLK || tcper[minor(bp->b_dev)&07]) {
-               bp->b_flags |= B_ERROR;
-               iodone(bp);
-               return;
-       }
-       bp->av_forw = 0;
-       spl6();
-       if (tctab.b_actf==0)
-               tctab.b_actf = bp;
-       else
-               tctab.b_actl->av_forw = bp;
-       tctab.b_actl = bp;
-       if (tctab.b_active==0)
-               tcstart();
-       spl0();
-}
-
-tcstart()
-{
-       register struct buf *bp;
-       register int com;
-       register union wb *tccmp;
-
-loop:
-       tccmp = &TCADDR->tccm;
-       if ((bp = tctab.b_actf) == 0)
-               return;
-       if(tcper[minor(bp->b_dev)&07]) {
-               if((tctab.b_actf = bp->av_forw) == 0)
-                       tccmp->b[0] = SAT|GO;
-               bp->b_flags |= B_ERROR;
-               iodone(bp);
-               goto loop;
-       }
-       if ((tccmp->b[1]&07) != minor(bp->b_dev))
-               tccmp->b[0] = SAT|GO;
-       tctab.b_errcnt = 20;
-       tctab.b_active = SFORW;
-       com = (minor(bp->b_dev)<<8) | IENABLE|RNUM|GO;
-       if ((TCADDR->tccsr & UPS) == 0) {
-               com |= TREV;
-               tctab.b_active = SREV;
-       }
-       tccmp->w = com;
-}
-
-tcintr()
-{
-       register struct buf *bp;
-       register union wb *tccmp;
-       register int *tcdtp;
-
-       tccmp = &TCADDR->tccm;
-       tcdtp = &TCADDR->tccsr;
-       bp = tctab.b_actf;
-       if (tccmp->w&TAPERR) {
-               if((*tcdtp&(ENDZ|BLKM)) == 0)
-                       deverror(bp, *tcdtp, 0);
-               if(*tcdtp & (ILGOP|SELERR)) {
-                       tcper[bp->b_dev&07]++;
-                       tctab.b_errcnt = 0;
-               }
-               tccmp->w &= ~TAPERR;
-               if (--tctab.b_errcnt == 0) {
-                       bp->b_flags |= B_ERROR;
-                       goto done;
-               }
-               if (tccmp->w&TREV) {
-               setforw:
-                       tctab.b_active = SFORW;
-                       tccmp->w &= ~TREV;
-               } else {
-               setback:
-                       tctab.b_active = SREV;
-                       tccmp->w |= TREV;
-               }
-               tccmp->b[0] = IENABLE|RNUM|GO;
-               return;
-       }
-       tcdtp = &TCADDR->tcdt;
-       switch (tctab.b_active) {
-
-       case SIO:
-       done:
-               tctab.b_active = 0;
-               if (tctab.b_actf = bp->av_forw)
-                       tcstart();
-               else
-                       TCADDR->tccm.b[0] = SAT|GO;
-               iodone(bp);
-               return;
-
-       case SFORW:
-               if (*tcdtp > bp->b_blkno)
-                       goto setback;
-               if (*tcdtp < bp->b_blkno)
-                       goto setforw;
-               *--tcdtp = (int)bp->b_un.b_addr;        /* core address */
-               *--tcdtp = -(bp->b_bcount>>1);
-               tccmp->b[0] = ((bp->b_xmem & 03) << 4) | IENABLE|GO
-                   | (bp->b_flags&B_READ?RDATA:WDATA);
-               tctab.b_active = SIO;
-               return;
-
-       case SREV:
-               if (*tcdtp+3 > bp->b_blkno)
-                       goto setback;
-               goto setforw;
-       }
-}
diff --git a/usr/sys/dev/tm.c b/usr/sys/dev/tm.c
deleted file mode 100644 (file)
index 5901137..0000000
+++ /dev/null
@@ -1,300 +0,0 @@
-#
-
-/*
- * TM tape driver
- */
-
-#include "../h/param.h"
-#include "../h/buf.h"
-#include "../h/dir.h"
-#include "../h/conf.h"
-#include "../h/file.h"
-#include "../h/user.h"
-
-struct device {
-       int     tmer;
-       int     tmcs;
-       int     tmbc;
-       char    *tmba;
-       int     tmdb;
-       int     tmrd;
-};
-
-struct buf     tmtab;
-struct buf     ctmbuf;
-struct buf     rtmbuf;
-
-char   t_flags[8];
-char   t_openf[8];
-daddr_t        t_blkno[8];
-daddr_t        t_nxrec[8];
-
-#define        TMADDR ((struct device *)0172520)
-
-#define        GO      01
-#define        RCOM    02
-#define        WCOM    04
-#define        WEOF    06
-#define        NOP     0100
-#define        SFORW   010
-#define        SREV    012
-#define        WIRG    014
-#define        REW     016
-#define        DENS    060000          /* 9-channel */
-#define        IENABLE 0100
-#define        CRDY    0200
-#define GAPSD  010000
-#define        TUR     1
-#define        HARD    0102200 /* ILC, EOT, NXM */
-#define RLE    0100
-#define        EOF     0040000
-#define        WL      04
-
-#define        SSEEK   1
-#define        SIO     2
-#define        SCOM    3
-
-#define T_WRITTEN 1
-
-tmopen(dev, flag)
-{
-       register unit, ds;
-
-       unit = minor(dev) & 0177;
-       if (t_openf[unit]) {
-               u.u_error = ENXIO;
-               return;
-       }
-       t_blkno[unit] = 0;
-       t_nxrec[unit] = 65535;
-       t_flags[unit] = 0;
-
-       tmtab.b_flags |= B_TAPE;
-       ds = tcommand(dev, NOP);
-       if ((ds&TUR)==0) {
-               printf("mt%d off line\n",unit);
-               u.u_error = ENXIO;
-       }
-       if (flag && ds&WL) {
-               printf("mt%d needs write ring\n",unit);
-               u.u_error = ENXIO;
-       }
-       if (u.u_error==0)
-               t_openf[unit]++;
-}
-
-tmclose(dev, flag)
-dev_t dev;
-int flag;
-{
-
-       if ( flag == FWRITE ||
-       ((flag&FWRITE) && (t_flags[minor(dev)&0177]&T_WRITTEN))) {
-               tcommand(dev, WEOF);
-               tcommand(dev, WEOF);
-               tcommand(dev, SREV);
-       }
-       if ((minor(dev)&0200) == 0)
-               tcommand(dev, REW);
-       t_openf[minor(dev)&077] = 0;
-}
-
-tcommand(dev, com)
-{
-       register struct buf *bp;
-
-       bp = &ctmbuf;
-       spl5();
-       while (bp->b_flags&B_BUSY) {
-               bp->b_flags |= B_WANTED;
-               sleep((caddr_t)bp, PRIBIO);
-       }
-       bp->b_flags = B_BUSY|B_READ;
-       spl0();
-       bp->b_dev = dev;
-       bp->b_resid = com;
-       bp->b_blkno = 0;
-       tmstrategy(bp);
-       iowait(bp);
-       if (bp->b_flags&B_WANTED)
-               wakeup((caddr_t)bp);
-       bp->b_flags = 0;
-       return(bp->b_resid);
-}
-
-tmstrategy(bp)
-register struct buf *bp;
-{
-       register daddr_t *p;
-
-       if(bp->b_flags&B_PHYS)
-               mapalloc(bp);
-       if (bp != &ctmbuf) {
-               p = &t_nxrec[minor(bp->b_dev)&0177];
-               if (*p <= bp->b_blkno) {
-                       if (*p < bp->b_blkno) {
-                               bp->b_flags |= B_ERROR;
-                               iodone(bp);
-                               return;
-                       }
-                       if (bp->b_flags&B_READ) {
-                               clrbuf(bp);
-                               bp->b_resid = 0;
-                               iodone(bp);
-                               return;
-                       }
-               }
-               if ((bp->b_flags&B_READ) == 0) {
-                       t_flags[minor(bp->b_dev)&0177] |= T_WRITTEN;
-                       *p = bp->b_blkno+1;
-               }
-       }
-       bp->av_forw = 0;
-       spl5();
-       if (tmtab.b_actf == NULL)
-               tmtab.b_actf = bp;
-       else
-               tmtab.b_actl->av_forw = bp;
-       tmtab.b_actl = bp;
-       if (tmtab.b_active == NULL)
-               tmstart();
-       spl0();
-}
-
-tmstart()
-{
-       register struct buf *bp;
-       register int com;
-       int unit;
-       register daddr_t *blkno;
-
-    loop:
-       if ((bp = tmtab.b_actf) == 0)
-               return;
-       unit = minor(bp->b_dev)&0177;
-       blkno = &t_blkno[unit];
-       if (t_openf[unit] < 0 || (TMADDR->tmcs & CRDY) == NULL) {
-               bp->b_flags |= B_ERROR;
-               goto next;
-       }
-       if (bp == &ctmbuf) {
-               if (bp->b_resid == NOP) {
-                       bp->b_resid = TMADDR->tmer;
-                       goto next;
-               }
-               tmtab.b_active = SCOM;
-               TMADDR->tmcs = DENS|bp->b_resid|GO| (unit<<8) | IENABLE;
-               return;
-       }
-       com = (unit<<8) | ((bp->b_xmem & 03) << 4) | IENABLE|DENS;
-       if (*blkno != bp->b_blkno) {
-               tmtab.b_active = SSEEK;
-               if (*blkno < bp->b_blkno) {
-                       com |= SFORW|GO;
-                       TMADDR->tmbc = *blkno - bp->b_blkno;
-               } else {
-                       if (bp->b_blkno == 0)
-                               com |= REW|GO;
-                       else {
-                               com |= SREV|GO;
-                               TMADDR->tmbc = bp->b_blkno - *blkno;
-                       }
-               }
-               TMADDR->tmcs = com;
-               return;
-       }
-       tmtab.b_active = SIO;
-       TMADDR->tmbc = -bp->b_bcount;
-       TMADDR->tmba = bp->b_un.b_addr;
-       TMADDR->tmcs = com | ((bp->b_flags&B_READ)? RCOM|GO:
-           ((tmtab.b_errcnt)? WIRG|GO: WCOM|GO));
-       return;
-
-next:
-       tmtab.b_actf = bp->av_forw;
-       iodone(bp);
-       goto loop;
-}
-
-tmintr()
-{
-       register struct buf *bp;
-       register int unit;
-       int     state;
-
-       if ((bp = tmtab.b_actf) == NULL)
-               return;
-       unit = minor(bp->b_dev)&0177;
-       state = tmtab.b_active;
-       tmtab.b_active = 0;
-       if (TMADDR->tmcs < 0) {         /* error bit */
-               while(TMADDR->tmrd & GAPSD) ; /* wait for gap shutdown */
-               if (TMADDR->tmer&EOF) {
-                       t_nxrec[unit] = bp->b_blkno;
-                       state = SCOM;
-                       TMADDR->tmbc = -bp->b_bcount;
-                       goto out;
-               }
-               if ((TMADDR->tmer&HARD) == 0 && TMADDR->tmer&RLE) {
-                       state = SIO;
-                       goto out;
-               }
-               if ((TMADDR->tmer&(HARD|EOF)) == NULL && state==SIO) {
-                       if (++tmtab.b_errcnt < 2) {
-                               t_blkno[unit]++;
-                               tmtab.b_active = 0;
-                               tmstart();
-                               return;
-                       }
-               } else
-                       if (t_openf[unit]>0 && bp!=&rtmbuf &&
-                               (TMADDR->tmer&EOF)==0 ) {
-                               t_openf[unit] = -1;
-                               deverror(bp, TMADDR->tmer, 0);
-                       }
-               bp->b_flags |= B_ERROR;
-               state = SIO;
-       }
-out:
-       switch ( state ) {
-       case SIO:
-               t_blkno[unit] += (bp->b_bcount>>BSHIFT);
-       case SCOM:
-               tmtab.b_errcnt = 0;
-               tmtab.b_actf = bp->av_forw;
-               bp->b_resid = -TMADDR->tmbc;
-               iodone(bp);
-               break;
-       case SSEEK:
-               t_blkno[unit] = bp->b_blkno;
-               break;
-       default:
-               return;
-       }
-       tmstart();
-}
-
-tmread(dev)
-{
-       tmphys(dev);
-       physio(tmstrategy, &rtmbuf, dev, B_READ);
-}
-
-tmwrite(dev)
-{
-       tmphys(dev);
-       physio(tmstrategy, &rtmbuf, dev, B_WRITE);
-}
-
-tmphys(dev)
-{
-       register unit;
-       daddr_t a;
-
-       unit = minor(dev) & 0177;
-       if(unit < 8) {
-               a = u.u_offset >> 9;
-               t_blkno[unit] = a;
-               t_nxrec[unit] = a+1;
-       }
-}
diff --git a/usr/sys/dev/tty.c b/usr/sys/dev/tty.c
deleted file mode 100644 (file)
index e48f3f0..0000000
+++ /dev/null
@@ -1,728 +0,0 @@
-#
-/*
- * general TTY subroutines
- */
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/tty.h"
-#include "../h/proc.h"
-#include "../h/mx.h"
-#include "../h/inode.h"
-#include "../h/file.h"
-#include "../h/reg.h"
-#include "../h/conf.h"
-
-char   partab[];
-
-
-/*
- * Input mapping table-- if an entry is non-zero, when the
- * corresponding character is typed preceded by "\" the escape
- * sequence is replaced by the table value.  Mostly used for
- * upper-case only terminals.
- */
-
-char   maptab[] ={
-       000,000,000,000,000,000,000,000,
-       000,000,000,000,000,000,000,000,
-       000,000,000,000,000,000,000,000,
-       000,000,000,000,000,000,000,000,
-       000,'|',000,000,000,000,000,'`',
-       '{','}',000,000,000,000,000,000,
-       000,000,000,000,000,000,000,000,
-       000,000,000,000,000,000,000,000,
-       000,000,000,000,000,000,000,000,
-       000,000,000,000,000,000,000,000,
-       000,000,000,000,000,000,000,000,
-       000,000,000,000,000,000,'~',000,
-       000,'A','B','C','D','E','F','G',
-       'H','I','J','K','L','M','N','O',
-       'P','Q','R','S','T','U','V','W',
-       'X','Y','Z',000,000,000,000,000,
-};
-
-
-/*
- * shorthand
- */
-#define        q1      tp->t_rawq
-#define        q2      tp->t_canq
-#define        q3      tp->t_outq
-#define        q4      tp->t_un.t_ctlq
-
-
-/*
- * routine called on first teletype open.
- * establishes a process group for distribution
- * of quits and interrupts from the tty.
- */
-ttyopen(dev, tp)
-dev_t dev;
-register struct tty *tp;
-{
-       register struct proc *pp;
-
-       pp = u.u_procp;
-       tp->t_dev = dev;
-       if(pp->p_pgrp == 0) {
-               u.u_ttyp = tp;
-               u.u_ttyd = dev;
-               if (tp->t_pgrp==0)
-                       tp->t_pgrp = pp->p_pid;
-               pp->p_pgrp = tp->t_pgrp;
-       }
-       tp->t_state &= ~WOPEN;
-       tp->t_state |= ISOPEN;
-}
-
-
-/*
- * set default control characters.
- */
-ttychars(tp)
-register struct tty *tp;
-{
-       tun.t_intrc = CINTR;
-       tun.t_quitc = CQUIT;
-       tun.t_startc = CSTART;
-       tun.t_stopc = CSTOP;
-       tun.t_eofc = CEOT;
-       tun.t_brkc = CBRK;
-       tp->t_erase = CERASE;
-       tp->t_kill = CKILL;
-}
-
-/*
- * clean tp on last close
- */
-ttyclose(tp)
-register struct tty *tp;
-{
-
-       tp->t_pgrp = 0;
-       wflushtty(tp);
-       tp->t_state = 0;
-}
-
-/*
- * stty/gtty writearound
- */
-stty()
-{
-       u.u_arg[2] = u.u_arg[1];
-       u.u_arg[1] = TIOCSETP;
-       ioctl();
-}
-
-gtty()
-{
-       u.u_arg[2] = u.u_arg[1];
-       u.u_arg[1] = TIOCGETP;
-       ioctl();
-}
-
-/*
- * ioctl system call
- * Check legality, execute common code, and switch out to individual
- * device routine.
- */
-ioctl()
-{
-       register struct file *fp;
-       register struct inode *ip;
-       register struct a {
-               int     fdes;
-               int     cmd;
-               caddr_t cmarg;
-       } *uap;
-       register dev_t dev;
-       register fmt;
-
-       uap = (struct a *)u.u_ap;
-       if ((fp = getf(uap->fdes)) == NULL)
-               return;
-       if (uap->cmd==FIOCLEX) {
-               u.u_pofile[uap->fdes] |= EXCLOSE;
-               return;
-       }
-       if (uap->cmd==FIONCLEX) {
-               u.u_pofile[uap->fdes] &= ~EXCLOSE;
-               return;
-       }
-       ip = fp->f_inode;
-       fmt = ip->i_mode & IFMT;
-       if (fmt != IFCHR && fmt != IFMPC) {
-               u.u_error = ENOTTY;
-               return;
-       }
-       dev = (dev_t)ip->i_un.i_rdev;
-       (*cdevsw[major(dev)].d_ioctl)(dev, uap->cmd, uap->cmarg, fp->f_flag);
-}
-
-/*
- * Common code for several tty ioctl commands
- */
-ttioccomm(com, tp, addr, dev)
-register struct tty *tp;
-caddr_t addr;
-{
-       unsigned t;
-       struct ttiocb iocb;
-       extern int nldisp;
-
-       switch(com) {
-
-       /*
-        * get discipline number
-        */
-       case TIOCGETD:
-               t = tp->t_line;
-               if (copyout((caddr_t)&t, addr, sizeof(t)))
-                       u.u_error = EFAULT;
-               break;
-
-       /*
-        * set line discipline
-        */
-       case TIOCSETD:
-               if (copyin(addr, (caddr_t)&t, sizeof(t))) {
-                       u.u_error = EFAULT;
-                       break;
-               }
-               if (t >= nldisp) {
-                       u.u_error = ENXIO;
-                       break;
-               }
-               if (tp->t_line)
-                       (*linesw[tp->t_line].l_close)(tp);
-               if (t)
-                       (*linesw[t].l_open)(dev, tp, addr);
-               if (u.u_error==0)
-                       tp->t_line = t;
-               break;
-
-       /*
-        * prevent more opens on channel
-        */
-       case TIOCEXCL:
-               tp->t_state |= XCLUDE;
-               break;
-       case TIOCNXCL:
-               tp->t_state &= ~XCLUDE;
-               break;
-
-       /*
-        * Set new parameters
-        */
-       case TIOCSETP:
-               wflushtty(tp);
-       case TIOCSETN:
-               if (copyin(addr, (caddr_t)&iocb, sizeof(iocb))) {
-                       u.u_error = EFAULT;
-                       return(1);
-               }
-               tp->t_ispeed = iocb.ioc_ispeed;
-               tp->t_ospeed = iocb.ioc_ospeed;
-               tp->t_erase = iocb.ioc_erase;
-               tp->t_kill = iocb.ioc_kill;
-               tp->t_flags = iocb.ioc_flags;
-               break;
-
-       /*
-        * send current parameters to user
-        */
-       case TIOCGETP:
-               iocb.ioc_ispeed = tp->t_ispeed;
-               iocb.ioc_ospeed = tp->t_ospeed;
-               iocb.ioc_erase = tp->t_erase;
-               iocb.ioc_kill = tp->t_kill;
-               iocb.ioc_flags = tp->t_flags;
-               if (copyout((caddr_t)&iocb, addr, sizeof(iocb)))
-                       u.u_error = EFAULT;
-               break;
-
-       /*
-        * Hang up line on last close
-        */
-
-       case TIOCHPCL:
-               tp->t_state |= HUPCLS;
-               break;
-
-       case TIOCFLUSH:
-               flushtty(tp);
-               break;
-
-       /*
-        * ioctl entries to line discipline
-        */
-       case DIOCSETP:
-       case DIOCGETP:
-               (*linesw[tp->t_line].l_ioctl)(com, tp, addr);
-               break;
-
-       /*
-        * set and fetch special characters
-        */
-       case TIOCSETC:
-               if (copyin(addr, (caddr_t)&tun, sizeof(struct tc)))
-                       u.u_error = EFAULT;
-               break;
-
-       case TIOCGETC:
-               if (copyout((caddr_t)&tun, addr, sizeof(struct tc)))
-                       u.u_error = EFAULT;
-               break;
-
-       default:
-               return(0);
-       }
-       return(1);
-}
-
-/*
- * Wait for output to drain, then flush input waiting.
- */
-wflushtty(tp)
-register struct tty *tp;
-{
-
-       spl5();
-       while (tp->t_outq.c_cc && tp->t_state&CARR_ON) {
-               (*tp->t_oproc)(tp);
-               tp->t_state |= ASLEEP;
-               sleep((caddr_t)&tp->t_outq, TTOPRI);
-       }
-       flushtty(tp);
-       spl0();
-}
-
-/*
- * flush all TTY queues
- */
-flushtty(tp)
-register struct tty *tp;
-{
-       register s;
-
-       while (getc(&tp->t_canq) >= 0)
-               ;
-       wakeup((caddr_t)&tp->t_rawq);
-       wakeup((caddr_t)&tp->t_outq);
-       s = spl6();
-       tp->t_state &= ~TTSTOP;
-       (*cdevsw[major(tp->t_dev)].d_stop)(tp);
-       while (getc(&tp->t_outq) >= 0)
-               ;
-       while (getc(&tp->t_rawq) >= 0)
-               ;
-       tp->t_delct = 0;
-       splx(s);
-}
-
-
-
-/*
- * transfer raw input list to canonical list,
- * doing erase-kill processing and handling escapes.
- * It waits until a full line has been typed in cooked mode,
- * or until any character has been typed in raw mode.
- */
-canon(tp)
-register struct tty *tp;
-{
-       register char *bp;
-       char *bp1;
-       register int c;
-       int mc;
-
-       spl5();
-       while ((tp->t_flags&(RAW|CBREAK))==0 && tp->t_delct==0
-           || (tp->t_flags&(RAW|CBREAK))!=0 && tp->t_rawq.c_cc==0) {
-               if ((tp->t_state&CARR_ON)==0 || tp->t_chan!=NULL) {
-                       return(0);
-               }
-               sleep((caddr_t)&tp->t_rawq, TTIPRI);
-       }
-       spl0();
-loop:
-       bp = &canonb[2];
-       while ((c=getc(&tp->t_rawq)) >= 0) {
-               if ((tp->t_flags&(RAW|CBREAK))==0) {
-                       if (c==0377) {
-                               tp->t_delct--;
-                               break;
-                       }
-                       if (bp[-1]!='\\') {
-                               if (c==tp->t_erase) {
-                                       if (bp > &canonb[2])
-                                               bp--;
-                                       continue;
-                               }
-                               if (c==tp->t_kill)
-                                       goto loop;
-                               if (c==tun.t_eofc)
-                                       continue;
-                       } else {
-                               mc = maptab[c];
-                               if (c==tp->t_erase || c==tp->t_kill)
-                                       mc = c;
-                               if (mc && (mc==c || (tp->t_flags&LCASE))) {
-                                       if (bp[-2] != '\\')
-                                               c = mc;
-                                       bp--;
-                               }
-                       }
-               }
-               *bp++ = c;
-               if (bp>=canonb+CANBSIZ)
-                       break;
-       }
-       bp1 = &canonb[2];
-       b_to_q(bp1, bp-bp1, &tp->t_canq);
-
-       if (tp->t_state&TBLOCK && tp->t_rawq.c_cc < TTYHOG/5) {
-               if (putc(tun.t_startc, &tp->t_outq)==0) {
-                       tp->t_state &= ~TBLOCK;
-                       ttstart(tp);
-               }
-               tp->t_char = 0;
-       }
-
-       return(bp-bp1);
-}
-
-
-/*
- * block transfer input handler.
- */
-ttyrend(tp, pb, pe)
-register struct tty *tp;
-register char *pb, *pe;
-{
-       int     tandem;
-
-       tandem = tp->t_flags&TANDEM;
-       if (tp->t_flags&RAW) {
-               b_to_q(pb, pe-pb, &tp->t_rawq);
-               if (tp->t_chan)
-                       sdata(tp->t_chan); else
-                       wakeup((caddr_t)&tp->t_rawq);
-       } else {
-               tp->t_flags &= ~TANDEM;
-               while (pb < pe)
-                       ttyinput(*pb++, tp);
-               tp->t_flags |= tandem;
-       }
-       if (tandem)
-               ttyblock(tp);
-}
-
-/*
- * Place a character on raw TTY input queue, putting in delimiters
- * and waking up top half as needed.
- * Also echo if required.
- * The arguments are the character and the appropriate
- * tty structure.
- */
-ttyinput(c, tp)
-register c;
-register struct tty *tp;
-{
-       register int t_flags;
-       register struct chan *cp;
-
-       tk_nin += 1;
-       c &= 0377;
-       t_flags = tp->t_flags;
-       if (t_flags&TANDEM)
-               ttyblock(tp);
-       if ((t_flags&RAW)==0) {
-               c &= 0177;
-               if (tp->t_state&TTSTOP) {
-                       if (c==tun.t_startc) {
-                               tp->t_state &= ~TTSTOP;
-                               ttstart(tp);
-                               return;
-                       }
-                       if (c==tun.t_stopc)
-                               return;
-                       tp->t_state &= ~TTSTOP;
-                       ttstart(tp);
-               } else {
-                       if (c==tun.t_stopc) {
-                               tp->t_state |= TTSTOP;
-                               (*cdevsw[major(tp->t_dev)].d_stop)(tp);
-                               return;
-                       }
-                       if (c==tun.t_startc)
-                               return;
-               }
-               if (c==tun.t_quitc || c==tun.t_intrc) {
-                       flushtty(tp);
-                       c = (c==tun.t_intrc) ? SIGINT:SIGQUIT;
-                       if (tp->t_chan)
-                               scontrol(tp->t_chan, M_SIG, c);
-                       else
-                               signal(tp->t_pgrp, c);
-                       return;
-               }
-               if (c=='\r' && t_flags&CRMOD)
-                       c = '\n';
-       }
-       if (tp->t_rawq.c_cc>TTYHOG) {
-               flushtty(tp);
-               return;
-       }
-       if (t_flags&LCASE && c>='A' && c<='Z')
-               c += 'a'-'A';
-       putc(c, &tp->t_rawq);
-       if (t_flags&(RAW|CBREAK)||(c=='\n'||c==tun.t_eofc||c==tun.t_brkc)) {
-               if ((t_flags&(RAW|CBREAK))==0 && putc(0377, &tp->t_rawq)==0)
-                       tp->t_delct++;
-               if ((cp=tp->t_chan)!=NULL)
-                       sdata(cp); else
-                       wakeup((caddr_t)&tp->t_rawq);
-       }
-       if (t_flags&ECHO) {
-               ttyoutput(c, tp);
-               if (c==tp->t_kill && (t_flags&(RAW|CBREAK))==0)
-                       ttyoutput('\n', tp);
-               ttstart(tp);
-       }
-}
-
-
-/*
- * Send stop character on input overflow.
- */
-ttyblock(tp)
-register struct tty *tp;
-{
-register x;
-       x = q1.c_cc + q2.c_cc;
-       if (q1.c_cc > TTYHOG) {
-               flushtty(tp);
-               tp->t_state &= ~TBLOCK;
-       }
-       if (x >= TTYHOG/2) {
-               if (putc(tun.t_stopc, &tp->t_outq)==0) {
-                       tp->t_state |= TBLOCK;
-                       tp->t_char++;
-                       ttstart(tp);
-               }
-       }
-}
-
-/*
- * put character on TTY output queue, adding delays,
- * expanding tabs, and handling the CR/NL bit.
- * It is called both from the top half for output, and from
- * interrupt level for echoing.
- * The arguments are the character and the tty structure.
- */
-ttyoutput(c, tp)
-register c;
-register struct tty *tp;
-{
-       register char *colp;
-       register ctype;
-
-       tk_nout += 1;
-       /*
-        * Ignore EOT in normal mode to avoid hanging up
-        * certain terminals.
-        * In raw mode dump the char unchanged.
-        */
-
-       if ((tp->t_flags&RAW)==0) {
-               c &= 0177;
-               if (c==CEOT)
-                       return;
-       } else {
-               putc(c, &tp->t_outq);
-               return;
-       }
-
-       /*
-        * Turn tabs to spaces as required
-        */
-       if (c=='\t' && (tp->t_flags&TBDELAY)==XTABS) {
-               c = 8;
-               do
-                       ttyoutput(' ', tp);
-               while (--c >= 0 && tp->t_col&07);
-               return;
-       }
-       /*
-        * for upper-case-only terminals,
-        * generate escapes.
-        */
-       if (tp->t_flags&LCASE) {
-               colp = "({)}!|^~'`";
-               while(*colp++)
-                       if(c == *colp++) {
-                               ttyoutput('\\', tp);
-                               c = colp[-2];
-                               break;
-                       }
-               if ('a'<=c && c<='z')
-                       c += 'A' - 'a';
-       }
-       /*
-        * turn <nl> to <cr><lf> if desired.
-        */
-       if (c=='\n' && tp->t_flags&CRMOD)
-               ttyoutput('\r', tp);
-       putc(c, &tp->t_outq);
-       /*
-        * Calculate delays.
-        * The numbers here represent clock ticks
-        * and are not necessarily optimal for all terminals.
-        * The delays are indicated by characters above 0200.
-        * In raw mode there are no delays and the
-        * transmission path is 8 bits wide.
-        */
-       colp = &tp->t_col;
-       ctype = partab[c];
-       c = 0;
-       switch (ctype&077) {
-
-       /* ordinary */
-       case 0:
-               (*colp)++;
-
-       /* non-printing */
-       case 1:
-               break;
-
-       /* backspace */
-       case 2:
-               if (*colp)
-                       (*colp)--;
-               break;
-
-       /* newline */
-       case 3:
-               ctype = (tp->t_flags >> 8) & 03;
-               if(ctype == 1) { /* tty 37 */
-                       if (*colp)
-                               c = max(((unsigned)*colp>>4) + 3, (unsigned)6);
-               } else
-               if(ctype == 2) { /* vt05 */
-                       c = 6;
-               }
-               *colp = 0;
-               break;
-
-       /* tab */
-       case 4:
-               ctype = (tp->t_flags >> 10) & 03;
-               if(ctype == 1) { /* tty 37 */
-                       c = 1 - (*colp | ~07);
-                       if(c < 5)
-                               c = 0;
-               }
-               *colp |= 07;
-               (*colp)++;
-               break;
-
-       /* vertical motion */
-       case 5:
-               if(tp->t_flags & VTDELAY) /* tty 37 */
-                       c = 0177;
-               break;
-
-       /* carriage return */
-       case 6:
-               ctype = (tp->t_flags >> 12) & 03;
-               if(ctype == 1) { /* tn 300 */
-                       c = 5;
-               } else if(ctype == 2) { /* ti 700 */
-                       c = 10;
-               }
-               *colp = 0;
-       }
-       if(c)
-               putc(c|0200, &tp->t_outq);
-}
-
-/*
- * Restart typewriter output following a delay
- * timeout.
- * The name of the routine is passed to the timeout
- * subroutine and it is called during a clock interrupt.
- */
-ttrstrt(tp)
-register struct tty *tp;
-{
-
-       tp->t_state &= ~TIMEOUT;
-       ttstart(tp);
-}
-
-/*
- * Start output on the typewriter. It is used from the top half
- * after some characters have been put on the output queue,
- * from the interrupt routine to transmit the next
- * character, and after a timeout has finished.
- */
-ttstart(tp)
-register struct tty *tp;
-{
-       register s;
-
-       s = spl5();
-       if((tp->t_state&(TIMEOUT|TTSTOP|BUSY)) == 0)
-               (*tp->t_oproc)(tp);
-       splx(s);
-}
-
-/*
- * Called from device's read routine after it has
- * calculated the tty-structure given as argument.
- */
-ttread(tp)
-register struct tty *tp;
-{
-
-       if ((tp->t_state&CARR_ON)==0)
-               return(0);
-       if (tp->t_canq.c_cc || canon(tp))
-               while (tp->t_canq.c_cc && passc(getc(&tp->t_canq))>=0)
-                       ;
-       return(tp->t_rawq.c_cc + tp->t_canq.c_cc);
-}
-
-/*
- * Called from the device's write routine after it has
- * calculated the tty-structure given as argument.
- */
-caddr_t
-ttwrite(tp)
-register struct tty *tp;
-{
-       register c;
-
-       if ((tp->t_state&CARR_ON)==0)
-               return(NULL);
-       while (u.u_count) {
-               spl5();
-               while (tp->t_outq.c_cc > TTHIWAT) {
-                       ttstart(tp);
-                       tp->t_state |= ASLEEP;
-                       if (tp->t_chan) 
-                               return((caddr_t)&tp->t_outq);
-                       sleep((caddr_t)&tp->t_outq, TTOPRI);
-               }
-               spl0();
-               if ((c = cpass()) < 0)
-                       break;
-               ttyoutput(c, tp);
-       }
-       ttstart(tp);
-       return(NULL);
-}
-
diff --git a/usr/sys/dev/vp.c b/usr/sys/dev/vp.c
deleted file mode 100644 (file)
index 6bcdf80..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- *  Versatec matrix printer/plotter 
- *  dma interface driver
- */
-
-#include "../h/param.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/buf.h"
-#include "../h/systm.h"
-
-#define        VPPRI   (PZERO+8)
-
-/* device registers */
-struct vpregs {
-       int     plbcr;
-       int     fill;
-       int     prbcr;
-       caddr_t pbaddr;
-       int     plcsr;
-       int     plbuf;
-       int     prcsr;
-       caddr_t prbuf;
-};
-
-#define        VPADDR  ((struct vpregs *)0177500)
-
-/* status bits */
-#define        ERROR   0100000
-#define        DTCINTR 040000
-#define        DMAACT  020000
-#define        READY   0200
-#define        IENABLE 0100
-#define TERMCOM        040
-#define        FFCOM   020
-#define        EOTCOM  010
-#define        CLRCOM  04
-#define        RESET   02
-#define        SPP     01
-
-struct {
-       int     vp_state;
-       int     vp_count;
-       struct  buf     *vp_buf;
-       caddr_t vp_bufp;
-}      vp11;
-
-/*states */
-#define        ISOPEN  01
-#define        CMNDS   076
-#define        MODE    0700
-#define        PRINT   0100
-#define        PLOT    0200
-#define        PPLOT   0400
-#define        BUSY    01000
-
-vpopen()
-{
-       if (vp11.vp_state & ISOPEN) {
-               u.u_error = ENXIO;
-               return;
-       }
-       vp11.vp_state = ISOPEN | PRINT | CLRCOM | FFCOM | RESET;
-       vp11.vp_count = 0;
-       vp11.vp_buf = geteblk();
-       vp11.vp_bufp = vp11.vp_buf->b_un.b_addr;
-       VPADDR->prcsr = IENABLE | DTCINTR;
-       vptimo();
-       while(vp11.vp_state & CMNDS) {
-               spl4();
-               if (vperror(READY)) {
-                       vpclose();
-                       u.u_error = EIO;
-                       return;
-               }
-               vpstart();
-               spl0();
-       }
-}
-
-vpwrite()
-{
-       register int i, e;
-
-       if (u.u_count == 0)
-               return;
-       spl4();
-       while(vp11.vp_state & BUSY)
-               sleep((caddr_t)&vp11, VPPRI);
-       vp11.vp_state |= BUSY;
-       spl0();
-       while(i = vp11.vp_count = min(512,u.u_count)) {
-               u.u_offset = 0;         /* Make even, speed up iomove */
-               iomove(vp11.vp_buf->b_un.b_addr, i, B_WRITE);
-               spl4();
-               if (e = vperror(READY))
-                       break;
-               vpstart();
-               while ((vp11.vp_state&PLOT?VPADDR->plcsr:VPADDR->prcsr)&DMAACT)
-                       sleep((caddr_t)&vp11, VPPRI);
-               if ((vp11.vp_state&MODE) == PPLOT)
-                       vp11.vp_state = vp11.vp_state&~MODE | PLOT;
-               spl0();
-       }
-       vp11.vp_state &= ~BUSY;
-       if (e)
-               u.u_error = EIO;
-       wakeup((caddr_t)&vp11);
-}
-
-vperror(bit)
-{
-       register state, e;
-
-       state = vp11.vp_state&PLOT;
-       while((e=(state?VPADDR->plcsr:VPADDR->prcsr) & (bit|ERROR)) == 0)
-               sleep((caddr_t)&vp11, VPPRI);
-       return(e&ERROR);
-}
-
-vpstart()
-{
-       register bit;
-
-       if (vp11.vp_count) {
-               VPADDR->pbaddr = vp11.vp_bufp;
-               if (vp11.vp_state & (PRINT|PPLOT))
-                       VPADDR->prbcr = vp11.vp_count;
-               else
-                       VPADDR->plbcr = vp11.vp_count;
-               return;
-       }
-       for (bit=1; bit!=0; bit <<= 1)
-               if (vp11.vp_state&bit&CMNDS) {
-                       VPADDR->plcsr |= bit;
-                       vp11.vp_state &= ~bit;
-                       return;
-               }
-}
-
-vpioctl(dev, cmd, addr, flag)
-register caddr_t addr;
-{
-       register m;
-
-       switch(cmd) {
-
-       /* get mode */
-       case ('v'<<8)+0:
-               suword(addr, vp11.vp_state);
-               return;
-
-       /* set mode */
-       case ('v'<<8)+1:
-               m = fuword(addr);
-               if (m == -1) {
-                       u.u_error = EFAULT;
-                       return;
-               }
-               spl4();
-               vperror(READY);
-               vp11.vp_state = (vp11.vp_state & ~MODE) | (m&(MODE|CMNDS));
-               if (vp11.vp_state&PPLOT)
-                       VPADDR->plcsr |= SPP;
-               else
-                       VPADDR->plcsr &= ~SPP;
-               vp11.vp_count = 0;
-               while(CMNDS & vp11.vp_state) {
-                       vperror(READY);
-                       vpstart();
-               }
-               spl0();
-               return;
-
-       default:
-               u.u_error = ENOTTY;
-               return;
-       }
-}
-
-vptimo()
-{
-       if (vp11.vp_state&ISOPEN)
-               timeout(vptimo, (caddr_t)0, HZ/10);
-       vpintr(0);
-}
-
-vpintr(dev)
-{
-       wakeup((caddr_t)&vp11);
-}
-
-vpclose()
-{
-       brelse(vp11.vp_buf);
-       vp11.vp_state = 0;
-       vp11.vp_count = 0;
-       vp11.vp_buf = 0;
-       vp11.vp_bufp = 0;
-       VPADDR->plcsr = 0;
-}
diff --git a/usr/sys/dev/vs.c b/usr/sys/dev/vs.c
deleted file mode 100644 (file)
index 87fd6cf..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Screw Works interface via DC-11
- */
-
-#include "../h/types.h"
-#include "../h/tty.h"
-
-#define        VSADDR  ((struct device *)0174140)
-#define        CDLEAD  01
-#define        B1200   030
-#define        STOP1   0400
-#define        CLSEND  02
-#define        RQSEND  01
-
-#define        GO      026
-#define        COUNT   120
-
-struct device {
-       int     vsrcsr;
-       int     vsrbuf;
-       int     vsxcsr;
-       int     vsxbuf;
-};
-
-struct {
-       struct  clist   iq;
-       int     vtime;
-       struct  clist   oq;
-} vs;
-
-
-vsopen(dev)
-{
-       register c;
-
-       c = VSADDR->vsrcsr;             /* touch register */
-       VSADDR->vsrcsr = IENABLE|B1200|CDLEAD;
-       VSADDR->vsxcsr = STOP1|IENABLE|B1200;
-       vschar(GO);
-}
-
-vsclose(dev)
-{
-       vschar(GO);
-       VSADDR->vsrcsr &= ~IENABLE;
-       while (getc(&vs.iq) >= 0);
-}
-
-vswrite(dev)
-{
-       register int count, c;
-
-       count = 0;
-       while ((c=cpass()) >= 0) {
-               if (--count <= 0) {
-                       count = COUNT;
-                       vschar(GO);
-               }
-               vschar(c);
-       }
-       vschar(GO);
-}
-
-vschar(c)
-{
-
-       spl5();
-       while (vs.oq.c_cc > 120) {
-               vsxintr();
-               sleep((caddr_t)&vs.oq, TTIPRI);
-       }
-       putc(c, &vs.oq);
-       vsxintr();
-       spl0();
-}
-
-vstimo()
-{
-       vs.vtime = 0;
-       vsxintr();
-}
-
-vsxintr()
-{
-       static lchar;
-       register c;
-       register int *xcsr;
-
-       xcsr = &VSADDR->vsxcsr;
-       if (*xcsr&DONE) {
-               if (lchar==GO) {
-                       *xcsr &= ~RQSEND;
-                       lchar = -1;
-                       if (vs.oq.c_cc==0) {
-                               wakeup((caddr_t)&vs.oq);
-                               return;
-                       }
-               }
-               if ((*xcsr&CLSEND) == 0) {
-                       *xcsr |= RQSEND;
-                       if ((*xcsr&CLSEND) == 0) {
-                               if (vs.vtime==0) {
-                                       vs.vtime++;
-                                       timeout(vstimo, (caddr_t)0, 60);
-                               }
-                               return;
-                       }
-               }
-               if ((c = getc(&vs.oq)) >= 0)
-                       VSADDR->vsxbuf = lchar = c;
-               else
-                       *xcsr &= ~RQSEND;
-               if (vs.oq.c_cc <= 15)
-                       wakeup((caddr_t)&vs.oq);
-       }
-}
-
-vsread(dev)
-{
-       register int c;
-
-       spl5();
-       while ((c = getc(&vs.iq)) < 0)
-               sleep((caddr_t)&vs.iq, TTIPRI);
-       spl0();
-       passc("?0*#?546?213?879?"[c&017]);
-}
-
-vsrintr()
-{
-       register int c;
-
-       c = VSADDR->vsrbuf;     /* Register must be read (?) */
-       c = VSADDR->vsrbuf;
-       if (vs.iq.c_cc<=10)
-               putc(c, &vs.iq);
-       wakeup((caddr_t)&vs.iq);
-}
diff --git a/usr/sys/dummy b/usr/sys/dummy
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/sys/h/acct.h b/usr/sys/h/acct.h
deleted file mode 100644 (file)
index 8a7d7c6..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Accounting structures
- */
-
-typedef        unsigned short comp_t;  /* "floating pt": 3 bits base 8 exp, 13 bits fraction */
-struct acct
-{
-       char    ac_comm[10];            /* Accounting command name */
-       comp_t  ac_utime;               /* Accounting user time */
-       comp_t  ac_stime;               /* Accounting system time */
-       comp_t  ac_etime;               /* Accounting elapsed time */
-       time_t  ac_btime;               /* Beginning time */
-       short   ac_uid;                 /* Accounting user ID */
-       short   ac_gid;                 /* Accounting group ID */
-       short   ac_mem;                 /* average memory usage */
-       comp_t  ac_io;                  /* number of disk IO blocks */
-       dev_t   ac_tty;                 /* control typewriter */
-       char    ac_flag;                /* Accounting flag */
-};
-
-extern struct  acct    acctbuf;
-extern struct  inode   *acctp;         /* inode of accounting file */
-
-#define        AFORK   01              /* has executed fork, but no exec */
-#define        ASU     02              /* used super-user privileges */
diff --git a/usr/sys/h/buf.h b/usr/sys/h/buf.h
deleted file mode 100644 (file)
index e606883..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Each buffer in the pool is usually doubly linked into 2 lists:
- * the device with which it is currently associated (always)
- * and also on a list of blocks available for allocation
- * for other use (usually).
- * The latter list is kept in last-used order, and the two
- * lists are doubly linked to make it easy to remove
- * a buffer from one list when it was found by
- * looking through the other.
- * A buffer is on the available list, and is liable
- * to be reassigned to another disk block, if and only
- * if it is not marked BUSY.  When a buffer is busy, the
- * available-list pointers can be used for other purposes.
- * Most drivers use the forward ptr as a link in their I/O
- * active queue.
- * A buffer header contains all the information required
- * to perform I/O.
- * Most of the routines which manipulate these things
- * are in bio.c.
- */
-struct buf
-{
-       int     b_flags;                /* see defines below */
-       struct  buf *b_forw;            /* headed by d_tab of conf.c */
-       struct  buf *b_back;            /*  "  */
-       struct  buf *av_forw;           /* position on free list, */
-       struct  buf *av_back;           /*     if not BUSY*/
-       dev_t   b_dev;                  /* major+minor device name */
-       unsigned b_bcount;              /* transfer count */
-       union {
-           caddr_t b_addr;             /* low order core address */
-           int *b_words;               /* words for clearing */
-           struct filsys *b_filsys;    /* superblocks */
-           struct dinode *b_dino;      /* ilist */
-           daddr_t *b_daddr;           /* indirect block */
-       } b_un;
-       daddr_t b_blkno;                /* block # on device */
-       char    b_xmem;                 /* high order core address */
-       char    b_error;                /* returned after I/O */
-       unsigned int b_resid;           /* words not transferred after error */
-};
-
-extern struct buf buf[];               /* The buffer pool itself */
-extern struct buf bfreelist;           /* head of available list */
-
-/*
- * These flags are kept in b_flags.
- */
-#define        B_WRITE 0       /* non-read pseudo-flag */
-#define        B_READ  01      /* read when I/O occurs */
-#define        B_DONE  02      /* transaction finished */
-#define        B_ERROR 04      /* transaction aborted */
-#define        B_BUSY  010     /* not on av_forw/back list */
-#define        B_PHYS  020     /* Physical IO potentially using UNIBUS map */
-#define        B_MAP   040     /* This block has the UNIBUS map allocated */
-#define        B_WANTED 0100   /* issue wakeup when BUSY goes off */
-#define        B_AGE   0200    /* delayed write for correct aging */
-#define        B_ASYNC 0400    /* don't wait for I/O completion */
-#define        B_DELWRI 01000  /* don't write till block leaves available list */
-#define        B_TAPE 02000    /* this is a magtape (no bdwrite) */
-#define        B_PBUSY 04000
-#define        B_PACK  010000
-
-/*
- * special redeclarations for
- * the head of the queue per
- * device driver.
- */
-#define        b_actf  av_forw
-#define        b_actl  av_back
-#define        b_active b_bcount
-#define        b_errcnt b_resid
diff --git a/usr/sys/h/callo.h b/usr/sys/h/callo.h
deleted file mode 100644 (file)
index f66e5bb..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * The callout structure is for
- * a routine arranging
- * to be called by the clock interrupt
- * (clock.c) with a specified argument,
- * in a specified amount of time.
- * Used, for example, to time tab
- * delays on typewriters.
- */
-
-struct callo
-{
-       int     c_time;         /* incremental time */
-       caddr_t c_arg;          /* argument to routine */
-       int     (*c_func)();    /* routine */
-};
-struct callo   callout[NCALL];
diff --git a/usr/sys/h/conf.h b/usr/sys/h/conf.h
deleted file mode 100644 (file)
index 66d4252..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Declaration of block device
- * switch. Each entry (row) is
- * the only link between the
- * main unix code and the driver.
- * The initialization of the
- * device switches is in the
- * file conf.c.
- */
-extern struct bdevsw
-{
-       int     (*d_open)();
-       int     (*d_close)();
-       int     (*d_strategy)();
-       struct buf *d_tab;
-} bdevsw[];
-
-/*
- * Character device switch.
- */
-extern struct cdevsw
-{
-       int     (*d_open)();
-       int     (*d_close)();
-       int     (*d_read)();
-       int     (*d_write)();
-       int     (*d_ioctl)();
-       int     (*d_stop)();
-       struct tty *d_ttys;
-} cdevsw[];
-
-/*
- * tty line control switch.
- */
-extern struct linesw
-{
-       int     (*l_open)();
-       int     (*l_close)();
-       int     (*l_read)();
-       char    *(*l_write)();
-       int     (*l_ioctl)();
-       int     (*l_rint)();
-       int     (*l_rend)();
-       int     (*l_meta)();
-       int     (*l_start)();
-       int     (*l_modem)();
-} linesw[];
diff --git a/usr/sys/h/dir.h b/usr/sys/h/dir.h
deleted file mode 100644 (file)
index 737a3a6..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef        DIRSIZ
-#define        DIRSIZ  14
-#endif
-struct direct
-{
-       ino_t   d_ino;
-       char    d_name[DIRSIZ];
-};
diff --git a/usr/sys/h/fblk.h b/usr/sys/h/fblk.h
deleted file mode 100644 (file)
index 9a1ba29..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-struct fblk
-{
-       int     df_nfree;
-       daddr_t df_free[NICFREE];
-};
diff --git a/usr/sys/h/file.h b/usr/sys/h/file.h
deleted file mode 100644 (file)
index f526043..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * One file structure is allocated
- * for each open/creat/pipe call.
- * Main use is to hold the read/write
- * pointer associated with each open
- * file.
- */
-struct file
-{
-       char    f_flag;
-       char    f_count;        /* reference count */
-       struct inode *f_inode;  /* pointer to inode structure */
-       union {
-               off_t   f_offset;       /* read/write character pointer */
-               struct chan *f_chan;    /* mpx channel pointer */
-       } f_un;
-};
-
-extern struct file file[];     /* The file table itself */
-
-/* flags */
-#define        FREAD   01
-#define        FWRITE  02
-#define        FPIPE   04
-#define FMPX   010
-#define        FMPY    020
-#define        FMP     030
-#define        FKERNEL 040
diff --git a/usr/sys/h/filsys.h b/usr/sys/h/filsys.h
deleted file mode 100644 (file)
index 19ebcee..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Structure of the super-block
- */
-struct filsys {
-       unsigned short s_isize; /* size in blocks of i-list */
-       daddr_t s_fsize;        /* size in blocks of entire volume */
-       short   s_nfree;        /* number of addresses in s_free */
-       daddr_t s_free[NICFREE];/* free block list */
-       short   s_ninode;       /* number of i-nodes in s_inode */
-       ino_t   s_inode[NICINOD];/* free i-node list */
-       char    s_flock;        /* lock during free list manipulation */
-       char    s_ilock;        /* lock during i-list manipulation */
-       char    s_fmod;         /* super block modified flag */
-       char    s_ronly;        /* mounted read-only flag */
-       time_t  s_time;         /* last super block update */
-       /* remainder not maintained by this version of the system */
-       daddr_t s_tfree;        /* total free blocks*/
-       ino_t   s_tinode;       /* total free inodes */
-       short   s_m;            /* interleave factor */
-       short   s_n;            /* " " */
-       char    s_fname[6];     /* file system name */
-       char    s_fpack[6];     /* file system pack name */
-};
diff --git a/usr/sys/h/ino.h b/usr/sys/h/ino.h
deleted file mode 100644 (file)
index 90579cb..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Inode structure as it appears on
- * a disk block.
- */
-struct dinode
-{
-       unsigned short  di_mode;        /* mode and type of file */
-       short   di_nlink;       /* number of links to file */
-       short   di_uid;         /* owner's user id */
-       short   di_gid;         /* owner's group id */
-       off_t   di_size;        /* number of bytes in file */
-       char    di_addr[40];    /* disk block addresses */
-       time_t  di_atime;       /* time last accessed */
-       time_t  di_mtime;       /* time last modified */
-       time_t  di_ctime;       /* time created */
-};
-#define        INOPB   8       /* 8 inodes per block */
-/*
- * the 40 address bytes:
- *     39 used; 13 addresses
- *     of 3 bytes each.
- */
diff --git a/usr/sys/h/inode.h b/usr/sys/h/inode.h
deleted file mode 100644 (file)
index 5ced95d..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * The I node is the focus of all
- * file activity in unix. There is a unique
- * inode allocated for each active file,
- * each current directory, each mounted-on
- * file, text file, and the root. An inode is 'named'
- * by its dev/inumber pair. (iget/iget.c)
- * Data, from mode on, is read in
- * from permanent inode on volume.
- */
-
-#define        NADDR   13
-#define        NINDEX  15
-
-struct group {
-       short   g_state;
-       char    g_index;
-       char    g_rot;
-       struct  group   *g_group;
-       struct  inode   *g_inode;
-       struct  file    *g_file;
-       short   g_rotmask;
-       short   g_datq;
-       struct  chan *g_chans[NINDEX];
-};
-struct inode
-{
-       char    i_flag;
-       char    i_count;        /* reference count */
-       dev_t   i_dev;          /* device where inode resides */
-       ino_t   i_number;       /* i number, 1-to-1 with device address */
-       unsigned short  i_mode;
-       short   i_nlink;        /* directory entries */
-       short   i_uid;          /* owner */
-       short   i_gid;          /* group of owner */
-       off_t   i_size;         /* size of file */
-       union {
-               struct {
-                       daddr_t i_addr[NADDR];  /* if normal file/directory */
-                       daddr_t i_lastr;        /* last logical block read (for read-ahead) */
-               };
-               struct  {
-                       daddr_t i_rdev;                 /* i_addr[0] */
-                       struct  group   i_group;        /*  multiplexor group file */
-               };
-       } i_un;
-};
-
-
-extern struct inode inode[];   /* The inode table itself */
-struct inode *mpxip;           /* mpx virtual inode */
-
-/* flags */
-#define        ILOCK   01              /* inode is locked */
-#define        IUPD    02              /* file has been modified */
-#define        IACC    04              /* inode access time to be updated */
-#define        IMOUNT  010             /* inode is mounted on */
-#define        IWANT   020             /* some process waiting on lock */
-#define        ITEXT   040             /* inode is pure text prototype */
-#define        ICHG    0100            /* inode has been changed */
-
-/* modes */
-#define        IFMT    0170000         /* type of file */
-#define                IFDIR   0040000 /* directory */
-#define                IFCHR   0020000 /* character special */
-#define                IFBLK   0060000 /* block special */
-#define                IFREG   0100000 /* regular */
-#define                IFMPC   0030000 /* multiplexed char special */
-#define                IFMPB   0070000 /* multiplexed block special */
-#define        ISUID   04000           /* set user id on execution */
-#define        ISGID   02000           /* set group id on execution */
-#define ISVTX  01000           /* save swapped text even after use */
-#define        IREAD   0400            /* read, write, execute permissions */
-#define        IWRITE  0200
-#define        IEXEC   0100
diff --git a/usr/sys/h/map.h b/usr/sys/h/map.h
deleted file mode 100644 (file)
index d4af68b..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-struct map
-{
-       short   m_size;
-       unsigned short m_addr;
-};
-
-struct map coremap[CMAPSIZ];   /* space for core allocation */
-struct map swapmap[SMAPSIZ];   /* space for swap allocation */
diff --git a/usr/sys/h/mount.h b/usr/sys/h/mount.h
deleted file mode 100644 (file)
index dfdbc90..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * Mount structure.
- * One allocated on every mount.
- * Used to find the super block.
- */
-struct mount
-{
-       dev_t   m_dev;          /* device mounted */
-       struct buf *m_bufp;     /* pointer to superblock */
-       struct inode *m_inodp;  /* pointer to mounted on inode */
-} mount[NMOUNT];
diff --git a/usr/sys/h/mpx.h b/usr/sys/h/mpx.h
deleted file mode 100644 (file)
index 1ba6c13..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#define        M       3
-#define        C       100
-
-/*
- * character Q structure
- */
-struct clist
-{
-       int     c_cc;
-       int     c_cf;
-       int     c_cl;
-};
-
-struct chan
-{
-       char    cflag;
-       char    m, c;
-       struct  chan    *dest;
-       struct  clist   ioq;
-};
-
-/* c flags */
-#define        BLOCK   01
-
-struct line
-{
-       char    xbuf[24+2];
-       char    rbuf[100+2];
-       char    rseq;
-       char    xseq;
-       char    ackf;
-       char    xflag;
-       char    state;
-       char    time;
-       int     sum;
-       char    *ip;
-       char    *ep;
-};
-#define        WWAIT   02
-#define        CRUN    04
-#define        RWAIT   010
-#define        ALLOC   020
-#define        DIS     040
-#define        DLY     0100
-
-/*
- * machine structure
- */
-struct mach
-{
-       char    mflag;
-       char    rchan;
-       char    rcount;
-       char    xchan;
-       char    xcount;
-       struct  clist   ackq;
-       struct  clist   datq;
-       struct  clist   disq;
-       struct  chan    *chanp[128];
-};
-
-/* m flags */
-#define        RNEXT   01
-#define        MRUN    04
-#define        XNEXT   010
-
-/*
- * trace buffer
- */
-#define        TBSIZ   100
diff --git a/usr/sys/h/mx.h b/usr/sys/h/mx.h
deleted file mode 100644 (file)
index 7d5a95f..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-#define        NGROUPS         10      /* number of mpx files permitted at one time */
-#define        NCHANS          20      /* number of channel structures */
-#define        NPORTS          30      /* number of channels to i/o ports */
-#define        CNTLSIZ         10
-#define        NLEVELS         4
-#define        NMSIZE          50      /* max size of mxlstn file name */
-
-/*
- * header returned on read of mpx
- */
-struct rh {
-       short   index;
-       short   count;
-       short   ccount;
-};
-
-/*
- * head expected on write of mpx
- */
-struct wh {
-       short   index;
-       short   count;
-       short   ccount;
-       char    *data;
-};
-
-struct mx_args {
-       char    *m_name;
-       int     m_cmd;
-       int     m_arg[3];
-};
-
-
-#ifdef KERNEL
-/*
- * internal structure for channel
- */
-
-struct chan {
-       short   c_flags;
-       char    c_index;
-       char    c_line;
-       struct  group   *c_group;
-       struct  file    *c_fy;
-       struct  tty     *c_ttyp;
-       struct  clist   c_ctlx;
-       int     c_pgrp;
-       struct  tty     *c_ottyp;
-       char    c_oline;
-       union {
-               struct  clist   datq;
-       } cx;
-       union {
-               struct  clist   datq;
-               struct  chan    *c_chan;
-       } cy;
-       struct  clist   c_ctly;
-};
-
-struct schan {
-       short   c_flags;
-       char    c_index;
-       char    c_line;
-       struct  group   *c_group;
-       struct  file    *c_fy;
-       struct  tty     *c_ttyp;
-       struct  clist   c_ctlx;
-       int     c_pgrp;
-};
-
-
-/*
- * flags
- */
-#define        INUSE   01
-#define COPEN  02
-#define        XGRP    04
-#define        YGRP    010
-#define        WCLOSE  020
-#define        ISGRP   0100
-#define        BLOCK   0200
-#define        EOTMARK 0400
-#define        SIGBLK  01000
-#define        BLKMSG  01000
-#define        ENAMSG  02000
-#define        WFLUSH  04000
-#define        NMBUF   010000
-#define        PORT    020000
-#define        ALT     040000
-
-#endif
-
-
-
-
-
-
-
-
-
-/*
- * mpxchan command codes
- */
-#define        MPX     5
-#define        MPXN    6
-#define        CHAN    1
-#define JOIN   2
-#define EXTR   3
-#define        ATTACH  4
-#define        CONNECT 7
-#define        DETACH  8
-#define        DISCON  9
-#define DEBUG  10
-#define        NPGRP   11
-#define        CSIG    12
-#define PACK   13
-
-#define NDEBUGS        30
-/*
- * control channel message codes
- */
-#define M_WATCH 1
-#define M_CLOSE 2
-#define        M_EOT   3
-#define        M_OPEN  4
-#define        M_BLK   5
-#define        M_UBLK  6
-#define        DO_BLK  7
-#define        DO_UBLK 8
-#define        M_IOCTL 12
-#define        M_SIG   14
-
-
-/*
- * debug codes other than mpxchan cmds
- */
-#define MCCLOSE 29
-#define MCOPEN 28
-#define        ALL     27
-#define SCON   26
-#define        MSREAD  25
-#define        SDATA   24
-#define        MCREAD  23
-#define MCWRITE        22
-
diff --git a/usr/sys/h/pack.h b/usr/sys/h/pack.h
deleted file mode 100644 (file)
index db8a22b..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-struct header {
-       char    sync;
-       char    ksize;
-       short   sum;
-       char    cntl;
-       char    ccntl;
-};
-#define        HDRSIZ  6
-
-struct pack {
-       short   p_state;        /* line state */
-       short   p_bits;         /* mask for getepack */
-       short   p_rsize;        /* input packet size */
-       short   p_xsize;        /* output packet size */
-       struct  header p_ihbuf; /* input header */
-       struct  header p_ohbuf; /* output header */
-       char    *p_rptr;
-       char    p_mode;
-       char    **p_ipool;
-       char    p_xcount;       /* # active output buffers */
-       char    p_rcount;
-       char    p_nout,p_tout;
-       char    p_lpsize;       /* log(psize/32) */
-       char    p_timer;
-       char    p_obusy;
-       char    p_srxmit;
-       char    p_rwindow;      /* window size */
-       char    p_swindow;
-       char    p_msg;          /* control msg */
-       char    p_rmsg;         /* repeated control msg */
-       char    p_ps,p_pr;      /* last packet sent, recv'd */
-       char    p_rpr;
-       char    p_nxtps;        /* next output seq number */
-       char    p_imap;         /* bit map of input buffers */
-       char    p_pscopy;       /* newest output packet */
-       char    *p_ob[8];       /* output buffers */
-       char    *p_ib[8];       /* input buffers */
-       char    p_os[8];        /* output buffer status */
-       char    p_is[8];        /* input buffer status */
-       short   p_osum[8];      /* output checksums */
-       short   p_isum[8];      /* input checksums */
-       DSYSTEM;
-};
-#define        CHECK   0125252
-#define        SYN     020
-#define        MOD8    7
-#define        ISCNTL(a)       ((a & 0300)==0)
-#define        MIN(a,b)        ((a<b)? a:b)
-
-char   next[8];
-char   mask[8];
-int    npbits;
-int    pkactive;
-
-/*
- * driver state
- */
-#define        DEAD    0
-#define        INITa   1
-#define        INITb   2
-#define        INITab  3
-#define        LIVE    010
-#define        RXMIT   020
-#define        RREJ    040
-#define PDEBUG 0200
-#define        DRAINO  0400
-#define        WAITO   01000
-#define        DOWN    02000
-#define        RCLOSE  04000
-#define        BADFRAME 020000
-
-/*
- * io buffer states
- */
-#define        B_NULL  0
-#define        B_READY 1
-#define        B_SENT  2
-#define        B_RESID 010
-#define        B_COPY  020
-#define        B_MARK  040
-#define        B_SHORT 0100
-
-/*
- * control messages
- */
-#define        CLOSE   1
-#define        RJ      2
-#define        SRJ     3
-#define        RR      4
-#define        INITC   5
-#define        INITB   6
-#define        INITA   7
-
-#define        M_RJ    4
-#define        M_SRJ   010
-#define        M_RR    020
-#define        M_INITC 040
-#define        M_CLOSE 2
-#define        M_INITA 0200
-#define        M_INITB 0100
-
-
-
-#define        PKOPRI  31
-#define        PKIPRI  30
-
-#define        NPLINES 8
-
-/*
- * packet ioctl buf
- */
-struct piocb {
-       unsigned t;
-       short   psize;
-       short   mode;
-       short   state;
-       char    window;
-};
-
-int pkdebug;
-int pksizes[];
diff --git a/usr/sys/h/param.h b/usr/sys/h/param.h
deleted file mode 100644 (file)
index 3ddfa97..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * tunable variables
- */
-
-#define        NBUF    29              /* size of buffer cache */
-#define        NINODE  200             /* number of in core inodes */
-#define        NFILE   175             /* number of in core file structures */
-#define        NMOUNT  8               /* number of mountable file systems */
-#define        MAXMEM  (64*32)         /* max core per process - first # is Kw */
-#define        MAXUPRC 25              /* max processes per user */
-#define        SSIZE   20              /* initial stack size (*64 bytes) */
-#define        SINCR   20              /* increment of stack (*64 bytes) */
-#define        NOFILE  20              /* max open files per process */
-#define        CANBSIZ 256             /* max size of typewriter line */
-#define        CMAPSIZ 50              /* size of core allocation area */
-#define        SMAPSIZ 50              /* size of swap allocation area */
-#define        NCALL   20              /* max simultaneous time callouts */
-#define        NPROC   150             /* max number of processes */
-#define        NTEXT   40              /* max number of pure texts */
-#define        NCLIST  100             /* max total clist size */
-#define        HZ      60              /* Ticks/second of the clock */
-#define        TIMEZONE (5*60)         /* Minutes westward from Greenwich */
-#define        DSTFLAG 1               /* Daylight Saving Time applies in this locality */
-#define        MSGBUFS 128             /* Characters saved from error messages */
-#define        NCARGS  5120            /* # characters in exec arglist */
-
-/*
- * priorities
- * probably should not be
- * altered too much
- */
-
-#define        PSWP    0
-#define        PINOD   10
-#define        PRIBIO  20
-#define        PZERO   25
-#define        NZERO   20
-#define        PPIPE   26
-#define        PWAIT   30
-#define        PSLEP   40
-#define        PUSER   50
-
-/*
- * signals
- * dont change
- */
-
-#define        NSIG    17
-/*
- * No more than 16 signals (1-16) because they are
- * stored in bits in a word.
- */
-#define        SIGHUP  1       /* hangup */
-#define        SIGINT  2       /* interrupt (rubout) */
-#define        SIGQUIT 3       /* quit (FS) */
-#define        SIGINS  4       /* illegal instruction */
-#define        SIGTRC  5       /* trace or breakpoint */
-#define        SIGIOT  6       /* iot */
-#define        SIGEMT  7       /* emt */
-#define        SIGFPT  8       /* floating exception */
-#define        SIGKIL  9       /* kill, uncatchable termination */
-#define        SIGBUS  10      /* bus error */
-#define        SIGSEG  11      /* segmentation violation */
-#define        SIGSYS  12      /* bad system call */
-#define        SIGPIPE 13      /* end of pipe */
-#define        SIGCLK  14      /* alarm clock */
-#define        SIGTRM  15      /* Catchable termination */
-
-/*
- * fundamental constants of the implementation--
- * cannot be changed easily
- */
-
-#define        NBPW    sizeof(int)     /* number of bytes in an integer */
-#define        BSIZE   512             /* size of secondary block (bytes) */
-/* BSLOP can be 0 unless you have a TIU/Spider */
-#define        BSLOP   2               /* In case some device needs bigger buffers */
-#define        NINDIR  (BSIZE/sizeof(daddr_t))
-#define        BMASK   0777            /* BSIZE-1 */
-#define        BSHIFT  9               /* LOG2(BSIZE) */
-#define        NMASK   0177            /* NINDIR-1 */
-#define        NSHIFT  7               /* LOG2(NINDIR) */
-#define        USIZE   16              /* size of user block (*64) */
-#define        UBASE   0140000         /* abs. addr of user block */
-#define        NULL    0
-#define        CMASK   0               /* default mask for file creation */
-#define        NODEV   (dev_t)(-1)
-#define        ROOTINO ((ino_t)2)      /* i number of all roots */
-#define        SUPERB  ((daddr_t)1)    /* block number of the super block */
-#define        DIRSIZ  14              /* max characters per directory */
-#define        NICINOD 100             /* number of superblock inodes */
-#define        NICFREE 50              /* number of superblock free blocks */
-#define        INFSIZE 138             /* size of per-proc info for users */
-#define        CBSIZE  14              /* number of chars in a clist block */
-#define        CROUND  017             /* clist rounding: sizeof(int *) + CBSIZE - 1*/
-
-/*
- * Some macros for units conversion
- */
-/* Core clicks (64 bytes) to segments and vice versa */
-#define        ctos(x) ((x+127)/128)
-#define stoc(x) ((x)*128)
-
-/* Core clicks (64 bytes) to disk blocks */
-#define        ctod(x) ((x+7)>>3)
-
-/* inumber to disk address */
-#define        itod(x) (daddr_t)((((unsigned)x+15)>>3))
-
-/* inumber to disk offset */
-#define        itoo(x) (int)((x+15)&07)
-
-/* clicks to bytes */
-#define        ctob(x) (x<<6)
-
-/* bytes to clicks */
-#define        btoc(x) ((((unsigned)x+63)>>6))
-
-/* major part of a device */
-#define        major(x)        (int)(((unsigned)x>>8))
-
-/* minor part of a device */
-#define        minor(x)        (int)(x&0377)
-
-/* make a device number */
-#define        makedev(x,y)    (dev_t)((x)<<8 | (y))
-
-typedef        struct { int r[1]; } *  physadr;
-typedef        long            daddr_t;
-typedef char *         caddr_t;
-typedef        unsigned int    ino_t;
-typedef        long            time_t;
-typedef        int             label_t[6];     /* regs 2-7 */
-typedef        int             dev_t;
-typedef        long            off_t;
-
-/*
- * Machine-dependent bits and macros
- */
-#define        UMODE   0170000         /* usermode bits */
-#define        USERMODE(ps)    ((ps & UMODE)==UMODE)
-
-#define        INTPRI  0340            /* Priority bits */
-#define        BASEPRI(ps)     ((ps & INTPRI) != 0)
diff --git a/usr/sys/h/pk.h b/usr/sys/h/pk.h
deleted file mode 100644 (file)
index 4d8bc21..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * six-byte packet header for asynch lines.
- * headers for other devices take up the same
- * or less space.  If this changes the header
- * struct will have to become a union.
- */
-struct header {
-       char    sync;           /* sync byte */
-       char    ksize;          /* encoded packet size */
-       unsigned short sum;     /* block check of data packet */
-       char    cntl;           /* control byte */
-       char    ccntl;          /* block check of header */
-};
-#define        HDRSIZ  6
-
-/*
- * Control structure for a packet driver connection.
- */
-struct pack {
-       short   p_state;        /* line state */
-       short   p_bits;         /* mask for getepack */
-       short   p_rsize;        /* input packet size */
-       short   p_xsize;        /* output packet size */
-       struct  header p_ihbuf; /* input header */
-       struct  header p_ohbuf; /* output header */
-       char    *p_rptr;
-       char    p_mode;
-       char    **p_ipool;      /* head link to input buffer pool */
-       char    **p_io;         /* input buffer given to driver */
-       char    p_xcount;       /* # active output buffers */
-       char    p_rcount;
-       char    p_nout,p_tout;
-       char    p_lpsize;       /* log(psize/32) */
-       char    p_timer;
-       char    p_obusy;
-       char    p_srxmit;
-       char    p_rwindow;      /* window size */
-       char    p_swindow;
-       char    p_msg;          /* control msg */
-       char    p_rmsg;         /* repeated control msg */
-       char    p_ps,p_pr;      /* last packet sent, recv'd */
-       char    p_rpr;          /* copy of remote pr */
-       char    p_nxtps;        /* next output seq number */
-       char    p_imap;         /* bit map of input buffers */
-       char    p_pscopy;       /* newest output packet */
-       char    *p_ob[8];       /* output buffers */
-       char    *p_ib[8];       /* input buffers */
-       char    p_os[8];        /* output buffer status */
-       char    p_is[8];        /* input buffer status */
-       short   p_osum[8];      /* output checksums */
-       short   p_isum[8];      /* input checksums */
-       DSYSTEM;
-};
-#define        CHECK   0125252
-#define        SYN     020
-#define        MOD8    7
-#define        NOTCNTL(a)      (a & 0300)
-#define        MIN(a,b)        ((a<b)? a:b)
-
-char   next[8];
-char   mask[8];
-int    npbits;
-int    pkactive;
-int    pkzot;
-int    pkdisc;
-
-/*
- * driver state
- */
-#define        DEAD    0
-#define        INITa   1
-#define        INITb   2
-#define        INITab  3
-#define        LIVE    010
-#define        RXMIT   020
-#define        RREJ    040
-#define PDEBUG 0200
-#define        DRAINO  0400
-#define        WAITO   01000
-#define        DOWN    02000
-#define        RCLOSE  04000
-#define        BADFRAME 020000
-
-/*
- * modes
- */
-#define        SLOWMODE        0100
-/*
- * io buffer states
- */
-#define        B_NULL  0
-#define        B_READY 1
-#define        B_SENT  2
-#define        B_RESID 010
-#define        B_COPY  020
-#define        B_MARK  040
-#define        B_SHORT 0100
-
-/*
- * control messages
- */
-#define        CLOSE   1
-#define        RJ      2
-#define        SRJ     3
-#define        RR      4
-#define        INITC   5
-#define        INITB   6
-#define        INITA   7
-
-#define        M_RJ    4
-#define        M_SRJ   010
-#define        M_RR    020
-#define        M_INITC 040
-#define        M_CLOSE 2
-#define        M_INITA 0200
-#define        M_INITB 0100
-
-
-
-#define        PKOPRI  31
-#define        PKIPRI  30
-
-#define        NPLINES 8
-
-/*
- * packet ioctl buf
- */
-struct piocb {
-       unsigned t;
-       short   psize;
-       short   mode;
-       short   state;
-       char    window;
-};
-
-int pkdebug;
-int pksizes[];
-
-#define        Pwrite  1
-#define        Poutput 1
-#define        Pxint   1
-
-
-#define        Print   01
-#define        Prend   01
-#define        Pacc    01
-#define        Pread   01
-
-int    *PTRACE;
-
diff --git a/usr/sys/h/pk.p b/usr/sys/h/pk.p
deleted file mode 100644 (file)
index 5c21eed..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * kernel level
- */
-#ifdef KERNEL
-
-#define PADDR          ((struct pack *)tp->t_linep)
-#define TURNOFF                pkturnoff(tp)
-#define UCOUNT         u.u_count
-#define S              tp
-#define P              pk->p_ttyp
-#define SDEF           struct tty *tp
-#define FS             , tp
-
-#define SIGNAL         signal(pk->p_ttyp->t_pgrp, SIGPIPE)
-#define TERROR         pk->p_istate == R_ERROR
-#define SETERROR       u.u_error = EIO
-#define OBUSY          tp->t_state&BUSY
-#define        ODEAD           ((tp->t_state&CARR_ON)==0)
-char *getepack();
-#define GETEPACK       getepack(pk->p_bits)
-#define FREEPACK(a,b)  freepack(a, b)
-
-
-#define q1     tp->t_rawq
-#define q2     tp->t_canq
-#define q3     tp->t_outq
-
-#define LOCK           s = spl6()
-#define UNLOCK         splx(s)
-#define DSYSTEM                struct tty *p_ttyp
-#define ISYSTEM                tp = pk->p_ttyp
-#define SLEEP(a, b)    sleep((caddr_t)a, b)
-#define        SLEEPNO         (tp->t_chan!=NULL)
-#define WAKEUP(a)      wakeup((caddr_t)a)
-#define IOMOVE(p, c, f) iomove(p, c, f)
-#define PKGETPKT(p)
-#define DTOM(a)                dtom(a)
-#include "../h/param.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/pk.h"
-#include "../h/tty.h"
-#include "../h/buf.h"
-#include "../h/proc.h"
-
-#endif
-/*
- * user level
- */
-#ifdef USER
-#define SLEEP(a, b) 
-#define SIGNAL
-#define WAKEUP(a)
-#define DSYSTEM                int p_ifn, p_ofn
-#define ISYSTEM
-#define GETEPACK       malloc(pk->p_xsize)
-#define FREEPACK(a, b) free(a)
-#define OBUSY          0
-#define PKGETPKT(p)    pkgetpack(p);
-#define DTOM(a)                1;
-#define S              ipk, ibuf, icount
-#define SDEF           int icount; char *ibuf; struct pack *ipk
-#define UCOUNT         icount
-#define IOMOVE(p, c, f)        pkmove(p, ibuf, c, f) ; ibuf += c; UCOUNT -= c
-#define PADDR          ipk
-#define TURNOFF
-#define LOCK
-#define UNLOCK
-#define SETERROR
-#define GENERROR(p, s)
-#define        PACKSIZE        64
-#define        WINDOWS         3
-#define        PKDEBUG(l, f, s) { extern Debug; if (Debug >= l) fprintf(stderr, f, s);}
-#define        PKASSERT(e, f, v) if (!(e)) {\
-fprintf(stderr, "AERROR - (%s) ", "e");\
-fprintf(stderr, f, v);\
-pkfail();};
-#endif
diff --git a/usr/sys/h/prim.h b/usr/sys/h/prim.h
deleted file mode 100644 (file)
index a710c9f..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#define        NOSLEEP 0400
-#define        FORCE   01000
-#define        NORM    02000
-#define        KEEP    04000
-#define        CLR     010000
-
-int    bwaiting,wcount;
-
-char *getepack();
diff --git a/usr/sys/h/proc.h b/usr/sys/h/proc.h
deleted file mode 100644 (file)
index 7d6c1b1..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * One structure allocated per active
- * process. It contains all data needed
- * about the process while the
- * process may be swapped out.
- * Other per process data (user.h)
- * is swapped with the process.
- */
-struct proc {
-       char    p_stat;
-       char    p_flag;
-       char    p_pri;          /* priority, negative is high */
-       char    p_time;         /* resident time for scheduling */
-       char    p_cpu;          /* cpu usage for scheduling */
-       char    p_nice;         /* nice for cpu usage */
-       short   p_sig;          /* signals pending to this process */
-       short   p_uid;          /* user id, used to direct tty signals */
-       short   p_pgrp;         /* name of process group leader */
-       short   p_pid;          /* unique process id */
-       short   p_ppid;         /* process id of parent */
-       short   p_addr;         /* address of swappable image */
-       short   p_size;         /* size of swappable image (clicks) */
-       caddr_t p_wchan;        /* event process is awaiting */
-       struct text *p_textp;   /* pointer to text structure */
-       struct proc *p_link;    /* linked list of running processes */
-       int     p_clktim;       /* time to alarm clock signal */
-};
-
-extern struct proc proc[];     /* the proc table itself */
-
-/* stat codes */
-#define        SSLEEP  1               /* awaiting an event */
-#define        SWAIT   2               /* (abandoned state) */
-#define        SRUN    3               /* running */
-#define        SIDL    4               /* intermediate state in process creation */
-#define        SZOMB   5               /* intermediate state in process termination */
-#define        SSTOP   6               /* process being traced */
-
-/* flag codes */
-#define        SLOAD   01              /* in core */
-#define        SSYS    02              /* scheduling process */
-#define        SLOCK   04              /* process cannot be swapped */
-#define        SSWAP   010             /* process is being swapped out */
-#define        STRC    020             /* process is being traced */
-#define        SWTED   040             /* another tracing flag */
-#define        SULOCK  0100            /* user settable lock in core */
-
-/*
- * parallel proc structure
- * to replace part with times
- * to be passed to parent process
- * in ZOMBIE state.
- */
-struct xproc {
-       char    xp_stat;
-       char    xp_flag;
-       char    xp_pri;         /* priority, negative is high */
-       char    xp_time;        /* resident time for scheduling */
-       char    xp_cpu;         /* cpu usage for scheduling */
-       char    xp_nice;        /* nice for cpu usage */
-       short   xp_sig;         /* signals pending to this process */
-       short   xp_uid;         /* user id, used to direct tty signals */
-       short   xp_pgrp;        /* name of process group leader */
-       short   xp_pid;         /* unique process id */
-       short   xp_ppid;        /* process id of parent */
-       short   xp_xstat;       /* Exit status for wait */
-       time_t  xp_utime;       /* user time, this proc */
-       time_t  xp_stime;       /* system time, this proc */
-};
diff --git a/usr/sys/h/pwd.h b/usr/sys/h/pwd.h
deleted file mode 100644 (file)
index cfd941d..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-struct passwd
-{
-       char    *pw_name;
-       char    *pw_passwd;
-       int     pw_uid;
-       int     pw_gid;
-       int     pw_quota;
-       char    *pw_comment;
-       char    *pw_gecos;
-       char    *pw_dir;
-       char    *pw_shell;
-};
diff --git a/usr/sys/h/reg.h b/usr/sys/h/reg.h
deleted file mode 100644 (file)
index 9a76d64..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Location of the users' stored
- * registers relative to R0.
- * Usage is u.u_ar0[XX].
- */
-#define        R0      (0)
-#define        R1      (-2)
-#define        R2      (-9)
-#define        R3      (-8)
-#define        R4      (-7)
-#define        R5      (-6)
-#define        R6      (-3)
-#define        R7      (1)
-#define        PC      (1)
-#define        RPS     (2)
-
-#define        TBIT    020             /* PS trace bit */
diff --git a/usr/sys/h/seg.h b/usr/sys/h/seg.h
deleted file mode 100644 (file)
index 5d7d296..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * KT-11 addresses and bits.
- */
-
-#define        UISD    ((physadr)0177600)      /* first user I-space descriptor register */
-#define        UISA    ((physadr)0177640)      /* first user I-space address register */
-#define        UDSA    ((physadr)0177660)      /* first user D-space address register */
-#define        RO      02              /* access abilities */
-#define        RW      06
-#define        ED      010             /* extend direction */
-#define        TX      020             /* Software: text segment */
-#define        ABS     040             /* Software: absolute address */
-
-/*
- * structure used to address
- * a sequence of integers.
- */
-physadr        ka6;            /* 11/40 KISA6; 11/45 KDSA6 */
-
-/*
- * address to access 11/70 UNIBUS map
- */
-#define        UBMAP   ((physadr)0170200)
diff --git a/usr/sys/h/smallparam.h b/usr/sys/h/smallparam.h
deleted file mode 100644 (file)
index cfb8720..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * tunable variables
- */
-
-#define        NBUF    8               /* size of buffer cache */
-#define        NINODE  75              /* number of in core inodes */
-#define        NFILE   75              /* number of in core file structures */
-#define        NMOUNT  3               /* number of mountable file systems */
-#define        MAXMEM  (64*32)         /* max core per process - first # is Kw */
-#define        MAXUPRC 15              /* max processes per user */
-#define        SSIZE   20              /* initial stack size (*64 bytes) */
-#define        SINCR   20              /* increment of stack (*64 bytes) */
-#define        NOFILE  20              /* max open files per process */
-#define        CANBSIZ 256             /* max size of typewriter line */
-#define        CMAPSIZ 50              /* size of core allocation area */
-#define        SMAPSIZ 50              /* size of swap allocation area */
-#define        NCALL   20              /* max simultaneous time callouts */
-#define        NPROC   50              /* max number of processes */
-#define        NTEXT   25              /* max number of pure texts */
-#define        NCLIST  100             /* max total clist size */
-#define        HZ      60              /* Ticks/second of the clock */
-#define        TIMEZONE (5*60)         /* Minutes westward from Greenwich */
-#define        DSTFLAG 1               /* Daylight Saving Time applies in this locality */
-#define        MSGBUFS 128             /* Characters saved from error messages */
-#define        NCARGS  5120            /* # characters in exec arglist */
-
-/*
- * priorities
- * probably should not be
- * altered too much
- */
-
-#define        PSWP    0
-#define        PINOD   10
-#define        PRIBIO  20
-#define        PZERO   25
-#define        NZERO   20
-#define        PPIPE   26
-#define        PWAIT   30
-#define        PSLEP   40
-#define        PUSER   50
-
-/*
- * signals
- * dont change
- */
-
-#define        NSIG    17
-/*
- * No more than 16 signals (1-16) because they are
- * stored in bits in a word.
- */
-#define        SIGHUP  1       /* hangup */
-#define        SIGINT  2       /* interrupt (rubout) */
-#define        SIGQUIT 3       /* quit (FS) */
-#define        SIGINS  4       /* illegal instruction */
-#define        SIGTRC  5       /* trace or breakpoint */
-#define        SIGIOT  6       /* iot */
-#define        SIGEMT  7       /* emt */
-#define        SIGFPT  8       /* floating exception */
-#define        SIGKIL  9       /* kill, uncatchable termination */
-#define        SIGBUS  10      /* bus error */
-#define        SIGSEG  11      /* segmentation violation */
-#define        SIGSYS  12      /* bad system call */
-#define        SIGPIPE 13      /* end of pipe */
-#define        SIGCLK  14      /* alarm clock */
-#define        SIGTRM  15      /* Catchable termination */
-
-/*
- * fundamental constants of the implementation--
- * cannot be changed easily
- */
-
-#define        NBPW    sizeof(int)     /* number of bytes in an integer */
-#define        BSIZE   512             /* size of secondary block (bytes) */
-/* BSLOP can be 0 unless you have a TIU/Spider */
-#define        BSLOP   2               /* In case some device needs bigger buffers */
-#define        NINDIR  (BSIZE/sizeof(daddr_t))
-#define        BMASK   0777            /* BSIZE-1 */
-#define        BSHIFT  9               /* LOG2(BSIZE) */
-#define        NMASK   0177            /* NINDIR-1 */
-#define        NSHIFT  7               /* LOG2(NINDIR) */
-#define        USIZE   16              /* size of user block (*64) */
-#define        UBASE   0140000         /* abs. addr of user block */
-#define        NULL    0
-#define        CMASK   0               /* default mask for file creation */
-#define        NODEV   (dev_t)(-1)
-#define        ROOTINO ((ino_t)2)      /* i number of all roots */
-#define        SUPERB  ((daddr_t)1)    /* block number of the super block */
-#define        DIRSIZ  14              /* max characters per directory */
-#define        NICINOD 100             /* number of superblock inodes */
-#define        NICFREE 50              /* number of superblock free blocks */
-#define        INFSIZE 138             /* size of per-proc info for users */
-#define        CBSIZE  6               /* number of chars in a clist block */
-#define        CROUND  07              /* clist rounding: sizeof(int *) + CBSIZE - 1*/
-
-/*
- * Some macros for units conversion
- */
-/* Core clicks (64 bytes) to segments and vice versa */
-#define        ctos(x) ((x+127)/128)
-#define stoc(x) ((x)*128)
-
-/* Core clicks (64 bytes) to disk blocks */
-#define        ctod(x) ((x+7)>>3)
-
-/* inumber to disk address */
-#define        itod(x) (daddr_t)((((unsigned)x+15)>>3))
-
-/* inumber to disk offset */
-#define        itoo(x) (int)((x+15)&07)
-
-/* clicks to bytes */
-#define        ctob(x) (x<<6)
-
-/* bytes to clicks */
-#define        btoc(x) ((((unsigned)x+63)>>6))
-
-/* major part of a device */
-#define        major(x)        (int)(((unsigned)x>>8))
-
-/* minor part of a device */
-#define        minor(x)        (int)(x&0377)
-
-/* make a device number */
-#define        makedev(x,y)    (dev_t)((x)<<8 | (y))
-
-typedef        struct { int r[1]; } *  physadr;
-typedef        long            daddr_t;
-typedef char *         caddr_t;
-typedef        unsigned int    ino_t;
-typedef        long            time_t;
-typedef        int             label_t[6];     /* regs 2-7 */
-typedef        int             dev_t;
-typedef        long            off_t;
-
-/*
- * Machine-dependent bits and macros
- */
-#define        UMODE   0170000         /* usermode bits */
-#define        USERMODE(ps)    ((ps & UMODE)==UMODE)
-
-#define        INTPRI  0340            /* Priority bits */
-#define        BASEPRI(ps)     ((ps & INTPRI) != 0)
diff --git a/usr/sys/h/stat.h b/usr/sys/h/stat.h
deleted file mode 100644 (file)
index d1f4dc8..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-struct stat
-{
-       dev_t   st_dev;
-       ino_t   st_ino;
-       unsigned short st_mode;
-       short   st_nlink;
-       short   st_uid;
-       short   st_gid;
-       dev_t   st_rdev;
-       off_t   st_size;
-       time_t  st_atime;
-       time_t  st_mtime;
-       time_t  st_ctime;
-};
-
-#define        S_IFMT  0170000         /* type of file */
-#define                S_IFDIR 0040000 /* directory */
-#define                S_IFCHR 0020000 /* character special */
-#define                S_IFBLK 0060000 /* block special */
-#define                S_IFREG 0100000 /* regular */
-#define                S_IFMPC 0030000 /* multiplexed char special */
-#define                S_IFMPB 0070000 /* multiplexed block special */
-#define        S_ISUID 0004000         /* set user id on execution */
-#define        S_ISGID 0002000         /* set group id on execution */
-#define        S_ISVTX 0001000         /* save swapped text even after use */
-#define        S_IREAD 0000400         /* read permission, owner */
-#define        S_IWRITE        0000200         /* write permission, owner */
-#define        S_IEXEC 0000100         /* execute/search permission, owner */
diff --git a/usr/sys/h/systm.h b/usr/sys/h/systm.h
deleted file mode 100644 (file)
index 54d3a7a..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Random set of variables
- * used by more than one
- * routine.
- */
-char   canonb[CANBSIZ];        /* buffer for erase and kill (#@) */
-struct inode *rootdir;         /* pointer to inode of root directory */
-struct proc *runq;             /* head of linked list of running processes */
-int    cputype;                /* type of cpu =40, 45, or 70 */
-int    lbolt;                  /* time of day in 60th not in time */
-time_t time;                   /* time in sec from 1970 */
-
-/*
- * Nblkdev is the number of entries
- * (rows) in the block switch. It is
- * set in binit/bio.c by making
- * a pass over the switch.
- * Used in bounds checking on major
- * device numbers.
- */
-int    nblkdev;
-
-/*
- * Number of character switch entries.
- * Set by cinit/tty.c
- */
-int    nchrdev;
-
-int    mpid;                   /* generic for unique process id's */
-char   runin;                  /* scheduling flag */
-char   runout;                 /* scheduling flag */
-char   runrun;                 /* scheduling flag */
-char   curpri;                 /* more scheduling */
-int    maxmem;                 /* actual max memory per process */
-physadr        lks;                    /* pointer to clock device */
-daddr_t        swplo;                  /* block number of swap space */
-int    nswap;                  /* size of swap space */
-int    updlock;                /* lock for sync */
-daddr_t        rablock;                /* block to be read ahead */
-extern char    regloc[];       /* locs. of saved user registers (trap.c) */
-char   msgbuf[MSGBUFS];        /* saved "printf" characters */
-dev_t  rootdev;                /* device of the root */
-dev_t  swapdev;                /* swapping device */
-dev_t  pipedev;                /* pipe device */
-extern int     icode[];        /* user init code */
-extern int     szicode;        /* its size */
-
-dev_t getmdev();
-daddr_t        bmap();
-struct inode *ialloc();
-struct inode *iget();
-struct inode *owner();
-struct inode *maknode();
-struct inode *namei();
-struct buf *alloc();
-struct buf *getblk();
-struct buf *geteblk();
-struct buf *bread();
-struct buf *breada();
-struct filsys *getfs();
-struct file *getf();
-struct file *falloc();
-int    uchar();
-/*
- * Instrumentation
- */
-int    dk_busy;
-long   dk_time[32];
-long   dk_numb[3];
-long   dk_wds[3];
-long   tk_nin;
-long   tk_nout;
-
-/*
- * Structure of the system-entry table
- */
-extern struct sysent {
-       char    sy_narg;                /* total number of arguments */
-       char    sy_nrarg;               /* number of args in registers */
-       int     (*sy_call)();           /* handler */
-} sysent[];
diff --git a/usr/sys/h/text.h b/usr/sys/h/text.h
deleted file mode 100644 (file)
index 3e3b69e..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Text structure.
- * One allocated per pure
- * procedure on swap device.
- * Manipulated by text.c
- */
-struct text
-{
-       short   x_daddr;        /* disk address of segment (relative to swplo) */
-       short   x_caddr;        /* core address, if loaded */
-       short   x_size;         /* size (clicks) */
-       struct inode *x_iptr;   /* inode of prototype */
-       char    x_count;        /* reference count */
-       char    x_ccount;       /* number of loaded references */
-       char    x_flag;         /* traced, written flags */
-};
-
-extern struct text text[];
-
-#define        XTRC    01              /* Text may be written, exclusive use */
-#define        XWRIT   02              /* Text written into, must swap out */
-#define        XLOAD   04              /* Currently being read from file */
-#define        XLOCK   010             /* Being swapped in or out */
-#define        XWANT   020             /* Wanted for swapping */
diff --git a/usr/sys/h/timeb.h b/usr/sys/h/timeb.h
deleted file mode 100644 (file)
index 23c850c..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
- * Structure returned by ftime system call
- */
-struct timeb {
-       time_t  time;
-       unsigned short millitm;
-       short   timezone;
-       short   dstflag;
-};
diff --git a/usr/sys/h/tty.h b/usr/sys/h/tty.h
deleted file mode 100644 (file)
index 71fbd8b..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * A clist structure is the head
- * of a linked list queue of characters.
- * The characters are stored in 4-word
- * blocks containing a link and several characters.
- * The routines getc and putc
- * manipulate these structures.
- */
-struct clist
-{
-       int     c_cc;           /* character count */
-       char    *c_cf;          /* pointer to first char */
-       char    *c_cl;          /* pointer to last char */
-};
-
-/*
- * A tty structure is needed for
- * each UNIX character device that
- * is used for normal terminal IO.
- * The routines in tty.c handle the
- * common code associated with
- * these structures.
- * The definition and device dependent
- * code is in each driver. (kl.c dc.c dh.c)
- */
-
-struct tc {
-       char    t_intrc;        /* interrupt */
-       char    t_quitc;        /* quit */
-       char    t_startc;       /* start output */
-       char    t_stopc;        /* stop output */
-       char    t_eofc;         /* end-of-file */
-       char    t_brkc;         /* input delimiter (like nl) */
-};
-
-struct tty
-{
-       struct  clist t_rawq;   /* input chars right off device */
-       struct  clist t_canq;   /* input chars after erase and kill */
-       struct  clist t_outq;   /* output list to device */
-       int     (* t_oproc)();  /* routine to start output */
-       int     (* t_iproc)();  /* routine to start input */
-       struct chan *t_chan;    /* destination channel */
-       caddr_t t_linep;        /* aux line discipline pointer */
-       caddr_t t_addr;         /* device address */
-       dev_t   t_dev;          /* device number */
-       short   t_flags;        /* mode, settable by ioctl call */
-       short   t_state;        /* internal state, not visible externally */
-       short   t_pgrp;         /* process group name */
-       char    t_delct;        /* number of delimiters in raw q */
-       char    t_line;         /* line discipline */
-       char    t_col;          /* printing column of device */
-       char    t_erase;        /* erase character */
-       char    t_kill;         /* kill character */
-       char    t_char;         /* character temporary */
-       char    t_ispeed;       /* input speed */
-       char    t_ospeed;       /* output speed */
-       union {
-               struct tc;
-               struct clist t_ctlq;
-       } t_un;
-};
-
-#define        tun     tp->t_un
-
-/*
- * structure of arg for ioctl
- */
-struct ttiocb {
-       char    ioc_ispeed;
-       char    ioc_ospeed;
-       char    ioc_erase;
-       char    ioc_kill;
-       int     ioc_flags;
-};
-
-#define        TTIPRI  28
-#define        TTOPRI  29
-
-#define        CERASE  '#'             /* default special characters */
-#define        CEOT    004
-#define        CKILL   '@'
-#define        CQUIT   034             /* FS, cntl shift L */
-#define        CINTR   0177            /* DEL */
-#define        CSTOP   023             /* Stop output: ctl-s */
-#define        CSTART  021             /* Start output: ctl-q */
-#define        CBRK    0377
-
-/* limits */
-#define        TTHIWAT 100
-#define        TTLOWAT 50
-#define        TTYHOG  256
-
-/* modes */
-#define        TANDEM  01
-#define        CBREAK  02
-#define        LCASE   04
-#define        ECHO    010
-#define        CRMOD   020
-#define        RAW     040
-#define        ODDP    0100
-#define        EVENP   0200
-#define        NLDELAY 001400
-#define        TBDELAY 006000
-#define        XTABS   006000
-#define        CRDELAY 030000
-#define        VTDELAY 040000
-
-/* Hardware bits */
-#define        DONE    0200
-#define        IENABLE 0100
-
-/* Internal state bits */
-#define        TIMEOUT 01              /* Delay timeout in progress */
-#define        WOPEN   02              /* Waiting for open to complete */
-#define        ISOPEN  04              /* Device is open */
-#define        FLUSH   010             /* outq has been flushed during DMA */
-#define        CARR_ON 020             /* Software copy of carrier-present */
-#define        BUSY    040             /* Output in progress */
-#define        ASLEEP  0100            /* Wakeup when output done */
-#define        XCLUDE  0200            /* exclusive-use flag against open */
-#define        TTSTOP  0400            /* Output stopped by ctl-s */
-#define        HUPCLS  01000           /* Hang up upon last close */
-#define        TBLOCK  02000           /* tandem queue blocked */
-#define        DKCMD   04000           /* datakit command channel */
-#define        DKMPX   010000          /* datakit user-multiplexed mode */
-#define        DKCALL  020000          /* datakit dial mode */
-#define        DKLINGR 040000          /* datakit lingering close mode */
-#define        CNTLQ   0100000         /* interpret t_un as clist */
-
-/*
- * tty ioctl commands
- */
-#define        TIOCGETD        (('t'<<8)|0)
-#define        TIOCSETD        (('t'<<8)|1)
-#define        TIOCHPCL        (('t'<<8)|2)
-#define        TIOCMODG        (('t'<<8)|3)
-#define        TIOCMODS        (('t'<<8)|4)
-#define        TIOCGETP        (('t'<<8)|8)
-#define        TIOCSETP        (('t'<<8)|9)
-#define        TIOCSETN        (('t'<<8)|10)
-#define        TIOCEXCL        (('t'<<8)|13)
-#define        TIOCNXCL        (('t'<<8)|14)
-#define        TIOCFLUSH       (('t'<<8)|16)
-#define        TIOCSETC        (('t'<<8)|17)
-#define        TIOCGETC        (('t'<<8)|18)
-#define        DIOCLSTN        (('d'<<8)|1)
-#define        DIOCNTRL        (('d'<<8)|2)
-#define        DIOCMPX         (('d'<<8)|3)
-#define        DIOCNMPX        (('d'<<8)|4)
-#define        DIOCSCALL       (('d'<<8)|5)
-#define        DIOCRCALL       (('d'<<8)|6)
-#define        DIOCPGRP        (('d'<<8)|7)
-#define        DIOCGETP        (('d'<<8)|8)
-#define        DIOCSETP        (('d'<<8)|9)
-#define        DIOCLOSE        (('d'<<8)|10)
-#define        DIOCTIME        (('d'<<8)|11)
-#define        DIOCRESET       (('d'<<8)|12)
-#define        FIOCLEX         (('f'<<8)|1)
-#define        FIONCLEX        (('f'<<8)|2)
-#define        MXLSTN          (('x'<<8)|1)
-#define        MXNBLK          (('x'<<8)|2)
diff --git a/usr/sys/h/types.h b/usr/sys/h/types.h
deleted file mode 100644 (file)
index 1640008..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-typedef        long            daddr_t;        /* disk address */
-typedef        char *          caddr_t;        /* core address */
-typedef        unsigned int    ino_t;          /* i-node number */
-typedef        long            time_t;         /* a time */
-typedef        int             label_t[6];     /* program status */
-typedef        int             dev_t;          /* device code */
-typedef        long            off_t;          /* offset in file */
-       /* selectors and constructor for device code */
-#define        major(x)        (int)(((unsigned)x>>8))
-#define        minor(x)        (int)(x&0377)
-#define        makedev(x,y)    (dev_t)((x)<<8|(y))
diff --git a/usr/sys/h/user.h b/usr/sys/h/user.h
deleted file mode 100644 (file)
index d5653ed..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * The user structure.
- * One allocated per process.
- * Contains all per process data
- * that doesn't need to be referenced
- * while the process is swapped.
- * The user block is USIZE*64 bytes
- * long; resides at virtual kernel
- * loc 140000; contains the system
- * stack per user; is cross referenced
- * with the proc structure for the
- * same process.
- */
-
-#define        EXCLOSE 01
-
-struct user
-{
-       label_t u_rsav;                 /* save info when exchanging stacks */
-       int     u_fper;                 /* FP error register */
-       int     u_fpsaved;              /* FP regs saved for this proc */
-       struct {
-               int     u_fpsr;         /* FP status register */
-               double  u_fpregs[6];    /* FP registers */
-       } u_fps;
-       char    u_segflg;               /* IO flag: 0:user D; 1:system; 2:user I */
-       char    u_error;                /* return error code */
-       short   u_uid;                  /* effective user id */
-       short   u_gid;                  /* effective group id */
-       short   u_ruid;                 /* real user id */
-       short   u_rgid;                 /* real group id */
-       struct proc *u_procp;           /* pointer to proc structure */
-       int     *u_ap;                  /* pointer to arglist */
-       union {                         /* syscall return values */
-               struct  {
-                       int     r_val1;
-                       int     r_val2;
-               };
-               off_t   r_off;
-               time_t  r_time;
-       } u_r;
-       caddr_t u_base;                 /* base address for IO */
-       unsigned int u_count;           /* bytes remaining for IO */
-       off_t   u_offset;               /* offset in file for IO */
-       struct inode *u_cdir;           /* pointer to inode of current directory */
-       struct inode *u_rdir;           /* root directory of current process */
-       char    u_dbuf[DIRSIZ];         /* current pathname component */
-       caddr_t u_dirp;                 /* pathname pointer */
-       struct direct u_dent;           /* current directory entry */
-       struct inode *u_pdir;           /* inode of parent directory of dirp */
-       int     u_uisa[16];             /* prototype of segmentation addresses */
-       int     u_uisd[16];             /* prototype of segmentation descriptors */
-       struct file *u_ofile[NOFILE];   /* pointers to file structures of open files */
-       char    u_pofile[NOFILE];       /* per-process flags of open files */
-       int     u_arg[5];               /* arguments to current system call */
-       unsigned u_tsize;               /* text size (clicks) */
-       unsigned u_dsize;               /* data size (clicks) */
-       unsigned u_ssize;               /* stack size (clicks) */
-       label_t u_qsav;                 /* label variable for quits and interrupts */
-       label_t u_ssav;                 /* label variable for swapping */
-       int     u_signal[NSIG];         /* disposition of signals */
-       time_t  u_utime;                /* this process user time */
-       time_t  u_stime;                /* this process system time */
-       time_t  u_cutime;               /* sum of childs' utimes */
-       time_t  u_cstime;               /* sum of childs' stimes */
-       int     *u_ar0;                 /* address of users saved R0 */
-       struct {                        /* profile arguments */
-               short   *pr_base;       /* buffer base */
-               unsigned pr_size;       /* buffer size */
-               unsigned pr_off;        /* pc offset */
-               unsigned pr_scale;      /* pc scaling */
-       } u_prof;
-       char    u_intflg;               /* catch intr from sys */
-       char    u_sep;                  /* flag for I and D separation */
-       struct tty *u_ttyp;             /* controlling tty pointer */
-       dev_t   u_ttyd;                 /* controlling tty dev */
-       struct {                        /* header of executable file */
-               int     ux_mag;         /* magic number */
-               unsigned ux_tsize;      /* text size */
-               unsigned ux_dsize;      /* data size */
-               unsigned ux_bsize;      /* bss size */
-               unsigned ux_ssize;      /* symbol table size */
-               unsigned ux_entloc;     /* entry location */
-               unsigned ux_unused;
-               unsigned ux_relflg;
-       } u_exdata;
-       char    u_comm[DIRSIZ];
-       time_t  u_start;
-       char    u_acflag;
-       short   u_fpflag;               /* unused now, will be later */
-       short   u_cmask;                /* mask for file creation */
-       int     u_stack[1];
-                                       /* kernel stack per user
-                                        * extends from u + USIZE*64
-                                        * backward not to reach here
-                                        */
-};
-
-extern struct user u;
-
-/* u_error codes */
-#define        EPERM   1
-#define        ENOENT  2
-#define        ESRCH   3
-#define        EINTR   4
-#define        EIO     5
-#define        ENXIO   6
-#define        E2BIG   7
-#define        ENOEXEC 8
-#define        EBADF   9
-#define        ECHILD  10
-#define        EAGAIN  11
-#define        ENOMEM  12
-#define        EACCES  13
-#define        EFAULT  14
-#define        ENOTBLK 15
-#define        EBUSY   16
-#define        EEXIST  17
-#define        EXDEV   18
-#define        ENODEV  19
-#define        ENOTDIR 20
-#define        EISDIR  21
-#define        EINVAL  22
-#define        ENFILE  23
-#define        EMFILE  24
-#define        ENOTTY  25
-#define        ETXTBSY 26
-#define        EFBIG   27
-#define        ENOSPC  28
-#define        ESPIPE  29
-#define        EROFS   30
-#define        EMLINK  31
-#define        EPIPE   32
-#define        EDOM    33
-#define        ERANGE  34
diff --git a/usr/sys/sys/acct.c b/usr/sys/sys/acct.c
deleted file mode 100644 (file)
index ec3f04f..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/acct.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/inode.h"
-#include "../h/proc.h"
-#include "../h/seg.h"
-
-/*
- * Perform process accounting functions.
- */
-
-sysacct()
-{
-       register struct inode *ip;
-       register struct a {
-               char    *fname;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       if (suser()) {
-               if (uap->fname==NULL) {
-                       if (acctp) {
-                               plock(acctp);
-                               iput(acctp);
-                               acctp = NULL;
-                       }
-                       return;
-               }
-               if (acctp) {
-                       u.u_error = EBUSY;
-                       return;
-               }
-               ip = namei(uchar, 0);
-               if(ip == NULL)
-                       return;
-               if((ip->i_mode & IFMT) != IFREG) {
-                       u.u_error = EACCES;
-                       iput(ip);
-                       return;
-               }
-               acctp = ip;
-               prele(ip);
-       }
-}
-
-/*
- * On exit, write a record on the accounting file.
- */
-acct()
-{
-       register i;
-       register struct inode *ip;
-       off_t siz;
-
-       if ((ip=acctp)==NULL)
-               return;
-       plock(ip);
-       for (i=0; i<sizeof(acctbuf.ac_comm); i++)
-               acctbuf.ac_comm[i] = u.u_comm[i];
-       acctbuf.ac_utime = compress(u.u_utime);
-       acctbuf.ac_stime = compress(u.u_stime);
-       acctbuf.ac_etime = compress(time - u.u_start);
-       acctbuf.ac_btime = u.u_start;
-       acctbuf.ac_uid = u.u_ruid;
-       acctbuf.ac_gid = u.u_rgid;
-       acctbuf.ac_mem = 0;
-       acctbuf.ac_io = 0;
-       acctbuf.ac_tty = u.u_ttyd;
-       acctbuf.ac_flag = u.u_acflag;
-       siz = ip->i_size;
-       u.u_offset = siz;
-       u.u_base = (caddr_t)&acctbuf;
-       u.u_count = sizeof(acctbuf);
-       u.u_segflg = 1;
-       u.u_error = 0;
-       writei(ip);
-       if(u.u_error)
-               ip->i_size = siz;
-       prele(ip);
-}
-
-/*
- * Produce a pseudo-floating point representation
- * with 3 bits base-8 exponent, 13 bits fraction.
- */
-compress(t)
-register time_t t;
-{
-       register exp = 0, round = 0;
-
-       while (t >= 8192) {
-               exp++;
-               round = t&04;
-               t >>= 3;
-       }
-       if (round) {
-               t++;
-               if (t >= 8192) {
-                       t >>= 3;
-                       exp++;
-               }
-       }
-       return((exp<<13) + t);
-}
-
-/*
- * lock user into core as much
- * as possible. swapping may still
- * occur if core grows.
- */
-syslock()
-{
-       register struct proc *p;
-       register struct a {
-               int     flag;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       if(suser()) {
-               p = u.u_procp;
-               p->p_flag &= ~SULOCK;
-               if(uap->flag)
-                       p->p_flag |= SULOCK;
-       }
-}
diff --git a/usr/sys/sys/alloc.c b/usr/sys/sys/alloc.c
deleted file mode 100644 (file)
index 6892659..0000000
+++ /dev/null
@@ -1,319 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/mount.h"
-#include "../h/filsys.h"
-#include "../h/fblk.h"
-#include "../h/conf.h"
-#include "../h/buf.h"
-#include "../h/inode.h"
-#include "../h/ino.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-typedef        struct fblk *FBLKP;
-
-/*
- * alloc will obtain the next available
- * free disk block from the free list of
- * the specified device.
- * The super block has up to NICFREE remembered
- * free blocks; the last of these is read to
- * obtain NICFREE more . . .
- *
- * no space on dev x/y -- when
- * the free list is exhausted.
- */
-struct buf *
-alloc(dev)
-dev_t dev;
-{
-       daddr_t bno;
-       register struct filsys *fp;
-       register struct buf *bp;
-
-       fp = getfs(dev);
-       while(fp->s_flock)
-               sleep((caddr_t)&fp->s_flock, PINOD);
-       do {
-               if(fp->s_nfree <= 0)
-                       goto nospace;
-               if (fp->s_nfree > NICFREE) {
-                       prdev("Bad free count", dev);
-                       goto nospace;
-               }
-               bno = fp->s_free[--fp->s_nfree];
-               if(bno == 0)
-                       goto nospace;
-       } while (badblock(fp, bno, dev));
-       if(fp->s_nfree <= 0) {
-               fp->s_flock++;
-               bp = bread(dev, bno);
-               if ((bp->b_flags&B_ERROR) == 0) {
-                       fp->s_nfree = ((FBLKP)(bp->b_un.b_addr))->df_nfree;
-                       bcopy((caddr_t)((FBLKP)(bp->b_un.b_addr))->df_free,
-                           (caddr_t)fp->s_free, sizeof(fp->s_free));
-               }
-               brelse(bp);
-               fp->s_flock = 0;
-               wakeup((caddr_t)&fp->s_flock);
-               if (fp->s_nfree <=0)
-                       goto nospace;
-       }
-       bp = getblk(dev, bno);
-       clrbuf(bp);
-       fp->s_fmod = 1;
-       return(bp);
-
-nospace:
-       fp->s_nfree = 0;
-       prdev("no space", dev);
-       u.u_error = ENOSPC;
-       return(NULL);
-}
-
-/*
- * place the specified disk block
- * back on the free list of the
- * specified device.
- */
-free(dev, bno)
-dev_t dev;
-daddr_t bno;
-{
-       register struct filsys *fp;
-       register struct buf *bp;
-
-       fp = getfs(dev);
-       fp->s_fmod = 1;
-       while(fp->s_flock)
-               sleep((caddr_t)&fp->s_flock, PINOD);
-       if (badblock(fp, bno, dev))
-               return;
-       if(fp->s_nfree <= 0) {
-               fp->s_nfree = 1;
-               fp->s_free[0] = 0;
-       }
-       if(fp->s_nfree >= NICFREE) {
-               fp->s_flock++;
-               bp = getblk(dev, bno);
-               ((FBLKP)(bp->b_un.b_addr))->df_nfree = fp->s_nfree;
-               bcopy((caddr_t)fp->s_free,
-                       (caddr_t)((FBLKP)(bp->b_un.b_addr))->df_free,
-                       sizeof(fp->s_free));
-               fp->s_nfree = 0;
-               bwrite(bp);
-               fp->s_flock = 0;
-               wakeup((caddr_t)&fp->s_flock);
-       }
-       fp->s_free[fp->s_nfree++] = bno;
-       fp->s_fmod = 1;
-}
-
-/*
- * Check that a block number is in the
- * range between the I list and the size
- * of the device.
- * This is used mainly to check that a
- * garbage file system has not been mounted.
- *
- * bad block on dev x/y -- not in range
- */
-badblock(fp, bn, dev)
-register struct filsys *fp;
-daddr_t bn;
-dev_t dev;
-{
-
-       if (bn < fp->s_isize || bn >= fp->s_fsize) {
-               prdev("bad block", dev);
-               return(1);
-       }
-       return(0);
-}
-
-/*
- * Allocate an unused I node
- * on the specified device.
- * Used with file creation.
- * The algorithm keeps up to
- * NICINOD spare I nodes in the
- * super block. When this runs out,
- * a linear search through the
- * I list is instituted to pick
- * up NICINOD more.
- */
-struct inode *
-ialloc(dev)
-dev_t dev;
-{
-       register struct filsys *fp;
-       register struct buf *bp;
-       register struct inode *ip;
-       int i;
-       struct dinode *dp;
-       ino_t ino;
-       daddr_t adr;
-
-       fp = getfs(dev);
-       while(fp->s_ilock)
-               sleep((caddr_t)&fp->s_ilock, PINOD);
-loop:
-       if(fp->s_ninode > 0) {
-               ino = fp->s_inode[--fp->s_ninode];
-               if (ino < ROOTINO)
-                       goto loop;
-               ip = iget(dev, ino);
-               if(ip == NULL)
-                       return(NULL);
-               if(ip->i_mode == 0) {
-                       for (i=0; i<NADDR; i++)
-                               ip->i_un.i_addr[i] = 0;
-                       fp->s_fmod = 1;
-                       return(ip);
-               }
-               /*
-                * Inode was allocated after all.
-                * Look some more.
-                */
-               iput(ip);
-               goto loop;
-       }
-       fp->s_ilock++;
-       ino = 1;
-       for(adr = SUPERB+1; adr < fp->s_isize; adr++) {
-               bp = bread(dev, adr);
-               if (bp->b_flags & B_ERROR) {
-                       brelse(bp);
-                       ino += INOPB;
-                       continue;
-               }
-               dp = bp->b_un.b_dino;
-               for(i=0; i<INOPB; i++) {
-                       if(dp->di_mode != 0)
-                               goto cont;
-                       for(ip = &inode[0]; ip < &inode[NINODE]; ip++)
-                       if(dev==ip->i_dev && ino==ip->i_number)
-                               goto cont;
-                       fp->s_inode[fp->s_ninode++] = ino;
-                       if(fp->s_ninode >= NICINOD)
-                               break;
-               cont:
-                       ino++;
-                       dp++;
-               }
-               brelse(bp);
-               if(fp->s_ninode >= NICINOD)
-                       break;
-       }
-       fp->s_ilock = 0;
-       wakeup((caddr_t)&fp->s_ilock);
-       if(fp->s_ninode > 0)
-               goto loop;
-       prdev("Out of inodes", dev);
-       u.u_error = ENOSPC;
-       return(NULL);
-}
-
-/*
- * Free the specified I node
- * on the specified device.
- * The algorithm stores up
- * to NICINOD I nodes in the super
- * block and throws away any more.
- */
-ifree(dev, ino)
-dev_t dev;
-ino_t ino;
-{
-       register struct filsys *fp;
-
-       fp = getfs(dev);
-       if(fp->s_ilock)
-               return;
-       if(fp->s_ninode >= NICINOD)
-               return;
-       fp->s_inode[fp->s_ninode++] = ino;
-       fp->s_fmod = 1;
-}
-
-/*
- * getfs maps a device number into
- * a pointer to the incore super
- * block.
- * The algorithm is a linear
- * search through the mount table.
- * A consistency check of the
- * in core free-block and i-node
- * counts.
- *
- * bad count on dev x/y -- the count
- *     check failed. At this point, all
- *     the counts are zeroed which will
- *     almost certainly lead to "no space"
- *     diagnostic
- * panic: no fs -- the device is not mounted.
- *     this "cannot happen"
- */
-struct filsys *
-getfs(dev)
-dev_t dev;
-{
-       register struct mount *mp;
-       register struct filsys *fp;
-
-       for(mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
-       if(mp->m_bufp != NULL && mp->m_dev == dev) {
-               fp = mp->m_bufp->b_un.b_filsys;
-               if(fp->s_nfree > NICFREE || fp->s_ninode > NICINOD) {
-                       prdev("bad count", dev);
-                       fp->s_nfree = 0;
-                       fp->s_ninode = 0;
-               }
-               return(fp);
-       }
-       panic("no fs");
-       return(NULL);
-}
-
-/*
- * update is the internal name of
- * 'sync'. It goes through the disk
- * queues to initiate sandbagged IO;
- * goes through the I nodes to write
- * modified nodes; and it goes through
- * the mount table to initiate modified
- * super blocks.
- */
-update()
-{
-       register struct inode *ip;
-       register struct mount *mp;
-       register struct buf *bp;
-       struct filsys *fp;
-
-       if(updlock)
-               return;
-       updlock++;
-       for(mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
-               if(mp->m_bufp != NULL) {
-                       fp = mp->m_bufp->b_un.b_filsys;
-                       if(fp->s_fmod==0 || fp->s_ilock!=0 ||
-                          fp->s_flock!=0 || fp->s_ronly!=0)
-                               continue;
-                       bp = getblk(mp->m_dev, SUPERB);
-                       if (bp->b_flags & B_ERROR)
-                               continue;
-                       fp->s_fmod = 0;
-                       fp->s_time = time;
-                       bcopy((caddr_t)fp, bp->b_un.b_addr, BSIZE);
-                       bwrite(bp);
-               }
-       for(ip = &inode[0]; ip < &inode[NINODE]; ip++)
-               if((ip->i_flag&ILOCK)==0 && ip->i_count) {
-                       ip->i_flag |= ILOCK;
-                       ip->i_count++;
-                       iupdat(ip, &time, &time);
-                       iput(ip);
-               }
-       updlock = 0;
-       bflush(NODEV);
-}
diff --git a/usr/sys/sys/clock.c b/usr/sys/sys/clock.c
deleted file mode 100644 (file)
index 70e2c4c..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/callo.h"
-#include "../h/seg.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/proc.h"
-#include "../h/reg.h"
-
-#define        SCHMAG  8/10
-
-/*
- * clock is called straight from
- * the real time clock interrupt.
- *
- * Functions:
- *     reprime clock
- *     copy *switches to display
- *     implement callouts
- *     maintain user/system times
- *     maintain date
- *     profile
- *     lightning bolt wakeup (every second)
- *     alarm clock signals
- *     jab the scheduler
- */
-
-clock(dev, sp, r1, nps, r0, pc, ps)
-dev_t dev;
-caddr_t pc;
-{
-       register struct callo *p1, *p2;
-       register struct proc *pp;
-       int a;
-       extern caddr_t waitloc;
-
-       /*
-        * restart clock
-        */
-
-       lks->r[0] = 0115;
-
-       /*
-        * display register
-        */
-
-       display();
-       /*
-        * callouts
-        * if none, just continue
-        * else update first non-zero time
-        */
-
-       if(callout[0].c_func == NULL)
-               goto out;
-       p2 = &callout[0];
-       while(p2->c_time<=0 && p2->c_func!=NULL)
-               p2++;
-       p2->c_time--;
-
-       /*
-        * if ps is high, just return
-        */
-       if (BASEPRI(ps))
-               goto out;
-
-       /*
-        * callout
-        */
-
-       spl5();
-       if(callout[0].c_time <= 0) {
-               p1 = &callout[0];
-               while(p1->c_func != 0 && p1->c_time <= 0) {
-                       (*p1->c_func)(p1->c_arg);
-                       p1++;
-               }
-               p2 = &callout[0];
-               while(p2->c_func = p1->c_func) {
-                       p2->c_time = p1->c_time;
-                       p2->c_arg = p1->c_arg;
-                       p1++;
-                       p2++;
-               }
-       }
-
-       /*
-        * lightning bolt time-out
-        * and time of day
-        */
-out:
-       a = dk_busy&07;
-       if (USERMODE(ps)) {
-               u.u_utime++;
-               if(u.u_prof.pr_scale)
-                       addupc(pc, &u.u_prof, 1);
-               if(u.u_procp->p_nice > NZERO)
-                       a += 8;
-       } else {
-               a += 16;
-               if (pc == waitloc)
-                       a += 8;
-               u.u_stime++;
-       }
-       dk_time[a] += 1;
-       pp = u.u_procp;
-       if(++pp->p_cpu == 0)
-               pp->p_cpu--;
-       if(++lbolt >= HZ) {
-               if (BASEPRI(ps))
-                       return;
-               lbolt -= HZ;
-               ++time;
-               spl1();
-               runrun++;
-               wakeup((caddr_t)&lbolt);
-               for(pp = &proc[0]; pp < &proc[NPROC]; pp++)
-               if (pp->p_stat && pp->p_stat<SZOMB) {
-                       if(pp->p_time != 127)
-                               pp->p_time++;
-                       if(pp->p_clktim)
-                               if(--pp->p_clktim == 0)
-                                       psignal(pp, SIGCLK);
-                       a = (pp->p_cpu & 0377)*SCHMAG + pp->p_nice - NZERO;
-                       if(a < 0)
-                               a = 0;
-                       if(a > 255)
-                               a = 255;
-                       pp->p_cpu = a;
-                       if(pp->p_pri >= PUSER)
-                               setpri(pp);
-               }
-               if(runin!=0) {
-                       runin = 0;
-                       wakeup((caddr_t)&runin);
-               }
-       }
-}
-
-/*
- * timeout is called to arrange that
- * fun(arg) is called in tim/HZ seconds.
- * An entry is sorted into the callout
- * structure. The time in each structure
- * entry is the number of HZ's more
- * than the previous entry.
- * In this way, decrementing the
- * first entry has the effect of
- * updating all entries.
- *
- * The panic is there because there is nothing
- * intelligent to be done if an entry won't fit.
- */
-timeout(fun, arg, tim)
-int (*fun)();
-caddr_t arg;
-{
-       register struct callo *p1, *p2;
-       register int t;
-       int s;
-
-       t = tim;
-       p1 = &callout[0];
-       s = spl7();
-       while(p1->c_func != 0 && p1->c_time <= t) {
-               t -= p1->c_time;
-               p1++;
-       }
-       if (p1 >= &callout[NCALL-1])
-               panic("Timeout table overflow");
-       p1->c_time -= t;
-       p2 = p1;
-       while(p2->c_func != 0)
-               p2++;
-       while(p2 >= p1) {
-               (p2+1)->c_time = p2->c_time;
-               (p2+1)->c_func = p2->c_func;
-               (p2+1)->c_arg = p2->c_arg;
-               p2--;
-       }
-       p1->c_time = t;
-       p1->c_func = fun;
-       p1->c_arg = arg;
-       splx(s);
-}
diff --git a/usr/sys/sys/fakemx.c b/usr/sys/sys/fakemx.c
deleted file mode 100644 (file)
index 5496063..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Fake multiplexor routines to satisfy references
- * if you don't want it.
- */
-
-#include "../h/param.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/tty.h"
-#include "../h/inode.h"
-#include "../h/mx.h"
-
-sdata(cp)
-struct chan *cp;
-{
-}
-
-mcttstart(tp)
-struct tty *tp;
-{
-}
-
-mpxchan()
-{
-       u.u_error = EINVAL;
-}
-
-mcstart(p, q)
-struct chan *p;
-caddr_t q;
-{
-}
-
-scontrol(chan, s, c)
-struct chan *chan;
-{
-}
diff --git a/usr/sys/sys/fio.c b/usr/sys/sys/fio.c
deleted file mode 100644 (file)
index 57286f3..0000000
+++ /dev/null
@@ -1,260 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/filsys.h"
-#include "../h/file.h"
-#include "../h/conf.h"
-#include "../h/inode.h"
-#include "../h/reg.h"
-#include "../h/acct.h"
-
-/*
- * Convert a user supplied
- * file descriptor into a pointer
- * to a file structure.
- * Only task is to check range
- * of the descriptor.
- */
-struct file *
-getf(f)
-register int f;
-{
-       register struct file *fp;
-
-       if(0 <= f && f < NOFILE) {
-               fp = u.u_ofile[f];
-               if(fp != NULL)
-                       return(fp);
-       }
-       u.u_error = EBADF;
-       return(NULL);
-}
-
-/*
- * Internal form of close.
- * Decrement reference count on
- * file structure.
- * Also make sure the pipe protocol
- * does not constipate.
- *
- * Decrement reference count on the inode following
- * removal to the referencing file structure.
- * Call device handler on last close.
- */
-closef(fp)
-register struct file *fp;
-{
-       register struct inode *ip;
-       int flag, mode;
-       dev_t dev;
-       register int (*cfunc)();
-       struct chan *cp;
-
-       if(fp == NULL)
-               return;
-       if (fp->f_count > 1) {
-               fp->f_count--;
-               return;
-       }
-       ip = fp->f_inode;
-       flag = fp->f_flag;
-       cp = fp->f_un.f_chan;
-       dev = (dev_t)ip->i_un.i_rdev;
-       mode = ip->i_mode;
-
-       plock(ip);
-       fp->f_count = 0;
-       if(flag & FPIPE) {
-               ip->i_mode &= ~(IREAD|IWRITE);
-               wakeup((caddr_t)ip+1);
-               wakeup((caddr_t)ip+2);
-       }
-       iput(ip);
-
-       switch(mode&IFMT) {
-
-       case IFCHR:
-       case IFMPC:
-               cfunc = cdevsw[major(dev)].d_close;
-               break;
-
-       case IFBLK:
-       case IFMPB:
-               cfunc = bdevsw[major(dev)].d_close;
-               break;
-       default:
-               return;
-       }
-
-       if ((flag & FMP) == 0)
-               for(fp=file; fp < &file[NFILE]; fp++)
-                       if (fp->f_count && fp->f_inode==ip)
-                               return;
-       (*cfunc)(dev, flag, cp);
-}
-
-/*
- * openi called to allow handler
- * of special files to initialize and
- * validate before actual IO.
- */
-openi(ip, rw)
-register struct inode *ip;
-{
-       dev_t dev;
-       register unsigned int maj;
-
-       dev = (dev_t)ip->i_un.i_rdev;
-       maj = major(dev);
-       switch(ip->i_mode&IFMT) {
-
-       case IFCHR:
-       case IFMPC:
-               if(maj >= nchrdev)
-                       goto bad;
-               (*cdevsw[maj].d_open)(dev, rw);
-               break;
-
-       case IFBLK:
-       case IFMPB:
-               if(maj >= nblkdev)
-                       goto bad;
-               (*bdevsw[maj].d_open)(dev, rw);
-       }
-       return;
-
-bad:
-       u.u_error = ENXIO;
-}
-
-/*
- * Check mode permission on inode pointer.
- * Mode is READ, WRITE or EXEC.
- * In the case of WRITE, the
- * read-only status of the file
- * system is checked.
- * Also in WRITE, prototype text
- * segments cannot be written.
- * The mode is shifted to select
- * the owner/group/other fields.
- * The super user is granted all
- * permissions.
- */
-access(ip, mode)
-register struct inode *ip;
-{
-       register m;
-
-       m = mode;
-       if(m == IWRITE) {
-               if(getfs(ip->i_dev)->s_ronly != 0) {
-                       u.u_error = EROFS;
-                       return(1);
-               }
-               if (ip->i_flag&ITEXT)           /* try to free text */
-                       xrele(ip);
-               if(ip->i_flag & ITEXT) {
-                       u.u_error = ETXTBSY;
-                       return(1);
-               }
-       }
-       if(u.u_uid == 0)
-               return(0);
-       if(u.u_uid != ip->i_uid) {
-               m >>= 3;
-               if(u.u_gid != ip->i_gid)
-                       m >>= 3;
-       }
-       if((ip->i_mode&m) != 0)
-               return(0);
-
-       u.u_error = EACCES;
-       return(1);
-}
-
-/*
- * Look up a pathname and test if
- * the resultant inode is owned by the
- * current user.
- * If not, try for super-user.
- * If permission is granted,
- * return inode pointer.
- */
-struct inode *
-owner()
-{
-       register struct inode *ip;
-
-       ip = namei(uchar, 0);
-       if(ip == NULL)
-               return(NULL);
-       if(u.u_uid == ip->i_uid)
-               return(ip);
-       if(suser())
-               return(ip);
-       iput(ip);
-       return(NULL);
-}
-
-/*
- * Test if the current user is the
- * super user.
- */
-suser()
-{
-
-       if(u.u_uid == 0) {
-               u.u_acflag |= ASU;
-               return(1);
-       }
-       u.u_error = EPERM;
-       return(0);
-}
-
-/*
- * Allocate a user file descriptor.
- */
-ufalloc()
-{
-       register i;
-
-       for(i=0; i<NOFILE; i++)
-               if(u.u_ofile[i] == NULL) {
-                       u.u_r.r_val1 = i;
-                       u.u_pofile[i] = 0;
-                       return(i);
-               }
-       u.u_error = EMFILE;
-       return(-1);
-}
-
-/*
- * Allocate a user file descriptor
- * and a file structure.
- * Initialize the descriptor
- * to point at the file structure.
- *
- * no file -- if there are no available
- *     file structures.
- */
-struct file *
-falloc()
-{
-       register struct file *fp;
-       register i;
-
-       i = ufalloc();
-       if(i < 0)
-               return(NULL);
-       for(fp = &file[0]; fp < &file[NFILE]; fp++)
-               if(fp->f_count == 0) {
-                       u.u_ofile[i] = fp;
-                       fp->f_count++;
-                       fp->f_un.f_offset = 0;
-                       return(fp);
-               }
-       printf("no file\n");
-       u.u_error = ENFILE;
-       return(NULL);
-}
diff --git a/usr/sys/sys/iget.c b/usr/sys/sys/iget.c
deleted file mode 100644 (file)
index 440eb78..0000000
+++ /dev/null
@@ -1,321 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/mount.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/inode.h"
-#include "../h/ino.h"
-#include "../h/filsys.h"
-#include "../h/conf.h"
-#include "../h/buf.h"
-
-/*
- * Look up an inode by device,inumber.
- * If it is in core (in the inode structure),
- * honor the locking protocol.
- * If it is not in core, read it in from the
- * specified device.
- * If the inode is mounted on, perform
- * the indicated indirection.
- * In all cases, a pointer to a locked
- * inode structure is returned.
- *
- * printf warning: no inodes -- if the inode
- *     structure is full
- * panic: no imt -- if the mounted file
- *     system is not in the mount table.
- *     "cannot happen"
- */
-struct inode *
-iget(dev, ino)
-dev_t dev;
-ino_t ino;
-{
-       register struct inode *ip;
-       register struct mount *mp;
-       register struct inode *oip;
-       register struct buf *bp;
-       register struct dinode *dp;
-
-loop:
-       oip = NULL;
-       for(ip = &inode[0]; ip < &inode[NINODE]; ip++) {
-               if(ino == ip->i_number && dev == ip->i_dev) {
-                       if((ip->i_flag&ILOCK) != 0) {
-                               ip->i_flag |= IWANT;
-                               sleep((caddr_t)ip, PINOD);
-                               goto loop;
-                       }
-                       if((ip->i_flag&IMOUNT) != 0) {
-                               for(mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
-                               if(mp->m_inodp == ip) {
-                                       dev = mp->m_dev;
-                                       ino = ROOTINO;
-                                       goto loop;
-                               }
-                               panic("no imt");
-                       }
-                       ip->i_count++;
-                       ip->i_flag |= ILOCK;
-                       return(ip);
-               }
-               if(oip==NULL && ip->i_count==0)
-                       oip = ip;
-       }
-       ip = oip;
-       if(ip == NULL) {
-               printf("Inode table overflow\n");
-               u.u_error = ENFILE;
-               return(NULL);
-       }
-       ip->i_dev = dev;
-       ip->i_number = ino;
-       ip->i_flag = ILOCK;
-       ip->i_count++;
-       ip->i_un.i_lastr = 0;
-       bp = bread(dev, itod(ino));
-       /*
-        * Check I/O errors
-        */
-       if((bp->b_flags&B_ERROR) != 0) {
-               brelse(bp);
-               iput(ip);
-               return(NULL);
-       }
-       dp = bp->b_un.b_dino;
-       dp += itoo(ino);
-       iexpand(ip, dp);
-       brelse(bp);
-       return(ip);
-}
-
-iexpand(ip, dp)
-register struct inode *ip;
-register struct dinode *dp;
-{
-       register char *p1;
-       char *p2;
-       int i;
-
-       ip->i_mode = dp->di_mode;
-       ip->i_nlink = dp->di_nlink;
-       ip->i_uid = dp->di_uid;
-       ip->i_gid = dp->di_gid;
-       ip->i_size = dp->di_size;
-       p1 = (char *)ip->i_un.i_addr;
-       p2 = (char *)dp->di_addr;
-       for(i=0; i<NADDR; i++) {
-               *p1++ = *p2++;
-               *p1++ = 0;
-               *p1++ = *p2++;
-               *p1++ = *p2++;
-       }
-}
-
-/*
- * Decrement reference count of
- * an inode structure.
- * On the last reference,
- * write the inode out and if necessary,
- * truncate and deallocate the file.
- */
-iput(ip)
-register struct inode *ip;
-{
-
-       if(ip->i_count == 1) {
-               ip->i_flag |= ILOCK;
-               if(ip->i_nlink <= 0) {
-                       itrunc(ip);
-                       ip->i_mode = 0;
-                       ip->i_flag |= IUPD|ICHG;
-                       ifree(ip->i_dev, ip->i_number);
-               }
-               iupdat(ip, &time, &time);
-               prele(ip);
-               ip->i_flag = 0;
-               ip->i_number = 0;
-       }
-       ip->i_count--;
-       prele(ip);
-}
-
-/*
- * Check accessed and update flags on
- * an inode structure.
- * If any are on, update the inode
- * with the current time.
- */
-iupdat(ip, ta, tm)
-register struct inode *ip;
-time_t *ta, *tm;
-{
-       register struct buf *bp;
-       struct dinode *dp;
-       register char *p1;
-       char *p2;
-       int i;
-
-       if((ip->i_flag&(IUPD|IACC|ICHG)) != 0) {
-               if(getfs(ip->i_dev)->s_ronly)
-                       return;
-               bp = bread(ip->i_dev, itod(ip->i_number));
-               if (bp->b_flags & B_ERROR) {
-                       brelse(bp);
-                       return;
-               }
-               dp = bp->b_un.b_dino;
-               dp += itoo(ip->i_number);
-               dp->di_mode = ip->i_mode;
-               dp->di_nlink = ip->i_nlink;
-               dp->di_uid = ip->i_uid;
-               dp->di_gid = ip->i_gid;
-               dp->di_size = ip->i_size;
-               p1 = (char *)dp->di_addr;
-               p2 = (char *)ip->i_un.i_addr;
-               for(i=0; i<NADDR; i++) {
-                       *p1++ = *p2++;
-                       if(*p2++ != 0 && (ip->i_mode&IFMT)!=IFMPC
-                          && (ip->i_mode&IFMT)!=IFMPB)
-                               printf("iaddress > 2^24\n");
-                       *p1++ = *p2++;
-                       *p1++ = *p2++;
-               }
-               if(ip->i_flag&IACC)
-                       dp->di_atime = *ta;
-               if(ip->i_flag&IUPD)
-                       dp->di_mtime = *tm;
-               if(ip->i_flag&ICHG)
-                       dp->di_ctime = time;
-               ip->i_flag &= ~(IUPD|IACC|ICHG);
-               bdwrite(bp);
-       }
-}
-
-/*
- * Free all the disk blocks associated
- * with the specified inode structure.
- * The blocks of the file are removed
- * in reverse order. This FILO
- * algorithm will tend to maintain
- * a contiguous free list much longer
- * than FIFO.
- */
-itrunc(ip)
-register struct inode *ip;
-{
-       register i;
-       dev_t dev;
-       daddr_t bn;
-
-       i = ip->i_mode & IFMT;
-       if (i!=IFREG && i!=IFDIR)
-               return;
-       dev = ip->i_dev;
-       for(i=NADDR-1; i>=0; i--) {
-               bn = ip->i_un.i_addr[i];
-               if(bn == (daddr_t)0)
-                       continue;
-               ip->i_un.i_addr[i] = (daddr_t)0;
-               switch(i) {
-
-               default:
-                       free(dev, bn);
-                       break;
-
-               case NADDR-3:
-                       tloop(dev, bn, 0, 0);
-                       break;
-
-               case NADDR-2:
-                       tloop(dev, bn, 1, 0);
-                       break;
-
-               case NADDR-1:
-                       tloop(dev, bn, 1, 1);
-               }
-       }
-       ip->i_size = 0;
-       ip->i_flag |= ICHG|IUPD;
-}
-
-tloop(dev, bn, f1, f2)
-dev_t dev;
-daddr_t bn;
-{
-       register i;
-       register struct buf *bp;
-       register daddr_t *bap;
-       daddr_t nb;
-
-       bp = NULL;
-       for(i=NINDIR-1; i>=0; i--) {
-               if(bp == NULL) {
-                       bp = bread(dev, bn);
-                       if (bp->b_flags & B_ERROR) {
-                               brelse(bp);
-                               return;
-                       }
-                       bap = bp->b_un.b_daddr;
-               }
-               nb = bap[i];
-               if(nb == (daddr_t)0)
-                       continue;
-               if(f1) {
-                       brelse(bp);
-                       bp = NULL;
-                       tloop(dev, nb, f2, 0);
-               } else
-                       free(dev, nb);
-       }
-       if(bp != NULL)
-               brelse(bp);
-       free(dev, bn);
-}
-
-/*
- * Make a new file.
- */
-struct inode *
-maknode(mode)
-{
-       register struct inode *ip;
-
-       ip = ialloc(u.u_pdir->i_dev);
-       if(ip == NULL) {
-               iput(u.u_pdir);
-               return(NULL);
-       }
-       ip->i_flag |= IACC|IUPD|ICHG;
-       if((mode&IFMT) == 0)
-               mode |= IFREG;
-       ip->i_mode = mode & ~u.u_cmask;
-       ip->i_nlink = 1;
-       ip->i_uid = u.u_uid;
-       ip->i_gid = u.u_gid;
-       wdir(ip);
-       return(ip);
-}
-
-/*
- * Write a directory entry with
- * parameters left as side effects
- * to a call to namei.
- */
-wdir(ip)
-struct inode *ip;
-{
-
-       if (u.u_pdir->i_nlink <= 0) {
-               u.u_error = ENOTDIR;
-               goto out;
-       }
-       u.u_dent.d_ino = ip->i_number;
-       bcopy((caddr_t)u.u_dbuf, (caddr_t)u.u_dent.d_name, DIRSIZ);
-       u.u_count = sizeof(struct direct);
-       u.u_segflg = 1;
-       u.u_base = (caddr_t)&u.u_dent;
-       writei(u.u_pdir);
-out:
-       iput(u.u_pdir);
-}
diff --git a/usr/sys/sys/machdep.c b/usr/sys/sys/machdep.c
deleted file mode 100644 (file)
index 0925ae8..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/acct.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/inode.h"
-#include "../h/proc.h"
-#include "../h/seg.h"
-#include "../h/map.h"
-#include "../h/reg.h"
-#include "../h/buf.h"
-
-/*
- * Icode is the octal bootstrap
- * program executed in user mode
- * to bring up the system.
- */
-int    icode[] =
-{
-       0104413,        /* sys exec; init; initp */
-       0000014,
-       0000010,
-       0000777,        /* br . */
-       0000014,        /* initp: init; 0 */
-       0000000,
-       0062457,        /* init: </etc/init\0> */
-       0061564,
-       0064457,
-       0064556,
-       0000164,
-};
-int    szicode = sizeof(icode);
-
-/*
- * Machine-dependent startup code
- */
-startup()
-{
-       register i;
-
-       /*
-        * zero and free all of core
-        */
-
-       i = ka6->r[0] + USIZE;
-       UISD->r[0] = 077406;
-       for(;;) {
-               UISA->r[0] = i;
-               if(fuibyte((caddr_t)0) < 0)
-                       break;
-               clearseg(i);
-               maxmem++;
-               mfree(coremap, 1, i);
-               i++;
-       }
-       if(cputype == 70)
-       for(i=0; i<62; i+=2) {
-               UBMAP->r[i] = i<<12;
-               UBMAP->r[i+1] = 0;
-       }
-       printf("mem = %D\n", ctob((long)maxmem));
-       if(MAXMEM < maxmem)
-               maxmem = MAXMEM;
-       mfree(swapmap, nswap, 1);
-       swplo--;
-
-       /*
-        * determine clock
-        */
-
-       UISA->r[7] = ka6->r[1]; /* io segment */
-       UISD->r[7] = 077406;
-}
-
-/*
- * set up a physical address
- * into users virtual address space.
- */
-sysphys()
-{
-       register i, s, d;
-       register struct a {
-               int     segno;
-               int     size;
-               int     phys;
-       } *uap;
-
-       if(!suser())
-               return;
-       uap = (struct a *)u.u_ap;
-       i = uap->segno;
-       if(i < 0 || i >= 8)
-               goto bad;
-       s = uap->size;
-       if(s < 0 || s > 128)
-               goto bad;
-       d = u.u_uisd[i+8];
-       if(d != 0 && (d&ABS) == 0)
-               goto bad;
-       u.u_uisd[i+8] = 0;
-       u.u_uisa[i+8] = 0;
-       if(!u.u_sep) {
-               u.u_uisd[i] = 0;
-               u.u_uisa[i] = 0;
-       }
-       if(s) {
-               u.u_uisd[i+8] = ((s-1)<<8) | RW|ABS;
-               u.u_uisa[i+8] = uap->phys;
-               if(!u.u_sep) {
-                       u.u_uisa[i] = u.u_uisa[i+8];
-                       u.u_uisd[i] = u.u_uisd[i+8];
-               }
-       }
-       sureg();
-       return;
-
-bad:
-       u.u_error = EINVAL;
-}
-
-/*
- * Determine which clock is attached, and start it.
- * panic: no clock found
- */
-#define        CLOCK1  ((physadr)0177546)
-#define        CLOCK2  ((physadr)0172540)
-clkstart()
-{
-       lks = CLOCK1;
-       if(fuiword((caddr_t)lks) == -1) {
-               lks = CLOCK2;
-               if(fuiword((caddr_t)lks) == -1)
-                       panic("no clock");
-       }
-       lks->r[0] = 0115;
-}
-
-/*
- * Let a process handle a signal by simulating an interrupt
- */
-sendsig(p, signo)
-caddr_t p;
-{
-       register unsigned n;
-
-       n = u.u_ar0[R6] - 4;
-       grow(n);
-       suword((caddr_t)n+2, u.u_ar0[RPS]);
-       suword((caddr_t)n, u.u_ar0[R7]);
-       u.u_ar0[R6] = n;
-       u.u_ar0[RPS] &= ~TBIT;
-       u.u_ar0[R7] = (int)p;
-}
-
-/*
- * 11/70 routine to allocate the
- * UNIBUS map and initialize for
- * a unibus device.
- * The code here and in
- * rhstart assumes that an rh on an 11/70
- * is an rh70 and contains 22 bit addressing.
- */
-int    maplock;
-
-mapalloc(bp)
-register struct buf *bp;
-{
-       register i, a;
-
-       if(cputype != 70)
-               return;
-       spl6();
-       while(maplock&B_BUSY) {
-               maplock |= B_WANTED;
-               sleep((caddr_t)&maplock, PSWP+1);
-       }
-       maplock |= B_BUSY;
-       spl0();
-       bp->b_flags |= B_MAP;
-       a = bp->b_xmem;
-       for(i=16; i<32; i+=2)
-               UBMAP->r[i+1] = a;
-       for(a++; i<48; i+=2)
-               UBMAP->r[i+1] = a;
-       bp->b_xmem = 1;
-}
-
-mapfree(bp)
-struct buf *bp;
-{
-
-       bp->b_flags &= ~B_MAP;
-       if(maplock&B_WANTED)
-               wakeup((caddr_t)&maplock);
-       maplock = 0;
-}
diff --git a/usr/sys/sys/main.c b/usr/sys/sys/main.c
deleted file mode 100644 (file)
index a09ca23..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/filsys.h"
-#include "../h/mount.h"
-#include "../h/map.h"
-#include "../h/proc.h"
-#include "../h/inode.h"
-#include "../h/seg.h"
-#include "../h/conf.h"
-#include "../h/buf.h"
-
-/*
- * Initialization code.
- * Called from cold start routine as
- * soon as a stack and segmentation
- * have been established.
- * Functions:
- *     clear and free user core
- *     turn on clock
- *     hand craft 0th process
- *     call all initialization routines
- *     fork - process 0 to schedule
- *          - process 1 execute bootstrap
- *
- * loop at low address in user mode -- /etc/init
- *     cannot be executed.
- */
-main()
-{
-
-       startup();
-       /*
-        * set up system process
-        */
-
-       proc[0].p_addr = ka6->r[0];
-       proc[0].p_size = USIZE;
-       proc[0].p_stat = SRUN;
-       proc[0].p_flag |= SLOAD|SSYS;
-       proc[0].p_nice = NZERO;
-       u.u_procp = &proc[0];
-       u.u_cmask = CMASK;
-
-       /*
-        * Initialize devices and
-        * set up 'known' i-nodes
-        */
-
-       clkstart();
-       cinit();
-       binit();
-       iinit();
-       rootdir = iget(rootdev, (ino_t)ROOTINO);
-       rootdir->i_flag &= ~ILOCK;
-       u.u_cdir = iget(rootdev, (ino_t)ROOTINO);
-       u.u_cdir->i_flag &= ~ILOCK;
-       u.u_rdir = NULL;
-
-       /*
-        * make init process
-        * enter scheduling loop
-        * with system process
-        */
-
-       if(newproc()) {
-               expand(USIZE + (int)btoc(szicode));
-               estabur((unsigned)0, btoc(szicode), (unsigned)0, 0, RO);
-               copyout((caddr_t)icode, (caddr_t)0, szicode);
-               /*
-                * Return goes to loc. 0 of user init
-                * code just copied out.
-                */
-               return;
-       }
-       sched();
-}
-
-/*
- * iinit is called once (from main)
- * very early in initialization.
- * It reads the root's super block
- * and initializes the current date
- * from the last modified date.
- *
- * panic: iinit -- cannot read the super
- * block. Usually because of an IO error.
- */
-iinit()
-{
-       register struct buf *cp, *bp;
-       register struct filsys *fp;
-
-       (*bdevsw[major(rootdev)].d_open)(rootdev, 1);
-       bp = bread(rootdev, SUPERB);
-       cp = geteblk();
-       if(u.u_error)
-               panic("iinit");
-       bcopy(bp->b_un.b_addr, cp->b_un.b_addr, sizeof(struct filsys));
-       brelse(bp);
-       mount[0].m_bufp = cp;
-       mount[0].m_dev = rootdev;
-       fp = cp->b_un.b_filsys;
-       fp->s_flock = 0;
-       fp->s_ilock = 0;
-       fp->s_ronly = 0;
-       time = fp->s_time;
-}
-
-/*
- * This is the set of buffers proper, whose heads
- * were declared in buf.h.  There can exist buffer
- * headers not pointing here that are used purely
- * as arguments to the I/O routines to describe
- * I/O to be done-- e.g. swbuf for
- * swapping.
- */
-char   buffers[NBUF][BSIZE+BSLOP];
-
-/*
- * Initialize the buffer I/O system by freeing
- * all buffers and setting all device buffer lists to empty.
- */
-binit()
-{
-       register struct buf *bp;
-       register struct buf *dp;
-       register int i;
-       struct bdevsw *bdp;
-
-       bfreelist.b_forw = bfreelist.b_back =
-           bfreelist.av_forw = bfreelist.av_back = &bfreelist;
-       for (i=0; i<NBUF; i++) {
-               bp = &buf[i];
-               bp->b_dev = NODEV;
-               bp->b_un.b_addr = buffers[i];
-               bp->b_back = &bfreelist;
-               bp->b_forw = bfreelist.b_forw;
-               bfreelist.b_forw->b_back = bp;
-               bfreelist.b_forw = bp;
-               bp->b_flags = B_BUSY;
-               brelse(bp);
-       }
-       for (bdp = bdevsw; bdp->d_open; bdp++) {
-               dp = bdp->d_tab;
-               if(dp) {
-                       dp->b_forw = dp;
-                       dp->b_back = dp;
-               }
-               nblkdev++;
-       }
-}
diff --git a/usr/sys/sys/malloc.c b/usr/sys/sys/malloc.c
deleted file mode 100644 (file)
index 2142ed6..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/map.h"
-
-/*
- * Allocate 'size' units from the given
- * map. Return the base of the allocated
- * space.
- * In a map, the addresses are increasing and the
- * list is terminated by a 0 size.
- * The core map unit is 64 bytes; the swap map unit
- * is 512 bytes.
- * Algorithm is first-fit.
- */
-malloc(mp, size)
-struct map *mp;
-{
-       register unsigned int a;
-       register struct map *bp;
-
-       for (bp=mp; bp->m_size; bp++) {
-               if (bp->m_size >= size) {
-                       a = bp->m_addr;
-                       bp->m_addr += size;
-                       if ((bp->m_size -= size) == 0) {
-                               do {
-                                       bp++;
-                                       (bp-1)->m_addr = bp->m_addr;
-                               } while ((bp-1)->m_size = bp->m_size);
-                       }
-                       return(a);
-               }
-       }
-       return(0);
-}
-
-/*
- * Free the previously allocated space aa
- * of size units into the specified map.
- * Sort aa into map and combine on
- * one or both ends if possible.
- */
-mfree(mp, size, a)
-struct map *mp;
-register int a;
-{
-       register struct map *bp;
-       register unsigned int t;
-
-       if ((bp = mp)==coremap && runin) {
-               runin = 0;
-               wakeup((caddr_t)&runin);        /* Wake scheduler when freeing core */
-       }
-       for (; bp->m_addr<=a && bp->m_size!=0; bp++);
-       if (bp>mp && (bp-1)->m_addr+(bp-1)->m_size == a) {
-               (bp-1)->m_size += size;
-               if (a+size == bp->m_addr) {
-                       (bp-1)->m_size += bp->m_size;
-                       while (bp->m_size) {
-                               bp++;
-                               (bp-1)->m_addr = bp->m_addr;
-                               (bp-1)->m_size = bp->m_size;
-                       }
-               }
-       } else {
-               if (a+size == bp->m_addr && bp->m_size) {
-                       bp->m_addr -= size;
-                       bp->m_size += size;
-               } else if (size) {
-                       do {
-                               t = bp->m_addr;
-                               bp->m_addr = a;
-                               a = t;
-                               t = bp->m_size;
-                               bp->m_size = size;
-                               bp++;
-                       } while (size = t);
-               }
-       }
-}
diff --git a/usr/sys/sys/mklib b/usr/sys/sys/mklib
deleted file mode 100755 (executable)
index 0fa5ccd..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-ar cr LIB1 \
-main.o \
-trap.o \
-sig.o \
-iget.o \
-prf.o \
-slp.o \
-subr.o \
-rdwri.o \
-clock.o \
-fio.o \
-malloc.o \
-alloc.o \
-machdep.o \
-nami.o \
-pipe.o \
-prim.o \
-fakemx.o \
-sysent.o \
-sys3.o \
-sys1.o \
-sys4.o \
-sys2.o \
-acct.o \
-text.o \
-ureg.o
diff --git a/usr/sys/sys/nami.c b/usr/sys/sys/nami.c
deleted file mode 100644 (file)
index b310575..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/inode.h"
-#include "../h/mount.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/buf.h"
-
-/*
- * Convert a pathname into a pointer to
- * an inode. Note that the inode is locked.
- *
- * func = function called to get next char of name
- *     &uchar if name is in user space
- *     &schar if name is in system space
- * flag = 0 if name is sought
- *     1 if name is to be created
- *     2 if name is to be deleted
- */
-struct inode *
-namei(func, flag)
-int (*func)();
-{
-       register struct inode *dp;
-       register c;
-       register char *cp;
-       struct buf *bp;
-       int i;
-       dev_t d;
-       off_t eo;
-
-       /*
-        * If name starts with '/' start from
-        * root; otherwise start from current dir.
-        */
-
-       dp = u.u_cdir;
-       if((c=(*func)()) == '/')
-               if ((dp = u.u_rdir) == NULL)
-                       dp = rootdir;
-       iget(dp->i_dev, dp->i_number);
-       while(c == '/')
-               c = (*func)();
-       if(c == '\0' && flag != 0)
-               u.u_error = ENOENT;
-
-cloop:
-       /*
-        * Here dp contains pointer
-        * to last component matched.
-        */
-
-       if(u.u_error)
-               goto out;
-       if(c == '\0')
-               return(dp);
-
-       /*
-        * If there is another component,
-        * Gather up name into
-        * users' dir buffer.
-        */
-
-       cp = &u.u_dbuf[0];
-       while (c != '/' && c != '\0' && u.u_error == 0 ) {
-               if (mpxip!=NULL && c=='!')
-                       break;
-               if(cp < &u.u_dbuf[DIRSIZ])
-                       *cp++ = c;
-               c = (*func)();
-       }
-       while(cp < &u.u_dbuf[DIRSIZ])
-               *cp++ = '\0';
-       while(c == '/')
-               c = (*func)();
-       if (c == '!' && mpxip != NULL) {
-               iput(dp);
-               plock(mpxip);
-               mpxip->i_count++;
-               return(mpxip);
-       }
-
-seloop:
-       /*
-        * dp must be a directory and
-        * must have X permission.
-        */
-
-       if((dp->i_mode&IFMT) != IFDIR)
-               u.u_error = ENOTDIR;
-       access(dp, IEXEC);
-       if(u.u_error)
-               goto out;
-
-       /*
-        * set up to search a directory
-        */
-       u.u_offset = 0;
-       u.u_segflg = 1;
-       eo = 0;
-       bp = NULL;
-
-eloop:
-
-       /*
-        * If at the end of the directory,
-        * the search failed. Report what
-        * is appropriate as per flag.
-        */
-
-       if(u.u_offset >= dp->i_size) {
-               if(bp != NULL)
-                       brelse(bp);
-               if(flag==1 && c=='\0') {
-                       if(access(dp, IWRITE))
-                               goto out;
-                       u.u_pdir = dp;
-                       if(eo)
-                               u.u_offset = eo-sizeof(struct direct);
-                       else
-                               dp->i_flag |= IUPD|ICHG;
-                       return(NULL);
-               }
-               u.u_error = ENOENT;
-               goto out;
-       }
-
-       /*
-        * If offset is on a block boundary,
-        * read the next directory block.
-        * Release previous if it exists.
-        */
-
-       if((u.u_offset&BMASK) == 0) {
-               if(bp != NULL)
-                       brelse(bp);
-               bp = bread(dp->i_dev,
-                       bmap(dp, (daddr_t)(u.u_offset>>BSHIFT), B_READ));
-               if (bp->b_flags & B_ERROR) {
-                       brelse(bp);
-                       goto out;
-               }
-       }
-
-       /*
-        * Note first empty directory slot
-        * in eo for possible creat.
-        * String compare the directory entry
-        * and the current component.
-        * If they do not match, go back to eloop.
-        */
-
-       bcopy(bp->b_un.b_addr+(u.u_offset&BMASK), (caddr_t)&u.u_dent,
-               sizeof(struct direct));
-       u.u_offset += sizeof(struct direct);
-       if(u.u_dent.d_ino == 0) {
-               if(eo == 0)
-                       eo = u.u_offset;
-               goto eloop;
-       }
-       for(i=0; i<DIRSIZ; i++)
-               if(u.u_dbuf[i] != u.u_dent.d_name[i])
-                       goto eloop;
-
-       /*
-        * Here a component matched in a directory.
-        * If there is more pathname, go back to
-        * cloop, otherwise return.
-        */
-
-       if(bp != NULL)
-               brelse(bp);
-       if(flag==2 && c=='\0') {
-               if(access(dp, IWRITE))
-                       goto out;
-               return(dp);
-       }
-       d = dp->i_dev;
-       if(u.u_dent.d_ino == ROOTINO)
-       if(dp->i_number == ROOTINO)
-       if(u.u_dent.d_name[1] == '.')
-               for(i=1; i<NMOUNT; i++)
-                       if(mount[i].m_bufp != NULL)
-                       if(mount[i].m_dev == d) {
-                               iput(dp);
-                               dp = mount[i].m_inodp;
-                               dp->i_count++;
-                               plock(dp);
-                               goto seloop;
-                       }
-       iput(dp);
-       dp = iget(d, u.u_dent.d_ino);
-       if(dp == NULL)
-               return(NULL);
-       goto cloop;
-
-out:
-       iput(dp);
-       return(NULL);
-}
-
-/*
- * Return the next character from the
- * kernel string pointed at by dirp.
- */
-schar()
-{
-
-       return(*u.u_dirp++ & 0377);
-}
-
-/*
- * Return the next character from the
- * user string pointed at by dirp.
- */
-uchar()
-{
-       register c;
-
-       c = fubyte(u.u_dirp++);
-       if(c == -1)
-               u.u_error = EFAULT;
-       return(c);
-}
diff --git a/usr/sys/sys/pipe.c b/usr/sys/sys/pipe.c
deleted file mode 100644 (file)
index 1ca26ba..0000000
+++ /dev/null
@@ -1,216 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/inode.h"
-#include "../h/file.h"
-#include "../h/reg.h"
-
-/*
- * Max allowable buffering per pipe.
- * This is also the max size of the
- * file created to implement the pipe.
- * If this size is bigger than 5120,
- * pipes will be implemented with large
- * files, which is probably not good.
- */
-#define        PIPSIZ  4096
-
-/*
- * The sys-pipe entry.
- * Allocate an inode on the root device.
- * Allocate 2 file structures.
- * Put it all together with flags.
- */
-pipe()
-{
-       register struct inode *ip;
-       register struct file *rf, *wf;
-       int r;
-
-       ip = ialloc(pipedev);
-       if(ip == NULL)
-               return;
-       rf = falloc();
-       if(rf == NULL) {
-               iput(ip);
-               return;
-       }
-       r = u.u_r.r_val1;
-       wf = falloc();
-       if(wf == NULL) {
-               rf->f_count = 0;
-               u.u_ofile[r] = NULL;
-               iput(ip);
-               return;
-       }
-       u.u_r.r_val2 = u.u_r.r_val1;
-       u.u_r.r_val1 = r;
-       wf->f_flag = FWRITE|FPIPE;
-       wf->f_inode = ip;
-       rf->f_flag = FREAD|FPIPE;
-       rf->f_inode = ip;
-       ip->i_count = 2;
-       ip->i_mode = IFREG;
-       ip->i_flag = IACC|IUPD|ICHG;
-}
-
-/*
- * Read call directed to a pipe.
- */
-readp(fp)
-register struct file *fp;
-{
-       register struct inode *ip;
-
-       ip = fp->f_inode;
-
-loop:
-       /*
-        * Very conservative locking.
-        */
-
-       plock(ip);
-       /*
-        * If nothing in the pipe, wait.
-        */
-       if (ip->i_size == 0) {
-               /*
-                * If there are not both reader and
-                * writer active, return without
-                * satisfying read.
-                */
-               prele(ip);
-               if(ip->i_count < 2)
-                       return;
-               ip->i_mode |= IREAD;
-               sleep((caddr_t)ip+2, PPIPE);
-               goto loop;
-       }
-
-       /*
-        * Read and return
-        */
-
-       u.u_offset = fp->f_un.f_offset;
-       readi(ip);
-       fp->f_un.f_offset = u.u_offset;
-       /*
-        * If reader has caught up with writer, reset
-        * offset and size to 0.
-        */
-       if (fp->f_un.f_offset == ip->i_size) {
-               fp->f_un.f_offset = 0;
-               ip->i_size = 0;
-               if(ip->i_mode & IWRITE) {
-                       ip->i_mode &= ~IWRITE;
-                       wakeup((caddr_t)ip+1);
-               }
-       }
-       prele(ip);
-}
-
-/*
- * Write call directed to a pipe.
- */
-writep(fp)
-register struct file *fp;
-{
-       register c;
-       register struct inode *ip;
-
-       ip = fp->f_inode;
-       c = u.u_count;
-
-loop:
-
-       /*
-        * If all done, return.
-        */
-
-       plock(ip);
-       if(c == 0) {
-               prele(ip);
-               u.u_count = 0;
-               return;
-       }
-
-       /*
-        * If there are not both read and
-        * write sides of the pipe active,
-        * return error and signal too.
-        */
-
-       if(ip->i_count < 2) {
-               prele(ip);
-               u.u_error = EPIPE;
-               psignal(u.u_procp, SIGPIPE);
-               return;
-       }
-
-       /*
-        * If the pipe is full,
-        * wait for reads to deplete
-        * and truncate it.
-        */
-
-       if(ip->i_size >= PIPSIZ) {
-               ip->i_mode |= IWRITE;
-               prele(ip);
-               sleep((caddr_t)ip+1, PPIPE);
-               goto loop;
-       }
-
-       /*
-        * Write what is possible and
-        * loop back.
-        * If writing less than PIPSIZ, it always goes.
-        * One can therefore get a file > PIPSIZ if write
-        * sizes do not divide PIPSIZ.
-        */
-
-       u.u_offset = ip->i_size;
-       u.u_count = min((unsigned)c, (unsigned)PIPSIZ);
-       c -= u.u_count;
-       writei(ip);
-       prele(ip);
-       if(ip->i_mode&IREAD) {
-               ip->i_mode &= ~IREAD;
-               wakeup((caddr_t)ip+2);
-       }
-       goto loop;
-}
-
-/*
- * Lock a pipe.
- * If its already locked,
- * set the WANT bit and sleep.
- */
-plock(ip)
-register struct inode *ip;
-{
-
-       while(ip->i_flag&ILOCK) {
-               ip->i_flag |= IWANT;
-               sleep((caddr_t)ip, PINOD);
-       }
-       ip->i_flag |= ILOCK;
-}
-
-/*
- * Unlock a pipe.
- * If WANT bit is on,
- * wakeup.
- * This routine is also used
- * to unlock inodes in general.
- */
-prele(ip)
-register struct inode *ip;
-{
-
-       ip->i_flag &= ~ILOCK;
-       if(ip->i_flag&IWANT) {
-               ip->i_flag &= ~IWANT;
-               wakeup((caddr_t)ip);
-       }
-}
diff --git a/usr/sys/sys/prf.c b/usr/sys/sys/prf.c
deleted file mode 100644 (file)
index 4ba9863..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/seg.h"
-#include "../h/buf.h"
-#include "../h/conf.h"
-
-/*
- * In case console is off,
- * panicstr contains argument to last
- * call to panic.
- */
-
-char   *panicstr;
-
-/*
- * Scaled down version of C Library printf.
- * Only %s %u %d (==%u) %o %x %D are recognized.
- * Used to print diagnostic information
- * directly on console tty.
- * Since it is not interrupt driven,
- * all system activities are pretty much
- * suspended.
- * Printf should not be used for chit-chat.
- */
-/* VARARGS 1 */
-printf(fmt, x1)
-register char *fmt;
-unsigned x1;
-{
-       register c;
-       register unsigned int *adx;
-       char *s;
-
-       adx = &x1;
-loop:
-       while((c = *fmt++) != '%') {
-               if(c == '\0')
-                       return;
-               putchar(c);
-       }
-       c = *fmt++;
-       if(c == 'd' || c == 'u' || c == 'o' || c == 'x')
-               printn((long)*adx, c=='o'? 8: (c=='x'? 16:10));
-       else if(c == 's') {
-               s = (char *)*adx;
-               while(c = *s++)
-                       putchar(c);
-       } else if (c == 'D') {
-               printn(*(long *)adx, 10);
-               adx += (sizeof(long) / sizeof(int)) - 1;
-       }
-       adx++;
-       goto loop;
-}
-
-/*
- * Print an unsigned integer in base b.
- */
-printn(n, b)
-long n;
-{
-       register long a;
-
-       if (n<0) {      /* shouldn't happen */
-               putchar('-');
-               n = -n;
-       }
-       if(a = n/b)
-               printn(a, b);
-       putchar("0123456789ABCDEF"[(int)(n%b)]);
-}
-
-/*
- * Panic is called on unresolvable
- * fatal errors.
- * It syncs, prints "panic: mesg" and
- * then loops.
- */
-panic(s)
-char *s;
-{
-       panicstr = s;
-       update();
-       printf("panic: %s\n", s);
-       for(;;)
-               idle();
-}
-
-/*
- * prdev prints a warning message of the
- * form "mesg on dev x/y".
- * x and y are the major and minor parts of
- * the device argument.
- */
-prdev(str, dev)
-char *str;
-dev_t dev;
-{
-
-       printf("%s on dev %u/%u\n", str, major(dev), minor(dev));
-}
-
-/*
- * deverr prints a diagnostic from
- * a device driver.
- * It prints the device, block number,
- * and an octal word (usually some error
- * status register) passed as argument.
- */
-deverror(bp, o1, o2)
-register struct buf *bp;
-{
-
-       prdev("err", bp->b_dev);
-       printf("bn=%D er=%o,%o\n", bp->b_blkno, o1, o2);
-}
diff --git a/usr/sys/sys/prim.c b/usr/sys/sys/prim.c
deleted file mode 100644 (file)
index 9f686a7..0000000
+++ /dev/null
@@ -1,326 +0,0 @@
-#include "../h/param.h"
-#include "../h/tty.h"
-#include "../h/systm.h"
-#include "../h/conf.h"
-#include "../h/buf.h"
-
-struct cblock {
-       struct cblock *c_next;
-       char    c_info[CBSIZE];
-};
-
-struct cblock  cfree[NCLIST];
-struct cblock  *cfreelist;
-int    cbad;
-
-/*
- * Character list get/put
- */
-getc(p)
-register struct clist *p;
-{
-       register struct cblock *bp;
-       register int c, s;
-
-       s = spl6();
-       if (p->c_cc <= 0) {
-               c = -1;
-               p->c_cc = 0;
-               p->c_cf = p->c_cl = NULL;
-       } else {
-               c = *p->c_cf++ & 0377;
-               if (--p->c_cc<=0) {
-                       bp = (struct cblock *)(p->c_cf-1);
-                       bp = (struct cblock *) ((int)bp & ~CROUND);
-                       p->c_cf = NULL;
-                       p->c_cl = NULL;
-                       bp->c_next = cfreelist;
-                       cfreelist = bp;
-               } else if (((int)p->c_cf & CROUND) == 0){
-                       bp = (struct cblock *)(p->c_cf);
-                       bp--;
-                       p->c_cf = bp->c_next->c_info;
-                       bp->c_next = cfreelist;
-                       cfreelist = bp;
-               }
-       }
-       splx(s);
-       return(c);
-}
-
-/*
- * copy clist to buffer.
- * return number of bytes moved.
- */
-q_to_b(q, cp, cc)
-register struct clist *q;
-register char *cp;
-{
-       register struct cblock *bp;
-       register int s;
-       char *acp;
-
-       if (cc <= 0)
-               return(0);
-       s = spl6();
-       if (q->c_cc <= 0) {
-               q->c_cc = 0;
-               q->c_cf = q->c_cl = NULL;
-               return(0);
-       }
-       acp = cp;
-       cc++;
-
-       while (--cc) {
-               *cp++ = *q->c_cf++;
-               if (--q->c_cc <= 0) {
-                       bp = (struct cblock *)(q->c_cf-1);
-                       bp = (struct cblock *)((int)bp & ~CROUND);
-                       q->c_cf = q->c_cl = NULL;
-                       bp->c_next = cfreelist;
-                       cfreelist = bp;
-                       break;
-               }
-               if (((int)q->c_cf & CROUND) == 0) {
-                       bp = (struct cblock *)(q->c_cf);
-                       bp--;
-                       q->c_cf = bp->c_next->c_info;
-                       bp->c_next = cfreelist;
-                       cfreelist = bp;
-               }
-       }
-       splx(s);
-       return(cp-acp);
-}
-
-
-/*
- * Return count of contiguous characters
- * in clist starting at q->c_cf.
- * Stop counting if flag&character is non-null.
- */
-ndqb(q, flag)
-register struct clist *q;
-{
-register cc;
-int s;
-
-       s = spl6();
-       if (q->c_cc <= 0) {
-               cc = -q->c_cc;
-               goto out;
-       }
-       cc = ((int)q->c_cf + CBSIZE) & ~CROUND;
-       cc -= (int)q->c_cf;
-       if (q->c_cc < cc)
-               cc = q->c_cc;
-       if (flag) {
-               register char *p, *end;
-
-               p = q->c_cf;
-               end = p;
-               end += cc;
-               while (p < end) {
-                       if (*p & flag) {
-                               cc = (int)p;
-                               cc -= (int)q->c_cf;
-                               break;
-                       }
-                       p++;
-               }
-       }
-out:
-       splx(s);
-       return(cc);
-}
-
-
-
-/*
- * Update clist to show that cc characters
- * were removed.  It is assumed that cc < CBSIZE.
- */
-ndflush(q, cc)
-register struct clist *q;
-register cc;
-{
-register s;
-
-       s = spl6();
-       if (q->c_cc < 0) {
-               if (q->c_cf != NULL) {
-                       q->c_cc += cc;
-                       q->c_cf += cc;
-                       goto out;
-               }
-               q->c_cc = 0;
-               goto out;
-       }
-       if (q->c_cc == 0) {
-               goto out;
-       }
-       if (cc > CBSIZE || cc <= 0) {
-               cbad++;
-               goto out;
-       }
-       q->c_cc -= cc;
-       q->c_cf += cc;
-       if (((int)q->c_cf & CROUND) == 0) {
-               register struct cblock *bp;
-
-               bp = (struct cblock *)(q->c_cf) -1;
-               if (bp->c_next) {
-                       q->c_cf = bp->c_next->c_info;
-               } else {
-                       q->c_cf = q->c_cl = NULL;
-               }
-               bp->c_next = cfreelist;
-               cfreelist = bp;
-       } else
-       if (q->c_cc == 0) {
-               register struct cblock *bp;
-               q->c_cf = (char *)((int)q->c_cf & ~CROUND);
-               bp = (struct cblock *)(q->c_cf);
-               bp->c_next = cfreelist;
-               cfreelist = bp;
-               q->c_cf = q->c_cl = NULL;
-       }
-out:
-       splx(s);
-}
-putc(c, p)
-register struct clist *p;
-{
-       register struct cblock *bp;
-       register char *cp;
-       register s;
-
-       s = spl6();
-       if ((cp = p->c_cl) == NULL || p->c_cc < 0 ) {
-               if ((bp = cfreelist) == NULL) {
-                       splx(s);
-                       return(-1);
-               }
-               cfreelist = bp->c_next;
-               bp->c_next = NULL;
-               p->c_cf = cp = bp->c_info;
-       } else if (((int)cp & CROUND) == 0) {
-               bp = (struct cblock *)cp - 1;
-               if ((bp->c_next = cfreelist) == NULL) {
-                       splx(s);
-                       return(-1);
-               }
-               bp = bp->c_next;
-               cfreelist = bp->c_next;
-               bp->c_next = NULL;
-               cp = bp->c_info;
-       }
-       *cp++ = c;
-       p->c_cc++;
-       p->c_cl = cp;
-       splx(s);
-       return(0);
-}
-
-
-
-/*
- * copy buffer to clist.
- * return number of bytes not transfered.
- */
-b_to_q(cp, cc, q)
-register char *cp;
-struct clist *q;
-register int cc;
-{
-       register char *cq;
-       register struct cblock *bp;
-       register s, acc;
-
-       if (cc <= 0)
-               return(0);
-       acc = cc;
-
-
-       s = spl6();
-       if ((cq = q->c_cl) == NULL || q->c_cc < 0) {
-               if ((bp = cfreelist) == NULL) 
-                       goto out;
-               cfreelist = bp->c_next;
-               bp->c_next = NULL;
-               q->c_cf = cq = bp->c_info;
-       }
-
-       while (cc) {
-               if (((int)cq & CROUND) == 0) {
-                       bp = (struct cblock *) cq - 1;
-                       if ((bp->c_next = cfreelist) == NULL) 
-                               goto out;
-                       bp = bp->c_next;
-                       cfreelist = bp->c_next;
-                       bp->c_next = NULL;
-                       cq = bp->c_info;
-               }
-               *cq++ = *cp++;
-               cc--;
-       }
-out:
-       q->c_cl = cq;
-       q->c_cc += acc-cc;
-       splx(s);
-       return(cc);
-}
-
-/*
- * Initialize clist by freeing all character blocks, then count
- * number of character devices. (Once-only routine)
- */
-cinit()
-{
-       register int ccp;
-       register struct cblock *cp;
-       register struct cdevsw *cdp;
-
-       ccp = (int)cfree;
-       ccp = (ccp+CROUND) & ~CROUND;
-       for(cp=(struct cblock *)ccp; cp <= &cfree[NCLIST-1]; cp++) {
-               cp->c_next = cfreelist;
-               cfreelist = cp;
-       }
-       ccp = 0;
-       for(cdp = cdevsw; cdp->d_open; cdp++)
-               ccp++;
-       nchrdev = ccp;
-}
-
-
-/*
- * integer (2-byte) get/put
- * using clists
- */
-getw(p)
-register struct clist *p;
-{
-       register int s;
-
-       if (p->c_cc <= 1)
-               return(-1);
-       s = getc(p);
-       return(s | (getc(p)<<8));
-}
-
-putw(c, p)
-register struct clist *p;
-{
-       register s;
-
-       s = spl6();
-       if (cfreelist==NULL) {
-               splx(s);
-               return(-1);
-       }
-       putc(c, p);
-       putc(c>>8, p);
-       splx(s);
-       return(0);
-}
diff --git a/usr/sys/sys/rdwri.c b/usr/sys/sys/rdwri.c
deleted file mode 100644 (file)
index 510d618..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/inode.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/buf.h"
-#include "../h/conf.h"
-
-/*
- * Read the file corresponding to
- * the inode pointed at by the argument.
- * The actual read arguments are found
- * in the variables:
- *     u_base          core address for destination
- *     u_offset        byte offset in file
- *     u_count         number of bytes to read
- *     u_segflg        read to kernel/user/user I
- */
-readi(ip)
-register struct inode *ip;
-{
-       struct buf *bp;
-       dev_t dev;
-       daddr_t lbn, bn;
-       off_t diff;
-       register on, n;
-       register type;
-
-       if(u.u_count == 0)
-               return;
-       if(u.u_offset < 0) {
-               u.u_error = EINVAL;
-               return;
-       }
-       ip->i_flag |= IACC;
-       dev = (dev_t)ip->i_un.i_rdev;
-       type = ip->i_mode&IFMT;
-       if (type==IFCHR || type==IFMPC) {
-               return((*cdevsw[major(dev)].d_read)(dev));
-       }
-
-       do {
-               lbn = bn = u.u_offset >> BSHIFT;
-               on = u.u_offset & BMASK;
-               n = min((unsigned)(BSIZE-on), u.u_count);
-               if (type!=IFBLK && type!=IFMPB) {
-                       diff = ip->i_size - u.u_offset;
-                       if(diff <= 0)
-                               return;
-                       if(diff < n)
-                               n = diff;
-                       bn = bmap(ip, bn, B_READ);
-                       if(u.u_error)
-                               return;
-                       dev = ip->i_dev;
-               } else
-                       rablock = bn+1;
-               if ((long)bn<0) {
-                       bp = geteblk();
-                       clrbuf(bp);
-               } else if (ip->i_un.i_lastr+1==lbn)
-                       bp = breada(dev, bn, rablock);
-               else
-                       bp = bread(dev, bn);
-               ip->i_un.i_lastr = lbn;
-               n = min((unsigned)n, BSIZE-bp->b_resid);
-               if (n!=0)
-                       iomove(bp->b_un.b_addr+on, n, B_READ);
-               brelse(bp);
-       } while(u.u_error==0 && u.u_count!=0 && n>0);
-}
-
-/*
- * Write the file corresponding to
- * the inode pointed at by the argument.
- * The actual write arguments are found
- * in the variables:
- *     u_base          core address for source
- *     u_offset        byte offset in file
- *     u_count         number of bytes to write
- *     u_segflg        write to kernel/user/user I
- */
-writei(ip)
-register struct inode *ip;
-{
-       struct buf *bp;
-       dev_t dev;
-       daddr_t bn;
-       register n, on;
-       register type;
-
-       if(u.u_offset < 0) {
-               u.u_error = EINVAL;
-               return;
-       }
-       dev = (dev_t)ip->i_un.i_rdev;
-       type = ip->i_mode&IFMT;
-       if (type==IFCHR || type==IFMPC) {
-               ip->i_flag |= IUPD|ICHG;
-               (*cdevsw[major(dev)].d_write)(dev);
-               return;
-       }
-       if (u.u_count == 0)
-               return;
-
-       do {
-               bn = u.u_offset >> BSHIFT;
-               on = u.u_offset & BMASK;
-               n = min((unsigned)(BSIZE-on), u.u_count);
-               if (type!=IFBLK && type!=IFMPB) {
-                       bn = bmap(ip, bn, B_WRITE);
-                       if((long)bn<0)
-                               return;
-                       dev = ip->i_dev;
-               }
-               if(n == BSIZE) 
-                       bp = getblk(dev, bn);
-               else
-                       bp = bread(dev, bn);
-               iomove(bp->b_un.b_addr+on, n, B_WRITE);
-               if(u.u_error != 0)
-                       brelse(bp);
-               else
-                       bdwrite(bp);
-               if(u.u_offset > ip->i_size &&
-                  (type==IFDIR || type==IFREG))
-                       ip->i_size = u.u_offset;
-               ip->i_flag |= IUPD|ICHG;
-       } while(u.u_error==0 && u.u_count!=0);
-}
-
-/*
- * Return the logical maximum
- * of the 2 arguments.
- */
-max(a, b)
-unsigned a, b;
-{
-
-       if(a > b)
-               return(a);
-       return(b);
-}
-
-/*
- * Return the logical minimum
- * of the 2 arguments.
- */
-min(a, b)
-unsigned a, b;
-{
-
-       if(a < b)
-               return(a);
-       return(b);
-}
-
-/*
- * Move n bytes at byte location
- * &bp->b_un.b_addr[o] to/from (flag) the
- * user/kernel (u.segflg) area starting at u.base.
- * Update all the arguments by the number
- * of bytes moved.
- *
- * There are 2 algorithms,
- * if source address, dest address and count
- * are all even in a user copy,
- * then the machine language copyin/copyout
- * is called.
- * If not, its done byte-by-byte with
- * cpass and passc.
- */
-iomove(cp, n, flag)
-register caddr_t cp;
-register n;
-{
-       register t;
-
-       if (n==0)
-               return;
-       if(u.u_segflg != 1 &&
-         (n&(NBPW-1)) == 0 &&
-         ((int)cp&(NBPW-1)) == 0 &&
-         ((int)u.u_base&(NBPW-1)) == 0) {
-               if (flag==B_WRITE)
-                       if (u.u_segflg==0)
-                               t = copyin(u.u_base, (caddr_t)cp, n);
-                       else
-                               t = copyiin(u.u_base, (caddr_t)cp, n);
-               else
-                       if (u.u_segflg==0)
-                               t = copyout((caddr_t)cp, u.u_base, n);
-                       else
-                               t = copyiout((caddr_t)cp, u.u_base, n);
-               if (t) {
-                       u.u_error = EFAULT;
-                       return;
-               }
-               u.u_base += n;
-               u.u_offset += n;
-               u.u_count -= n;
-               return;
-       }
-       if (flag==B_WRITE) {
-               do {
-                       if ((t = cpass()) < 0)
-                               return;
-                       *cp++ = t;
-               } while (--n);
-       } else
-               do {
-                       if(passc(*cp++) < 0)
-                               return;
-               } while (--n);
-}
diff --git a/usr/sys/sys/sig.c b/usr/sys/sys/sig.c
deleted file mode 100644 (file)
index eeb7193..0000000
+++ /dev/null
@@ -1,417 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/proc.h"
-#include "../h/inode.h"
-#include "../h/reg.h"
-#include "../h/text.h"
-#include "../h/seg.h"
-
-/*
- * Priority for tracing
- */
-#define        IPCPRI  PZERO
-
-/*
- * Tracing variables.
- * Used to pass trace command from
- * parent to child being traced.
- * This data base cannot be
- * shared and is locked
- * per user.
- */
-struct
-{
-       int     ip_lock;
-       int     ip_req;
-       int     *ip_addr;
-       int     ip_data;
-} ipc;
-
-/*
- * Send the specified signal to
- * all processes with 'pgrp' as
- * process group.
- * Called by tty.c for quits and
- * interrupts.
- */
-signal(pgrp, sig)
-register pgrp;
-{
-       register struct proc *p;
-
-       if(pgrp == 0)
-               return;
-       for(p = &proc[0]; p < &proc[NPROC]; p++)
-               if(p->p_pgrp == pgrp)
-                       psignal(p, sig);
-}
-
-/*
- * Send the specified signal to
- * the specified process.
- */
-psignal(p, sig)
-register struct proc *p;
-register sig;
-{
-
-       if((unsigned)sig >= NSIG)
-               return;
-       if(sig)
-               p->p_sig |= 1<<(sig-1);
-       if(p->p_pri > PUSER)
-               p->p_pri = PUSER;
-       if(p->p_stat == SSLEEP && p->p_pri > PZERO)
-               setrun(p);
-}
-
-/*
- * Returns true if the current
- * process has a signal to process.
- * This is asked at least once
- * each time a process enters the
- * system.
- * A signal does not do anything
- * directly to a process; it sets
- * a flag that asks the process to
- * do something to itself.
- */
-issig()
-{
-       register n;
-       register struct proc *p;
-
-       p = u.u_procp;
-       while(p->p_sig) {
-               n = fsig(p);
-               if((u.u_signal[n]&1) == 0 || (p->p_flag&STRC))
-                       return(n);
-               p->p_sig &= ~(1<<(n-1));
-       }
-       return(0);
-}
-
-/*
- * Enter the tracing STOP state.
- * In this state, the parent is
- * informed and the process is able to
- * receive commands from the parent.
- */
-stop()
-{
-       register struct proc *pp, *cp;
-
-loop:
-       cp = u.u_procp;
-       if(cp->p_ppid != 1)
-       for (pp = &proc[0]; pp < &proc[NPROC]; pp++)
-               if (pp->p_pid == cp->p_ppid) {
-                       wakeup((caddr_t)pp);
-                       cp->p_stat = SSTOP;
-                       swtch();
-                       if ((cp->p_flag&STRC)==0 || procxmt())
-                               return;
-                       goto loop;
-               }
-       exit(fsig(u.u_procp));
-}
-
-/*
- * Perform the action specified by
- * the current signal.
- * The usual sequence is:
- *     if(issig())
- *             psig();
- */
-psig()
-{
-       register n, p;
-       register struct proc *rp;
-
-       rp = u.u_procp;
-       if (u.u_fpsaved==0) {
-               savfp(&u.u_fps);
-               u.u_fpsaved = 1;
-       }
-       if (rp->p_flag&STRC)
-               stop();
-       n = fsig(rp);
-       if (n==0)
-               return;
-       rp->p_sig &= ~(1<<(n-1));
-       if((p=u.u_signal[n]) != 0) {
-               u.u_error = 0;
-               if(n != SIGINS && n != SIGTRC)
-                       u.u_signal[n] = 0;
-               sendsig((caddr_t)p, n);
-               return;
-       }
-       switch(n) {
-
-       case SIGQUIT:
-       case SIGINS:
-       case SIGTRC:
-       case SIGIOT:
-       case SIGEMT:
-       case SIGFPT:
-       case SIGBUS:
-       case SIGSEG:
-       case SIGSYS:
-               if(core())
-                       n += 0200;
-       }
-       exit(n);
-}
-
-/*
- * find the signal in bit-position
- * representation in p_sig.
- */
-fsig(p)
-struct proc *p;
-{
-       register n, i;
-
-       n = p->p_sig;
-       for(i=1; i<NSIG; i++) {
-               if(n & 1)
-                       return(i);
-               n >>= 1;
-       }
-       return(0);
-}
-
-/*
- * Create a core image on the file "core"
- * If you are looking for protection glitches,
- * there are probably a wealth of them here
- * when this occurs to a suid command.
- *
- * It writes USIZE block of the
- * user.h area followed by the entire
- * data+stack segments.
- */
-core()
-{
-       register struct inode *ip;
-       register unsigned s;
-       extern schar();
-
-       u.u_error = 0;
-       u.u_dirp = "core";
-       ip = namei(schar, 1);
-       if(ip == NULL) {
-               if(u.u_error)
-                       return(0);
-               ip = maknode(0666);
-               if (ip==NULL)
-                       return(0);
-       }
-       if(!access(ip, IWRITE) &&
-          (ip->i_mode&IFMT) == IFREG &&
-          u.u_uid == u.u_ruid) {
-               itrunc(ip);
-               u.u_offset = 0;
-               u.u_base = (caddr_t)&u;
-               u.u_count = ctob(USIZE);
-               u.u_segflg = 1;
-               writei(ip);
-               s = u.u_procp->p_size - USIZE;
-               estabur((unsigned)0, s, (unsigned)0, 0, RO);
-               u.u_base = 0;
-               u.u_count = ctob(s);
-               u.u_segflg = 0;
-               writei(ip);
-       }
-       iput(ip);
-       return(u.u_error==0);
-}
-
-/*
- * grow the stack to include the SP
- * true return if successful.
- */
-
-grow(sp)
-unsigned sp;
-{
-       register si, i;
-       register struct proc *p;
-       register a;
-
-       if(sp >= -ctob(u.u_ssize))
-               return(0);
-       si = (-sp)/64 - u.u_ssize + SINCR;
-       if(si <= 0)
-               return(0);
-       if(estabur(u.u_tsize, u.u_dsize, u.u_ssize+si, u.u_sep, RO))
-               return(0);
-       p = u.u_procp;
-       expand(p->p_size+si);
-       a = p->p_addr + p->p_size;
-       for(i=u.u_ssize; i; i--) {
-               a--;
-               copyseg(a-si, a);
-       }
-       for(i=si; i; i--)
-               clearseg(--a);
-       u.u_ssize += si;
-       return(1);
-}
-
-/*
- * sys-trace system call.
- */
-ptrace()
-{
-       register struct proc *p;
-       register struct a {
-               int     data;
-               int     pid;
-               int     *addr;
-               int     req;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       if (uap->req <= 0) {
-               u.u_procp->p_flag |= STRC;
-               return;
-       }
-       for (p=proc; p < &proc[NPROC]; p++) 
-               if (p->p_stat==SSTOP
-                && p->p_pid==uap->pid
-                && p->p_ppid==u.u_procp->p_pid)
-                       goto found;
-       u.u_error = ESRCH;
-       return;
-
-    found:
-       while (ipc.ip_lock)
-               sleep((caddr_t)&ipc, IPCPRI);
-       ipc.ip_lock = p->p_pid;
-       ipc.ip_data = uap->data;
-       ipc.ip_addr = uap->addr;
-       ipc.ip_req = uap->req;
-       p->p_flag &= ~SWTED;
-       setrun(p);
-       while (ipc.ip_req > 0)
-               sleep((caddr_t)&ipc, IPCPRI);
-       u.u_r.r_val1 = ipc.ip_data;
-       if (ipc.ip_req < 0)
-               u.u_error = EIO;
-       ipc.ip_lock = 0;
-       wakeup((caddr_t)&ipc);
-}
-
-/*
- * Code that the child process
- * executes to implement the command
- * of the parent process in tracing.
- */
-procxmt()
-{
-       register int i;
-       register *p;
-       register struct text *xp;
-
-       if (ipc.ip_lock != u.u_procp->p_pid)
-               return(0);
-       i = ipc.ip_req;
-       ipc.ip_req = 0;
-       wakeup((caddr_t)&ipc);
-       switch (i) {
-
-       /* read user I */
-       case 1:
-               if (fuibyte((caddr_t)ipc.ip_addr) == -1)
-                       goto error;
-               ipc.ip_data = fuiword((caddr_t)ipc.ip_addr);
-               break;
-
-       /* read user D */
-       case 2:
-               if (fubyte((caddr_t)ipc.ip_addr) == -1)
-                       goto error;
-               ipc.ip_data = fuword((caddr_t)ipc.ip_addr);
-               break;
-
-       /* read u */
-       case 3:
-               i = (int)ipc.ip_addr;
-               if (i<0 || i >= ctob(USIZE))
-                       goto error;
-               ipc.ip_data = ((physadr)&u)->r[i>>1];
-               break;
-
-       /* write user I */
-       /* Must set up to allow writing */
-       case 4:
-               /*
-                * If text, must assure exclusive use
-                */
-               if (xp = u.u_procp->p_textp) {
-                       if (xp->x_count!=1 || xp->x_iptr->i_mode&ISVTX)
-                               goto error;
-                       xp->x_iptr->i_flag &= ~ITEXT;
-               }
-               estabur(u.u_tsize, u.u_dsize, u.u_ssize, u.u_sep, RW);
-               i = suiword((caddr_t)ipc.ip_addr, 0);
-               suiword((caddr_t)ipc.ip_addr, ipc.ip_data);
-               estabur(u.u_tsize, u.u_dsize, u.u_ssize, u.u_sep, RO);
-               if (i<0)
-                       goto error;
-               if (xp)
-                       xp->x_flag |= XWRIT;
-               break;
-
-       /* write user D */
-       case 5:
-               if (suword((caddr_t)ipc.ip_addr, 0) < 0)
-                       goto error;
-               suword((caddr_t)ipc.ip_addr, ipc.ip_data);
-               break;
-
-       /* write u */
-       case 6:
-               i = (int)ipc.ip_addr;
-               p = (int *)&((physadr)&u)->r[i>>1];
-               if (p >= (int *)&u.u_fps && p < (int *)&u.u_fps.u_fpregs[6])
-                       goto ok;
-               for (i=0; i<8; i++)
-                       if (p == &u.u_ar0[regloc[i]])
-                               goto ok;
-               if (p == &u.u_ar0[RPS]) {
-                       ipc.ip_data |= 0170000; /* assure user space */
-                       ipc.ip_data &= ~0340;   /* priority 0 */
-                       goto ok;
-               }
-               goto error;
-
-       ok:
-               *p = ipc.ip_data;
-               break;
-
-       /* set signal and continue */
-       /*  one version causes a trace-trap */
-       case 9:
-               u.u_ar0[RPS] |= TBIT;
-       case 7:
-               if ((int)ipc.ip_addr != 1)
-                       u.u_ar0[PC] = (int)ipc.ip_addr;
-               u.u_procp->p_sig = 0;
-               if (ipc.ip_data)
-                       psignal(u.u_procp, ipc.ip_data);
-               return(1);
-
-       /* force exit */
-       case 8:
-               exit(fsig(u.u_procp));
-
-       default:
-       error:
-               ipc.ip_req = -1;
-       }
-       return(0);
-}
diff --git a/usr/sys/sys/slp.c b/usr/sys/sys/slp.c
deleted file mode 100644 (file)
index 77d9f8f..0000000
+++ /dev/null
@@ -1,575 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/proc.h"
-#include "../h/text.h"
-#include "../h/map.h"
-#include "../h/file.h"
-#include "../h/inode.h"
-#include "../h/buf.h"
-
-#define SQSIZE 0100    /* Must be power of 2 */
-#define HASH(x)        (( (int) x >> 5) & (SQSIZE-1))
-struct proc *slpque[SQSIZE];
-
-/*
- * Give up the processor till a wakeup occurs
- * on chan, at which time the process
- * enters the scheduling queue at priority pri.
- * The most important effect of pri is that when
- * pri<=PZERO a signal cannot disturb the sleep;
- * if pri>PZERO signals will be processed.
- * Callers of this routine must be prepared for
- * premature return, and check that the reason for
- * sleeping has gone away.
- */
-sleep(chan, pri)
-caddr_t chan;
-{
-       register struct proc *rp;
-       register s, h;
-
-       rp = u.u_procp;
-       s = spl6();
-       if (chan==0)
-               panic("zero wchan");
-       rp->p_stat = SSLEEP;
-       rp->p_wchan = chan;
-       if (chan==0)
-               panic("Sleeping on wchan 0");
-       rp->p_pri = pri;
-       h = HASH(chan);
-       rp->p_link = slpque[h];
-       slpque[h] = rp;
-       if(pri > PZERO) {
-               if(issig()) {
-                       rp->p_wchan = 0;
-                       rp->p_stat = SRUN;
-                       slpque[h] = rp->p_link;
-                       spl0();
-                       goto psig;
-               }
-               spl0();
-               if(runin != 0) {
-                       runin = 0;
-                       wakeup((caddr_t)&runin);
-               }
-               swtch();
-               if(issig())
-                       goto psig;
-       } else {
-               spl0();
-               swtch();
-       }
-       splx(s);
-       return;
-
-       /*
-        * If priority was low (>PZERO) and
-        * there has been a signal,
-        * execute non-local goto to
-        * the qsav location.
-        * (see trap1/trap.c)
-        */
-psig:
-       resume(u.u_procp->p_addr, u.u_qsav);
-}
-
-/*
- * Wake up all processes sleeping on chan.
- */
-wakeup(chan)
-register caddr_t chan;
-{
-       register struct proc *p, *q;
-       register i;
-       int s;
-
-       s = spl6();
-       i = HASH(chan);
-       p = slpque[i];
-       q = NULL;
-       while(p != NULL) {
-               if(p->p_wchan==chan && p->p_stat!=SZOMB) {
-                       struct proc *sp;
-
-                       if (q == NULL)
-                               sp = slpque[i] = p->p_link;
-                       else
-                               sp = q->p_link = p->p_link;
-                       p->p_wchan = 0;
-                       setrun(p);
-                       p = sp;
-                       continue;
-               }
-               q = p;
-               p = p->p_link;
-       }
-       splx(s);
-}
-
-/*
- * when you are sure that it
- * is impossible to get the
- * 'proc on q' diagnostic, the
- * diagnostic loop can be removed.
- */
-setrq(p)
-struct proc *p;
-{
-       register struct proc *q;
-       register s;
-
-       s = spl6();
-       for(q=runq; q!=NULL; q=q->p_link)
-               if(q == p) {
-                       printf("proc on q\n");
-                       goto out;
-               }
-       p->p_link = runq;
-       runq = p;
-out:
-       splx(s);
-}
-
-/*
- * Set the process running;
- * arrange for it to be swapped in if necessary.
- */
-setrun(p)
-register struct proc *p;
-{
-       register caddr_t w;
-
-       if (p->p_stat==0 || p->p_stat==SZOMB)
-               panic("Running a dead proc");
-       /*
-        * The assignment to w is necessary because of
-        * race conditions. (Interrupt between test and use)
-        */
-       if (w = p->p_wchan) {
-               wakeup(w);
-               return;
-       }
-       p->p_stat = SRUN;
-       setrq(p);
-       if(p->p_pri < curpri)
-               runrun++;
-       if(runout != 0 && (p->p_flag&SLOAD) == 0) {
-               runout = 0;
-               wakeup((caddr_t)&runout);
-       }
-}
-
-/*
- * Set user priority.
- * The rescheduling flag (runrun)
- * is set if the priority is better
- * than the currently running process.
- */
-setpri(pp)
-register struct proc *pp;
-{
-       register p;
-
-       p = (pp->p_cpu & 0377)/16;
-       p += PUSER + pp->p_nice - NZERO;
-       if(p > 127)
-               p = 127;
-       if(p < curpri)
-               runrun++;
-       pp->p_pri = p;
-       return(p);
-}
-
-/*
- * The main loop of the scheduling (swapping)
- * process.
- * The basic idea is:
- *  see if anyone wants to be swapped in;
- *  swap out processes until there is room;
- *  swap him in;
- *  repeat.
- * The runout flag is set whenever someone is swapped out.
- * Sched sleeps on it awaiting work.
- *
- * Sched sleeps on runin whenever it cannot find enough
- * core (by swapping out or otherwise) to fit the
- * selected swapped process.  It is awakened when the
- * core situation changes and in any case once per second.
- */
-sched()
-{
-       register struct proc *rp, *p;
-       register outage, inage;
-       int maxsize;
-
-       /*
-        * find user to swap in;
-        * of users ready, select one out longest
-        */
-
-loop:
-       spl6();
-       outage = -20000;
-       for (rp = &proc[0]; rp < &proc[NPROC]; rp++)
-       if (rp->p_stat==SRUN && (rp->p_flag&SLOAD)==0 &&
-           rp->p_time - (rp->p_nice-NZERO)*8 > outage) {
-               p = rp;
-               outage = rp->p_time - (rp->p_nice-NZERO)*8;
-       }
-       /*
-        * If there is no one there, wait.
-        */
-       if (outage == -20000) {
-               runout++;
-               sleep((caddr_t)&runout, PSWP);
-               goto loop;
-       }
-       spl0();
-
-       /*
-        * See if there is core for that process;
-        * if so, swap it in.
-        */
-
-       if (swapin(p))
-               goto loop;
-
-       /*
-        * none found.
-        * look around for core.
-        * Select the largest of those sleeping
-        * at bad priority; if none, select the oldest.
-        */
-
-       spl6();
-       p = NULL;
-       maxsize = -1;
-       inage = -1;
-       for (rp = &proc[0]; rp < &proc[NPROC]; rp++) {
-               if (rp->p_stat==SZOMB
-                || (rp->p_flag&(SSYS|SLOCK|SULOCK|SLOAD))!=SLOAD)
-                       continue;
-               if (rp->p_textp && rp->p_textp->x_flag&XLOCK)
-                       continue;
-               if (rp->p_stat==SSLEEP&&rp->p_pri>=PZERO || rp->p_stat==SSTOP) {
-                       if (maxsize < rp->p_size) {
-                               p = rp;
-                               maxsize = rp->p_size;
-                       }
-               } else if (maxsize<0 && (rp->p_stat==SRUN||rp->p_stat==SSLEEP)) {
-                       if (rp->p_time+rp->p_nice-NZERO > inage) {
-                               p = rp;
-                               inage = rp->p_time+rp->p_nice-NZERO;
-                       }
-               }
-       }
-       spl0();
-       /*
-        * Swap found user out if sleeping at bad pri,
-        * or if he has spent at least 2 seconds in core and
-        * the swapped-out process has spent at least 3 seconds out.
-        * Otherwise wait a bit and try again.
-        */
-       if (maxsize>=0 || (outage>=3 && inage>=2)) {
-               p->p_flag &= ~SLOAD;
-               xswap(p, 1, 0);
-               goto loop;
-       }
-       spl6();
-       runin++;
-       sleep((caddr_t)&runin, PSWP);
-       goto loop;
-}
-
-/*
- * Swap a process in.
- * Allocate data and possible text separately.
- * It would be better to do largest first.
- */
-swapin(p)
-register struct proc *p;
-{
-       register struct text *xp;
-       register int a;
-       int x;
-
-       if ((a = malloc(coremap, p->p_size)) == NULL)
-               return(0);
-       if (xp = p->p_textp) {
-               xlock(xp);
-               if (xp->x_ccount==0) {
-                       if ((x = malloc(coremap, xp->x_size)) == NULL) {
-                               xunlock(xp);
-                               mfree(coremap, p->p_size, a);
-                               return(0);
-                       }
-                       xp->x_caddr = x;
-                       if ((xp->x_flag&XLOAD)==0)
-                               swap(xp->x_daddr,x,xp->x_size,B_READ);
-               }
-               xp->x_ccount++;
-               xunlock(xp);
-       }
-       swap(p->p_addr, a, p->p_size, B_READ);
-       mfree(swapmap, ctod(p->p_size), p->p_addr);
-       p->p_addr = a;
-       p->p_flag |= SLOAD;
-       p->p_time = 0;
-       return(1);
-}
-
-/*
- * put the current process on
- * the Q of running processes and
- * call the scheduler.
- */
-qswtch()
-{
-
-       setrq(u.u_procp);
-       swtch();
-}
-
-/*
- * This routine is called to reschedule the CPU.
- * if the calling process is not in RUN state,
- * arrangements for it to restart must have
- * been made elsewhere, usually by calling via sleep.
- * There is a race here. A process may become
- * ready after it has been examined.
- * In this case, idle() will be called and
- * will return in at most 1HZ time.
- * i.e. its not worth putting an spl() in.
- */
-swtch()
-{
-       register n;
-       register struct proc *p, *q, *pp, *pq;
-
-       /*
-        * If not the idle process, resume the idle process.
-        */
-       if (u.u_procp != &proc[0]) {
-               if (save(u.u_rsav)) {
-                       sureg();
-                       return;
-               }
-               if (u.u_fpsaved==0) {
-                       savfp(&u.u_fps);
-                       u.u_fpsaved = 1;
-               }
-               resume(proc[0].p_addr, u.u_qsav);
-       }
-       /*
-        * The first save returns nonzero when proc 0 is resumed
-        * by another process (above); then the second is not done
-        * and the process-search loop is entered.
-        *
-        * The first save returns 0 when swtch is called in proc 0
-        * from sched().  The second save returns 0 immediately, so
-        * in this case too the process-search loop is entered.
-        * Thus when proc 0 is awakened by being made runnable, it will
-        * find itself and resume itself at rsav, and return to sched().
-        */
-       if (save(u.u_qsav)==0 && save(u.u_rsav))
-               return;
-loop:
-       spl6();
-       runrun = 0;
-       pp = NULL;
-       q = NULL;
-       n = 128;
-       /*
-        * Search for highest-priority runnable process
-        */
-       for(p=runq; p!=NULL; p=p->p_link) {
-               if((p->p_stat==SRUN) && (p->p_flag&SLOAD)) {
-                       if(p->p_pri < n) {
-                               pp = p;
-                               pq = q;
-                               n = p->p_pri;
-                       }
-               }
-               q = p;
-       }
-       /*
-        * If no process is runnable, idle.
-        */
-       p = pp;
-       if(p == NULL) {
-               idle();
-               goto loop;
-       }
-       q = pq;
-       if(q == NULL)
-               runq = p->p_link;
-       else
-               q->p_link = p->p_link;
-       curpri = n;
-       spl0();
-       /*
-        * The rsav (ssav) contents are interpreted in the new address space
-        */
-       n = p->p_flag&SSWAP;
-       p->p_flag &= ~SSWAP;
-       resume(p->p_addr, n? u.u_ssav: u.u_rsav);
-}
-
-/*
- * Create a new process-- the internal version of
- * sys fork.
- * It returns 1 in the new process, 0 in the old.
- */
-newproc()
-{
-       int a1, a2;
-       struct proc *p, *up;
-       register struct proc *rpp, *rip;
-       register n;
-
-       p = NULL;
-       /*
-        * First, just locate a slot for a process
-        * and copy the useful info from this process into it.
-        * The panic "cannot happen" because fork has already
-        * checked for the existence of a slot.
-        */
-retry:
-       mpid++;
-       if(mpid >= 30000) {
-               mpid = 0;
-               goto retry;
-       }
-       for(rpp = &proc[0]; rpp < &proc[NPROC]; rpp++) {
-               if(rpp->p_stat == NULL && p==NULL)
-                       p = rpp;
-               if (rpp->p_pid==mpid || rpp->p_pgrp==mpid)
-                       goto retry;
-       }
-       if ((rpp = p)==NULL)
-               panic("no procs");
-
-       /*
-        * make proc entry for new proc
-        */
-
-       rip = u.u_procp;
-       up = rip;
-       rpp->p_stat = SRUN;
-       rpp->p_clktim = 0;
-       rpp->p_flag = SLOAD;
-       rpp->p_uid = rip->p_uid;
-       rpp->p_pgrp = rip->p_pgrp;
-       rpp->p_nice = rip->p_nice;
-       rpp->p_textp = rip->p_textp;
-       rpp->p_pid = mpid;
-       rpp->p_ppid = rip->p_pid;
-       rpp->p_time = 0;
-       rpp->p_cpu = 0;
-
-       /*
-        * make duplicate entries
-        * where needed
-        */
-
-       for(n=0; n<NOFILE; n++)
-               if(u.u_ofile[n] != NULL)
-                       u.u_ofile[n]->f_count++;
-       if(up->p_textp != NULL) {
-               up->p_textp->x_count++;
-               up->p_textp->x_ccount++;
-       }
-       u.u_cdir->i_count++;
-       if (u.u_rdir)
-               u.u_rdir->i_count++;
-       /*
-        * Partially simulate the environment
-        * of the new process so that when it is actually
-        * created (by copying) it will look right.
-        */
-       rpp = p;
-       u.u_procp = rpp;
-       rip = up;
-       n = rip->p_size;
-       a1 = rip->p_addr;
-       rpp->p_size = n;
-       /*
-        * When the resume is executed for the new process,
-        * here's where it will resume.
-        */
-       if (save(u.u_ssav)) {
-               sureg();
-               return(1);
-       }
-       a2 = malloc(coremap, n);
-       /*
-        * If there is not enough core for the
-        * new process, swap out the current process to generate the
-        * copy.
-        */
-       if(a2 == NULL) {
-               rip->p_stat = SIDL;
-               rpp->p_addr = a1;
-               xswap(rpp, 0, 0);
-               rip->p_stat = SRUN;
-       } else {
-               /*
-                * There is core, so just copy.
-                */
-               rpp->p_addr = a2;
-               while(n--)
-                       copyseg(a1++, a2++);
-       }
-       u.u_procp = rip;
-       setrq(rpp);
-       rpp->p_flag |= SSWAP;
-       return(0);
-}
-
-/*
- * Change the size of the data+stack regions of the process.
- * If the size is shrinking, it's easy-- just release the extra core.
- * If it's growing, and there is core, just allocate it
- * and copy the image, taking care to reset registers to account
- * for the fact that the system's stack has moved.
- * If there is no core, arrange for the process to be swapped
- * out after adjusting the size requirement-- when it comes
- * in, enough core will be allocated.
- *
- * After the expansion, the caller will take care of copying
- * the user's stack towards or away from the data area.
- */
-expand(newsize)
-{
-       register i, n;
-       register struct proc *p;
-       register a1, a2;
-
-       p = u.u_procp;
-       n = p->p_size;
-       p->p_size = newsize;
-       a1 = p->p_addr;
-       if(n >= newsize) {
-               mfree(coremap, n-newsize, a1+newsize);
-               return;
-       }
-       if (save(u.u_ssav)) {
-               sureg();
-               return;
-       }
-       a2 = malloc(coremap, newsize);
-       if(a2 == NULL) {
-               xswap(p, 1, n);
-               p->p_flag |= SSWAP;
-               qswtch();
-               /* no return */
-       }
-       p->p_addr = a2;
-       for(i=0; i<n; i++)
-               copyseg(a1+i, a2+i);
-       mfree(coremap, n, a1);
-       resume(a2, u.u_ssav);
-}
diff --git a/usr/sys/sys/subr.c b/usr/sys/sys/subr.c
deleted file mode 100644 (file)
index 5c10b4a..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/conf.h"
-#include "../h/inode.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/buf.h"
-
-/*
- * Bmap defines the structure of file system storage
- * by returning the physical block number on a device given the
- * inode and the logical block number in a file.
- * When convenient, it also leaves the physical
- * block number of the next block of the file in rablock
- * for use in read-ahead.
- */
-daddr_t
-bmap(ip, bn, rwflg)
-register struct inode *ip;
-daddr_t bn;
-{
-       register i;
-       struct buf *bp, *nbp;
-       int j, sh;
-       daddr_t nb, *bap;
-       dev_t dev;
-
-       if(bn < 0) {
-               u.u_error = EFBIG;
-               return((daddr_t)0);
-       }
-       dev = ip->i_dev;
-       rablock = 0;
-
-       /*
-        * blocks 0..NADDR-4 are direct blocks
-        */
-       if(bn < NADDR-3) {
-               i = bn;
-               nb = ip->i_un.i_addr[i];
-               if(nb == 0) {
-                       if(rwflg==B_READ || (bp = alloc(dev))==NULL)
-                               return((daddr_t)-1);
-                       nb = bp->b_blkno;
-                       bdwrite(bp);
-                       ip->i_un.i_addr[i] = nb;
-                       ip->i_flag |= IUPD|ICHG;
-               }
-               if(i < NADDR-4)
-                       rablock = ip->i_un.i_addr[i+1];
-               return(nb);
-       }
-
-       /*
-        * addresses NADDR-3, NADDR-2, and NADDR-1
-        * have single, double, triple indirect blocks.
-        * the first step is to determine
-        * how many levels of indirection.
-        */
-       sh = 0;
-       nb = 1;
-       bn -= NADDR-3;
-       for(j=3; j>0; j--) {
-               sh += NSHIFT;
-               nb <<= NSHIFT;
-               if(bn < nb)
-                       break;
-               bn -= nb;
-       }
-       if(j == 0) {
-               u.u_error = EFBIG;
-               return((daddr_t)0);
-       }
-
-       /*
-        * fetch the address from the inode
-        */
-       nb = ip->i_un.i_addr[NADDR-j];
-       if(nb == 0) {
-               if(rwflg==B_READ || (bp = alloc(dev))==NULL)
-                       return((daddr_t)-1);
-               nb = bp->b_blkno;
-               bdwrite(bp);
-               ip->i_un.i_addr[NADDR-j] = nb;
-               ip->i_flag |= IUPD|ICHG;
-       }
-
-       /*
-        * fetch through the indirect blocks
-        */
-       for(; j<=3; j++) {
-               bp = bread(dev, nb);
-               if(bp->b_flags & B_ERROR) {
-                       brelse(bp);
-                       return((daddr_t)0);
-               }
-               bap = bp->b_un.b_daddr;
-               sh -= NSHIFT;
-               i = (bn>>sh) & NMASK;
-               nb = bap[i];
-               if(nb == 0) {
-                       if(rwflg==B_READ || (nbp = alloc(dev))==NULL) {
-                               brelse(bp);
-                               return((daddr_t)-1);
-                       }
-                       nb = nbp->b_blkno;
-                       bdwrite(nbp);
-                       bap[i] = nb;
-                       bdwrite(bp);
-               } else
-                       brelse(bp);
-       }
-
-       /*
-        * calculate read-ahead.
-        */
-       if(i < NINDIR-1)
-               rablock = bap[i+1];
-       return(nb);
-}
-
-/*
- * Pass back  c  to the user at his location u_base;
- * update u_base, u_count, and u_offset.  Return -1
- * on the last character of the user's read.
- * u_base is in the user address space unless u_segflg is set.
- */
-passc(c)
-register c;
-{
-       register id;
-
-       if((id = u.u_segflg) == 1)
-               *u.u_base = c;
-       else
-               if(id?suibyte(u.u_base, c):subyte(u.u_base, c) < 0) {
-                       u.u_error = EFAULT;
-                       return(-1);
-               }
-       u.u_count--;
-       u.u_offset++;
-       u.u_base++;
-       return(u.u_count == 0? -1: 0);
-}
-
-/*
- * Pick up and return the next character from the user's
- * write call at location u_base;
- * update u_base, u_count, and u_offset.  Return -1
- * when u_count is exhausted.  u_base is in the user's
- * address space unless u_segflg is set.
- */
-cpass()
-{
-       register c, id;
-
-       if(u.u_count == 0)
-               return(-1);
-       if((id = u.u_segflg) == 1)
-               c = *u.u_base;
-       else
-               if((c = id==0?fubyte(u.u_base):fuibyte(u.u_base)) < 0) {
-                       u.u_error = EFAULT;
-                       return(-1);
-               }
-       u.u_count--;
-       u.u_offset++;
-       u.u_base++;
-       return(c&0377);
-}
-
-/*
- * Routine which sets a user error; placed in
- * illegal entries in the bdevsw and cdevsw tables.
- */
-nodev()
-{
-
-       u.u_error = ENODEV;
-}
-
-/*
- * Null routine; placed in insignificant entries
- * in the bdevsw and cdevsw tables.
- */
-nulldev()
-{
-}
-
-/*
- * copy count bytes from from to to.
- */
-bcopy(from, to, count)
-caddr_t from, to;
-register count;
-{
-       register char *f, *t;
-
-       f = from;
-       t = to;
-       do
-               *t++ = *f++;
-       while(--count);
-}
diff --git a/usr/sys/sys/sys1.c b/usr/sys/sys/sys1.c
deleted file mode 100644 (file)
index 1172f3d..0000000
+++ /dev/null
@@ -1,523 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/map.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/proc.h"
-#include "../h/buf.h"
-#include "../h/reg.h"
-#include "../h/inode.h"
-#include "../h/seg.h"
-#include "../h/acct.h"
-
-/*
- * exec system call, with and without environments.
- */
-struct execa {
-       char    *fname;
-       char    **argp;
-       char    **envp;
-};
-
-exec()
-{
-       ((struct execa *)u.u_ap)->envp = NULL;
-       exece();
-}
-
-exece()
-{
-       register nc;
-       register char *cp;
-       register struct buf *bp;
-       register struct execa *uap;
-       int na, ne, bno, ucp, ap, c;
-       struct inode *ip;
-
-       if ((ip = namei(uchar, 0)) == NULL)
-               return;
-       bno = 0;
-       bp = 0;
-       if(access(ip, IEXEC))
-               goto bad;
-       if((ip->i_mode & IFMT) != IFREG ||
-          (ip->i_mode & (IEXEC|(IEXEC>>3)|(IEXEC>>6))) == 0) {
-               u.u_error = EACCES;
-               goto bad;
-       }
-       /*
-        * Collect arguments on "file" in swap space.
-        */
-       na = 0;
-       ne = 0;
-       nc = 0;
-       uap = (struct execa *)u.u_ap;
-       if ((bno = malloc(swapmap,(NCARGS+BSIZE-1)/BSIZE)) == 0)
-               panic("Out of swap");
-       if (uap->argp) for (;;) {
-               ap = NULL;
-               if (uap->argp) {
-                       ap = fuword((caddr_t)uap->argp);
-                       uap->argp++;
-               }
-               if (ap==NULL && uap->envp) {
-                       uap->argp = NULL;
-                       if ((ap = fuword((caddr_t)uap->envp)) == NULL)
-                               break;
-                       uap->envp++;
-                       ne++;
-               }
-               if (ap==NULL)
-                       break;
-               na++;
-               if(ap == -1)
-                       u.u_error = EFAULT;
-               do {
-                       if (nc >= NCARGS-1)
-                               u.u_error = E2BIG;
-                       if ((c = fubyte((caddr_t)ap++)) < 0)
-                               u.u_error = EFAULT;
-                       if (u.u_error)
-                               goto bad;
-                       if ((nc&BMASK) == 0) {
-                               if (bp)
-                                       bawrite(bp);
-                               bp = getblk(swapdev, swplo+bno+(nc>>BSHIFT));
-                               cp = bp->b_un.b_addr;
-                       }
-                       nc++;
-                       *cp++ = c;
-               } while (c>0);
-       }
-       if (bp)
-               bawrite(bp);
-       bp = 0;
-       nc = (nc + NBPW-1) & ~(NBPW-1);
-       if (getxfile(ip, nc) || u.u_error)
-               goto bad;
-
-       /*
-        * copy back arglist
-        */
-
-       ucp = -nc - NBPW;
-       ap = ucp - na*NBPW - 3*NBPW;
-       u.u_ar0[R6] = ap;
-       suword((caddr_t)ap, na-ne);
-       nc = 0;
-       for (;;) {
-               ap += NBPW;
-               if (na==ne) {
-                       suword((caddr_t)ap, 0);
-                       ap += NBPW;
-               }
-               if (--na < 0)
-                       break;
-               suword((caddr_t)ap, ucp);
-               do {
-                       if ((nc&BMASK) == 0) {
-                               if (bp)
-                                       brelse(bp);
-                               bp = bread(swapdev, swplo+bno+(nc>>BSHIFT));
-                               cp = bp->b_un.b_addr;
-                       }
-                       subyte((caddr_t)ucp++, (c = *cp++));
-                       nc++;
-               } while(c&0377);
-       }
-       suword((caddr_t)ap, 0);
-       suword((caddr_t)ucp, 0);
-       setregs();
-bad:
-       if (bp)
-               brelse(bp);
-       if(bno)
-               mfree(swapmap, (NCARGS+BSIZE-1)/BSIZE, bno);
-       iput(ip);
-}
-
-/*
- * Read in and set up memory for executed file.
- * Zero return is normal;
- * non-zero means only the text is being replaced
- */
-getxfile(ip, nargc)
-register struct inode *ip;
-{
-       register unsigned ds;
-       register sep;
-       register unsigned ts, ss;
-       register i, overlay;
-       long lsize;
-
-       /*
-        * read in first few bytes
-        * of file for segment
-        * sizes:
-        * ux_mag = 407/410/411/405
-        *  407 is plain executable
-        *  410 is RO text
-        *  411 is separated ID
-        *  405 is overlaid text
-        */
-
-       u.u_base = (caddr_t)&u.u_exdata;
-       u.u_count = sizeof(u.u_exdata);
-       u.u_offset = 0;
-       u.u_segflg = 1;
-       readi(ip);
-       u.u_segflg = 0;
-       if(u.u_error)
-               goto bad;
-       if (u.u_count!=0) {
-               u.u_error = ENOEXEC;
-               goto bad;
-       }
-       sep = 0;
-       overlay = 0;
-       if(u.u_exdata.ux_mag == 0407) {
-               lsize = (long)u.u_exdata.ux_dsize + u.u_exdata.ux_tsize;
-               u.u_exdata.ux_dsize = lsize;
-               if (lsize != u.u_exdata.ux_dsize) {     /* check overflow */
-                       u.u_error = ENOMEM;
-                       goto bad;
-               }
-               u.u_exdata.ux_tsize = 0;
-       } else if (u.u_exdata.ux_mag == 0411)
-               sep++;
-       else if (u.u_exdata.ux_mag == 0405)
-               overlay++;
-       else if (u.u_exdata.ux_mag != 0410) {
-               u.u_error = ENOEXEC;
-               goto bad;
-       }
-       if(u.u_exdata.ux_tsize!=0 && (ip->i_flag&ITEXT)==0 && ip->i_count!=1) {
-               u.u_error = ETXTBSY;
-               goto bad;
-       }
-
-       /*
-        * find text and data sizes
-        * try them out for possible
-        * overflow of max sizes
-        */
-       ts = btoc(u.u_exdata.ux_tsize);
-       lsize = (long)u.u_exdata.ux_dsize + u.u_exdata.ux_bsize;
-       if (lsize != (unsigned)lsize) {
-               u.u_error = ENOMEM;
-               goto bad;
-       }
-       ds = btoc(lsize);
-       ss = SSIZE + btoc(nargc);
-       if (overlay) {
-               if (u.u_sep==0 && ctos(ts) != ctos(u.u_tsize) || nargc) {
-                       u.u_error = ENOMEM;
-                       goto bad;
-               }
-               ds = u.u_dsize;
-               ss = u.u_ssize;
-               sep = u.u_sep;
-               xfree();
-               xalloc(ip);
-               u.u_ar0[PC] = u.u_exdata.ux_entloc & ~01;
-       } else {
-               if(estabur(ts, ds, ss, sep, RO))
-                       goto bad;
-       
-               /*
-                * allocate and clear core
-                * at this point, committed
-                * to the new image
-                */
-       
-               u.u_prof.pr_scale = 0;
-               xfree();
-               i = USIZE+ds+ss;
-               expand(i);
-               while(--i >= USIZE)
-                       clearseg(u.u_procp->p_addr+i);
-               xalloc(ip);
-       
-               /*
-                * read in data segment
-                */
-       
-               estabur((unsigned)0, ds, (unsigned)0, 0, RO);
-               u.u_base = 0;
-               u.u_offset = sizeof(u.u_exdata)+u.u_exdata.ux_tsize;
-               u.u_count = u.u_exdata.ux_dsize;
-               readi(ip);
-               /*
-                * set SUID/SGID protections, if no tracing
-                */
-               if ((u.u_procp->p_flag&STRC)==0) {
-                       if(ip->i_mode&ISUID)
-                               if(u.u_uid != 0) {
-                                       u.u_uid = ip->i_uid;
-                                       u.u_procp->p_uid = ip->i_uid;
-                               }
-                       if(ip->i_mode&ISGID)
-                               u.u_gid = ip->i_gid;
-               } else
-                       psignal(u.u_procp, SIGTRC);
-       }
-       u.u_tsize = ts;
-       u.u_dsize = ds;
-       u.u_ssize = ss;
-       u.u_sep = sep;
-       estabur(ts, ds, ss, sep, RO);
-bad:
-       return(overlay);
-}
-
-/*
- * Clear registers on exec
- */
-setregs()
-{
-       register int *rp;
-       register char *cp;
-       register i;
-
-       for(rp = &u.u_signal[0]; rp < &u.u_signal[NSIG]; rp++)
-               if((*rp & 1) == 0)
-                       *rp = 0;
-       for(cp = &regloc[0]; cp < &regloc[6];)
-               u.u_ar0[*cp++] = 0;
-       u.u_ar0[PC] = u.u_exdata.ux_entloc & ~01;
-       for(rp = (int *)&u.u_fps; rp < (int *)&u.u_fps.u_fpregs[6];)
-               *rp++ = 0;
-       for(i=0; i<NOFILE; i++) {
-               if (u.u_pofile[i]&EXCLOSE) {
-                       closef(u.u_ofile[i]);
-                       u.u_ofile[i] = NULL;
-                       u.u_pofile[i] &= ~EXCLOSE;
-               }
-       }
-       /*
-        * Remember file name for accounting.
-        */
-       u.u_acflag &= ~AFORK;
-       bcopy((caddr_t)u.u_dbuf, (caddr_t)u.u_comm, DIRSIZ);
-}
-
-/*
- * exit system call:
- * pass back caller's arg
- */
-rexit()
-{
-       register struct a {
-               int     rval;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       exit((uap->rval & 0377) << 8);
-}
-
-/*
- * Release resources.
- * Save u. area for parent to look at.
- * Enter zombie state.
- * Wake up parent and init processes,
- * and dispose of children.
- */
-exit(rv)
-{
-       register int i;
-       register struct proc *p, *q;
-       register struct file *f;
-
-       p = u.u_procp;
-       p->p_flag &= ~(STRC|SULOCK);
-       p->p_clktim = 0;
-       for(i=0; i<NSIG; i++)
-               u.u_signal[i] = 1;
-       for(i=0; i<NOFILE; i++) {
-               f = u.u_ofile[i];
-               u.u_ofile[i] = NULL;
-               closef(f);
-       }
-       plock(u.u_cdir);
-       iput(u.u_cdir);
-       if (u.u_rdir) {
-               plock(u.u_rdir);
-               iput(u.u_rdir);
-       }
-       xfree();
-       acct();
-       mfree(coremap, p->p_size, p->p_addr);
-       p->p_stat = SZOMB;
-       ((struct xproc *)p)->xp_xstat = rv;
-       ((struct xproc *)p)->xp_utime = u.u_cutime + u.u_utime;
-       ((struct xproc *)p)->xp_stime = u.u_cstime + u.u_stime;
-       for(q = &proc[0]; q < &proc[NPROC]; q++)
-               if(q->p_ppid == p->p_pid) {
-                       wakeup((caddr_t)&proc[1]);
-                       q->p_ppid = 1;
-                       if (q->p_stat==SSTOP)
-                               setrun(q);
-               }
-       for(q = &proc[0]; q < &proc[NPROC]; q++)
-               if(p->p_ppid == q->p_pid) {
-                       wakeup((caddr_t)q);
-                       swtch();
-                       /* no return */
-               }
-       swtch();
-}
-
-/*
- * Wait system call.
- * Search for a terminated (zombie) child,
- * finally lay it to rest, and collect its status.
- * Look also for stopped (traced) children,
- * and pass back status from them.
- */
-wait()
-{
-       register f;
-       register struct proc *p;
-
-       f = 0;
-
-loop:
-       for(p = &proc[0]; p < &proc[NPROC]; p++)
-       if(p->p_ppid == u.u_procp->p_pid) {
-               f++;
-               if(p->p_stat == SZOMB) {
-                       u.u_r.r_val1 = p->p_pid;
-                       u.u_r.r_val2 = ((struct xproc *)p)->xp_xstat;
-                       u.u_cutime += ((struct xproc *)p)->xp_utime;
-                       u.u_cstime += ((struct xproc *)p)->xp_stime;
-                       p->p_pid = 0;
-                       p->p_ppid = 0;
-                       p->p_pgrp = 0;
-                       p->p_sig = 0;
-                       p->p_flag = 0;
-                       p->p_wchan = 0;
-                       p->p_stat = NULL;
-                       return;
-               }
-               if(p->p_stat == SSTOP) {
-                       if((p->p_flag&SWTED) == 0) {
-                               p->p_flag |= SWTED;
-                               u.u_r.r_val1 = p->p_pid;
-                               u.u_r.r_val2 = (fsig(p)<<8) | 0177;
-                               return;
-                       }
-                       continue;
-               }
-       }
-       if(f) {
-               sleep((caddr_t)u.u_procp, PWAIT);
-               goto loop;
-       }
-       u.u_error = ECHILD;
-}
-
-/*
- * fork system call.
- */
-fork()
-{
-       register struct proc *p1, *p2;
-       register a;
-
-       /*
-        * Make sure there's enough swap space for max
-        * core image, thus reducing chances of running out
-        */
-       if ((a = malloc(swapmap, ctod(MAXMEM))) == 0) {
-               u.u_error = ENOMEM;
-               goto out;
-       }
-       mfree(swapmap, ctod(MAXMEM), a);
-       a = 0;
-       p2 = NULL;
-       for(p1 = &proc[0]; p1 < &proc[NPROC]; p1++) {
-               if (p1->p_stat==NULL && p2==NULL)
-                       p2 = p1;
-               else {
-                       if (p1->p_uid==u.u_uid && p1->p_stat!=NULL)
-                               a++;
-               }
-       }
-       /*
-        * Disallow if
-        *  No processes at all;
-        *  not su and too many procs owned; or
-        *  not su and would take last slot.
-        */
-       if (p2==NULL || (u.u_uid!=0 && (p2==&proc[NPROC-1] || a>MAXUPRC))) {
-               u.u_error = EAGAIN;
-               goto out;
-       }
-       p1 = u.u_procp;
-       if(newproc()) {
-               u.u_r.r_val1 = p1->p_pid;
-               u.u_start = time;
-               u.u_cstime = 0;
-               u.u_stime = 0;
-               u.u_cutime = 0;
-               u.u_utime = 0;
-               u.u_acflag = AFORK;
-               return;
-       }
-       u.u_r.r_val1 = p2->p_pid;
-
-out:
-       u.u_ar0[R7] += NBPW;
-}
-
-/*
- * break system call.
- *  -- bad planning: "break" is a dirty word in C.
- */
-sbreak()
-{
-       struct a {
-               char    *nsiz;
-       };
-       register a, n, d;
-       int i;
-
-       /*
-        * set n to new data size
-        * set d to new-old
-        * set n to new total size
-        */
-
-       n = btoc((int)((struct a *)u.u_ap)->nsiz);
-       if(!u.u_sep)
-               n -= ctos(u.u_tsize) * stoc(1);
-       if(n < 0)
-               n = 0;
-       d = n - u.u_dsize;
-       n += USIZE+u.u_ssize;
-       if(estabur(u.u_tsize, u.u_dsize+d, u.u_ssize, u.u_sep, RO))
-               return;
-       u.u_dsize += d;
-       if(d > 0)
-               goto bigger;
-       a = u.u_procp->p_addr + n - u.u_ssize;
-       i = n;
-       n = u.u_ssize;
-       while(n--) {
-               copyseg(a-d, a);
-               a++;
-       }
-       expand(i);
-       return;
-
-bigger:
-       expand(n);
-       a = u.u_procp->p_addr + n;
-       n = u.u_ssize;
-       while(n--) {
-               a--;
-               copyseg(a-d, a);
-       }
-       while(d--)
-               clearseg(--a);
-}
diff --git a/usr/sys/sys/sys2.c b/usr/sys/sys/sys2.c
deleted file mode 100644 (file)
index 79d1de7..0000000
+++ /dev/null
@@ -1,316 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/reg.h"
-#include "../h/file.h"
-#include "../h/inode.h"
-
-/*
- * read system call
- */
-read()
-{
-       rdwr(FREAD);
-}
-
-/*
- * write system call
- */
-write()
-{
-       rdwr(FWRITE);
-}
-
-/*
- * common code for read and write calls:
- * check permissions, set base, count, and offset,
- * and switch out to readi, writei, or pipe code.
- */
-rdwr(mode)
-register mode;
-{
-       register struct file *fp;
-       register struct inode *ip;
-       register struct a {
-               int     fdes;
-               char    *cbuf;
-               unsigned count;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       fp = getf(uap->fdes);
-       if(fp == NULL)
-               return;
-       if((fp->f_flag&mode) == 0) {
-               u.u_error = EBADF;
-               return;
-       }
-       u.u_base = (caddr_t)uap->cbuf;
-       u.u_count = uap->count;
-       u.u_segflg = 0;
-       if((fp->f_flag&FPIPE) != 0) {
-               if(mode == FREAD)
-                       readp(fp);
-               else
-                       writep(fp);
-       } else {
-               ip = fp->f_inode;
-               if (fp->f_flag&FMP)
-                       u.u_offset = 0;
-               else
-                       u.u_offset = fp->f_un.f_offset;
-               if((ip->i_mode&(IFCHR&IFBLK)) == 0)
-                       plock(ip);
-               if(mode == FREAD)
-                       readi(ip);
-               else
-                       writei(ip);
-               if((ip->i_mode&(IFCHR&IFBLK)) == 0)
-                       prele(ip);
-               if ((fp->f_flag&FMP) == 0)
-                       fp->f_un.f_offset += uap->count-u.u_count;
-       }
-       u.u_r.r_val1 = uap->count-u.u_count;
-}
-
-/*
- * open system call
- */
-open()
-{
-       register struct inode *ip;
-       register struct a {
-               char    *fname;
-               int     rwmode;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       ip = namei(uchar, 0);
-       if(ip == NULL)
-               return;
-       open1(ip, ++uap->rwmode, 0);
-}
-
-/*
- * creat system call
- */
-creat()
-{
-       register struct inode *ip;
-       register struct a {
-               char    *fname;
-               int     fmode;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       ip = namei(uchar, 1);
-       if(ip == NULL) {
-               if(u.u_error)
-                       return;
-               ip = maknode(uap->fmode&07777&(~ISVTX));
-               if (ip==NULL)
-                       return;
-               open1(ip, FWRITE, 2);
-       } else
-               open1(ip, FWRITE, 1);
-}
-
-/*
- * common code for open and creat.
- * Check permissions, allocate an open file structure,
- * and call the device open routine if any.
- */
-open1(ip, mode, trf)
-register struct inode *ip;
-register mode;
-{
-       register struct file *fp;
-       int i;
-
-       if(trf != 2) {
-               if(mode&FREAD)
-                       access(ip, IREAD);
-               if(mode&FWRITE) {
-                       access(ip, IWRITE);
-                       if((ip->i_mode&IFMT) == IFDIR)
-                               u.u_error = EISDIR;
-               }
-       }
-       if(u.u_error)
-               goto out;
-       if(trf == 1)
-               itrunc(ip);
-       prele(ip);
-       if ((fp = falloc()) == NULL)
-               goto out;
-       fp->f_flag = mode&(FREAD|FWRITE);
-       fp->f_inode = ip;
-       i = u.u_r.r_val1;
-       openi(ip, mode&FWRITE);
-       if(u.u_error == 0)
-               return;
-       u.u_ofile[i] = NULL;
-       fp->f_count--;
-
-out:
-       iput(ip);
-}
-
-/*
- * close system call
- */
-close()
-{
-       register struct file *fp;
-       register struct a {
-               int     fdes;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       fp = getf(uap->fdes);
-       if(fp == NULL)
-               return;
-       u.u_ofile[uap->fdes] = NULL;
-       closef(fp);
-}
-
-/*
- * seek system call
- */
-seek()
-{
-       register struct file *fp;
-       register struct a {
-               int     fdes;
-               off_t   off;
-               int     sbase;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       fp = getf(uap->fdes);
-       if(fp == NULL)
-               return;
-       if(fp->f_flag&(FPIPE|FMP)) {
-               u.u_error = ESPIPE;
-               return;
-       }
-       if(uap->sbase == 1)
-               uap->off += fp->f_un.f_offset;
-       else if(uap->sbase == 2)
-               uap->off += fp->f_inode->i_size;
-       fp->f_un.f_offset = uap->off;
-       u.u_r.r_off = uap->off;
-}
-
-/*
- * link system call
- */
-link()
-{
-       register struct inode *ip, *xp;
-       register struct a {
-               char    *target;
-               char    *linkname;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       ip = namei(uchar, 0);
-       if(ip == NULL)
-               return;
-       if((ip->i_mode&IFMT)==IFDIR && !suser())
-               goto out;
-       /*
-        * Unlock to avoid possibly hanging the namei.
-        * Sadly, this means races. (Suppose someone
-        * deletes the file in the meantime?)
-        * Nor can it be locked again later
-        * because then there will be deadly
-        * embraces.
-        */
-       prele(ip);
-       u.u_dirp = (caddr_t)uap->linkname;
-       xp = namei(uchar, 1);
-       if(xp != NULL) {
-               u.u_error = EEXIST;
-               iput(xp);
-               goto out;
-       }
-       if (u.u_error)
-               goto out;
-       if(u.u_pdir->i_dev != ip->i_dev) {
-               iput(u.u_pdir);
-               u.u_error = EXDEV;
-               goto out;
-       }
-       wdir(ip);
-       if (u.u_error==0) {
-               ip->i_nlink++;
-               ip->i_flag |= ICHG;
-       }
-
-out:
-       iput(ip);
-}
-
-/*
- * mknod system call
- */
-mknod()
-{
-       register struct inode *ip;
-       register struct a {
-               char    *fname;
-               int     fmode;
-               int     dev;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       if(suser()) {
-               ip = namei(uchar, 1);
-               if(ip != NULL) {
-                       u.u_error = EEXIST;
-                       goto out;
-               }
-       }
-       if(u.u_error)
-               return;
-       ip = maknode(uap->fmode);
-       if (ip == NULL)
-               return;
-       ip->i_un.i_rdev = (dev_t)uap->dev;
-
-out:
-       iput(ip);
-}
-
-/*
- * access system call
- */
-saccess()
-{
-       register svuid, svgid;
-       register struct inode *ip;
-       register struct a {
-               char    *fname;
-               int     fmode;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       svuid = u.u_uid;
-       svgid = u.u_gid;
-       u.u_uid = u.u_ruid;
-       u.u_gid = u.u_rgid;
-       ip = namei(uchar, 0);
-       if (ip != NULL) {
-               if (uap->fmode&(IREAD>>6))
-                       access(ip, IREAD);
-               if (uap->fmode&(IWRITE>>6))
-                       access(ip, IWRITE);
-               if (uap->fmode&(IEXEC>>6))
-                       access(ip, IEXEC);
-               iput(ip);
-       }
-       u.u_uid = svuid;
-       u.u_gid = svgid;
-}
diff --git a/usr/sys/sys/sys3.c b/usr/sys/sys/sys3.c
deleted file mode 100644 (file)
index 1523d25..0000000
+++ /dev/null
@@ -1,255 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/mount.h"
-#include "../h/ino.h"
-#include "../h/reg.h"
-#include "../h/buf.h"
-#include "../h/filsys.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/inode.h"
-#include "../h/file.h"
-#include "../h/conf.h"
-#include "../h/stat.h"
-
-/*
- * the fstat system call.
- */
-fstat()
-{
-       register struct file *fp;
-       register struct a {
-               int     fdes;
-               struct stat *sb;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       fp = getf(uap->fdes);
-       if(fp == NULL)
-               return;
-       stat1(fp->f_inode, uap->sb, fp->f_flag&FPIPE? fp->f_un.f_offset: 0);
-}
-
-/*
- * the stat system call.
- */
-stat()
-{
-       register struct inode *ip;
-       register struct a {
-               char    *fname;
-               struct stat *sb;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       ip = namei(uchar, 0);
-       if(ip == NULL)
-               return;
-       stat1(ip, uap->sb, (off_t)0);
-       iput(ip);
-}
-
-/*
- * The basic routine for fstat and stat:
- * get the inode and pass appropriate parts back.
- */
-stat1(ip, ub, pipeadj)
-register struct inode *ip;
-struct stat *ub;
-off_t pipeadj;
-{
-       register struct dinode *dp;
-       register struct buf *bp;
-       struct stat ds;
-
-       iupdat(ip, &time, &time);
-       /*
-        * first copy from inode table
-        */
-       ds.st_dev = ip->i_dev;
-       ds.st_ino = ip->i_number;
-       ds.st_mode = ip->i_mode;
-       ds.st_nlink = ip->i_nlink;
-       ds.st_uid = ip->i_uid;
-       ds.st_gid = ip->i_gid;
-       ds.st_rdev = (dev_t)ip->i_un.i_rdev;
-       ds.st_size = ip->i_size - pipeadj;
-       /*
-        * next the dates in the disk
-        */
-       bp = bread(ip->i_dev, itod(ip->i_number));
-       dp = bp->b_un.b_dino;
-       dp += itoo(ip->i_number);
-       ds.st_atime = dp->di_atime;
-       ds.st_mtime = dp->di_mtime;
-       ds.st_ctime = dp->di_ctime;
-       brelse(bp);
-       if (copyout((caddr_t)&ds, (caddr_t)ub, sizeof(ds)) < 0)
-               u.u_error = EFAULT;
-}
-
-/*
- * the dup system call.
- */
-dup()
-{
-       register struct file *fp;
-       register struct a {
-               int     fdes;
-               int     fdes2;
-       } *uap;
-       register i, m;
-
-       uap = (struct a *)u.u_ap;
-       m = uap->fdes & ~077;
-       uap->fdes &= 077;
-       fp = getf(uap->fdes);
-       if(fp == NULL)
-               return;
-       if ((m&0100) == 0) {
-               if ((i = ufalloc()) < 0)
-                       return;
-       } else {
-               i = uap->fdes2;
-               if (i<0 || i>=NOFILE) {
-                       u.u_error = EBADF;
-                       return;
-               }
-               u.u_r.r_val1 = i;
-       }
-       if (i!=uap->fdes) {
-               if (u.u_ofile[i]!=NULL)
-                       closef(u.u_ofile[i]);
-               u.u_ofile[i] = fp;
-               fp->f_count++;
-       }
-}
-
-/*
- * the mount system call.
- */
-smount()
-{
-       dev_t dev;
-       register struct inode *ip;
-       register struct mount *mp;
-       struct mount *smp;
-       register struct filsys *fp;
-       struct buf *bp;
-       register struct a {
-               char    *fspec;
-               char    *freg;
-               int     ronly;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       dev = getmdev();
-       if(u.u_error)
-               return;
-       u.u_dirp = (caddr_t)uap->freg;
-       ip = namei(uchar, 0);
-       if(ip == NULL)
-               return;
-       if(ip->i_count!=1 || (ip->i_mode&(IFBLK&IFCHR))!=0)
-               goto out;
-       smp = NULL;
-       for(mp = &mount[0]; mp < &mount[NMOUNT]; mp++) {
-               if(mp->m_bufp != NULL) {
-                       if(dev == mp->m_dev)
-                               goto out;
-               } else
-               if(smp == NULL)
-                       smp = mp;
-       }
-       mp = smp;
-       if(mp == NULL)
-               goto out;
-       (*bdevsw[major(dev)].d_open)(dev, !uap->ronly);
-       if(u.u_error)
-               goto out;
-       bp = bread(dev, SUPERB);
-       if(u.u_error) {
-               brelse(bp);
-               goto out1;
-       }
-       mp->m_inodp = ip;
-       mp->m_dev = dev;
-       mp->m_bufp = geteblk();
-       bcopy((caddr_t)bp->b_un.b_addr, mp->m_bufp->b_un.b_addr, BSIZE);
-       fp = mp->m_bufp->b_un.b_filsys;
-       fp->s_ilock = 0;
-       fp->s_flock = 0;
-       fp->s_ronly = uap->ronly & 1;
-       brelse(bp);
-       ip->i_flag |= IMOUNT;
-       prele(ip);
-       return;
-
-out:
-       u.u_error = EBUSY;
-out1:
-       iput(ip);
-}
-
-/*
- * the umount system call.
- */
-sumount()
-{
-       dev_t dev;
-       register struct inode *ip;
-       register struct mount *mp;
-       struct buf *bp;
-       register struct a {
-               char    *fspec;
-       };
-
-       dev = getmdev();
-       if(u.u_error)
-               return;
-       xumount(dev);   /* remove unused sticky files from text table */
-       update();
-       for(mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
-               if(mp->m_bufp != NULL && dev == mp->m_dev)
-                       goto found;
-       u.u_error = EINVAL;
-       return;
-
-found:
-       for(ip = &inode[0]; ip < &inode[NINODE]; ip++)
-               if(ip->i_number != 0 && dev == ip->i_dev) {
-                       u.u_error = EBUSY;
-                       return;
-               }
-       (*bdevsw[major(dev)].d_close)(dev, 0);
-       ip = mp->m_inodp;
-       ip->i_flag &= ~IMOUNT;
-       plock(ip);
-       iput(ip);
-       bp = mp->m_bufp;
-       mp->m_bufp = NULL;
-       brelse(bp);
-}
-
-/*
- * Common code for mount and umount.
- * Check that the user's argument is a reasonable
- * thing on which to mount, and return the device number if so.
- */
-dev_t
-getmdev()
-{
-       dev_t dev;
-       register struct inode *ip;
-
-       ip = namei(uchar, 0);
-       if(ip == NULL)
-               return(NODEV);
-       if((ip->i_mode&IFMT) != IFBLK)
-               u.u_error = ENOTBLK;
-       dev = (dev_t)ip->i_un.i_rdev;
-       if(major(dev) >= nblkdev)
-               u.u_error = ENXIO;
-       iput(ip);
-       return(dev);
-}
diff --git a/usr/sys/sys/sys4.c b/usr/sys/sys/sys4.c
deleted file mode 100644 (file)
index c8fba7c..0000000
+++ /dev/null
@@ -1,422 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/reg.h"
-#include "../h/inode.h"
-#include "../h/proc.h"
-#include "../h/timeb.h"
-
-/*
- * Everything in this file is a routine implementing a system call.
- */
-
-/*
- * return the current time (old-style entry)
- */
-gtime()
-{
-       u.u_r.r_time = time;
-}
-
-/*
- * New time entry-- return TOD with milliseconds, timezone,
- * DST flag
- */
-ftime()
-{
-       register struct a {
-               struct  timeb   *tp;
-       } *uap;
-       struct timeb t;
-       register unsigned ms;
-
-       uap = (struct a *)u.u_ap;
-       spl7();
-       t.time = time;
-       ms = lbolt;
-       spl0();
-       if (ms > HZ) {
-               ms -= HZ;
-               t.time++;
-       }
-       t.millitm = (1000*ms)/HZ;
-       t.timezone = TIMEZONE;
-       t.dstflag = DSTFLAG;
-       if (copyout((caddr_t)&t, (caddr_t)uap->tp, sizeof(t)) < 0)
-               u.u_error = EFAULT;
-}
-
-/*
- * Set the time
- */
-stime()
-{
-       register struct a {
-               time_t  time;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       if(suser())
-               time = uap->time;
-}
-
-setuid()
-{
-       register uid;
-       register struct a {
-               int     uid;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       uid = uap->uid;
-       if(u.u_ruid == uid || suser()) {
-               u.u_uid = uid;
-               u.u_procp->p_uid = uid;
-               u.u_ruid = uid;
-       }
-}
-
-getuid()
-{
-
-       u.u_r.r_val1 = u.u_ruid;
-       u.u_r.r_val2 = u.u_uid;
-}
-
-setgid()
-{
-       register gid;
-       register struct a {
-               int     gid;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       gid = uap->gid;
-       if(u.u_rgid == gid || suser()) {
-               u.u_gid = gid;
-               u.u_rgid = gid;
-       }
-}
-
-getgid()
-{
-
-       u.u_r.r_val1 = u.u_rgid;
-       u.u_r.r_val2 = u.u_gid;
-}
-
-getpid()
-{
-       u.u_r.r_val1 = u.u_procp->p_pid;
-       u.u_r.r_val2 = u.u_procp->p_ppid;
-}
-
-sync()
-{
-
-       update();
-}
-
-nice()
-{
-       register n;
-       register struct a {
-               int     niceness;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       n = uap->niceness;
-       if(n < 0 && !suser())
-               n = 0;
-       n += u.u_procp->p_nice;
-       if(n >= 2*NZERO)
-               n = 2*NZERO -1;
-       if(n < 0)
-               n = 0;
-       u.u_procp->p_nice = n;
-}
-
-/*
- * Unlink system call.
- * Hard to avoid races here, especially
- * in unlinking directories.
- */
-unlink()
-{
-       register struct inode *ip, *pp;
-       struct a {
-               char    *fname;
-       };
-
-       pp = namei(uchar, 2);
-       if(pp == NULL)
-               return;
-       /*
-        * Check for unlink(".")
-        * to avoid hanging on the iget
-        */
-       if (pp->i_number == u.u_dent.d_ino) {
-               ip = pp;
-               ip->i_count++;
-       } else
-               ip = iget(pp->i_dev, u.u_dent.d_ino);
-       if(ip == NULL)
-               goto out1;
-       if((ip->i_mode&IFMT)==IFDIR && !suser())
-               goto out;
-       /*
-        * Don't unlink a mounted file.
-        */
-       if (ip->i_dev != pp->i_dev) {
-               u.u_error = EBUSY;
-               goto out;
-       }
-       if (ip->i_flag&ITEXT)
-               xrele(ip);      /* try once to free text */
-       if (ip->i_flag&ITEXT && ip->i_nlink==1) {
-               u.u_error = ETXTBSY;
-               goto out;
-       }
-       u.u_offset -= sizeof(struct direct);
-       u.u_base = (caddr_t)&u.u_dent;
-       u.u_count = sizeof(struct direct);
-       u.u_dent.d_ino = 0;
-       writei(pp);
-       ip->i_nlink--;
-       ip->i_flag |= ICHG;
-
-out:
-       iput(ip);
-out1:
-       iput(pp);
-}
-chdir()
-{
-       chdirec(&u.u_cdir);
-}
-
-chroot()
-{
-       if (suser())
-               chdirec(&u.u_rdir);
-}
-
-chdirec(ipp)
-register struct inode **ipp;
-{
-       register struct inode *ip;
-       struct a {
-               char    *fname;
-       };
-
-       ip = namei(uchar, 0);
-       if(ip == NULL)
-               return;
-       if((ip->i_mode&IFMT) != IFDIR) {
-               u.u_error = ENOTDIR;
-               goto bad;
-       }
-       if(access(ip, IEXEC))
-               goto bad;
-       prele(ip);
-       if (*ipp) {
-               plock(*ipp);
-               iput(*ipp);
-       }
-       *ipp = ip;
-       return;
-
-bad:
-       iput(ip);
-}
-
-chmod()
-{
-       register struct inode *ip;
-       register struct a {
-               char    *fname;
-               int     fmode;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       if ((ip = owner()) == NULL)
-               return;
-       ip->i_mode &= ~07777;
-       if (u.u_uid)
-               uap->fmode &= ~ISVTX;
-       ip->i_mode |= uap->fmode&07777;
-       ip->i_flag |= ICHG;
-       if (ip->i_flag&ITEXT && (ip->i_mode&ISVTX)==0)
-               xrele(ip);
-       iput(ip);
-}
-
-chown()
-{
-       register struct inode *ip;
-       register struct a {
-               char    *fname;
-               int     uid;
-               int     gid;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       if (!suser() || (ip = owner()) == NULL)
-               return;
-       ip->i_uid = uap->uid;
-       ip->i_gid = uap->gid;
-       ip->i_flag |= ICHG;
-       iput(ip);
-}
-
-ssig()
-{
-       register a;
-       struct a {
-               int     signo;
-               int     fun;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       a = uap->signo;
-       if(a<=0 || a>=NSIG || a==SIGKIL) {
-               u.u_error = EINVAL;
-               return;
-       }
-       u.u_r.r_val1 = u.u_signal[a];
-       u.u_signal[a] = uap->fun;
-       u.u_procp->p_sig &= ~(1<<(a-1));
-}
-
-kill()
-{
-       register struct proc *p, *q;
-       register a;
-       register struct a {
-               int     pid;
-               int     signo;
-       } *uap;
-       int f, priv;
-
-       uap = (struct a *)u.u_ap;
-       f = 0;
-       a = uap->pid;
-       priv = 0;
-       if (a==-1 && u.u_uid==0) {
-               priv++;
-               a = 0;
-       }
-       q = u.u_procp;
-       for(p = &proc[0]; p < &proc[NPROC]; p++) {
-               if(p->p_stat == NULL)
-                       continue;
-               if(a != 0 && p->p_pid != a)
-                       continue;
-               if(a==0 && ((p->p_pgrp!=q->p_pgrp&&priv==0) || p<=&proc[1]))
-                       continue;
-               if(u.u_uid != 0 && u.u_uid != p->p_uid)
-                       continue;
-               f++;
-               psignal(p, uap->signo);
-       }
-       if(f == 0)
-               u.u_error = ESRCH;
-}
-
-times()
-{
-       register struct a {
-               time_t  (*times)[4];
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       if (copyout((caddr_t)&u.u_utime, (caddr_t)uap->times, sizeof(*uap->times)) < 0)
-               u.u_error = EFAULT;
-}
-
-profil()
-{
-       register struct a {
-               short   *bufbase;
-               unsigned bufsize;
-               unsigned pcoffset;
-               unsigned pcscale;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       u.u_prof.pr_base = uap->bufbase;
-       u.u_prof.pr_size = uap->bufsize;
-       u.u_prof.pr_off = uap->pcoffset;
-       u.u_prof.pr_scale = uap->pcscale;
-}
-
-/*
- * alarm clock signal
- */
-alarm()
-{
-       register struct proc *p;
-       register c;
-       register struct a {
-               int     deltat;
-       } *uap;
-
-       uap = (struct a *)u.u_ap;
-       p = u.u_procp;
-       c = p->p_clktim;
-       p->p_clktim = uap->deltat;
-       u.u_r.r_val1 = c;
-}
-
-/*
- * indefinite wait.
- * no one should wakeup(&u)
- */
-pause()
-{
-
-       for(;;)
-               sleep((caddr_t)&u, PSLEP);
-}
-
-/*
- * mode mask for creation of files
- */
-umask()
-{
-       register struct a {
-               int     mask;
-       } *uap;
-       register t;
-
-       uap = (struct a *)u.u_ap;
-       t = u.u_cmask;
-       u.u_cmask = uap->mask & 0777;
-       u.u_r.r_val1 = t;
-}
-
-/*
- * Set IUPD and IACC times on file.
- * Can't set ICHG.
- */
-utime()
-{
-       register struct a {
-               char    *fname;
-               time_t  *tptr;
-       } *uap;
-       register struct inode *ip;
-       time_t tv[2];
-
-       uap = (struct a *)u.u_ap;
-       if ((ip = owner()) == NULL)
-               return;
-       if (copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof(tv))) {
-               u.u_error = EFAULT;
-               return;
-       }
-       ip->i_flag |= IACC|IUPD|ICHG;
-       iupdat(ip, &tv[0], &tv[1]);
-       iput(ip);
-}
diff --git a/usr/sys/sys/sysent.c b/usr/sys/sys/sysent.c
deleted file mode 100644 (file)
index 81ca2d6..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-
-/*
- * This table is the switch used to transfer
- * to the appropriate routine for processing a system call.
- * Each row contains the number of arguments expected
- * and a pointer to the routine.
- */
-int    alarm();
-int    mpxchan();
-int    chdir();
-int    chmod();
-int    chown();
-int    chroot();
-int    close();
-int    creat();
-int    dup();
-int    exec();
-int    exece();
-int    fork();
-int    fstat();
-int    getgid();
-int    getpid();
-int    getuid();
-int    gtime();
-int    gtty();
-int    ioctl();
-int    kill();
-int    link();
-int    mknod();
-int    nice();
-int    nosys();
-int    nullsys();
-int    open();
-int    pause();
-int    pipe();
-int    profil();
-int    ptrace();
-int    read();
-int    rexit();
-int    saccess();
-int    sbreak();
-int    seek();
-int    setgid();
-int    setuid();
-int    smount();
-int    ssig();
-int    stat();
-int    stime();
-int    stty();
-int    sumount();
-int    ftime();
-int    sync();
-int    sysacct();
-int    syslock();
-int    sysphys();
-int    times();
-int    umask();
-int    unlink();
-int    utime();
-int    wait();
-int    write();
-
-struct sysent sysent[64] =
-{
-       0, 0, nullsys,                  /*  0 = indir */
-       1, 1, rexit,                    /*  1 = exit */
-       0, 0, fork,                     /*  2 = fork */
-       3, 1, read,                     /*  3 = read */
-       3, 1, write,                    /*  4 = write */
-       2, 0, open,                     /*  5 = open */
-       1, 1, close,                    /*  6 = close */
-       0, 0, wait,                     /*  7 = wait */
-       2, 0, creat,                    /*  8 = creat */
-       2, 0, link,                     /*  9 = link */
-       1, 0, unlink,                   /* 10 = unlink */
-       2, 0, exec,                     /* 11 = exec */
-       1, 0, chdir,                    /* 12 = chdir */
-       0, 0, gtime,                    /* 13 = time */
-       3, 0, mknod,                    /* 14 = mknod */
-       2, 0, chmod,                    /* 15 = chmod */
-       3, 0, chown,                    /* 16 = chown; now 3 args */
-       1, 0, sbreak,                   /* 17 = break */
-       2, 0, stat,                     /* 18 = stat */
-       4, 1, seek,                     /* 19 = seek; now 3 args */
-       0, 0, getpid,                   /* 20 = getpid */
-       3, 0, smount,                   /* 21 = mount */
-       1, 0, sumount,                  /* 22 = umount */
-       1, 1, setuid,                   /* 23 = setuid */
-       0, 0, getuid,                   /* 24 = getuid */
-       2, 2, stime,                    /* 25 = stime */
-       4, 1, ptrace,                   /* 26 = ptrace */
-       1, 1, alarm,                    /* 27 = alarm */
-       2, 1, fstat,                    /* 28 = fstat */
-       0, 0, pause,                    /* 29 = pause */
-       2, 0, utime,                    /* 30 = utime */
-       2, 1, stty,                     /* 31 = stty */
-       2, 1, gtty,                     /* 32 = gtty */
-       2, 0, saccess,                  /* 33 = access */
-       1, 1, nice,                     /* 34 = nice */
-       1, 0, ftime,                    /* 35 = ftime; formerly sleep */
-       0, 0, sync,                     /* 36 = sync */
-       2, 1, kill,                     /* 37 = kill */
-       0, 0, nullsys,                  /* 38 = switch; inoperative */
-       0, 0, nullsys,                  /* 39 = setpgrp (not in yet) */
-       1, 1, nosys,                    /* 40 = tell (obsolete) */
-       2, 2, dup,                      /* 41 = dup */
-       0, 0, pipe,                     /* 42 = pipe */
-       1, 0, times,                    /* 43 = times */
-       4, 0, profil,                   /* 44 = prof */
-       0, 0, nosys,                    /* 45 = unused */
-       1, 1, setgid,                   /* 46 = setgid */
-       0, 0, getgid,                   /* 47 = getgid */
-       2, 0, ssig,                     /* 48 = sig */
-       0, 0, nosys,                    /* 49 = reserved for USG */
-       0, 0, nosys,                    /* 50 = reserved for USG */
-       1, 0, sysacct,                  /* 51 = turn acct off/on */
-       3, 0, sysphys,                  /* 52 = set user physical addresses */
-       1, 0, syslock,                  /* 53 = lock user in core */
-       3, 0, ioctl,                    /* 54 = ioctl */
-       0, 0, nosys,                    /* 55 = readwrite (in abeyance) */
-       4, 0, mpxchan,                  /* 56 = creat mpx comm channel */
-       0, 0, nosys,                    /* 57 = reserved for USG */
-       0, 0, nosys,                    /* 58 = reserved for USG */
-       3, 0, exece,                    /* 59 = exece */
-       1, 0, umask,                    /* 60 = umask */
-       1, 0, chroot,                   /* 61 = chroot */
-       0, 0, nosys,                    /* 62 = x */
-       0, 0, nosys                     /* 63 = used internally */
-};
diff --git a/usr/sys/sys/text.c b/usr/sys/sys/text.c
deleted file mode 100644 (file)
index 30540bb..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/map.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/proc.h"
-#include "../h/text.h"
-#include "../h/inode.h"
-#include "../h/buf.h"
-#include "../h/seg.h"
-
-/*
- * Swap out process p.
- * The ff flag causes its core to be freed--
- * it may be off when called to create an image for a
- * child process in newproc.
- * Os is the old size of the data area of the process,
- * and is supplied during core expansion swaps.
- *
- * panic: out of swap space
- */
-xswap(p, ff, os)
-register struct proc *p;
-{
-       register a;
-
-       if(os == 0)
-               os = p->p_size;
-       a = malloc(swapmap, ctod(p->p_size));
-       if(a == NULL)
-               panic("out of swap space");
-       p->p_flag |= SLOCK;
-       xccdec(p->p_textp);
-       swap(a, p->p_addr, os, B_WRITE);
-       if(ff)
-               mfree(coremap, os, p->p_addr);
-       p->p_addr = a;
-       p->p_flag &= ~(SLOAD|SLOCK);
-       p->p_time = 0;
-       if(runout) {
-               runout = 0;
-               wakeup((caddr_t)&runout);
-       }
-}
-
-/*
- * relinquish use of the shared text segment
- * of a process.
- */
-xfree()
-{
-       register struct text *xp;
-       register struct inode *ip;
-
-       if((xp=u.u_procp->p_textp) == NULL)
-               return;
-       xlock(xp);
-       xp->x_flag &= ~XLOCK;
-       u.u_procp->p_textp = NULL;
-       ip = xp->x_iptr;
-       if(--xp->x_count==0 && (ip->i_mode&ISVTX)==0) {
-               xp->x_iptr = NULL;
-               mfree(swapmap, ctod(xp->x_size), xp->x_daddr);
-               mfree(coremap, xp->x_size, xp->x_caddr);
-               ip->i_flag &= ~ITEXT;
-               if (ip->i_flag&ILOCK)
-                       ip->i_count--;
-               else
-                       iput(ip);
-       } else
-               xccdec(xp);
-}
-
-/*
- * Attach to a shared text segment.
- * If there is no shared text, just return.
- * If there is, hook up to it:
- * if it is not currently being used, it has to be read
- * in from the inode (ip); the written bit is set to force it
- * to be written out as appropriate.
- * If it is being used, but is not currently in core,
- * a swap has to be done to get it back.
- */
-xalloc(ip)
-register struct inode *ip;
-{
-       register struct text *xp;
-       register unsigned ts;
-       register struct text *xp1;
-
-       if(u.u_exdata.ux_tsize == 0)
-               return;
-       xp1 = NULL;
-       for (xp = &text[0]; xp < &text[NTEXT]; xp++) {
-               if(xp->x_iptr == NULL) {
-                       if(xp1 == NULL)
-                               xp1 = xp;
-                       continue;
-               }
-               if(xp->x_iptr == ip) {
-                       xlock(xp);
-                       xp->x_count++;
-                       u.u_procp->p_textp = xp;
-                       if (xp->x_ccount == 0)
-                               xexpand(xp);
-                       else
-                               xp->x_ccount++;
-                       xunlock(xp);
-                       return;
-               }
-       }
-       if((xp=xp1) == NULL) {
-               printf("out of text");
-               psignal(u.u_procp, SIGKIL);
-               return;
-       }
-       xp->x_flag = XLOAD|XLOCK;
-       xp->x_count = 1;
-       xp->x_ccount = 0;
-       xp->x_iptr = ip;
-       ip->i_flag |= ITEXT;
-       ip->i_count++;
-       ts = btoc(u.u_exdata.ux_tsize);
-       xp->x_size = ts;
-       if((xp->x_daddr = malloc(swapmap, (int)ctod(ts))) == NULL)
-               panic("out of swap space");
-       u.u_procp->p_textp = xp;
-       xexpand(xp);
-       estabur(ts, (unsigned)0, (unsigned)0, 0, RW);
-       u.u_count = u.u_exdata.ux_tsize;
-       u.u_offset = sizeof(u.u_exdata);
-       u.u_base = 0;
-       u.u_segflg = 2;
-       u.u_procp->p_flag |= SLOCK;
-       readi(ip);
-       u.u_procp->p_flag &= ~SLOCK;
-       u.u_segflg = 0;
-       xp->x_flag = XWRIT;
-}
-
-/*
- * Assure core for text segment
- * Text must be locked to keep someone else from
- * freeing it in the meantime.
- * x_ccount must be 0.
- */
-xexpand(xp)
-register struct text *xp;
-{
-       if ((xp->x_caddr = malloc(coremap, xp->x_size)) != NULL) {
-               if ((xp->x_flag&XLOAD)==0)
-                       swap(xp->x_daddr, xp->x_caddr, xp->x_size, B_READ);
-               xp->x_ccount++;
-               xunlock(xp);
-               return;
-       }
-       if (save(u.u_ssav)) {
-               sureg();
-               return;
-       }
-       xswap(u.u_procp, 1, 0);
-       xunlock(xp);
-       u.u_procp->p_flag |= SSWAP;
-       qswtch();
-       /* no return */
-}
-
-/*
- * Lock and unlock a text segment from swapping
- */
-xlock(xp)
-register struct text *xp;
-{
-
-       while(xp->x_flag&XLOCK) {
-               xp->x_flag |= XWANT;
-               sleep((caddr_t)xp, PSWP);
-       }
-       xp->x_flag |= XLOCK;
-}
-
-xunlock(xp)
-register struct text *xp;
-{
-
-       if (xp->x_flag&XWANT)
-               wakeup((caddr_t)xp);
-       xp->x_flag &= ~(XLOCK|XWANT);
-}
-
-/*
- * Decrement the in-core usage count of a shared text segment.
- * When it drops to zero, free the core space.
- */
-xccdec(xp)
-register struct text *xp;
-{
-
-       if (xp==NULL || xp->x_ccount==0)
-               return;
-       xlock(xp);
-       if (--xp->x_ccount==0) {
-               if (xp->x_flag&XWRIT) {
-                       xp->x_flag &= ~XWRIT;
-                       swap(xp->x_daddr,xp->x_caddr,xp->x_size,B_WRITE);
-               }
-               mfree(coremap, xp->x_size, xp->x_caddr);
-       }
-       xunlock(xp);
-}
-
-/*
- * free the swap image of all unused saved-text text segments
- * which are from device dev (used by umount system call).
- */
-xumount(dev)
-register dev;
-{
-       register struct text *xp;
-
-       for (xp = &text[0]; xp < &text[NTEXT]; xp++) 
-               if (xp->x_iptr!=NULL && dev==xp->x_iptr->i_dev)
-                       xuntext(xp);
-}
-
-/*
- * remove a shared text segment from the text table, if possible.
- */
-xrele(ip)
-register struct inode *ip;
-{
-       register struct text *xp;
-
-       if (ip->i_flag&ITEXT==0)
-               return;
-       for (xp = &text[0]; xp < &text[NTEXT]; xp++)
-               if (ip==xp->x_iptr)
-                       xuntext(xp);
-}
-
-/*
- * remove text image from the text table.
- * the use count must be zero.
- */
-xuntext(xp)
-register struct text *xp;
-{
-       register struct inode *ip;
-
-       xlock(xp);
-       if (xp->x_count) {
-               xunlock(xp);
-               return;
-       }
-       ip = xp->x_iptr;
-       xp->x_flag &= ~XLOCK;
-       xp->x_iptr = NULL;
-       mfree(swapmap, ctod(xp->x_size), xp->x_daddr);
-       ip->i_flag &= ~ITEXT;
-       if (ip->i_flag&ILOCK)
-               ip->i_count--;
-       else
-               iput(ip);
-}
diff --git a/usr/sys/sys/trap.c b/usr/sys/sys/trap.c
deleted file mode 100644 (file)
index b29229d..0000000
+++ /dev/null
@@ -1,251 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/proc.h"
-#include "../h/reg.h"
-#include "../h/seg.h"
-
-#define        EBIT    1               /* user error bit in PS: C-bit */
-#define        SETD    0170011         /* SETD instruction */
-#define        SYS     0104400         /* sys (trap) instruction */
-#define        USER    020             /* user-mode flag added to dev */
-#define        MEMORY  ((physadr)0177740) /* 11/70 "memory" subsystem */
-
-/*
- * Offsets of the user's registers relative to
- * the saved r0. See reg.h
- */
-char   regloc[9] =
-{
-       R0, R1, R2, R3, R4, R5, R6, R7, RPS
-};
-
-/*
- * Called from l40.s or l45.s when a processor trap occurs.
- * The arguments are the words saved on the system stack
- * by the hardware and software during the trap processing.
- * Their order is dictated by the hardware and the details
- * of C's calling sequence. They are peculiar in that
- * this call is not 'by value' and changed user registers
- * get copied back on return.
- * dev is the kind of trap that occurred.
- */
-trap(dev, sp, r1, nps, r0, pc, ps)
-int *pc;
-dev_t dev;
-{
-       register i;
-       register *a;
-       register struct sysent *callp;
-       int (*fetch)();
-       time_t syst;
-
-       syst = u.u_stime;
-       u.u_fpsaved = 0;
-       if ((ps&UMODE) == UMODE)
-               dev |= USER;
-       u.u_ar0 = &r0;
-       switch(minor(dev)) {
-
-       /*
-        * Trap not expected.
-        * Usually a kernel mode bus error.
-        * The numbers printed are used to
-        * find the hardware PS/PC as follows.
-        * (all numbers in octal 18 bits)
-        *      address_of_saved_ps =
-        *              (ka6*0100) + aps - 0140000;
-        *      address_of_saved_pc =
-        *              address_of_saved_ps - 2;
-        */
-       default:
-               printf("ka6 = %o\n", ka6->r[0]);
-               printf("aps = %o\n", &ps);
-               printf("pc = %o ps = %o\n", pc, ps);
-               printf("trap type %o\n", dev);
-               panic("trap");
-
-       case 0+USER: /* bus error */
-               i = SIGBUS;
-               break;
-
-       /*
-        * If illegal instructions are not
-        * being caught and the offending instruction
-        * is a SETD, the trap is ignored.
-        * This is because C produces a SETD at
-        * the beginning of every program which
-        * will trap on CPUs without 11/45 FPU.
-        */
-       case 1+USER: /* illegal instruction */
-               if(fuiword((caddr_t)(pc-1)) == SETD && u.u_signal[SIGINS] == 0)
-                       goto out;
-               i = SIGINS;
-               break;
-
-       case 2+USER: /* bpt or trace */
-               i = SIGTRC;
-               ps &= ~TBIT;
-               break;
-
-       case 3+USER: /* iot */
-               i = SIGIOT;
-               break;
-
-       case 5+USER: /* emt */
-               i = SIGEMT;
-               break;
-
-       case 6+USER: /* sys call */
-               u.u_error = 0;
-               ps &= ~EBIT;
-               a = pc;
-               callp = &sysent[fuiword((caddr_t)(a-1))&077];
-               if (callp == sysent) { /* indirect */
-                       a = (int *)fuiword((caddr_t)(a));
-                       pc++;
-                       i = fuword((caddr_t)a);
-                       a++;
-                       if ((i & ~077) != SYS)
-                               i = 077;        /* illegal */
-                       callp = &sysent[i&077];
-                       fetch = fuword;
-               } else {
-                       pc += callp->sy_narg - callp->sy_nrarg;
-                       fetch = fuiword;
-               }
-               for (i=0; i<callp->sy_nrarg; i++)
-                       u.u_arg[i] = u.u_ar0[regloc[i]];
-               for(; i<callp->sy_narg; i++)
-                       u.u_arg[i] = (*fetch)((caddr_t)a++);
-               u.u_dirp = (caddr_t)u.u_arg[0];
-               u.u_r.r_val1 = u.u_ar0[R0];
-               u.u_r.r_val2 = u.u_ar0[R1];
-               u.u_ap = u.u_arg;
-               if (save(u.u_qsav)) {
-                       if (u.u_error==0)
-                               u.u_error = EINTR;
-               } else {
-                       (*callp->sy_call)();
-               }
-               if(u.u_error) {
-                       ps |= EBIT;
-                       u.u_ar0[R0] = u.u_error;
-               } else {
-                       u.u_ar0[R0] = u.u_r.r_val1;
-                       u.u_ar0[R1] = u.u_r.r_val2;
-               }
-               goto out;
-
-       /*
-        * Since the floating exception is an
-        * imprecise trap, a user generated
-        * trap may actually come from kernel
-        * mode. In this case, a signal is sent
-        * to the current process to be picked
-        * up later.
-        */
-       case 8: /* floating exception */
-               stst(&u.u_fper);        /* save error code */
-               psignal(u.u_procp, SIGFPT);
-               return;
-
-       case 8+USER:
-               i = SIGFPT;
-               stst(&u.u_fper);
-               break;
-
-       /*
-        * If the user SP is below the stack segment,
-        * grow the stack automatically.
-        * This relies on the ability of the hardware
-        * to restart a half executed instruction.
-        * On the 11/40 this is not the case and
-        * the routine backup/l40.s may fail.
-        * The classic example is on the instruction
-        *      cmp     -(sp),-(sp)
-        */
-       case 9+USER: /* segmentation exception */
-       {
-       int     osp;
-
-               osp = sp;
-               if(backup(u.u_ar0) == 0)
-                       if(grow((unsigned)osp))
-                               goto out;
-               i = SIGSEG;
-               break;
-       }
-
-       /*
-        * The code here is a half-hearted
-        * attempt to do something with all
-        * of the 11/70 parity registers.
-        * In fact, there is little that
-        * can be done.
-        */
-       case 10:
-       case 10+USER:
-               printf("parity\n");
-               if(cputype == 70) {
-                       for(i=0; i<4; i++)
-                               printf("%o ", MEMORY->r[i]);
-                       printf("\n");
-                       MEMORY->r[2] = -1;
-                       if(dev & USER) {
-                               i = SIGBUS;
-                               break;
-                       }
-               }
-               panic("parity");
-
-       /*
-        * Allow process switch
-        */
-       case USER+12:
-               goto out;
-
-       /*
-        * Locations 0-2 specify this style trap, since
-        * DEC hardware often generates spurious
-        * traps through location 0.  This is a
-        * symptom of hardware problems and may
-        * represent a real interrupt that got
-        * sent to the wrong place.  Watch out
-        * for hangs on disk completion if this message appears.
-        */
-       case 15:
-       case 15+USER:
-               printf("Random interrupt ignored\n");
-               return;
-       }
-       psignal(u.u_procp, i);
-
-out:
-       if(issig()) {
-               psig();
-       }
-       curpri = setpri(u.u_procp);
-       if (runrun)
-               qswtch();
-       if(u.u_prof.pr_scale)
-               addupc((caddr_t)pc, &u.u_prof, (int)(u.u_stime-syst));
-       if (u.u_fpsaved)
-               restfp(&u.u_fps);
-}
-
-/*
- * nonexistent system call-- set fatal error code.
- */
-nosys()
-{
-       u.u_error = EINVAL;
-}
-
-/*
- * Ignored system call
- */
-nullsys()
-{
-}
diff --git a/usr/sys/sys/ureg.c b/usr/sys/sys/ureg.c
deleted file mode 100644 (file)
index 9810aa0..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/proc.h"
-#include "../h/text.h"
-#include "../h/seg.h"
-
-/*
- * Load the user hardware segmentation
- * registers from the software prototype.
- * The software registers must have
- * been setup prior by estabur.
- */
-sureg()
-{
-       register *udp, *uap, *rdp;
-       int *rap, *limudp;
-       int taddr, daddr;
-       struct text *tp;
-
-       taddr = daddr = u.u_procp->p_addr;
-       if ((tp=u.u_procp->p_textp) != NULL)
-               taddr = tp->x_caddr;
-       limudp = &u.u_uisd[16];
-       if (cputype==40)
-               limudp = &u.u_uisd[8];
-       rap = (int *)UISA;
-       rdp = (int *)UISD;
-       uap = &u.u_uisa[0];
-       for (udp = &u.u_uisd[0]; udp < limudp;) {
-               *rap++ = *uap++ + (*udp&TX? taddr: (*udp&ABS? 0: daddr));
-               *rdp++ = *udp++;
-       }
-}
-
-/*
- * Set up software prototype segmentation
- * registers to implement the 3 pseudo
- * text,data,stack segment sizes passed
- * as arguments.
- * The argument sep specifies if the
- * text and data+stack segments are to
- * be separated.
- * The last argument determines whether the text
- * segment is read-write or read-only.
- */
-estabur(nt, nd, ns, sep, xrw)
-unsigned nt, nd, ns;
-{
-       register a, *ap, *dp;
-
-       if(sep) {
-               if(cputype == 40)
-                       goto err;
-               if(ctos(nt) > 8 || ctos(nd)+ctos(ns) > 8)
-                       goto err;
-       } else
-               if(ctos(nt)+ctos(nd)+ctos(ns) > 8)
-                       goto err;
-       if(nt+nd+ns+USIZE > maxmem)
-               goto err;
-       a = 0;
-       ap = &u.u_uisa[0];
-       dp = &u.u_uisd[0];
-       while(nt >= 128) {
-               *dp++ = (127<<8) | xrw|TX;
-               *ap++ = a;
-               a += 128;
-               nt -= 128;
-       }
-       if(nt) {
-               *dp++ = ((nt-1)<<8) | xrw|TX;
-               *ap++ = a;
-       }
-       if(sep)
-       while(ap < &u.u_uisa[8]) {
-               *ap++ = 0;
-               *dp++ = 0;
-       }
-       a = USIZE;
-       while(nd >= 128) {
-               *dp++ = (127<<8) | RW;
-               *ap++ = a;
-               a += 128;
-               nd -= 128;
-       }
-       if(nd) {
-               *dp++ = ((nd-1)<<8) | RW;
-               *ap++ = a;
-               a += nd;
-       }
-       while(ap < &u.u_uisa[8]) {
-               if(*dp &ABS) {
-                       dp++;
-                       ap++;
-                       continue;
-               }
-               *dp++ = 0;
-               *ap++ = 0;
-       }
-       if(sep)
-       while(ap < &u.u_uisa[16]) {
-               if(*dp & ABS) {
-                       dp++;
-                       ap++;
-                       continue;
-               }
-               *dp++ = 0;
-               *ap++ = 0;
-       }
-       a += ns;
-       while(ns >= 128) {
-               a -= 128;
-               ns -= 128;
-               *--dp = (127<<8) | RW;
-               *--ap = a;
-       }
-       if(ns) {
-               *--dp = ((128-ns)<<8) | RW | ED;
-               *--ap = a-128;
-       }
-       if(!sep) {
-               ap = &u.u_uisa[0];
-               dp = &u.u_uisa[8];
-               while(ap < &u.u_uisa[8])
-                       *dp++ = *ap++;
-               ap = &u.u_uisd[0];
-               dp = &u.u_uisd[8];
-               while(ap < &u.u_uisd[8])
-                       *dp++ = *ap++;
-       }
-       sureg();
-       return(0);
-
-err:
-       u.u_error = ENOMEM;
-       return(-1);
-}
diff --git a/usr/t.toc b/usr/t.toc
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/tmp/dummy b/usr/tmp/dummy
new file mode 100644 (file)
index 0000000..e69de29